summaryrefslogtreecommitdiff
path: root/noncore/settings/appearance2/appearance.cpp
Unidiff
Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp162
1 files changed, 98 insertions, 64 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 9e5eede..ba12e55 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -27,6 +27,30 @@
27 27
28*/ 28*/
29 29
30#include "appearance.h"
31#include "editScheme.h"
32#include "stylelistitem.h"
33#include "decolistitem.h"
34#include "colorlistitem.h"
35#include "exceptlistitem.h"
36#include "sample.h"
37
38/* OPIE */
39#include <opie/ofontselector.h>
40#include <opie/odevice.h>
41#include <opie/ofiledialog.h>
42#include <opie/otabwidget.h>
43
44#include <qpe/config.h>
45#include <qpe/global.h>
46#include <qpe/qpeapplication.h>
47#include <qpe/qpemessagebox.h>
48#include <qpe/qcopenvelope_qws.h>
49#include <qpe/qpestyle.h>
50#include <qpe/lightstyle.h>
51#include <qpe/styleinterface.h>
52
53/* QT */
30#include <qbuttongroup.h> 54#include <qbuttongroup.h>
31#include <qcheckbox.h> 55#include <qcheckbox.h>
32#include <qcombobox.h> 56#include <qcombobox.h>
@@ -49,31 +73,6 @@
49#include <qvbox.h> 73#include <qvbox.h>
50#include <qwhatsthis.h> 74#include <qwhatsthis.h>
51 75
52#include <qpe/config.h>
53#include <qpe/global.h>
54#include <qpe/resource.h>
55#include <qpe/qpeapplication.h>
56#include <qpe/qpemessagebox.h>
57#include <qpe/qcopenvelope_qws.h>
58#include <qpe/qpestyle.h>
59#include <qpe/lightstyle.h>
60#include <qpe/qlibrary.h>
61#include <qpe/styleinterface.h>
62
63#include <opie/ofontselector.h>
64#include <opie/odevice.h>
65#include <opie/ofiledialog.h>
66#include <opie/otabwidget.h>
67
68#include "appearance.h"
69#include "editScheme.h"
70#include "stylelistitem.h"
71#include "decolistitem.h"
72#include "colorlistitem.h"
73#include "exceptlistitem.h"
74#include "sample.h"
75
76
77using namespace Opie; 76using namespace Opie;
78 77
79 78
@@ -81,13 +80,16 @@ class DefaultWindowDecoration : public WindowDecorationInterface
81{ 80{
82public: 81public:
83 DefaultWindowDecoration() : ref(0) {} 82 DefaultWindowDecoration() : ref(0) {}
84 QString name() const { 83 QString name() const
84 {
85 return "Default"; 85 return "Default";
86 } 86 }
87QPixmap icon() const { 87 QPixmap icon() const
88 {
88 return QPixmap(); 89 return QPixmap();
89 } 90 }
90 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 91 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface )
92 {
91 *iface = 0; 93 *iface = 0;
92 if ( uuid == IID_QUnknown ) 94 if ( uuid == IID_QUnknown )
93 *iface = this; 95 *iface = this;
@@ -134,19 +136,22 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
134 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); 136 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
135 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); 137 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
136#endif 138#endif
139
137 { 140 {
138 QString path = QPEApplication::qpeDir ( ); 141 QString path = QPEApplication::qpeDir ( );
139 path.append( "/plugins/styles/" ); 142 path.append( "/plugins/styles/" );
140 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 143 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
141 144
142 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 145 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
146 {
143 QString libstr = path; 147 QString libstr = path;
144 libstr.append( "/" ); 148 libstr.append( "/" );
145 libstr.append( *it ); 149 libstr.append( *it );
146 QLibrary *lib = new QLibrary ( libstr ); 150 QLibrary *lib = new QLibrary ( libstr );
147 StyleInterface *iface; 151 StyleInterface *iface;
148 152
149 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { 153 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface )
154 {
150 StyleListItem *slit = new StyleListItem ( lib, iface ); 155 StyleListItem *slit = new StyleListItem ( lib, iface );
151 m_style_list-> insertItem ( slit ); 156 m_style_list-> insertItem ( slit );
152 157
@@ -184,14 +189,16 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
184 path.append( "/plugins/decorations/" ); 189 path.append( "/plugins/decorations/" );
185 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 190 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
186 191
187 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 192 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
193 {
188 QString libstr = path; 194 QString libstr = path;
189 libstr.append( "/" ); 195 libstr.append( "/" );
190 libstr.append( *it ); 196 libstr.append( *it );
191 QLibrary *lib = new QLibrary ( libstr ); 197 QLibrary *lib = new QLibrary ( libstr );
192 WindowDecorationInterface *iface; 198 WindowDecorationInterface *iface;
193 199
194 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { 200 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK )
201 {
195 DecoListItem *dlit = new DecoListItem ( lib, iface ); 202 DecoListItem *dlit = new DecoListItem ( lib, iface );
196 m_deco_list-> insertItem ( dlit ); 203 m_deco_list-> insertItem ( dlit );
197 204
@@ -246,7 +253,8 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
246 path.append( "/etc/colors/" ); 253 path.append( "/etc/colors/" );
247 QStringList sl = QDir ( path ). entryList ( "*.scheme" ); 254 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
248 255
249 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 256 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
257 {
250 QString name = (*it). left ((*it). find ( ".scheme" )); 258 QString name = (*it). left ((*it). find ( ".scheme" ));
251 QString pathstr = path; 259 QString pathstr = path;
252 pathstr.append( *it ); 260 pathstr.append( *it );
@@ -348,7 +356,8 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
348 356
349 QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); 357 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
350 QListViewItem *lvit = 0; 358 QListViewItem *lvit = 0;
351 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 359 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
360 {
352 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); 361 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
353 362
354 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); 363 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
@@ -432,9 +441,12 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
432 int rotDirection = cfg.readNumEntry( "rotatedir" ); 441 int rotDirection = cfg.readNumEntry( "rotatedir" );
433 ODirection rot = CW; 442 ODirection rot = CW;
434 443
435 if (rotDirection == -1) { 444 if (rotDirection == -1)
445 {
436 rot = ODevice::inst ( )-> direction ( ); 446 rot = ODevice::inst ( )-> direction ( );
437 } else { 447 }
448 else
449 {
438 rot = (ODirection)rotDirection; 450 rot = (ODirection)rotDirection;
439 } 451 }
440 452
@@ -482,12 +494,12 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
482} 494}
483 495
484Appearance::~Appearance() 496Appearance::~Appearance()
485{ 497{}
486}
487 498
488void Appearance::tabChanged ( QWidget *w ) 499void Appearance::tabChanged ( QWidget *w )
489{ 500{
490 if ( w == m_advtab ) { 501 if ( w == m_advtab )
502 {
491 m_sample-> hide ( ); 503 m_sample-> hide ( );
492 updateGeometry ( ); // shouldn't be necessary ... 504 updateGeometry ( ); // shouldn't be necessary ...
493 } 505 }
@@ -503,24 +515,28 @@ void Appearance::accept ( )
503 Config config ( "qpe" ); 515 Config config ( "qpe" );
504 config. setGroup ( "Appearance" ); 516 config. setGroup ( "Appearance" );
505 517
506 if ( m_style_changed ) { 518 if ( m_style_changed )
519 {
507 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 520 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
508 if ( item ) 521 if ( item )
509 config.writeEntry( "Style", item-> key ( )); 522 config.writeEntry( "Style", item-> key ( ));
510 } 523 }
511 524
512 if ( m_deco_changed ) { 525 if ( m_deco_changed )
526 {
513 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 527 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
514 if ( item ) 528 if ( item )
515 config.writeEntry( "Decoration", item-> key ( )); 529 config.writeEntry( "Decoration", item-> key ( ));
516 } 530 }
517 531
518 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { 532 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos ))
533 {
519 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 534 config. writeEntry ( "TabStyle", newtabstyle + 1 );
520 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 535 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
521 } 536 }
522 537
523 if ( m_font_changed ) { 538 if ( m_font_changed )
539 {
524 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 540 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
525 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 541 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
526 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 542 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
@@ -536,11 +552,16 @@ void Appearance::accept ( )
536 } 552 }
537 553
538 ODirection rot; 554 ODirection rot;
539 if (m_rotdir_ccw-> isChecked ( )) { 555 if (m_rotdir_ccw-> isChecked ( ))
556 {
540 rot = CCW; 557 rot = CCW;
541 } else if (m_rotdir_cw-> isChecked ( )) { 558 }
559 else if (m_rotdir_cw-> isChecked ( ))
560 {
542 rot = CW; 561 rot = CW;
543 } else { 562 }
563 else
564 {
544 rot = Flip; 565 rot = Flip;
545 } 566 }
546 config. writeEntry ( "rotatedir", (int)rot ); 567 config. writeEntry ( "rotatedir", (int)rot );
@@ -549,7 +570,8 @@ void Appearance::accept ( )
549 570
550 QStringList sl; 571 QStringList sl;
551 QString exceptstr; 572 QString exceptstr;
552 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { 573 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( ))
574 {
553 int fl = 0; 575 int fl = 0;
554 fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); 576 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
555 fl |= ( it-> noFont ( ) ? 0x02 : 0 ); 577 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
@@ -579,7 +601,8 @@ void Appearance::styleClicked ( int index )
579 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 601 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
580 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 602 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
581 603
582 if ( m_sample && sli && sli-> style ( )) { 604 if ( m_sample && sli && sli-> style ( ))
605 {
583 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; 606 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1;
584 607
585 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); 608 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( ));
@@ -592,19 +615,20 @@ void Appearance::styleSettingsClicked ( )
592{ 615{
593 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 616 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
594 617
595 if ( item && item-> hasSettings ( )) { 618 if ( item && item-> hasSettings ( ))
619 {
596 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 620 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
597 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); 621 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
598 622
599 QWidget *w = item-> settings ( d ); 623 QWidget *w = item-> settings ( d );
600 624
601 if ( w ) { 625 if ( w )
626 {
602 vbox-> addWidget ( w ); 627 vbox-> addWidget ( w );
603 628
604 d-> setCaption ( w-> caption ( )); 629 d-> setCaption ( w-> caption ( ));
605 630
606 d-> showMaximized ( ); 631 bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted );
607 bool accepted = ( d-> exec ( ) == QDialog::Accepted );
608 632
609 if ( item-> setSettings ( accepted )) 633 if ( item-> setSettings ( accepted ))
610 m_style_changed = true; 634 m_style_changed = true;
@@ -617,7 +641,8 @@ void Appearance::decoClicked ( int index )
617{ 641{
618 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 642 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
619 643
620 if ( m_sample ) { 644 if ( m_sample )
645 {
621 if ( dli && dli-> interface ( )) 646 if ( dli && dli-> interface ( ))
622 m_sample-> setDecoration ( dli-> interface ( )); 647 m_sample-> setDecoration ( dli-> interface ( ));
623 else 648 else
@@ -652,10 +677,12 @@ void Appearance::editSchemeClicked ( )
652 QString labels [QColorGroup::NColorRoles]; 677 QString labels [QColorGroup::NColorRoles];
653 QColor colors [QColorGroup::NColorRoles]; 678 QColor colors [QColorGroup::NColorRoles];
654 679
655 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 680 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ )
681 {
656 QColor col = item-> color ( role ); 682 QColor col = item-> color ( role );
657 683
658 if ( col. isValid ( )) { 684 if ( col. isValid ( ))
685 {
659 labels [cnt] = item-> label ( role ); 686 labels [cnt] = item-> label ( role );
660 colors [cnt] = col; 687 colors [cnt] = col;
661 688
@@ -664,13 +691,15 @@ void Appearance::editSchemeClicked ( )
664 } 691 }
665 692
666 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); 693 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true );
667 editdlg-> showMaximized ( ); 694 if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted )
668 if ( editdlg-> exec ( ) == QDialog::Accepted ) { 695 {
669 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); 696 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 );
670 cnt = 0; 697 cnt = 0;
671 698
672 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 699 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ )
673 if ( item-> color ( role ). isValid ( )) { 700 {
701 if ( item-> color ( role ). isValid ( ))
702 {
674 citem-> setColor ( role, colors [cnt] ); 703 citem-> setColor ( role, colors [cnt] );
675 cnt++; 704 cnt++;
676 } 705 }
@@ -698,7 +727,8 @@ void Appearance::saveSchemeClicked()
698 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); 727 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed );
699 ed-> setFocus ( ); 728 ed-> setFocus ( );
700 729
701 if ( d-> exec ( ) == QDialog::Accepted ) { 730 if ( d-> exec ( ) == QDialog::Accepted )
731 {
702 QString schemename = ed-> text ( ); 732 QString schemename = ed-> text ( );
703 QString filestr = QPEApplication::qpeDir(); 733 QString filestr = QPEApplication::qpeDir();
704 filestr.append( "/etc/colors/" ); 734 filestr.append( "/etc/colors/" );
@@ -761,7 +791,8 @@ void Appearance::addExcept ( )
761 791
762void Appearance::delExcept ( ) 792void Appearance::delExcept ( )
763{ 793{
764 if ( m_except-> selectedItem ( )) { 794 if ( m_except-> selectedItem ( ))
795 {
765 m_except-> setFocus ( ); 796 m_except-> setFocus ( );
766 delete m_except-> selectedItem ( ); 797 delete m_except-> selectedItem ( );
767 } 798 }
@@ -783,7 +814,8 @@ void Appearance::downExcept ( )
783 it-> moveItem ( it-> itemBelow ( )); 814 it-> moveItem ( it-> itemBelow ( ));
784} 815}
785 816
786class ExEdit : public QLineEdit { 817class ExEdit : public QLineEdit
818{
787public: 819public:
788 ExEdit ( ExceptListItem *item ) 820 ExEdit ( ExceptListItem *item )
789 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) 821 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
@@ -822,7 +854,8 @@ public:
822 { 854 {
823 if ( e-> key ( ) == Key_Return ) 855 if ( e-> key ( ) == Key_Return )
824 it-> listView ( )-> setFocus ( ); 856 it-> listView ( )-> setFocus ( );
825 else if ( e-> key ( ) == Key_Escape ) { 857 else if ( e-> key ( ) == Key_Escape )
858 {
826 m_out = false; 859 m_out = false;
827 it-> listView ( )-> setFocus ( ); 860 it-> listView ( )-> setFocus ( );
828 } 861 }
@@ -848,7 +881,8 @@ void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
848 it-> setNoFont ( !it-> noFont ( )); 881 it-> setNoFont ( !it-> noFont ( ));
849 else if ( c == 2 ) 882 else if ( c == 2 )
850 it-> setNoDeco ( !it-> noDeco ( )); 883 it-> setNoDeco ( !it-> noDeco ( ));
851 else if ( c == 3 ) { 884 else if ( c == 3 )
885 {
852 m_except-> ensureItemVisible ( it ); 886 m_except-> ensureItemVisible ( it );
853 new ExEdit ( it ); 887 new ExEdit ( it );
854 } 888 }