From e35f3fe53cd8df85d4fd04e49dfffbaeac971cdf Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 7 Nov 2011 21:50:31 -0600 Subject: Rename kwin to twin (Part 2 of 2) --- twin-styles/cde/config/CMakeLists.txt | 28 ++++++++ twin-styles/cde/config/Makefile.am | 17 +++++ twin-styles/cde/config/config.cpp | 131 ++++++++++++++++++++++++++++++++++ twin-styles/cde/config/config.h | 52 ++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 twin-styles/cde/config/CMakeLists.txt create mode 100644 twin-styles/cde/config/Makefile.am create mode 100644 twin-styles/cde/config/config.cpp create mode 100644 twin-styles/cde/config/config.h (limited to 'twin-styles/cde/config') diff --git a/twin-styles/cde/config/CMakeLists.txt b/twin-styles/cde/config/CMakeLists.txt new file mode 100644 index 00000000..5faec263 --- /dev/null +++ b/twin-styles/cde/config/CMakeLists.txt @@ -0,0 +1,28 @@ +################################################# +# +# (C) 2011 Golubev Alexander +# fatzer2 (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_cde_config (module) ################### + +tde_add_kpart( twin_cde_config AUTOMOC + SOURCES config.cpp + LINK tdeui-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/twin-styles/cde/config/Makefile.am b/twin-styles/cde/config/Makefile.am new file mode 100644 index 00000000..3e5bd243 --- /dev/null +++ b/twin-styles/cde/config/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = twin_cde_config.la + +twin_cde_config_la_SOURCES = config.cpp +twin_cde_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx +twin_cde_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-styles/cde/config/config.cpp b/twin-styles/cde/config/config.cpp new file mode 100644 index 00000000..fcd2de42 --- /dev/null +++ b/twin-styles/cde/config/config.cpp @@ -0,0 +1,131 @@ +// $Id$ +#include "config.h" +#include +#include +#include +#include +#include + +extern "C" KDE_EXPORT TQObject* allocate_config( KConfig* conf, TQWidget* parent ) +{ + return new CdeConfig(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 + */ + +CdeConfig::CdeConfig( KConfig* conf, TQWidget* parent ) + : TQObject( parent ) +{ + cdeConfig = new KConfig("twincderc"); + KGlobal::locale()->insertCatalogue("twin_art_clients"); + + groupBox = new TQVBox( parent ); + + bgAlign = new TQButtonGroup( 3, Qt::Horizontal, i18n("Text &Alignment"), groupBox ); + bgAlign->setExclusive( true ); + TQWhatsThis::add( bgAlign, i18n("Use these buttons to set the tqalignment of the titlebar caption text.") ); + new TQRadioButton( i18n("Left"), bgAlign, "AlignLeft" ); + TQRadioButton *radio2 = new TQRadioButton( i18n("Centered"), bgAlign, "AlignHCenter" ); + radio2->setChecked( true ); + new TQRadioButton( i18n("Right"), bgAlign, "AlignRight" ); + + cbColorBorder = new TQCheckBox( i18n("Draw window frames using &titlebar colors"), groupBox ); + TQWhatsThis::add( cbColorBorder, i18n("When selected, the window decoration borders " + "are drawn using the titlebar colors. Otherwise, they are " + "drawn using normal border colors instead.") ); + +// cbTitlebarButton = new TQCheckBox( i18n("Titlebar acts like a &pushbutton when clicked"), groupBox ); +// TQWhatsThis::add( cbTitlebarButton, i18n("When selected, this option causes the window titlebar to behave " +// "as if it was a pushbutton when you click it to move the window.") ); + + (void) new TQLabel( i18n("Tip: If you want the look of the original Motif(tm) Window Manager,\n" + "click the \"Buttons\" tab above and remove the help\n" + "and close buttons from the titlebar."), groupBox ); + + // Load configuration options + load( conf ); + + // Ensure we track user changes properly + connect( cbColorBorder, TQT_SIGNAL(clicked()), TQT_SLOT(slotSelectionChanged()) ); +// connect( cbTitlebarButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotSelectionChanged()) ); + connect( bgAlign, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotSelectionChanged(int)) ); + + // Make the widgets visible in twindecoration + groupBox->show(); +} + + +CdeConfig::~CdeConfig() +{ + delete bgAlign; + delete groupBox; + delete cdeConfig; +} + + +void CdeConfig::slotSelectionChanged() +{ + emit changed(); +} + +void CdeConfig::slotSelectionChanged( int ) +{ + emit changed(); +} + +// Loads the configurable options from the twinrc config file +// It is passed the open config from twindecoration to improve efficiency +void CdeConfig::load( KConfig* /*conf*/ ) +{ + cdeConfig->setGroup("General"); + + TQString value = cdeConfig->readEntry( "TextAlignment", "AlignHCenter" ); + TQRadioButton *button = (TQRadioButton*)bgAlign->child( (const char *)value.latin1() ); + if ( button ) + button->setChecked( true ); + + bool coloredFrame = cdeConfig->readBoolEntry( "UseTitleBarBorderColors", true ); + cbColorBorder->setChecked( coloredFrame ); + +// bool titlebarButton = cdeConfig->readBoolEntry( "TitlebarButtonMode", true ); +// cbTitlebarButton->setChecked( titlebarButton ); +} + + +// Saves the configurable options to the twinrc config file +void CdeConfig::save( KConfig* /*conf*/ ) +{ + cdeConfig->setGroup("General"); + + TQRadioButton *button = (TQRadioButton*)bgAlign->selected(); + if ( button ) + cdeConfig->writeEntry( "TextAlignment", TQString(button->name()) ); + + cdeConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() ); +// cdeConfig->writeEntry( "TitlebarButtonMode", cbTitlebarButton->isChecked() ); + + // Ensure others trying to read this config get updated + cdeConfig->sync(); +} + + +// Sets UI widget defaults which must correspond to style defaults +void CdeConfig::defaults() +{ + TQRadioButton *button = (TQRadioButton*)bgAlign->child( "AlignHCenter" ); + if ( button ) + button->setChecked( true ); + + cbColorBorder->setChecked( true ); +// cbTitlebarButton->setChecked( true ); +} + +#include "config.moc" +// vim: ts=4 diff --git a/twin-styles/cde/config/config.h b/twin-styles/cde/config/config.h new file mode 100644 index 00000000..fc7fa136 --- /dev/null +++ b/twin-styles/cde/config/config.h @@ -0,0 +1,52 @@ +#ifndef __KDE_CDECONFIG_H +#define __KDE_CDECONFIG_H + +#include +#include +#include +#include +#include +#include +#include + +class TQCheckBox; +class TQGroupBox; +class TQVBox; +class TQLabel; +class TQRadioButton; + +class CdeConfig: public TQObject +{ + Q_OBJECT + TQ_OBJECT + + public: + CdeConfig( KConfig* conf, TQWidget* parent ); + ~CdeConfig(); + + // 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 + void slotSelectionChanged( int ); + + private: + KConfig* cdeConfig; + TQCheckBox* cbColorBorder; +// TQCheckBox* cbTitlebarButton; + TQHBox* groupBox; + TQGroupBox* gbSlider; + TQButtonGroup* bgAlign; +}; + + +#endif + +// vim: ts=4 -- cgit v1.2.1