added breeze-settings5 standalone configuration app

wilder-pre-rebase
Hugo Pereira Da Costa 11 years ago
parent e5e447e7f5
commit ca6bf0b9e2
  1. 22
      kstyle/config/CMakeLists.txt
  2. 285
      kstyle/config/breezeconfigdialog.cpp
  3. 99
      kstyle/config/breezeconfigdialog.h
  4. 60
      kstyle/config/main.cpp
  5. 79
      kstyle/config/ui/breezeconfigdialog.ui

@ -28,3 +28,25 @@ else()
endif()
########### next target ###############
if(KF5Service_FOUND AND NOT BREEZE_USE_KDE4)
set(breeze_settings_SOURCES
breezeconfigdialog.cpp
main.cpp)
set(breeze_settings_FORMS ui/breezeconfigdialog.ui)
ki18n_wrap_ui(breeze_settings_FORMS_HEADERS ${breeze_settings_FORMS})
add_executable(breeze-settings5
${breeze_settings_SOURCES}
${breeze_settings_FORMS_HEADERS}
)
target_link_libraries(breeze-settings5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::DBus)
target_link_libraries(breeze-settings5 KF5::I18n KF5::WidgetsAddons KF5::ConfigCore KF5::ConfigGui KF5::Service)
install(TARGETS breeze-settings5 ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()

@ -0,0 +1,285 @@
//////////////////////////////////////////////////////////////////////////////
// breezeconfigdialog.cpp
// breeze configuration 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 "breezeconfigdialog.h"
#include "breezeconfigdialog.moc"
#include "../breeze.h"
#include "../config-breeze.h"
#include <QIcon>
#include <QLabel>
#include <QLayout>
#include <QLibrary>
#include <QPushButton>
#include <QShortcut>
#include <QTextStream>
#if BREEZE_USE_KDE4
#include <KIcon>
#include <KLibrary>
#endif
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginLoader>
#include <KStandardShortcut>
#include <QDBusConnection>
#include <QDBusMessage>
namespace Breeze
{
//_______________________________________________________________
ConfigDialog::ConfigDialog( QWidget* parent ):
QDialog( parent ),
_stylePluginObject(0),
_decorationPluginObject( 0 ),
_styleChanged( false ),
_decorationChanged( false )
{
setWindowTitle( i18n( "Breeze Settings" ) );
updateWindowTitle();
// ui
setupUi(this);
#if BREEZE_USE_KDE4
// install Quit shortcut
connect( new QShortcut( KStandardShortcut::quit().primary(), this ), SIGNAL(activated()), SLOT(close()) );
connect( new QShortcut( KStandardShortcut::quit().alternate(), this ), SIGNAL(activated()), SLOT(close()) );
#else
foreach( const QKeySequence& sequence, KStandardShortcut::quit() )
{ connect( new QShortcut( sequence, this ), SIGNAL(activated()), SLOT(close()) ); }
#endif
connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL(clicked()), SLOT(close()) );
// connections
connect( pageWidget, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), SLOT(updateWindowTitle(KPageWidgetItem*)) );
// generic page
KPageWidgetItem *page;
// style
page = loadStyleConfig();
page->setName( i18n("Widget Style") );
page->setHeader( i18n("Modify the appearance of widgets") );
#if BREEZE_USE_KDE4
page->setIcon( KIcon( "preferences-desktop-theme" ) );
#else
page->setIcon( QIcon::fromTheme( QStringLiteral( "preferences-desktop-theme" ) ) );
#endif
pageWidget->addPage( page );
if( _stylePluginObject )
{
connect( _stylePluginObject, SIGNAL(changed(bool)), this, SLOT(updateStyleChanged(bool)) );
connect( _stylePluginObject, SIGNAL(changed(bool)), this, SLOT(updateChanged()) );
connect( buttonBox->button( QDialogButtonBox::Reset ), SIGNAL(clicked()), _stylePluginObject, SLOT(reset()) );
connect( buttonBox->button( QDialogButtonBox::RestoreDefaults ), SIGNAL(clicked()), _stylePluginObject, SLOT(defaults()) );
connect( this, SIGNAL(pluginSave()), _stylePluginObject, SLOT(save()) );
}
// decoration
page = loadDecorationConfig();
page->setName( i18n("Window Decorations") );
page->setHeader( i18n("Modify the appearance of window decorations") );
#if BREEZE_USE_KDE4
page->setIcon( KIcon( "preferences-system-windows" ) );
#else
page->setIcon( QIcon::fromTheme( QStringLiteral( "preferences-system-windows" ) ) );
#endif
pageWidget->addPage( page );
if( _decorationPluginObject )
{
connect( _decorationPluginObject, SIGNAL(changed(bool)), this, SLOT(updateDecorationChanged(bool)) );
connect( _decorationPluginObject, SIGNAL(changed(bool)), this, SLOT(updateChanged()) );
connect( buttonBox->button( QDialogButtonBox::Reset ), SIGNAL(clicked()), _decorationPluginObject, SLOT(load()) );
connect( buttonBox->button( QDialogButtonBox::RestoreDefaults ), SIGNAL(clicked()), _decorationPluginObject, SLOT(defaults()) );
connect( this, SIGNAL(pluginSave()), _decorationPluginObject, SLOT(save()) );
}
// button connections
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL(clicked()), SLOT(save()) );
connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL(clicked()), SLOT(save()) );
updateChanged();
}
//_______________________________________________________________
void ConfigDialog::save( void )
{
// trigger pluggins to save themselves
emit pluginSave();
/*
* emit dbus message to kwin instances
* this is copied from kwin/kcmkwin/kwindecoration/kwindecoration.cpp
*/
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
QDBusConnection::sessionBus().send(message);
// reset 'changed' flags
updateStyleChanged( false );
updateDecorationChanged( false );
updateChanged();
}
//_______________________________________________________________
void ConfigDialog::updateChanged( void )
{
bool modified( changed() );
buttonBox->button( QDialogButtonBox::Apply )->setEnabled( modified );
buttonBox->button( QDialogButtonBox::Reset )->setEnabled( modified );
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( modified );
updateWindowTitle( pageWidget->currentPage() );
}
//_______________________________________________________________
void ConfigDialog::updateWindowTitle( KPageWidgetItem* item )
{
QString title;
QTextStream what( &title );
if( item )
{
what << item->name();
if( changed() ) what << " [modified]";
what << " - ";
}
what << i18n( "Breeze Settings" );
setWindowTitle( title );
}
//_______________________________________________________________
KPageWidgetItem* ConfigDialog::loadStyleConfig( void )
{
// load style from plugin
#if BREEZE_USE_KDE4
KLibrary library( "kstyle_breeze_config" );
#else
QLibrary library( KPluginLoader::findPlugin( QStringLiteral( "kstyle_breeze_config" ) ) );
#endif
if( library.load() )
{
#if BREEZE_USE_KDE4
KLibrary::void_function_ptr alloc_ptr = library.resolveFunction("allocate_kstyle_config");
#else
QFunctionPointer alloc_ptr = library.resolve( "allocate_kstyle_config" );
#endif
if( alloc_ptr != nullptr )
{
// pointer to decoration plugin allocation function
QWidget* (*allocator)( QWidget* );
allocator = (QWidget* (*)(QWidget* parent))alloc_ptr;
// create container
QWidget* container = new QWidget();
container->setLayout( new QVBoxLayout() );
container->setObjectName( QStringLiteral( "breeze-settings-container" ) );
container->layout()->setMargin( 0 );
// allocate config object
_stylePluginObject = (QObject*)(allocator( container ));
container->layout()->addWidget( static_cast<QWidget*>( _stylePluginObject ) );
return new KPageWidgetItem( container );
}
}
// fall back to warning label
QLabel* label = new QLabel();
label->setMargin(5);
label->setAlignment( Qt::AlignCenter );
label->setText( i18n( "Unable to find breeze style configuration plugin" ) );
return new KPageWidgetItem( label );
}
//_______________________________________________________________
KPageWidgetItem* ConfigDialog::loadDecorationConfig( void )
{
// load style from plugin
#if BREEZE_USE_KDE4
KLibrary library( "kwin_breeze_config" );
#else
// QLibrary library( KPluginLoader::findPlugin( QStringLiteral( "kwin/kdecorations/config/kwin_breeze_config" ) ) );
QLibrary library( KPluginLoader::findPlugin( QStringLiteral( "org.kde.kdecoration2/breezedecoration_config.so" ) ) );
#endif
if( library.load() )
{
#if BREEZE_USE_KDE4
KLibrary::void_function_ptr alloc_ptr = library.resolveFunction("allocate_config");
#else
QFunctionPointer alloc_ptr = library.resolve( "allocate_config" );
#endif
if( alloc_ptr != nullptr )
{
// cast resolved function
QObject* (*allocator)( KConfig*, QWidget* );
allocator = ( QObject* (*)(KConfig*, QWidget*) )alloc_ptr;
// create container
QWidget* container = new QWidget();
container->setLayout( new QVBoxLayout() );
container->layout()->setMargin( 0 );
_decorationPluginObject = (QObject*)(allocator( nullptr, container ));
if( _decorationPluginObject ) return new KPageWidgetItem( container );
} else { QTextStream( stdout ) << "unable to resolve function allocate_config" << endl; }
} else { QTextStream( stdout ) << "unable to load plugin kwin_breeze_config" << endl; }
// fall back to warning label
QLabel* label = new QLabel();
label->setMargin(5);
label->setAlignment( Qt::AlignCenter );
label->setText( i18n( "Unable to find breeze decoration configuration plugin" ) );
return new KPageWidgetItem( label );
}
}

