author | sandman <sandman> | 2002-09-23 22:41:28 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-23 22:41:28 (UTC) |
commit | 44e815d58c7565eccab2bd585923e343b70ac0f3 (patch) (unidiff) | |
tree | 3f8529224432f46f7a2a1f1fd0a15778d43d6e3e | |
parent | 074769a4adb816153e47d63087e9e326bd3a04bf (diff) | |
download | opie-44e815d58c7565eccab2bd585923e343b70ac0f3.zip opie-44e815d58c7565eccab2bd585923e343b70ac0f3.tar.gz opie-44e815d58c7565eccab2bd585923e343b70ac0f3.tar.bz2 |
- minor bugfixes
- fileselector is now in libopie as OFileSelector
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 174 | ||||
-rw-r--r-- | noncore/settings/appearance2/appearance.h | 17 |
2 files changed, 30 insertions, 161 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index cf3069e..23630c5 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -1,708 +1,584 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> |
22 | ** | 22 | ** |
23 | **********************************************************************/ | 23 | **********************************************************************/ |
24 | 24 | ||
25 | #include "appearance.h" | 25 | #include "appearance.h" |
26 | #include "editScheme.h" | 26 | #include "editScheme.h" |
27 | 27 | ||
28 | #include <opie/ofiledialog.h> | 28 | #include <opie/ofiledialog.h> |
29 | #include <opie/otabwidget.h> | 29 | #include <opie/otabwidget.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 36 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qdialog.h> | 44 | #include <qdialog.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qlistbox.h> | 49 | #include <qlistbox.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qmultilineedit.h> | 51 | #include <qmultilineedit.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | #include <qpushbutton.h> | 53 | #include <qpushbutton.h> |
54 | #include <qradiobutton.h> | 54 | #include <qradiobutton.h> |
55 | #if QT_VERSION >= 300 | 55 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 56 | #include <qstylefactory.h> |
57 | #else | 57 | #else |
58 | #include <qwindowsstyle.h> | 58 | #include <qwindowsstyle.h> |
59 | #include <qpe/qpestyle.h> | 59 | #include <qpe/qpestyle.h> |
60 | #include <qpe/lightstyle.h> | 60 | #include <qpe/lightstyle.h> |
61 | #include <qpe/qlibrary.h> | 61 | #include <qpe/qlibrary.h> |
62 | #include <qpe/styleinterface.h> | 62 | #include <qpe/styleinterface.h> |
63 | #endif | 63 | #endif |
64 | #include <qtabwidget.h> | 64 | #include <qtabwidget.h> |
65 | #include <qtoolbutton.h> | 65 | #include <qtoolbutton.h> |
66 | #include <qvgroupbox.h> | 66 | #include <qvgroupbox.h> |
67 | #include <qwidget.h> | 67 | #include <qwidget.h> |
68 | 68 | ||
69 | #include "stylelistitem.h" | 69 | #include "stylelistitem.h" |
70 | #include "decolistitem.h" | 70 | #include "decolistitem.h" |
71 | #include "fontlistitem.h" | ||
72 | #include "colorlistitem.h" | 71 | #include "colorlistitem.h" |
73 | 72 | ||
74 | #include "sample.h" | 73 | #include "sample.h" |
75 | 74 | ||
75 | #include <opie/ofontselector.h> | ||
76 | 76 | ||
77 | static int findItemCB ( QComboBox *box, const QString &str ) | ||
78 | { | ||
79 | for ( int i = 0; i < box-> count ( ); i++ ) { | ||
80 | if ( box-> text ( i ) == str ) | ||
81 | return i; | ||
82 | } | ||
83 | return -1; | ||
84 | } | ||
85 | 77 | ||
86 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
87 | { | 79 | { |
88 | public: | 80 | public: |
89 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
90 | QString name() const { | 82 | QString name() const { |
91 | return "Default"; | 83 | return "Default"; |
92 | } | 84 | } |
93 | QPixmap icon() const { | 85 | QPixmap icon() const { |
94 | return QPixmap(); | 86 | return QPixmap(); |
95 | } | 87 | } |
96 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 88 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
97 | *iface = 0; | 89 | *iface = 0; |
98 | if ( uuid == IID_QUnknown ) | 90 | if ( uuid == IID_QUnknown ) |
99 | *iface = this; | 91 | *iface = this; |
100 | else if ( uuid == IID_WindowDecoration ) | 92 | else if ( uuid == IID_WindowDecoration ) |
101 | *iface = this; | 93 | *iface = this; |
102 | 94 | ||
103 | if ( *iface ) | 95 | if ( *iface ) |
104 | (*iface)->addRef(); | 96 | (*iface)->addRef(); |
105 | return QS_OK; | 97 | return QS_OK; |
106 | } | 98 | } |
107 | Q_REFCOUNT | 99 | Q_REFCOUNT |
108 | 100 | ||
109 | private: | 101 | private: |
110 | ulong ref; | 102 | ulong ref; |
111 | }; | 103 | }; |
112 | 104 | ||
113 | 105 | ||
114 | 106 | ||
115 | void Appearance::loadStyles ( QListBox *list ) | 107 | void Appearance::loadStyles ( QListBox *list ) |
116 | { | 108 | { |
117 | #if QT_VERSION >= 300 | 109 | #if QT_VERSION >= 300 |
118 | list->insertStringList(QStyleFactory::styles()); | 110 | list->insertStringList(QStyleFactory::styles()); |
119 | #else | 111 | #else |
120 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 112 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
121 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); | 113 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); |
122 | #ifndef QT_NO_STYLE_MOTIF | 114 | #ifndef QT_NO_STYLE_MOTIF |
123 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); | 115 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); |
124 | #endif | 116 | #endif |
125 | #ifndef QT_NO_STYLE_MOTIFPLUS | 117 | #ifndef QT_NO_STYLE_MOTIFPLUS |
126 | list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); | 118 | list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); |
127 | #endif | 119 | #endif |
128 | #ifndef QT_NO_STYLE_PLATINUM | 120 | #ifndef QT_NO_STYLE_PLATINUM |
129 | list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); | 121 | list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); |
130 | #endif | 122 | #endif |
131 | #endif | 123 | #endif |
132 | list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); | 124 | list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); |
133 | 125 | ||
134 | #if QT_VERSION < 300 | 126 | #if QT_VERSION < 300 |
135 | { | 127 | { |
136 | QString path = QPEApplication::qpeDir() + "/plugins/styles/"; | 128 | QString path = QPEApplication::qpeDir() + "/plugins/styles/"; |
137 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 129 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
138 | 130 | ||
139 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 131 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
140 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 132 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
141 | StyleInterface *iface; | 133 | StyleInterface *iface; |
142 | 134 | ||
143 | if ( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) | 135 | if ( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) |
144 | list-> insertItem ( new StyleListItem ( lib, iface )); | 136 | list-> insertItem ( new StyleListItem ( lib, iface )); |
145 | else | 137 | else |
146 | delete lib; | 138 | delete lib; |
147 | } | 139 | } |
148 | } | 140 | } |
149 | 141 | ||
150 | #endif | 142 | #endif |
151 | } | 143 | } |
152 | 144 | ||
153 | void Appearance::loadDecos ( QListBox *list ) | 145 | void Appearance::loadDecos ( QListBox *list ) |
154 | { | 146 | { |
155 | list-> insertItem ( new DecoListItem ( tr( "Default" ))); | 147 | list-> insertItem ( new DecoListItem ( tr( "Default" ))); |
156 | 148 | ||
157 | { | 149 | { |
158 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 150 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; |
159 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 151 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
160 | 152 | ||
161 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 153 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
162 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 154 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
163 | WindowDecorationInterface *iface; | 155 | WindowDecorationInterface *iface; |
164 | 156 | ||
165 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 157 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
166 | list-> insertItem ( new DecoListItem ( lib, iface )); | 158 | list-> insertItem ( new DecoListItem ( lib, iface )); |
167 | else | 159 | else |
168 | delete lib; | 160 | delete lib; |
169 | } | 161 | } |
170 | } | 162 | } |
171 | } | 163 | } |
172 | 164 | ||
173 | void Appearance::loadColors ( QListBox *list ) | 165 | void Appearance::loadColors ( QListBox *list ) |
174 | { | 166 | { |
175 | list-> clear ( ); | 167 | list-> clear ( ); |
176 | { | 168 | { |
177 | Config config ( "qpe" ); | 169 | Config config ( "qpe" ); |
178 | config. setGroup ( "Appearance" ); | 170 | config. setGroup ( "Appearance" ); |
179 | 171 | ||
180 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); | 172 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); |
181 | } | 173 | } |
182 | 174 | ||
183 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | 175 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; |
184 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 176 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
185 | 177 | ||
186 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 178 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
187 | QString name = (*it). left ((*it). find ( ".scheme" )); | 179 | QString name = (*it). left ((*it). find ( ".scheme" )); |
188 | Config config ( path + *it, Config::File ); | 180 | Config config ( path + *it, Config::File ); |
189 | config. setGroup ( "Colors" ); | 181 | config. setGroup ( "Colors" ); |
190 | 182 | ||
191 | list-> insertItem ( new ColorListItem ( name, config )); | 183 | list-> insertItem ( new ColorListItem ( name, config )); |
192 | } | 184 | } |
193 | } | 185 | } |
194 | 186 | ||
195 | void Appearance::loadFonts ( QListBox *list ) | ||
196 | { | ||
197 | FontDatabase fd; | ||
198 | QStringList f = fd. families ( ); | ||
199 | |||
200 | for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) | ||
201 | list-> insertItem ( new FontListItem ( *it, fd. styles ( *it ), fd. pointSizes ( *it ))); | ||
202 | } | ||
203 | |||
204 | 187 | ||
205 | QWidget *Appearance::createStyleTab ( QWidget *parent ) | 188 | QWidget *Appearance::createStyleTab ( QWidget *parent ) |
206 | { | 189 | { |
207 | Config config ( "qpe" ); | 190 | Config config ( "qpe" ); |
208 | config. setGroup ( "Appearance" ); | 191 | config. setGroup ( "Appearance" ); |
209 | 192 | ||
210 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 193 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
211 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 194 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
212 | 195 | ||
213 | m_style_list = new QListBox( tab, "m_style_list" ); | 196 | m_style_list = new QListBox( tab, "m_style_list" ); |
214 | vertLayout->addWidget( m_style_list ); | 197 | vertLayout->addWidget( m_style_list ); |
215 | 198 | ||
216 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 199 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
217 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 200 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
218 | vertLayout-> addWidget ( m_style_settings ); | 201 | vertLayout-> addWidget ( m_style_settings ); |
219 | 202 | ||
220 | loadStyles ( m_style_list ); | 203 | loadStyles ( m_style_list ); |
221 | 204 | ||
222 | QString s = config. readEntry ( "Style", "Light" ); | 205 | QString s = config. readEntry ( "Style", "Light" ); |
223 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); | 206 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); |
224 | m_original_style = m_style_list-> currentItem ( ); | 207 | m_original_style = m_style_list-> currentItem ( ); |
225 | styleClicked ( m_original_style ); | 208 | styleClicked ( m_original_style ); |
226 | 209 | ||
227 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 210 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
228 | 211 | ||
229 | return tab; | 212 | return tab; |
230 | } | 213 | } |
231 | 214 | ||
232 | QWidget *Appearance::createDecoTab ( QWidget *parent ) | 215 | QWidget *Appearance::createDecoTab ( QWidget *parent ) |
233 | { | 216 | { |
234 | Config config ( "qpe" ); | 217 | Config config ( "qpe" ); |
235 | config. setGroup ( "Appearance" ); | 218 | config. setGroup ( "Appearance" ); |
236 | 219 | ||
237 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 220 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
238 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 221 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
239 | 222 | ||
240 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 223 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
241 | vertLayout->addWidget( m_deco_list ); | 224 | vertLayout->addWidget( m_deco_list ); |
242 | 225 | ||
243 | loadDecos ( m_deco_list ); | 226 | loadDecos ( m_deco_list ); |
244 | 227 | ||
245 | QString s = config. readEntry ( "Decoration" ); | 228 | QString s = config. readEntry ( "Decoration" ); |
246 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); | 229 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); |
247 | m_original_deco = m_deco_list-> currentItem ( ); | 230 | m_original_deco = m_deco_list-> currentItem ( ); |
248 | if ( m_deco_list-> currentItem ( ) < 0 ) | 231 | if ( m_deco_list-> currentItem ( ) < 0 ) |
249 | m_deco_list-> setCurrentItem ( 0 ); | 232 | m_deco_list-> setCurrentItem ( 0 ); |
250 | decoClicked ( m_original_deco ); | 233 | decoClicked ( m_original_deco ); |
251 | 234 | ||
252 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 235 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
253 | 236 | ||
254 | return tab; | 237 | return tab; |
255 | } | 238 | } |
256 | 239 | ||
257 | QWidget *Appearance::createFontTab ( QWidget *parent ) | 240 | QWidget *Appearance::createFontTab ( QWidget *parent ) |
258 | { | 241 | { |
259 | Config config ( "qpe" ); | 242 | Config config ( "qpe" ); |
260 | config. setGroup ( "Appearance" ); | 243 | config. setGroup ( "Appearance" ); |
261 | 244 | ||
262 | |||
263 | QWidget *tab = new QWidget( parent, "FontTab" ); | ||
264 | QGridLayout *gridLayout = new QGridLayout ( tab, 0, 0, 4, 4 ); | ||
265 | gridLayout->setRowStretch ( 4, 10 ); | ||
266 | |||
267 | m_font_family_list = new QListBox( tab, "FontListBox" ); | ||
268 | gridLayout->addMultiCellWidget( m_font_family_list, 0, 4, 0, 0 ); | ||
269 | connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); | ||
270 | |||
271 | QLabel *label = new QLabel( tr( "Style" ), tab ); | ||
272 | gridLayout->addWidget( label, 0, 1 ); | ||
273 | |||
274 | m_font_style_list = new QComboBox( tab, "StyleListBox" ); | ||
275 | connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); | ||
276 | gridLayout->addWidget( m_font_style_list, 1, 1 ); | ||
277 | |||
278 | label = new QLabel( tr( "Size" ), tab ); | ||
279 | gridLayout->addWidget( label, 2, 1 ); | ||
280 | |||
281 | m_font_size_list = new QComboBox( tab, "SizeListBox" ); | ||
282 | connect( m_font_size_list, SIGNAL( activated( int ) ), | ||
283 | this, SLOT( fontSizeClicked( int ) ) ); | ||
284 | gridLayout->addWidget( m_font_size_list, 3, 1 ); | ||
285 | |||
286 | loadFonts ( m_font_family_list ); | ||
287 | |||
288 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); | 245 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); |
289 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); | 246 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); |
290 | QString sizeStr = config.readEntry( "FontSize", "10" ); | 247 | int size = config.readNumEntry( "FontSize", 10 ); |
291 | 248 | ||
292 | m_font_family_list-> setCurrentItem ( m_font_family_list-> findItem ( familyStr )); | 249 | m_fontselect = new OFontSelector ( parent, "FontTab" ); |
293 | m_original_fontfamily = m_font_family_list-> currentItem ( ); | 250 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
294 | if ( m_font_family_list-> currentItem ( ) < 0 ) | ||
295 | m_font_family_list-> setCurrentItem ( 0 ); | ||
296 | 251 | ||
297 | fontFamilyClicked ( m_original_fontfamily ); | 252 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
253 | this, SLOT( fontClicked ( const QFont & ))); | ||
298 | 254 | ||
299 | m_font_style_list-> setCurrentItem ( findItemCB ( m_font_style_list, styleStr )); | 255 | return m_fontselect; |
300 | m_original_fontstyle = m_font_style_list-> currentItem ( ); | ||
301 | fontStyleClicked ( m_original_fontstyle ); | ||
302 | |||
303 | m_font_size_list-> setCurrentItem ( findItemCB ( m_font_size_list, sizeStr )); | ||
304 | m_original_fontsize = m_font_size_list-> currentItem ( ); | ||
305 | fontSizeClicked ( m_original_fontsize ); | ||
306 | |||
307 | return tab; | ||
308 | } | 256 | } |
309 | 257 | ||
310 | QWidget *Appearance::createColorTab ( QWidget *parent ) | 258 | QWidget *Appearance::createColorTab ( QWidget *parent ) |
311 | { | 259 | { |
312 | Config config ( "qpe" ); | 260 | Config config ( "qpe" ); |
313 | config. setGroup ( "Appearance" ); | 261 | config. setGroup ( "Appearance" ); |
314 | 262 | ||
315 | 263 | ||
316 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 264 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
317 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); | 265 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); |
318 | gridLayout->setRowStretch ( 3, 10 ); | 266 | gridLayout->setRowStretch ( 3, 10 ); |
319 | 267 | ||
320 | m_color_list = new QListBox ( tab ); | 268 | m_color_list = new QListBox ( tab ); |
321 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 269 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
322 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 270 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
323 | 271 | ||
324 | loadColors ( m_color_list ); | 272 | loadColors ( m_color_list ); |
325 | m_color_list-> setCurrentItem ( 0 ); | 273 | m_color_list-> setCurrentItem ( 0 ); |
326 | 274 | ||
327 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 275 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
328 | tempButton->setText( tr( "Edit..." ) ); | 276 | tempButton->setText( tr( "Edit..." ) ); |
329 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 277 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
330 | gridLayout->addWidget( tempButton, 0, 1 ); | 278 | gridLayout->addWidget( tempButton, 0, 1 ); |
331 | 279 | ||
332 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 280 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
333 | tempButton->setText( tr( "Delete" ) ); | 281 | tempButton->setText( tr( "Delete" ) ); |
334 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
335 | gridLayout->addWidget( tempButton, 1, 1 ); | 283 | gridLayout->addWidget( tempButton, 1, 1 ); |
336 | 284 | ||
337 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 285 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
338 | tempButton->setText( tr( "Save" ) ); | 286 | tempButton->setText( tr( "Save" ) ); |
339 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 287 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
340 | gridLayout->addWidget( tempButton, 2, 1 ); | 288 | gridLayout->addWidget( tempButton, 2, 1 ); |
341 | 289 | ||
342 | return tab; | 290 | return tab; |
343 | } | 291 | } |
344 | 292 | ||
345 | QWidget *Appearance::createGuiTab ( QWidget *parent ) | 293 | QWidget *Appearance::createGuiTab ( QWidget *parent ) |
346 | { | 294 | { |
347 | Config config ( "qpe" ); | 295 | Config config ( "qpe" ); |
348 | config. setGroup ( "Appearance" ); | 296 | config. setGroup ( "Appearance" ); |
349 | 297 | ||
350 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); | 298 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); |
351 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); | 299 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); |
352 | 300 | ||
353 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 301 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
354 | 302 | ||
355 | int style = config. readNumEntry ( "TabStyle", 2 ); | 303 | int style = config. readNumEntry ( "TabStyle", 2 ) - 1; |
304 | bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); | ||
356 | 305 | ||
357 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 306 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
358 | gridLayout-> addWidget ( label, 0, 0 ); | 307 | gridLayout-> addWidget ( label, 0, 0 ); |
359 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 308 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
360 | btngrp-> hide ( ); | 309 | btngrp-> hide ( ); |
361 | btngrp-> setExclusive ( true ); | 310 | btngrp-> setExclusive ( true ); |
362 | 311 | ||
363 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 312 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
364 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 313 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
365 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 314 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
366 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 315 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
367 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 316 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
368 | m_tabstyle_list-> setCurrentItem ( style & 0xff ); | 317 | m_tabstyle_list-> setCurrentItem ( style ); |
369 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 318 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
370 | 319 | ||
371 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 320 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
372 | btngrp-> insert ( m_tabstyle_top ); | 321 | btngrp-> insert ( m_tabstyle_top ); |
373 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 322 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
374 | 323 | ||
375 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 324 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
376 | btngrp-> insert ( m_tabstyle_top ); | 325 | btngrp-> insert ( m_tabstyle_bottom ); |
377 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 326 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
378 | 327 | ||
379 | bool tabtop = ( style & 0xff00 ) == 0; | ||
380 | m_tabstyle_top-> setChecked ( tabtop ); | 328 | m_tabstyle_top-> setChecked ( tabtop ); |
381 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 329 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
382 | 330 | ||
383 | m_original_tabstyle = style; | 331 | m_original_tabstyle = style; |
332 | m_original_tabpos = tabtop; | ||
384 | 333 | ||
385 | return tab; | 334 | return tab; |
386 | } | 335 | } |
387 | 336 | ||
388 | 337 | ||
389 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 338 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
390 | : QDialog ( parent, name, true ) | 339 | : QDialog ( parent, name, true ) |
391 | { | 340 | { |
392 | setCaption( tr( "Appearance" ) ); | 341 | setCaption( tr( "Appearance" ) ); |
393 | 342 | ||
394 | Config config( "qpe" ); | 343 | Config config( "qpe" ); |
395 | config.setGroup( "Appearance" ); | 344 | config.setGroup( "Appearance" ); |
396 | 345 | ||
397 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); | 346 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); |
398 | 347 | ||
399 | m_sample = new SampleWindow ( this ); | 348 | m_sample = new SampleWindow ( this ); |
400 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 349 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
401 | 350 | ||
402 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 351 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
403 | QWidget *styletab; | 352 | QWidget *styletab; |
404 | 353 | ||
405 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); | 354 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); |
406 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); | 355 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); |
407 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); | 356 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); |
408 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); | 357 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); |
409 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); | 358 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); |
410 | 359 | ||
411 | top-> addWidget ( tw, 10 ); | 360 | top-> addWidget ( tw, 10 ); |
412 | top-> addWidget ( m_sample, 1 ); | 361 | top-> addWidget ( m_sample, 1 ); |
413 | 362 | ||
414 | tw-> setCurrentTab ( styletab ); | 363 | tw-> setCurrentTab ( styletab ); |
415 | } | 364 | } |
416 | 365 | ||
417 | Appearance::~Appearance() | 366 | Appearance::~Appearance() |
418 | { | 367 | { |
419 | } | 368 | } |
420 | 369 | ||
421 | void Appearance::accept ( ) | 370 | void Appearance::accept ( ) |
422 | { | 371 | { |
423 | Config config("qpe"); | 372 | Config config("qpe"); |
424 | config.setGroup( "Appearance" ); | 373 | config.setGroup( "Appearance" ); |
425 | 374 | ||
426 | int newstyle = m_style_list-> currentItem ( ); | 375 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
427 | int newtabstyle = ( m_tabstyle_list-> currentItem ( ) & 0xff ) | \ | 376 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
428 | ( m_tabstyle_top-> isChecked ( ) ? 0x000 : 0x100 ); | ||
429 | int newfontfamily = m_font_family_list-> currentItem ( ); | ||
430 | int newfontstyle = m_font_style_list-> currentItem ( ); | ||
431 | int newfontsize = m_font_size_list-> currentItem ( ); | ||
432 | 377 | ||
433 | 378 | ||
434 | if ( m_style_changed ) { | 379 | if ( m_style_changed ) { |
435 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( newstyle ); | 380 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
436 | if ( item ) | 381 | if ( item ) |
437 | config.writeEntry( "Style", item-> key ( )); | 382 | config.writeEntry( "Style", item-> key ( )); |
438 | } | 383 | } |
439 | if ( newtabstyle != m_original_tabstyle ) { | 384 | |
440 | config. writeEntry ( "TabStyle", newtabstyle ); | 385 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { |
386 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | ||
387 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | ||
441 | } | 388 | } |
442 | 389 | ||
443 | if ( m_font_changed ) { | 390 | if ( m_font_changed ) { |
444 | config.writeEntry( "FontFamily", m_font_family_list-> text ( newfontfamily )); | 391 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
445 | config.writeEntry( "FontStyle", m_font_style_list-> text ( newfontstyle )); | 392 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
446 | config.writeEntry( "FontSize", m_font_size_list-> text ( newfontsize )); | 393 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
447 | } | 394 | } |
448 | 395 | ||
449 | 396 | ||
450 | if ( m_color_changed ) | 397 | if ( m_color_changed ) |
451 | { | 398 | { |
452 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 399 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
453 | 400 | ||
454 | if ( item ) | 401 | if ( item ) |
455 | item-> save ( config ); | 402 | item-> save ( config ); |
456 | } | 403 | } |
457 | 404 | ||
458 | config. write ( ); // need to flush the config info first | 405 | config. write ( ); // need to flush the config info first |
459 | Global::applyStyle ( ); | 406 | Global::applyStyle ( ); |
460 | 407 | ||
461 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 408 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
462 | QCopEnvelope e( "QPE/System", "restart()" ); | 409 | QCopEnvelope e( "QPE/System", "restart()" ); |
463 | } | 410 | } |
464 | 411 | ||
465 | QDialog::accept ( ); | 412 | QDialog::accept ( ); |
466 | } | 413 | } |
467 | 414 | ||
468 | void Appearance::done ( int r ) | 415 | void Appearance::done ( int r ) |
469 | { | 416 | { |
470 | QDialog::done ( r ); | 417 | QDialog::done ( r ); |
471 | close ( ); | 418 | close ( ); |
472 | } | 419 | } |
473 | 420 | ||
474 | 421 | ||
475 | void Appearance::styleClicked ( int index ) | 422 | void Appearance::styleClicked ( int index ) |
476 | { | 423 | { |
477 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 424 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
478 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 425 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
479 | 426 | ||
480 | if ( m_sample && sli && sli-> style ( )) | 427 | if ( m_sample && sli && sli-> style ( )) |
481 | m_sample-> setStyle2 ( sli-> style ( )); | 428 | m_sample-> setStyle2 ( sli-> style ( )); |
482 | 429 | ||
483 | m_style_changed |= ( index != m_original_style ); | 430 | m_style_changed |= ( index != m_original_style ); |
484 | } | 431 | } |
485 | 432 | ||
486 | void Appearance::styleSettingsClicked ( ) | 433 | void Appearance::styleSettingsClicked ( ) |
487 | { | 434 | { |
488 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 435 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
489 | 436 | ||
490 | if ( item && item-> hasSettings ( )) { | 437 | if ( item && item-> hasSettings ( )) { |
491 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 438 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
492 | QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); | 439 | QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); |
493 | 440 | ||
494 | QWidget *w = item-> settings ( d ); | 441 | QWidget *w = item-> settings ( d ); |
495 | 442 | ||
496 | if ( w ) { | 443 | if ( w ) { |
497 | vbox-> addWidget ( w ); | 444 | vbox-> addWidget ( w ); |
498 | 445 | ||
499 | d-> setCaption ( w-> caption ( )); | 446 | d-> setCaption ( w-> caption ( )); |
500 | 447 | ||
501 | d-> showMaximized ( ); | 448 | d-> showMaximized ( ); |
502 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | 449 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); |
503 | 450 | ||
504 | if ( item-> setSettings ( accepted )) | 451 | if ( item-> setSettings ( accepted )) |
505 | m_style_changed = true; | 452 | m_style_changed = true; |
506 | } | 453 | } |
507 | delete d; | 454 | delete d; |
508 | } | 455 | } |
509 | } | 456 | } |
510 | 457 | ||
511 | void Appearance::decoClicked ( int index ) | 458 | void Appearance::decoClicked ( int index ) |
512 | { | 459 | { |
513 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 460 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
514 | 461 | ||
515 | if ( m_sample ) { | 462 | if ( m_sample ) { |
516 | if ( dli && dli-> interface ( )) | 463 | if ( dli && dli-> interface ( )) |
517 | m_sample-> setDecoration ( dli-> interface ( )); | 464 | m_sample-> setDecoration ( dli-> interface ( )); |
518 | else | 465 | else |
519 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 466 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
520 | } | 467 | } |
521 | m_deco_changed |= ( index != m_original_deco ); | 468 | m_deco_changed |= ( index != m_original_deco ); |
522 | } | 469 | } |
523 | 470 | ||
524 | void Appearance::fontFamilyClicked ( int index ) | 471 | void Appearance::fontClicked ( const QFont &f ) |
525 | { | 472 | { |
526 | QString oldstyle = m_font_style_list-> currentText ( ); | 473 | m_font_changed |= ( f != m_sample-> font ( )); |
527 | QString oldsize = m_font_size_list-> currentText ( ); | 474 | m_sample-> setFont ( f ); |
528 | |||
529 | FontListItem *fli = (FontListItem *) m_font_family_list-> item ( index ); | ||
530 | |||
531 | m_font_style_list-> clear ( ); | ||
532 | m_font_style_list-> insertStringList ( fli-> styles ( )); | ||
533 | m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( )); | ||
534 | |||
535 | int i; | ||
536 | |||
537 | i = findItemCB ( m_font_style_list, oldstyle ); | ||
538 | if ( i < 0 ) | ||
539 | i = findItemCB ( m_font_style_list, "Regular" ); | ||
540 | if (( i < 0 ) && ( m_font_style_list-> count ( ) > 0 )) | ||
541 | i = 0; | ||
542 | |||
543 | if ( i >= 0 ) { | ||
544 | m_font_style_list-> setCurrentItem ( i ); | ||
545 | fontStyleClicked ( i ); | ||
546 | } | ||
547 | |||
548 | m_font_size_list-> clear ( ); | ||
549 | QValueList<int> sl = fli-> sizes ( ); | ||
550 | |||
551 | for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | ||
552 | m_font_size_list-> insertItem ( QString::number ( *it )); | ||
553 | |||
554 | i = findItemCB ( m_font_size_list, oldsize ); | ||
555 | if ( i < 0 ) | ||
556 | i = findItemCB ( m_font_size_list, "10" ); | ||
557 | if (( i < 0 ) && ( m_font_size_list-> count ( ) > 0 )) | ||
558 | i = 0; | ||
559 | |||
560 | if ( i >= 0 ) { | ||
561 | m_font_size_list-> setCurrentItem ( i ); | ||
562 | fontSizeClicked ( i ); | ||
563 | } | ||
564 | changeText ( ); | ||
565 | |||
566 | m_font_changed |= ( index != m_original_fontfamily ); | ||
567 | } | ||
568 | |||
569 | void Appearance::fontStyleClicked ( int index ) | ||
570 | { | ||
571 | changeText ( ); | ||
572 | |||
573 | m_font_changed |= ( index != m_original_fontstyle ); | ||
574 | } | ||
575 | |||
576 | void Appearance::fontSizeClicked ( int index ) | ||
577 | { | ||
578 | changeText ( ); | ||
579 | |||
580 | m_font_changed |= ( index != m_original_fontsize ); | ||
581 | } | ||
582 | |||
583 | void Appearance::changeText ( ) | ||
584 | { | ||
585 | int ffa = m_font_family_list-> currentItem ( ); | ||
586 | int fst = m_font_style_list-> currentItem ( ); | ||
587 | int fsi = m_font_size_list-> currentItem ( ); | ||
588 | |||
589 | FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa ); | ||
590 | |||
591 | if ( fli ) { | ||
592 | FontDatabase fdb; | ||
593 | |||
594 | m_sample-> setFont ( fdb. font ( fli-> family ( ), \ | ||
595 | fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \ | ||
596 | fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \ | ||
597 | fdb. charSets ( fli-> family ( )) [0] )); | ||
598 | } | ||
599 | } | 475 | } |
600 | 476 | ||
601 | void Appearance::colorClicked ( int index ) | 477 | void Appearance::colorClicked ( int index ) |
602 | { | 478 | { |
603 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 479 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
604 | 480 | ||
605 | if ( item ) | 481 | if ( item ) |
606 | m_sample-> setPalette ( item-> palette ( )); | 482 | m_sample-> setPalette ( item-> palette ( )); |
607 | 483 | ||
608 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 484 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
609 | } | 485 | } |
610 | 486 | ||
611 | 487 | ||
612 | void Appearance::editSchemeClicked ( ) | 488 | void Appearance::editSchemeClicked ( ) |
613 | { | 489 | { |
614 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 490 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
615 | 491 | ||
616 | int cnt = 0; | 492 | int cnt = 0; |
617 | QString controlLabel [QColorGroup::NColorRoles]; | 493 | QString controlLabel [QColorGroup::NColorRoles]; |
618 | QString controlColor [QColorGroup::NColorRoles]; | 494 | QString controlColor [QColorGroup::NColorRoles]; |
619 | 495 | ||
620 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 496 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
621 | QColor col = item-> color ( role ); | 497 | QColor col = item-> color ( role ); |
622 | 498 | ||
623 | if ( col. isValid ( )) { | 499 | if ( col. isValid ( )) { |
624 | controlLabel [cnt] = item-> label ( role ); | 500 | controlLabel [cnt] = item-> label ( role ); |
625 | controlColor [cnt] = col. name ( ); | 501 | controlColor [cnt] = col. name ( ); |
626 | 502 | ||
627 | cnt++; | 503 | cnt++; |
628 | } | 504 | } |
629 | } | 505 | } |
630 | 506 | ||
631 | EditScheme* editdlg = new EditScheme( this, "editScheme", true, 0, cnt, controlLabel, controlColor ); | 507 | EditScheme* editdlg = new EditScheme( this, "editScheme", true, 0, cnt, controlLabel, controlColor ); |
632 | editdlg-> showMaximized ( ); | 508 | editdlg-> showMaximized ( ); |
633 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | 509 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { |
634 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 510 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
635 | cnt = 0; | 511 | cnt = 0; |
636 | 512 | ||
637 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 513 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
638 | if ( item-> color ( role ). isValid ( )) { | 514 | if ( item-> color ( role ). isValid ( )) { |
639 | citem-> setColor ( role, QColor ( controlColor [cnt] )); | 515 | citem-> setColor ( role, QColor ( controlColor [cnt] )); |
640 | cnt++; | 516 | cnt++; |
641 | } | 517 | } |
642 | } | 518 | } |
643 | 519 | ||
644 | m_color_list-> setCurrentItem ( 0 ); | 520 | m_color_list-> setCurrentItem ( 0 ); |
645 | colorClicked ( 0 ); | 521 | colorClicked ( 0 ); |
646 | 522 | ||
647 | m_color_changed = true; | 523 | m_color_changed = true; |
648 | } | 524 | } |
649 | delete editdlg; | 525 | delete editdlg; |
650 | } | 526 | } |
651 | 527 | ||
652 | 528 | ||
653 | void Appearance::saveSchemeClicked() | 529 | void Appearance::saveSchemeClicked() |
654 | { | 530 | { |
655 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 531 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
656 | 532 | ||
657 | if ( !item ) | 533 | if ( !item ) |
658 | return; | 534 | return; |
659 | 535 | ||
660 | QDialog *d = new QDialog ( this, 0, true ); | 536 | QDialog *d = new QDialog ( this, 0, true ); |
661 | d-> setCaption ( tr( "Save Scheme" )); | 537 | d-> setCaption ( tr( "Save Scheme" )); |
662 | QLineEdit *ed = new QLineEdit ( this ); | 538 | QLineEdit *ed = new QLineEdit ( this ); |
663 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); | 539 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); |
664 | 540 | ||
665 | if ( d-> exec ( ) == QDialog::Accepted ) { | 541 | if ( d-> exec ( ) == QDialog::Accepted ) { |
666 | QString schemename = ed-> text ( ); | 542 | QString schemename = ed-> text ( ); |
667 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); | 543 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); |
668 | if ( !file. exists ( )) | 544 | if ( !file. exists ( )) |
669 | { | 545 | { |
670 | QPalette p = item-> palette ( ); | 546 | QPalette p = item-> palette ( ); |
671 | 547 | ||
672 | Config config ( file.name(), Config::File ); | 548 | Config config ( file.name(), Config::File ); |
673 | config. setGroup( "Colors" ); | 549 | config. setGroup( "Colors" ); |
674 | 550 | ||
675 | item-> save ( config ); | 551 | item-> save ( config ); |
676 | 552 | ||
677 | config. write ( ); // need to flush the config info first | 553 | config. write ( ); // need to flush the config info first |
678 | loadColors ( m_color_list ); | 554 | loadColors ( m_color_list ); |
679 | } | 555 | } |
680 | else | 556 | else |
681 | { | 557 | { |
682 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 558 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
683 | } | 559 | } |
684 | } | 560 | } |
685 | delete d; | 561 | delete d; |
686 | } | 562 | } |
687 | 563 | ||
688 | void Appearance::deleteSchemeClicked() | 564 | void Appearance::deleteSchemeClicked() |
689 | { | 565 | { |
690 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 566 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
691 | 567 | ||
692 | if ( !item ) | 568 | if ( !item ) |
693 | return; | 569 | return; |
694 | 570 | ||
695 | if ( m_color_list-> currentItem ( ) > 0 ) | 571 | if ( m_color_list-> currentItem ( ) > 0 ) |
696 | { | 572 | { |
697 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", | 573 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", |
698 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 574 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
699 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); | 575 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); |
700 | loadColors ( m_color_list ); | 576 | loadColors ( m_color_list ); |
701 | } | 577 | } |
702 | } | 578 | } |
703 | else | 579 | else |
704 | { | 580 | { |
705 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 581 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
706 | } | 582 | } |
707 | } | 583 | } |
708 | 584 | ||
diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h index ce0d4b0..4a86e57 100644 --- a/noncore/settings/appearance2/appearance.h +++ b/noncore/settings/appearance2/appearance.h | |||
@@ -1,116 +1,109 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> |
22 | ** | 22 | ** |
23 | **********************************************************************/ | 23 | **********************************************************************/ |
24 | 24 | ||
25 | #ifndef APPEARANCESETTINGS_H | 25 | #ifndef APPEARANCESETTINGS_H |
26 | #define APPEARANCESETTINGS_H | 26 | #define APPEARANCESETTINGS_H |
27 | 27 | ||
28 | #include <qpe/fontdatabase.h> | 28 | #include <qpe/fontdatabase.h> |
29 | 29 | ||
30 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | 32 | ||
33 | class QCheckBox; | 33 | class QCheckBox; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class QLabel; | 35 | class QLabel; |
36 | class QLineEdit; | 36 | class QLineEdit; |
37 | class QListBox; | 37 | class QListBox; |
38 | class QMultiLineEdit; | 38 | class QMultiLineEdit; |
39 | class QPushButton; | 39 | class QPushButton; |
40 | class QRadioButton; | 40 | class QRadioButton; |
41 | class QToolButton; | 41 | class QToolButton; |
42 | class SampleWindow; | 42 | class SampleWindow; |
43 | class OFontSelector; | ||
43 | 44 | ||
44 | class Appearance : public QDialog | 45 | class Appearance : public QDialog |
45 | { | 46 | { |
46 | Q_OBJECT | 47 | Q_OBJECT |
47 | 48 | ||
48 | public: | 49 | public: |
49 | Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 50 | Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
50 | ~Appearance(); | 51 | ~Appearance(); |
51 | 52 | ||
52 | protected: | 53 | protected: |
53 | virtual void accept ( ); | 54 | virtual void accept ( ); |
54 | virtual void done ( int r ); | 55 | virtual void done ( int r ); |
55 | 56 | ||
56 | protected slots: | 57 | protected slots: |
57 | void styleClicked ( int ); | 58 | void styleClicked ( int ); |
58 | void styleSettingsClicked ( ); | 59 | void styleSettingsClicked ( ); |
59 | void decoClicked ( int ); | 60 | void decoClicked ( int ); |
60 | void fontFamilyClicked ( int ); | 61 | void fontClicked ( const QFont & ); |
61 | void fontStyleClicked ( int ); | ||
62 | void fontSizeClicked ( int ); | ||
63 | void colorClicked ( int ); | 62 | void colorClicked ( int ); |
64 | // void tabStyleClicked ( int ); | ||
65 | 63 | ||
66 | void editSchemeClicked(); | 64 | void editSchemeClicked(); |
67 | void saveSchemeClicked(); | 65 | void saveSchemeClicked(); |
68 | void deleteSchemeClicked(); | 66 | void deleteSchemeClicked(); |
69 | 67 | ||
70 | private: | 68 | private: |
71 | void loadStyles ( QListBox * ); | 69 | void loadStyles ( QListBox * ); |
72 | void loadDecos ( QListBox * ); | 70 | void loadDecos ( QListBox * ); |
73 | void loadFonts ( QListBox * ); | ||
74 | void loadColors ( QListBox * ); | 71 | void loadColors ( QListBox * ); |
75 | 72 | ||
76 | void changeText(); | 73 | void changeText(); |
77 | 74 | ||
78 | QWidget *createStyleTab ( QWidget *parent ); | 75 | QWidget *createStyleTab ( QWidget *parent ); |
79 | QWidget *createDecoTab ( QWidget *parent ); | 76 | QWidget *createDecoTab ( QWidget *parent ); |
80 | QWidget *createFontTab ( QWidget *parent ); | 77 | QWidget *createFontTab ( QWidget *parent ); |
81 | QWidget *createColorTab ( QWidget *parent ); | 78 | QWidget *createColorTab ( QWidget *parent ); |
82 | QWidget *createGuiTab ( QWidget *parent ); | 79 | QWidget *createGuiTab ( QWidget *parent ); |
83 | 80 | ||
84 | private: | 81 | private: |
85 | bool m_style_changed; | 82 | bool m_style_changed; |
86 | bool m_font_changed; | 83 | bool m_font_changed; |
87 | bool m_scheme_changed; | 84 | bool m_scheme_changed; |
88 | bool m_deco_changed; | 85 | bool m_deco_changed; |
89 | bool m_color_changed; | 86 | bool m_color_changed; |
90 | 87 | ||
91 | int m_original_style; | 88 | int m_original_style; |
92 | int m_original_deco; | 89 | int m_original_deco; |
93 | int m_original_fontfamily; | ||
94 | int m_original_fontstyle; | ||
95 | int m_original_fontsize; | ||
96 | int m_original_tabstyle; | 90 | int m_original_tabstyle; |
91 | bool m_original_tabpos; | ||
97 | 92 | ||
98 | QListBox * m_style_list; | 93 | QListBox * m_style_list; |
99 | QPushButton * m_style_settings; | 94 | QPushButton * m_style_settings; |
100 | 95 | ||
101 | QListBox * m_deco_list; | 96 | QListBox * m_deco_list; |
102 | 97 | ||
103 | QListBox * m_color_list; | 98 | QListBox * m_color_list; |
104 | 99 | ||
105 | QListBox * m_font_family_list; | 100 | OFontSelector *m_fontselect; |
106 | QComboBox * m_font_style_list; | ||
107 | QComboBox * m_font_size_list; | ||
108 | 101 | ||
109 | SampleWindow *m_sample; | 102 | SampleWindow *m_sample; |
110 | 103 | ||
111 | QComboBox * m_tabstyle_list; | 104 | QComboBox * m_tabstyle_list; |
112 | QRadioButton *m_tabstyle_top; | 105 | QRadioButton *m_tabstyle_top; |
113 | QRadioButton *m_tabstyle_bottom; | 106 | QRadioButton *m_tabstyle_bottom; |
114 | }; | 107 | }; |
115 | 108 | ||
116 | #endif // APPEARANCESETTINGS_H | 109 | #endif |