Apply patch from #152030 (make it optionally follow system colors).
svn path=/trunk/KDE/kdebase/workspace/; revision=795249
This commit is contained in:
parent
e9b46ee24c
commit
2cdceb2fac
9 changed files with 230 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
|
add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
|
||||||
|
|
||||||
|
add_subdirectory( config )
|
||||||
|
|
||||||
########### next target ###############
|
########### next target ###############
|
||||||
|
|
||||||
set(kwin_ozone_SRCS
|
set(kwin_ozone_SRCS
|
||||||
|
|
18
clients/ozone/config/CMakeLists.txt
Normal file
18
clients/ozone/config/CMakeLists.txt
Normal 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} )
|
||||||
|
|
91
clients/ozone/config/config.cpp
Normal file
91
clients/ozone/config/config.cpp
Normal 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
|
64
clients/ozone/config/config.h
Normal file
64
clients/ozone/config/config.h
Normal 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
|
35
clients/ozone/config/oxygenconfig.ui
Normal file
35
clients/ozone/config/oxygenconfig.ui
Normal 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>
|
|
@ -47,6 +47,7 @@ namespace Oxygen
|
||||||
|
|
||||||
bool OxygenFactory::initialized_ = false;
|
bool OxygenFactory::initialized_ = false;
|
||||||
Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft;
|
Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft;
|
||||||
|
bool OxygenFactory::blendTitlebarColors_ = true;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// OxygenFactory()
|
// OxygenFactory()
|
||||||
|
@ -116,7 +117,10 @@ bool OxygenFactory::readConfig()
|
||||||
else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter;
|
else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter;
|
||||||
else if (value == "AlignRight") titlealign_ = Qt::AlignRight;
|
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;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -65,6 +65,7 @@ public:
|
||||||
|
|
||||||
static bool initialized();
|
static bool initialized();
|
||||||
static Qt::Alignment titleAlign();
|
static Qt::Alignment titleAlign();
|
||||||
|
static bool blendTitlebarColors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool readConfig();
|
bool readConfig();
|
||||||
|
@ -72,6 +73,7 @@ private:
|
||||||
private:
|
private:
|
||||||
static bool initialized_;
|
static bool initialized_;
|
||||||
static Qt::Alignment titlealign_;
|
static Qt::Alignment titlealign_;
|
||||||
|
static bool blendTitlebarColors_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool OxygenFactory::initialized()
|
inline bool OxygenFactory::initialized()
|
||||||
|
@ -80,6 +82,9 @@ inline bool OxygenFactory::initialized()
|
||||||
inline Qt::Alignment OxygenFactory::titleAlign()
|
inline Qt::Alignment OxygenFactory::titleAlign()
|
||||||
{ return titlealign_; }
|
{ return titlealign_; }
|
||||||
|
|
||||||
|
inline bool OxygenFactory::blendTitlebarColors()
|
||||||
|
{ return blendTitlebarColors_; }
|
||||||
|
|
||||||
} //namespace Oxygen
|
} //namespace Oxygen
|
||||||
} //namespace Ozone
|
} //namespace Ozone
|
||||||
|
|
||||||
|
|
|
@ -176,23 +176,26 @@ void OxygenButton::paintEvent(QPaintEvent *)
|
||||||
if(client_.maximizeMode() == OxygenClient::MaximizeRestore)
|
if(client_.maximizeMode() == OxygenClient::MaximizeRestore)
|
||||||
painter.translate(0,-1);
|
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));
|
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(status_ == Oxygen::Hovered) {
|
||||||
if(type_ == ButtonClose) {
|
if(type_ == ButtonClose) {
|
||||||
QColor color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
|
QColor color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
|
||||||
lg = helper_.decoGradient(QRect(4,4,13,13), 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{
|
else{
|
||||||
QColor color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color();
|
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
|
else
|
||||||
painter.drawPixmap(0, 0, helper_.windecoButton(pal.button()));
|
painter.drawPixmap(0, 0, helper_.windecoButton(bt));
|
||||||
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing);
|
painter.setRenderHints(QPainter::Antialiasing);
|
||||||
painter.setBrush(Qt::NoBrush);
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
|
|
@ -237,6 +237,8 @@ QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
|
||||||
|
|
||||||
QColor OxygenClient::titlebarTextColor(const QPalette &palette)
|
QColor OxygenClient::titlebarTextColor(const QPalette &palette)
|
||||||
{
|
{
|
||||||
|
if( !OxygenFactory::blendTitlebarColors())
|
||||||
|
return options()->color(ColorFont, isActive());
|
||||||
if (isActive())
|
if (isActive())
|
||||||
return palette.color(QPalette::Active, QPalette::WindowText);
|
return palette.color(QPalette::Active, QPalette::WindowText);
|
||||||
else {
|
else {
|
||||||
|
@ -271,7 +273,7 @@ void OxygenClient::paintEvent(QPaintEvent *e)
|
||||||
|
|
||||||
int x,y,w,h;
|
int x,y,w,h;
|
||||||
QRect frame = widget()->frameGeometry();
|
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 titleHeight = layoutMetric(LM_TitleHeight);
|
||||||
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top();
|
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top();
|
||||||
|
|
Loading…
Reference in a new issue