diff --git a/clients/ozone/CMakeLists.txt b/clients/ozone/CMakeLists.txt index 5ffa46301a..05f48a35cb 100644 --- a/clients/ozone/CMakeLists.txt +++ b/clients/ozone/CMakeLists.txt @@ -1,5 +1,7 @@ add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS) +add_subdirectory( config ) + ########### next target ############### set(kwin_ozone_SRCS diff --git a/clients/ozone/config/CMakeLists.txt b/clients/ozone/config/CMakeLists.txt new file mode 100644 index 0000000000..f492d2f4c6 --- /dev/null +++ b/clients/ozone/config/CMakeLists.txt @@ -0,0 +1,18 @@ +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/ozone/config/config.cpp b/clients/ozone/config/config.cpp new file mode 100644 index 0000000000..c696dc0205 --- /dev/null +++ b/clients/ozone/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->blendTitlebarColors, 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->blendTitlebarColors->setChecked( cg.readEntry("BlendTitlebarColors", true) ); +} + + +// Saves the configurable options to the kwinrc config file +void OxygenConfig::save( KConfigGroup& ) +{ + KConfigGroup cg(c, "Windeco"); + cg.writeEntry( "BlendTitlebarColors", ui->blendTitlebarColors->isChecked() ); + c->sync(); +} + + +// Sets UI widget defaults which must correspond to style defaults +void OxygenConfig::defaults() +{ + ui->blendTitlebarColors->setChecked( true ); + + emit changed(); +} + +} //namespace Oxygen diff --git a/clients/ozone/config/config.h b/clients/ozone/config/config.h new file mode 100644 index 0000000000..467a918b16 --- /dev/null +++ b/clients/ozone/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/ozone/config/oxygenconfig.ui b/clients/ozone/config/oxygenconfig.ui new file mode 100644 index 0000000000..471adb366a --- /dev/null +++ b/clients/ozone/config/oxygenconfig.ui @@ -0,0 +1,35 @@ + + OxygenConfigUI + + + + 0 + 0 + 287 + 33 + + + + Ozone + + + + 0 + + + + + When enabled, this option makes the window titlebar use same colors as window contents, instead of using system titlebar colors. + + + Blend titlebar colors with window contents + + + + + + + qPixmapFromMimeSource + + + diff --git a/clients/ozone/oxygen.cpp b/clients/ozone/oxygen.cpp index 3245b5989e..421273f2a4 100644 --- a/clients/ozone/oxygen.cpp +++ b/clients/ozone/oxygen.cpp @@ -47,6 +47,7 @@ namespace Oxygen bool OxygenFactory::initialized_ = false; Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft; +bool OxygenFactory::blendTitlebarColors_ = true; ////////////////////////////////////////////////////////////////////////////// // OxygenFactory() @@ -116,7 +117,10 @@ bool OxygenFactory::readConfig() else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter; else if (value == "AlignRight") titlealign_ = Qt::AlignRight; - if (oldalign == titlealign_) + bool oldblend = blendTitlebarColors; + blendTitlebarColors_ = group.readEntry( "BlendTitlebarColors", true ); + + if (oldalign == titlealign_ && oldblend == blendTitlebarColors_) return false; else return true; diff --git a/clients/ozone/oxygen.h b/clients/ozone/oxygen.h index 7bb99fc812..e60acb818b 100644 --- a/clients/ozone/oxygen.h +++ b/clients/ozone/oxygen.h @@ -65,6 +65,7 @@ public: static bool initialized(); static Qt::Alignment titleAlign(); + static bool blendTitlebarColors(); private: bool readConfig(); @@ -72,6 +73,7 @@ private: private: static bool initialized_; static Qt::Alignment titlealign_; + static bool blendTitlebarColors_; }; inline bool OxygenFactory::initialized() @@ -80,6 +82,9 @@ inline bool OxygenFactory::initialized() inline Qt::Alignment OxygenFactory::titleAlign() { return titlealign_; } +inline bool OxygenFactory::blendTitlebarColors() + { return blendTitlebarColors_; } + } //namespace Oxygen } //namespace Ozone diff --git a/clients/ozone/oxygenbutton.cpp b/clients/ozone/oxygenbutton.cpp index 7079bf0abd..00938d3955 100644 --- a/clients/ozone/oxygenbutton.cpp +++ b/clients/ozone/oxygenbutton.cpp @@ -176,23 +176,26 @@ void OxygenButton::paintEvent(QPaintEvent *) if(client_.maximizeMode() == OxygenClient::MaximizeRestore) painter.translate(0,-1); - QColor bg = helper_.backgroundTopColor(pal.window()); + QColor bg = helper_.backgroundTopColor(OxygenFactory::blendTitlebarColors()?pal.window().color() + :client_.options()->color(KDecorationDefines::ColorTitleBar,client_.isActive())); QLinearGradient lg = helper_.decoGradient(QRect(4,4,13,13), buttonDetailColor(pal)); + QColor bt = OxygenFactory::blendTitlebarColors()?pal.button().color() + :client_.options()->color(KDecorationDefines::ColorButtonBg,client_.isActive()); if(status_ == Oxygen::Hovered) { if(type_ == ButtonClose) { QColor color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color(); lg = helper_.decoGradient(QRect(4,4,13,13), color); - painter.drawPixmap(0, 0, helper_.windecoButtonFocused(pal.button(), color,7)); + painter.drawPixmap(0, 0, helper_.windecoButtonFocused(bt, color,7)); } else{ QColor color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color(); - painter.drawPixmap(0, 0, helper_.windecoButtonFocused(pal.button(), color, 7)); + painter.drawPixmap(0, 0, helper_.windecoButtonFocused(bt, color, 7)); } } else - painter.drawPixmap(0, 0, helper_.windecoButton(pal.button())); + painter.drawPixmap(0, 0, helper_.windecoButton(bt)); painter.setRenderHints(QPainter::Antialiasing); painter.setBrush(Qt::NoBrush); diff --git a/clients/ozone/oxygenclient.cpp b/clients/ozone/oxygenclient.cpp index 1e8c99756d..89fa3ec8a2 100644 --- a/clients/ozone/oxygenclient.cpp +++ b/clients/ozone/oxygenclient.cpp @@ -237,6 +237,8 @@ QColor reduceContrast(const QColor &c0, const QColor &c1, double t) QColor OxygenClient::titlebarTextColor(const QPalette &palette) { + if( !OxygenFactory::blendTitlebarColors()) + return options()->color(ColorFont, isActive()); if (isActive()) return palette.color(QPalette::Active, QPalette::WindowText); else { @@ -271,7 +273,7 @@ void OxygenClient::paintEvent(QPaintEvent *e) int x,y,w,h; QRect frame = widget()->frameGeometry(); - QColor color = palette.window().color(); + QColor color = OxygenFactory::blendTitlebarColors() ? palette.window().color() : options()->color( ColorTitleBar, isActive()); const int titleHeight = layoutMetric(LM_TitleHeight); const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top();