@ -0,0 +1,99 @@
#ifndef breezeconfigdialog_h
#define breezeconfigdialog_h
//////////////////////////////////////////////////////////////////////////////
// breezeconfigdialog.h
// breeze configuration 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_breezeconfigdialog.h"
namespace Breeze
{
class ConfigDialog: public QDialog, Ui::BreezeConfigDialog
{
Q_OBJECT
public:
//! constructor
explicit ConfigDialog( QWidget* parent = 0 );
//! destructor
virtual ~ConfigDialog( void )
{}
Q_SIGNALS:
//! save local changes
void pluginSave( void );
public Q_SLOTS:
//! save local changes
virtual void save( void );
protected Q_SLOTS:
// update decoration changed state
void updateStyleChanged( bool state = true )
{ _styleChanged = state; }
// update decoration changed state
void updateDecorationChanged( bool state = true )
{ _decorationChanged = state; }
// handle configuration modifications
virtual void updateChanged( void );
// update window title based on selected page
virtual void updateWindowTitle( KPageWidgetItem* = 0 );
private:
//! true if configuration changed
bool changed( void ) const
{ return _styleChanged || _decorationChanged; }
//! load style config widget from plugin
KPageWidgetItem* loadStyleConfig( void );
//! load decoration config widget from plugin
KPageWidgetItem* loadDecorationConfig( void );
//! style plugin widget
QObject *_stylePluginObject;
//! decoration plugin widget
QObject *_decorationPluginObject;
bool _styleChanged;
bool _decorationChanged;
};
}
#endif

