Move Oxygen kwin decoration to the oxygen folder

icc-effect-5.14.5
Àlex Fiestas 2014-03-24 16:43:11 +01:00
parent f8134f9393
commit b33425baaa
53 changed files with 0 additions and 9880 deletions

View File

@ -133,7 +133,6 @@ endif()
include(CMakeDependentOption)
option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_OXYGEN "Enable building of default decoration Oxygen" ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
option(KWIN_BUILD_SCREENEDGES "Enable building of KWin with screen edge support" ON)

View File

@ -1,5 +1,2 @@
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1216)
add_subdirectory( aurorae )
if(KWIN_BUILD_OXYGEN)
add_subdirectory( oxygen )
endif()

View File

@ -1,36 +0,0 @@
########### add version number into compilation defines
add_definitions (-DAPP_VERSION=\\\"${KWIN_VERSION}\\\")
add_definitions(-DHAVE_X11=${X11_FOUND})
add_subdirectory(config)
add_subdirectory(demo)
add_subdirectory(data)
########### next target ###############
set(kwin_oxygen_SRCS
oxygenbutton.cpp
oxygenclient.cpp
oxygenclientgroupitemdata.cpp
oxygendecohelper.cpp
oxygenexceptionlist.cpp
oxygenfactory.cpp
oxygensizegrip.cpp
oxygentitleanimationdata.cpp
)
kconfig_add_kcfg_files(kwin_oxygen_SRCS oxygenconfiguration.kcfgc )
add_library(kwin3_oxygen MODULE ${kwin_oxygen_SRCS})
target_link_libraries(kwin3_oxygen Qt5::Widgets )
target_link_libraries(kwin3_oxygen KF5::I18n KF5::WindowSystem KF5::Style KF5::Service)
target_link_libraries(kwin3_oxygen kdecorations)
target_link_libraries(kwin3_oxygen oxygenstyle)
kservice_desktop_to_json(kwin3_oxygen oxygenclient.desktop)
if(X11_FOUND)
target_link_libraries(kwin3_oxygen XCB::XCB)
endif()
install(TARGETS kwin3_oxygen DESTINATION ${PLUGIN_INSTALL_DIR}/kwin/kdecorations)

View File

@ -1,35 +0,0 @@
set(kwin_oxygen_config_PART_SRCS
oxygenanimationconfigwidget.cpp
oxygenconfig.cpp
oxygenconfigwidget.cpp
oxygendetectwidget.cpp
oxygenexceptiondialog.cpp
oxygenexceptionlistwidget.cpp
oxygenexceptionmodel.cpp
../oxygenexceptionlist.cpp
)
kconfig_add_kcfg_files(kwin_oxygen_config_PART_SRCS ../oxygenconfiguration.kcfgc)
set( kwin_oxygen_config_PART_FORMS
ui/oxygenconfigurationui.ui
ui/oxygendetectwidget.ui
ui/oxygenexceptiondialog.ui
ui/oxygenexceptionlistwidget.ui
)
qt5_wrap_ui(kwin_oxygen_config_PART_FORMS_HEADERS ${kwin_oxygen_config_PART_FORMS})
add_library(kwin_oxygen_config MODULE
${kwin_oxygen_config_PART_SRCS}
${kwin_oxygen_config_PART_FORMS_HEADERS})
target_link_libraries(kwin_oxygen_config Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus)
target_link_libraries(kwin_oxygen_config KF5::WindowSystem KF5::Completion)
target_link_libraries(kwin_oxygen_config kdecorations oxygenstyle oxygenstyleconfig)
if(X11_FOUND)
target_link_libraries(kwin_oxygen_config XCB::XCB)
target_link_libraries(kwin_oxygen_config Qt5::X11Extras)
endif()
install(TARGETS kwin_oxygen_config DESTINATION ${QT_PLUGIN_INSTALL_DIR}/kf5/kwin/kdecorations/config)

View File

@ -1,3 +0,0 @@
{
"X-KDE-PluginInfo-Name": "Oxygen"
}

View File

@ -1,156 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenanimationconfigwidget.cpp
// animation configuration widget
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenanimationconfigwidget.h"
#include "oxygenanimationconfigwidget.moc"
#include "oxygenanimationconfigitem.h"
#include "oxygengenericanimationconfigitem.h"
#include <QButtonGroup>
#include <QHoverEvent>
#include <QTextStream>
#include <KLocalizedString>
namespace Oxygen
{
//_______________________________________________
AnimationConfigWidget::AnimationConfigWidget( QWidget* parent ):
BaseAnimationConfigWidget( parent )
{
QGridLayout* layout( qobject_cast<QGridLayout*>( BaseAnimationConfigWidget::layout() ) );
setupItem( layout, _buttonAnimations = new GenericAnimationConfigItem( this,
i18n("Button mouseover transition"),
i18n("Configure window buttons' mouseover highlight animation" ) ) );
setupItem( layout, _titleAnimations = new GenericAnimationConfigItem( this,
i18n("Title transitions" ),
i18n("Configure fading transitions when window title is changed" ) ) );
setupItem( layout, _shadowAnimations = new GenericAnimationConfigItem( this,
i18n("Window active state change transitions" ),
i18n("Configure fading between window shadow and glow when window's active state is changed" ) ) );
setupItem( layout, _tabAnimations = new GenericAnimationConfigItem( this,
i18n("Window grouping animations" ),
i18n("Configure window titlebar animations when windows are grouped/ungrouped" ) ) );
// add spacers to the first column, previous row to finalize layout
layout->addItem( new QSpacerItem( 25, 0 ), _row-1, 0, 1, 1 );
// add vertical spacer
layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ), _row, 1, 1, 1 );
++_row;
connect( animationsEnabled(), SIGNAL(toggled(bool)), SLOT(updateChanged()) );
foreach( AnimationConfigItem* item, findChildren<AnimationConfigItem*>() )
{
item->QWidget::setEnabled( false );
connect( animationsEnabled(), SIGNAL(toggled(bool)), item, SLOT(setEnabled(bool)) );
}
}
//_______________________________________________
void AnimationConfigWidget::load( void )
{
// check configuration
if( !_configuration ) return;
animationsEnabled()->setChecked( _configuration->animationsEnabled() );
_buttonAnimations->setEnabled( _configuration->buttonAnimationsEnabled() );
_buttonAnimations->setDuration( _configuration->buttonAnimationsDuration() );
_titleAnimations->setEnabled( _configuration->titleAnimationsEnabled() );
_titleAnimations->setDuration( _configuration->titleAnimationsDuration() );
_shadowAnimations->setEnabled( _configuration->shadowAnimationsEnabled() );
_shadowAnimations->setDuration( _configuration->shadowAnimationsDuration() );
_tabAnimations->setEnabled( _configuration->tabAnimationsEnabled() );
_tabAnimations->setDuration( _configuration->tabAnimationsDuration() );
setChanged( false );
}
//_______________________________________________
void AnimationConfigWidget::save( void )
{
// check configuration
if( !_configuration ) return;
// save modifications
_configuration->setAnimationsEnabled( animationsEnabled()->isChecked() );
_configuration->setButtonAnimationsEnabled( _buttonAnimations->enabled() );
_configuration->setButtonAnimationsDuration( _buttonAnimations->duration() );
_configuration->setTitleAnimationsEnabled( _titleAnimations->enabled() );
_configuration->setTitleAnimationsDuration( _titleAnimations->duration() );
_configuration->setShadowAnimationsEnabled( _shadowAnimations->enabled() );
_configuration->setShadowAnimationsDuration( _shadowAnimations->duration() );
_configuration->setTabAnimationsEnabled( _tabAnimations->enabled() );
_configuration->setTabAnimationsDuration( _tabAnimations->duration() );
setChanged( false );
}
//_______________________________________________
void AnimationConfigWidget::updateChanged( void )
{
// check configuration
if( !_configuration ) return;
// track modifications
bool modified( false );
if( animationsEnabled()->isChecked() != _configuration->animationsEnabled() ) modified = true;
else if( _buttonAnimations->enabled() != _configuration->buttonAnimationsEnabled() ) modified = true;
else if( _buttonAnimations->duration() != _configuration->buttonAnimationsDuration() ) modified = true;
else if( _titleAnimations->enabled() != _configuration->titleAnimationsEnabled() ) modified = true;
else if( _titleAnimations->duration() != _configuration->titleAnimationsDuration() ) modified = true;
else if( _shadowAnimations->enabled() != _configuration->shadowAnimationsEnabled() ) modified = true;
else if( _shadowAnimations->duration() != _configuration->shadowAnimationsDuration() ) modified = true;
else if( _tabAnimations->enabled() != _configuration->tabAnimationsEnabled() ) modified = true;
else if( _tabAnimations->duration() != _configuration->tabAnimationsDuration() ) modified = true;
setChanged( modified );
}
}

View File

@ -1,88 +0,0 @@
#ifndef oxygenanimationconfigwidget_h
#define oxygenanimationconfigwidget_h
//////////////////////////////////////////////////////////////////////////////
// oxygenanimationconfigwidget.h
// animation configuration item
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "../oxygendecorationdefines.h"
#include "oxygenbaseanimationconfigwidget.h"
namespace Oxygen
{
// forward declaration
class GenericAnimationConfigItem;
//! container to configure animations individually
class AnimationConfigWidget: public BaseAnimationConfigWidget
{
Q_OBJECT
public:
//! constructor
explicit AnimationConfigWidget( QWidget* = 0 );
//! destructor
virtual ~AnimationConfigWidget( void )
{}
//! configuration
void setConfiguration( ConfigurationPtr configuration )
{ _configuration = configuration; }
public Q_SLOTS:
//! read current configuration
virtual void load( void );
//! save current configuration
virtual void save( void );
protected Q_SLOTS:
//! check whether configuration is changed and emit appropriate signal if yes
virtual void updateChanged();
private:
//! local configuration, needed to handle I/O
ConfigurationPtr _configuration;
//!@name animations
//@{
GenericAnimationConfigItem* _buttonAnimations;
GenericAnimationConfigItem* _titleAnimations;
GenericAnimationConfigItem* _shadowAnimations;
GenericAnimationConfigItem* _tabAnimations;
//@}
};
}
#endif

View File

