Diffstat (limited to 'noncore/styles/theme/settings') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/theme/settings/main.cpp | 34 | ||||
-rw-r--r-- | noncore/styles/theme/settings/settings.pro | 24 | ||||
-rw-r--r-- | noncore/styles/theme/settings/themeset.cpp | 124 | ||||
-rw-r--r-- | noncore/styles/theme/settings/themeset.h | 20 |
4 files changed, 202 insertions, 0 deletions
diff --git a/noncore/styles/theme/settings/main.cpp b/noncore/styles/theme/settings/main.cpp new file mode 100644 index 0000000..94d40f3 --- a/dev/null +++ b/noncore/styles/theme/settings/main.cpp @@ -0,0 +1,34 @@ +/********************************************************************** +** 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 <qpe/qpeapplication.h> + + +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 new file mode 100644 index 0000000..85d1f7a --- a/dev/null +++ b/noncore/styles/theme/settings/settings.pro @@ -0,0 +1,24 @@ +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.cpp b/noncore/styles/theme/settings/themeset.cpp new file mode 100644 index 0000000..046618e --- a/dev/null +++ b/noncore/styles/theme/settings/themeset.cpp @@ -0,0 +1,124 @@ +/********************************************************************** +** 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 <qpe/qpeapplication.h> +#include <qpe/global.h> + +#include <qlabel.h> +#include <qlayout.h> +#include <qlistview.h> +#include <qdir.h> + +#include <qpe/config.h> + + +class MyConfig : public Config +{ +public: + MyConfig ( const QString &f, Domain d ) : Config ( f, d ) + { } + + bool hasGroup ( const QString &gname ) const + { + QMap< QString, ConfigGroup>::ConstIterator it = groups. find ( gname ); + return ( it != groups.end() ); + } +}; + +class MyItem : public QListViewItem +{ +public: + MyItem ( QListView *lv, const QString &name, const QString &comm, const QString &theme ) : QListViewItem ( lv, name, comm ) + { + m_theme = theme; + } + + + QString m_theme; +}; + + +ThemeSet::ThemeSet ( QWidget* parent, const char *name, WFlags fl ) + : QDialog ( parent, name, fl ) +{ + setCaption ( tr( "Theme Style" ) ); + + Config config ( "qpe" ); + config. setGroup ( "Appearance" ); + + QString active = config. readEntry ( "Theme", "default" ); + + QVBoxLayout *vbox = new QVBoxLayout ( this ); + vbox-> setSpacing ( 3 ); + vbox-> setMargin ( 6 ); + + vbox-> addWidget ( new QLabel ( tr( "Select the theme to be used" ), this )); + + m_list = new QListView ( this ); + m_list-> addColumn ( tr( "Name" )); + m_list-> addColumn ( tr( "Description" )); + m_list-> setSelectionMode ( QListView::Single ); + m_list-> setAllColumnsShowFocus ( true ); + vbox-> addWidget ( m_list, 10 ); + + QListViewItem *item = new MyItem ( m_list, tr( "[No theme]" ), "", "" ); + m_list-> setSelected ( item, true ); + + QString path = QPEApplication::qpeDir() + "/plugins/styles/themes"; + QStringList list = QDir ( path, "*.themerc" ). entryList ( ); + + for ( QStringList::Iterator it = list. begin(); it != list. end ( ); ++it ) { + MyConfig cfg ( path + "/" + *it, Config::File ); + + if ( cfg. hasGroup ( "Misc" )) { + cfg. setGroup ( "Misc" ); + + QString name = cfg. readEntry ( "Name" ); + QString comm = cfg. readEntry ( "Comment" ); + + if ( !name. isEmpty ( )) { + QString fname = (*it). left ((*it). length ( ) - 8 ); + + item = new MyItem ( m_list, name, comm, fname ); + if ( active == fname ) { + m_list-> setSelected ( item, true ); + } + } + } + } +} + +void ThemeSet::accept ( ) +{ + Config config ( "qpe" ); + config. setGroup ( "Appearance" ); + + MyItem *it = (MyItem *) m_list-> selectedItem ( ); + config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); + + Global::applyStyle ( ); + + QDialog::accept ( ); +} + diff --git a/noncore/styles/theme/settings/themeset.h b/noncore/styles/theme/settings/themeset.h new file mode 100644 index 0000000..24804ce --- a/dev/null +++ b/noncore/styles/theme/settings/themeset.h @@ -0,0 +1,20 @@ +#ifndef __OPIE_THEME_SET_H__ +#define __OPIE_THEME_SET_H__ + +#include <qdialog.h> + +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 |