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 | |||
@@ -68,20 +68,12 @@ | |||
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 | { |
@@ -192,15 +184,6 @@ void Appearance::loadColors ( QListBox *list ) | |||
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 | { |
@@ -259,52 +242,17 @@ QWidget *Appearance::createFontTab ( QWidget *parent ) | |||
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 ) |
@@ -352,7 +300,8 @@ QWidget *Appearance::createGuiTab ( QWidget *parent ) | |||
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 ); |
@@ -365,7 +314,7 @@ QWidget *Appearance::createGuiTab ( QWidget *parent ) | |||
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" ); |
@@ -373,14 +322,14 @@ QWidget *Appearance::createGuiTab ( QWidget *parent ) | |||
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 | } |
@@ -423,27 +372,25 @@ void Appearance::accept ( ) | |||
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 | ||
@@ -521,81 +468,10 @@ void Appearance::decoClicked ( int index ) | |||
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 ) |
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 | |||
@@ -40,6 +40,7 @@ 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 | { |
@@ -57,11 +58,8 @@ 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(); |
@@ -70,7 +68,6 @@ protected slots: | |||
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(); |
@@ -90,10 +87,8 @@ private: | |||
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; |
@@ -102,9 +97,7 @@ private: | |||
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 | ||
@@ -113,4 +106,4 @@ private: | |||
113 | QRadioButton *m_tabstyle_bottom; | 106 | QRadioButton *m_tabstyle_bottom; |
114 | }; | 107 | }; |
115 | 108 | ||
116 | #endif // APPEARANCESETTINGS_H | 109 | #endif |