summaryrefslogtreecommitdiffstats
path: root/kwin/clients/b2/config
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kwin/clients/b2/config
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kwin/clients/b2/config')
-rw-r--r--kwin/clients/b2/config/Makefile.am16
-rw-r--r--kwin/clients/b2/config/config.cpp165
-rw-r--r--kwin/clients/b2/config/config.h50
3 files changed, 231 insertions, 0 deletions
diff --git a/kwin/clients/b2/config/Makefile.am b/kwin/clients/b2/config/Makefile.am
new file mode 100644
index 000000000..9ad21f7d4
--- /dev/null
+++ b/kwin/clients/b2/config/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = kwin_b2_config.la
+
+kwin_b2_config_la_SOURCES = config.cpp
+kwin_b2_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
+kwin_b2_config_la_LIBADD = $(LIB_KDEUI)
+
+METASOURCES = AUTO
+noinst_HEADERS = config.h
+
+lnkdir = $(kde_datadir)/kwin/
+
+###KMAKE-start (don't edit or delete this block)
+
+###KMAKE-end
diff --git a/kwin/clients/b2/config/config.cpp b/kwin/clients/b2/config/config.cpp
new file mode 100644
index 000000000..d16a90307
--- /dev/null
+++ b/kwin/clients/b2/config/config.cpp
@@ -0,0 +1,165 @@
+/*
+ * This file contains the B2 configuration widget
+ *
+ * Copyright (c) 2001
+ * Karol Szwed <gallium@kde.org>
+ * http://gallium.n3.net/
+ */
+
+#include "config.h"
+#include <kglobal.h>
+#include <qwhatsthis.h>
+#include <qvbox.h>
+#include <klocale.h>
+
+
+extern "C"
+{
+ KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
+ {
+ return(new B2Config(conf, parent));
+ }
+}
+
+
+/* NOTE:
+ * 'conf' is a pointer to the kwindecoration modules open kwin config,
+ * and is by default set to the "Style" group.
+ *
+ * 'parent' is the parent of the QObject, which is a VBox inside the
+ * Configure tab in kwindecoration
+ */
+
+B2Config::B2Config( KConfig* conf, QWidget* parent )
+ : QObject( parent )
+{
+ KGlobal::locale()->insertCatalogue("kwin_b2_config");
+ b2Config = new KConfig("kwinb2rc");
+ gb = new QVBox(parent);
+
+ cbColorBorder = new QCheckBox(
+ i18n("Draw window frames using &titlebar colors"), gb);
+ QWhatsThis::add(cbColorBorder,
+ i18n("When selected, the window borders "
+ "are drawn using the titlebar colors; otherwise, they are "
+ "drawn using normal border colors."));
+
+ // Grab Handle
+ showGrabHandleCb = new QCheckBox(
+ i18n("Draw &resize handle"), gb);
+ QWhatsThis::add(showGrabHandleCb,
+ i18n("When selected, decorations are drawn with a \"grab handle\" "
+ "in the bottom right corner of the windows; "
+ "otherwise, no grab handle is drawn."));
+
+ // Double click menu option support
+ actionsGB = new QHGroupBox(i18n("Actions Settings"), gb);
+ QLabel *menuDblClickLabel = new QLabel(actionsGB);
+ menuDblClickLabel->setText(i18n("Double click on menu button:"));
+ menuDblClickOp = new QComboBox(actionsGB);
+ menuDblClickOp->insertItem(i18n("Do Nothing"));
+ menuDblClickOp->insertItem(i18n("Minimize Window"));
+ menuDblClickOp->insertItem(i18n("Shade Window"));
+ menuDblClickOp->insertItem(i18n("Close Window"));
+
+ QWhatsThis::add(menuDblClickOp,
+ i18n("An action can be associated to a double click "
+ "of the menu button. Leave it to none if in doubt."));
+
+ // Load configuration options
+ load(conf);
+
+ // Ensure we track user changes properly
+ connect(cbColorBorder, SIGNAL(clicked()),
+ this, SLOT(slotSelectionChanged()));
+ connect(showGrabHandleCb, SIGNAL(clicked()),
+ this, SLOT(slotSelectionChanged()));
+ connect(menuDblClickOp, SIGNAL(activated(int)),
+ this, SLOT(slotSelectionChanged()));
+ // Make the widgets visible in kwindecoration
+ gb->show();
+}
+
+
+B2Config::~B2Config()
+{
+ delete b2Config;
+ delete gb;
+}
+
+
+void B2Config::slotSelectionChanged()
+{
+ emit changed();
+}
+
+
+// Loads the configurable options from the kwinrc config file
+// It is passed the open config from kwindecoration to improve efficiency
+void B2Config::load(KConfig * /*conf*/)
+{
+ b2Config->setGroup("General");
+
+ bool override = b2Config->readBoolEntry("UseTitleBarBorderColors", false);
+ cbColorBorder->setChecked(override);
+
+ override = b2Config->readBoolEntry( "DrawGrabHandle", true );
+ showGrabHandleCb->setChecked(override);
+
+ QString returnString = b2Config->readEntry(
+ "MenuButtonDoubleClickOperation", "NoOp");
+
+ int op;
+ if (returnString == "Close") {
+ op = 3;
+ } else if (returnString == "Shade") {
+ op = 2;
+ } else if (returnString == "Minimize") {
+ op = 1;
+ } else {
+ op = 0;
+ }
+
+ menuDblClickOp->setCurrentItem(op);
+
+}
+
+static QString opToString(int op)
+{
+ switch (op) {
+ case 1:
+ return "Minimize";
+ case 2:
+ return "Shade";
+ case 3:
+ return "Close";
+ case 0:
+ default:
+ return "NoOp";
+ }
+}
+
+
+// Saves the configurable options to the kwinrc config file
+void B2Config::save(KConfig * /*conf*/)
+{
+ b2Config->setGroup("General");
+ b2Config->writeEntry("UseTitleBarBorderColors", cbColorBorder->isChecked());
+ b2Config->writeEntry("DrawGrabHandle", showGrabHandleCb->isChecked());
+ b2Config->writeEntry("MenuButtonDoubleClickOperation",
+ opToString(menuDblClickOp->currentItem()));
+ // Ensure others trying to read this config get updated
+ b2Config->sync();
+}
+
+
+// Sets UI widget defaults which must correspond to style defaults
+void B2Config::defaults()
+{
+ cbColorBorder->setChecked(false);
+ showGrabHandleCb->setChecked(true);
+ menuDblClickOp->setCurrentItem(0);
+}
+
+#include "config.moc"
+// vim: ts=4
diff --git a/kwin/clients/b2/config/config.h b/kwin/clients/b2/config/config.h
new file mode 100644
index 000000000..9985f3f4f
--- /dev/null
+++ b/kwin/clients/b2/config/config.h
@@ -0,0 +1,50 @@
+/*
+ * This file contains the B2 configuration widget
+ *
+ * Copyright (c) 2001
+ * Karol Szwed <gallium@kde.org>
+ * http://gallium.n3.net/
+ */
+
+#ifndef _KDE_B2CONFIG_H
+#define _KDE_B2CONFIG_H
+
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qhgroupbox.h>
+#include <qlabel.h>
+#include <qcombobox.h>
+#include <kconfig.h>
+
+class B2Config: public QObject
+{
+ Q_OBJECT
+
+ public:
+ B2Config( KConfig* conf, QWidget* parent );
+ ~B2Config();
+
+ // These public signals/slots work similar to KCM modules
+ signals:
+ void changed();
+
+ public slots:
+ void load( KConfig* conf );
+ void save( KConfig* conf );
+ void defaults();
+
+ protected slots:
+ void slotSelectionChanged(); // Internal use
+
+ private:
+ KConfig* b2Config;
+ QCheckBox* cbColorBorder;
+ QCheckBox* showGrabHandleCb;
+ QHGroupBox* actionsGB;
+ QComboBox* menuDblClickOp;
+ QWidget* gb;
+};
+
+#endif
+
+// vim: ts=4