Replace Ozone with Nitrogen as the default decoration and remove Ozone.
CCMAIL:kwin@kde.org svn path=/trunk/KDE/kdebase/workspace/; revision=1016904
This commit is contained in:
parent
ebc76aa81d
commit
47ef5f02cc
17 changed files with 4 additions and 1970 deletions
|
@ -8,7 +8,6 @@ add_subdirectory( laptop )
|
|||
add_subdirectory( modernsystem )
|
||||
add_subdirectory( nitrogen )
|
||||
add_subdirectory( oxygen )
|
||||
add_subdirectory( ozone )
|
||||
add_subdirectory( quartz )
|
||||
add_subdirectory( redmond )
|
||||
add_subdirectory( web )
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
add_subdirectory( config )
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(kwin_ozone_SRCS
|
||||
lib/helper.cpp
|
||||
lib/tileset.cpp
|
||||
oxygenclient.cpp
|
||||
oxygenbutton.cpp
|
||||
oxygen.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(kwin3_ozone ${kwin_ozone_SRCS})
|
||||
|
||||
|
||||
target_link_libraries(kwin3_ozone ${KDE4_KDEUI_LIBS} ${X11_Xrender_LIB} kdecorations)
|
||||
|
||||
install(TARGETS kwin3_ozone DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install( FILES ozoneclient.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
This decoration is a fork of the Oxygen decoration, for reasons stated
|
||||
in bug #152030 (comment #70 and others), namely Oxygen developers not
|
||||
willing to accept widely-requested patches because of not fitting
|
||||
the Oxygen vision and instead preferring a fork that's not branded
|
||||
as Oxygen.
|
||||
|
||||
Everything is put into extra namespace called Ozone to make syncing easier.
|
||||
All visible strings have Oxygen changed to Ozone.
|
||||
Other things are not renamed to minimize conflicts as much as possible.
|
|
@ -1,18 +0,0 @@
|
|||
include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib )
|
||||
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(kwin_ozone_config_PART_SRCS config.cpp )
|
||||
|
||||
|
||||
kde4_add_ui_files(kwin_ozone_config_PART_SRCS oxygenconfig.ui )
|
||||
|
||||
kde4_add_plugin(kwin_ozone_config ${kwin_ozone_config_PART_SRCS})
|
||||
|
||||
|
||||
|
||||
target_link_libraries(kwin_ozone_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
|
||||
|
||||
install(TARGETS kwin_ozone_config DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* 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 Ozone::Oxygen::OxygenConfig( conf, parent ) );
|
||||
}
|
||||
}
|
||||
|
||||
namespace Ozone {
|
||||
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()) );
|
||||
connect( ui->blendTitlebarColors, SIGNAL(clicked()), SIGNAL(changed()) );
|
||||
connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) );
|
||||
connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) );
|
||||
connect( ui->titleAlignmentRight, 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) );
|
||||
ui->blendTitlebarColors->setChecked( cg.readEntry("BlendTitlebarColors", true) );
|
||||
|
||||
QString titleAlignment = cg.readEntry("TitleAlignment", "Left");
|
||||
ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" );
|
||||
ui->titleAlignmentCenter->setChecked( titleAlignment == "Center" );
|
||||
ui->titleAlignmentRight->setChecked( titleAlignment == "Right" );
|
||||
}
|
||||
|
||||
|
||||
// Saves the configurable options to the kwinrc config file
|
||||
void OxygenConfig::save( KConfigGroup& )
|
||||
{
|
||||
KConfigGroup cg(c, "Windeco");
|
||||
cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
|
||||
cg.writeEntry( "BlendTitlebarColors", ui->blendTitlebarColors->isChecked() );
|
||||
|
||||
QString titleAlignment = "Left";
|
||||
if (ui->titleAlignmentCenter->isChecked())
|
||||
{
|
||||
titleAlignment = "Center";
|
||||
}
|
||||
else if (ui->titleAlignmentRight->isChecked())
|
||||
{
|
||||
titleAlignment = "Right";
|
||||
}
|
||||
cg.writeEntry( "TitleAlignment", titleAlignment);
|
||||
c->sync();
|
||||
}
|
||||
|
||||
|
||||
// Sets UI widget defaults which must correspond to style defaults
|
||||
void OxygenConfig::defaults()
|
||||
{
|
||||
ui->showStripes->setChecked( true );
|
||||
ui->titleAlignmentLeft->setChecked( true );
|
||||
ui->blendTitlebarColors->setChecked( true );
|
||||
|
||||
emit changed();
|
||||
}
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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 Ozone {
|
||||
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
|
||||
} //namespace Ozone
|
||||
|
||||
#endif
|
|
@ -1,77 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Ozone::OxygenConfigUI</class>
|
||||
<widget class="QWidget" name="OxygenConfigUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>364</width>
|
||||
<height>92</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Ozone</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Title &Alignment</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="titleAlignmentLeft">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Left</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="titleAlignmentCenter">
|
||||
<property name="text">
|
||||
<string>Center</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="titleAlignmentRight">
|
||||
<property name="text">
|
||||
<string>&Right</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="blendTitlebarColors">
|
||||
<property name="whatsThis">
|
||||
<string>When enabled, this option makes the window title bar use the same colors as the window contents, instead of using the system title bar colors.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Blend title bar colors with window contents</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showStripes">
|
||||
<property name="whatsThis">
|
||||
<string>When enabled, this option increases the visibility of the window titlebar by showing stripes</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show stripes next to the title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,230 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenbutton.h
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE.
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "oxygen.h"
|
||||
#include "oxygenclient.h"
|
||||
#include <kconfiggroup.h>
|
||||
#include <QApplication>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
KDE_EXPORT KDecorationFactory* create_factory()
|
||||
{
|
||||
return new Ozone::Oxygen::OxygenFactory();
|
||||
}
|
||||
}
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
OxygenHelper *oxygenHelper(); // referenced from definition in oxygendclient.cpp
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OxygenFactory Class //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool OxygenFactory::initialized_ = false;
|
||||
Qt::Alignment OxygenFactory::titleAlignment_ = Qt::AlignLeft;
|
||||
bool OxygenFactory::showStripes_ = true;
|
||||
int OxygenFactory::borderSize_ = 4; // BorderSize::BorderNormal
|
||||
bool OxygenFactory::blendTitlebarColors_ = true;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OxygenFactory()
|
||||
// ----------------
|
||||
// Constructor
|
||||
|
||||
OxygenFactory::OxygenFactory()
|
||||
{
|
||||
readConfig();
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// ~OxygenFactory()
|
||||
// -----------------
|
||||
// Destructor
|
||||
|
||||
OxygenFactory::~OxygenFactory() { initialized_ = false; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// createDecoration()
|
||||
// -----------------
|
||||
// Create the decoration
|
||||
|
||||
KDecoration* OxygenFactory::createDecoration(KDecorationBridge* b)
|
||||
{
|
||||
return (new OxygenClient(b, this))->decoration();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// reset()
|
||||
// -------
|
||||
// Reset the handler. Returns true if decorations need to be remade, false if
|
||||
// only a repaint is necessary
|
||||
|
||||
bool OxygenFactory::reset(unsigned long changed)
|
||||
{
|
||||
// read in the configuration
|
||||
initialized_ = false;
|
||||
bool confchange = readConfig();
|
||||
initialized_ = true;
|
||||
|
||||
if (confchange ||
|
||||
(changed & (SettingDecoration | SettingButtons | SettingBorder))) {
|
||||
return true;
|
||||
} else {
|
||||
resetDecorations(changed);
|
||||
return false;
|
||||
}
|
||||
|
||||
// taken from plastik
|
||||
switch(KDecoration::options()->preferredBorderSize( this )) {
|
||||
case BorderTiny:
|
||||
borderSize_ = 2;
|
||||
break;
|
||||
case BorderLarge:
|
||||
borderSize_ = 8;
|
||||
break;
|
||||
case BorderVeryLarge:
|
||||
borderSize_ = 12;
|
||||
break;
|
||||
case BorderHuge:
|
||||
borderSize_ = 18;
|
||||
break;
|
||||
case BorderVeryHuge:
|
||||
borderSize_ = 27;
|
||||
break;
|
||||
case BorderOversized:
|
||||
borderSize_ = 40;
|
||||
break;
|
||||
case BorderNormal:
|
||||
default:
|
||||
borderSize_ = 4;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// readConfig()
|
||||
// ------------
|
||||
// Read in the configuration file
|
||||
|
||||
bool OxygenFactory::readConfig()
|
||||
{
|
||||
// create a config object
|
||||
KConfig config("oxygenrc");
|
||||
KConfigGroup group = config.group("Windeco");
|
||||
|
||||
// grab settings
|
||||
Qt::Alignment oldalign = titleAlignment_;
|
||||
QString value = group.readEntry("TitleAlignment", "Left");
|
||||
if (value == "Left")
|
||||
titleAlignment_ = Qt::AlignLeft;
|
||||
else if (value == "Center")
|
||||
titleAlignment_ = Qt::AlignHCenter;
|
||||
else if (value == "Right")
|
||||
titleAlignment_ = Qt::AlignRight;
|
||||
|
||||
int oldBorderSize = borderSize_;
|
||||
switch(KDecoration::options()->preferredBorderSize( this )) {
|
||||
case BorderTiny:
|
||||
borderSize_ = 2;
|
||||
break;
|
||||
case BorderLarge:
|
||||
borderSize_ = 8;
|
||||
break;
|
||||
case BorderVeryLarge:
|
||||
borderSize_ = 12;
|
||||
break;
|
||||
case BorderHuge:
|
||||
borderSize_ = 18;
|
||||
break;
|
||||
case BorderVeryHuge:
|
||||
borderSize_ = 27;
|
||||
break;
|
||||
case BorderOversized:
|
||||
borderSize_ = 40;
|
||||
break;
|
||||
case BorderNormal:
|
||||
default:
|
||||
borderSize_ = 4;
|
||||
}
|
||||
|
||||
bool oldstripes = showStripes_;
|
||||
showStripes_ = group.readEntry( "ShowStripes", true );
|
||||
|
||||
bool oldblend = blendTitlebarColors;
|
||||
blendTitlebarColors_ = group.readEntry( "BlendTitlebarColors", true );
|
||||
|
||||
if (oldalign == titleAlignment_ && oldstripes == showStripes_
|
||||
&& oldBorderSize == borderSize_)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OxygenFactory::supports( Ability ability ) const
|
||||
{
|
||||
switch( ability ) {
|
||||
// announce
|
||||
case AbilityAnnounceButtons:
|
||||
case AbilityAnnounceColors:
|
||||
// buttons
|
||||
case AbilityButtonMenu:
|
||||
case AbilityButtonHelp:
|
||||
case AbilityButtonMinimize:
|
||||
case AbilityButtonMaximize:
|
||||
case AbilityButtonClose:
|
||||
case AbilityButtonOnAllDesktops:
|
||||
case AbilityButtonAboveOthers:
|
||||
case AbilityButtonBelowOthers:
|
||||
case AbilityButtonSpacer:
|
||||
case AbilityButtonShade:
|
||||
// compositing
|
||||
case AbilityProvidesShadow: // TODO: UI option to use default shadows instead
|
||||
case AbilityUsesAlphaChannel:
|
||||
return true;
|
||||
// no colors supported at this time
|
||||
default:
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
QList< OxygenFactory::BorderSize >
|
||||
OxygenFactory::borderSizes() const
|
||||
{
|
||||
// the list must be sorted
|
||||
return QList< BorderSize >() << BorderTiny << BorderNormal <<
|
||||
BorderLarge << BorderVeryLarge << BorderHuge <<
|
||||
BorderVeryHuge << BorderOversized;
|
||||
}
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
|
@ -1,101 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenbutton.h
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE.
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef OXYGEN_H
|
||||
#define OXYGEN_H
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kdecorationfactory.h>
|
||||
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen
|
||||
{
|
||||
// OxygenFactory /////////////////////////////////////////////////////////////
|
||||
|
||||
static const int OXYGEN_BUTTONSIZE = 22;
|
||||
static const qreal SHADOW_WIDTH = 25.5;
|
||||
#define TFRAMESIZE 3
|
||||
|
||||
enum ButtonType {
|
||||
ButtonHelp=0,
|
||||
ButtonMax,
|
||||
ButtonMin,
|
||||
ButtonClose,
|
||||
ButtonMenu,
|
||||
ButtonSticky,
|
||||
ButtonAbove,
|
||||
ButtonBelow,
|
||||
ButtonShade,
|
||||
ButtonTypeCount
|
||||
};
|
||||
Q_DECLARE_FLAGS(ButtonTypes, ButtonType)
|
||||
|
||||
class OxygenFactory: public KDecorationFactoryUnstable
|
||||
{
|
||||
public:
|
||||
OxygenFactory();
|
||||
virtual ~OxygenFactory();
|
||||
virtual KDecoration *createDecoration(KDecorationBridge *b);
|
||||
virtual bool reset(unsigned long changed);
|
||||
virtual bool supports( Ability ability ) const;
|
||||
QList< BorderSize > borderSizes() const;
|
||||
|
||||
static bool initialized();
|
||||
static Qt::Alignment titleAlignment();
|
||||
static bool showStripes();
|
||||
static int borderSize();
|
||||
static bool blendTitlebarColors();
|
||||
|
||||
private:
|
||||
bool readConfig();
|
||||
|
||||
private:
|
||||
static bool initialized_;
|
||||
static Qt::Alignment titleAlignment_;
|
||||
static bool showStripes_;
|
||||
static int borderSize_;
|
||||
static bool blendTitlebarColors_;
|
||||
};
|
||||
|
||||
inline bool OxygenFactory::initialized()
|
||||
{ return initialized_; }
|
||||
|
||||
inline Qt::Alignment OxygenFactory::titleAlignment()
|
||||
{ return titleAlignment_; }
|
||||
|
||||
inline bool OxygenFactory::blendTitlebarColors()
|
||||
{ return blendTitlebarColors_; }
|
||||
|
||||
inline bool OxygenFactory::showStripes()
|
||||
{ return showStripes_; }
|
||||
|
||||
inline int OxygenFactory::borderSize()
|
||||
{ return borderSize_; }
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
||||
|
||||
#endif
|
|
@ -1,382 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenbutton.cpp
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE. Buttons.
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
||||
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "oxygenbutton.h"
|
||||
#include <kcommondecoration.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <QPainterPath>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QBitmap>
|
||||
|
||||
#include <kdecoration.h>
|
||||
#include <kglobal.h>
|
||||
#include <KColorUtils>
|
||||
#include <kdebug.h>
|
||||
#include <KColorScheme>
|
||||
|
||||
#include "oxygenclient.h"
|
||||
#include "oxygen.h"
|
||||
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen
|
||||
{
|
||||
// class OxygenClient;
|
||||
/*
|
||||
extern int BUTTONSIZE;
|
||||
extern int DECOSIZE;*/
|
||||
|
||||
// static const int DECOSIZE = 8;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OxygenButton Class //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OxygenButton()
|
||||
// ---------------
|
||||
// Constructor
|
||||
|
||||
OxygenButton::OxygenButton(OxygenClient &parent,
|
||||
const QString& tip, ButtonType type)
|
||||
: KCommonDecorationButton((::ButtonType)type, &parent)
|
||||
, client_(parent)
|
||||
, helper_(parent.helper_)
|
||||
, type_(type)
|
||||
, lastmouse_(0)
|
||||
, colorCacheInvalid_(true)
|
||||
{
|
||||
setAutoFillBackground(false);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||
setFixedSize(OXYGEN_BUTTONSIZE, OXYGEN_BUTTONSIZE);
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setToolTip(tip);
|
||||
}
|
||||
|
||||
OxygenButton::~OxygenButton()
|
||||
{
|
||||
}
|
||||
|
||||
//declare function from oxygenclient.cpp
|
||||
QColor reduceContrast(const QColor &c0, const QColor &c1, double t);
|
||||
|
||||
|
||||
QColor OxygenButton::buttonDetailColor(const QPalette &palette)
|
||||
{
|
||||
if (client_.isActive())
|
||||
return palette.color(QPalette::Active, QPalette::ButtonText);
|
||||
else {
|
||||
if (colorCacheInvalid_) {
|
||||
QColor ab = palette.color(QPalette::Active, QPalette::Button);
|
||||
QColor af = palette.color(QPalette::Active, QPalette::ButtonText);
|
||||
QColor nb = palette.color(QPalette::Inactive, QPalette::Button);
|
||||
QColor nf = palette.color(QPalette::Inactive, QPalette::ButtonText);
|
||||
|
||||
colorCacheInvalid_ = false;
|
||||
cachedButtonDetailColor_ = reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4))));
|
||||
}
|
||||
return cachedButtonDetailColor_;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sizeHint()
|
||||
// ----------
|
||||
// Return size hint
|
||||
|
||||
QSize OxygenButton::sizeHint() const
|
||||
{
|
||||
return QSize(OXYGEN_BUTTONSIZE, OXYGEN_BUTTONSIZE);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// enterEvent()
|
||||
// ------------
|
||||
// Mouse has entered the button
|
||||
|
||||
void OxygenButton::enterEvent(QEvent *e)
|
||||
{
|
||||
KCommonDecorationButton::enterEvent(e);
|
||||
if (status_ != Oxygen::Pressed) {
|
||||
status_ = Oxygen::Hovered;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// leaveEvent()
|
||||
// ------------
|
||||
// Mouse has left the button
|
||||
|
||||
void OxygenButton::leaveEvent(QEvent *e)
|
||||
{
|
||||
KCommonDecorationButton::leaveEvent(e);
|
||||
// if we wanted to do mouseovers, we would keep track of it here
|
||||
status_ = Oxygen::Normal;
|
||||
update();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// mousePressEvent()
|
||||
// ------------
|
||||
// Mouse has pressed the button
|
||||
|
||||
void OxygenButton::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
status_ = Oxygen::Pressed;
|
||||
update();
|
||||
|
||||
KCommonDecorationButton::mousePressEvent(e);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// mouseReleaseEvent()
|
||||
// ------------
|
||||
// Mouse has released the button
|
||||
|
||||
void OxygenButton::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
status_ = Oxygen::Normal;
|
||||
update();
|
||||
|
||||
KCommonDecorationButton::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// drawButton()
|
||||
// ------------
|
||||
// Draw the button
|
||||
|
||||
void OxygenButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
QPalette pal = palette(); // de-const-ify
|
||||
|
||||
// Set palette to the right group.
|
||||
// TODO - fix KWin to do this for us :-).
|
||||
if (client_.isActive())
|
||||
pal.setCurrentColorGroup(QPalette::Active);
|
||||
else
|
||||
pal.setCurrentColorGroup(QPalette::Inactive);
|
||||
|
||||
QPalette pal2( pal );
|
||||
if( !OxygenFactory::blendTitlebarColors()) {
|
||||
pal2.setColor( window()->backgroundRole(), client_.options()->color(
|
||||
KDecorationDefines::ColorTitleBar, client_.isActive()));
|
||||
}
|
||||
// fill the grey square
|
||||
helper_.renderWindowBackground(&painter, this->rect(), this, pal2, 23 /*TODO: calculate this from layout metrics*/);
|
||||
painter.setClipRect(this->rect());
|
||||
|
||||
// draw dividing line
|
||||
painter.setRenderHints(QPainter::Antialiasing);
|
||||
QRect frame = client_.widget()->rect();
|
||||
int x = -this->geometry().x()+1;
|
||||
int w = frame.width()-2;
|
||||
|
||||
const int titleHeight = client_.layoutMetric(KCommonDecoration::LM_TitleHeight);
|
||||
|
||||
QColor color = OxygenFactory::blendTitlebarColors()?pal.window().color()
|
||||
:client_.options()->color( KDecorationDefines::ColorTitleBar, client_.isActive());
|
||||
QColor light = helper_.calcLightColor( color );
|
||||
QColor dark = helper_.calcDarkColor( color );
|
||||
|
||||
dark.setAlpha(120);
|
||||
|
||||
if(client_.isActive())
|
||||
{
|
||||
helper_.drawSeparator(&painter, QRect(x, titleHeight-1.5, w, 2), color, Qt::Horizontal);
|
||||
}
|
||||
|
||||
if (type_ == ButtonMenu)
|
||||
{
|
||||
// we paint the mini icon (which is 16 pixels high)
|
||||
int dx = (width() - 16) / 2;
|
||||
int dy = (height() - 16) / 2 - 1;
|
||||
painter.drawPixmap(dx, dy, client_.icon().pixmap(16));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(client_.maximizeMode() == OxygenClient::MaximizeRestore)
|
||||
{
|
||||
painter.translate(0,-1);
|
||||
}
|
||||
|
||||
QColor bg = helper_.backgroundTopColor(OxygenFactory::blendTitlebarColors()?pal.window().color()
|
||||
:client_.options()->color(KDecorationDefines::ColorTitleBar,client_.isActive()));
|
||||
|
||||
// get icon color
|
||||
color = buttonDetailColor(pal);
|
||||
if (status_ == Oxygen::Hovered || status_ == Oxygen::Pressed)
|
||||
{
|
||||
if (type_ == ButtonClose)
|
||||
{
|
||||
color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color();
|
||||
}
|
||||
else
|
||||
{
|
||||
color = KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color();
|
||||
}
|
||||
}
|
||||
|
||||
// draw button
|
||||
QColor bt = OxygenFactory::blendTitlebarColors()?pal.window().color()
|
||||
:client_.options()->color(KDecorationDefines::ColorButtonBg,client_.isActive());
|
||||
painter.drawPixmap(0, 0, helper_.windecoButton(bt, status_ == Oxygen::Pressed));
|
||||
|
||||
// draw glow on hover
|
||||
if (status_ == Oxygen::Hovered)
|
||||
{
|
||||
painter.drawPixmap(0, 0, helper_.windecoButtonGlow(color));
|
||||
}
|
||||
|
||||
if (client_.isActive())
|
||||
{
|
||||
painter.setRenderHints(QPainter::Antialiasing);
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
painter.setPen(QPen(color, 1.4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
drawIcon(&painter, pal, type_);
|
||||
}
|
||||
else
|
||||
{
|
||||
// outlined mode
|
||||
QPixmap pixmap(size());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter pp(&pixmap);
|
||||
pp.setRenderHints(QPainter::Antialiasing);
|
||||
pp.setBrush(Qt::NoBrush);
|
||||
pp.setPen(QPen(color, 3.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
drawIcon(&pp, pal, type_);
|
||||
|
||||
pp.setCompositionMode(QPainter::CompositionMode_DestinationOut);
|
||||
pp.setPen(QPen(color, 1.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
drawIcon(&pp, pal, type_);
|
||||
|
||||
painter.drawPixmap(QPoint(0,0), pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
void OxygenButton::drawIcon(QPainter *p, QPalette &pal, ButtonType &type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case ButtonSticky:
|
||||
if(isChecked()) {
|
||||
QPen newPen = p->pen();
|
||||
newPen.setColor(KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color());
|
||||
p->setPen(newPen);
|
||||
}
|
||||
p->drawPoint(QPointF(10.5,10.5));
|
||||
break;
|
||||
case ButtonHelp:
|
||||
p->translate(1.5, 1.5);
|
||||
p->drawArc(7,5,4,4,135*16, -180*16);
|
||||
p->drawArc(9,8,4,4,135*16,45*16);
|
||||
p->drawPoint(9,12);
|
||||
p->translate(-1.5, -1.5);
|
||||
break;
|
||||
case ButtonMin:
|
||||
p->drawLine(QPointF( 7.5, 9.5), QPointF(10.5,12.5));
|
||||
p->drawLine(QPointF(10.5,12.5), QPointF(13.5, 9.5));
|
||||
break;
|
||||
case ButtonMax:
|
||||
switch(client_.maximizeMode())
|
||||
{
|
||||
case OxygenClient::MaximizeRestore:
|
||||
case OxygenClient::MaximizeVertical:
|
||||
case OxygenClient::MaximizeHorizontal:
|
||||
p->drawLine(QPointF( 7.5,11.5), QPointF(10.5, 8.5));
|
||||
p->drawLine(QPointF(10.5, 8.5), QPointF(13.5,11.5));
|
||||
break;
|
||||
case OxygenClient::MaximizeFull:
|
||||
{
|
||||
p->translate(1.5, 1.5);
|
||||
//p->setBrush(lg);
|
||||
QPoint points[4] = {QPoint(9, 6), QPoint(12, 9), QPoint(9, 12), QPoint(6, 9)};
|
||||
//QPoint points[4] = {QPoint(9, 5), QPoint(13, 9), QPoint(9, 13), QPoint(5, 9)};
|
||||
p->drawPolygon(points, 4);
|
||||
p->translate(-1.5, -1.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ButtonClose:
|
||||
p->drawLine(QPointF( 7.5,7.5), QPointF(13.5,13.5));
|
||||
p->drawLine(QPointF(13.5,7.5), QPointF( 7.5,13.5));
|
||||
break;
|
||||
case ButtonAbove:
|
||||
if(isChecked()) {
|
||||
QPen newPen = p->pen();
|
||||
newPen.setColor(KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color());
|
||||
p->setPen(newPen);
|
||||
}
|
||||
|
||||
p->drawLine(QPointF( 7.5,14), QPointF(10.5,11));
|
||||
p->drawLine(QPointF(10.5,11), QPointF(13.5,14));
|
||||
p->drawLine(QPointF( 7.5,10), QPointF(10.5, 7));
|
||||
p->drawLine(QPointF(10.5, 7), QPointF(13.5,10));
|
||||
break;
|
||||
case ButtonBelow:
|
||||
if(isChecked()) {
|
||||
QPen newPen = p->pen();
|
||||
newPen.setColor(KColorScheme(pal.currentColorGroup()).decoration(KColorScheme::HoverColor).color());
|
||||
p->setPen(newPen);
|
||||
}
|
||||
|
||||
p->drawLine(QPointF( 7.5,11), QPointF(10.5,14));
|
||||
p->drawLine(QPointF(10.5,14), QPointF(13.5,11));
|
||||
p->drawLine(QPointF( 7.5, 7), QPointF(10.5,10));
|
||||
p->drawLine(QPointF(10.5,10), QPointF(13.5, 7));
|
||||
break;
|
||||
case ButtonShade:
|
||||
if (!isChecked()) // shade button
|
||||
{
|
||||
p->drawLine(QPointF( 7.5, 7.5), QPointF(10.5,10.5));
|
||||
p->drawLine(QPointF(10.5,10.5), QPointF(13.5, 7.5));
|
||||
p->drawLine(QPointF( 7.5,13.0), QPointF(13.5,13.0));
|
||||
} else { // unshade button
|
||||
p->drawLine(QPointF( 7.5,10.5), QPointF(10.5, 7.5));
|
||||
p->drawLine(QPointF(10.5, 7.5), QPointF(13.5,10.5));
|
||||
p->drawLine(QPointF( 7.5,13.0), QPointF(13.5,13.0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
|
@ -1,84 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenbutton.h
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE. Buttons.
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// class QAbstractButton;
|
||||
#ifndef OXYGENBUTTON_H
|
||||
#define OXYGENBUTTON_H
|
||||
|
||||
#include <kcommondecoration.h>
|
||||
|
||||
#include "oxygen.h"
|
||||
#include "oxygenclient.h"
|
||||
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen
|
||||
{
|
||||
class OxygenClient;
|
||||
|
||||
enum ButtonStatus {
|
||||
Normal,
|
||||
Hovered,
|
||||
Pressed };
|
||||
|
||||
Q_DECLARE_FLAGS(ButtonState, ButtonStatus)
|
||||
|
||||
class OxygenButton : public KCommonDecorationButton
|
||||
{
|
||||
public:
|
||||
explicit OxygenButton(OxygenClient &parent,
|
||||
const QString &tip=NULL,
|
||||
ButtonType type=ButtonHelp);
|
||||
~OxygenButton();
|
||||
|
||||
QSize sizeHint() const;
|
||||
int lastMousePress() const {return lastmouse_;}
|
||||
void reset(long unsigned int){repaint();}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void drawIcon(QPainter *p, QPalette &pal, ButtonType &type);
|
||||
QColor buttonDetailColor(const QPalette &palette);
|
||||
|
||||
private:
|
||||
OxygenClient &client_;
|
||||
OxygenHelper &helper_;
|
||||
ButtonType type_;
|
||||
ButtonState status_;
|
||||
int lastmouse_;
|
||||
bool colorCacheInvalid_;
|
||||
QColor cachedButtonDetailColor_;
|
||||
};
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
||||
|
||||
#endif
|
|
@ -1,658 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenclient.cpp
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// #ifndef OXYGENCLIENT_H
|
||||
// #define OXYGENCLIENT_H
|
||||
|
||||
#include "oxygenclient.h"
|
||||
|
||||
#include <KConfig>
|
||||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
#include <KDebug>
|
||||
#include <KColorUtils>
|
||||
|
||||
#include <QBitmap>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QPainter>
|
||||
#include <QToolTip>
|
||||
//Added by qt3to4:
|
||||
#include <QBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QResizeEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QShowEvent>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainterPath>
|
||||
#include <QTimer>
|
||||
#include <QCache>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
#include "math.h"
|
||||
|
||||
#include "oxygenclient.moc"
|
||||
#include "oxygenbutton.h"
|
||||
#include "oxygen.h"
|
||||
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("OxygenDeco"))
|
||||
|
||||
OxygenHelper *oxygenHelper()
|
||||
{
|
||||
return globalHelper;
|
||||
}
|
||||
|
||||
static void oxkwincleanupBefore()
|
||||
{
|
||||
OxygenHelper *h = globalHelper;
|
||||
h->invalidateCaches();
|
||||
}
|
||||
|
||||
void OxygenClient::invalidateCaches()
|
||||
{
|
||||
}
|
||||
|
||||
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
||||
{
|
||||
p->drawEllipse(QRectF(point.x()-diameter/2, point.y()-diameter/2, diameter, diameter));
|
||||
}
|
||||
|
||||
|
||||
OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f)
|
||||
: KCommonDecorationUnstable(b, f)
|
||||
, colorCacheInvalid_(true)
|
||||
, shadowTiles_(NULL)
|
||||
, glowTiles_(NULL)
|
||||
, helper_(*globalHelper)
|
||||
{
|
||||
qAddPostRoutine(oxkwincleanupBefore);
|
||||
}
|
||||
|
||||
OxygenClient::~OxygenClient()
|
||||
{
|
||||
delete glowTiles_;
|
||||
delete shadowTiles_;
|
||||
}
|
||||
QString OxygenClient::visibleName() const
|
||||
{
|
||||
return i18n("Ozone");
|
||||
}
|
||||
|
||||
void OxygenClient::init()
|
||||
{
|
||||
KCommonDecoration::init();
|
||||
|
||||
widget()->setAutoFillBackground(false);
|
||||
widget()->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
}
|
||||
|
||||
bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const
|
||||
{
|
||||
switch (behaviour) {
|
||||
case DB_MenuClose:
|
||||
return true;//Handler()->menuClose();
|
||||
|
||||
case DB_WindowMask:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return KCommonDecoration::decorationBehaviour(behaviour);
|
||||
}
|
||||
}
|
||||
|
||||
int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
|
||||
{
|
||||
bool maximized = isMaximized();
|
||||
int frameWidth = OxygenFactory::borderSize();
|
||||
|
||||
switch (lm) {
|
||||
case LM_BorderLeft:
|
||||
case LM_BorderRight:
|
||||
case LM_BorderBottom:
|
||||
{
|
||||
if (respectWindowState && maximized) {
|
||||
return 0;
|
||||
} else {
|
||||
// Even for thin borders (2px wide) we want to preserve
|
||||
// the rounded corners having a minimum height of 7px
|
||||
if (lm == LM_BorderBottom) {
|
||||
return qMax(frameWidth, 7);
|
||||
} else {
|
||||
return frameWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case LM_TitleEdgeTop:
|
||||
{
|
||||
if (respectWindowState && maximized) {
|
||||
return 0;
|
||||
} else {
|
||||
return TFRAMESIZE;
|
||||
}
|
||||
}
|
||||
|
||||
case LM_TitleEdgeBottom:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
case LM_TitleEdgeLeft:
|
||||
case LM_TitleEdgeRight:
|
||||
{
|
||||
if (respectWindowState && maximized) {
|
||||
return 0;
|
||||
} else {
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
case LM_TitleBorderLeft:
|
||||
case LM_TitleBorderRight:
|
||||
return 5;
|
||||
|
||||
case LM_ButtonWidth:
|
||||
case LM_ButtonHeight:
|
||||
case LM_TitleHeight:
|
||||
{
|
||||
if (respectWindowState && isToolWindow()) {
|
||||
return OXYGEN_BUTTONSIZE;
|
||||
} else {
|
||||
return OXYGEN_BUTTONSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
case LM_ButtonSpacing:
|
||||
return 1;
|
||||
|
||||
case LM_ButtonMarginTop:
|
||||
return 0;
|
||||
|
||||
// outer margin for shadow/glow
|
||||
case LM_OuterPaddingLeft:
|
||||
case LM_OuterPaddingRight:
|
||||
case LM_OuterPaddingTop:
|
||||
case LM_OuterPaddingBottom:
|
||||
return SHADOW_WIDTH;
|
||||
|
||||
default:
|
||||
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCommonDecorationButton *OxygenClient::createButton(::ButtonType type)
|
||||
{
|
||||
switch (type) {
|
||||
case MenuButton:
|
||||
return new OxygenButton(*this, i18n("Menu"), ButtonMenu);
|
||||
|
||||
case HelpButton:
|
||||
return new OxygenButton(*this, i18n("Help"), ButtonHelp);
|
||||
|
||||
case MinButton:
|
||||
return new OxygenButton(*this, i18n("Minimize"), ButtonMin);
|
||||
|
||||
case MaxButton:
|
||||
return new OxygenButton(*this, i18n("Maximize"), ButtonMax);
|
||||
|
||||
case CloseButton:
|
||||
return new OxygenButton(*this, i18n("Close"), ButtonClose);
|
||||
|
||||
case AboveButton:
|
||||
return new OxygenButton(*this, i18n("Keep Above Others"), ButtonAbove);
|
||||
|
||||
case BelowButton:
|
||||
return new OxygenButton(*this, i18n("Keep Below Others"), ButtonBelow);
|
||||
|
||||
case OnAllDesktopsButton:
|
||||
return new OxygenButton(*this, i18n("On All Desktops"), ButtonSticky);
|
||||
|
||||
case ShadeButton:
|
||||
return new OxygenButton(*this, i18n("Shade Button"), ButtonShade);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// c0 - background
|
||||
// c1 - foreground
|
||||
// t - target contrast ratio
|
||||
QColor reduceContrast(const QColor &c0, const QColor &c1, double t)
|
||||
{
|
||||
double s = KColorUtils::contrastRatio(c0, c1);
|
||||
if (s < t)
|
||||
return c1;
|
||||
|
||||
double l = 0.0, h = 1.0;
|
||||
double x = s, a;
|
||||
QColor r = c1;
|
||||
for (int maxiter = 16; maxiter; --maxiter) {
|
||||
a = 0.5 * (l + h);
|
||||
r = KColorUtils::mix(c0, c1, a);
|
||||
x = KColorUtils::contrastRatio(c0, r);
|
||||
if (fabs(x - t) < 0.01)
|
||||
break;
|
||||
if (x > t)
|
||||
h = a;
|
||||
else
|
||||
l = a;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
QColor OxygenClient::titlebarTextColor(const QPalette &palette)
|
||||
{
|
||||
if( !OxygenFactory::blendTitlebarColors())
|
||||
return options()->color(ColorFont, isActive());
|
||||
if (isActive())
|
||||
return palette.color(QPalette::Active, QPalette::WindowText);
|
||||
else {
|
||||
if(colorCacheInvalid_) {
|
||||
QColor ab = palette.color(QPalette::Active, QPalette::Window);
|
||||
QColor af = palette.color(QPalette::Active, QPalette::WindowText);
|
||||
QColor nb = palette.color(QPalette::Inactive, QPalette::Window);
|
||||
QColor nf = palette.color(QPalette::Inactive, QPalette::WindowText);
|
||||
|
||||
colorCacheInvalid_ = false;
|
||||
cachedTitlebarTextColor_ = reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4))));
|
||||
}
|
||||
return cachedTitlebarTextColor_;
|
||||
}
|
||||
}
|
||||
|
||||
bool OxygenClient::isMaximized() const
|
||||
{
|
||||
return maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
|
||||
}
|
||||
|
||||
void OxygenClient::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
if (!OxygenFactory::initialized()) return;
|
||||
|
||||
QPalette palette = widget()->palette();
|
||||
QPainter painter(widget());
|
||||
|
||||
// Set palette to the right group.
|
||||
// TODO - fix KWin to do this for us :-).
|
||||
if (isActive())
|
||||
palette.setCurrentColorGroup(QPalette::Active);
|
||||
else
|
||||
palette.setCurrentColorGroup(QPalette::Inactive);
|
||||
|
||||
int x,y,w,h;
|
||||
QRect frame = widget()->rect();
|
||||
frame.adjust(SHADOW_WIDTH, SHADOW_WIDTH, -SHADOW_WIDTH, -SHADOW_WIDTH);
|
||||
|
||||
QColor color = OxygenFactory::blendTitlebarColors() ? palette.window().color() : options()->color( ColorTitleBar, isActive());
|
||||
QColor light = helper_.calcLightColor( color );
|
||||
QColor dark = helper_.calcDarkColor( color );
|
||||
|
||||
const int titleHeight = layoutMetric(LM_TitleHeight);
|
||||
const int titleTop = layoutMetric(LM_TitleEdgeTop) + frame.top();
|
||||
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
||||
const int marginLeft = layoutMetric(LM_TitleBorderLeft);
|
||||
const int marginRight = layoutMetric(LM_TitleBorderRight);
|
||||
|
||||
const int titleLeft = frame.left() + titleEdgeLeft + buttonsLeftWidth() + marginLeft;
|
||||
const int titleWidth = frame.width() -
|
||||
titleEdgeLeft - layoutMetric(LM_TitleEdgeRight) -
|
||||
buttonsLeftWidth() - buttonsRightWidth() -
|
||||
marginLeft - marginRight;
|
||||
|
||||
QPalette pal2( palette );
|
||||
if( !OxygenFactory::blendTitlebarColors()) {
|
||||
pal2.setColor( QPalette::Window, options()->color(
|
||||
KDecorationDefines::ColorTitleBar, isActive()));
|
||||
}
|
||||
|
||||
// draw shadow
|
||||
|
||||
if (compositingActive() && !isMaximized())
|
||||
shadowTiles(color,KDecoration::options()->color(ColorTitleBar),
|
||||
SHADOW_WIDTH, isActive())->render( frame.adjusted(-SHADOW_WIDTH+4,
|
||||
-SHADOW_WIDTH+4, SHADOW_WIDTH-4, SHADOW_WIDTH-4),
|
||||
&painter, TileSet::Ring);
|
||||
|
||||
// draw window background
|
||||
bool isCompositingActive = compositingActive();
|
||||
|
||||
if (isCompositingActive) {
|
||||
frame.getRect(&x, &y, &w, &h);
|
||||
|
||||
QRegion mask(x+5, y+0, w-10, h-0);
|
||||
mask += QRegion(x+0, y+5, w-0, h-10);
|
||||
mask += QRegion(x+1, y+3, w-2, h-6);
|
||||
mask += QRegion(x+2, y+2, w-4, h-4);
|
||||
mask += QRegion(x+3, y+1, w-6, h-2);
|
||||
|
||||
painter.setClipRegion(mask);
|
||||
}
|
||||
|
||||
helper_.renderWindowBackground(&painter, frame, this->widget(), pal2, SHADOW_WIDTH);
|
||||
|
||||
if (isCompositingActive) {
|
||||
painter.setClipping(false);
|
||||
}
|
||||
|
||||
// draw title text
|
||||
painter.setFont(options()->font(isActive(), false));
|
||||
painter.setPen(titlebarTextColor(pal2));
|
||||
painter.drawText(titleLeft, titleTop-1, titleWidth, titleHeight, // -1 is to go into top resizearea
|
||||
OxygenFactory::titleAlignment() | Qt::AlignVCenter, caption());
|
||||
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
// Draw dividing line
|
||||
if (compositingActive()) {
|
||||
frame.adjust(-1,-1,1,1);
|
||||
}
|
||||
frame.getRect(&x, &y, &w, &h);
|
||||
|
||||
if(isActive()) {
|
||||
helper_.drawSeparator(&painter, QRect(x, titleTop+titleHeight-1.5, w, 2), color, Qt::Horizontal);
|
||||
}
|
||||
|
||||
// draw stripes as indicator for active windows
|
||||
if (isActive() && OxygenFactory::showStripes()) {
|
||||
Qt::Alignment align = OxygenFactory::titleAlignment();
|
||||
if (widget()->layoutDirection() == Qt::RightToLeft)
|
||||
{
|
||||
if (align == Qt::AlignLeft)
|
||||
align = Qt::AlignRight;
|
||||
else if (align == Qt::AlignRight)
|
||||
align = Qt::AlignLeft;
|
||||
}
|
||||
|
||||
if (align & Qt::AlignLeft) {
|
||||
int left = titleLeft + QFontMetrics(options()->font(isActive(), false)).width(caption()) + 4;
|
||||
int right = titleLeft + titleWidth;
|
||||
if (left < right)
|
||||
drawStripes(&painter, palette, left, right, titleTop+6);
|
||||
}
|
||||
if (align & Qt::AlignRight) {
|
||||
int left = titleLeft;
|
||||
int right = titleLeft + titleWidth - QFontMetrics(options()->font(isActive(), false)).width(caption()) - 4;
|
||||
if (left < right)
|
||||
drawStripes(&painter, palette, right, left, titleTop+6);
|
||||
}
|
||||
if (align & Qt::AlignHCenter) {
|
||||
int textWidth = QFontMetrics(options()->font(isActive(), false)).width(caption());
|
||||
int left = titleLeft;
|
||||
int centerLeft = titleLeft + titleWidth/2 - textWidth/2 - 4;
|
||||
int centerRight = titleLeft + titleWidth/2 + textWidth/2 + 4;
|
||||
int right = titleLeft + titleWidth;
|
||||
if (left < centerLeft && right > centerRight) {
|
||||
drawStripes(&painter, palette, centerLeft, left, titleTop+6);
|
||||
drawStripes(&painter, palette, centerRight, right, titleTop+6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw shadows of the frame
|
||||
if(isMaximized())
|
||||
return;
|
||||
|
||||
helper_.drawFloatFrame(&painter, frame, color, !compositingActive(), isActive(),
|
||||
KDecoration::options()->color(ColorTitleBar));
|
||||
|
||||
if(!isResizable())
|
||||
return;
|
||||
|
||||
// Draw the 3-dots resize handles
|
||||
qreal cenY = frame.height() / 2 + x + 0.5;
|
||||
qreal posX = frame.width() + y - 2.5;
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(QColor(0, 0, 0, 66));
|
||||
renderDot(&painter, QPointF(posX, cenY - 3), 1.8);
|
||||
renderDot(&painter, QPointF(posX, cenY), 1.8);
|
||||
renderDot(&painter, QPointF(posX, cenY + 3), 1.8);
|
||||
|
||||
painter.translate(x + frame.width()-9, y + frame.height()-9);
|
||||
renderDot(&painter, QPointF(2.5, 6.5), 1.8);
|
||||
renderDot(&painter, QPointF(5.5, 5.5), 1.8);
|
||||
renderDot(&painter, QPointF(6.5, 2.5), 1.8);
|
||||
}
|
||||
|
||||
void OxygenClient::drawStripes(QPainter *p, QPalette &palette, const int start, const int end, const int topMargin)
|
||||
{
|
||||
QLinearGradient stripeGradient(QPoint(start,0), QPoint(end,0));
|
||||
stripeGradient.setColorAt(0.0, Qt::transparent);
|
||||
stripeGradient.setColorAt(0.05, KDecoration::options()->color(ColorTitleBar));
|
||||
stripeGradient.setColorAt(1.0, Qt::transparent);
|
||||
QPen pen1(stripeGradient, 0.5);
|
||||
|
||||
QLinearGradient stripeGradient2(QPoint(start,0), QPoint(end,0));
|
||||
stripeGradient2.setColorAt(0.0, Qt::transparent);
|
||||
stripeGradient2.setColorAt(0.05, helper_.calcLightColor(palette.color(QPalette::Window)));
|
||||
stripeGradient2.setColorAt(1.0, Qt::transparent);
|
||||
QPen pen2(stripeGradient2, 0.5);
|
||||
|
||||
bool antialiasing = p->testRenderHint(QPainter::Antialiasing);
|
||||
p->setRenderHint(QPainter::Antialiasing, false);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
p->setPen(pen1);
|
||||
p->drawLine(QPointF(start, topMargin+4*i), QPointF(end, topMargin+4*i));
|
||||
p->setPen(pen2);
|
||||
p->drawLine(QPointF(start, topMargin+4*i+1), QPointF(end, topMargin+4*i+1));
|
||||
}
|
||||
p->setRenderHint(QPainter::Antialiasing, antialiasing);
|
||||
}
|
||||
|
||||
|
||||
void OxygenClient::updateWindowShape()
|
||||
{
|
||||
if(isMaximized() || compositingActive()) {
|
||||
clearMask();
|
||||
return;
|
||||
}
|
||||
|
||||
int w=widget()->width() - (int)SHADOW_WIDTH;
|
||||
int h=widget()->height() - (int)SHADOW_WIDTH;
|
||||
|
||||
// set a mask if compositing is not active
|
||||
int sw = SHADOW_WIDTH;
|
||||
QRegion mask(sw+4, sw+0, -sw+w-8, -sw+h);
|
||||
mask += QRegion(sw+0, sw+4, -sw+w, -sw+h-8);
|
||||
mask += QRegion(sw+2, sw+1, -sw+w-4, -sw+h-2);
|
||||
mask += QRegion(sw+1, sw+2, -sw+w-2, -sw+h-4);
|
||||
|
||||
setMask(mask);
|
||||
}
|
||||
|
||||
TileSet *OxygenClient::shadowTiles(const QColor& color, const QColor& glow, qreal size, bool active)
|
||||
{
|
||||
ShadowTilesOption opt;
|
||||
opt.active = active;
|
||||
opt.width = size;
|
||||
opt.windowColor = color;
|
||||
opt.glowColor = glow;
|
||||
|
||||
ShadowTilesOption currentOpt = active ? shadowTilesOption_ : glowTilesOption_;
|
||||
|
||||
bool optionChanged = true;
|
||||
if (currentOpt.active == opt.active
|
||||
&& currentOpt.width == opt.width
|
||||
&& opt.windowColor == opt.windowColor
|
||||
&& opt.glowColor == opt.glowColor)
|
||||
optionChanged = false;
|
||||
|
||||
if (active && glowTiles_ && !optionChanged)
|
||||
return glowTiles_;
|
||||
else if (!active && shadowTiles_ && !optionChanged)
|
||||
return shadowTiles_;
|
||||
|
||||
TileSet *tileSet = 0;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Create new glow/shadow tiles
|
||||
|
||||
QColor light = oxygenHelper()->calcLightColor(oxygenHelper()->backgroundTopColor(color));
|
||||
QColor dark = oxygenHelper()->calcDarkColor(oxygenHelper()->backgroundBottomColor(color));
|
||||
|
||||
QPixmap shadow = QPixmap( size*2, size*2 );
|
||||
shadow.fill( Qt::transparent );
|
||||
|
||||
// draw the corner of the window - actually all 4 corners as one circle
|
||||
QLinearGradient lg = QLinearGradient(0.0, size-4.5, 0.0, size+4.5);
|
||||
lg.setColorAt(0.52, light);
|
||||
lg.setColorAt(1.0, dark);
|
||||
|
||||
QPainter p( &shadow );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
|
||||
if (active)
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Active shadow texture
|
||||
|
||||
QRadialGradient rg( size, size, size );
|
||||
QColor c = color;
|
||||
c.setAlpha( 255 ); rg.setColorAt( 4.4/size, c );
|
||||
c.setAlpha( 220 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 180 ); rg.setColorAt( 5/size, c );
|
||||
c.setAlpha( 25 ); rg.setColorAt( 5.5/size, c );
|
||||
c.setAlpha( 0 ); rg.setColorAt( 6.5/size, c );
|
||||
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
rg = QRadialGradient( size, size, size );
|
||||
c = color;
|
||||
c.setAlpha( 255 ); rg.setColorAt( 4.4/size, c );
|
||||
c = glow;
|
||||
c.setAlpha( 0.58*255 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 0.43*255 ); rg.setColorAt( 5.5/size, c );
|
||||
c.setAlpha( 0.30*255 ); rg.setColorAt( 6.5/size, c );
|
||||
c.setAlpha( 0.22*255 ); rg.setColorAt( 7.5/size, c );
|
||||
c.setAlpha( 0.15*255 ); rg.setColorAt( 8.5/size, c );
|
||||
c.setAlpha( 0.08*255 ); rg.setColorAt( 11.5/size, c );
|
||||
c.setAlpha( 0); rg.setColorAt( 14.5/size, c );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
p.setBrush( Qt::NoBrush );
|
||||
p.setPen(QPen(lg, 0.8));
|
||||
p.drawEllipse(QRectF(size-4, size-4, 8, 8));
|
||||
|
||||
p.end();
|
||||
|
||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||
glowTilesOption_ = opt;
|
||||
if (glowTiles_) {
|
||||
delete glowTiles_;
|
||||
}
|
||||
glowTiles_ = tileSet;
|
||||
} else {
|
||||
//---------------------------------------------------------------
|
||||
// Inactive shadow texture
|
||||
|
||||
QRadialGradient rg = QRadialGradient( size, size+4, size );
|
||||
QColor c = QColor( Qt::black );
|
||||
c.setAlpha( 0.12*255 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 0.11*255 ); rg.setColorAt( 6.6/size, c );
|
||||
c.setAlpha( 0.075*255 ); rg.setColorAt( 8.5/size, c );
|
||||
c.setAlpha( 0.06*255 ); rg.setColorAt( 11.5/size, c );
|
||||
c.setAlpha( 0.035*255 ); rg.setColorAt( 14.5/size, c );
|
||||
c.setAlpha( 0.025*255 ); rg.setColorAt( 17.5/size, c );
|
||||
c.setAlpha( 0.01*255 ); rg.setColorAt( 21.5/size, c );
|
||||
c.setAlpha( 0.0*255 ); rg.setColorAt( 25.5/size, c );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
rg = QRadialGradient( size, size+2, size );
|
||||
c = QColor( Qt::black );
|
||||
c.setAlpha( 0.25*255 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 0.20*255 ); rg.setColorAt( 5.5/size, c );
|
||||
c.setAlpha( 0.13*255 ); rg.setColorAt( 7.5/size, c );
|
||||
c.setAlpha( 0.06*255 ); rg.setColorAt( 8.5/size, c );
|
||||
c.setAlpha( 0.015*255 ); rg.setColorAt( 11.5/size, c );
|
||||
c.setAlpha( 0.0*255 ); rg.setColorAt( 14.5/size, c );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
rg = QRadialGradient( size, size+0.2, size );
|
||||
c = color;
|
||||
c = QColor( Qt::black );
|
||||
c.setAlpha( 0.35*255 ); rg.setColorAt( 0/size, c );
|
||||
c.setAlpha( 0.32*255 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 0.22*255 ); rg.setColorAt( 5.0/size, c );
|
||||
c.setAlpha( 0.03*255 ); rg.setColorAt( 5.5/size, c );
|
||||
c.setAlpha( 0.0*255 ); rg.setColorAt( 6.5/size, c );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
rg = QRadialGradient( size, size, size );
|
||||
c = color;
|
||||
c.setAlpha( 255 ); rg.setColorAt( 4.0/size, c );
|
||||
c.setAlpha( 0 ); rg.setColorAt( 4.01/size, c );
|
||||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
p.setBrush( rg );
|
||||
p.drawRect( shadow.rect() );
|
||||
|
||||
// draw the corner of the window - actually all 4 corners as one circle
|
||||
p.setBrush( Qt::NoBrush );
|
||||
p.setPen(QPen(lg, 0.8));
|
||||
p.drawEllipse(QRectF(size-4, size-4, 8, 8));
|
||||
|
||||
p.end();
|
||||
|
||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||
shadowTilesOption_ = opt;
|
||||
if (shadowTiles_) {
|
||||
delete shadowTiles_;
|
||||
}
|
||||
shadowTiles_ = tileSet;
|
||||
}
|
||||
return tileSet;
|
||||
}
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
||||
|
||||
//#include "oxygenclient.moc"
|
||||
|
||||
// #endif
|
|
@ -1,90 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenclient.h
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE
|
||||
// -------------------
|
||||
// Copyright (c) 2003, 2004 David Johnson <david@usermode.org>
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef OXYGENCLIENT_H
|
||||
#define OXYGENCLIENT_H
|
||||
|
||||
|
||||
#include <kcommondecoration.h>
|
||||
|
||||
#include "lib/helper.h"
|
||||
#include "lib/tileset.h"
|
||||
|
||||
class QPoint;
|
||||
|
||||
namespace Ozone
|
||||
{
|
||||
namespace Oxygen {
|
||||
|
||||
class OxygenClient : public KCommonDecorationUnstable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OxygenClient(KDecorationBridge *b, KDecorationFactory *f);
|
||||
virtual ~OxygenClient();
|
||||
virtual void invalidateCaches();
|
||||
|
||||
virtual QString visibleName() const;
|
||||
virtual KCommonDecorationButton *createButton(::ButtonType type);
|
||||
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
|
||||
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
||||
virtual void updateWindowShape();
|
||||
virtual void init();
|
||||
|
||||
private:
|
||||
struct ShadowTilesOption {
|
||||
QColor windowColor;
|
||||
QColor glowColor;
|
||||
qreal width;
|
||||
bool active;
|
||||
};
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void drawStripes(QPainter *p, QPalette &palette, const int start, const int end, const int topMargin);
|
||||
QColor titlebarTextColor(const QPalette &palette);
|
||||
bool isMaximized() const;
|
||||
bool colorCacheInvalid_;
|
||||
QColor cachedTitlebarTextColor_;
|
||||
|
||||
TileSet *shadowTiles(const QColor& color, const QColor& glow, qreal size, bool active);
|
||||
|
||||
ShadowTilesOption shadowTilesOption_;
|
||||
ShadowTilesOption glowTilesOption_;
|
||||
TileSet *shadowTiles_;
|
||||
TileSet *glowTiles_;
|
||||
|
||||
protected:
|
||||
friend class OxygenButton;
|
||||
OxygenHelper &helper_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Oxygen
|
||||
} // namespace Ozone
|
||||
|
||||
#endif // EXAMPLECLIENT_H
|
|
@ -1,38 +0,0 @@
|
|||
# KDE Desktop Entry
|
||||
[Desktop Entry]
|
||||
Name=Ozone
|
||||
Name[ar]=أوزون
|
||||
Name[bg]=Озон
|
||||
Name[bn]=ওজোন
|
||||
Name[bn_IN]=Ozone (ওজোন)
|
||||
Name[csb]=Òzón
|
||||
Name[de]=Ozon
|
||||
Name[es]=Ozono
|
||||
Name[eu]=Ozonoa
|
||||
Name[ga]=Ózón
|
||||
Name[gu]=ઓઝોન
|
||||
Name[hi]=ओजोन
|
||||
Name[hne]=ओजोन
|
||||
Name[hr]=Ozon
|
||||
Name[id]=Ozon
|
||||
Name[it]=Ozono
|
||||
Name[kk]=Озон
|
||||
Name[km]=អូហ្សូន
|
||||
Name[kn]=ಓಜೋನ್
|
||||
Name[mai]=ओजोन
|
||||
Name[mk]=Озон
|
||||
Name[ml]=ഓസോണ്
|
||||
Name[mr]=ओझोन
|
||||
Name[nds]=Ozoon
|
||||
Name[nn]=Ozon
|
||||
Name[pa]=ਓਜ਼ੋਨ
|
||||
Name[ro]=Ozon
|
||||
Name[ru]=Озон
|
||||
Name[sl]=Ozon
|
||||
Name[sr]=Озон
|
||||
Name[te]=ఓజోన్
|
||||
Name[th]=โอโซน
|
||||
Name[uk]=Озон
|
||||
Name[x-test]=xxOzonexx
|
||||
Name[zh_CN]=臭氧
|
||||
X-KDE-Library=kwin3_ozone
|
|
@ -1,72 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenbutton.h
|
||||
// -------------------
|
||||
// Ozone window decoration for KDE. Buttons.
|
||||
// -------------------
|
||||
// Copyright (c) 2006, 2007 Riccardo Iaconelli <ruphy@fsfe.org>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OxygenWidget : public QWidget
|
||||
{
|
||||
protected:
|
||||
virtual void paintEvent ( QPaintEvent * event );
|
||||
};
|
||||
|
||||
void OxygenWidget::paintEvent ( QPaintEvent * )
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
QRadialGradient grad1(QPointF(5.0, 5.0),5.0);
|
||||
grad1.setColorAt(0.9, QColor(0,0,0,100));
|
||||
grad1.setColorAt(1.0, QColor(0,0,0,0));
|
||||
QRadialGradient grad2(QPointF(5.0, 5.0),5.0);
|
||||
grad2.setColorAt(0.0, QColor(235,235,235));
|
||||
grad2.setColorAt(1.0, QColor(220,220,220));
|
||||
QRadialGradient grad3(QPointF(5.0, 3.75), 3.5,QPointF(5.0, 2.5));
|
||||
grad3.setColorAt(0, QColor(255,255,255,50));
|
||||
grad3.setColorAt(1, QColor(255,255,255,0));
|
||||
QRadialGradient grad4(QPointF(5.0, 3.3), 3.5, QPointF(5.0, 2.1));
|
||||
grad4.setColorAt(0, QColor(255,255,255,50));
|
||||
grad4.setColorAt(1, QColor(255,255,255,0));
|
||||
QBrush brush1(grad1);
|
||||
QBrush brush2(grad2);
|
||||
QBrush brush3(grad3);
|
||||
QBrush brush4(grad4);
|
||||
|
||||
painter.scale(1.6, 1.6);
|
||||
painter.setRenderHint(QPainter::Antialiasing,true);
|
||||
|
||||
QPainterPath path1;
|
||||
path1.addEllipse(0.0, 0.0, 10.0, 10.0);
|
||||
painter.fillPath(path1, brush1);
|
||||
|
||||
QPainterPath path2;
|
||||
path2.addEllipse(0.5, 0.5, 9.0, 9.0);
|
||||
painter.fillPath(path2, brush2);
|
||||
|
||||
QPainterPath path3;
|
||||
path3.addEllipse(1.5, 0.5, 7.0, 6.0);
|
||||
painter.fillPath(path3, brush3);
|
||||
|
||||
QPainterPath path4;
|
||||
path4.addEllipse(1.5, 0.5, 7.0, 6.0);
|
||||
painter.fillPath(path4, brush4);
|
||||
}
|
|
@ -443,7 +443,7 @@ void KWinDecorationModule::readConfig( const KConfigGroup & conf )
|
|||
|
||||
oldLibraryName = currentLibraryName;
|
||||
currentLibraryName = conf.readEntry("PluginLib",
|
||||
((QPixmap::defaultDepth() > 8) ? "kwin3_ozone" : "kwin3_plastik"));
|
||||
((QPixmap::defaultDepth() > 8) ? "kwin3_nitrogen" : "kwin3_plastik"));
|
||||
QString decoName = decorationName( currentLibraryName );
|
||||
|
||||
// If we are using the "default" kde client, use the "default" entry.
|
||||
|
@ -548,8 +548,8 @@ void KWinDecorationModule::defaults()
|
|||
// Don't set default for now
|
||||
// decorationList->setSelected(
|
||||
// decorationList->findItem( i18n("KDE 2") ), true ); // KDE classic client
|
||||
decorationList->setCurrentItem( i18n("Ozone"), true ); // KDE classic client
|
||||
slotChangeDecoration(i18n("Ozone"));
|
||||
decorationList->setCurrentItem( i18n("Nitrogen"), true ); // KDE classic client
|
||||
slotChangeDecoration(i18n("Nitrogen"));
|
||||
|
||||
buttonPositionWidget->setButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
|
||||
buttonPositionWidget->setButtonsRight(KDecorationOptions::defaultTitleButtonsRight());
|
||||
|
|
|
@ -33,7 +33,7 @@ PluginMgr::PluginMgr()
|
|||
: KDecorationPlugins( KGlobal::config())
|
||||
{
|
||||
defaultPlugin = (QPixmap::defaultDepth() > 8) ?
|
||||
"kwin3_ozone" : "kwin3_plastik";
|
||||
"kwin3_nitrogen" : "kwin3_plastik";
|
||||
loadPlugin( "" ); // load the plugin specified in cfg file
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue