-rw-r--r-- | noncore/styles/theme/themeset.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/styles/theme/themeset.cpp b/noncore/styles/theme/themeset.cpp index 4a4efcb..d4005bc 100644 --- a/noncore/styles/theme/themeset.cpp +++ b/noncore/styles/theme/themeset.cpp | |||
@@ -1,123 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | #include "themeset.h" | 23 | #include "themeset.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | 27 | ||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlistview.h> | 30 | #include <qlistview.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | 32 | ||
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | 34 | ||
35 | 35 | ||
36 | class MyConfig : public Config | 36 | class MyConfig : public Config |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | MyConfig ( const QString &f, Domain d ) : Config ( f, d ) | 39 | MyConfig ( const QString &f, Domain d ) : Config ( f, d ) |
40 | { } | 40 | { } |
41 | 41 | ||
42 | bool hasGroup ( const QString &gname ) const | 42 | bool hasGroup ( const QString &gname ) const |
43 | { | 43 | { |
44 | QMap< QString, ConfigGroup>::ConstIterator it = groups. find ( gname ); | 44 | QMap< QString, ConfigGroup>::ConstIterator it = groups. find ( gname ); |
45 | return ( it != groups.end() ); | 45 | return ( it != groups.end() ); |
46 | } | 46 | } |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class MyItem : public QListViewItem | 49 | class MyItem : public QListViewItem |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | MyItem ( QListView *lv, const QString &name, const QString &comm, const QString &theme ) : QListViewItem ( lv, name, comm ) | 52 | MyItem ( QListView *lv, QListViewItem *after, const QString &name, const QString &comm, const QString &theme ) : QListViewItem ( lv, after, name, comm ) |
53 | { | 53 | { |
54 | m_theme = theme; | 54 | m_theme = theme; |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | QString m_theme; | 58 | QString m_theme; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl ) | 62 | ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl ) |
63 | : QWidget ( parent, name, fl ) | 63 | : QWidget ( parent, name, fl ) |
64 | { | 64 | { |
65 | setCaption ( tr( "Theme Style" ) ); | 65 | setCaption ( tr( "Theme Style" ) ); |
66 | 66 | ||
67 | Config config ( "qpe" ); | 67 | Config config ( "qpe" ); |
68 | config. setGroup ( "Appearance" ); | 68 | config. setGroup ( "Appearance" ); |
69 | 69 | ||
70 | QString active = config. readEntry ( "Theme", "default" ); | 70 | QString active = config. readEntry ( "Theme", "default" ); |
71 | 71 | ||
72 | QVBoxLayout *vbox = new QVBoxLayout ( this ); | 72 | QVBoxLayout *vbox = new QVBoxLayout ( this ); |
73 | vbox-> setSpacing ( 3 ); | 73 | vbox-> setSpacing ( 3 ); |
74 | vbox-> setMargin ( 6 ); | 74 | vbox-> setMargin ( 6 ); |
75 | 75 | ||
76 | vbox-> addWidget ( new QLabel ( tr( "Select the theme to be used" ), this )); | 76 | vbox-> addWidget ( new QLabel ( tr( "Select the theme to be used" ), this )); |
77 | 77 | ||
78 | m_list = new QListView ( this ); | 78 | m_list = new QListView ( this ); |
79 | m_list-> addColumn ( tr( "Name" )); | 79 | m_list-> addColumn ( tr( "Name" )); |
80 | m_list-> addColumn ( tr( "Description" )); | 80 | m_list-> addColumn ( tr( "Description" )); |
81 | m_list-> setSelectionMode ( QListView::Single ); | 81 | m_list-> setSelectionMode ( QListView::Single ); |
82 | m_list-> setAllColumnsShowFocus ( true ); | 82 | m_list-> setAllColumnsShowFocus ( true ); |
83 | m_list-> setSorting ( -1 ); | ||
83 | vbox-> addWidget ( m_list, 10 ); | 84 | vbox-> addWidget ( m_list, 10 ); |
84 | 85 | ||
85 | QListViewItem *item = new MyItem ( m_list, tr( "[No theme]" ), "", "" ); | 86 | QListViewItem *item = new MyItem ( m_list, 0, tr( "[No theme]" ), "", "" ); |
86 | m_list-> setSelected ( item, true ); | 87 | m_list-> setSelected ( item, true ); |
87 | 88 | ||
88 | QString path = QPEApplication::qpeDir() + "/plugins/styles/themes"; | 89 | QString path = QPEApplication::qpeDir() + "/plugins/styles/themes"; |
89 | QStringList list = QDir ( path, "*.themerc" ). entryList ( ); | 90 | QStringList list = QDir ( path, "*.themerc" ). entryList ( ); |
90 | 91 | ||
91 | for ( QStringList::Iterator it = list. begin(); it != list. end ( ); ++it ) { | 92 | for ( QStringList::Iterator it = list. begin(); it != list. end ( ); ++it ) { |
92 | MyConfig cfg ( path + "/" + *it, Config::File ); | 93 | MyConfig cfg ( path + "/" + *it, Config::File ); |
93 | 94 | ||
94 | if ( cfg. hasGroup ( "Misc" )) { | 95 | if ( cfg. hasGroup ( "Misc" )) { |
95 | cfg. setGroup ( "Misc" ); | 96 | cfg. setGroup ( "Misc" ); |
96 | 97 | ||
97 | QString name = cfg. readEntry ( "Name" ); | 98 | QString name = cfg. readEntry ( "Name" ); |
98 | QString comm = cfg. readEntry ( "Comment" ); | 99 | QString comm = cfg. readEntry ( "Comment" ); |
99 | 100 | ||
100 | if ( !name. isEmpty ( )) { | 101 | if ( !name. isEmpty ( )) { |
101 | QString fname = (*it). left ((*it). length ( ) - 8 ); | 102 | QString fname = (*it). left ((*it). length ( ) - 8 ); |
102 | 103 | ||
103 | item = new MyItem ( m_list, name, comm, fname ); | 104 | item = new MyItem ( m_list, item, name, comm, fname ); |
104 | if ( active == fname ) { | 105 | if ( active == fname ) { |
105 | m_list-> setSelected ( item, true ); | 106 | m_list-> setSelected ( item, true ); |
106 | } | 107 | } |
107 | } | 108 | } |
108 | } | 109 | } |
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | bool ThemeSettings::writeConfig ( ) | 113 | bool ThemeSettings::writeConfig ( ) |
113 | { | 114 | { |
114 | Config config ( "qpe" ); | 115 | Config config ( "qpe" ); |
115 | config. setGroup ( "Appearance" ); | 116 | config. setGroup ( "Appearance" ); |
116 | 117 | ||
117 | MyItem *it = (MyItem *) m_list-> selectedItem ( ); | 118 | MyItem *it = (MyItem *) m_list-> selectedItem ( ); |
118 | config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); | 119 | config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); |
119 | config. write ( ); | 120 | config. write ( ); |
120 | 121 | ||
121 | return true; | 122 | return true; |
122 | } | 123 | } |
123 | 124 | ||