From 3a422983abc7342c9229dccac825d0608fca10f3 Mon Sep 17 00:00:00 2001 From: sandman Date: Sat, 06 Jul 2002 16:42:29 +0000 Subject: Complete renovation of the external style API: - created two QCom interfaces in "styleinterface.h" - moved the liquid/theme settings apps into the plugins - modified the plugin interface for all three styles - extended appearance to fully support the new API (replaces the settings apps) Additional work: - made a workaround in appearance for a Qt Bug -- now a QDialog again (this should really be fixed in Qt, but Z won't work that way) --- (limited to 'noncore/styles/theme') diff --git a/noncore/styles/theme/opie-theme.control b/noncore/styles/theme/opie-theme.control index 02739fb..adb4f4b 100644 --- a/noncore/styles/theme/opie-theme.control +++ b/noncore/styles/theme/opie-theme.control @@ -1,4 +1,4 @@ -Files: plugins/styles/libtheme.so* bin/theme-settings apps/Settings/Theme.desktop pics/theme/Theme.png +Files: plugins/styles/libtheme.so* Priority: optional Section: opie/system Maintainer: Robert Griebl diff --git a/noncore/styles/theme/plugin.cpp b/noncore/styles/theme/plugin.cpp index b334357..4383693 100644 --- a/noncore/styles/theme/plugin.cpp +++ b/noncore/styles/theme/plugin.cpp @@ -1,19 +1,111 @@ -//#include #include "othemestyle.h" +#include "themeset.h" +#include "plugin.h" -extern "C" + + +ThemeInterface::ThemeInterface ( ) : ref ( 0 ) { - QStyle * allocate() { - return new OThemeStyle ( "" ); - } - int minor_version() { - return 0; - } - int major_version() { - return 1; - } - const char * description() { - return ( "Theme Style" ); +} + +ThemeInterface::~ThemeInterface ( ) +{ +} + +QStyle *ThemeInterface::create ( ) +{ + return new OThemeStyle ( "" ); +} + +QString ThemeInterface::name ( ) +{ + return QObject::tr( "Themed style", "name" ); +} + +QString ThemeInterface::description ( ) +{ + return QObject::tr( "KDE2 theme compatible style engine", "description" ); +} + +QCString ThemeInterface::key ( ) +{ + return QCString ( "theme" ); +} + +unsigned int ThemeInterface::version ( ) +{ + return 100; // 1.0.0 (\d+.\d.\d) +} + +QRESULT ThemeInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) +{ + static ThemeSettingsInterface *setiface = 0; + + *iface = 0; + + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_Style ) + *iface = this; + else if ( uuid == IID_StyleSettings ) { + if ( !setiface ) + setiface = new ThemeSettingsInterface ( ); + *iface = setiface; } + + if ( *iface ) + (*iface)-> addRef ( ); + + return QS_OK; +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( ThemeInterface ) +} + + +ThemeSettingsInterface::ThemeSettingsInterface ( ) : ref ( 0 ) +{ + m_widget = 0; +} + +ThemeSettingsInterface::~ThemeSettingsInterface ( ) +{ +} + +QWidget *ThemeSettingsInterface::create ( QWidget *parent, const char *name ) +{ + m_widget = new ThemeSettings ( parent, name ? name : "THEME-SETTINGS" ); + + return m_widget; +} + +bool ThemeSettingsInterface::accept ( ) +{ + if ( !m_widget ) + return false; + + return m_widget-> writeConfig ( ); +} + +void ThemeSettingsInterface::reject ( ) +{ +} + +QRESULT ThemeSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) +{ + *iface = 0; + + + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_StyleSettings ) + *iface = this; + + if ( *iface ) + (*iface)-> addRef ( ); + + return QS_OK; } diff --git a/noncore/styles/theme/plugin.h b/noncore/styles/theme/plugin.h new file mode 100644 index 0000000..d13fc5d --- a/dev/null +++ b/noncore/styles/theme/plugin.h @@ -0,0 +1,46 @@ +#ifndef __OPIE_THEME_PLUGIN_H__ +#define __OPIE_THEME_PLUGIN_H__ + +#include + +class ThemeSettings; + +class ThemeInterface : public StyleInterface { +public: + ThemeInterface ( ); + virtual ~ThemeInterface ( ); + + QRESULT queryInterface ( const QUuid &, QUnknownInterface ** ); + Q_REFCOUNT + + virtual QStyle *create ( ); + + virtual QString description ( ); + virtual QString name ( ); + virtual QCString key ( ); + + virtual unsigned int version ( ); + +private: + ulong ref; +}; + +class ThemeSettingsInterface : public StyleSettingsInterface { +public: + ThemeSettingsInterface ( ); + virtual ~ThemeSettingsInterface ( ); + + QRESULT queryInterface ( const QUuid &, QUnknownInterface ** ); + Q_REFCOUNT + + virtual QWidget *create ( QWidget *parent, const char *name = 0 ); + + virtual bool accept ( ); + virtual void reject ( ); + +private: + ThemeSettings *m_widget; + ulong ref; +}; + +#endif diff --git a/noncore/styles/theme/settings/main.cpp b/noncore/styles/theme/settings/main.cpp deleted file mode 100644 index 94d40f3..0000000 --- a/noncore/styles/theme/settings/main.cpp +++ b/dev/null @@ -1,34 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "themeset.h" - -#include - - -int main ( int argc, char** argv ) -{ - QPEApplication a ( argc, argv ); - - ThemeSet dlg; - a. showMainWidget ( &dlg ); - - return a. exec ( ); -} diff --git a/noncore/styles/theme/settings/settings.pro b/noncore/styles/theme/settings/settings.pro deleted file mode 100644 index 85d1f7a..0000000 --- a/noncore/styles/theme/settings/settings.pro +++ b/dev/null @@ -1,24 +0,0 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin -HEADERS = themeset.h -SOURCES = themeset.cpp main.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += ../$(OPIEDIR)/include -LIBS += -lqpe -TARGET = theme-settings - -TRANSLATIONS = ../../../../i18n/de/theme-settings.ts \ - ../../../../i18n/en/theme-settings.ts \ - ../../../../i18n/es/theme-settings.ts \ - ../../../../i18n/fr/theme-settings.ts \ - ../../../../i18n/hu/theme-settings.ts \ - ../../../../i18n/ja/theme-settings.ts \ - ../../../../i18n/ko/theme-settings.ts \ - ../../../../i18n/no/theme-settings.ts \ - ../../../../i18n/pl/theme-settings.ts \ - ../../../../i18n/pt/theme-settings.ts \ - ../../../../i18n/pt_BR/theme-settings.ts \ - ../../../../i18n/sl/theme-settings.ts \ - ../../../../i18n/zh_CN/theme-settings.ts \ - ../../../../i18n/zh_TW/theme-settings.ts diff --git a/noncore/styles/theme/settings/themeset.h b/noncore/styles/theme/settings/themeset.h deleted file mode 100644 index 24804ce..0000000 --- a/noncore/styles/theme/settings/themeset.h +++ b/dev/null @@ -1,20 +0,0 @@ -#ifndef __OPIE_THEME_SET_H__ -#define __OPIE_THEME_SET_H__ - -#include - -class QListView; - -class ThemeSet : public QDialog { - Q_OBJECT - -public: - ThemeSet ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); - -protected: - virtual void accept ( ); - -private: - QListView *m_list; -}; -#endif diff --git a/noncore/styles/theme/theme.pro b/noncore/styles/theme/theme.pro index fdcd20e..49c4103 100644 --- a/noncore/styles/theme/theme.pro +++ b/noncore/styles/theme/theme.pro @@ -3,11 +3,14 @@ CONFIG = qt embedded debug warn_on SOURCES = ogfxeffect.cpp \ othemestyle.cpp \ othemebase.cpp \ + themeset.cpp \ plugin.cpp HEADERS = ogfxeffect.h \ othemebase.h \ - othemestyle.h + othemestyle.h \ + themeset.h \ + plugin.h LIBS += -lqpe diff --git a/noncore/styles/theme/settings/themeset.cpp b/noncore/styles/theme/themeset.cpp index 046618e..4a4efcb 100644 --- a/noncore/styles/theme/settings/themeset.cpp +++ b/noncore/styles/theme/themeset.cpp @@ -59,8 +59,8 @@ public: }; -ThemeSet::ThemeSet ( QWidget* parent, const char *name, WFlags fl ) - : QDialog ( parent, name, fl ) +ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl ) + : QWidget ( parent, name, fl ) { setCaption ( tr( "Theme Style" ) ); @@ -109,16 +109,15 @@ ThemeSet::ThemeSet ( QWidget* parent, const char *name, WFlags fl ) } } -void ThemeSet::accept ( ) +bool ThemeSettings::writeConfig ( ) { Config config ( "qpe" ); config. setGroup ( "Appearance" ); MyItem *it = (MyItem *) m_list-> selectedItem ( ); config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); + config. write ( ); - Global::applyStyle ( ); - - QDialog::accept ( ); + return true; } diff --git a/noncore/styles/theme/themeset.h b/noncore/styles/theme/themeset.h new file mode 100644 index 0000000..c337cfa --- a/dev/null +++ b/noncore/styles/theme/themeset.h @@ -0,0 +1,20 @@ +#ifndef __OPIE_THEME_SETTINGS_H__ +#define __OPIE_THEME_SETTINGS_H__ + +#include + +class QListView; + +class ThemeSettings : public QWidget { + Q_OBJECT + +public: + ThemeSettings ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); + +public: + virtual bool writeConfig ( ); + +private: + QListView *m_list; +}; +#endif -- cgit v0.9.0.2