Added configuration widget

Not (yet) loaded inside kwin decoration kcm
wilder-pre-rebase
Hugo Pereira Da Costa 11 years ago
parent 0b0f104444
commit cc61aa262c
  1. 2
      windec/kdecoration2/CMakeLists.txt
  2. 8
      windec/kdecoration2/breezedecoration.cpp
  3. 1
      windec/kdecoration2/breezedecoration.h
  4. 8
      windec/kdecoration2/breezesettingsdata.kcfg
  5. 24
      windec/kdecoration2/config/CMakeLists.txt
  6. 191
      windec/kdecoration2/config/breezeconfig.cpp
  7. 129
      windec/kdecoration2/config/breezeconfig.h
  8. 109
      windec/kdecoration2/config/breezeconfigwidget.cpp
  9. 100
      windec/kdecoration2/config/breezeconfigwidget.h
  10. 3
      windec/kdecoration2/config/config.json
  11. 163
      windec/kdecoration2/config/ui/breezeconfigurationui.ui

@ -25,3 +25,5 @@ target_link_libraries(breezedecoration
)
install(TARGETS breezedecoration DESTINATION ${PLUGIN_INSTALL_DIR}/org.kde.kdecoration2)
add_subdirectory(config)

@ -80,6 +80,7 @@ namespace Breeze
// a change in font might cause the borders to change
connect(s.data(), &KDecoration2::DecorationSettings::fontChanged, this, &Decoration::recalculateBorders);
connect(s.data(), &KDecoration2::DecorationSettings::spacingChanged, this, &Decoration::recalculateBorders);
connect(s.data(), &KDecoration2::DecorationSettings::reconfigured, this, &Decoration::reconfigure);
connect(client().data(), &KDecoration2::DecoratedClient::adjacentScreenEdgesChanged, this, &Decoration::recalculateBorders);
connect(client().data(), &KDecoration2::DecoratedClient::maximizedHorizontallyChanged, this, &Decoration::recalculateBorders);
connect(client().data(), &KDecoration2::DecoratedClient::maximizedVerticallyChanged, this, &Decoration::recalculateBorders);
@ -156,6 +157,13 @@ namespace Breeze
return borderSize(settings, false);
}
//________________________________________________________________
void Decoration::reconfigure()
{
m_internalSettings.read();
recalculateBorders();
}
//________________________________________________________________
void Decoration::recalculateBorders()
{

@ -72,6 +72,7 @@ namespace Breeze
void init() override;
private Q_SLOTS:
void reconfigure();
void recalculateBorders();
void updateButtonPositions();
void updateTitleBar();

@ -27,9 +27,11 @@
</entry>
<!-- maximized windows -->
<entry name="DrawBorderOnMaximizedWindows" type = "Bool">
<default>false</default>
</entry>
<!--
<entry name="DrawBorderOnMaximizedWindows" type = "Bool">
<default>false</default>
</entry>
-->
<!-- animations -->
<entry name="AnimationsEnabled" type = "Bool">

@ -0,0 +1,24 @@
add_definitions(-DTRANSLATION_DOMAIN=\"breeze_decoration_config\")
find_package(Qt5 CONFIG REQUIRED COMPONENTS DBus )
set(breezedecoration_config_PART_SRCS
breezeconfig.cpp
breezeconfigwidget.cpp
)
set(breezedecoration_config_PART_FORMS
ui/breezeconfigurationui.ui
)
kconfig_add_kcfg_files(breezedecoration_config_PART_SRCS ../breezesettings.kcfgc)
ki18n_wrap_ui(breezedecoration_config_PART_FORMS_HEADERS ${breezedecoration_config_PART_FORMS})
add_library(breezedecoration_config MODULE
${breezedecoration_config_PART_SRCS}
${breezedecoration_config_PART_FORMS_HEADERS})
target_link_libraries(breezedecoration_config Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus)
target_link_libraries(breezedecoration_config KF5::I18n KF5::ConfigCore KF5::ConfigWidgets)
install(TARGETS breezedecoration_config DESTINATION ${PLUGIN_INSTALL_DIR}/org.kde.kdecoration2)

@ -0,0 +1,191 @@
//////////////////////////////////////////////////////////////////////////////
// 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 "breezeconfig.h"
#include "../breezesettings.h"
#include <QTextStream>
#include <QDBusConnection>
#include <QDBusMessage>
#include <KLocalizedString>
#include <KPluginFactory>
//_______________________________________________________________________
//* plugin definition
/**
* this is the old style/KDE4 plugin declaration.
* it is used in breeze-settings
*/
extern "C"
{
Q_DECL_EXPORT QObject* allocate_config( KConfig*, QWidget* parent )
{ return ( new Breeze::Config( parent ) ); }
}
/** this is the new style/KF5 plugin declaration, used internally by KWin */
K_PLUGIN_FACTORY_WITH_JSON(
BreezeConfigPlugin,
"config.json",
registerPlugin<Breeze::ConfigurationModule>(QStringLiteral("kcmodule"));
)
#include "breezeconfig.moc"
namespace Breeze
{
// create new configuration
QObject *Config::create(QWidget *parentWidget, QObject *, const QList<QVariant> &)
{ return new Config(parentWidget); }
//_______________________________________________________________________
Config::Config(QWidget* parent ):
QObject( parent )
{
// configuration
m_configuration = KSharedConfig::openConfig( QStringLiteral( "breezerc" ) );
// create new configuration widget and add to layout, if any
m_configWidget = new ConfigWidget( parent );
if( parent && parent->layout() ) parent->layout()->addWidget( m_configWidget );
else m_configWidget->show();
load();
connect( m_configWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
}
//_______________________________________________________________________
Config::~Config()
{ delete m_configWidget; }
//_______________________________________________________________________
void Config::load( void )
{
// load standard configuration
InternalSettingsPtr internalSettings( new InternalSettings() );
internalSettings->load();
loadInternalSettings( internalSettings );
updateChanged();
}
//_______________________________________________________________________
void Config::updateChanged( void )
{
bool modified( false );
// exceptions
if( m_configWidget->isChanged() ) modified = true;
// emit relevant signals
if( modified ) emit changed();
emit changed( modified );
}
//_______________________________________________________________________
void Config::save( void )
{
// create configuration from group
InternalSettingsPtr internalSettings( new InternalSettings() );
internalSettings->load();
// save config widget
m_configWidget->setInternalSettings( internalSettings );
m_configWidget->save();
// save configuration
internalSettings->save();
// sync configuration
m_configuration->sync();
QDBusMessage message( QDBusMessage::createSignal( QStringLiteral( "/BreezeWindeco" ), QStringLiteral( "org.kde.Breeze.Style" ), QStringLiteral( "reparseConfiguration") ) );
QDBusConnection::sessionBus().send(message);
}
//_______________________________________________________________________
void Config::defaults( void )
{
// install default configuration
InternalSettingsPtr internalSettings( new InternalSettings() );
internalSettings->setDefaults();
loadInternalSettings( internalSettings );
updateChanged();
}
//_______________________________________________________________________
void Config::loadInternalSettings( InternalSettingsPtr configuration )
{
m_configWidget->setInternalSettings( configuration );
m_configWidget->load();
}
//_______________________________________________________________________
ConfigurationModule::ConfigurationModule(QWidget *parent, const QVariantList &args):
KCModule(parent, args)
{
setLayout(new QVBoxLayout(this));
m_config = new Config( this );
}
//_______________________________________________________________________
void ConfigurationModule::defaults()
{
m_config->defaults();
KCModule::defaults();
}
//_______________________________________________________________________
void ConfigurationModule::load()
{
m_config->load();
KCModule::load();
}
//_______________________________________________________________________
void ConfigurationModule::save()
{
m_config->save();
KCModule::save();
}
}

@ -0,0 +1,129 @@
#ifndef breeze_config_h
#define breeze_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 "breezeconfigwidget.h"
#include <KSharedConfig>
#include <KCModule>
namespace Breeze {
class Configuration;
// breeze 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 );
private Q_SLOTS:
//* update change state
void updateChanged( void );
private:
//* load configuration
void loadInternalSettings( InternalSettingsPtr );
//* user interface
ConfigWidget* m_configWidget;
//* kconfiguration object
KSharedConfig::Ptr m_configuration;
};
//* configuration module
class ConfigurationModule: public KCModule
{
Q_OBJECT
public:
ConfigurationModule(QWidget *parent, const QVariantList &args);
public Q_SLOTS:
void defaults() override;
void load() override;
void save() override;
private:
//* configuration
Config* m_config;
};
} //namespace Breeze
#endif

@ -0,0 +1,109 @@
//////////////////////////////////////////////////////////////////////////////
// breezeconfigurationui.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 "breezeconfigwidget.h"
#include <QGroupBox>
#include <QIcon>
#include <QLabel>
#include <QLayout>
#include <KLocalizedString>
namespace Breeze
{
//_________________________________________________________
ConfigWidget::ConfigWidget( QWidget* parent ):
QWidget( parent ),
m_changed( false )
{
m_ui.setupUi( this );
// track ui changes
connect( m_ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( m_ui.buttonSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
// track animations changes
connect( m_ui.animationsEnabled, SIGNAL(clicked()), SLOT(updateChanged()) );
connect( m_ui.animationsDuration, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
}
//_________________________________________________________
void ConfigWidget::setInternalSettings( InternalSettingsPtr internalSettings )
{ m_internalSettings = internalSettings; }
//_________________________________________________________
void ConfigWidget::load( void )
{
if( !m_internalSettings ) return;
m_ui.titleAlignment->setCurrentIndex( m_internalSettings->titleAlignment() );
m_ui.buttonSize->setCurrentIndex( m_internalSettings->buttonSize() );
m_ui.animationsEnabled->setChecked( m_internalSettings->animationsEnabled() );
m_ui.animationsDuration->setValue( m_internalSettings->animationsDuration() );
setChanged( false );
}
//_________________________________________________________
void ConfigWidget::save( void )
{
if( !m_internalSettings ) return;
// apply modifications from ui
m_internalSettings->setTitleAlignment( m_ui.titleAlignment->currentIndex() );
m_internalSettings->setButtonSize( m_ui.buttonSize->currentIndex() );
m_internalSettings->setAnimationsEnabled( m_ui.animationsEnabled->isChecked() );
m_internalSettings->setAnimationsDuration( m_ui.animationsDuration->value() );
setChanged( false );
}
//_______________________________________________
void ConfigWidget::updateChanged( void )
{
// check configuration
if( !m_internalSettings ) return;
// track modifications
bool modified( false );
if( m_ui.titleAlignment->currentIndex() != m_internalSettings->titleAlignment() ) modified = true;
else if( m_ui.buttonSize->currentIndex() != m_internalSettings->buttonSize() ) modified = true;
// animations
else if( m_ui.animationsEnabled->isChecked() != m_internalSettings->animationsEnabled() ) modified = true;
else if( m_ui.animationsDuration->value() != m_internalSettings->animationsDuration() ) modified = true;
setChanged( modified );
}
}

@ -0,0 +1,100 @@
#ifndef breezeconfigwidget_h
#define breezeconfigwidget_h
//////////////////////////////////////////////////////////////////////////////
// breezeconfigurationui.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_breezeconfigurationui.h"
#include "../breezesettings.h"
#include <QWidget>
#include <QSharedPointer>
namespace Breeze
{
typedef QSharedPointer<InternalSettings> InternalSettingsPtr;
//_____________________________________________
class ConfigWidget: public QWidget
{
Q_OBJECT
public:
//* constructor
explicit ConfigWidget( QWidget* );
//* destructor
virtual ~ConfigWidget( void )
{}
//* set configuration
void setInternalSettings( InternalSettingsPtr );
//* load configuration
void load( void );
//* save configuration
void save( void );
//* true if changed
virtual bool isChanged( void ) const
{ return m_changed; }
Q_SIGNALS:
//* emmited when changed
void changed( bool );
protected Q_SLOTS:
//* update changed state
virtual void updateChanged();
protected:
//* set changed state
virtual void setChanged( bool value )
{
m_changed = value;
emit changed( value );
}
private:
//* ui
Ui_BreezeConfigurationUI m_ui;
//* internal exception
InternalSettingsPtr m_internalSettings;
//* changed state
bool m_changed;
};
}
#endif

@ -0,0 +1,3 @@
{
"X-KDE-PluginInfo-Name": "org.kde.breeze"
}

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BreezeConfigurationUI</class>
<widget class="QWidget" name="BreezeConfigurationUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>433</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QComboBox" name="buttonSize">
<item>
<property name="text">
<string comment="@item:inlistbox Button size:">Very Small</string>
</property>
</item>
<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>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" 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="4" column="1">
<widget class="QSpinBox" name="animationsDuration">
<property name="suffix">
<string>ms</string>
</property>
<property name="maximum">
<number>500</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<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="4" column="0">
<widget class="QLabel" name="animationsDurationLabel">
<property name="text">
<string>&amp;Animations duration:</string>
</property>
<property name="buddy">
<cstring>animationsDuration</cstring>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>187</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<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="5" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>418</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save