From 769df90a59d6aa840b8d6568287001e66e263f01 Mon Sep 17 00:00:00 2001 From: sandman Date: Sat, 29 Jun 2002 23:45:19 +0000 Subject: *** empty log message *** --- (limited to 'noncore/styles/theme/settings/themeset.cpp') 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 +#include + +#include +#include +#include +#include + +#include + + +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 ( ); +} + -- cgit v0.9.0.2