summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp25
-rw-r--r--noncore/settings/appearance2/sample.cpp4
-rw-r--r--noncore/settings/appearance2/sample.h2
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
@@ -375,102 +375,104 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
btngrp-> hide ( );
btngrp-> setExclusive ( true );
m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
m_tabstyle_list-> insertItem ( tr( "Tabs" ));
m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
m_tabstyle_list-> setCurrentItem ( style );
gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
btngrp-> insert ( m_tabstyle_top );
gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) );
m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
btngrp-> insert ( m_tabstyle_bottom );
gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) );
m_tabstyle_top-> setChecked ( tabtop );
m_tabstyle_bottom-> setChecked ( !tabtop );
m_original_tabstyle = style;
m_original_tabpos = tabtop;
return tab;
}
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 )
{
if ( w == m_advtab ) {
m_sample-> hide ( );
updateGeometry ( ); // shouldn't be necessary ...
}
else
m_sample-> show ( );
}
void Appearance::accept ( )
{
bool newtabpos = m_tabstyle_top-> isChecked ( );
int newtabstyle = m_tabstyle_list-> currentItem ( );
Config config ( "qpe" );
config. setGroup ( "Appearance" );
if ( m_style_changed ) {
StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
if ( item )
config.writeEntry( "Style", item-> key ( ));
}
if ( m_deco_changed ) {
DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
if ( item )
config.writeEntry( "Decoration", item-> key ( ));
}
if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) {
config. writeEntry ( "TabStyle", newtabstyle + 1 );
config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
}
@@ -483,100 +485,103 @@ void Appearance::accept ( )
if ( m_color_changed )
{
ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
if ( item )
item-> save ( config );
}
m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
QStringList sl;
QString exceptstr;
for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) {
int fl = 0;
fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
fl |= ( it-> noFont ( ) ? 0x02 : 0 );
fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
exceptstr = QString::number ( fl, 32 );
exceptstr.append( it-> pattern ( ));
sl << exceptstr;
}
config. writeEntry ( "NoStyle", sl, ';' );
config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
config. write ( ); // need to flush the config info first
Global::applyStyle ( );
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 ) {
QCopEnvelope e( "QPE/System", "restart()" );
}
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 );
d-> setCaption ( w-> caption ( ));
d-> showMaximized ( );
bool accepted = ( d-> exec ( ) == QDialog::Accepted );
if ( item-> setSettings ( accepted ))
m_style_changed = true;
}
delete d;
}
}
void Appearance::decoClicked ( int index )
{
DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
if ( m_sample ) {
if ( dli && dli-> interface ( ))
m_sample-> setDecoration ( dli-> interface ( ));
else
m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
m_sample-> repaint ( );
}
m_deco_changed |= ( index != m_original_deco );
}
void Appearance::fontClicked ( const QFont &f )
{
m_font_changed |= ( f != m_sample-> font ( ));
m_sample-> setFont ( f );
}
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
@@ -64,104 +64,104 @@ public:
void paintEvent( QPaintEvent * )
{
QPainter p(this);
if ( hl )
p.setPen( colorGroup().highlightedText() );
else
p.setPen( colorGroup().text() );
p.drawText( rect(), AlignCenter, text );
}
private:
bool hl;
QString text;
};
SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0)
{
init();
}
QSize SampleWindow::sizeHint() const
{
return container->sizeHint() + QSize( 10, 35 );
}
void SampleWindow::setFont( const QFont &f )
{
QWidget::setFont( f );
popup->setFont( f );
QTimer::singleShot ( 0, this, SLOT( fixGeometry ( )));
}
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;
wd.reserved = 1;
th = iface->metric(WindowDecorationInterface::TitleHeight, &wd);
tb = iface->metric(WindowDecorationInterface::TopBorder, &wd);
lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd);
rb = iface->metric(WindowDecorationInterface::RightBorder, &wd);
bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd);
int yoff = th + tb;
int xoff = lb;
wd.rect.setX( 0 );
wd.rect.setWidth( width() - lb - rb );
wd.rect.setY( 0 );
wd.rect.setHeight( height() - yoff - bb );
container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() );
setMinimumSize( container->sizeHint().width()+lb+rb,
container->sizeHint().height()+tb+th+bb );
}
void SampleWindow::paintEvent( QPaintEvent * )
{
if ( !iface )
return;
QPainter p( this );
p.translate( lb, th+tb );
iface->drawArea(WindowDecorationInterface::Border, &p, &wd);
iface->drawArea(WindowDecorationInterface::Title, &p, &wd);
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
@@ -2,76 +2,76 @@
                This file is part of the OPIE Project
=. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __PREVIEW_H__
#define __PREVIEW_H__
#include <qwidget.h>
#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;
WindowDecorationInterface::WindowData wd;
QVBox *container;
QPopupMenu *popup;
int th;
int tb;
int lb;
int rb;
int bb;
};
#endif