author | sandman <sandman> | 2002-09-24 23:53:23 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-24 23:53:23 (UTC) |
commit | 5ae62a1def1d21c4827560607b208033d6054ed0 (patch) (side-by-side diff) | |
tree | 445b34a539ec9f377d36ba9fb1587c72dafa46b0 | |
parent | a390040768072b4b2b931ec0bcdaaa55daae0b4c (diff) | |
download | opie-5ae62a1def1d21c4827560607b208033d6054ed0.zip opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.gz opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.bz2 |
- updated all copyright headers
- use new OColorButton
- rearranged editScheme a bit
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 62 | ||||
-rw-r--r-- | noncore/settings/appearance2/appearance.h | 50 | ||||
-rw-r--r-- | noncore/settings/appearance2/colorlistitem.h | 28 | ||||
-rw-r--r-- | noncore/settings/appearance2/decolistitem.h | 27 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.cpp | 116 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.h | 73 | ||||
-rw-r--r-- | noncore/settings/appearance2/main.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.h | 29 | ||||
-rw-r--r-- | noncore/settings/appearance2/stylelistitem.h | 28 |
10 files changed, 318 insertions, 170 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 23630c5..66cf2c3 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp @@ -1,215 +1,219 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -*********************************************************************** -** -** Enhancements by: Dan Williams, <williamsdr@acm.org> -** -**********************************************************************/ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "appearance.h" #include "editScheme.h" #include <opie/ofiledialog.h> #include <opie/otabwidget.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qaction.h> #include <qbuttongroup.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> #include <qdir.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistbox.h> #include <qmessagebox.h> #include <qmultilineedit.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qradiobutton.h> #if QT_VERSION >= 300 #include <qstylefactory.h> #else #include <qwindowsstyle.h> #include <qpe/qpestyle.h> #include <qpe/lightstyle.h> #include <qpe/qlibrary.h> #include <qpe/styleinterface.h> #endif #include <qtabwidget.h> #include <qtoolbutton.h> #include <qvgroupbox.h> #include <qwidget.h> #include "stylelistitem.h" #include "decolistitem.h" #include "colorlistitem.h" #include "sample.h" #include <opie/ofontselector.h> class DefaultWindowDecoration : public WindowDecorationInterface { public: DefaultWindowDecoration() : ref(0) {} QString name() const { return "Default"; } QPixmap icon() const { return QPixmap(); } QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_WindowDecoration ) *iface = this; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT private: ulong ref; }; void Appearance::loadStyles ( QListBox *list ) { #if QT_VERSION >= 300 list->insertStringList(QStyleFactory::styles()); #else list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); #ifndef QT_NO_STYLE_MOTIF list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); #endif #ifndef QT_NO_STYLE_MOTIFPLUS list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); #endif #ifndef QT_NO_STYLE_PLATINUM list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); #endif #endif list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); #if QT_VERSION < 300 { QString path = QPEApplication::qpeDir() + "/plugins/styles/"; QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QLibrary *lib = new QLibrary ( path + "/" + *it ); StyleInterface *iface; if ( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) list-> insertItem ( new StyleListItem ( lib, iface )); else delete lib; } } #endif } void Appearance::loadDecos ( QListBox *list ) { list-> insertItem ( new DecoListItem ( tr( "Default" ))); { QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QLibrary *lib = new QLibrary ( path + "/" + *it ); WindowDecorationInterface *iface; if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) list-> insertItem ( new DecoListItem ( lib, iface )); else delete lib; } } } void Appearance::loadColors ( QListBox *list ) { list-> clear ( ); { Config config ( "qpe" ); config. setGroup ( "Appearance" ); list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); } QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; QStringList sl = QDir ( path ). entryList ( "*.scheme" ); for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { QString name = (*it). left ((*it). find ( ".scheme" )); Config config ( path + *it, Config::File ); config. setGroup ( "Colors" ); list-> insertItem ( new ColorListItem ( name, config )); } } QWidget *Appearance::createStyleTab ( QWidget *parent ) { Config config ( "qpe" ); config. setGroup ( "Appearance" ); QWidget* tab = new QWidget( parent, "StyleTab" ); QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); m_style_list = new QListBox( tab, "m_style_list" ); vertLayout->addWidget( m_style_list ); m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); vertLayout-> addWidget ( m_style_settings ); loadStyles ( m_style_list ); QString s = config. readEntry ( "Style", "Light" ); m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); m_original_style = m_style_list-> currentItem ( ); styleClicked ( m_original_style ); connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); return tab; } QWidget *Appearance::createDecoTab ( QWidget *parent ) @@ -301,284 +305,284 @@ QWidget *Appearance::createGuiTab ( QWidget *parent ) QGridLayout* gridLayout = new QGridLayout ( vertLayout ); int style = config. readNumEntry ( "TabStyle", 2 ) - 1; bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); QLabel* label = new QLabel( tr( "Tab style:" ), tab ); gridLayout-> addWidget ( label, 0, 0 ); QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); 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 ); m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); btngrp-> insert ( m_tabstyle_top ); gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); btngrp-> insert ( m_tabstyle_bottom ); gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); 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 ) { setCaption( tr( "Appearance" ) ); Config config( "qpe" ); config.setGroup( "Appearance" ); QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); m_sample = new SampleWindow ( this ); m_sample-> setDecoration ( new DefaultWindowDecoration ( )); OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); QWidget *styletab; tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); top-> addWidget ( tw, 10 ); top-> addWidget ( m_sample, 1 ); tw-> setCurrentTab ( styletab ); } Appearance::~Appearance() { } void Appearance::accept ( ) { Config config("qpe"); config.setGroup( "Appearance" ); int newtabstyle = m_tabstyle_list-> currentItem ( ); bool newtabpos = m_tabstyle_top-> isChecked ( ); if ( m_style_changed ) { StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); if ( item ) config.writeEntry( "Style", item-> key ( )); } if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { config. writeEntry ( "TabStyle", newtabstyle + 1 ); config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); } if ( m_font_changed ) { config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); } if ( m_color_changed ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( item ) item-> save ( config ); } config. write ( ); // need to flush the config info first Global::applyStyle ( ); if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), 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 ( )); 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, 4, 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_deco_changed |= ( index != m_original_deco ); } void Appearance::fontClicked ( const QFont &f ) { m_font_changed |= ( f != m_sample-> font ( )); m_sample-> setFont ( f ); } void Appearance::colorClicked ( int index ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); if ( item ) m_sample-> setPalette ( item-> palette ( )); m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); } void Appearance::editSchemeClicked ( ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); int cnt = 0; - QString controlLabel [QColorGroup::NColorRoles]; - QString controlColor [QColorGroup::NColorRoles]; + QString labels [QColorGroup::NColorRoles]; + QColor colors [QColorGroup::NColorRoles]; for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { QColor col = item-> color ( role ); if ( col. isValid ( )) { - controlLabel [cnt] = item-> label ( role ); - controlColor [cnt] = col. name ( ); + labels [cnt] = item-> label ( role ); + colors [cnt] = col; cnt++; } } - EditScheme* editdlg = new EditScheme( this, "editScheme", true, 0, cnt, controlLabel, controlColor ); + EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); editdlg-> showMaximized ( ); if ( editdlg-> exec ( ) == QDialog::Accepted ) { ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); cnt = 0; for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { if ( item-> color ( role ). isValid ( )) { - citem-> setColor ( role, QColor ( controlColor [cnt] )); + citem-> setColor ( role, colors [cnt] ); cnt++; } } m_color_list-> setCurrentItem ( 0 ); colorClicked ( 0 ); m_color_changed = true; } delete editdlg; } void Appearance::saveSchemeClicked() { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( !item ) return; QDialog *d = new QDialog ( this, 0, true ); d-> setCaption ( tr( "Save Scheme" )); QLineEdit *ed = new QLineEdit ( this ); ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); if ( d-> exec ( ) == QDialog::Accepted ) { QString schemename = ed-> text ( ); QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); if ( !file. exists ( )) { QPalette p = item-> palette ( ); Config config ( file.name(), Config::File ); config. setGroup( "Colors" ); item-> save ( config ); config. write ( ); // need to flush the config info first loadColors ( m_color_list ); } else { QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); } } delete d; } void Appearance::deleteSchemeClicked() { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( !item ) return; if ( m_color_list-> currentItem ( ) > 0 ) { if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); loadColors ( m_color_list ); } } else { QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); } } diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h index 4a86e57..ddf94f2 100644 --- a/noncore/settings/appearance2/appearance.h +++ b/noncore/settings/appearance2/appearance.h @@ -1,109 +1,113 @@ -/********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. -** -** This file is part of the Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -*********************************************************************** -** -** Enhancements by: Dan Williams, <williamsdr@acm.org> -** -**********************************************************************/ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef APPEARANCESETTINGS_H #define APPEARANCESETTINGS_H #include <qpe/fontdatabase.h> #include <qmainwindow.h> #include <qdialog.h> class QCheckBox; class QComboBox; class QLabel; class QLineEdit; class QListBox; class QMultiLineEdit; class QPushButton; class QRadioButton; class QToolButton; class SampleWindow; class OFontSelector; class Appearance : public QDialog { Q_OBJECT public: Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~Appearance(); protected: virtual void accept ( ); virtual void done ( int r ); protected slots: void styleClicked ( int ); void styleSettingsClicked ( ); void decoClicked ( int ); void fontClicked ( const QFont & ); void colorClicked ( int ); void editSchemeClicked(); void saveSchemeClicked(); void deleteSchemeClicked(); private: void loadStyles ( QListBox * ); void loadDecos ( QListBox * ); void loadColors ( QListBox * ); void changeText(); QWidget *createStyleTab ( QWidget *parent ); QWidget *createDecoTab ( QWidget *parent ); QWidget *createFontTab ( QWidget *parent ); QWidget *createColorTab ( QWidget *parent ); QWidget *createGuiTab ( QWidget *parent ); private: bool m_style_changed; bool m_font_changed; bool m_scheme_changed; bool m_deco_changed; bool m_color_changed; int m_original_style; int m_original_deco; int m_original_tabstyle; bool m_original_tabpos; QListBox * m_style_list; QPushButton * m_style_settings; QListBox * m_deco_list; QListBox * m_color_list; OFontSelector *m_fontselect; SampleWindow *m_sample; QComboBox * m_tabstyle_list; QRadioButton *m_tabstyle_top; QRadioButton *m_tabstyle_bottom; }; #endif diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h index 1ff6ecc..1df541b 100644 --- a/noncore/settings/appearance2/colorlistitem.h +++ b/noncore/settings/appearance2/colorlistitem.h @@ -1,113 +1,141 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #ifndef COLORLISTITEM_H #define COLORLISTITEM_H #include <qlistbox.h> #include <qpalette.h> #include <qapplication.h> #include <qpe/config.h> class Appearance; class ColorListItem : public QListBoxText { public: ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) { m_colors = new QColor [s_colorcount]; load ( cfg ); } virtual ~ColorListItem ( ) { delete [] m_colors; } QPalette palette ( ) { return m_palette; } bool load ( Config &cfg ) { for ( int i = 0; i < s_colorcount; i++ ) m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); buildPalette ( ); return true; } void buildPalette ( ) { m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); } bool save ( Config &cfg ) { for ( int i = 0; i < s_colorcount; i++ ) cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); return true; } QColor color ( QColorGroup::ColorRole role ) { int i = r2i ( role ); return i >= 0 ? m_colors [i] : QColor ( ); } void setColor ( QColorGroup::ColorRole role, QColor c ) { int i = r2i ( role ); if ( i >= 0 ) { m_colors [i] = c; buildPalette ( ); } } QString label ( QColorGroup::ColorRole role ) { int i = r2i ( role ); return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; } private: QPalette m_palette; QColor *m_colors; static struct colorlut { QColorGroup::ColorRole m_role; const char * m_key; const char * m_def; const char * m_label; } const s_colorlut []; static const int s_colorcount; static int r2i ( QColorGroup::ColorRole role ) { for ( int i = 0; i < s_colorcount; i++ ) { if ( s_colorlut [i]. m_role == role ) return i; } return -1; } }; const ColorListItem::colorlut ColorListItem::s_colorlut [] = { { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } }; const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); #endif diff --git a/noncore/settings/appearance2/decolistitem.h b/noncore/settings/appearance2/decolistitem.h index dfdce47..953a939 100644 --- a/noncore/settings/appearance2/decolistitem.h +++ b/noncore/settings/appearance2/decolistitem.h @@ -1,79 +1,106 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef DECOLISTITEM_H #define DECOLISTITEM_H #include <qpe/windowdecorationinterface.h> #include <qlistbox.h> class DecoListItem : public QListBoxText { public: DecoListItem ( const QString &t ) : QListBoxText ( t ) { m_lib = 0; m_window_if = 0; // m_settings_if = 0; } DecoListItem ( QLibrary *lib, WindowDecorationInterface *iface ) : QListBoxText ( iface-> name ( )) { m_lib = lib; m_window_if = iface; // iface-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &m_settings_if ); } virtual ~DecoListItem ( ) { // if ( m_settings_if ) // m_settings_if-> release ( ); if ( m_window_if ) m_window_if-> release ( ); delete m_lib; } bool hasSettings ( ) const { // return ( m_settings_if ); return false; } QWidget *settings ( QWidget * /*parent*/ ) { // return m_settings_if ? m_settings_if-> create ( parent ) : 0; return 0; } bool setSettings ( bool /*accepted*/ ) { // if ( !m_settings_if ) // return false; // if ( accepted ) // return m_settings_if-> accept ( ); // else { // m_settings_if-> reject ( ); // return false; // } return false; } QString key ( ) { if ( m_window_if ) return QString ( m_window_if-> name ( )); else return text ( ); } WindowDecorationInterface *interface ( ) { return m_window_if; } private: QLibrary *m_lib; WindowDecorationInterface *m_window_if; // WindowDecorationSettingsInterface *m_settings_if; }; #endif
\ No newline at end of file diff --git a/noncore/settings/appearance2/editScheme.cpp b/noncore/settings/appearance2/editScheme.cpp index 4f2ac2c..8cb0f1c 100644 --- a/noncore/settings/appearance2/editScheme.cpp +++ b/noncore/settings/appearance2/editScheme.cpp @@ -1,87 +1,73 @@ -/********************************************************************** -** EditScheme -** -** Dialog for editing color scheme -** -** Copyright (C) 2002, Dan Williams -** williamsdr@acm.org -** http://draknor.net -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "editScheme.h" -#include "opie/colorpopupmenu.h" +#include <opie/ocolorbutton.h> #include <qaction.h> #include <qlabel.h> #include <qlayout.h> #include <qpopupmenu.h> #include <qscrollview.h> #include <qtoolbutton.h> -EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, - int max, QString *list, QString *colors ) - : QDialog( parent, name, modal, fl ) +EditScheme::EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog ( parent, name, modal, fl ) { - setCaption( tr( "Edit scheme" ) ); - QGridLayout* layout = new QGridLayout( this ); - layout->setSpacing( 4 ); - layout->setMargin( 4 ); - + setCaption ( tr( "Edit scheme" ) ); + QGridLayout *layout = new QGridLayout ( this, 0, 0, 4, 4 ); - maxCount = max; - colorList = colors; - surfaceList = list; - colorButtons = new QToolButton * [max]; - int i; - QLabel* label; - ColorPopupMenu* colorPopupMenu; - for ( i = 0; i < max; i++ ) + m_count = cnt; + m_buttons = new OColorButton * [cnt]; + m_colors = colors; + + for ( int i = 0; i < cnt; i++ ) { -// colorList[i] = colors[i]; -// surfaceList[i] = list[i]; - label = new QLabel( tr( surfaceList[i] ), this ); - layout->addWidget( label, i, 0 ); - colorButtons[i] = new QToolButton( this, list[i] ); - colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); - layout->addWidget( colorButtons[i], i, 1 ); - - colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] ); - colorButtons[i]->setPopup( colorPopupMenu ); - colorButtons[i]->setPopupDelay( 0 ); - connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) ); + QLabel *l = new QLabel ( labels [i], this ); + layout-> addWidget ( l, i, 0 ); + + m_buttons [i] = new OColorButton ( this ); + m_buttons [i]-> setColor ( colors [i] ); + layout-> addWidget ( m_buttons [i], i, 1 ); } } -EditScheme::~EditScheme() +EditScheme::~EditScheme ( ) { - delete [] colorButtons; + delete [] m_buttons; } -void EditScheme::changeColor( const QColor& color ) +void EditScheme::accept ( ) { - QString name( sender()->name() ); - int i; - - for ( i = 0; i < maxCount; i++ ) - { - if ( name == colorButtons[i]->name() ) - { - break; - } - } - if ( i < maxCount && name == colorButtons[i]->name() ) - { - colorList[i] = color.name(); - colorButtons[i]->setPalette( QPalette( QColor( colorList[i] ) ) ); - } + for ( int i = 0; i < m_count; i++ ) + m_colors [i] = m_buttons [i]-> color ( ); + + QDialog::accept ( ); } + diff --git a/noncore/settings/appearance2/editScheme.h b/noncore/settings/appearance2/editScheme.h index 583050f..0a025bd 100644 --- a/noncore/settings/appearance2/editScheme.h +++ b/noncore/settings/appearance2/editScheme.h @@ -1,48 +1,53 @@ -/********************************************************************** -** EditScheme -** -** Dialog for editing color scheme -** -** Copyright (C) 2002, Dan Williams -** williamsdr@acm.org -** http://draknor.net -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef EDITSCHEME_H #define EDITSCHEME_H #include <qdialog.h> -#include <qtoolbutton.h> class QColor; +class OColorButton; -class EditScheme : public QDialog -{ - Q_OBJECT +class EditScheme : public QDialog { + Q_OBJECT public: - EditScheme( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, - int = 0, QString * = 0, QString * = 0 ); - ~EditScheme(); - - int maxCount; - QString * surfaceList; - QString * colorList; - - - QToolButton** colorButtons; + EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + virtual ~EditScheme ( ); protected slots: - void changeColor( const QColor& ); + virtual void accept ( ); + +private: + int m_count; + QColor *m_colors; + OColorButton **m_buttons; }; -#endif // EDITSCHEME_H +#endif diff --git a/noncore/settings/appearance2/main.cpp b/noncore/settings/appearance2/main.cpp index cfbab0b..3afec46 100644 --- a/noncore/settings/appearance2/main.cpp +++ b/noncore/settings/appearance2/main.cpp @@ -1,35 +1,43 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "appearance.h" #include <qpe/qpeapplication.h> int main ( int argc, char **argv ) { QPEApplication app ( argc, argv ); Appearance m; app. showMainDocumentWidget ( &m ); return app. exec ( ); } diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index e447002..0d8b003 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp @@ -1,192 +1,221 @@ +/* + 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 library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #include <qvbox.h> #include <qpopupmenu.h> #include <qpainter.h> #include <qmenubar.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qscrollbar.h> #include <qlayout.h> #include <qwhatsthis.h> #include <qpixmapcache.h> #include <qtimer.h> #include <qobjectlist.h> #include <qcommonstyle.h> #include "sample.h" class SampleText : public QWidget { public: SampleText( const QString &t, bool h, QWidget *parent ) : QWidget( parent ), hl(h), text(t) { if ( hl ) setBackgroundMode( PaletteHighlight ); else setBackgroundMode( PaletteBase ); } QSize sizeHint() const { QFontMetrics fm(font()); return QSize( fm.width(text)+10, fm.height()+4 ); } 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 ) { 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 ( ); 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); p.setPen(palette().active().color(QColorGroup::HighlightedText)); QFont f( font() ); f.setWeight( QFont::Bold ); p.setFont(f); iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); iface->drawButton( WindowDecorationInterface::Help, &p, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); brect.moveBy( wd.rect.width() - iface->metric(WindowDecorationInterface::OKWidth,&wd) - iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); iface->drawButton( WindowDecorationInterface::Close, &p, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); iface->drawButton( WindowDecorationInterface::OK, &p, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); } void SampleWindow::init() { container = new QVBox( this ); popup = new QPopupMenu( this ); popup->insertItem( tr("Normal Item"), 1 ); popup->insertItem( tr("Disabled Item"), 2 ); popup->setItemEnabled(2, FALSE); QMenuBar *mb = new QMenuBar( container ); mb->insertItem( tr("Menu"), popup ); QHBox *hb = new QHBox( container ); QWidget *w = new QWidget( hb ); (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); gl->addWidget( l, 0, 0 ); l = new SampleText( tr("Highlighted Text"), TRUE, w ); gl->addWidget( l, 1, 0 ); QPushButton *pb = new QPushButton( tr("Button"), w ); gl->addWidget( pb, 0, 1 ); pb->setFocusPolicy( NoFocus ); QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); gl->addWidget( cb, 1, 1 ); cb->setFocusPolicy( NoFocus ); cb->setChecked( TRUE ); QWhatsThis::add( this, tr("Sample window using the selected settings.") ); } bool SampleWindow::eventFilter( QObject *, QEvent *e ) diff --git a/noncore/settings/appearance2/sample.h b/noncore/settings/appearance2/sample.h index c6f9b5a..a189f69 100644 --- a/noncore/settings/appearance2/sample.h +++ b/noncore/settings/appearance2/sample.h @@ -1,49 +1,78 @@ +/* + 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 library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + 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 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 diff --git a/noncore/settings/appearance2/stylelistitem.h b/noncore/settings/appearance2/stylelistitem.h index 3cc63dc..bbfbd41 100644 --- a/noncore/settings/appearance2/stylelistitem.h +++ b/noncore/settings/appearance2/stylelistitem.h @@ -1,85 +1,113 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library 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 library 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 +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + #ifndef STYLELISTITEM_H #define STYLELISTITEM_H #include <qlistbox.h> #include <qpe/styleinterface.h> #include <stdio.h> class StyleListItem : public QListBoxText { public: StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) { m_lib = 0; m_style_if = 0; m_settings_if = 0; m_style = sty; } StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) { m_lib = lib; m_style_if = iface; m_settings_if = 0; m_style = iface-> create ( ); iface-> queryInterface ( IID_StyleSettings, (QUnknownInterface **) &m_settings_if ); } virtual ~StyleListItem ( ) { delete m_style; if ( m_settings_if ) m_settings_if-> release ( ); if ( m_style_if ) m_style_if-> release ( ); delete m_lib; } bool hasSettings ( ) const { return ( m_settings_if ); } QWidget *settings ( QWidget *parent ) { return m_settings_if ? m_settings_if-> create ( parent ) : 0; } bool setSettings ( bool accepted ) { if ( !m_settings_if ) return false; if ( accepted ) return m_settings_if-> accept ( ); else { m_settings_if-> reject ( ); return false; } } QString key ( ) { if ( m_style_if ) return QString ( m_style_if-> key ( )); else return text ( ); } QStyle *style ( ) { return m_style; } private: QLibrary *m_lib; QStyle *m_style; StyleInterface *m_style_if; StyleSettingsInterface *m_settings_if; }; #endif |