Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

liquidset.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 
00022 
00023 #include "liquidset.h"
00024 #include "liquid.h"
00025 
00026 #include <qpe/qpeapplication.h>
00027 #include <qpe/global.h>
00028 
00029 #include <qslider.h>
00030 #include <qcombobox.h>
00031 #include <qradiobutton.h>
00032 #include <qcheckbox.h>
00033 #include <qlabel.h>
00034 #include <qlayout.h>
00035 
00036 #include <qpe/config.h>
00037 
00038 #include <opie2/ocolorbutton.h>
00039 
00040 
00041 using namespace Opie;
00042 LiquidSettings::LiquidSettings ( QWidget* parent, const char *name, WFlags fl )
00043                 : QWidget ( parent, name, fl )
00044 {
00045         setCaption ( tr( "Liquid Style" ) );
00046 
00047         Config config ( "qpe" );
00048     config. setGroup ( "Liquid-Style" );
00049 
00050         m_type       = config. readNumEntry ( "Type", TransStippleBg );
00051         QColor mcol  = QColor ( config. readEntry ( "Color",  QApplication::palette ( ). active ( ). button ( ). name ( )));
00052         QColor tcol  = QColor ( config. readEntry ( "TextColor", QApplication::palette ( ). active ( ). text ( ). name ( )));
00053         int opacity  = config. readNumEntry ( "Opacity", 10 );
00054         m_shadow     = config. readBoolEntry ( "ShadowText", true );
00055         int contrast = config. readNumEntry ( "StippleContrast", 5 );
00056         m_flat       = config. readBoolEntry ( "FlatToolButtons", false );
00057 
00058         QVBoxLayout *vbox = new QVBoxLayout ( this );
00059         vbox-> setSpacing ( 3 );
00060         vbox-> setMargin ( 4 );
00061 
00062         QComboBox *cb = new QComboBox ( this );
00063         cb-> insertItem ( tr( "No translucency" ), None );
00064         cb-> insertItem ( tr( "Stippled, background color" ), StippledBg );
00065         cb-> insertItem ( tr( "Stippled, button color" ), StippledBtn );
00066         cb-> insertItem ( tr( "Translucent stippled, background color" ), TransStippleBg );
00067         cb-> insertItem ( tr( "Translucent stippled, button color" ), TransStippleBtn );
00068         cb-> insertItem ( tr( "Custom translucency" ), Custom );
00069 
00070         cb-> setCurrentItem ( m_type );
00071         vbox-> addWidget ( cb );
00072 
00073 
00074         QGridLayout *grid = new QGridLayout ( vbox );
00075         grid-> addColSpacing ( 0, 16 );
00076         grid-> addColSpacing ( 3, 8 );
00077 
00078         grid-> addWidget ( m_menulbl = new QLabel ( tr( "Menu color" ), this ), 0, 1 );
00079         grid-> addWidget ( m_textlbl = new QLabel ( tr( "Text color" ), this ), 0, 4 );
00080         grid-> addWidget ( m_opaclbl = new QLabel ( tr( "Opacity" ), this ), 1, 1 );
00081 
00082         m_menubtn = new OColorButton ( this, mcol );
00083         grid-> addWidget ( m_menubtn, 0, 2 );
00084 
00085         m_textbtn = new OColorButton ( this, tcol );
00086         grid-> addWidget ( m_textbtn, 0, 5 );
00087 
00088         m_opacsld = new QSlider ( Horizontal, this );
00089         m_opacsld-> setRange ( -20, 20 );
00090         m_opacsld-> setSteps ( 1, 1 );
00091         m_opacsld-> setValue ( opacity );
00092         m_opacsld-> setTickmarks ( QSlider::Below );
00093         grid-> addMultiCellWidget ( m_opacsld, 1, 1, 2, 5 );
00094 
00095         vbox-> addSpacing ( 4 );
00096 
00097         QCheckBox *shadow = new QCheckBox ( tr( "Use shadowed menu text" ), this );
00098         shadow-> setChecked ( m_shadow );
00099         vbox-> addWidget ( shadow );
00100         
00101         vbox-> addSpacing ( 4 );
00102         
00103         QCheckBox *flattb = new QCheckBox ( tr( "Make toolbar buttons appear flat" ), this );
00104         flattb-> setChecked ( m_flat );
00105         vbox-> addWidget ( flattb );
00106 
00107         vbox-> addSpacing ( 4 );
00108         
00109         QHBoxLayout *hbox = new QHBoxLayout ( vbox );
00110         
00111         hbox-> addWidget ( new QLabel ( tr( "Stipple contrast" ), this )); 
00112         
00113         m_contsld = new QSlider ( Horizontal, this );
00114         m_contsld-> setRange ( 0, 10 );
00115         m_contsld-> setSteps ( 1, 1 );
00116         m_contsld-> setValue ( contrast );
00117         m_contsld-> setTickmarks ( QSlider::Below );
00118         hbox-> addWidget ( m_contsld, 10 );
00119         
00120         vbox-> addStretch ( 10 );
00121 
00122         changeType ( m_type );
00123         
00124         connect ( cb, SIGNAL( highlighted(int) ), this, SLOT( changeType(int) ) );
00125         connect ( shadow, SIGNAL( toggled(bool) ), this, SLOT( changeShadow(bool) ) );
00126         connect ( flattb, SIGNAL( toggled(bool) ), this, SLOT( changeFlat(bool) ) );
00127 }
00128 
00129 void LiquidSettings::changeType ( int t )
00130 {
00131         bool custom = ( t == Custom );
00132         
00133         m_menulbl-> setEnabled ( custom );      
00134         m_textlbl-> setEnabled ( custom );      
00135         m_opaclbl-> setEnabled ( custom );      
00136         m_menubtn-> setEnabled ( custom );      
00137         m_textbtn-> setEnabled ( custom );      
00138         m_opacsld-> setEnabled ( custom );      
00139         
00140         m_type = t;
00141 }
00142 
00143 void LiquidSettings::changeShadow ( bool b )
00144 {
00145         m_shadow = b;
00146 }
00147 
00148 void LiquidSettings::changeFlat ( bool b )
00149 {
00150         m_flat = b;
00151 }
00152 
00153 
00154 bool LiquidSettings::writeConfig ( )
00155 {
00156         Config config ( "qpe" );
00157     config. setGroup ( "Liquid-Style" );
00158 
00159         config. writeEntry ( "Type", m_type  );
00160         config. writeEntry ( "Color",  m_menubtn-> color ( ). name ( ));
00161         config. writeEntry ( "TextColor", m_textbtn-> color ( ). name ( ));
00162         config. writeEntry ( "Opacity", m_opacsld-> value ( ));
00163         config. writeEntry ( "ShadowText", m_shadow );  
00164         config. writeEntry ( "StippleContrast", m_contsld-> value ( ));
00165         config. writeEntry ( "FlatToolButtons", m_flat );
00166         config. write ( );
00167 
00168         return true;
00169 }
00170 

Generated on Sat Nov 5 16:17:59 2005 for OPIE by  doxygen 1.4.2