author | sandman <sandman> | 2002-11-24 18:26:33 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-24 18:26:33 (UTC) |
commit | 60cf133c331f02fddee902caa13c19f63ab0f3b9 (patch) (unidiff) | |
tree | 37a512d0f8fe22c5bef18df5ef6797a69b6fc338 | |
parent | 89bf0723eefc1e66a104fe8135f1a5389f021442 (diff) | |
download | opie-60cf133c331f02fddee902caa13c19f63ab0f3b9.zip opie-60cf133c331f02fddee902caa13c19f63ab0f3b9.tar.gz opie-60cf133c331f02fddee902caa13c19f63ab0f3b9.tar.bz2 |
- New GUI for the "force style" and "don't style" options.
- Also restructured some of the old code.
- Fixed a bug regarding color-scheme saving (why didn't anybody notice
this ?!)
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 475 | ||||
-rw-r--r-- | noncore/settings/appearance2/appearance.h | 32 | ||||
-rw-r--r-- | noncore/settings/appearance2/exceptlistitem.h | 199 |
3 files changed, 529 insertions, 177 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 303e0b9..22b12b4 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -24,63 +24,58 @@ | |||
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "appearance.h" | ||
31 | #include "editScheme.h" | ||
32 | |||
33 | #include <opie/ofiledialog.h> | ||
34 | #include <opie/otabwidget.h> | ||
35 | |||
36 | #include <qpe/applnk.h> | ||
37 | #include <qpe/config.h> | ||
38 | #include <qpe/global.h> | ||
39 | #include <qpe/resource.h> | ||
40 | #include <qpe/qpeapplication.h> | ||
41 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
42 | #include <qpe/qcopenvelope_qws.h> | ||
43 | #endif | ||
44 | |||
45 | #include <qaction.h> | ||
46 | #include <qbuttongroup.h> | 30 | #include <qbuttongroup.h> |
47 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
48 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
49 | #include <qdialog.h> | 33 | #include <qdialog.h> |
50 | #include <qdir.h> | 34 | #include <qdir.h> |
51 | #include <qlabel.h> | 35 | #include <qlabel.h> |
52 | #include <qlayout.h> | 36 | #include <qlayout.h> |
53 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
54 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
55 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
56 | #include <qmultilineedit.h> | ||
57 | #include <qpopupmenu.h> | ||
58 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
59 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
60 | #if QT_VERSION >= 300 | 42 | #if QT_VERSION >= 300 |
61 | #include <qstylefactory.h> | 43 | #include <qstylefactory.h> |
62 | #else | 44 | #endif |
45 | #include <qtoolbutton.h> | ||
63 | #include <qwindowsstyle.h> | 46 | #include <qwindowsstyle.h> |
47 | #include <qlistview.h> | ||
48 | #include <qheader.h> | ||
49 | #include <qvbox.h> | ||
50 | |||
51 | #include <qpe/config.h> | ||
52 | #include <qpe/global.h> | ||
53 | #include <qpe/resource.h> | ||
54 | #include <qpe/qpeapplication.h> | ||
55 | #include <qpe/qcopenvelope_qws.h> | ||
64 | #include <qpe/qpestyle.h> | 56 | #include <qpe/qpestyle.h> |
65 | #include <qpe/lightstyle.h> | 57 | #include <qpe/lightstyle.h> |
66 | #include <qpe/qlibrary.h> | 58 | #include <qpe/qlibrary.h> |
67 | #include <qpe/styleinterface.h> | 59 | #include <qpe/styleinterface.h> |
68 | #endif | ||
69 | #include <qtabwidget.h> | ||
70 | #include <qtoolbutton.h> | ||
71 | #include <qvgroupbox.h> | ||
72 | #include <qwidget.h> | ||
73 | 60 | ||
61 | #include <opie/ofontselector.h> | ||
62 | #include <opie/odevice.h> | ||
63 | #include <opie/ofiledialog.h> | ||
64 | #include <opie/otabwidget.h> | ||
65 | |||
66 | #include "appearance.h" | ||
67 | #include "editScheme.h" | ||
74 | #include "stylelistitem.h" | 68 | #include "stylelistitem.h" |
75 | #include "decolistitem.h" | 69 | #include "decolistitem.h" |
76 | #include "colorlistitem.h" | 70 | #include "colorlistitem.h" |
77 | 71 | #include "exceptlistitem.h" | |
78 | #include "sample.h" | 72 | #include "sample.h" |
79 | 73 | ||
80 | #include <opie/ofontselector.h> | 74 | |
75 | using namespace Opie; | ||
81 | 76 | ||
82 | 77 | ||
83 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
84 | { | 79 | { |
85 | public: | 80 | public: |
86 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
@@ -106,192 +101,146 @@ public: | |||
106 | private: | 101 | private: |
107 | ulong ref; | 102 | ulong ref; |
108 | }; | 103 | }; |
109 | 104 | ||
110 | 105 | ||
111 | 106 | ||
112 | void Appearance::loadStyles ( QListBox *list ) | ||
113 | { | ||
114 | #if QT_VERSION >= 300 | ||
115 | list->insertStringList(QStyleFactory::styles()); | ||
116 | #else | ||
117 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | ||
118 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); | ||
119 | #ifndef QT_NO_STYLE_MOTIF | ||
120 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); | ||
121 | #endif | ||
122 | #ifndef QT_NO_STYLE_MOTIFPLUS | ||
123 | list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); | ||
124 | #endif | ||
125 | #ifndef QT_NO_STYLE_PLATINUM | ||
126 | list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); | ||
127 | #endif | ||
128 | #endif | ||
129 | list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); | ||
130 | |||
131 | #if QT_VERSION < 300 | ||
132 | { | ||
133 | QString path = QPEApplication::qpeDir() + "/plugins/styles/"; | ||
134 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | ||
135 | 107 | ||
136 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | ||
137 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | ||
138 | StyleInterface *iface; | ||
139 | 108 | ||
140 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) | ||
141 | list-> insertItem ( new StyleListItem ( lib, iface )); | ||
142 | else | ||
143 | delete lib; | ||
144 | } | ||
145 | } | ||
146 | 109 | ||
147 | #endif | ||
148 | } | ||
149 | 110 | ||
150 | void Appearance::loadDecos ( QListBox *list ) | 111 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
151 | { | 112 | { |
152 | list-> insertItem ( new DecoListItem ( "QPE" )); | 113 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
114 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | ||
153 | 115 | ||
116 | m_style_list = new QListBox( tab, "m_style_list" ); | ||
117 | vertLayout->addWidget( m_style_list ); | ||
118 | |||
119 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | ||
120 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | ||
121 | vertLayout-> addWidget ( m_style_settings ); | ||
122 | |||
123 | QString s = cfg. readEntry ( "Style", "Light" ); | ||
124 | |||
125 | |||
126 | #if QT_VERSION >= 300 | ||
127 | m_style_list->insertStringList(QStyleFactory::styles()); | ||
128 | #else | ||
129 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | ||
130 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | ||
131 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | ||
132 | #endif | ||
154 | { | 133 | { |
155 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 134 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
156 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 135 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
157 | 136 | ||
158 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 137 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
159 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 138 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
160 | WindowDecorationInterface *iface; | 139 | StyleInterface *iface; |
161 | 140 | ||
162 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 141 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { |
163 | list-> insertItem ( new DecoListItem ( lib, iface )); | 142 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
143 | m_style_list-> insertItem ( slit ); | ||
144 | |||
145 | if ( slit-> key ( ) == s ) | ||
146 | m_style_list-> setCurrentItem ( slit ); | ||
147 | } | ||
164 | else | 148 | else |
165 | delete lib; | 149 | delete lib; |
166 | } | 150 | } |
167 | } | 151 | } |
168 | } | ||
169 | |||
170 | void Appearance::loadColors ( QListBox *list ) | ||
171 | { | ||
172 | list-> clear ( ); | ||
173 | { | ||
174 | Config config ( "qpe" ); | ||
175 | config. setGroup ( "Appearance" ); | ||
176 | |||
177 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); | ||
178 | } | ||
179 | |||
180 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | ||
181 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | ||
182 | |||
183 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | ||
184 | QString name = (*it). left ((*it). find ( ".scheme" )); | ||
185 | Config config ( path + *it, Config::File ); | ||
186 | config. setGroup ( "Colors" ); | ||
187 | |||
188 | list-> insertItem ( new ColorListItem ( name, config )); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
193 | QWidget *Appearance::createStyleTab ( QWidget *parent ) | ||
194 | { | ||
195 | Config config ( "qpe" ); | ||
196 | config. setGroup ( "Appearance" ); | ||
197 | 152 | ||
198 | QWidget* tab = new QWidget( parent, "StyleTab" ); | ||
199 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | ||
200 | |||
201 | m_style_list = new QListBox( tab, "m_style_list" ); | ||
202 | vertLayout->addWidget( m_style_list ); | ||
203 | |||
204 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | ||
205 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | ||
206 | vertLayout-> addWidget ( m_style_settings ); | ||
207 | |||
208 | loadStyles ( m_style_list ); | ||
209 | |||
210 | QString s = config. readEntry ( "Style", "Light" ); | ||
211 | |||
212 | for ( uint i = 0; i < m_style_list-> count ( ); i++ ) { | ||
213 | if (((StyleListItem *) m_style_list-> item ( i ))-> key ( ) == s ) { | ||
214 | m_style_list-> setCurrentItem ( i ); | ||
215 | break; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | m_original_style = m_style_list-> currentItem ( ); | 153 | m_original_style = m_style_list-> currentItem ( ); |
220 | styleClicked ( m_original_style ); | 154 | styleClicked ( m_original_style ); |
221 | 155 | ||
222 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 156 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
223 | 157 | ||
224 | return tab; | 158 | return tab; |
225 | } | 159 | } |
226 | 160 | ||
227 | QWidget *Appearance::createDecoTab ( QWidget *parent ) | 161 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
228 | { | 162 | { |
229 | Config config ( "qpe" ); | ||
230 | config. setGroup ( "Appearance" ); | ||
231 | |||
232 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 163 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
233 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 164 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
234 | 165 | ||
235 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 166 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
236 | vertLayout->addWidget( m_deco_list ); | 167 | vertLayout->addWidget( m_deco_list ); |
237 | 168 | ||
238 | loadDecos ( m_deco_list ); | 169 | QString s = cfg. readEntry ( "Decoration" ); |
239 | 170 | ||
240 | QString s = config. readEntry ( "Decoration" ); | 171 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
172 | |||
173 | { | ||
174 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | ||
175 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | ||
176 | |||
177 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | ||
178 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | ||
179 | WindowDecorationInterface *iface; | ||
180 | |||
181 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { | ||
182 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | ||
183 | m_deco_list-> insertItem ( dlit ); | ||
184 | |||
185 | if ( dlit-> key ( ) == s ) | ||
186 | m_deco_list-> setCurrentItem ( dlit ); | ||
187 | } | ||
188 | else | ||
189 | delete lib; | ||
190 | } | ||
191 | } | ||
241 | 192 | ||
242 | for ( uint i = 0; i < m_deco_list-> count ( ); i++ ) { | ||
243 | if (((DecoListItem *) m_deco_list-> item ( i ))-> key ( ) == s ) { | ||
244 | m_deco_list-> setCurrentItem ( i ); | ||
245 | break; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | m_original_deco = m_deco_list-> currentItem ( ); | 193 | m_original_deco = m_deco_list-> currentItem ( ); |
250 | if ( m_deco_list-> currentItem ( ) < 0 ) | 194 | if ( m_deco_list-> currentItem ( ) < 0 ) |
251 | m_deco_list-> setCurrentItem ( 0 ); | 195 | m_deco_list-> setCurrentItem ( 0 ); |
252 | decoClicked ( m_original_deco ); | 196 | decoClicked ( m_original_deco ); |
253 | 197 | ||
254 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 198 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
255 | 199 | ||
256 | return tab; | 200 | return tab; |
257 | } | 201 | } |
258 | 202 | ||
259 | QWidget *Appearance::createFontTab ( QWidget *parent ) | 203 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
260 | { | 204 | { |
261 | Config config ( "qpe" ); | 205 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
262 | config. setGroup ( "Appearance" ); | 206 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
263 | 207 | int size = cfg. readNumEntry ( "FontSize", 10 ); | |
264 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); | ||
265 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); | ||
266 | int size = config.readNumEntry( "FontSize", 10 ); | ||
267 | 208 | ||
268 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 209 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
269 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 210 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
270 | 211 | ||
271 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 212 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
272 | this, SLOT( fontClicked ( const QFont & ))); | 213 | this, SLOT( fontClicked ( const QFont & ))); |
273 | 214 | ||
274 | return m_fontselect; | 215 | return m_fontselect; |
275 | } | 216 | } |
276 | 217 | ||
277 | QWidget *Appearance::createColorTab ( QWidget *parent ) | 218 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
278 | { | 219 | { |
279 | Config config ( "qpe" ); | ||
280 | config. setGroup ( "Appearance" ); | ||
281 | |||
282 | |||
283 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 220 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
284 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); | 221 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
285 | gridLayout->setRowStretch ( 3, 10 ); | 222 | gridLayout->setRowStretch ( 3, 10 ); |
286 | 223 | ||
287 | m_color_list = new QListBox ( tab ); | 224 | m_color_list = new QListBox ( tab ); |
288 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 225 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
289 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 226 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
290 | 227 | ||
291 | loadColors ( m_color_list ); | 228 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
229 | |||
230 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | ||
231 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | ||
232 | |||
233 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | ||
234 | QString name = (*it). left ((*it). find ( ".scheme" )); | ||
235 | Config config ( path + *it, Config::File ); | ||
236 | config. setGroup ( "Colors" ); | ||
237 | |||
238 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | ||
239 | } | ||
240 | |||
292 | m_color_list-> setCurrentItem ( 0 ); | 241 | m_color_list-> setCurrentItem ( 0 ); |
293 | 242 | ||
294 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 243 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
295 | tempButton->setText( tr( "Edit..." ) ); | 244 | tempButton->setText( tr( "Edit..." ) ); |
296 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 245 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
297 | gridLayout->addWidget( tempButton, 0, 1 ); | 246 | gridLayout->addWidget( tempButton, 0, 1 ); |
@@ -306,24 +255,90 @@ QWidget *Appearance::createColorTab ( QWidget *parent ) | |||
306 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 255 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
307 | gridLayout->addWidget( tempButton, 2, 1 ); | 256 | gridLayout->addWidget( tempButton, 2, 1 ); |
308 | 257 | ||
309 | return tab; | 258 | return tab; |
310 | } | 259 | } |
311 | 260 | ||
312 | QWidget *Appearance::createGuiTab ( QWidget *parent ) | 261 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) |
313 | { | 262 | { |
314 | Config config ( "qpe" ); | 263 | QWidget *tab = new QWidget ( parent ); |
315 | config. setGroup ( "Appearance" ); | 264 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
265 | |||
266 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | ||
316 | 267 | ||
317 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); | 268 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); |
318 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); | 269 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); |
270 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); | ||
271 | |||
272 | QLabel *l = new QLabel ( tab ); | ||
273 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); | ||
274 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); | ||
275 | |||
276 | m_except = new QListView ( tab ); | ||
277 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/style.png" ), "", 24 ); | ||
278 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/font.png" ), "", 24 ); | ||
279 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco.png" ), "", 24 ); | ||
280 | m_except-> addColumn ( tr( "Binary file(s)" )); | ||
281 | m_except-> setColumnAlignment ( 0, AlignCenter ); | ||
282 | m_except-> setColumnAlignment ( 1, AlignCenter ); | ||
283 | m_except-> setColumnAlignment ( 2, AlignCenter ); | ||
284 | m_except-> setAllColumnsShowFocus ( true ); | ||
285 | m_except-> setMinimumHeight ( 30 ); | ||
286 | m_except-> header ( )-> setClickEnabled ( false ); | ||
287 | m_except-> header ( )-> setResizeEnabled ( false ); | ||
288 | m_except-> header ( )-> setMovingEnabled ( false ); | ||
289 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | ||
290 | |||
291 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | ||
292 | |||
293 | QToolButton *tb = new QToolButton ( tab ); | ||
294 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | ||
295 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | ||
296 | lay-> addWidget ( tb, 2, 1 ); | ||
297 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | ||
298 | |||
299 | tb = new QToolButton ( tab ); | ||
300 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | ||
301 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | ||
302 | lay-> addWidget ( tb, 3, 1 ); | ||
303 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | ||
304 | |||
305 | tb = new QToolButton ( tab ); | ||
306 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | ||
307 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | ||
308 | lay-> addWidget ( tb, 4, 1 ); | ||
309 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | ||
310 | |||
311 | tb = new QToolButton ( tab ); | ||
312 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | ||
313 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | ||
314 | lay-> addWidget ( tb, 5, 1 ); | ||
315 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | ||
316 | |||
317 | lay-> setRowStretch ( 6, 10 ); | ||
318 | lay-> setColStretch ( 0, 10 ); | ||
319 | |||
320 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | ||
321 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | ||
322 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | ||
323 | |||
324 | new ExceptListItem ( m_except, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | ||
325 | } | ||
326 | |||
327 | |||
328 | vertLayout-> addSpacing ( 3 ); | ||
329 | QFrame *f = new QFrame ( tab ); | ||
330 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | ||
331 | vertLayout-> addWidget ( f ); | ||
332 | vertLayout-> addSpacing ( 3 ); | ||
333 | |||
319 | 334 | ||
320 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 335 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
321 | 336 | ||
322 | int style = config. readNumEntry ( "TabStyle", 2 ) - 1; | 337 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
323 | bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); | 338 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
324 | 339 | ||
325 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 340 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
326 | gridLayout-> addWidget ( label, 0, 0 ); | 341 | gridLayout-> addWidget ( label, 0, 0 ); |
327 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 342 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
328 | btngrp-> hide ( ); | 343 | btngrp-> hide ( ); |
329 | btngrp-> setExclusive ( true ); | 344 | btngrp-> setExclusive ( true ); |
@@ -359,38 +374,49 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | |||
359 | { | 374 | { |
360 | setCaption( tr( "Appearance" ) ); | 375 | setCaption( tr( "Appearance" ) ); |
361 | 376 | ||
362 | Config config( "qpe" ); | 377 | Config config( "qpe" ); |
363 | config.setGroup( "Appearance" ); | 378 | config.setGroup( "Appearance" ); |
364 | 379 | ||
365 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); | 380 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
366 | 381 | ||
367 | m_sample = new SampleWindow ( this ); | 382 | m_sample = new SampleWindow ( this ); |
368 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 383 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
369 | 384 | ||
370 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 385 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
371 | QWidget *styletab; | 386 | QWidget *styletab; |
372 | 387 | ||
373 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); | 388 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style.png", tr( "Style" )); |
374 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); | 389 | tw-> addTab ( createFontTab ( tw, config ), "appearance/font.png", tr( "Font" )); |
375 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); | 390 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color.png", tr( "Colors" ) ); |
376 | tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) ); | 391 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco.png", tr( "Windows" ) ); |
377 | tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) ); | 392 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced.png", tr( "Advanced" ) ); |
378 | 393 | ||
379 | top-> addWidget ( tw, 10 ); | 394 | top-> addWidget ( tw, 10 ); |
380 | top-> addWidget ( m_sample, 1 ); | 395 | top-> addWidget ( m_sample, 1 ); |
381 | 396 | ||
382 | tw-> setCurrentTab ( styletab ); | 397 | tw-> setCurrentTab ( styletab ); |
383 | 398 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | |
399 | |||
384 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 400 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
385 | } | 401 | } |
386 | 402 | ||
387 | Appearance::~Appearance() | 403 | Appearance::~Appearance() |
388 | { | 404 | { |
389 | } | 405 | } |
390 | 406 | ||
407 | void Appearance::tabChanged ( QWidget *w ) | ||
408 | { | ||
409 | if ( w == m_advtab ) { | ||
410 | m_sample-> hide ( ); | ||
411 | updateGeometry ( ); // shouldn't be necessary ... | ||
412 | } | ||
413 | else | ||
414 | m_sample-> show ( ); | ||
415 | } | ||
416 | |||
391 | void Appearance::accept ( ) | 417 | void Appearance::accept ( ) |
392 | { | 418 | { |
393 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 419 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
394 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 420 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
395 | 421 | ||
396 | Config config ( "qpe" ); | 422 | Config config ( "qpe" ); |
@@ -424,17 +450,29 @@ void Appearance::accept ( ) | |||
424 | { | 450 | { |
425 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 451 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
426 | 452 | ||
427 | if ( item ) | 453 | if ( item ) |
428 | item-> save ( config ); | 454 | item-> save ( config ); |
429 | } | 455 | } |
430 | 456 | ||
457 | |||
458 | QStringList sl; | ||
459 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { | ||
460 | int fl = 0; | ||
461 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | ||
462 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | ||
463 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | ||
464 | sl << ( QString::number ( fl, 32 ) + it-> pattern ( )); | ||
465 | } | ||
466 | config. writeEntry ( "NoStyle", sl, ';' ); | ||
467 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | ||
468 | |||
431 | config. write ( ); // need to flush the config info first | 469 | config. write ( ); // need to flush the config info first |
432 | Global::applyStyle ( ); | 470 | Global::applyStyle ( ); |
433 | 471 | ||
434 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 472 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart %1 now?" ). arg ( ODevice::inst ( )-> system ( ) == System_Zaurus ? "Qtopia" : "Opie" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
435 | QCopEnvelope e( "QPE/System", "restart()" ); | 473 | QCopEnvelope e( "QPE/System", "restart()" ); |
436 | } | 474 | } |
437 | 475 | ||
438 | QDialog::accept ( ); | 476 | QDialog::accept ( ); |
439 | } | 477 | } |
440 | 478 | ||
@@ -459,13 +497,13 @@ void Appearance::styleClicked ( int index ) | |||
459 | void Appearance::styleSettingsClicked ( ) | 497 | void Appearance::styleSettingsClicked ( ) |
460 | { | 498 | { |
461 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 499 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
462 | 500 | ||
463 | if ( item && item-> hasSettings ( )) { | 501 | if ( item && item-> hasSettings ( )) { |
464 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 502 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
465 | QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); | 503 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); |
466 | 504 | ||
467 | QWidget *w = item-> settings ( d ); | 505 | QWidget *w = item-> settings ( d ); |
468 | 506 | ||
469 | if ( w ) { | 507 | if ( w ) { |
470 | vbox-> addWidget ( w ); | 508 | vbox-> addWidget ( w ); |
471 | 509 | ||
@@ -559,14 +597,15 @@ void Appearance::saveSchemeClicked() | |||
559 | 597 | ||
560 | if ( !item ) | 598 | if ( !item ) |
561 | return; | 599 | return; |
562 | 600 | ||
563 | QDialog *d = new QDialog ( this, 0, true ); | 601 | QDialog *d = new QDialog ( this, 0, true ); |
564 | d-> setCaption ( tr( "Save Scheme" )); | 602 | d-> setCaption ( tr( "Save Scheme" )); |
565 | QLineEdit *ed = new QLineEdit ( this ); | 603 | QLineEdit *ed = new QLineEdit ( d ); |
566 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); | 604 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); |
605 | ed-> setFocus ( ); | ||
567 | 606 | ||
568 | if ( d-> exec ( ) == QDialog::Accepted ) { | 607 | if ( d-> exec ( ) == QDialog::Accepted ) { |
569 | QString schemename = ed-> text ( ); | 608 | QString schemename = ed-> text ( ); |
570 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); | 609 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); |
571 | if ( !file. exists ( )) | 610 | if ( !file. exists ( )) |
572 | { | 611 | { |
@@ -575,13 +614,14 @@ void Appearance::saveSchemeClicked() | |||
575 | Config config ( file.name(), Config::File ); | 614 | Config config ( file.name(), Config::File ); |
576 | config. setGroup( "Colors" ); | 615 | config. setGroup( "Colors" ); |
577 | 616 | ||
578 | item-> save ( config ); | 617 | item-> save ( config ); |
579 | 618 | ||
580 | config. write ( ); // need to flush the config info first | 619 | config. write ( ); // need to flush the config info first |
581 | loadColors ( m_color_list ); | 620 | |
621 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); | ||
582 | } | 622 | } |
583 | else | 623 | else |
584 | { | 624 | { |
585 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 625 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
586 | } | 626 | } |
587 | } | 627 | } |
@@ -597,15 +637,118 @@ void Appearance::deleteSchemeClicked() | |||
597 | 637 | ||
598 | if ( m_color_list-> currentItem ( ) > 0 ) | 638 | if ( m_color_list-> currentItem ( ) > 0 ) |
599 | { | 639 | { |
600 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", | 640 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", |
601 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 641 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
602 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); | 642 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); |
603 | loadColors ( m_color_list ); | 643 | delete item; |
604 | } | 644 | } |
605 | } | 645 | } |
606 | else | 646 | else |
607 | { | 647 | { |
608 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 648 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
609 | } | 649 | } |
610 | } | 650 | } |
611 | 651 | ||
652 | |||
653 | void Appearance::addExcept ( ) | ||
654 | { | ||
655 | ExceptListItem *it = new ExceptListItem ( m_except, tr( "<new>" ), true, true, true ); | ||
656 | m_except-> ensureItemVisible ( it ); | ||
657 | m_except-> setSelected ( it, true ); | ||
658 | } | ||
659 | |||
660 | void Appearance::delExcept ( ) | ||
661 | { | ||
662 | if ( m_except-> selectedItem ( )) { | ||
663 | m_except-> setFocus ( ); | ||
664 | delete m_except-> selectedItem ( ); | ||
665 | } | ||
666 | } | ||
667 | |||
668 | void Appearance::upExcept ( ) | ||
669 | { | ||
670 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | ||
671 | |||
672 | if ( it && it-> itemAbove ( )) | ||
673 | it-> itemAbove ( )-> moveItem ( it ); | ||
674 | } | ||
675 | |||
676 | void Appearance::downExcept ( ) | ||
677 | { | ||
678 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | ||
679 | |||
680 | if ( it && it-> itemBelow ( )) | ||
681 | it-> moveItem ( it-> itemBelow ( )); | ||
682 | } | ||
683 | |||
684 | class ExEdit : public QLineEdit { | ||
685 | public: | ||
686 | ExEdit ( ExceptListItem *item ) | ||
687 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) | ||
688 | { | ||
689 | setFrame ( false ); | ||
690 | |||
691 | QRect r = it-> listView ( )-> itemRect ( it ); | ||
692 | |||
693 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | ||
694 | int y = r. y ( ); | ||
695 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | ||
696 | int h = r. height ( ); // + 2; | ||
697 | |||
698 | setText ( it-> pattern ( )); | ||
699 | setGeometry ( x, y, w, h ); | ||
700 | |||
701 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | ||
702 | |||
703 | m_out = true; | ||
704 | |||
705 | show ( ); | ||
706 | setFocus ( ); | ||
707 | selectAll ( ); | ||
708 | end ( true ); | ||
709 | } | ||
710 | |||
711 | virtual void focusOutEvent ( QFocusEvent * ) | ||
712 | { | ||
713 | hide ( ); | ||
714 | if ( m_out ) | ||
715 | it-> setPattern ( text ( )); | ||
716 | delete this; | ||
717 | } | ||
718 | |||
719 | virtual void keyPressEvent ( QKeyEvent *e ) | ||
720 | { | ||
721 | if ( e-> key ( ) == Key_Return ) | ||
722 | it-> listView ( )-> setFocus ( ); | ||
723 | else if ( e-> key ( ) == Key_Escape ) { | ||
724 | m_out = false; | ||
725 | it-> listView ( )-> setFocus ( ); | ||
726 | } | ||
727 | else | ||
728 | QLineEdit::keyPressEvent ( e ); | ||
729 | } | ||
730 | |||
731 | private: | ||
732 | ExceptListItem *it; | ||
733 | bool m_out; | ||
734 | }; | ||
735 | |||
736 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) | ||
737 | { | ||
738 | if ( !item || c < 0 || c > 3 ) | ||
739 | return; | ||
740 | |||
741 | ExceptListItem *it = (ExceptListItem *) item; | ||
742 | |||
743 | if ( c == 0 ) | ||
744 | it-> setNoStyle ( !it-> noStyle ( )); | ||
745 | else if ( c == 1 ) | ||
746 | it-> setNoFont ( !it-> noFont ( )); | ||
747 | else if ( c == 2 ) | ||
748 | it-> setNoDeco ( !it-> noDeco ( )); | ||
749 | else if ( c == 3 ) { | ||
750 | m_except-> ensureItemVisible ( it ); | ||
751 | new ExEdit ( it ); | ||
752 | } | ||
753 | } | ||
754 | |||
diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h index a392aa7..065dfb7 100644 --- a/noncore/settings/appearance2/appearance.h +++ b/noncore/settings/appearance2/appearance.h | |||
@@ -28,13 +28,12 @@ | |||
28 | 28 | ||
29 | #ifndef APPEARANCESETTINGS_H | 29 | #ifndef APPEARANCESETTINGS_H |
30 | #define APPEARANCESETTINGS_H | 30 | #define APPEARANCESETTINGS_H |
31 | 31 | ||
32 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | 33 | ||
34 | #include <qmainwindow.h> | ||
35 | #include <qdialog.h> | 34 | #include <qdialog.h> |
36 | 35 | ||
37 | class QCheckBox; | 36 | class QCheckBox; |
38 | class QComboBox; | 37 | class QComboBox; |
39 | class QLabel; | 38 | class QLabel; |
40 | class QLineEdit; | 39 | class QLineEdit; |
@@ -42,12 +41,15 @@ class QListBox; | |||
42 | class QMultiLineEdit; | 41 | class QMultiLineEdit; |
43 | class QPushButton; | 42 | class QPushButton; |
44 | class QRadioButton; | 43 | class QRadioButton; |
45 | class QToolButton; | 44 | class QToolButton; |
46 | class SampleWindow; | 45 | class SampleWindow; |
47 | class OFontSelector; | 46 | class OFontSelector; |
47 | class QListView; | ||
48 | class QListViewItem; | ||
49 | class Config; | ||
48 | 50 | ||
49 | class Appearance : public QDialog | 51 | class Appearance : public QDialog |
50 | { | 52 | { |
51 | Q_OBJECT | 53 | Q_OBJECT |
52 | 54 | ||
53 | public: | 55 | public: |
@@ -65,37 +67,41 @@ protected slots: | |||
65 | void fontClicked ( const QFont & ); | 67 | void fontClicked ( const QFont & ); |
66 | void colorClicked ( int ); | 68 | void colorClicked ( int ); |
67 | 69 | ||
68 | void editSchemeClicked(); | 70 | void editSchemeClicked(); |
69 | void saveSchemeClicked(); | 71 | void saveSchemeClicked(); |
70 | void deleteSchemeClicked(); | 72 | void deleteSchemeClicked(); |
73 | |||
74 | void tabChanged ( QWidget * ); | ||
75 | |||
76 | void addExcept ( ); | ||
77 | void delExcept ( ); | ||
78 | void upExcept ( ); | ||
79 | void downExcept ( ); | ||
80 | void clickedExcept ( QListViewItem *, const QPoint &, int ); | ||
71 | 81 | ||
72 | private: | 82 | private: |
73 | void loadStyles ( QListBox * ); | ||
74 | void loadDecos ( QListBox * ); | ||
75 | void loadColors ( QListBox * ); | ||
76 | |||
77 | void changeText(); | 83 | void changeText(); |
78 | 84 | ||
79 | QWidget *createStyleTab ( QWidget *parent ); | 85 | QWidget *createStyleTab ( QWidget *parent, Config &cfg ); |
80 | QWidget *createDecoTab ( QWidget *parent ); | 86 | QWidget *createDecoTab ( QWidget *parent, Config &cfg ); |
81 | QWidget *createFontTab ( QWidget *parent ); | 87 | QWidget *createFontTab ( QWidget *parent, Config &cfg ); |
82 | QWidget *createColorTab ( QWidget *parent ); | 88 | QWidget *createColorTab ( QWidget *parent, Config &cfg ); |
83 | QWidget *createGuiTab ( QWidget *parent ); | 89 | QWidget *createAdvancedTab ( QWidget *parent, Config &cfg ); |
84 | 90 | ||
85 | private: | 91 | private: |
86 | bool m_style_changed; | 92 | bool m_style_changed; |
87 | bool m_font_changed; | 93 | bool m_font_changed; |
88 | bool m_scheme_changed; | 94 | bool m_scheme_changed; |
89 | bool m_deco_changed; | 95 | bool m_deco_changed; |
90 | bool m_color_changed; | 96 | bool m_color_changed; |
91 | 97 | ||
92 | int m_original_style; | 98 | int m_original_style; |
93 | int m_original_deco; | 99 | int m_original_deco; |
94 | int m_original_tabstyle; | 100 | int m_original_tabstyle; |
95 | bool m_original_tabpos; | 101 | bool m_original_tabpos; |
96 | 102 | ||
97 | QListBox * m_style_list; | 103 | QListBox * m_style_list; |
98 | QPushButton * m_style_settings; | 104 | QPushButton * m_style_settings; |
99 | 105 | ||
100 | QListBox * m_deco_list; | 106 | QListBox * m_deco_list; |
101 | 107 | ||
@@ -105,9 +111,13 @@ private: | |||
105 | 111 | ||
106 | SampleWindow *m_sample; | 112 | SampleWindow *m_sample; |
107 | 113 | ||
108 | QComboBox * m_tabstyle_list; | 114 | QComboBox * m_tabstyle_list; |
109 | QRadioButton *m_tabstyle_top; | 115 | QRadioButton *m_tabstyle_top; |
110 | QRadioButton *m_tabstyle_bottom; | 116 | QRadioButton *m_tabstyle_bottom; |
117 | |||
118 | QWidget * m_advtab; | ||
119 | QListView * m_except; | ||
120 | QCheckBox * m_force; | ||
111 | }; | 121 | }; |
112 | 122 | ||
113 | #endif | 123 | #endif |
diff --git a/noncore/settings/appearance2/exceptlistitem.h b/noncore/settings/appearance2/exceptlistitem.h new file mode 100644 index 0000000..5eda79c --- a/dev/null +++ b/noncore/settings/appearance2/exceptlistitem.h | |||
@@ -0,0 +1,199 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This file is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This file is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
17 | ..}^=.= = ; Public License for more details. | ||
18 | ++= -. .` .: | ||
19 | : = ...= . :.=- You should have received a copy of the GNU | ||
20 | -. .:....=;==+<; General Public License along with this file; | ||
21 | -_. . . )=. = see the file COPYING. If not, write to the | ||
22 | -- :-=` Free Software Foundation, Inc., | ||
23 | 59 Temple Place - Suite 330, | ||
24 | Boston, MA 02111-1307, USA. | ||
25 | |||
26 | */ | ||
27 | |||
28 | #ifndef EXCEPTLISTITEM_H | ||
29 | #define EXCEPTLISTITEM_H | ||
30 | |||
31 | #include <qlistview.h> | ||
32 | #include <qpixmap.h> | ||
33 | #include <qimage.h> | ||
34 | #include <qpainter.h> | ||
35 | |||
36 | class ExceptListItem : public QListViewItem { | ||
37 | public: | ||
38 | ExceptListItem ( QListView *lv, const QString &t, bool nostyle = true, bool nofont = true, bool nodeco = true ) : QListViewItem ( lv ) | ||
39 | { | ||
40 | m_text = t; | ||
41 | |||
42 | m_nofont = nofont; | ||
43 | m_nostyle = nostyle; | ||
44 | m_nodeco = nodeco; | ||
45 | |||
46 | init ( ); | ||
47 | } | ||
48 | |||
49 | virtual ~ExceptListItem ( ) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | static void overlay ( QImage &img, const QImage &ovl ) | ||
54 | { | ||
55 | if (( img. size ( ) != ovl. size ( )) || | ||
56 | ( img. depth ( ) != ovl. depth ( ))) | ||
57 | return; | ||
58 | |||
59 | for ( int y = 0; y != img. height ( ); y++ ) { | ||
60 | QRgb *iline = (QRgb *) img. scanLine ( y ); | ||
61 | QRgb *oline = (QRgb *) ovl. scanLine ( y ); | ||
62 | |||
63 | for ( int x = 0; x != img. width ( ); x++ ) { | ||
64 | QRgb i = *iline; | ||
65 | QRgb o = *oline; | ||
66 | |||
67 | *iline = qRgba (( qRed ( i ) + qRed ( o )) / 2, | ||
68 | ( qGreen ( i ) + qGreen ( o )) / 2, | ||
69 | ( qBlue ( i ) + qBlue ( o )) / 2, | ||
70 | ( qAlpha ( i ) + qAlpha ( o )) / 2 ); | ||
71 | iline++; | ||
72 | oline++; | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | static void init ( ) | ||
78 | { | ||
79 | static bool init = false; | ||
80 | |||
81 | if ( init ) | ||
82 | return; | ||
83 | |||
84 | QImage noimg = Resource::loadImage ( "appearance/no.png" ); | ||
85 | QImage fontimg = Resource::loadImage ( "appearance/font.png" ); | ||
86 | QImage styleimg = Resource::loadImage ( "appearance/style.png" ); | ||
87 | QImage decoimg = Resource::loadImage ( "appearance/deco.png" ); | ||
88 | |||
89 | s_fontpix [0] = new QPixmap ( ); | ||
90 | s_fontpix [0]-> convertFromImage ( fontimg ); | ||
91 | overlay ( fontimg, noimg ); | ||
92 | s_fontpix [1] = new QPixmap ( ); | ||
93 | s_fontpix [1]-> convertFromImage ( fontimg ); | ||
94 | |||
95 | s_stylepix [0] = new QPixmap ( ); | ||
96 | s_stylepix [0]-> convertFromImage ( styleimg ); | ||
97 | overlay ( styleimg, noimg ); | ||
98 | s_stylepix [1] = new QPixmap ( ); | ||
99 | s_stylepix [1]-> convertFromImage ( styleimg ); | ||
100 | |||
101 | s_decopix [0] = new QPixmap ( ); | ||
102 | s_decopix [0]-> convertFromImage ( decoimg ); | ||
103 | overlay ( decoimg, noimg ); | ||
104 | s_decopix [1] = new QPixmap ( ); | ||
105 | s_decopix [1]-> convertFromImage ( decoimg ); | ||
106 | |||
107 | init = true; | ||
108 | } | ||
109 | |||
110 | bool noFont ( ) const | ||
111 | { | ||
112 | return m_nofont; | ||
113 | } | ||
114 | |||
115 | bool noStyle ( ) const | ||
116 | { | ||
117 | return m_nostyle; | ||
118 | } | ||
119 | |||
120 | bool noDeco ( ) const | ||
121 | { | ||
122 | return m_nodeco; | ||
123 | } | ||
124 | |||
125 | void setNoDeco ( bool b ) | ||
126 | { | ||
127 | if ( b != m_nodeco ) { | ||
128 | m_nodeco = b; | ||
129 | repaint ( ); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | void setNoStyle ( bool b ) | ||
134 | { | ||
135 | if ( b != m_nostyle ) { | ||
136 | m_nostyle = b; | ||
137 | repaint ( ); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void setNoFont ( bool b ) | ||
142 | { | ||
143 | if ( b != m_nofont ) { | ||
144 | m_nofont = b; | ||
145 | repaint ( ); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | QString pattern ( ) const | ||
150 | { | ||
151 | return m_text; | ||
152 | } | ||
153 | |||
154 | void setPattern ( const QString &s ) | ||
155 | { | ||
156 | if ( s != m_text ) { | ||
157 | m_text = s; | ||
158 | widthChanged ( 3 ); | ||
159 | repaint ( ); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | QString text ( int i ) const | ||
164 | { | ||
165 | if ( i == 3 ) | ||
166 | return m_text; | ||
167 | else | ||
168 | return QString::null; | ||
169 | |||
170 | } | ||
171 | |||
172 | const QPixmap *pixmap ( int i ) const | ||
173 | { | ||
174 | if ( i == 0 ) | ||
175 | return (const QPixmap *) s_stylepix [m_nostyle ? 1 : 0]; | ||
176 | else if ( i == 1 ) | ||
177 | return (const QPixmap *) s_fontpix [m_nofont ? 1 : 0]; | ||
178 | else if ( i == 2 ) | ||
179 | return (const QPixmap *) s_decopix [m_nodeco ? 1 : 0]; | ||
180 | else | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | private: | ||
185 | QString m_text; | ||
186 | bool m_nofont; | ||
187 | bool m_nostyle; | ||
188 | bool m_nodeco; | ||
189 | |||
190 | static QPixmap *s_stylepix [2]; | ||
191 | static QPixmap *s_fontpix [2]; | ||
192 | static QPixmap *s_decopix [2]; | ||
193 | }; | ||
194 | |||
195 | QPixmap *ExceptListItem::s_stylepix [2] = { 0, 0 }; | ||
196 | QPixmap *ExceptListItem::s_fontpix [2] = { 0, 0 }; | ||
197 | QPixmap *ExceptListItem::s_decopix [2] = { 0, 0 }; | ||
198 | |||
199 | #endif | ||