@ -1,181 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// config.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
// Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
//
// Based on the Quartz configuration module,
// Copyright (c) 2001 Karol Szwed <gallium@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 "oxygenconfig.h"
#include "oxygenanimationconfigwidget.h"
#include "oxygenconfiguration.h"
#include "oxygenutil.h"
#include "../oxygenexceptionlist.h"
#include <QTextStream>
#include <QDBusConnection>
#include <QDBusMessage>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginFactory>
//_______________________________________________________________________
K_PLUGIN_FACTORY_WITH_JSON(OxygenConfigPlugin,
"config.json",
registerPlugin<Oxygen::Config>(QString(), &Oxygen::Config::create); )
namespace Oxygen
{
QObject *Config::create(QWidget *parentWidget, QObject *, const QList<QVariant> &)
{
return new Config(parentWidget);
}
//_______________________________________________________________________
Config::Config(QWidget* parent ):
QObject( parent )
{
// configuration
_configuration = KSharedConfig::openConfig( QStringLiteral( "oxygenrc" ) );
// create new configuration widget and add to layout, if any
_configWidget = new ConfigWidget( parent );
if( parent && parent->layout() ) parent->layout()->addWidget( _configWidget );
else _configWidget->show();
load();
connect( _configWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
}
//_______________________________________________________________________
Config::~Config()
{ delete _configWidget; }
//_______________________________________________________________________
void Config::toggleExpertMode( bool value )
{ _configWidget->toggleExpertMode( value ); }
//_______________________________________________________________________
void Config::load( void )
{
// load standard configuration
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
loadConfiguration( configuration );
// load shadows
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
{ ui->readConfig( _configuration.data() ); }
// load exceptions
ExceptionList exceptions;
exceptions.readConfig( _configuration );
_configWidget->exceptionListWidget()->setExceptions( exceptions.get() );
updateChanged();
}
//_______________________________________________________________________
void Config::updateChanged( void )
{
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
bool modified( false );
// exceptions
if( _configWidget->isChanged() ) modified = true;
// emit relevant signals
if( modified ) emit changed();
emit changed( modified );
}
//_______________________________________________________________________
void Config::save( void )
{
// create configuration from group
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
// save config widget
_configWidget->setConfiguration( configuration );
_configWidget->save();
// save standard configuration
Util::writeConfig( configuration.data(), _configuration.data() );
// get list of exceptions and write
ConfigurationList exceptions( _configWidget->exceptionListWidget()->exceptions() );
ExceptionList( exceptions ).writeConfig( _configuration );
// write shadow configuration
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
{ ui->writeConfig( _configuration.data() ); }
// sync configuration
_configuration->sync();
QDBusMessage message( QDBusMessage::createSignal( QStringLiteral( "/OxygenWindeco" ), QStringLiteral( "org.kde.Oxygen.Style" ), QStringLiteral( "reparseConfiguration") ) );
QDBusConnection::sessionBus().send(message);
}
//_______________________________________________________________________
void Config::defaults( void )
{
// install default configuration
ConfigurationPtr configuration( new Configuration() );
configuration->setDefaults();
loadConfiguration( configuration );
// load shadows
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
{ ui->readDefaults( _configuration.data() ); }
updateChanged();
}
//_______________________________________________________________________
void Config::loadConfiguration( ConfigurationPtr configuration )
{
_configWidget->setConfiguration( configuration );
_configWidget->load();
}
}
#include "oxygenconfig.moc"

View File

@ -1,112 +0,0 @@
#ifndef oxygen_config_h
#define oxygen_config_h
//////////////////////////////////////////////////////////////////////////////
// config.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
// Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
//
// Based on the Quartz configuration module,
// Copyright (c) 2001 Karol Szwed <gallium@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 "oxygenconfigwidget.h"
#include "oxygenconfiguration.h"
#include "../oxygendecorationdefines.h"
#include <KSharedConfig>
#include <QPalette>
namespace Oxygen {
class Configuration;
// oxygen configuration object
class Config: public QObject
{
Q_OBJECT
public:
//! constructor
Config( QWidget* parent );
//! destructor
~Config();
static QObject *create(QWidget *parentWidget, QObject *parent, const QList<QVariant> &arguments);
Q_SIGNALS:
//! emmited whenever configuration is changed
void changed();
//! emmited whenever configuration is changed
void changed( bool );
public Q_SLOTS:
//! load configuration
/*! although kconfiggroup argument is not used. It is required by KWin API */
void load( const KConfigGroup& )
{ load(); }
//! save configuration
/*! although kconfiggroup argument is not used. It is required by KWin API */
void save( KConfigGroup& )
{ save(); }
//! load configuration
void load( void );
//! save configuration
void save( void );
//! restore defaults
void defaults( void );
//! toggle expert mode
void toggleExpertMode( bool );
private Q_SLOTS:
//! update change state
void updateChanged( void );
private:
//! load configuration
void loadConfiguration( ConfigurationPtr );
//! user interface
ConfigWidget* _configWidget;
//! kconfiguration object
KSharedConfig::Ptr _configuration;
};
} //namespace Oxygen
#endif

View File

@ -1,251 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenconfigurationui.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenconfigwidget.h"
#include "oxygenanimationconfigwidget.h"
#include <QGroupBox>
#include <QIcon>
#include <QLabel>
#include <QLayout>
#include <KLocalizedString>
namespace Oxygen
{
//_________________________________________________________
ConfigWidget::ConfigWidget( QWidget* parent ):
QWidget( parent ),
_expertMode( false ),
_animationConfigWidget(0),
_changed( false )
{
ui.setupUi( this );
// shadow configuration
ui.activeShadowConfiguration->setGroup( QPalette::Active );
ui.inactiveShadowConfiguration->setGroup( QPalette::Inactive );
shadowConfigurations.append( ui.activeShadowConfiguration );
shadowConfigurations.append( ui.inactiveShadowConfiguration );
// animation config widget
_animationConfigWidget = new AnimationConfigWidget();
_animationConfigWidget->installEventFilter( this );
// expert mode
ui._expertModeButton->setIcon( QIcon::fromTheme( QStringLiteral( "configure" ) ) );
toggleExpertModeInternal( false );
// connections
connect( ui._expertModeButton, SIGNAL(clicked()), SLOT(toggleExpertModeInternal()) );
connect( _animationConfigWidget, SIGNAL(layoutChanged()), SLOT(updateLayout()) );
// track ui changes
connect( ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( ui.buttonSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( ui.frameBorder, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( ui.titleOutline, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( ui.drawSizeGrip, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( ui.narrowButtonSpacing, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( ui.closeFromMenuButton, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( ui.separatorMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( ui.drawBorderOnMaximizedWindows, SIGNAL(clicked()), SLOT(updateChanged()) );
// track exception changes
connect( ui.exceptions, SIGNAL(changed(bool)), SLOT(updateChanged()) );
// track shadow configuration changes
connect( shadowConfigurations[0], SIGNAL(changed(bool)), SLOT(updateChanged()) );
connect( shadowConfigurations[1], SIGNAL(changed(bool)), SLOT(updateChanged()) );
// track animations changes
connect( ui.animationsEnabled, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( _animationConfigWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
}
//_________________________________________________________
void ConfigWidget::setConfiguration( ConfigurationPtr configuration )
{
_configuration = configuration;
_animationConfigWidget->setConfiguration( configuration );
}
//_________________________________________________________
void ConfigWidget::load( void )
{
if( !_configuration ) return;
ui.titleAlignment->setCurrentIndex( _configuration->titleAlignment() );
ui.buttonSize->setCurrentIndex( _configuration->buttonSize() );
ui.frameBorder->setCurrentIndex( _configuration->frameBorder() );
ui.separatorMode->setCurrentIndex( _configuration->separatorMode() );
ui.drawSizeGrip->setChecked( _configuration->drawSizeGrip() );
ui.titleOutline->setChecked( _configuration->drawTitleOutline() );
ui.animationsEnabled->setChecked( _configuration->animationsEnabled() );
ui.narrowButtonSpacing->setChecked( _configuration->useNarrowButtonSpacing() );
ui.closeFromMenuButton->setChecked( _configuration->closeWindowFromMenuButton() );
ui.drawBorderOnMaximizedWindows->setChecked( _configuration->drawBorderOnMaximizedWindows() );
setChanged( false );
_animationConfigWidget->load();
}
//_________________________________________________________
void ConfigWidget::save( void )
{
if( !_configuration ) return;
// apply modifications from ui
_configuration->setTitleAlignment( ui.titleAlignment->currentIndex() );
_configuration->setButtonSize( ui.buttonSize->currentIndex() );
_configuration->setFrameBorder( ui.frameBorder->currentIndex() );
_configuration->setSeparatorMode( ui.separatorMode->currentIndex() );
_configuration->setDrawSizeGrip( ui.drawSizeGrip->isChecked() );
_configuration->setDrawTitleOutline( ui.titleOutline->isChecked() );
_configuration->setUseNarrowButtonSpacing( ui.narrowButtonSpacing->isChecked() );
_configuration->setCloseWindowFromMenuButton( ui.closeFromMenuButton->isChecked() );
_configuration->setDrawBorderOnMaximizedWindows( ui.drawBorderOnMaximizedWindows->isChecked() );
setChanged( false );
if( _expertMode ) _animationConfigWidget->save();
else _configuration->setAnimationsEnabled( ui.animationsEnabled->isChecked() );
}
//_________________________________________________________
void ConfigWidget::toggleExpertMode( bool value )
{
ui._expertModeContainer->hide();
toggleExpertModeInternal( value );
}
//_________________________________________________________
void ConfigWidget::toggleExpertModeInternal( bool value )
{
// store value
_expertMode = value;
// update button text
ui._expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
// narrow button spacing
ui.narrowButtonSpacing->setVisible( _expertMode );
// size grip
ui.drawSizeGrip->setVisible( _expertMode );
// 'basic' animations enabled flag
ui.animationsEnabled->setVisible( !_expertMode );
// layout and animations
if( _expertMode )
{
// add animationConfigWidget to tabbar if needed
if( ui.tabWidget->indexOf( _animationConfigWidget ) < 0 )
{ ui.tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
} else {
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
if( int index = ui.tabWidget->indexOf( _animationConfigWidget ) >= 0 )
{ ui.tabWidget->removeTab( index ); }
}
}
//__________________________________________________________________
bool ConfigWidget::eventFilter( QObject* object, QEvent* event )
{
switch( event->type() )
{
case QEvent::ShowToParent:
object->event( event );
updateLayout();
return true;
default:
return false;
}
}
//__________________________________________________________________
void ConfigWidget::updateLayout( void )
{
int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
}
//_______________________________________________
void ConfigWidget::updateChanged( void )
{
// check configuration
if( !_configuration ) return;
// track modifications
bool modified( false );
if( ui.titleAlignment->currentIndex() != _configuration->titleAlignment() ) modified = true;
else if( ui.buttonSize->currentIndex() != _configuration->buttonSize() ) modified = true;
else if( ui.frameBorder->currentIndex() != _configuration->frameBorder() ) modified = true;
else if( ui.separatorMode->currentIndex() != _configuration->separatorMode() ) modified = true;
else if( ui.drawSizeGrip->isChecked() != _configuration->drawSizeGrip() ) modified = true;
else if( ui.titleOutline->isChecked() != _configuration->drawTitleOutline() ) modified = true;
else if( ui.narrowButtonSpacing->isChecked() != _configuration->useNarrowButtonSpacing() ) modified = true;
else if( ui.closeFromMenuButton->isChecked() != _configuration->closeWindowFromMenuButton() ) modified = true;
else if( ui.drawBorderOnMaximizedWindows->isChecked() != _configuration->drawBorderOnMaximizedWindows() ) modified = true;
// exceptions
else if( ui.exceptions->isChanged() ) modified = true;
// shadow configurations
else if( shadowConfigurations[0]->isChanged() ) modified = true;
else if( shadowConfigurations[1]->isChanged() ) modified = true;
// animations
else if( !_expertMode && ui.animationsEnabled->isChecked() != _configuration->animationsEnabled() ) modified = true;
else if( _expertMode && _animationConfigWidget->isChanged() ) modified = true;
setChanged( modified );
}
}

View File

@ -1,135 +0,0 @@
#ifndef oxygenconfigwidget_h
#define oxygenconfigwidget_h
//////////////////////////////////////////////////////////////////////////////
// oxygenconfigurationui.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "ui_oxygenconfigurationui.h"
#include "oxygenshadowconfigwidget.h"
#include "oxygenexceptionlistwidget.h"
#include "../oxygendecorationdefines.h"
#include <KComboBox>
#include <QWidget>
#include <QCheckBox>
#include <QVector>
namespace Oxygen
{
class AnimationConfigWidget;
//_____________________________________________
class ConfigWidget: public QWidget
{
Q_OBJECT
public:
//! constructor
explicit ConfigWidget( QWidget* );
//! destructor
virtual ~ConfigWidget( void )
{}
//! set configuration
void setConfiguration( ConfigurationPtr );
//! load configuration
void load( void );
//! save configuration
void save( void );
//! true if changed
virtual bool isChanged( void ) const
{ return _changed; }
//! exceptions
ExceptionListWidget* exceptionListWidget( void ) const
{ return ui.exceptions; }
//! shadow configuration
QVector<ShadowConfigWidget*> shadowConfigurations;
//! toggle expert mode
void toggleExpertMode( bool );
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
Q_SIGNALS:
//! emmited when changed
void changed( bool );
protected Q_SLOTS:
//! toggle expert mode
void toggleExpertModeInternal( void )
{ toggleExpertModeInternal( !_expertMode ); }
//! toggle expert mode
void toggleExpertModeInternal( bool );
//! update changed state
virtual void updateChanged();
//! update layout
/*! needed in expert mode to accommodate with animations config widget size changes */
void updateLayout( void );
protected:
//! set changed state
virtual void setChanged( bool value )
{
_changed = value;
emit changed( value );
}
private:
//! ui
Ui_OxygenConfigurationUI ui;
//! internal exception
ConfigurationPtr _configuration;
//! expert mode
bool _expertMode;
//! animation config (expert mode only)
AnimationConfigWidget* _animationConfigWidget;
//! changed state
bool _changed;
};
}
#endif

View File

@ -1,175 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygendetectwidget.cpp
// Note: this class is a stripped down version of
// /kdebase/workspace/kwin/kcmkwin/kwinrules/detectwidget.cpp
// Copyright (c) 2004 Lubos Lunak <l.lunak@kde.org>
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygendetectwidget.h"
#include "oxygendetectwidget.moc"
#include <QButtonGroup>
#include <QLayout>
#include <QGroupBox>
#include <QMouseEvent>
#include <QPushButton>
#include <QX11Info>
#include <xcb/xcb.h>
namespace Oxygen
{
//_________________________________________________________
DetectDialog::DetectDialog( QWidget* parent ):
QDialog( parent ),
_grabber( 0 ),
_wmStateAtom( 0 )
{
// setup
setupUi( this );
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL(clicked()), this, SLOT(close()) );
windowClassCheckBox->setChecked( true );
// create atom
xcb_connection_t* connection( QX11Info::connection() );
const QString atomName( QStringLiteral( "WM_STATE" ) );
xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, atomName.size(), qPrintable( atomName ) ) );
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> reply( xcb_intern_atom_reply( connection, cookie, nullptr) );
_wmStateAtom = reply ? reply->atom : 0;
}
//_________________________________________________________
void DetectDialog::detect( WId window )
{
if( window == 0 ) selectWindow();
else readWindow( window );
}
//_________________________________________________________
void DetectDialog::readWindow( WId window )
{
if( window == 0 )
{
emit detectionDone( false );
return;
}
_info.reset(new KWindowInfo( window, NET::WMAllProperties, NET::WM2AllProperties ));
if( !_info->valid())
{
emit detectionDone( false );
return;
}
const QString wmClassClass( QString::fromUtf8( _info->windowClassClass() ) );
const QString wmClassName( QString::fromUtf8( _info->windowClassName() ) );
windowClass->setText( QStringLiteral( "%1 (%2 %3)" ).arg( wmClassClass ).arg( wmClassName ).arg( wmClassClass ) );
Ui::OxygenDetectWidget::windowTitle->setText( _info->name() );
emit detectionDone( exec() == QDialog::Accepted );
return;
}
//_________________________________________________________
void DetectDialog::selectWindow()
{
// use a dialog, so that all user input is blocked
// use WX11BypassWM and moving away so that it's not actually visible
// grab only mouse, so that keyboard can be used e.g. for switching windows
_grabber = new QDialog( 0, Qt::X11BypassWindowManagerHint );
_grabber->move( -1000, -1000 );
_grabber->setModal( true );
_grabber->show();
// need to explicitly override cursor for Qt5
qApp->setOverrideCursor( Qt::CrossCursor );
_grabber->grabMouse( Qt::CrossCursor );
_grabber->installEventFilter( this );
}
//_________________________________________________________
bool DetectDialog::eventFilter( QObject* o, QEvent* e )
{
// check object and event type
if( o != _grabber ) return false;
if( e->type() != QEvent::MouseButtonRelease ) return false;
// need to explicitely release cursor for Qt5
qApp->restoreOverrideCursor();
// delete old _grabber
delete _grabber;
_grabber = 0;
// check button
if( static_cast< QMouseEvent* >( e )->button() != Qt::LeftButton ) return true;
// read window information
readWindow( findWindow() );
return true;
}
//_________________________________________________________
WId DetectDialog::findWindow()
{
// check atom
if( !_wmStateAtom ) return 0;
xcb_connection_t* connection( QX11Info::connection() );
xcb_window_t parent( QX11Info::appRootWindow() );
// why is there a loop of only 10 here
for( int i = 0; i < 10; ++i )
{
// query pointer
xcb_query_pointer_cookie_t pointerCookie( xcb_query_pointer( connection, parent ) );
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter> pointerReply( xcb_query_pointer_reply( connection, pointerCookie, nullptr ) );
if( !( pointerReply && pointerReply->child ) ) return 0;
const xcb_window_t child( pointerReply->child );
xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, child, _wmStateAtom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0 ) );
QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( xcb_get_property_reply( connection, cookie, nullptr ) );
if( reply && reply->type ) return child;
else parent = child;
}
return 0;
}
}

View File

@ -1,111 +0,0 @@
#ifndef oxygendetectwidget_h
#define oxygendetectwidget_h
//////////////////////////////////////////////////////////////////////////////
// oxygendetectwidget.h
// Note: this class is a stripped down version of
// /kdebase/workspace/kwin/kcmkwin/kwinrules/detectwidget.h
// Copyright (c) 2004 Lubos Lunak <l.lunak@kde.org>
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenconfiguration.h"
#include "ui_oxygendetectwidget.h"
#include <QByteArray>
#include <QCheckBox>
#include <QDialog>
#include <QEvent>
#include <QLabel>
#include <kwindowsystem.h>
#include <xcb/xcb.h>
namespace Oxygen
{
class DetectDialog : public QDialog, Ui::OxygenDetectWidget
{
Q_OBJECT
public:
//! constructor
explicit DetectDialog( QWidget* );
//! read window properties or select one from mouse grab
void detect( WId window );
//! selected class
QByteArray selectedClass() const;
//! window information
const KWindowInfo& windowInfo() const
{ return *(_info.data()); }
//! exception type
Configuration::EnumExceptionType exceptionType() const
{
if( windowClassCheckBox->isChecked() ) return Configuration::ExceptionWindowClassName;
else if( windowTitleCheckBox->isChecked() ) return Configuration::ExceptionWindowTitle;
else return Configuration::ExceptionWindowClassName;
}
Q_SIGNALS:
void detectionDone( bool );
protected:
virtual bool eventFilter( QObject* o, QEvent* e );
private:
//! select window from grab
void selectWindow();
//! read window properties
void readWindow( WId window );
//! find window under cursor
WId findWindow();
//! execute
void executeDialog( void );
//! invisible dialog used to grab mouse
QDialog* _grabber;
//! current window information
QScopedPointer<KWindowInfo> _info;
//! wm state atom
xcb_atom_t _wmStateAtom;
};
} // namespace
#endif

View File

@ -1,189 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptiondialog.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenexceptiondialog.h"
#include "oxygenexceptiondialog.moc"
#include "oxygendetectwidget.h"
namespace Oxygen
{
//___________________________________________
ExceptionDialog::ExceptionDialog( QWidget* parent ):
QDialog( parent ),
_detectDialog(0),
_changed( false )
{
setupUi( this );
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL(clicked()), this, SLOT(close()) );
// store checkboxes from ui into list
_checkBoxes.insert( FrameBorder, frameBorderCheckBox );
_checkBoxes.insert( SizeGripMode, sizeGripCheckBox );
_checkBoxes.insert( TitleOutline, titleOutlineCheckBox );
_checkBoxes.insert( DrawSeparator, separatorCheckBox );
// detect window properties
connect( detectDialogButton, SIGNAL(clicked()), SLOT(selectWindowProperties()) );
// connections
connect( exceptionType, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( exceptionEditor, SIGNAL(textChanged(QString)), SLOT(updateChanged()) );
connect( frameBorderComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( sizeGripComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( titleOutlineComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( separatorComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{ connect( iter.value(), SIGNAL(clicked()), SLOT(updateChanged()) ); }
connect( hideTitleBar, SIGNAL(clicked()), SLOT(updateChanged()) );
}
//___________________________________________
void ExceptionDialog::setException( ConfigurationPtr exception )
{
// store exception internally
_exception = exception;
// type
exceptionType->setCurrentIndex(_exception->exceptionType() );
exceptionEditor->setText( _exception->exceptionPattern() );
frameBorderComboBox->setCurrentIndex( _exception->frameBorder() );
sizeGripComboBox->setCurrentIndex( _exception->drawSizeGrip() );
separatorComboBox->setCurrentIndex( _exception->separatorMode() );
titleOutlineComboBox->setCurrentIndex( _exception->drawTitleOutline() );
hideTitleBar->setChecked( _exception->hideTitleBar() );
// mask
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{ iter.value()->setChecked( _exception->mask() & iter.key() ); }
setChanged( false );
}
//___________________________________________
void ExceptionDialog::save( void )
{
_exception->setExceptionType( exceptionType->currentIndex() );
_exception->setExceptionPattern( exceptionEditor->text() );
_exception->setFrameBorder( frameBorderComboBox->currentIndex() );
_exception->setDrawSizeGrip( sizeGripComboBox->currentIndex() );
_exception->setSeparatorMode( separatorComboBox->currentIndex() );
_exception->setDrawTitleOutline( titleOutlineComboBox->currentIndex() );
_exception->setHideTitleBar( hideTitleBar->isChecked() );
// mask
unsigned int mask = None;
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{ if( iter.value()->isChecked() ) mask |= iter.key(); }
_exception->setMask( mask );
setChanged( false );
}
//___________________________________________
void ExceptionDialog::updateChanged( void )
{
bool modified( false );
if( _exception->exceptionType() != exceptionType->currentIndex() ) modified = true;
else if( _exception->exceptionPattern() != exceptionEditor->text() ) modified = true;
else if( _exception->frameBorder() != frameBorderComboBox->currentIndex() ) modified = true;
else if( _exception->drawSizeGrip() != sizeGripComboBox->currentIndex() ) modified = true;
else if( _exception->separatorMode() != separatorComboBox->currentIndex() ) modified = true;
else if( _exception->drawTitleOutline() != titleOutlineComboBox->currentIndex() ) modified = true;
else if( _exception->hideTitleBar() != hideTitleBar->isChecked() ) modified = true;
else
{
// check mask
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{
if( iter.value()->isChecked() != (bool)( _exception->mask() & iter.key() ) )
{
modified = true;
break;
}
}
}
setChanged( modified );
}
//___________________________________________
void ExceptionDialog::selectWindowProperties( void )
{
// create widget
if( !_detectDialog )
{
_detectDialog = new DetectDialog( this );
connect( _detectDialog, SIGNAL(detectionDone(bool)), SLOT(readWindowProperties(bool)) );
}
_detectDialog->detect(0);
}
//___________________________________________
void ExceptionDialog::readWindowProperties( bool valid )
{
Q_CHECK_PTR( _detectDialog );
if( valid )
{
// type
exceptionType->setCurrentIndex( _detectDialog->exceptionType() );
// window info
const KWindowInfo& info( _detectDialog->windowInfo() );
switch( _detectDialog->exceptionType() )
{
default:
case Configuration::ExceptionWindowClassName:
exceptionEditor->setText( QString::fromUtf8( info.windowClassClass() ) );
break;
case Configuration::ExceptionWindowTitle:
exceptionEditor->setText( info.name() );
break;
}
}
delete _detectDialog;
_detectDialog = 0;
}
}

View File

@ -1,112 +0,0 @@
#ifndef oxygenexceptiondialog_h
#define oxygenexceptiondialog_h
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptiondialog.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "ui_oxygenexceptiondialog.h"
#include "../oxygendecorationdefines.h"
#include <QCheckBox>
#include <QMap>
namespace Oxygen
{
class DetectDialog;
//! oxygen exceptions list
class ExceptionDialog: public QDialog, Ui::OxygenExceptionDialog
{
Q_OBJECT
public:
//! constructor
explicit ExceptionDialog( QWidget* parent );
//! destructor
virtual ~ExceptionDialog( void )
{}
//! set exception
void setException( ConfigurationPtr );
//! save exception
void save( void );
//! true if changed
virtual bool isChanged( void ) const
{ return _changed; }
Q_SIGNALS:
//! emmited when changed
void changed( bool );
protected:
//! set changed state
virtual void setChanged( bool value )
{
_changed = value;
emit changed( value );
}
protected Q_SLOTS:
//! check whether configuration is changed and emit appropriate signal if yes
virtual void updateChanged();
private Q_SLOTS:
//! select window properties from grabbed pointers
void selectWindowProperties( void );
//! read properties of selected window
void readWindowProperties( bool );
private:
//! map mask and checkbox
typedef QMap< ExceptionMask, QCheckBox*> CheckBoxMap;
//! map mask and checkbox
CheckBoxMap _checkBoxes;
//! internal exception
ConfigurationPtr _exception;
//! detection dialog
DetectDialog* _detectDialog;
//! changed state
bool _changed;
};
}
#endif

View File

@ -1,347 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionlistwidget.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenexceptionlistwidget.h"
#include "oxygenexceptionlistwidget.moc"
#include "oxygenexceptiondialog.h"
#include <QMessageBox>
#include <QPointer>
#include <QIcon>
#include <KLocalizedString>
//__________________________________________________________
namespace Oxygen
{
//__________________________________________________________
ExceptionListWidget::ExceptionListWidget( QWidget* parent ):
QWidget( parent ),
_changed( false )
{
//! ui
ui.setupUi( this );
// list
ui.exceptionListView->setAllColumnsShowFocus( true );
ui.exceptionListView->setRootIsDecorated( false );
ui.exceptionListView->setSortingEnabled( false );
ui.exceptionListView->setModel( &model() );
ui.exceptionListView->sortByColumn( ExceptionModel::TYPE );
ui.exceptionListView->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Ignored ) );
ui.moveUpButton->setIcon( QIcon::fromTheme( QStringLiteral( "arrow-up" ) ) );
ui.moveDownButton->setIcon( QIcon::fromTheme( QStringLiteral( "arrow-down" ) ) );
ui.addButton->setIcon( QIcon::fromTheme( QStringLiteral( "list-add" ) ) );
ui.removeButton->setIcon( QIcon::fromTheme( QStringLiteral( "list-remove" ) ) );
ui.editButton->setIcon( QIcon::fromTheme( QStringLiteral( "edit-rename" ) ) );
connect( ui.addButton, SIGNAL(clicked()), SLOT(add()) );
connect( ui.editButton, SIGNAL(clicked()), SLOT(edit()) );
connect( ui.removeButton, SIGNAL(clicked()), SLOT(remove()) );
connect( ui.moveUpButton, SIGNAL(clicked()), SLOT(up()) );
connect( ui.moveDownButton, SIGNAL(clicked()), SLOT(down()) );
connect( ui.exceptionListView, SIGNAL(activated(QModelIndex)), SLOT(edit()) );
connect( ui.exceptionListView, SIGNAL(clicked(QModelIndex)), SLOT(toggle(QModelIndex)) );
connect( ui.exceptionListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateButtons()) );
updateButtons();
resizeColumns();
}
//__________________________________________________________
void ExceptionListWidget::setExceptions( const ConfigurationList& exceptions )
{
model().set( exceptions );
resizeColumns();
setChanged( false );
}
//__________________________________________________________
ConfigurationList ExceptionListWidget::exceptions( void )
{
return model().get();
setChanged( false );
}
//__________________________________________________________
void ExceptionListWidget::updateButtons( void )
{
bool hasSelection( !ui.exceptionListView->selectionModel()->selectedRows().empty() );
ui.removeButton->setEnabled( hasSelection );
ui.editButton->setEnabled( hasSelection );
ui.moveUpButton->setEnabled( hasSelection && !ui.exceptionListView->selectionModel()->isRowSelected( 0, QModelIndex() ) );
ui.moveDownButton->setEnabled( hasSelection && !ui.exceptionListView->selectionModel()->isRowSelected( model().rowCount()-1, QModelIndex() ) );
}
//_______________________________________________________
void ExceptionListWidget::add( void )
{
QPointer<ExceptionDialog> dialog = new ExceptionDialog( this );
ConfigurationPtr exception( new Configuration() );
exception->readConfig();
dialog->setException( exception );
// run dialog and check existence
if( !dialog->exec() )
{
delete dialog;
return;
}
dialog->save();
delete dialog;
// check exceptions
if( !checkException( exception ) ) return;
// create new item
model().add( exception );
setChanged( true );
// make sure item is selected
QModelIndex index( model().index( exception ) );
if( index != ui.exceptionListView->selectionModel()->currentIndex() )
{
ui.exceptionListView->selectionModel()->select( index, QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
ui.exceptionListView->selectionModel()->setCurrentIndex( index, QItemSelectionModel::Current|QItemSelectionModel::Rows );
}
resizeColumns();
return;
}
//_______________________________________________________
void ExceptionListWidget::edit( void )
{
// retrieve selection
QModelIndex current( ui.exceptionListView->selectionModel()->currentIndex() );
if( ! model().contains( current ) ) return;
ConfigurationPtr exception( model().get( current ) );
// create dialog
QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
dialog->setException( exception );
// map dialog
if( !dialog->exec() )
{
delete dialog;
return;
}
// check modifications
if( !dialog->isChanged() ) return;
// retrieve exception
dialog->save();
delete dialog;
// check new exception validity
checkException( exception );
resizeColumns();
setChanged( true );
return;
}
//_______________________________________________________
void ExceptionListWidget::remove( void )
{
// should use a konfirmation dialog
if( QMessageBox::question( this, i18n("Question - Oxygen Settings" ), i18n("Remove selected exception?") ) == QMessageBox::No ) return;
// remove
model().remove( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
resizeColumns();
updateButtons();
setChanged( true );
return;
}
//_______________________________________________________
void ExceptionListWidget::toggle( const QModelIndex& index )
{
if( !model().contains( index ) ) return;
if( index.column() != ExceptionModel::ENABLED ) return;
// get matching exception
ConfigurationPtr exception( model().get( index ) );
exception->setEnabled( !exception->enabled() );
setChanged( true );
return;
}
//_______________________________________________________
void ExceptionListWidget::up( void )
{
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
if( selection.empty() ) { return; }
// retrieve selected indexes in list and store in model
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedRows() );
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
ConfigurationList currentException( model().get() );
ConfigurationList newExceptions;
for( ConfigurationList::const_iterator iter = currentException.constBegin(); iter != currentException.constEnd(); ++iter )
{
// check if new list is not empty, current index is selected and last index is not.
// if yes, move.
if(
!( newExceptions.empty() ||
selectedIndices.indexOf( model().index( *iter ) ) == -1 ||
selectedIndices.indexOf( model().index( newExceptions.back() ) ) != -1
) )
{
ConfigurationPtr last( newExceptions.back() );
newExceptions.removeLast();
newExceptions.append( *iter );
newExceptions.append( last );
} else newExceptions.append( *iter );
}
model().set( newExceptions );
// restore selection
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
setChanged( true );
return;
}
//_______________________________________________________
void ExceptionListWidget::down( void )
{
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
if( selection.empty() )
{ return; }
// retrieve selected indexes in list and store in model
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedIndexes() );
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
ConfigurationList currentExceptions( model().get() );
ConfigurationList newExceptions;
ConfigurationListIterator iter( currentExceptions );
iter.toBack();
while( iter.hasPrevious() )
{
ConfigurationPtr current( iter.previous() );
// check if new list is not empty, current index is selected and last index is not.
// if yes, move.
if(
!( newExceptions.empty() ||
selectedIndices.indexOf( model().index( current ) ) == -1 ||
selectedIndices.indexOf( model().index( newExceptions.front() ) ) != -1
) )
{
ConfigurationPtr first( newExceptions.front() );
newExceptions.removeFirst();
newExceptions.prepend( current );
newExceptions.prepend( first );
} else newExceptions.prepend( current );
}
model().set( newExceptions );
// restore selection
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
setChanged( true );
return;
}
//_______________________________________________________
void ExceptionListWidget::resizeColumns( void ) const
{
ui.exceptionListView->resizeColumnToContents( ExceptionModel::ENABLED );
ui.exceptionListView->resizeColumnToContents( ExceptionModel::TYPE );
ui.exceptionListView->resizeColumnToContents( ExceptionModel::REGEXP );
}
//_______________________________________________________
bool ExceptionListWidget::checkException( ConfigurationPtr exception )
{
while( exception->exceptionPattern().isEmpty() || !QRegExp( exception->exceptionPattern() ).isValid() )
{
QMessageBox::warning( this, i18n( "Warning - Oxygen Settings" ), i18n("Regular Expression syntax is incorrect") );
QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
dialog->setException( exception );
if( dialog->exec() == QDialog::Rejected )
{
delete dialog;
return false;
}
dialog->save();
delete dialog;
}
return true;
}
}

View File

@ -1,124 +0,0 @@
#ifndef oxygenexceptionlistwidget_h
#define oxygenexceptionlistwidget_h
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionlistwidget.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "ui_oxygenexceptionlistwidget.h"
#include "oxygenexceptionmodel.h"
//! QDialog used to commit selected files
namespace Oxygen
{
class ExceptionListWidget: public QWidget
{
//! Qt meta object
Q_OBJECT
public:
//! constructor
explicit ExceptionListWidget( QWidget* = 0 );
//! set exceptions
void setExceptions( const ConfigurationList& );
//! get exceptions
ConfigurationList exceptions( void );
//! true if changed
virtual bool isChanged( void ) const
{ return _changed; }
Q_SIGNALS:
//! emitted when changed
void changed( bool );
protected:
//! model
const ExceptionModel& model() const
{ return _model; }
//! model
ExceptionModel& model()
{ return _model; }
protected Q_SLOTS:
//! update button states
virtual void updateButtons( void );
//! add
virtual void add( void );
//! edit
virtual void edit( void );
//! remove
virtual void remove( void );
//! toggle
virtual void toggle( const QModelIndex& );
//! move up
virtual void up( void );
//! move down
virtual void down( void );
protected:
//! resize columns
void resizeColumns( void ) const;
//! check exception
bool checkException( ConfigurationPtr );
//! set changed state
virtual void setChanged( bool value )
{
_changed = value;
emit changed( value );
}
private:
//! model
ExceptionModel _model;
//! ui
Ui_OxygenExceptionListWidget ui;
//! changed state
bool _changed;
};
}
#endif

View File

@ -1,105 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionmodel.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenexceptionmodel.h"
#include <KLocalizedString>
namespace Oxygen
{
//_______________________________________________
const QString ExceptionModel::_columnTitles[ ExceptionModel::nColumns ] =
{
QStringLiteral( "" ),
i18n("Exception Type"),
i18n("Regular Expression")
};
//__________________________________________________________________
QVariant ExceptionModel::data( const QModelIndex& index, int role ) const
{
// check index, role and column
if( !index.isValid() ) return QVariant();
// retrieve associated file info
const ConfigurationPtr& configuration( get(index) );
// return text associated to file and column
if( role == Qt::DisplayRole )
{
switch( index.column() )
{
case TYPE:
{
switch( configuration->exceptionType() )
{
case Configuration::ExceptionWindowTitle:
return i18n( "Window Title" );
default:
case Configuration::ExceptionWindowClassName:
return i18n( "Window Class Name" );
}
}
case REGEXP: return configuration->exceptionPattern();
default: return QVariant();
break;
}
} else if( role == Qt::CheckStateRole && index.column() == ENABLED ) {
return configuration->enabled() ? Qt::Checked : Qt::Unchecked;
} else if( role == Qt::ToolTipRole && index.column() == ENABLED ) {
return i18n("Enable/disable this exception");
}
return QVariant();
}
//__________________________________________________________________
QVariant ExceptionModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(
orientation == Qt::Horizontal &&
role == Qt::DisplayRole &&
section >= 0 &&
section < nColumns )
{ return _columnTitles[section]; }
// return empty
return QVariant();
}
}

View File

@ -1,81 +0,0 @@
#ifndef oxygenexceptionmodel_h
#define oxygenexceptionmodel_h
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionmodel.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenlistmodel.h"
#include "oxygenconfiguration.h"
#include "../oxygendecorationdefines.h"
namespace Oxygen
{
//! qlistview for object counters
class ExceptionModel: public ListModel<ConfigurationPtr>
{
public:
//! number of columns
enum { nColumns = 3 };
//! column type enumeration
enum ColumnType {
ENABLED,
TYPE,
REGEXP
};
//!@name methods reimplemented from base class
//@{
// return data for a given index
virtual QVariant data(const QModelIndex &index, int role) const;
//! header data
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
//! number of columns for a given index
virtual int columnCount(const QModelIndex& ) const
{ return nColumns; }
//@}
protected:
//! sort
virtual void privateSort( int, Qt::SortOrder )
{}
private:
//! column titles
static const QString _columnTitles[ nColumns ];
};
}
#endif

View File

@ -1,463 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OxygenConfigurationUI</class>
<widget class="QWidget" name="OxygenConfigurationUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<height>388</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<property name="usesScrollButtons">
<bool>false</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Border si&amp;ze:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>frameBorder</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="frameBorder">
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">No Border</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">No Side Borders</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Tiny</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Normal</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Oversized</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tit&amp;le alignment:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>titleAlignment</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="titleAlignment">
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Center</string>
</property>
</item>
<item>
<property name="text">
<string>Center (Full Width)</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>B&amp;utton size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>buttonSize</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="KComboBox" name="buttonSize">
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Small</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Normal</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Very Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Huge</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Fine Tuning</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>4</number>
</property>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="closeFromMenuButton">
<property name="text">
<string>Close windows by double clicking the menu button</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="separatorMode">
<item>
<property name="text">
<string>Never Draw Separator</string>
</property>
</item>
<item>
<property name="text">
<string>Draw Separator When Window is Active</string>
</property>
</item>
<item>
<property name="text">
<string>Always Draw Separator</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Separator disp&amp;lay:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>separatorMode</cstring>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="titleOutline">
<property name="text">
<string>Outline active window title</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="narrowButtonSpacing">
<property name="text">
<string>Use narrow space between decoration buttons</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="drawSizeGrip">
<property name="text">
<string>Add handle to resize windows with no border</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QCheckBox" name="drawBorderOnMaximizedWindows">
<property name="text">
<string>Display window borders for maximized windows</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Shadows</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="Oxygen::ShadowConfigWidget" name="inactiveShadowConfiguration">
<property name="title">
<string>Window Drop-Down Shadow</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Oxygen::ShadowConfigWidget" name="activeShadowConfiguration">
<property name="title">
<string>Active Window Glow</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="shadowSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Window-Specific Overrides</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Oxygen::ExceptionListWidget" name="exceptions" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="_expertModeContainer" native="true">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<widget class="QPushButton" name="_expertModeButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>Oxygen::ShadowConfigWidget</class>
<extends>QGroupBox</extends>
<header>oxygenshadowconfigwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Oxygen::ExceptionListWidget</class>
<extends>QWidget</extends>
<header>oxygenexceptionlistwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>frameBorder</tabstop>
<tabstop>titleAlignment</tabstop>
<tabstop>buttonSize</tabstop>
<tabstop>animationsEnabled</tabstop>
<tabstop>_expertModeButton</tabstop>
<tabstop>separatorMode</tabstop>
<tabstop>titleOutline</tabstop>
<tabstop>narrowButtonSpacing</tabstop>
<tabstop>inactiveShadowConfiguration</tabstop>
<tabstop>activeShadowConfiguration</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>titleOutline</sender>
<signal>toggled(bool)</signal>
<receiver>separatorMode</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>90</x>
<y>92</y>
</hint>
<hint type="destinationlabel">
<x>182</x>
<y>67</y>
</hint>
</hints>
</connection>
<connection>
<sender>titleOutline</sender>
<signal>toggled(bool)</signal>
<receiver>label_5</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>39</x>
<y>90</y>
</hint>
<hint type="destinationlabel">
<x>53</x>
<y>64</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OxygenDetectWidget</class>
<widget class="QDialog" name="OxygenDetectWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Information about Selected Window</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Class: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="windowClass">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Title: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="windowTitle">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Window Property Selection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="windowClassCheckBox">
<property name="text">
<string>Use window class (whole application)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="windowTitleCheckBox">
<property name="locale">
<locale language="French" country="France"/>
</property>
<property name="text">
<string>Use window title</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OxygenDetectWidget</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OxygenDetectWidget</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,365 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OxygenExceptionDialog</class>
<widget class="QDialog" name="OxygenExceptionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>347</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Window Identification</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Matching window property: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>exceptionType</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Regular expression to match: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>exceptionEditor</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="detectDialogButton">
<property name="text">
<string>Detect Window Properties</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="KLineEdit" name="exceptionEditor">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="KComboBox" name="exceptionType">
<item>
<property name="text">
<string>Window Class Name</string>
</property>
</item>
<item>
<property name="text">
<string>Window Title</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Decoration Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="2">
<widget class="KComboBox" name="titleOutlineComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string comment="outline window title">Disabled</string>
</property>
</item>
<item>
<property name="text">
<string comment="outline window title">Enabled</string>
</property>
</item>
</widget>
</item>
<item row="4" column="2">
<widget class="KComboBox" name="separatorComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Never Draw Separator</string>
</property>
</item>
<item>
<property name="text">
<string>Draw Separator When Window is Active</string>
</property>
</item>
<item>
<property name="text">
<string>Always Draw Separator</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="frameBorderCheckBox">
<property name="text">
<string>Border size:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="sizeGripCheckBox">
<property name="text">
<string>Add handle to resize windows with no border</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="titleOutlineCheckBox">
<property name="text">
<string>Outline active window title:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="separatorCheckBox">
<property name="text">
<string>Separator display:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="hideTitleBar">
<property name="text">
<string>Hide window title bar</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="frameBorderComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">No Border</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">No Side Borders</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Tiny</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Normal</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Large</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string comment="@item:inlistbox Border size:">Oversized</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2">
<widget class="KComboBox" name="sizeGripComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string comment="Add handle to resize windows with no border">Disabled</string>
</property>
</item>
<item>
<property name="text">
<string comment="Add handle to resize windows with no border">Enabled</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OxygenExceptionDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>252</x>
<y>342</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OxygenExceptionDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>320</x>
<y>342</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>frameBorderCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>frameBorderComboBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>316</x>
<y>163</y>
</hint>
</hints>
</connection>
<connection>
<sender>sizeGripCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>sizeGripComboBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>202</x>
<y>212</y>
</hint>
<hint type="destinationlabel">
<x>319</x>
<y>214</y>
</hint>
</hints>
</connection>
<connection>
<sender>titleOutlineCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>titleOutlineComboBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>198</x>
<y>237</y>
</hint>
<hint type="destinationlabel">
<x>317</x>
<y>241</y>
</hint>
</hints>
</connection>
<connection>
<sender>separatorCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>separatorComboBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>118</x>
<y>264</y>
</hint>
<hint type="destinationlabel">
<x>298</x>
<y>266</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OxygenExceptionListWidget</class>
<widget class="QWidget" name="OxygenExceptionListWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>163</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="6">
<widget class="QTreeView" name="exceptionListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="moveUpButton">
<property name="text">
<string>Move Up</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="moveDownButton">
<property name="text">
<string>Move Down</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>exceptionListView</tabstop>
<tabstop>moveUpButton</tabstop>
<tabstop>moveDownButton</tabstop>
<tabstop>addButton</tabstop>
<tabstop>removeButton</tabstop>
<tabstop>editButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,3 +0,0 @@
########### install files ###############
install( FILES oxygen.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )
install( PROGRAMS update_oxygen.pl DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )

View File

@ -1,5 +0,0 @@
# update decoration options for KDE 4.11
Id=1
File=oxygenrc
Options=overwrite
Script=update_oxygen.pl,perl

View File

@ -1,192 +0,0 @@
#!/usr/bin/perl
{
# keep track of current section
my $section = "";
# separator mode
my $drawSeparator;
my $separatorActiveOnly;
while( <> )
{
# store current line
my $line = $_;
# parse section
if( $line =~ /^\[\s*(.*)\s*\]/ )
{
$section = $1;
print( $line );
next;
}
# parse key and value
if( !( $line=~ /^(.+)\s*=\s*(.+)$/ ) )
{
print( $line );
next;
}
my $key = $1;
my $value = $2;
if( $key eq "BlendColor" ) {
# Blend style
# delete key (renamed to BlendStyle )
print( "# DELETE [$section]$key\n" );
$key="BlendStyle";
my %hash = (
"Solid Color"=>"BlendNone",
"Radial Gradient"=>"BlendRadial",
"Follow Style Hint"=>"BlendFromStyle" );
if( $hash{$value} )
{ print( "$key=$hash{$value}\n" ); }
} elsif( $key eq "ButtonSize" ) {
# Button size
my %hash = (
"Small"=>"ButtonSmall",
"Normal"=>"ButtonDefault",
"Large"=>"ButtonLarge",
"Very Large"=>"ButtonVeryLarge",
"Huge"=>"ButtonHuge" );
if( $hash{$value} ) { print( "$key=$hash{$value}\n" ); }
else { print( "# DELETE [$section]$key\n" ); }
} elsif( $key eq "FrameBorder" ) {
# frame border size
my %hash = (
"No Border"=>"BorderNone",
"No Side Border"=>"BorderNoSide",
"Tiny"=>"BorderTiny",
"Normal"=>"BorderDefault",
"Large"=>"BorderLarge",
"Very Large"=>"BorderVeryLarge",
"Huge"=>"BorderHuge",
"Very Huge"=>"BorderVeryHuge",
"Oversized"=>"BorderOverSized" );
if( $hash{$value} ) { print( "$key=$hash{$value}\n" ); }
else { print( "# DELETE [$section]$key\n" ); }
} elsif( $key eq "SizeGripMode" ) {
# size grip
# delete key (renamed to DrawSizeGrip )
print( "# DELETE [$section]$key\n" );
$key="DrawSizeGrip";
my %hash = (
"Always Hide Extra Size Grip"=>"false",
"Show Extra Size Grip When Needed"=>"true" );
if( $hash{$value} ) { print( "$key=$hash{$value}\n" ); }
} elsif( $key eq "TitleAlignment" ) {
# title alignment
my %hash = (
"Left"=>"AlignLeft",
"Center"=>"AlignCenter",
"Center (Full Width)"=>"AlignCenterFullWidth",
"Right"=>"AlignRight" );
if( $hash{$value} ) { print( "$key=$hash{$value}\n" ); }
else { print( "# DELETE [$section]$key\n" ); }
} elsif( $key eq "DrawSeparator" ) {
# separator
print( "# DELETE [$section]$key\n" );
$drawSeparator = $value;
if( !( $separatorActiveOnly eq "" ) )
{
$key = "SeparatorMode";
$value = "";
if( $drawSeparator eq "false" ) { $value = "SeparatorNever"; }
elsif( $drawSeparator eq "true" ) {
if( $separatorActiveOnly eq "true" ) { $value = "SeparatorActive"; }
elsif( $separatorActiveOnly eq "false" ) { $value = "SeparatorAlways"; }
}
if( !( $value eq "" ) ) { print( "$key=$value\n" ); }
$separatorActiveOnly="";
$drawSeparator="";
}
} elsif( $key eq "SeparatorActiveOnly" ) {
# separator
print( "# DELETE [$section]$key\n" );
$separatorActiveOnly = $value;
if( !( $drawSeparator eq "" ) )
{
$key = "SeparatorMode";
$value = "";
if( $drawSeparator eq "false" ) { $value = "SeparatorNever"; }
elsif( $drawSeparator eq "true" ) {
if( $separatorActiveOnly eq "true" ) { $value = "SeparatorActive"; }
elsif( $separatorActiveOnly eq "false" ) { $value = "SeparatorAlways"; }
}
if( !( $value eq "" ) ) { print( "$key=$value\n" ); }
$separatorActiveOnly="";
$drawSeparator="";
}
} elsif( $key eq "Pattern" ) {
# exception pattern
print( "# DELETE [$section]$key\n" );
$key="ExceptionPattern";
print( "$key=$value\n" );
} elsif( $key eq "Type" ) {
# exception type
print( "# DELETE [$section]$key\n" );
$key = "ExceptionType";
my %hash = (
"Window Class Name"=>"ExceptionWindowClassName",
"Window Title"=>"ExceptionWindowTitle" );
if( $hash{$value} ) { print( "$key=$hash{$value}\n" ); }
} elsif(
( $key eq "CenterTitleOnFullWidth" ) ||
( $key eq "UseDropShadows" ) ||
( $key eq "UseOxygenShadows" ) ) {
# obsolete flags
print( "# DELETE [$section]$key\n" );
} else {
print( $line );
}
}
}

View File

@ -1,20 +0,0 @@
set(oxygen_shadow_demo_SOURCES
oxygenshadowdemodialog.cpp
oxygenshadowdemowidget.cpp
main.cpp)
set(oxygen_shadow_demo_FORMS ui/oxygenshadowdemo.ui)
qt5_wrap_ui(oxygen_shadow_demo_FORMS_HEADERS ${oxygen_shadow_demo_FORMS})
add_executable(oxygen-shadow-demo ${oxygen_shadow_demo_SOURCES} ${oxygen_shadow_demo_FORMS_HEADERS})
target_link_libraries(oxygen-shadow-demo Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus)
target_link_libraries(oxygen-shadow-demo KF5::I18n)
target_link_libraries(oxygen-shadow-demo oxygenstyle )
if(X11_FOUND)
target_link_libraries(oxygen-shadow-demo ${X11_LIBRARIES})
endif()
install(TARGETS oxygen-shadow-demo ${INSTALL_TARGETS_DEFAULT_ARGS})

View File

@ -1,45 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// main.cpp
// oxygen-demo main
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenshadowdemodialog.h"
#include <QApplication>
#include <QIcon>
#include <KLocalizedString>
int main(int argc, char *argv[])
{
QApplication app( argc, argv );
app.setApplicationName( i18n( "Oxygen Shadow Demo" ) );
app.setWindowIcon( QIcon::fromTheme( QStringLiteral( "oxygen" ) ) );
Oxygen::ShadowDemoDialog dialog;
dialog.show();
bool result = app.exec();
return result;
}

View File

@ -1,116 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowdemodialog.h
// oxygen shadow demo dialog
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenshadowdemodialog.h"
#include "oxygenshadowdemodialog.moc"
#include <QDialogButtonBox>
#include <QDBusConnection>
#include <KLocalizedString>
namespace Oxygen
{
//_________________________________________________________
ShadowDemoDialog::ShadowDemoDialog( QWidget* parent ):
QDialog( parent ),
_helper( KSharedConfig::openConfig("oxygenrc") ),
_cache( _helper )
{
setWindowTitle( i18n( "Oxygen Shadow Demo" ) );
setupUi( this );
inactiveRoundWidget->setHelper( _helper );
inactiveSquareWidget->setHelper( _helper );
activeRoundWidget->setHelper( _helper );
activeSquareWidget->setHelper( _helper );
// reparse configuration
reparseConfiguration();
// customize button box
QList<QDialogButtonBox*> children( findChildren<QDialogButtonBox*>() );
if( !children.isEmpty() )
{
QDialogButtonBox* buttonBox( children.front() );
_backgroundCheckBox = new QCheckBox( i18n( "Draw window background" ) );
_backgroundCheckBox->setChecked( true );
buttonBox->addButton( _backgroundCheckBox, QDialogButtonBox::ResetRole );
connect( _backgroundCheckBox, SIGNAL(toggled(bool)), inactiveRoundWidget, SLOT(toggleBackground(bool)) );
connect( _backgroundCheckBox, SIGNAL(toggled(bool)), inactiveSquareWidget, SLOT(toggleBackground(bool)) );
connect( _backgroundCheckBox, SIGNAL(toggled(bool)), activeRoundWidget, SLOT(toggleBackground(bool)) );
connect( _backgroundCheckBox, SIGNAL(toggled(bool)), activeSquareWidget, SLOT(toggleBackground(bool)) );
}
// use DBus connection to update on oxygen configuration change
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.connect( QString(),
QStringLiteral( "/OxygenWindeco" ),
QStringLiteral( "org.kde.Oxygen.Style" ),
QStringLiteral( "reparseConfiguration" ), this, SLOT(reparseConfiguration()) );
}
//_________________________________________________________
void ShadowDemoDialog::reparseConfiguration( void )
{
// read shadow configurations
_cache.invalidateCaches();
_cache.setEnabled( true );
// pass tileSets to UI
ShadowCache::Key key;
key.active = false;
key.hasBorder = true;
inactiveRoundWidget->setTileSet( *_cache.tileSet( key ) );
inactiveRoundWidget->setShadowSize( _cache.shadowSize() );
key.active = false;
key.hasBorder = false;
inactiveSquareWidget->setTileSet( *_cache.tileSet( key ) );
inactiveSquareWidget->setShadowSize( _cache.shadowSize() );
inactiveSquareWidget->setSquare( true );
key.active = true;
key.hasBorder = true;
activeRoundWidget->setTileSet( *_cache.tileSet( key ) );
activeRoundWidget->setShadowSize( _cache.shadowSize() );
key.active = true;
key.hasBorder = false;
activeSquareWidget->setTileSet( *_cache.tileSet( key ) );
activeSquareWidget->setShadowSize( _cache.shadowSize() );
activeSquareWidget->setSquare( true );
}
}

View File

@ -1,73 +0,0 @@
#ifndef oxygenshadowdemodialog_h
#define oxygenshadowdemodialog_h
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowdemodialog.h
// oxygen shadow demo dialog
// -------------------
//
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "ui_oxygenshadowdemo.h"
#include "oxygenhelper.h"
#include "oxygenshadowcache.h"
#include <QCheckBox>
#include <QDialog>
namespace Oxygen
{
class ShadowDemoDialog: public QDialog, Ui::OxygenShadowDemoDialog
{
Q_OBJECT
public:
//! constructor
explicit ShadowDemoDialog( QWidget* = 0 );
//! destructor
virtual ~ShadowDemoDialog( void )
{}
protected Q_SLOTS:
//! reparse configuration
void reparseConfiguration( void );
private:
//! helper
Helper _helper;
//! shadow cache
ShadowCache _cache;
//! enable state checkbox
QCheckBox* _backgroundCheckBox;
};
}
#endif

View File

@ -1,105 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowdemowidget.h
// shadow demo widget
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenshadowdemowidget.h"
#include "oxygenshadowdemowidget.moc"
#include <QPainter>
namespace Oxygen
{
//______________________________________
void ShadowDemoWidget::paintEvent( QPaintEvent* event )
{
if( !_tileSet.isValid() ) return;
QPainter painter( this );
painter.setClipRegion( event->region() );
_tileSet.render( rect(), &painter );
// draw background
if( _drawBackground )
{
updateBackgroundPixmap();
painter.translate( _shadowSize, _shadowSize );
painter.drawPixmap( QPoint(0,0), _backgroundPixmap );
}
}
//______________________________________
void ShadowDemoWidget::updateBackgroundPixmap( void )
{
// check if background pixmap needs update
QRect backgroundRect( QPoint( 0, 0 ), size() - QSize( 2*_shadowSize, 2*_shadowSize ) );
if( !_backgroundPixmap.isNull() && _backgroundPixmap.size() == backgroundRect.size() )
{ return; }
_backgroundPixmap = QPixmap( backgroundRect.size() );
_backgroundPixmap.fill( Qt::transparent );
QPainter painter( &_backgroundPixmap );
painter.setRenderHint( QPainter::Antialiasing );
_dummy.resize( backgroundRect.size() );
helper().renderWindowBackground(
&painter, backgroundRect,
&_dummy, &_dummy, palette().color( QPalette::Window ), 0, 64 );
// float frame
helper().drawFloatFrame( &painter, backgroundRect.adjusted( -1, -1, 1, 1 ), palette().color( QPalette::Window ), false );
// add rounded mask
painter.save();
painter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
painter.setBrush( Qt::black );
painter.setPen( Qt::NoPen );
if( _square )
{
QRectF rectF( backgroundRect );
QPainterPath path;
// rotate counterclockwise, cause that makes angles easier
path.moveTo( rectF.topLeft() + QPointF( 3.5, 0 ) );
path.arcTo( QRectF( rectF.topLeft(), QSize( 7, 7 ) ), 90, 90 );
path.lineTo( rectF.bottomLeft() );
path.lineTo( rectF.bottomRight() );
path.lineTo( rectF.topRight() + QPointF( 0, 3.5 ) );
path.arcTo( QRectF( rectF.topRight() + QPointF( -7, 0 ), QSize( 7, 7 ) ), 0, 90 );
path.lineTo( rectF.topLeft() + QPointF( 3.5, 0 ) );
painter.drawPath( path );
} else {
painter.drawRoundedRect( QRectF( backgroundRect ), 3.5, 3.5 );
}
painter.restore();
}
}

View File

@ -1,140 +0,0 @@
#ifndef oxygenshadowdemowidget_h
#define oxygenshadowdemowidget_h
//////////////////////////////////////////////////////////////////////////////
// oxygenshadowdemowidget.h
// shadow demo widget
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygentileset.h"
#include "oxygenhelper.h"
#include <QWidget>
#include <QPaintEvent>
#include <QPixmap>
#include <cassert>
namespace Oxygen
{
//! shadow demo widget
class ShadowDemoWidget: public QWidget
{
Q_OBJECT
public:
//! constructor
explicit ShadowDemoWidget( QWidget* parent = nullptr ):
QWidget( parent ),
_drawBackground( true ),
_square( false ),
_helper( 0L )
{}
//! destructor
virtual ~ShadowDemoWidget( void )
{}
//! helper
void setHelper( Helper& helper )
{ _helper = &helper; }
//! set tileSet
void setTileSet( const TileSet& tileSet )
{
_tileSet = tileSet;
if( isVisible() ) update();
}
//! tileset
const TileSet& tileSet( void ) const
{ return _tileSet; }
//! set shadow size
void setShadowSize( int size )
{
_shadowSize = size;
setMinimumSize( _shadowSize*2 + 100, _shadowSize*2 + 60 );
}
//! square
void setSquare( bool value )
{
_square = value;
if( isVisible() ) update();
}
protected Q_SLOTS:
//! toggle background drawing
void toggleBackground( bool value )
{
if( value == _drawBackground ) return;
_drawBackground = value;
update();
}
protected:
//! paint event
virtual void paintEvent( QPaintEvent* );
//! render window to pixmap
void updateBackgroundPixmap( void );
Helper& helper( void ) const
{
assert( _helper );
return *_helper;
}
private:
//! shadow size
int _shadowSize;
//! draw window background
bool _drawBackground;
//! true if (bottom) corners are square
bool _square;
//! helper
Helper* _helper;
//! dummy widget
QWidget _dummy;
//! window pixmap
QPixmap _backgroundPixmap;
//! tileSet
TileSet _tileSet;
};
}
#endif

View File

@ -1,104 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OxygenShadowDemoDialog</class>
<widget class="QDialog" name="OxygenShadowDemoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>535</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1,1,0">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Inactive Windows</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Active Windows</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Oxygen::ShadowDemoWidget" name="inactiveRoundWidget" native="true"/>
</item>
<item row="2" column="0">
<widget class="Oxygen::ShadowDemoWidget" name="inactiveSquareWidget" native="true"/>
</item>
<item row="1" column="1">
<widget class="Oxygen::ShadowDemoWidget" name="activeRoundWidget" native="true"/>
</item>
<item row="2" column="1">
<widget class="Oxygen::ShadowDemoWidget" name="activeSquareWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Oxygen::ShadowDemoWidget</class>
<extends>QWidget</extends>
<header>oxygenshadowdemowidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OxygenShadowDemoDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OxygenShadowDemoDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,440 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// Button.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
// 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 "oxygenbutton.moc"
#include "oxygenclient.h"
#include <cmath>
#include <QPainter>
#include <QPen>
#include <KColorUtils>
#include <KColorScheme>
#include <kcommondecoration.h>
namespace Oxygen
{
//_______________________________________________
Button::Button(
Client &parent,
const QString& tip,
ButtonType type):
KCommonDecorationButton((::ButtonType)type, &parent),
_client(parent),
_helper( parent.helper() ),
_type(type),
_status( 0 ),
_forceInactive( false ),
_glowAnimation( new Animation( 150, this ) ),
_glowIntensity(0)
{
setAutoFillBackground(false);
setAttribute(Qt::WA_NoSystemBackground);
int size( _client.buttonSize() );
setFixedSize( size, size );
setCursor(Qt::ArrowCursor);
setToolTip(tip);
// setup animation
_glowAnimation->setStartValue( 0 );
_glowAnimation->setEndValue( 1.0 );
_glowAnimation->setTargetObject( this );
_glowAnimation->setPropertyName( "glowIntensity" );
_glowAnimation->setEasingCurve( QEasingCurve::InOutQuad );
// setup connections
reset(0);
}
//_______________________________________________
Button::~Button()
{}
//_______________________________________________
QColor Button::buttonDetailColor(const QPalette &palette) const
{
if( _client.glowIsAnimated() && !_forceInactive && !_client.isForcedActive()) return KColorUtils::mix(
buttonDetailColor( palette, false ),
buttonDetailColor( palette, true ),
_client.glowIntensity() );
else return buttonDetailColor( palette, isActive() || _client.isForcedActive() );
}
//___________________________________________________
bool Button::isActive( void ) const
{ return (!_forceInactive) && _client.isActive(); }
//___________________________________________________
bool Button::buttonAnimationsEnabled( void ) const
{ return _client.animationsEnabled() && _client.configuration()->buttonAnimationsEnabled(); }
//___________________________________________________
QSize Button::sizeHint() const
{
unsigned int size( _client.buttonSize() );
return QSize( size, size );
}
//___________________________________________________
void Button::reset( unsigned long )
{ _glowAnimation->setDuration( _client.configuration()->buttonAnimationsDuration() ); }
//___________________________________________________
void Button::paint( QPainter& painter )
{
QPalette palette( _client.palette() );
palette.setCurrentColorGroup( isActive() ? QPalette::Active : QPalette::Inactive);
if(
_client.compositingActive() &&
!( _client.isMaximized() || _type == ButtonItemClose || _type == ButtonItemMenu ) )
{ painter.translate( 0, -1 ); }
// translate buttons down if window maximized
if( _client.isMaximized() ) painter.translate( 0, 1 );
// base button color
QColor base;
if( _type == ButtonItemClose && _forceInactive ) base = _client.backgroundPalette( this, palette ).window().color();
else if( _type == ButtonItemClose ) base = palette.window().color();
else base = palette.button().color();
// text color
QColor color = (_type == ButtonItemClose && _forceInactive ) ?
buttonDetailColor( _client.backgroundPalette( this, palette ) ):
buttonDetailColor( palette );
// decide decoration color
QColor glow;
if( isAnimated() || (_status&Hovered) )
{
glow = isCloseButton() ?
_helper.viewNegativeTextBrush().brush(palette).color():
_helper.viewHoverBrush().brush(palette).color();
if( isAnimated() )
{
color = KColorUtils::mix( color, glow, glowIntensity() );
glow = _helper.alphaColor( glow, glowIntensity() );
} else if( _status&Hovered ) color = glow;
}
if( hasDecoration() )
{
// scale
qreal scale( (21.0*_client.buttonSize())/22.0 );
// pressed state
const bool pressed(
(_status&Pressed) ||
( _type == ButtonSticky && _client.isOnAllDesktops() ) ||
( _type == ButtonAbove && _client.keepAbove() ) ||
( _type == ButtonBelow && _client.keepBelow() ) );
// draw button shape
painter.drawPixmap(0, 0, _helper.windecoButton( base, glow, pressed, scale ) );
}
// Icon
// for menu button the application icon is used
if( isMenuButton() )
{
int iconScale( 0 );
switch( _client.buttonSize() )
{
case Configuration::ButtonSmall: iconScale = 13; break;
default:
case Configuration::ButtonDefault: iconScale = 16; break;
case Configuration::ButtonLarge: iconScale = 20; break;
case Configuration::ButtonVeryLarge: iconScale = 24; break;
case Configuration::ButtonHuge: iconScale = 35; break;
}
const QPixmap& pixmap( _client.icon().pixmap( iconScale ) );
const double offset = 0.5*(width()-pixmap.width() );
painter.drawPixmap(offset, offset-1, pixmap );
} else {
painter.setRenderHints(QPainter::Antialiasing);
qreal width( 1.2 );
// contrast
painter.setBrush(Qt::NoBrush);
painter.setPen(QPen( _helper.calcLightColor( base ), width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
drawIcon(&painter);
// main
painter.translate(0,-1.5);
painter.setBrush(Qt::NoBrush);
painter.setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
drawIcon(&painter);
}
}
//___________________________________________________
void Button::mousePressEvent( QMouseEvent *event )
{
if( _type == ButtonMax || event->button() == Qt::LeftButton )
{
_status |= Pressed;
parentUpdate();
}
KCommonDecorationButton::mousePressEvent( event );
}
//___________________________________________________
void Button::mouseReleaseEvent( QMouseEvent* event )
{
if (_type != ButtonApplicationMenu)
{
_status &= ~Pressed;
parentUpdate();
}
KCommonDecorationButton::mouseReleaseEvent( event );
}
//___________________________________________________
void Button::enterEvent( QEvent *event )
{
KCommonDecorationButton::enterEvent( event );
_status |= Hovered;
if( buttonAnimationsEnabled() )
{
_glowAnimation->setDirection( Animation::Forward );
if( !isAnimated() ) _glowAnimation->start();
} else parentUpdate();
}
//___________________________________________________
void Button::leaveEvent( QEvent *event )
{
KCommonDecorationButton::leaveEvent( event );
if( _status&Hovered && buttonAnimationsEnabled() )
{
_glowAnimation->setDirection( Animation::Backward );
if( !isAnimated() ) _glowAnimation->start();
}
_status &= ~Hovered;
parentUpdate();
}
//___________________________________________________
void Button::resizeEvent( QResizeEvent *event )
{
// resize backing store pixmap
if( !_client.compositingActive() )
{ _pixmap = QPixmap( event->size() ); }
// base class implementation
KCommonDecorationButton::resizeEvent( event );
}
//___________________________________________________
void Button::paintEvent(QPaintEvent *event)
{
if( _client.hideTitleBar() ) return;
/*
do nothing in compositing mode.
painting is performed by the parent widget
*/
if( !_client.compositingActive() )
{
{
// create painter
QPainter painter( &_pixmap );
painter.setRenderHints(QPainter::Antialiasing);
painter.setClipRect( this->rect().intersected( event->rect() ) );
// render parent background
painter.translate( -geometry().topLeft() );
_client.paintBackground( painter );
// render buttons
painter.translate( geometry().topLeft() );
paint( painter );
}
QPainter painter(this);
painter.setClipRegion( event->region() );
painter.drawPixmap( QPoint(), _pixmap );
}
}
//___________________________________________________
void Button::parentUpdate( void )
{
if( _client.compositingActive() || _client.isPreview() ) _client.update( geometry().adjusted( -1, -1, 1, 1 ) );
else if( parentWidget() ) parentWidget()->update( geometry().adjusted( -1, -1, 1, 1 ) );
else this->update();
}
//___________________________________________________
void Button::drawIcon( QPainter* painter )
{
painter->save();
painter->setWindow( 0, 0, 22, 22 );
switch(_type)
{
case ButtonSticky:
painter->drawPoint(QPointF(10.5,10.5));
break;
case ButtonHelp:
painter->translate(1.5, 1.5);
painter->drawArc(7,5,4,4,135*16, -180*16);
painter->drawArc(9,8,4,4,135*16,45*16);
painter->drawPoint(9,12);
painter->translate(-1.5, -1.5);
break;
case ButtonApplicationMenu:
painter->drawLine(QPointF(7.5, 7.5), QPointF(13.5, 7.5));
painter->drawLine(QPointF(7.5, 10.5), QPointF(13.5, 10.5));
painter->drawLine(QPointF(7.5, 13.5), QPointF(13.5, 13.5));
break;
case ButtonMin:
painter->drawLine(QPointF( 7.5, 9.5), QPointF(10.5,12.5));
painter->drawLine(QPointF(10.5,12.5), QPointF(13.5, 9.5));
break;
case ButtonMax:
switch(_client.maximizeMode())
{
case Client::MaximizeRestore:
case Client::MaximizeVertical:
case Client::MaximizeHorizontal:
painter->drawLine(QPointF( 7.5,11.5), QPointF(10.5, 8.5));
painter->drawLine(QPointF(10.5, 8.5), QPointF(13.5,11.5));
break;
case Client::MaximizeFull:
{
painter->translate(1.5, 1.5);
QPoint points[4] = {QPoint(9, 6), QPoint(12, 9), QPoint(9, 12), QPoint(6, 9)};
painter->drawPolygon(points, 4);
painter->translate(-1.5, -1.5);
break;
}
}
break;
case ButtonItemClose:
case ButtonClose:
painter->drawLine(QPointF( 7.5,7.5), QPointF(13.5,13.5));
painter->drawLine(QPointF(13.5,7.5), QPointF( 7.5,13.5));
break;
case ButtonAbove:
painter->drawLine(QPointF( 7.5,14), QPointF(10.5,11));
painter->drawLine(QPointF(10.5,11), QPointF(13.5,14));
painter->drawLine(QPointF( 7.5,10), QPointF(10.5, 7));
painter->drawLine(QPointF(10.5, 7), QPointF(13.5,10));
break;
case ButtonBelow:
painter->drawLine(QPointF( 7.5,11), QPointF(10.5,14));
painter->drawLine(QPointF(10.5,14), QPointF(13.5,11));
painter->drawLine(QPointF( 7.5, 7), QPointF(10.5,10));
painter->drawLine(QPointF(10.5,10), QPointF(13.5, 7));
break;
case ButtonShade:
if (!isChecked())
{
// shade button
painter->drawLine(QPointF( 7.5, 7.5), QPointF(10.5,10.5));
painter->drawLine(QPointF(10.5,10.5), QPointF(13.5, 7.5));
painter->drawLine(QPointF( 7.5,13.0), QPointF(13.5,13.0));
} else {
// unshade button
painter->drawLine(QPointF( 7.5,10.5), QPointF(10.5, 7.5));
painter->drawLine(QPointF(10.5, 7.5), QPointF(13.5,10.5));
painter->drawLine(QPointF( 7.5,13.0), QPointF(13.5,13.0));
}
break;
default:
break;
}
painter->restore();
return;
}
void Button::slotAppMenuHidden()
{
_status = Normal;
update();
}
}

View File

@ -1,206 +0,0 @@
#ifndef oxygenbutton_h
#define oxygenbutton_h
//////////////////////////////////////////////////////////////////////////////
// Button.h
// -------------------
//
// Copyright (c) 2006, 2007 Riccardo Iaconelli <riccardo@kde.org>
// Copyright (c) 2006, 2007 Casper Boemann <cbr@boemann.dk>
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenanimation.h"
#include "oxygendecorationdefines.h"
#include "oxygendecohelper.h"
#include <kcommondecoration.h>
namespace Oxygen
{
class Client;
Q_DECLARE_FLAGS(ButtonState, ButtonStatus)
class Button : public KCommonDecorationButton
{
Q_OBJECT
//! declare animation progress property
Q_PROPERTY( qreal glowIntensity READ glowIntensity WRITE setGlowIntensity )
public:
//! constructor
explicit Button(Client&, const QString& = QString(), ButtonType = ButtonHelp );
//! destructor
~Button();
//! destructor
QSize sizeHint() const;
//! button type
ButtonType type( void ) const
{ return _type; }
//! set force inactive
/*! returns true if value was actually changed */
void setForceInactive( const bool& value )
{ _forceInactive = value; }
//! configuration reset
virtual void reset( unsigned long );
//!@name glow animation
//@{
void setGlowIntensity( qreal value )
{
if( _glowIntensity == value ) return;
_glowIntensity = value;
parentUpdate();
}
qreal glowIntensity( void ) const
{ return _glowIntensity; }
//@}
//! render buttn to provided painter
void paint(QPainter& );
protected:
//! press event
void mousePressEvent( QMouseEvent* );
//! release event
void mouseReleaseEvent( QMouseEvent* );
//! enter event
void enterEvent( QEvent* );
//! leave event
void leaveEvent( QEvent* );
//! resize event
void resizeEvent( QResizeEvent* );
//! paint
void paintEvent( QPaintEvent* );
// parent update
void parentUpdate( void );
//! draw icon
void drawIcon( QPainter* );
//! color
QColor buttonDetailColor( const QPalette& ) const;
//! color
QColor buttonDetailColor( const QPalette& palette, bool active ) const
{
if( _type == ButtonItemClose )
{
return active ?
palette.color(QPalette::Active, QPalette::WindowText ):
_helper.inactiveTitleBarTextColor( palette );
} else {
return active ?
palette.color(QPalette::Active, QPalette::ButtonText ):
_helper.inactiveButtonTextColor( palette );
}
}
//! true if animation is in progress
bool isAnimated( void ) const
{ return _glowAnimation->isRunning(); }
//! true if button is active
bool isActive( void ) const;
//! true if buttons hover are animated
bool buttonAnimationsEnabled( void ) const;
//!@name button properties
//@{
//! true if button if of menu type
bool isMenuButton( void ) const
{ return _type == ButtonMenu || _type == ButtonItemMenu; }
//! true if button is of toggle type
bool isToggleButton( void ) const
{ return _type == ButtonSticky || _type == ButtonAbove || _type == ButtonBelow; }
//! true if button if of close type
bool isCloseButton( void ) const
{ return _type == ButtonClose || _type == ButtonItemClose; }
//! true if button has decoration
bool hasDecoration( void ) const
{ return !isMenuButton() && _type != ButtonItemClose; }
//@}
private Q_SLOTS:
void slotAppMenuHidden();
private:
//! parent client
Client &_client;
//! helper
DecoHelper &_helper;
//! backing store pixmap (when compositing is not active)
QPixmap _pixmap;
//! button type
ButtonType _type;
//! button status
unsigned int _status;
//! true if button should be forced inactive
bool _forceInactive;
//! glow animation
//Animation::Pointer _glowAnimation;
Animation* _glowAnimation;
//! glow intensity
qreal _glowIntensity;
};
} //namespace Oxygen
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,178 +0,0 @@
# KDE Desktop Entry
[Desktop Entry]
Name=Oxygen
Name[af]=Oxygen
Name[ar]=أكسجين
Name[as]=Oxygen
Name[ast]=Oxíxenu
Name[be]=Oxygen
Name[be@latin]=Oxygen
Name[bg]=Oxygen
Name[bn]=অক্সিজেন
Name[bn_IN]=Oxygen
Name[bs]=Kiseonik
Name[ca]=Oxygen
Name[ca@valencia]=Oxygen
Name[cs]=Oxygen
Name[csb]=Krziseń
Name[da]=Oxygen
Name[de]=Oxygen
Name[el]=Oxygen
Name[en_GB]=Oxygen
Name[eo]=Oxygen
Name[es]=Oxígeno
Name[et]=Oxygen
Name[eu]=Oxygen
Name[fa]=اکسیژن
Name[fi]=Oxygen
Name[fr]=Oxygen
Name[fy]=Oxygen
Name[ga]=Oxygen
Name[gl]=Oxygen
Name[gu]=ઓક્સિજન
Name[he]=Oxygen
Name[hi]=आक्सीजन
Name[hne]=आक्सीजन
Name[hr]=Oxygen
Name[hsb]=Oxygen
Name[hu]=Oxygen
Name[ia]=Oxygen
Name[id]=Oksigen
Name[is]=Oxygen
Name[it]=Oxygen
Name[ja]=Oxygen
Name[kk]=Oxygen
Name[km]=អុកស៊ីហ្សែន
Name[kn]=ಆಕ್ಸಿಜನ್
Name[ko]=Oxygen
Name[ku]=Oxygen
Name[lt]=Oxygen
Name[lv]=Oxygen
Name[mai]=आक्सीजन
Name[mk]=Оксиген
Name[ml]=ഓക്സിജന്‍
Name[mr]=ऑक्सीजन
Name[nb]=Oxygen
Name[nds]=Oxygen
Name[ne]=अक्सिजन
Name[nl]=Oxygen
Name[nn]=Oksygen
Name[or]=ଅକ୍ସିଜେନ
Name[pa]=ਆਕਸੀਜਨ
Name[pl]=Oxygen
Name[pt]=Oxygen
Name[pt_BR]=Oxygen
Name[ro]=Oxygen
Name[ru]=Oxygen
Name[se]=Oksygena
Name[si]=ඔක්සිජන්
Name[sk]=Oxygen
Name[sl]=Kisik
Name[sr]=Кисеоник
Name[sr@ijekavian]=Кисеоник
Name[sr@ijekavianlatin]=Kiseonik
Name[sr@latin]=Kiseonik
Name[sv]=Oxygen
Name[ta]=ஆக்ஸிஜன்
Name[te]=Oxygen
Name[tg]=Oxygen
Name[th]=รูปแบบ Oxygen
Name[tr]=Oxygen
Name[ug]=ئوكسېگىن
Name[uk]=Oxygen
Name[uz]=Oxygen
Name[uz@cyrillic]=Oxygen
Name[vi]=Oxygen
Name[wa]=Ocsidjinne
Name[x-test]=xxOxygenxx
Name[zh_CN]=Oxygen
Name[zh_TW]=Oxygen
Comment=Styling of the next generation desktop
Comment[af]=Stilering van die volgende generasie werkskerm
Comment[ar]=نمط الجيل التالي من سطح المكتب
Comment[ast]=Estilu de la siguiente xeneración d'escritorios
Comment[be]=Стыль працоўных сталоў наступнага пакалення
Comment[be@latin]=Styl nastupnaha pakaleńnia rabočaha stała
Comment[bg]=Стил за следващото поколение работни плотове
Comment[bs]=Stil za narednu generaciju površi
Comment[ca]=Estil de la propera generació d'escriptori
Comment[ca@valencia]=Estil de la propera generació d'escriptori
Comment[cs]=Styl plochy nové generace
Comment[csb]=Sztél nôslédny generacëji wëzdrzatkù pùltù
Comment[da]=Stilisering af næste generation af skrivebordet
Comment[de]=Das KDE-Design der nächsten Generation
Comment[el]=Μορφή της νέας γενιάς επιφάνειας εργασίας
Comment[en_GB]=Styling of the next generation desktop
Comment[eo]=Stilo por la labortablo de sekva generacio
Comment[es]=Estilo de la siguiente generación de escritorios
Comment[et]=Uue põlvkonna töölaua stiil
Comment[eu]=Hurrengo belaunaldiko mahaigainen estiloa
Comment[fi]=Seuraavan sukupolven työpöydän tyyli
Comment[fr]=Style pour la prochaine génération de bureau
Comment[fy]=De styl fan it buroblêd fan de folgjende generaasje
Comment[ga]=Stíliú na deisce don mhílaois nua
Comment[gl]=O estilo da seguinte xeración do escritorio
Comment[gu]=નવી પેઢીનાં ડેસ્કટોપની શૈલી
Comment[he]=הסגנון של הדור הבא של שולחן העבודה
Comment[hi]=अगली पीढ़ी के डेस्कटॉप की शैलियाँ
Comment[hne]=अगला जनरेसन डेस्कटाप के स्टाइलिंग
Comment[hr]=Stil sljedeće generacije radnih okruženja
Comment[hsb]=Stil za dźěłowy powjerch přichodneje generacije
Comment[hu]=Új generációs stílus
Comment[ia]=Le stilo de scriptorio de proxime generation
Comment[id]=Gaya dekstop generasi selanjutnya
Comment[is]=Stílar fyrir næstu-kynslóðar skjáborð
Comment[it]=Stile per il desktop di prossima generazione
Comment[ja]=次世代デスクトップのスタイル
Comment[kk]=Келесі буын үстел стилі
Comment[km]=ការ​កំណត់​រចនាប័ទ្ម​របស់​ផ្ទៃ​តុ​ជំនាន់​ក្រោយ​
Comment[kn]=ಮುಂದಿನ ಪೀಳಿಗೆಯ ಗಣಕತೆರೆ ವೈಖರಿ
Comment[ko]=다음 세대 데스크톱을 위한 스타일
Comment[ku]=Curekirina nifşê pêş ê sermaseyê
Comment[lt]=Kitos kartos darbastalio stiliaus kūrimas
Comment[lv]=Nākamās paaudzes darbvirsmas stils
Comment[mai]=अगिला पीढ़ीक डेस्कटापक शैली
Comment[mk]=Стил за следната генерација десктопи
Comment[ml]=ഭാവിതലമുറയിലെ പണിയിടത്തിനുള്ള രീതികള്‍
Comment[mr]=नेक्स्ट जेनरेशन डेस्कटॉपचे स्टायलिंग
Comment[nb]=Stil for skrivebord av neste generasjon
Comment[nds]=Stil för den kamen Schriefdisch
Comment[ne]=पछिल्लो युगको डेस्कटपको शैली
Comment[nl]=De stijl voor de volgende generatie bureaubladen
Comment[nn]=Ein stil for neste generasjons skrivebord
Comment[or]=ପରବର୍ତ୍ତୀ ପିଢ଼ି ଡ଼େସ୍କଟପର ଶୈଳୀକରଣ କରିବା
Comment[pa]=ਅਗਲੀ ਪੀੜ੍ਹੀ ਡੈਸਕਟਾਪ ਦਾ ਸਟਾਇਲ
Comment[pl]=Styl pulpitu następnej generacji
Comment[pt]=O estilo do ambiente de trabalho da próxima geração
Comment[pt_BR]=Estilo da próxima geração de área de trabalho
Comment[ro]=Stilul biroului de generație următoare
Comment[ru]=Стиль рабочего стола следующего поколения
Comment[se]=Stiila boahttebuolvvalaš čállinbeavdái
Comment[si]=ඊලඟ පරම්පරාවේ වැඩතල රටා
Comment[sk]=Štýl plochy novej generácie
Comment[sl]=Slog namizja naslednje generacije
Comment[sr]=Стил за наредну генерацију површи
Comment[sr@ijekavian]=Стил за наредну генерацију површи
Comment[sr@ijekavianlatin]=Stil za narednu generaciju površi
Comment[sr@latin]=Stil za narednu generaciju površi
Comment[sv]=Stil för nästa generations skrivbord
Comment[ta]=Styling of the next generation desktop
Comment[te]=తరువాతి తరం డెస్‍క్‌టాప్ యొక్క శైలీకరణ
Comment[tg]=Стиль рабочего стола следующего поколения
Comment[th]=รูปแบบสำหรับพื้นที่ทำงานในยุคถัดไป
Comment[tr]=Sonraki kuşak masaüstü biçimi
Comment[ug]=كېيىنكى ئەۋلاد ئۈستەلئۈستى ئۇسلۇبى
Comment[uk]=Стиль стільниці наступного покоління
Comment[wa]=Stîle del novele djermêye di scribannes
Comment[x-test]=xxStyling of the next generation desktopxx
Comment[zh_CN]=下一代桌面的风格
Comment[zh_TW]=下一代桌面的樣式
X-KDE-PluginInfo-Author=Nuno Pinheiro, Casper Boemann, Riccardo Iaconelli, Huynh Huu Long, Thomas Luebking, Hugo Pereira Da Costa, Matthew Woehlke
X-KDE-PluginInfo-Email=nuno@oxygen-icons.org, cbr@boemann.dk, riccardo@kde.org, long.upcase@googlemail.com, thomas.luebking@web.de, hugo.pereira@free.fr, mw_triad@users.sourceforge.net
X-KDE-PluginInfo-Name=Oxygen
X-KDE-PluginInfo-Category=
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View File

@ -1,540 +0,0 @@
#ifndef oxygenclient_h
#define oxygenclient_h
//////////////////////////////////////////////////////////////////////////////
// oxygenclient.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
// 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.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenanimation.h"
#include "oxygenclientgroupitemdata.h"
#include "oxygenconfiguration.h"
#include "oxygendecohelper.h"
#include "oxygenfactory.h"
#include "oxygenshadowcache.h"
#include "oxygentitleanimationdata.h"
#include <kcommondecoration.h>
#include <QBasicTimer>
#include <QTextStream>
#include <QTimerEvent>
#include <xcb/xcb.h>
namespace Oxygen
{
class SizeGrip;
class Client : public KCommonDecoration
{
Q_OBJECT
//! declare glow intensity property
Q_PROPERTY( qreal glowIntensity READ glowIntensityUnbiased WRITE setGlowIntensity )
public:
//! constructor
Client(KDecorationBridge *b, Factory *f);
//! destructor
virtual ~Client();
//! decoration name
virtual QString visibleName() const;
//! buttons
virtual KCommonDecorationButton *createButton(::ButtonType type);
//!@name flags
//@{
//! true if decoration has iquired behavior
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
//! true if window is maximized
virtual bool isMaximized( void ) const
{ return maximizeMode()==MaximizeFull && !configuration()->drawBorderOnMaximizedWindows(); }
//! true if animations are used
bool animationsEnabled( void ) const
{ return _configuration->animationsEnabled(); }
//! true if glow is animated
bool glowIsAnimated( void ) const
{ return _glowAnimation->isRunning(); }
//! true when decoration is forced active
bool isForcedActive( void ) const
{ return _forceActive && tabCount() > 1; }
//! true when separator is to be drawn
bool drawSeparator( void ) const
{
if( _configuration->drawTitleOutline() ) return false;
switch( _configuration->separatorMode() )
{
case Configuration::SeparatorAlways:
return true;
case Configuration::SeparatorActive:
return ( glowIsAnimated() || isActive() );
default:
case Configuration::SeparatorNever:
return false;
}
}
//! true if titlebar is hidden
bool hideTitleBar( void ) const
{
return
_configuration->hideTitleBar() &&
!isShade() &&
tabCount() == 1;
}
//@}
//! window shape
virtual void updateWindowShape();
//! initialization
virtual void init();
//! return associated configuration
Factory::ConfigurationPtr configuration( void ) const
{ return _configuration; }
//!@name glow animation
//@{
void setGlowIntensity( qreal value )
{
if( _glowIntensity == value ) return;
_glowIntensity = value;
widget()->update();
}
//! unbiased glow intensity
qreal glowIntensityUnbiased( void ) const
{ return _glowIntensity; }
//! glow bias
static qreal glowBias( void )
{ return 0.2; }
//! true (biased) intensity
/*! this is needed to have glow go from either 0.2->1 or 0.8->0 depending on the animation direction */
qreal glowIntensity( void ) const
{ return _glowAnimation->direction() == Animation::Forward ? _glowIntensity : _glowIntensity-glowBias(); }
//@}
//! helper class
DecoHelper& helper( void ) const
{ return _factory->helper(); }
//! helper class
ShadowCache& shadowCache( void ) const
{ return _factory->shadowCache(); }
//!@name metrics and color definitions
//@{
//! dimensions
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
//! get title rect for untabbed window
virtual QRect defaultTitleRect( bool active = true ) const;
//! get title bounding rect
virtual QRect titleBoundingRect( const QFont& font, const QString& caption ) const
{ return titleBoundingRect( font, titleRect(), caption ); }
//! get title bounding rect
virtual QRect titleBoundingRect( const QFont&, QRect, const QString& ) const;
//! palette background
QPalette backgroundPalette( const QWidget*, QPalette ) const;
//! background
QColor backgroundColor( const QWidget* widget, QPalette palette ) const
{ return backgroundColor( widget, palette, isActive() || isForcedActive() ); }
//! background
QColor backgroundColor( const QWidget*, QPalette, bool ) const;
//@}
//! title alignment
inline Qt::Alignment titleAlignment( void ) const;
//! button size
inline int buttonSize( void ) const;
//! frame border
inline int frameBorder( void ) const;
//!@name status change methods (overloaded from KCommonDecorationUnstable)
//@{
//! triggered when window activity is changed
virtual void activeChange();
//! triggered when maximize state changed
virtual void maximizeChange();
//! triggered when window shade is changed
virtual void shadeChange();
//! triggered when window shade is changed
virtual void captionChange();
//@}
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
//! resize event
virtual void resizeEvent( QResizeEvent* );
//! paint background to painter
void paintBackground( QPainter& ) const;
public Q_SLOTS:
//! triggers widget update in titleRect only
/*! one needs to add the title top margin to avoid some clipping glitches */
void updateTitleRect( void )
{ widget()->update( titleRect().adjusted( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 1 ) ); }
//! return region for a given defines. This allows to implement extended borders
QRegion region( KDecorationDefines::Region );
protected:
//! return shadow cache key associated to this client
ShadowCache::Key key( void ) const
{
ShadowCache::Key key;
key.active = ( isActive() || isForcedActive() ) && shadowCache().isEnabled( QPalette::Active );
key.isShade = isShade();
key.hasBorder = ( _configuration->frameBorder() > Configuration::BorderNone );
return key;
}
//! true when decoration is forced active
void setForceActive( bool value )
{ _forceActive = value; }
//!@name event filters
//@{
//! paint
virtual void paintEvent( QPaintEvent* );
//! render full decoration to provided painter
virtual void paint( QPainter& );
//! mouse press event
virtual bool mousePressEvent( QMouseEvent* );
//! mouse release event
virtual bool mouseReleaseEvent( QMouseEvent* );
//! mouse move event
virtual bool mouseMoveEvent( QMouseEvent* );
//! drag enter event
virtual bool dragEnterEvent( QDragEnterEvent* );
//! drag move event
virtual bool dragMoveEvent( QDragMoveEvent* );
//! drag leave event
virtual bool dragLeaveEvent( QDragLeaveEvent* );
//! drop event
virtual bool dropEvent( QDropEvent* );
//! timer event
virtual void timerEvent( QTimerEvent* );
//@}
//!@name rendering methods (called in paintEvent)
//@{
//! window background
virtual void renderWindowBackground( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
//! window border
// this draws a "blue" border around active window
virtual void renderWindowBorder( QPainter*, const QRect&, const QWidget*, const QPalette& ) const;
//! separator
virtual void renderSeparator( QPainter*, const QRect&, const QWidget*, const QColor& ) const;
//! title outline
virtual void renderTitleOutline( QPainter*, const QRect&, const QPalette& ) const;
//! title text
/*! second color, if valid, is for contrast pixel */
virtual void renderTitleText( QPainter*, const QRect&, const QColor&, const QColor& = QColor() ) const;
//! title text
/*! second color, if valid, is for contrast pixel */
virtual void renderTitleText( QPainter*, const QRect&, const QString&, const QColor&, const QColor& = QColor(), bool elide = true ) const;
//! title text
virtual QPixmap renderTitleText( const QRect&, const QString&, const QColor&, bool elide = true ) const;
//! GroupItem
virtual void renderItem( QPainter*, int, const QPalette& );
//! tabbing target rect
virtual void renderTargetRect( QPainter*, const QPalette& );
//! render corners
virtual void renderCorners( QPainter*, const QRect&, const QPalette& ) const;
//! render float frame
virtual void renderFloatFrame( QPainter*, const QRect&, const QPalette& ) const;
//! render dots
virtual void renderDots( QPainter*, const QRect&, const QColor& ) const;
//@}
//! close tab matching give button
virtual bool closeItem( const Button* );
//! index of item matching point
int tabIndexAt( const QPoint& position, bool between = false ) const
{ return _itemData.itemAt( position , between ); }
//! return pixmap corresponding to a given tab, for dragging
QPixmap itemDragPixmap( int, QRect, bool = false );
//! return true when activity change are animated
bool shadowAnimationsEnabled( void ) const
{ return ( animationsEnabled() && _configuration->shadowAnimationsEnabled() && !isPreview() ); }
//! return true when activity change are animated
bool titleAnimationsEnabled( void ) const
{
return
animationsEnabled() &&
_configuration->titleAnimationsEnabled() &&
!_configuration->drawTitleOutline() &&
!hideTitleBar() &&
!isPreview();
}
//! true if some title outline is rendered
bool hasTitleOutline( void ) const
{
return
tabCount() >= 2 ||
_itemData.isAnimated() ||
( (isActive()||glowIsAnimated()) && _configuration->drawTitleOutline() );
}
//! calculate mask
QRegion calcMask( void ) const;
//! text color
QColor titlebarTextColor(const QPalette&) const;
//! text color
QColor titlebarTextColor(const QPalette& palette, bool active) const
{
return active ?
palette.color(QPalette::Active, QPalette::WindowText):
helper().inactiveTitleBarTextColor( palette );
}
//! text color
QColor titlebarContrastColor(const QPalette& palette ) const
{ return titlebarContrastColor( palette.color( widget()->window()->backgroundRole() ) ); }
//! text color
QColor titlebarContrastColor(const QColor& color ) const
{ return helper().calcLightColor( color ); }
//!@name size grip
//@{
//! create size grip
void createSizeGrip( void );
//! delete size grip
void deleteSizeGrip( void );
// size grip
bool hasSizeGrip( void ) const
{ return (bool)_sizeGrip; }
//! size grip
SizeGrip& sizeGrip( void ) const
{ return *_sizeGrip; }
//@}
//! remove shadow hint
void removeShadowHint( void );
protected Q_SLOTS:
//! set target item to -1
void clearTargetItem( void );
//! clear force active flag
void clearForceActive( void )
{ if( isActive() ) setForceActive( false ); }
//! title bounding rects
/*! calculate and return title bounding rects in case of tabbed window */
void updateItemBoundingRects( bool alsoUpdate = true );
//! bound one rect to another
void boundRectTo( QRect&, const QRect& ) const;
private Q_SLOTS:
void updateCompositing();
void updateConfig();
private:
//! factory
Factory* _factory;
//! backing store pixmap (when compositing is not active)
QPixmap _pixmap;
//! size grip widget
SizeGrip* _sizeGrip;
//! configuration
Factory::ConfigurationPtr _configuration;
//! glow animation
Animation* _glowAnimation;
//! title animation data
TitleAnimationData* _titleAnimationData;
//! glow intensity
qreal _glowIntensity;
//! true when initialized
bool _initialized;
//! true when decoration is forced active
bool _forceActive;
//! mouse button
Qt::MouseButton _mouseButton;
//! tab bounding rects
ClientGroupItemDataList _itemData;
//! index of tab being dragged if any, -1 otherwise
int _sourceItem;
//! drag start point
QPoint _dragPoint;
//! drag start timer.
/*!
it is needed to activate animations when this was not done via either
dragMoveEvent or dragLeaveEvent
*/
QBasicTimer _dragStartTimer;
//! shadow atom
xcb_atom_t _shadowAtom;
};
} // namespace Oxygen
//____________________________________________________
Qt::Alignment Oxygen::Client::titleAlignment( void ) const
{
switch( _configuration->titleAlignment() )
{
case Configuration::AlignLeft: return Qt::AlignLeft;
case Configuration::AlignRight: return Qt::AlignRight;
default:
case Configuration::AlignCenter:
case Configuration::AlignCenterFullWidth:
return Qt::AlignCenter;
}
}
//____________________________________________________
int Oxygen::Client::buttonSize( void ) const
{
switch( _configuration->buttonSize() )
{
case Configuration::ButtonSmall: return 18;
default:
case Configuration::ButtonDefault: return 20;
case Configuration::ButtonLarge: return 24;
case Configuration::ButtonVeryLarge: return 32;
case Configuration::ButtonHuge: return 48;
}
}
//____________________________________________________
int Oxygen::Client::frameBorder( void ) const
{
switch( _configuration->frameBorder() )
{
case Configuration::BorderNone: return 0;
case Configuration::BorderNoSide: return 1;
default:
case Configuration::BorderTiny: return 2;
case Configuration::BorderDefault: return 4;
case Configuration::BorderLarge: return 8;
case Configuration::BorderVeryLarge: return 12;
case Configuration::BorderHuge: return 18;
case Configuration::BorderVeryHuge: return 27;
case Configuration::BorderOversized: return 40;
}
}
#endif

View File

@ -1,353 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenclientgroupitemdata.cpp
// handles tabs' geometry and animations
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenclientgroupitemdata.h"
#include "oxygenclientgroupitemdata.moc"
#include "oxygenclient.h"
namespace Oxygen
{
//____________________________________________________________________________
ClientGroupItemDataList::ClientGroupItemDataList( Client* parent ):
QObject( parent ),
QList<ClientGroupItemData>(),
_client( *parent ),
_dirty( false ),
animationsEnabled_( true ),
_animation( new Animation( 150, this ) ),
animationType_( AnimationNone ),
progress_(0),
draggedItem_( NoItem ),
targetItem_( NoItem )
{
// setup animation
animation().data()->setStartValue( 0 );
animation().data()->setEndValue( 1.0 );
animation().data()->setTargetObject( this );
animation().data()->setPropertyName( "progress" );
}
//________________________________________________________________
int ClientGroupItemDataList::itemAt( const QPoint& point, bool between ) const
{
for( int i=0; i < count(); i++ )
{
QRect rect = at(i)._activeRect;
if( between ) rect.translate( -rect.width() / 2, 0 );
if( rect.adjusted(0,0,0,2).contains( point ) )
{ return i; }
}
return NoItem;
}
//____________________________________________________________________________
void ClientGroupItemDataList::animate( AnimationTypes type, int target )
{
// store animation type
animationType_ = type;
if( type == AnimationNone )
{
if( isAnimationRunning() ) animation().data()->stop();
targetItem_ = NoItem;
draggedItem_ = NoItem;
targetRect_ = QRect();
} else if( type & (AnimationEnter|AnimationMove ) ) {
// store dragged item
bool animate( true );
if( (type&AnimationSameTarget) && draggedItem_ == NoItem )
{
animate = false;
draggedItem_ = target;
} else if( (type&AnimationMove) && targetItem_ == target ) return;
// check animation state
if( isAnimationRunning() ) animation().data()->stop();
targetItem_ = target;
targetRect_ = QRect();
QRect titleRect( _client.titleRect() );
int left( titleRect.left() );
int width = (type&AnimationSameTarget) ?
titleRect.width()/count():
titleRect.width()/(count()+1);
if( (type&AnimationSameTarget) && draggedItem_ < target )
{
target++;
if( target >= count() ) target = NoItem;
}
// loop over items and update bounding rects
for( int index = 0; index < count(); index++ )
{
ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
if( index == target )
{
targetRect_ = item._refBoundingRect;
targetRect_.setLeft( left );
targetRect_.setWidth( width );
left+=width;
}
item._startBoundingRect = item._boundingRect;
item._endBoundingRect = item._refBoundingRect;
item._endBoundingRect.setLeft( left );
if( (type&AnimationSameTarget) && index == draggedItem_ )
{
item._endBoundingRect.setWidth( 0 );
} else {
item._endBoundingRect.setWidth( width );
left+=width;
}
}
if( targetRect_.isNull() )
{
targetRect_ = back()._refBoundingRect;
targetRect_.setLeft( left );
targetRect_.setWidth( width );
}
if( animate )
{
if( animationsEnabled() ) animation().data()->start();
else {
// change progress to maximum
progress_ = 1;
updateBoundingRects();
}
} else {
for( int index = 0; index < count(); index++ )
{
ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
item._boundingRect = item._endBoundingRect;
}
updateButtons( true );
}
} else if( type & AnimationLeave ) {
// stop animation state
if( isAnimationRunning() ) animation().data()->stop();
// reset target
targetItem_ = NoItem;
targetRect_ = QRect();
if( type & AnimationSameTarget )
{
// store dragged item
draggedItem_ = target;
// do nothing if only one item
if( count() <= 1 ) return;
QRect titleRect( _client.titleRect() );
int left( titleRect.left() );
int width = titleRect.width()/(count()-1);
// loop over items and update bounding rects
for( int index = 0; index < count(); index++ )
{
ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
item._startBoundingRect = item._boundingRect;
item._endBoundingRect = item._refBoundingRect;
item._endBoundingRect.setLeft( left );
if( index != target )
{
if( count() <= 2 )
{
item._endBoundingRect = _client.defaultTitleRect( _client.tabId(index) == _client.currentTabId() );
} else {
item._endBoundingRect.setWidth( width );
left+=width;
}
} else {
item._endBoundingRect.setWidth( 0 );
}
}
} else {
// loop over items and update bounding rects
for( int index = 0; index < count(); index++ )
{
ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) );
item._startBoundingRect = item._boundingRect;
item._endBoundingRect = item._refBoundingRect;
}
}
if( animationsEnabled() ) animation().data()->start();
else {
// change progress to maximum
progress_ = 1;
updateBoundingRects();
}
}
return;
}
//____________________________________________________________________________
void ClientGroupItemDataList::updateButtonActivity( long visibleItem ) const
{
for( int index = 0; index < count(); index++ )
{
const ClientGroupItemData& item( at(index) );
if( item._closeButton )
{ item._closeButton.data()->setForceInactive( _client.tabId(index) != visibleItem ); }
}
}
//____________________________________________________________________________
void ClientGroupItemDataList::updateButtons( bool alsoUpdate ) const
{
// move close buttons
if( alsoUpdate ) _client.widget()->setUpdatesEnabled( false );
for( int index = 0; index < count(); index++ )
{
const ClientGroupItemData& item( at(index) );
if( !item._closeButton ) continue;
if( (!item._boundingRect.isValid()) || ((animationType_ & AnimationSameTarget)&&count()<=2 ) )
{
item._closeButton.data()->hide();
} else {
QPoint position(
item._boundingRect.right() - _client.buttonSize() - _client.layoutMetric(KCommonDecoration::LM_TitleEdgeRight),
item._boundingRect.top() + _client.layoutMetric( KCommonDecoration::LM_TitleEdgeTop ) );
if( item._closeButton.data()->isHidden() ) item._closeButton.data()->show();
item._closeButton.data()->move( position );
}
}
if( alsoUpdate )
{
_client.widget()->setUpdatesEnabled( true );
_client.updateTitleRect();
}
}
//____________________________________________________________________________
void ClientGroupItemDataList::updateBoundingRects( bool alsoUpdate )
{
qreal ratio( progress() );
for( iterator iter = begin(); iter != end(); ++iter )
{
// left
if( iter->_endBoundingRect.left() == iter->_startBoundingRect.left() )
{
iter->_boundingRect.setLeft( iter->_startBoundingRect.left() );
} else {
iter->_boundingRect.setLeft( (1.0-ratio)*iter->_startBoundingRect.left() + ratio*iter->_endBoundingRect.left() );
}
// right
if( iter->_endBoundingRect.right() == iter->_startBoundingRect.right() )
{
iter->_boundingRect.setRight( iter->_startBoundingRect.right() );
} else {
iter->_boundingRect.setRight( (1.0-ratio)*iter->_startBoundingRect.right() + ratio*iter->_endBoundingRect.right() );
}
}
// update button position
updateButtons( alsoUpdate );
}
}

View File

@ -1,223 +0,0 @@
#ifndef oxygenclientgroupitemdata_h
#define oxygenclientgroupitemdata_h
//////////////////////////////////////////////////////////////////////////////
// oxygenclientgroupitemdata.h
// handles tabs' geometry and animations
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenanimation.h"
#include <QList>
#include <QPointer>
#include <QRect>
namespace Oxygen
{
class Client;
//! animation type
enum AnimationType {
AnimationNone = 0,
AnimationEnter = 1<<0,
AnimationMove = 1<<1,
AnimationLeave = 1<<2,
AnimationSameTarget = 1<<3
};
Q_DECLARE_FLAGS(AnimationTypes, AnimationType)
//! tab data
class ClientGroupItemData
{
public:
//! constructor
explicit ClientGroupItemData( void )
{}
//! destructor
virtual ~ClientGroupItemData( void )
{}
//! reset all rects to argument
void reset( const QRect& rect )
{
_refBoundingRect = rect;
_startBoundingRect = rect;
_endBoundingRect = rect;
_boundingRect = rect;
}
//! tab active rect
QRect _activeRect;
//! reference bounding rect
/*! it is usually identical to activeRect unless there is only one tab in window */
QRect _refBoundingRect;
//! tab drawing rect
QRect _startBoundingRect;
//! tab drawing rect
QRect _endBoundingRect;
//! tab drawing rect
QRect _boundingRect;
//! tab button
typedef QPointer<Button> ButtonPointer;
ButtonPointer _closeButton;
};
class ClientGroupItemDataList: public QObject, public QList<ClientGroupItemData>
{
Q_OBJECT
//! declare animation progress property
Q_PROPERTY( qreal progress READ progress WRITE setProgress )
public:
//! invalid item index
enum { NoItem = -1 };
//! constructor
explicit ClientGroupItemDataList( Client* parent );
//! dirty state
void setDirty( const bool& value )
{ _dirty = value; }
//! dirty state
bool isDirty( void ) const
{ return _dirty; }
//! enable animations
void setAnimationsEnabled( bool value )
{ animationsEnabled_ = value; }
//! animations enabled
bool animationsEnabled( void ) const
{ return animationsEnabled_; }
//! true if being animated
bool isAnimated( void ) const
{ return animationType_ != AnimationNone; }
//! animation type
AnimationTypes animationType( void ) const
{ return animationType_; }
//! return item index matching QPoint, or -1 if none
int itemAt( const QPoint&, bool ) const;
//! returns true if index is target
bool isTarget( int index ) const
{ return index == targetItem_; }
//! start animation
/* might need to add the side of the target here */
void animate( AnimationTypes, int = NoItem );
//! true if animation is in progress
bool isAnimationRunning( void ) const
{ return animation().data()->isRunning(); }
//! update button activity
void updateButtonActivity( long visibleItem ) const;
//! update buttons
void updateButtons( bool alsoUpdate ) const;
//! target rect
const QRect& targetRect( void ) const
{ return targetRect_; }
//!@name animation progress
//@{
//! return animation object
virtual const Animation::Pointer& animation() const
{ return _animation; }
void setProgress( qreal value )
{
if( progress_ == value ) return;
progress_ = value;
updateBoundingRects();
}
qreal progress( void ) const
{ return progress_; }
//@}
protected:
//! update bounding rects
void updateBoundingRects( bool alsoUpdate = true );
private:
//! client
Client& _client;
//! dirty flag
/* used to trigger update at next paintEvent */
bool _dirty;
//! true if animations are enabled
bool animationsEnabled_;
//! animation
Animation::Pointer _animation;
//! last animation type
AnimationTypes animationType_;
//! animation progress
qreal progress_;
//! dragged item
int draggedItem_;
//! target item
int targetItem_;
//! target rect
QRect targetRect_;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Oxygen::AnimationTypes)
}
#endif

View File

@ -1,139 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg>
<kcfgfile name="oxygenrc"/>
<group name="Windeco">
<entry name="TitleAlignment" type="Enum">
<choices>
<choice name="AlignLeft" />
<choice name="AlignCenter" />
<choice name="AlignCenterFullWidth" />
<choice name="AlignRight" />
</choices>
<default>AlignCenterFullWidth</default>
</entry>
<entry name="ButtonSize" type="Enum">
<choices>
<choice name="ButtonSmall" />
<choice name="ButtonDefault" />
<choice name="ButtonLarge" />
<choice name="ButtonVeryLarge" />
<choice name="ButtonHuge" />
</choices>
<default>ButtonDefault</default>
</entry>
<entry name="SeparatorMode" type = "Enum">
<choices>
<choice name="SeparatorNever" />
<choice name="SeparatorActive" />
<choice name="SeparatorAlways" />
</choices>
<default>SeparatorNever</default>
</entry>
<entry name="FrameBorder" type = "Enum">
<choices>
<choice name="BorderNone" />
<choice name="BorderNoSide" />
<choice name="BorderTiny" />
<choice name="BorderDefault" />
<choice name="BorderLarge" />
<choice name="BorderVeryLarge" />
<choice name="BorderHuge" />
<choice name="BorderVeryHuge" />
<choice name="BorderOversized" />
</choices>
<default>BorderTiny</default>
</entry>
<entry name="DrawSizeGrip" type = "Bool">
<default>true</default>
</entry>
<entry name="DrawTitleOutline" type = "Bool">
<default>false</default>
</entry>
<entry name="HideTitleBar" type = "Bool">
<default>false</default>
</entry>
<entry name="UseNarrowButtonSpacing" type = "Bool">
<default>false</default>
</entry>
<entry name="CloseWindowFromMenuButton" type = "Bool">
<default>false</default>
</entry>
<entry name="UseExtendedWindowBorders" type = "Bool">
<default>true</default>
</entry>
<!-- maximized windows -->
<entry name="DrawBorderOnMaximizedWindows" type = "Bool">
<default>false</default>
</entry>
<!-- animations -->
<entry name="AnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ButtonAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="TitleAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ShadowAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="TabAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ButtonAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="TitleAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="ShadowAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="TabAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<!-- exceptions -->
<entry name="ExceptionType" type="Enum">
<choices>
<choice name="ExceptionWindowClassName" />
<choice name="ExceptionWindowTitle" />
</choices>
<default>ExceptionWindowClassName</default>
</entry>
<entry name="ExceptionPattern" type = "String"/>
<entry name="Enabled" type = "Bool">
<default>true</default>
</entry>
<entry name="Mask" type = "Int">
<default>0</default>
</entry>
</group>
</kcfg>

View File

@ -1,6 +0,0 @@
File=oxygenconfigdata.kcfgc
ClassName=Configuration
NameSpace=Oxygen
Singleton=false
Mutators=true
GlobalEnums=true

View File

@ -1,217 +0,0 @@
/*
* Copyright 2013 Hugo Pereira Da Costa <hugo.pereira@free.fr>
* Copyright 2008 Long Huynh Huu <long.upcase@googlemail.com>
* Copyright 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
* Copyright 2007 Casper Boemann <cbr@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "oxygendecohelper.h"
#include <QPainter>
#include <KColorUtils>
#include <cmath>
namespace Oxygen
{
//______________________________________________________________________________
DecoHelper::DecoHelper(KSharedConfigPtr config):
Helper(config)
{}
//______________________________________________________________________________
void DecoHelper::invalidateCaches( void )
{
// base class call
Helper::invalidateCaches();
// local caches
_windecoButtonCache.clear();
_titleBarTextColorCache.clear();
_buttonTextColorCache.clear();
}
//______________________________________________________________________________
QPixmap DecoHelper::windecoButton(const QColor &color, const QColor& glow, bool sunken, int size)
{
Oxygen::Cache<QPixmap>::Value* cache( _windecoButtonCache.get( color ) );
const quint64 key( ( colorKey(glow) << 32 ) | (sunken << 23 ) | size );
QPixmap *pixmap = cache->object( key );
if( !pixmap )
{
pixmap = new QPixmap(size, size);
pixmap->fill(Qt::transparent);
QPainter p( pixmap );
p.setRenderHints(QPainter::Antialiasing);
p.setPen(Qt::NoPen);
p.setWindow( 0, 0, 21, 21 );
// button shadow
if( color.isValid() )
{
p.save();
p.translate( 0, -1.4 );
drawShadow( p, calcShadowColor( color ), 21 );
p.restore();
}
// button glow
if( glow.isValid() )
{
p.save();
p.translate( 0, -1.4 );
drawOuterGlow( p, glow, 21 );
p.restore();
}
// button slab
p.setWindow( 0, 0, 18, 18 );
if( color.isValid() )
{
p.translate( 0, (0.5-0.668) );
const QColor light( calcLightColor(color) );
const QColor dark( calcDarkColor(color) );
{
//plain background
QLinearGradient lg( 0, 1.665, 0, (12.33+1.665) );
if( sunken )
{
lg.setColorAt( 1, light );
lg.setColorAt( 0, dark );
} else {
lg.setColorAt( 0, light );
lg.setColorAt( 1, dark );
}
const QRectF r( 0.5*(18-12.33), 1.665, 12.33, 12.33 );
p.setBrush( lg );
p.drawEllipse( r );
}
{
// outline circle
const qreal penWidth( 0.7 );
QLinearGradient lg( 0, 1.665, 0, (2.0*12.33+1.665) );
lg.setColorAt( 0, light );
lg.setColorAt( 1, dark );
const QRectF r( 0.5*(18-12.33+penWidth), (1.665+penWidth), (12.33-penWidth), (12.33-penWidth) );
p.setPen( QPen( lg, penWidth ) );
p.setBrush( Qt::NoBrush );
p.drawEllipse( r );
}
}
p.end();
cache->insert( key, pixmap );
}
return *pixmap;
}
//_______________________________________________________________________
QRegion DecoHelper::decoRoundedMask( const QRect& r, int left, int right, int top, int bottom ) const
{
// get rect geometry
int x, y, w, h;
r.getRect(&x, &y, &w, &h);
QRegion mask(x + 3*left, y + 0*top, w-3*(left+right), h-0*(top+bottom));
mask += QRegion(x + 0*left, y + 3*top, w-0*(left+right), h-3*(top+bottom));
mask += QRegion(x + 1*left, y + 1*top, w-1*(left+right), h-1*(top+bottom));
return mask;
}
//______________________________________________________________________________
const QColor& DecoHelper::inactiveTitleBarTextColor( const QPalette& palette )
{
const quint32 key( colorKey( palette.color(QPalette::Active, QPalette::Window) ) );
QColor* out( _titleBarTextColorCache.object( key ) );
if( !out )
{
// todo: reimplement cache
const QColor ab = palette.color(QPalette::Active, QPalette::Window);
const QColor af = palette.color(QPalette::Active, QPalette::WindowText);
const QColor nb = palette.color(QPalette::Inactive, QPalette::Window);
const QColor nf = palette.color(QPalette::Inactive, QPalette::WindowText);
out = new QColor( reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4)))) );
_titleBarTextColorCache.insert( key, out );
}
return *out;
}
//______________________________________________________________________________
const QColor& DecoHelper::inactiveButtonTextColor( const QPalette& palette )
{
const quint32 key( colorKey( palette.color(QPalette::Active, QPalette::Window) ) );
QColor* out( _buttonTextColorCache.object( key ) );
if( !out )
{
// todo: reimplement cache
const QColor ab = palette.color(QPalette::Active, QPalette::Button);
const QColor af = palette.color(QPalette::Active, QPalette::ButtonText);
const QColor nb = palette.color(QPalette::Inactive, QPalette::Button);
const QColor nf = palette.color(QPalette::Inactive, QPalette::ButtonText);
out = new QColor( reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4)))) );
_buttonTextColorCache.insert( key, out );
}
return *out;
}
//_________________________________________________________
QColor DecoHelper::reduceContrast(const QColor &c0, const QColor &c1, double t) const
{
const double s( KColorUtils::contrastRatio(c0, c1) );
if( s < t ) return c1;
double l(0);
double h(1.0);
double x(s);
double 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 ( std::abs(x - t) < 0.01) break;
if (x > t) h = a;
else l = a;
}
return r;
}
}

View File

@ -1,83 +0,0 @@
#ifndef oxygendecohelper_h
#define oxygendecohelper_h
/*
* Copyright 2013 Hugo Pereira Da Costa <hugo.pereira@free.fr>
* Copyright 2008 Long Huynh Huu <long.upcase@googlemail.com>
* Copyright 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
* Copyright 2007 Casper Boemann <cbr@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "oxygenhelper.h"
#include <ksharedconfig.h>
//! helper class
/*! contains utility functions used at multiple places in oxygen style */
namespace Oxygen
{
class DecoHelper : public Helper
{
public:
//! constructor
explicit DecoHelper(KSharedConfigPtr config);
//! destructor
virtual ~DecoHelper()
{}
//! reset all caches
virtual void invalidateCaches();
//!@name decoration specific helper functions
//!
//@{
virtual QPixmap windecoButton(const QColor &color, const QColor& glow, bool sunken, int size = 21);
//@}
//
virtual QRegion decoRoundedMask( const QRect&, int left = 1, int right = 1, int top = 1, int bottom = 1 ) const;
//! title bar text color
const QColor& inactiveTitleBarTextColor( const QPalette& );
//! button text color
const QColor& inactiveButtonTextColor( const QPalette& );
protected:
//! reduce contrast between two colors
QColor reduceContrast(const QColor&, const QColor&, double) const;
private:
//! windeco buttons
Cache<QPixmap> _windecoButtonCache;
//! titleBar text color cache
ColorCache _titleBarTextColorCache;
//! button text color cache
ColorCache _buttonTextColorCache;
};
}
#endif // __OXYGEN_STYLE_HELPER_H

View File

@ -1,83 +0,0 @@
#ifndef oxygendecorationdefines_h
#define oxygendecorationdefines_h
//////////////////////////////////////////////////////////////////////////////
// oxygendecorationdefines.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenconfiguration.h"
#include <QSharedPointer>
#include <QList>
namespace Oxygen
{
//! this should move to some global declaration
typedef QSharedPointer<Configuration> ConfigurationPtr;
typedef QList<ConfigurationPtr> ConfigurationList;
typedef QListIterator<ConfigurationPtr> ConfigurationListIterator;
//! buttons
enum ButtonType {
ButtonHelp=0,
ButtonMax,
ButtonMin,
ButtonClose,
ButtonMenu,
ButtonSticky,
ButtonAbove,
ButtonBelow,
ButtonShade,
ButtonApplicationMenu,
ButtonTypeCount,
// Close only one tab
ButtonItemClose=100,
// shows the window menu for one tab
ButtonItemMenu
};
//! buttons status
enum ButtonStatus {
Normal = 0,
Hovered = 1<<0,
Pressed = 1<<1
};
//! exception
enum ExceptionMask
{
None = 0,
TitleAlignment = 1<<0,
DrawSeparator = 1<<2,
TitleOutline = 1<<3,
FrameBorder = 1<<4,
SizeGripMode = 1<<6
};
}
#endif

View File

@ -1,104 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionlist.cpp
// window decoration exceptions
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenexceptionlist.h"
#include "oxygenutil.h"
#include <QTextStream>
namespace Oxygen
{
//______________________________________________________________
void ExceptionList::readConfig( KSharedConfig::Ptr config )
{
_exceptions.clear();
QString groupName;
for( int index = 0; config->hasGroup( groupName = exceptionGroupName( index ) ); ++index )
{
// create exception
Configuration exception;
// reset group
Util::readConfig( &exception, config.data(), groupName );
// create new configuration
ConfigurationPtr configuration( new Configuration() );
Util::readConfig( configuration.data(), config.data() );
// apply changes from exception
configuration->setEnabled( exception.enabled() );
configuration->setExceptionType( exception.exceptionType() );
configuration->setExceptionPattern( exception.exceptionPattern() );
configuration->setMask( exception.mask() );
// propagate all features found in mask to the output configuration
if( exception.mask() & FrameBorder ) configuration->setFrameBorder( exception.frameBorder() );
if( exception.mask() & DrawSeparator ) configuration->setSeparatorMode( exception.separatorMode() );
if( exception.mask() & TitleOutline ) configuration->setDrawTitleOutline( exception.drawTitleOutline() );
if( exception.mask() & SizeGripMode ) configuration->setDrawSizeGrip( exception.drawSizeGrip() );
configuration->setHideTitleBar( exception.hideTitleBar() );
// append to exceptions
_exceptions.append( configuration );
}
}
//______________________________________________________________
void ExceptionList::writeConfig( KSharedConfig::Ptr config )
{
// remove all existing exceptions
QString groupName;
for( int index = 0; config->hasGroup( groupName = exceptionGroupName( index ) ); ++index )
{ config->deleteGroup( groupName ); }
// rewrite current exceptions
int index = 0;
foreach( const ConfigurationPtr& exception, _exceptions )
{
Util::writeConfig( exception.data(), config.data(), exceptionGroupName( index ) );
++index;
}
}
//_______________________________________________________________________
QString ExceptionList::exceptionGroupName( int index )
{
QString out;
QTextStream( &out ) << "Windeco Exception " << index;
return out;
}
}

View File

@ -1,73 +0,0 @@
#ifndef oxygenexceptionlist_h
#define oxygenexceptionlist_h
//////////////////////////////////////////////////////////////////////////////
// oxygenexceptionlist.h
// window decoration exceptions
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenconfiguration.h"
#include "oxygendecorationdefines.h"
#include <KSharedConfig>
namespace Oxygen
{
//! oxygen exceptions list
class ExceptionList
{
public:
//! constructor from list
explicit ExceptionList( const ConfigurationList& exceptions = ConfigurationList() ):
_exceptions( exceptions )
{}
//! exceptions
const ConfigurationList& get( void ) const
{ return _exceptions; }
//! read from KConfig
void readConfig( KSharedConfig::Ptr );
//! write to kconfig
void writeConfig( KSharedConfig::Ptr );
protected:
//! generate exception group name for given exception index
static QString exceptionGroupName( int index );
private:
//! exceptions
ConfigurationList _exceptions;
};
}
#endif

View File

@ -1,204 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygen.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
// 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 "oxygenfactory.h"
#include "oxygenclient.h"
#include "oxygenexceptionlist.h"
#include <KSharedConfig>
#include <KConfigGroup>
#include <KWindowInfo>
KWIN_DECORATION(OxygenPluginFactory, "oxygenclient.json", Oxygen::Factory)
namespace Oxygen
{
//___________________________________________________
Factory::Factory(QObject *parent):
KDecorationFactory(parent),
_initialized( false ),
_config( KSharedConfig::openConfig( QStringLiteral("oxygenrc") ) ),
_helper( _config ),
_shadowCache( _helper )
{
readConfig();
setInitialized( true );
connect(options(), &KDecorationOptions::colorsChanged, this, [this]() {
_shadowCache.invalidateCaches();
});
connect(options(), &KDecorationOptions::configChanged, this, [this]() {
// read in the configuration
setInitialized( false );
readConfig();
setInitialized( true );
emit recreateDecorations();
});
}
//___________________________________________________
Factory::~Factory()
{ setInitialized( false ); }
//___________________________________________________
KDecoration* Factory::createDecoration(KDecorationBridge* bridge )
{ return (new Client( bridge, this ))->decoration(); }
//___________________________________________________
void Factory::readConfig()
{
/*
always reload helper
this is needed to properly handle
color contrast settings changed
*/
_config->reparseConfiguration(); // could be skipped on startup
helper().invalidateCaches();
helper().loadConfig();
// initialize default configuration and read
if( !_defaultConfiguration ) _defaultConfiguration = ConfigurationPtr(new Configuration());
_defaultConfiguration->setCurrentGroup( QStringLiteral("Windeco") );
_defaultConfiguration->readConfig();
// clear exceptions and read
ExceptionList exceptions;
exceptions.readConfig( _config );
_exceptions = exceptions.get();
// read shadowCache configuration
_shadowCache.readConfig();
_shadowCache.setAnimationsDuration( _defaultConfiguration->shadowAnimationsDuration() );
// background pixmap
{
KConfigGroup group( _config->group("Common") );
helper().setBackgroundPixmap( group.readEntry( "BackgroundPixmap", "" ) );
}
}
//_________________________________________________________________
bool Factory::supports( Ability ability ) const
{
switch( ability )
{
// announce
case AbilityAnnounceButtons:
// buttons
case AbilityButtonMenu:
case AbilityButtonApplicationMenu:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonOnAllDesktops:
case AbilityButtonAboveOthers:
case AbilityButtonBelowOthers:
case AbilityButtonSpacer:
case AbilityButtonShade:
// compositing
case AbilityProvidesShadow:
return true;
case AbilityUsesAlphaChannel:
case AbilityAnnounceAlphaChannel:
return true;
// tabs
case AbilityTabbing:
return true;
// no colors supported at this time
default:
return false;
};
}
//____________________________________________________________________
Factory::ConfigurationPtr Factory::configuration( const Client& client )
{
QString windowTitle;
QString className;
foreach( const ConfigurationPtr& configuration, _exceptions )
{
// discard disabled exceptions
if( !configuration->enabled() ) continue;
// discard exceptions with empty exception pattern
if( configuration->exceptionPattern().isEmpty() ) continue;
/*
decide which value is to be compared
to the regular expression, based on exception type
*/
QString value;
switch( configuration->exceptionType() )
{
case Configuration::ExceptionWindowTitle:
{
value = windowTitle.isEmpty() ? (windowTitle = client.caption()):windowTitle;
break;
}
default:
case Configuration::ExceptionWindowClassName:
{
if( className.isEmpty() )
{
// retrieve class name
KWindowInfo info( client.windowId(), 0, NET::WM2WindowClass );
QString window_className( QString::fromUtf8(info.windowClassName()) );
QString window_class( QString::fromUtf8(info.windowClassClass()) );
className = window_className + QStringLiteral(" ") + window_class;
}
value = className;
break;
}
}
// check matching
if( QRegExp( configuration->exceptionPattern() ).indexIn( value ) >= 0 )
{ return configuration; }
}
return _defaultConfiguration;
}
}
#include "oxygenfactory.moc"

View File

@ -1,138 +0,0 @@
#ifndef oxygenfactory_h
#define oxygenfactory_h
//////////////////////////////////////////////////////////////////////////////
// oxygen.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira <hugo.pereira@free.fr>
// 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.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenconfiguration.h"
#include "oxygendecorationdefines.h"
#include "oxygendecohelper.h"
#include "oxygenshadowcache.h"
#include <QObject>
#include <kdecorationfactory.h>
namespace Oxygen
{
class Client;
enum {
//! this is the top title bar edge
TFRAMESIZE = 3,
/*!
this is the extra title bar top and bottom edges
needed to outline active window title bar
*/
HFRAMESIZE = 4
};
//! window decoration factory
class Factory: public KDecorationFactory
{
Q_OBJECT
public:
//! constructor
explicit Factory(QObject *parent = nullptr);
//! destructor
virtual ~Factory();
//! create decoration
virtual KDecoration *createDecoration(KDecorationBridge *b);
//! configuration capabilities
virtual bool supports( Ability ability ) const;
//! true if initialized
virtual bool initialized()
{ return _initialized; }
//! helper
virtual DecoHelper& helper( void )
{ return _helper; }
//! shadow cache
virtual ShadowCache& shadowCache( void )
{ return _shadowCache; }
//! shadow cache
virtual const ShadowCache& shadowCache( void ) const
{ return _shadowCache; }
//! pointer to configuration
typedef QSharedPointer<Configuration> ConfigurationPtr;
//! get configuration for a give client
virtual ConfigurationPtr configuration( const Client& );
protected:
//! read configuration from KConfig
void readConfig();
//! initialization
void setInitialized( bool value )
{ _initialized = value; }
//! exception group name
QString exceptionGroupName( int index ) const
{
QString out;
QTextStream( &out ) << "Windeco Exception " << index;
return out;
}
private:
//! initialization flag
bool _initialized;
//! config object
KSharedConfigPtr _config;
//! helper
DecoHelper _helper;
//! shadow cache
ShadowCache _shadowCache;
//! default configuration
ConfigurationPtr _defaultConfiguration;
//! list of exceptiosn
QList<ConfigurationPtr> _exceptions;
};
}
#endif

View File

@ -1,238 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygensizegrip.cpp
// bottom right size grip for borderless windows
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygensizegrip.h"
#include "oxygenbutton.h"
#include "oxygenclient.h"
#include <cassert>
#include <QPainter>
#include <QPolygon>
#include <QTimer>
#include <xcb/xcb.h>
namespace Oxygen
{
//_____________________________________________
SizeGrip::SizeGrip( Client* client ):
QWidget(0),
_client( client )
{
setAttribute(Qt::WA_NoSystemBackground );
setAutoFillBackground( false );
// cursor
setCursor( Qt::SizeFDiagCursor );
// size
setFixedSize( QSize( GRIP_SIZE, GRIP_SIZE ) );
// mask
QPolygon p;
p << QPoint( 0, GRIP_SIZE )
<< QPoint( GRIP_SIZE, 0 )
<< QPoint( GRIP_SIZE, GRIP_SIZE )
<< QPoint( 0, GRIP_SIZE );
setMask( QRegion( p ) );
// embed
embed();
updatePosition();
// event filter
client->widget()->installEventFilter( this );
// show
show();
}
//_____________________________________________
SizeGrip::~SizeGrip( void )
{}
//_____________________________________________
void SizeGrip::activeChange( void )
{
static const uint32_t value = XCB_STACK_MODE_ABOVE;
xcb_configure_window( _client->helper().xcbConnection(), winId(), XCB_CONFIG_WINDOW_STACK_MODE, &value );
xcb_map_window( _client->helper().xcbConnection(), winId() );
}
//_____________________________________________
void SizeGrip::embed( void )
{
xcb_window_t window_id = _client->windowId();
if( _client->isPreview() ) {
setParent( _client->widget() );
} else if( window_id ) {
xcb_window_t current = window_id;
xcb_connection_t* connection = _client->helper().xcbConnection();
while( true )
{
xcb_query_tree_cookie_t cookie = xcb_query_tree_unchecked( connection, current );
Helper::ScopedPointer<xcb_query_tree_reply_t> tree(xcb_query_tree_reply( connection, cookie, nullptr ) );
if (tree.isNull()) break;
if (tree->parent && tree->parent != tree->root && tree->parent != current) current = tree->parent;
else break;
}
// reparent
xcb_reparent_window( connection, winId(), current, 0, 0 );
} else {
hide();
}
}
//_____________________________________________
bool SizeGrip::eventFilter( QObject*, QEvent* event )
{
if ( event->type() == QEvent::Resize) updatePosition();
return false;
}
//_____________________________________________
void SizeGrip::paintEvent( QPaintEvent* )
{
// get relevant colors
QColor base( _client->backgroundColor( this, palette(), _client->isActive() ) );
QColor light( _client->helper().calcDarkColor( base ) );
QColor dark( _client->helper().calcDarkColor( base.darker(150) ) );
// create and configure painter
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing );
painter.setPen( Qt::NoPen );
painter.setBrush( base );
// polygon
QPolygon p;
p << QPoint( 0, GRIP_SIZE )
<< QPoint( GRIP_SIZE, 0 )
<< QPoint( GRIP_SIZE, GRIP_SIZE )
<< QPoint( 0, GRIP_SIZE );
painter.drawPolygon( p );
// diagonal border
painter.setBrush( Qt::NoBrush );
painter.setPen( QPen( dark, 3 ) );
painter.drawLine( QPoint( 0, GRIP_SIZE ), QPoint( GRIP_SIZE, 0 ) );
// side borders
painter.setPen( QPen( light, 1.5 ) );
painter.drawLine( QPoint( 1, GRIP_SIZE ), QPoint( GRIP_SIZE, GRIP_SIZE ) );
painter.drawLine( QPoint( GRIP_SIZE, 1 ), QPoint( GRIP_SIZE, GRIP_SIZE ) );
painter.end();
}
//_____________________________________________
void SizeGrip::mousePressEvent( QMouseEvent* event )
{
switch (event->button())
{
case Qt::RightButton:
{
hide();
QTimer::singleShot(5000, this, SLOT(show()));
break;
}
case Qt::MidButton:
{
hide();
break;
}
case Qt::LeftButton:
if( rect().contains( event->pos() ) )
{
// check client window id
if( !_client->windowId() ) break;
_client->widget()->setFocus();
if( _client->decoration() )
{ _client->decoration()->performWindowOperation( KDecorationDefines::ResizeOp ); }
}
break;
default: break;
}
return;
}
//_______________________________________________________________________________
void SizeGrip::updatePosition( void )
{
QPoint position(
_client->width() - GRIP_SIZE - OFFSET,
_client->height() - GRIP_SIZE - OFFSET );
if( _client->isPreview() )
{
position -= QPoint(
_client->layoutMetric( Client::LM_BorderRight )+
_client->layoutMetric( Client::LM_OuterPaddingRight ),
_client->layoutMetric( Client::LM_OuterPaddingBottom )+
_client->layoutMetric( Client::LM_BorderBottom )
);
} else {
position -= QPoint(
_client->layoutMetric( Client::LM_BorderRight ),
_client->layoutMetric( Client::LM_BorderBottom ) );
}
move( position );
}
}

View File

@ -1,100 +0,0 @@
#ifndef oxygensizegrip_h
#define oxygensizegrip_h
//////////////////////////////////////////////////////////////////////////////
// oxygensizegrip.h
// bottom right size grip for borderless windows
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 <QWidget>
#include <QPaintEvent>
#include <QMouseEvent>
namespace Oxygen
{
class Client;
//! implements size grip for all widgets
class SizeGrip: public QWidget
{
public:
//! constructor
explicit SizeGrip( Client* );
//! constructor
virtual ~SizeGrip( void );
//! event filter
virtual bool eventFilter( QObject*, QEvent* );
public Q_SLOTS:
//! update background color
void activeChange( void );
protected Q_SLOTS:
//! embed into parent widget
void embed( void );
protected:
//!@name event handlers
//@{
//! paint
virtual void paintEvent( QPaintEvent* );
//! mouse press
virtual void mousePressEvent( QMouseEvent* );
//@}
//! client
Client& client( void ) const
{ return *_client; }
//! update position
void updatePosition( void );
private:
//! grip size
enum {
OFFSET = 0,
GRIP_SIZE = 14
};
// oxygen client
Client* _client;
};
}
#endif

View File

@ -1,152 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygentitleanimationdata.h
// handles transition when window title is changed
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygentitleanimationdata.h"
#include "oxygentitleanimationdata.moc"
#include <QPainter>
namespace Oxygen
{
// use 300 milliseconds for animation lock
const int TitleAnimationData::_lockTime = 300;
//_________________________________________________________
TitleAnimationData::TitleAnimationData( QObject* parent ):
QObject( parent ),
_dirty( false ),
_animation( new Animation( 200, this ) ),
_opacity(0)
{}
//_________________________________________________________
void TitleAnimationData::initialize( void )
{
// setup title animation
animation().data()->setStartValue( 0 );
animation().data()->setEndValue( 1 );
animation().data()->setTargetObject( this );
animation().data()->setPropertyName( "opacity" );
animation().data()->setEasingCurve( QEasingCurve::InOutQuad );
}
//_________________________________________________________
void TitleAnimationData::setPixmaps( QRect rect, QPixmap pixmap, QPixmap contrast )
{
// stop animation
if( isAnimated() ) animation().data()->stop();
// update pixmaps
_contrastPixmap.initialize( rect, contrast );
_pixmap.initialize( rect, pixmap );
setOpacity(0);
updatePixmaps();
}
//_________________________________________________________
void TitleAnimationData::updatePixmaps( void )
{
_contrastPixmap.blend( opacity() );
_pixmap.blend( opacity() );
emit pixmapsChanged();
}
//_________________________________________________________
void TitleAnimationData::timerEvent( QTimerEvent* e )
{
if( e->timerId() != _animationLockTimer.timerId() )
{ return QObject::timerEvent( e ); }
// unlock
unlockAnimations();
if( !isAnimated() )
{
// triggers pixmap updates
reset();
emit pixmapsChanged();
}
}
//_________________________________________________________
void TitleAnimationData::BlendedPixmap::blend( qreal opacity )
{
_currentPixmap = QPixmap( _endRect.size() );
_currentPixmap.fill( Qt::transparent );
QPainter painter( &_currentPixmap );
if( opacity < 1 && !_startPixmap.isNull() )
{ painter.drawPixmap( _startRect.topLeft() - _endRect.topLeft(), fade( _startPixmap, 1.0 - opacity ) ); }
if( opacity > 0 && !_endPixmap.isNull() )
{ painter.drawPixmap( QPoint(0,0), fade( _endPixmap, opacity ) ); }
painter.end();
return;
}
//_________________________________________________________
QPixmap TitleAnimationData::BlendedPixmap::fade( QPixmap source, qreal opacity ) const
{
if( source.isNull() ) return QPixmap();
QPixmap out( source.size() );
out.fill( Qt::transparent );
// do nothing if opacity is too small
if( opacity*255 < 1 ) return out;
// draw pixmap
QPainter p( &out );
p.drawPixmap( QPoint(0,0), source );
// opacity mask
if( opacity*255 <= 254 )
{
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
QColor color( Qt::black );
color.setAlphaF( opacity );
p.fillRect(out.rect(), color );
}
p.end();
return out;
}
}

View File

@ -1,258 +0,0 @@
#ifndef oxygentitleanimationdata_h
#define oxygentitleanimationdata_h
//////////////////////////////////////////////////////////////////////////////
// oxygentitleanimationdata.h
// handles transition when window title is changed
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// 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 "oxygenanimation.h"
#include <cassert>
#include <QObject>
#include <QPointer>
#include <QBasicTimer>
#include <QTimerEvent>
#include <QPixmap>
namespace Oxygen
{
class TitleAnimationData: public QObject
{
Q_OBJECT
//! declare title opacity
Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
public:
typedef QPointer<TitleAnimationData> Pointer;
//! constructor
explicit TitleAnimationData( QObject* );
//! reset
void reset( void )
{
setOpacity(0);
_contrastPixmap.reset();
_pixmap.reset();
}
//! initialize
void initialize( void );
// reset
void reset( QRect rect, QPixmap pixmap, QPixmap contrast )
{
setOpacity(0);
_contrastPixmap.reset( rect, contrast );
_pixmap.reset( rect, pixmap );
}
//! set pixmaps
void setPixmaps( QRect, QPixmap pixmap, QPixmap contrast );
//! duration
void setDuration( int duration )
{
assert( animation() );
animation().data()->setDuration( duration );
}
//! retrieve contrast pixmap
QPixmap contrastPixmap( void ) const
{ return _contrastPixmap.currentPixmap(); }
//! pixmap
QPixmap pixmap( void ) const
{ return _pixmap.currentPixmap(); }
//!@name animation
//@{
//! returns true if animations are locked
bool isLocked( void ) const
{ return _animationLockTimer.isActive(); }
//! returns true if title transition animation is currently running
bool isAnimated( void ) const
{ return animation().data()->isRunning(); }
//! start lock animation timer
void lockAnimations( void )
{ _animationLockTimer.start( _lockTime, this ); }
//! start lock animation timer
void unlockAnimations( void )
{ _animationLockTimer.stop(); }
//! start title transition animation
void startAnimation( void )
{
assert( !isAnimated() );
animation().data()->start();
}
//! finish title transition animation
void finishAnimation( void )
{
assert( isAnimated() );
animation().data()->stop();
}
//@}
//!@name opacity
//@{
qreal opacity( void ) const
{ return _opacity; }
void setOpacity( qreal value )
{
if( _opacity == value ) return;
_opacity = value;
updatePixmaps();
}
//@}
//! validity
bool isValid( void ) const
{ return _pixmap.isValid(); }
//! dirty flag
void setDirty( bool value )
{ _dirty = value; }
//! dirty flag
bool isDirty( void ) const
{ return _dirty; }
Q_SIGNALS:
void pixmapsChanged( void );
protected:
//! update pixmaps
virtual void updatePixmaps( void );
//! timer event
void timerEvent( QTimerEvent* );
//! animation object
const Animation::Pointer& animation( void ) const
{ return _animation; }
private:
//! used to blend pixmap
class BlendedPixmap
{
public:
// reset everything
void reset( void )
{
_startRect = _endRect = QRect();
_startPixmap = _endPixmap = _currentPixmap = QPixmap();
}
//! reset
void reset( const QRect& rect, QPixmap pixmap )
{
_startRect = _endRect = rect;
_startPixmap = _endPixmap = _currentPixmap = pixmap;
}
// update pixmaps
void initialize( const QRect& rect, QPixmap pixmap )
{
_startRect = _endRect;
_endRect = rect;
_startPixmap = _currentPixmap;
_endPixmap = pixmap;
}
//! update currentPixmap by blending start and end pixmap
void blend( qreal opacity );
//! current pixmap
QPixmap currentPixmap( void ) const
{ return _currentPixmap; }
//! validity
bool isValid( void ) const
{ return !(_endRect.isNull() || _endPixmap.isNull() ); }
protected:
// fade pixmap by some amount
QPixmap fade( QPixmap, qreal ) const;
private:
//! animation starting pixmap
QPixmap _startPixmap;
//! animation ending pixmap
QPixmap _endPixmap;
//! animation current pixmap
QPixmap _currentPixmap;
QRect _startRect;
QRect _endRect;
};
bool _dirty;
BlendedPixmap _contrastPixmap;
BlendedPixmap _pixmap;
//! lock time (milliseconds
static const int _lockTime;
//! timer used to disable animations when triggered too early
QBasicTimer _animationLockTimer;
//! title animation
Animation::Pointer _animation;
//! title opacity
qreal _opacity;
};
}
#endif