author | sandman <sandman> | 2002-12-17 19:23:17 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-17 19:23:17 (UTC) |
commit | 7459ea6f560b01290086a0919fc5808291973b33 (patch) (side-by-side diff) | |
tree | fb74789d6229c61a0f629939a7402a31f734f7f7 | |
parent | f36c70938c8c2907a1b61637af3bd589262b4b5e (diff) | |
download | opie-7459ea6f560b01290086a0919fc5808291973b33.zip opie-7459ea6f560b01290086a0919fc5808291973b33.tar.gz opie-7459ea6f560b01290086a0919fc5808291973b33.tar.bz2 |
- small fix to reset the palette when changing styles
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 25 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.h | 2 |
3 files changed, 18 insertions, 13 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 2f3ba74..e9e0ad9 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp @@ -407,38 +407,40 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) Appearance::Appearance( QWidget* parent, const char* name, WFlags ) : QDialog ( parent, name, true, WStyle_ContextHelp ) { setCaption( tr( "Appearance" ) ); Config config( "qpe" ); config.setGroup( "Appearance" ); QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); m_sample = new SampleWindow ( this ); m_sample-> setDecoration ( new DefaultWindowDecoration ( )); QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); QWidget *styletab; - - tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style.png", tr( "Style" )); - tw-> addTab ( createFontTab ( tw, config ), "appearance/font.png", tr( "Font" )); - tw-> addTab ( createColorTab ( tw, config ), "appearance/color.png", tr( "Colors" ) ); - tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco.png", tr( "Windows" ) ); - tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced.png", tr( "Advanced" ) ); + + m_color_list = 0; + + tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style", tr( "Style" )); + tw-> addTab ( createFontTab ( tw, config ), "appearance/font", tr( "Font" )); + tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); + tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); + tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced", tr( "Advanced" ) ); top-> addWidget ( tw, 10 ); top-> addWidget ( m_sample, 1 ); tw-> setCurrentTab ( styletab ); connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; } Appearance::~Appearance() { } void Appearance::tabChanged ( QWidget *w ) { @@ -515,36 +517,39 @@ void Appearance::accept ( ) } QDialog::accept ( ); } void Appearance::done ( int r ) { QDialog::done ( r ); close ( ); } void Appearance::styleClicked ( int index ) { StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); - - if ( m_sample && sli && sli-> style ( )) - m_sample-> setStyle2 ( sli-> style ( )); - + + if ( m_sample && sli && sli-> style ( )) { + int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; + + m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); + } + m_style_changed |= ( index != m_original_style ); } void Appearance::styleSettingsClicked ( ) { StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); if ( item && item-> hasSettings ( )) { QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); QWidget *w = item-> settings ( d ); if ( w ) { vbox-> addWidget ( w ); diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index 6bbed4b..b3a9d48 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp @@ -96,40 +96,40 @@ void SampleWindow::setFont( const QFont &f ) static void setStyleRecursive ( QWidget *w, QStyle *s ) { w->setStyle( s ); QObjectList *childObjects=(QObjectList*)w->children(); if ( childObjects ) { QObject * o; for(o=childObjects->first();o!=0;o=childObjects->next()) { if( o->isWidgetType() ) { setStyleRecursive((QWidget *)o,s); } } } } -void SampleWindow::setStyle2 ( QStyle *sty ) +void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal ) { typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); QPixmapCache::clear ( ); - QPalette p = palette ( ); + QPalette p = pal; // ette ( ); sty-> polish ( p ); qt_set_draw_menu_bar_impl ( 0 ); setStyleRecursive ( this, sty ); setPalette ( p ); QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); } void SampleWindow::setDecoration( WindowDecorationInterface *i ) { iface = i; wd.rect = QRect( 0, 0, 150, 75 ); wd.caption = tr("Sample"); wd.palette = palette(); wd.flags = WindowDecorationInterface::WindowData::Dialog | WindowDecorationInterface::WindowData::Active; diff --git a/noncore/settings/appearance2/sample.h b/noncore/settings/appearance2/sample.h index c861228..27e6db5 100644 --- a/noncore/settings/appearance2/sample.h +++ b/noncore/settings/appearance2/sample.h @@ -34,33 +34,33 @@ #include <qpe/windowdecorationinterface.h> class QVBox; class QPopupMenu; class SampleText; class SampleWindow : public QWidget { Q_OBJECT public: SampleWindow( QWidget *parent ); QSize sizeHint() const; virtual void setFont( const QFont &f ); - void setStyle2 ( QStyle *sty ); + void setStyle2 ( QStyle *sty, const QPalette &p ); void setDecoration( WindowDecorationInterface *i ); void setPalette ( const QPalette & ); virtual void paintEvent( QPaintEvent * ); void init(); virtual bool eventFilter( QObject *, QEvent *e ); virtual void paletteChange( const QPalette &old ); virtual void resizeEvent( QResizeEvent *re ); public slots: void fixGeometry(); protected: WindowDecorationInterface *iface; |