From ecfa8aa80fb54a97803ea2723d7fa47ded0a89f1 Mon Sep 17 00:00:00 2001 From: Huynh Huu Long Date: Sat, 7 Jun 2008 23:06:31 +0000 Subject: [PATCH] add configuration option for stripes svn path=/trunk/KDE/kdebase/workspace/; revision=818156 --- clients/oxygen/CMakeLists.txt | 2 + clients/oxygen/config/CMakeLists.txt | 17 +++++ clients/oxygen/config/config.cpp | 91 +++++++++++++++++++++++++++ clients/oxygen/config/config.h | 64 +++++++++++++++++++ clients/oxygen/config/oxygenconfig.ui | 35 +++++++++++ clients/oxygen/oxygen.cpp | 6 +- clients/oxygen/oxygen.h | 5 ++ clients/oxygen/oxygenclient.cpp | 4 +- 8 files changed, 221 insertions(+), 3 deletions(-) create mode 100644 clients/oxygen/config/CMakeLists.txt create mode 100644 clients/oxygen/config/config.cpp create mode 100644 clients/oxygen/config/config.h create mode 100644 clients/oxygen/config/oxygenconfig.ui diff --git a/clients/oxygen/CMakeLists.txt b/clients/oxygen/CMakeLists.txt index d8fd3a01f5..f2f885895d 100644 --- a/clients/oxygen/CMakeLists.txt +++ b/clients/oxygen/CMakeLists.txt @@ -1,5 +1,7 @@ add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS) +add_subdirectory( config ) + ########### next target ############### set(kwin_oxygen_SRCS diff --git a/clients/oxygen/config/CMakeLists.txt b/clients/oxygen/config/CMakeLists.txt new file mode 100644 index 0000000000..99f53bb0e6 --- /dev/null +++ b/clients/oxygen/config/CMakeLists.txt @@ -0,0 +1,17 @@ +include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib ) + + +########### next target ############### + +set(kwin_oxygen_config_PART_SRCS config.cpp ) + + +kde4_add_ui_files(kwin_oxygen_config_PART_SRCS oxygenconfig.ui ) + +kde4_add_plugin(kwin_oxygen_config ${kwin_oxygen_config_PART_SRCS}) + + + +target_link_libraries(kwin_oxygen_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY}) + +install(TARGETS kwin_oxygen_config DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/clients/oxygen/config/config.cpp b/clients/oxygen/config/config.cpp new file mode 100644 index 0000000000..74b78f76e3 --- /dev/null +++ b/clients/oxygen/config/config.cpp @@ -0,0 +1,91 @@ +/* + * Oxygen KWin client configuration module + * + * Copyright (C) 2008 Lubos Lunak + * + * Based on the Quartz configuration module, + * Copyright (c) 2001 Karol Szwed + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the license, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" + +#include +#include + +#include + +#include "config.moc" + +extern "C" +{ + KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent ) + { + return ( new Oxygen::OxygenConfig( conf, parent ) ); + } +} + +namespace Oxygen { + +OxygenConfig::OxygenConfig( KConfig*, QWidget* parent ) + : QObject( parent ) +{ + KGlobal::locale()->insertCatalog("kwin_clients"); + c = new KConfig( "oxygenrc" ); + KConfigGroup cg(c, "Windeco"); + ui = new OxygenConfigUI( parent ); + connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) ); + + load( cg ); + ui->show(); +} + + +OxygenConfig::~OxygenConfig() +{ + delete ui; + delete c; +} + + +// Loads the configurable options from the kwinrc config file +// It is passed the open config from kwindecoration to improve efficiency +void OxygenConfig::load( const KConfigGroup& ) +{ + KConfigGroup cg(c, "Windeco"); + ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) ); +} + + +// Saves the configurable options to the kwinrc config file +void OxygenConfig::save( KConfigGroup& ) +{ + KConfigGroup cg(c, "Windeco"); + cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() ); + c->sync(); +} + + +// Sets UI widget defaults which must correspond to style defaults +void OxygenConfig::defaults() +{ + ui->showStripes->setChecked( true ); + + emit changed(); +} + +} //namespace Oxygen diff --git a/clients/oxygen/config/config.h b/clients/oxygen/config/config.h new file mode 100644 index 0000000000..467a918b16 --- /dev/null +++ b/clients/oxygen/config/config.h @@ -0,0 +1,64 @@ +/* + * Oxygen KWin client configuration module + * + * Copyright (C) 2008 Lubos Lunak + * + * Based on the Quartz configuration module, + * Copyright (c) 2001 Karol Szwed + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the license, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef OXYGEN_CONFIG_H +#define OXYGEN_CONFIG_H + +#include + +#include "ui_oxygenconfig.h" + +namespace Oxygen { + +class OxygenConfigUI : public QWidget, public Ui::OxygenConfigUI +{ +public: + OxygenConfigUI( QWidget *parent ) : QWidget( parent ) + { + setupUi( this ); + } +}; + + +class OxygenConfig: public QObject +{ + Q_OBJECT +public: + OxygenConfig( KConfig* conf, QWidget* parent ); + ~OxygenConfig(); +// These public signals/slots work similar to KCM modules +signals: + void changed(); +public slots: + void load( const KConfigGroup& conf ); + void save( KConfigGroup& conf ); + void defaults(); +private: + OxygenConfigUI *ui; + KConfig *c; +}; + +} //namespace Oxygen + +#endif diff --git a/clients/oxygen/config/oxygenconfig.ui b/clients/oxygen/config/oxygenconfig.ui new file mode 100644 index 0000000000..245016f9a5 --- /dev/null +++ b/clients/oxygen/config/oxygenconfig.ui @@ -0,0 +1,35 @@ + + OxygenConfigUI + + + + 0 + 0 + 287 + 33 + + + + Ozone + + + + 0 + + + + + When enabled, this option increases the visibility of the window titlebar by showing stripes + + + Show stripes next to the title + + + + + + + qPixmapFromMimeSource + + + diff --git a/clients/oxygen/oxygen.cpp b/clients/oxygen/oxygen.cpp index 66dd2644fd..f08af47946 100644 --- a/clients/oxygen/oxygen.cpp +++ b/clients/oxygen/oxygen.cpp @@ -45,6 +45,7 @@ namespace Oxygen bool OxygenFactory::initialized_ = false; Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft; +bool OxygenFactory::showStripes_ = true; ////////////////////////////////////////////////////////////////////////////// // OxygenFactory() @@ -114,7 +115,10 @@ bool OxygenFactory::readConfig() else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter; else if (value == "AlignRight") titlealign_ = Qt::AlignRight; - if (oldalign == titlealign_) + bool oldstripes = showStripes; + showStripes_ = group.readEntry( "ShowStripes", true ); + + if (oldalign == titlealign_ && oldstripes == showStripes_) return false; else return true; diff --git a/clients/oxygen/oxygen.h b/clients/oxygen/oxygen.h index 535f003af1..7425e5fbdc 100644 --- a/clients/oxygen/oxygen.h +++ b/clients/oxygen/oxygen.h @@ -63,6 +63,7 @@ public: static bool initialized(); static Qt::Alignment titleAlign(); + static bool showStripes(); private: bool readConfig(); @@ -70,6 +71,7 @@ private: private: static bool initialized_; static Qt::Alignment titlealign_; + static bool showStripes_; }; inline bool OxygenFactory::initialized() @@ -78,6 +80,9 @@ inline bool OxygenFactory::initialized() inline Qt::Alignment OxygenFactory::titleAlign() { return titlealign_; } +inline bool OxygenFactory::showStripes() + { return showStripes_; } + } //namespace Oxygen #endif diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 7b0bfcfbb6..a356612a38 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -346,8 +346,8 @@ void OxygenClient::paintEvent(QPaintEvent *e) QPointF(x+w, titleTop+titleHeight-0.5)); } - // draw "scratches" as indicator for active windows - if (isActive()) { + // draw stripes as indicator for active windows + if (isActive() && OxygenFactory::showStripes()) { Qt::Alignment align = OxygenFactory::titleAlign(); if (widget()->layoutDirection() == Qt::RightToLeft) {