diff options
author | Timothy Pearson <[email protected]> | 2011-11-07 21:50:33 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-07 21:50:33 -0600 |
commit | 0b6057404f65218182ab27a9483a21065ef61fca (patch) | |
tree | b8b06dfa2deb965bebfbe131a772124e3e693a96 /twin/clients/b2/config | |
parent | 43d99cc2477266cb9072e179137f0e8485370b3d (diff) | |
download | tdebase-0b6057404f65218182ab27a9483a21065ef61fca.tar.gz tdebase-0b6057404f65218182ab27a9483a21065ef61fca.zip |
Rename kwin to twin (Part 2 of 2)
Diffstat (limited to 'twin/clients/b2/config')
-rw-r--r-- | twin/clients/b2/config/CMakeLists.txt | 29 | ||||
-rw-r--r-- | twin/clients/b2/config/Makefile.am | 16 | ||||
-rw-r--r-- | twin/clients/b2/config/config.cpp | 165 | ||||
-rw-r--r-- | twin/clients/b2/config/config.h | 50 |
4 files changed, 260 insertions, 0 deletions
diff --git a/twin/clients/b2/config/CMakeLists.txt b/twin/clients/b2/config/CMakeLists.txt new file mode 100644 index 000000000..0785fb176 --- /dev/null +++ b/twin/clients/b2/config/CMakeLists.txt @@ -0,0 +1,29 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### twin_b2_config (module) ################### + +tde_add_kpart( twin_b2_config AUTOMOC + SOURCES config.cpp + LINK tdeui-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/twin/clients/b2/config/Makefile.am b/twin/clients/b2/config/Makefile.am new file mode 100644 index 000000000..4319b5375 --- /dev/null +++ b/twin/clients/b2/config/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = twin_b2_config.la + +twin_b2_config_la_SOURCES = config.cpp +twin_b2_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +twin_b2_config_la_LIBADD = $(LIB_TDEUI) + +METASOURCES = AUTO +noinst_HEADERS = config.h + +lnkdir = $(kde_datadir)/twin/ + +###KMAKE-start (don't edit or delete this block) + +###KMAKE-end diff --git a/twin/clients/b2/config/config.cpp b/twin/clients/b2/config/config.cpp new file mode 100644 index 000000000..956f55bb4 --- /dev/null +++ b/twin/clients/b2/config/config.cpp @@ -0,0 +1,165 @@ +/* + * This file contains the B2 configuration widget + * + * Copyright (c) 2001 + * Karol Szwed <[email protected]> + * http://gallium.n3.net/ + */ + +#include "config.h" +#include <kglobal.h> +#include <tqwhatsthis.h> +#include <tqvbox.h> +#include <klocale.h> + + +extern "C" +{ + KDE_EXPORT TQObject* allocate_config( KConfig* conf, TQWidget* parent ) + { + return(new B2Config(conf, parent)); + } +} + + +/* NOTE: + * 'conf' is a pointer to the twindecoration modules open twin config, + * and is by default set to the "Style" group. + * + * 'parent' is the parent of the TQObject, which is a VBox inside the + * Configure tab in twindecoration + */ + +B2Config::B2Config( KConfig* conf, TQWidget* parent ) + : TQObject( parent ) +{ + KGlobal::locale()->insertCatalogue("twin_b2_config"); + b2Config = new KConfig("twinb2rc"); + gb = new TQVBox(parent); + + cbColorBorder = new TQCheckBox( + i18n("Draw window frames using &titlebar colors"), gb); + TQWhatsThis::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 TQCheckBox( + i18n("Draw &resize handle"), gb); + TQWhatsThis::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 TQHGroupBox(i18n("Actions Settings"), gb); + TQLabel *menuDblClickLabel = new TQLabel(actionsGB); + menuDblClickLabel->setText(i18n("Double click on menu button:")); + menuDblClickOp = new TQComboBox(actionsGB); + menuDblClickOp->insertItem(i18n("Do Nothing")); + menuDblClickOp->insertItem(i18n("Minimize Window")); + menuDblClickOp->insertItem(i18n("Shade Window")); + menuDblClickOp->insertItem(i18n("Close Window")); + + TQWhatsThis::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, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotSelectionChanged())); + connect(showGrabHandleCb, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotSelectionChanged())); + connect(menuDblClickOp, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotSelectionChanged())); + // Make the widgets visible in twindecoration + gb->show(); +} + + +B2Config::~B2Config() +{ + delete b2Config; + delete gb; +} + + +void B2Config::slotSelectionChanged() +{ + emit changed(); +} + + +// Loads the configurable options from the twinrc config file +// It is passed the open config from twindecoration 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); + + TQString 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 TQString 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 twinrc 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/twin/clients/b2/config/config.h b/twin/clients/b2/config/config.h new file mode 100644 index 000000000..99d664ad1 --- /dev/null +++ b/twin/clients/b2/config/config.h @@ -0,0 +1,50 @@ +/* + * This file contains the B2 configuration widget + * + * Copyright (c) 2001 + * Karol Szwed <[email protected]> + * http://gallium.n3.net/ + */ + +#ifndef _KDE_B2CONFIG_H +#define _KDE_B2CONFIG_H + +#include <tqcheckbox.h> +#include <tqgroupbox.h> +#include <tqhgroupbox.h> +#include <tqlabel.h> +#include <tqcombobox.h> +#include <kconfig.h> + +class B2Config: public TQObject +{ + Q_OBJECT + + public: + B2Config( KConfig* conf, TQWidget* 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; + TQCheckBox* cbColorBorder; + TQCheckBox* showGrabHandleCb; + TQHGroupBox* actionsGB; + TQComboBox* menuDblClickOp; + TQWidget* gb; +}; + +#endif + +// vim: ts=4 |