Apply patch from (make it optionally follow system colors).

svn path=/trunk/KDE/kdebase/workspace/; revision=795249
This commit is contained in:
Luboš Luňák 2008-04-09 15:48:12 +00:00
parent e9b46ee24c
commit 2cdceb2fac
9 changed files with 230 additions and 6 deletions

View file

@ -1,5 +1,7 @@
add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
add_subdirectory( config )
########### next target ###############
set(kwin_ozone_SRCS

View file

@ -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} )

View file

@ -0,0 +1,91 @@
/*
* Oxygen KWin client configuration module
*
* Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
*
* Based on the Quartz configuration module,
* Copyright (c) 2001 Karol Szwed <gallium@kde.org>
*
* 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 <kglobal.h>
#include <klocale.h>
#include <QCheckBox>
#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

View file

@ -0,0 +1,64 @@
/*
* Oxygen KWin client configuration module
*
* Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
*
* Based on the Quartz configuration module,
* Copyright (c) 2001 Karol Szwed <gallium@kde.org>
*
* 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 <kconfig.h>
#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

View file

@ -0,0 +1,35 @@
<ui version="4.0" >
<class>OxygenConfigUI</class>
<widget class="QWidget" name="OxygenConfigUI" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>33</height>
</rect>
</property>
<property name="windowTitle" >
<string>Ozone</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="blendTitlebarColors" >
<property name="whatsThis" >
<string>When enabled, this option makes the window titlebar use same colors as window contents, instead of using system titlebar colors.</string>
</property>
<property name="text" >
<string>Blend titlebar colors with window contents</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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();