config.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "config.h"
00010 #include <kglobal.h>
00011 #include <qwhatsthis.h>
00012 #include <qvbox.h>
00013 #include <klocale.h>
00014
00015
00016 extern "C"
00017 {
00018 QObject* allocate_config( KConfig* conf, QWidget* parent )
00019 {
00020 return(new B2Config(conf, parent));
00021 }
00022 }
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 B2Config::B2Config( KConfig* conf, QWidget* parent )
00034 : QObject( parent )
00035 {
00036 KGlobal::locale()->insertCatalogue("kwin_b2_config");
00037 b2Config = new KConfig("kwinb2rc");
00038 gb = new QVBox(parent);
00039
00040 cbColorBorder = new QCheckBox(
00041 i18n("Draw window frames using &titlebar colors"), gb);
00042 QWhatsThis::add(cbColorBorder,
00043 i18n("When selected, the window borders "
00044 "are drawn using the titlebar colors; otherwise, they are "
00045 "drawn using normal border colors."));
00046
00047
00048 showGrabHandleCb = new QCheckBox(
00049 i18n("Draw &resize handle"), gb);
00050 QWhatsThis::add(showGrabHandleCb,
00051 i18n("When selected, decorations are drawn with a \"grab handle\" "
00052 "in the bottom right corner of the windows; "
00053 "otherwise, no grab handle is drawn."));
00054
00055
00056 actionsGB = new QHGroupBox(i18n("Actions Settings"), gb);
00057 QLabel *menuDblClickLabel = new QLabel(actionsGB);
00058 menuDblClickLabel->setText(i18n("Double click on menu button:"));
00059 menuDblClickOp = new QComboBox(actionsGB);
00060 menuDblClickOp->insertItem(i18n("Do Nothing"));
00061 menuDblClickOp->insertItem(i18n("Minimize Window"));
00062 menuDblClickOp->insertItem(i18n("Shade Window"));
00063 menuDblClickOp->insertItem(i18n("Close Window"));
00064
00065 QWhatsThis::add(menuDblClickOp,
00066 i18n("An action can be associated to a double click "
00067 "of the menu button. Leave it to none if in doubt."));
00068
00069
00070 load(conf);
00071
00072
00073 connect(cbColorBorder, SIGNAL(clicked()),
00074 this, SLOT(slotSelectionChanged()));
00075 connect(showGrabHandleCb, SIGNAL(clicked()),
00076 this, SLOT(slotSelectionChanged()));
00077 connect(menuDblClickOp, SIGNAL(activated(int)),
00078 this, SLOT(slotSelectionChanged()));
00079
00080 gb->show();
00081 }
00082
00083
00084 B2Config::~B2Config()
00085 {
00086 delete b2Config;
00087 delete gb;
00088 }
00089
00090
00091 void B2Config::slotSelectionChanged()
00092 {
00093 emit changed();
00094 }
00095
00096
00097
00098
00099 void B2Config::load(KConfig * )
00100 {
00101 b2Config->setGroup("General");
00102
00103 bool override = b2Config->readBoolEntry("UseTitleBarBorderColors", false);
00104 cbColorBorder->setChecked(override);
00105
00106 override = b2Config->readBoolEntry( "DrawGrabHandle", true );
00107 showGrabHandleCb->setChecked(override);
00108
00109 QString returnString = b2Config->readEntry(
00110 "MenuButtonDoubleClickOperation", "NoOp");
00111
00112 int op;
00113 if (returnString == "Close") {
00114 op = 3;
00115 } else if (returnString == "Shade") {
00116 op = 2;
00117 } else if (returnString == "Minimize") {
00118 op = 1;
00119 } else {
00120 op = 0;
00121 }
00122
00123 menuDblClickOp->setCurrentItem(op);
00124
00125 }
00126
00127 static QString opToString(int op)
00128 {
00129 switch (op) {
00130 case 1:
00131 return "Minimize";
00132 case 2:
00133 return "Shade";
00134 case 3:
00135 return "Close";
00136 case 0:
00137 default:
00138 return "NoOp";
00139 }
00140 }
00141
00142
00143
00144 void B2Config::save(KConfig * )
00145 {
00146 b2Config->setGroup("General");
00147 b2Config->writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
00148 b2Config->writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
00149 b2Config->writeEntry("MenuButtonDoubleClickOperation",
00150 opToString(menuDblClickOp->currentItem()));
00151
00152 b2Config->sync();
00153 }
00154
00155
00156
00157 void B2Config::defaults()
00158 {
00159 cbColorBorder->setChecked(false);
00160 showGrabHandleCb->setChecked(true);
00161 menuDblClickOp->setCurrentItem(0);
00162 }
00163
00164 #include "config.moc"
00165
This file is part of the documentation for kwin Library Version 3.3.0.