@ -0,0 +1,60 @@
//////////////////////////////////////////////////////////////////////////////
// breezeanimationconfigitem.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 "breezeconfigdialog.h"
#include "../breeze.h"
#include "../config-breeze.h"
#include <QApplication>
#include <QIcon>
#include <KLocalizedString>
namespace Breeze
{
int run(int argc, char *argv[])
{
QApplication app( argc, argv );
app.setApplicationName( i18n( "Breeze Settings" ) );
app.setWindowIcon( QIcon::fromTheme( QStringLiteral( "breeze" ) ) );
Breeze::ConfigDialog dialog;
dialog.show();
bool result = app.exec();
return result;
}
}
//__________________________________________
int main(int argc, char *argv[])
{
#if !BREEZE_USE_KDE4
KLocalizedString::setApplicationDomain("breeze_style_config");
#endif
return Breeze::run( argc, argv );
}

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BreezeConfigDialog</class>
<widget class="QDialog" name="BreezeConfigDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>447</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KPageWidget" name="pageWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPageView</class>
<extends>QWidget</extends>
<header>kpageview.h</header>
</customwidget>
<customwidget>
<class>KPageWidget</class>
<extends>KPageView</extends>
<header>kpagewidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>BreezeConfigDialog</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>BreezeConfigDialog</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>
Loading…
Cancel
Save