Back to index

kdeartwork  4.3.2
config.cpp
Go to the documentation of this file.
00001 /*
00002  *     Distributed under the terms of the BSD license.
00003  */
00004 
00005 // $Id: config.cpp 742997 2007-11-29 15:53:23Z lunakl $
00006 #include "config.h"
00007 #include <kapplication.h>
00008 #include <kglobal.h>
00009 
00010 #include <kvbox.h>
00011 //Added by qt3to4:
00012 #include <QLabel>
00013 #include <klocale.h>
00014 
00015 extern "C" KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
00016 {
00017        return new CdeConfig(conf, parent);
00018 }
00019 
00020 
00021 /* NOTE: 
00022  * 'conf'     is a pointer to the kwindecoration modules open kwin config,
00023  *                   and is by default set to the "Style" group.
00024  *
00025  * 'parent'   is the parent of the QObject, which is a VBox inside the
00026  *                   Configure tab in kwindecoration
00027  */
00028 
00029 CdeConfig::CdeConfig( KConfig* conf, QWidget* parent )
00030        : QObject( parent )
00031 {
00032        cdeConfig = new KConfig("kwincderc");
00033        KGlobal::locale()->insertCatalog("kwin_art_clients");
00034        
00035        groupBox = new KVBox( parent );
00036        
00037        bgAlign = new Q3ButtonGroup( 3, Qt::Horizontal, i18n("Text &Alignment"), groupBox );
00038        bgAlign->setExclusive( true );
00039        bgAlign->setWhatsThis( i18n("Use these buttons to set the alignment of the titlebar caption text.") );
00040        new QRadioButton( i18n("Left"), bgAlign, "AlignLeft" );
00041        QRadioButton *radio2 = new QRadioButton( i18n("Centered"), bgAlign, "AlignHCenter" );
00042        radio2->setChecked( true );
00043        new QRadioButton( i18n("Right"), bgAlign, "AlignRight" );
00044        
00045        cbColorBorder = new QCheckBox( i18n("Draw window frames using &titlebar colors"), groupBox );
00046        cbColorBorder->setWhatsThis( i18n("When selected, the window decoration borders "
00047                                         "are drawn using the titlebar colors. Otherwise, they are "
00048                                         "drawn using normal border colors instead.") );
00049        
00050 //     cbTitlebarButton = new QCheckBox( i18n("Titlebar acts like a &pushbutton when clicked"), groupBox );
00051 //     QWhatsThis::add( cbTitlebarButton, i18n("When selected, this option causes the window titlebar to behave "
00052 //                                        "as if it was a pushbutton when you click it to move the window.") );
00053        
00054        (void) new QLabel( i18n("Tip: If you want the look of the original Motif(tm) Window Manager,\n"
00055                             "click the \"Buttons\" tab above and remove the help\n"
00056                             "and close buttons from the titlebar."), groupBox );
00057        
00058        // Load configuration options
00059        load( conf );
00060 
00061        // Ensure we track user changes properly
00062        connect( cbColorBorder, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
00063 //     connect( cbTitlebarButton, SIGNAL(clicked()), SLOT(slotSelectionChanged()) );
00064        connect( bgAlign, SIGNAL(clicked(int)), SLOT(slotSelectionChanged(int)) );
00065 
00066        // Make the widgets visible in kwindecoration
00067        groupBox->show();
00068 }
00069 
00070 
00071 CdeConfig::~CdeConfig()
00072 {
00073        delete bgAlign;
00074        delete groupBox;
00075        delete cdeConfig;
00076 }
00077 
00078 
00079 void CdeConfig::slotSelectionChanged()
00080 {
00081        emit changed();
00082 }
00083 
00084 void CdeConfig::slotSelectionChanged( int )
00085 {
00086        emit changed();
00087 }
00088 
00089 // Loads the configurable options from the kwinrc config file
00090 // It is passed the open config from kwindecoration to improve efficiency
00091 void CdeConfig::load( KConfig* /*conf*/ )
00092 {
00093        cdeConfig->setGroup("General");
00094 
00095        QString value = cdeConfig->readEntry( "TextAlignment", "AlignHCenter" );
00096        QRadioButton *button = (QRadioButton*)bgAlign->child( (const char *)value.latin1() );
00097        if ( button )
00098            button->setChecked( true );
00099 
00100        bool coloredFrame = cdeConfig->readEntry( "UseTitleBarBorderColors", true );
00101        cbColorBorder->setChecked( coloredFrame );
00102 
00103 //     bool titlebarButton = cdeConfig->readBoolEntry( "TitlebarButtonMode", true );
00104 //     cbTitlebarButton->setChecked( titlebarButton );
00105 }
00106 
00107 
00108 // Saves the configurable options to the kwinrc config file
00109 void CdeConfig::save( KConfig* /*conf*/ )
00110 {
00111        cdeConfig->setGroup("General");
00112 
00113        QRadioButton *button = (QRadioButton*)bgAlign->selected();
00114        if ( button )
00115            cdeConfig->writeEntry( "TextAlignment", QString(button->name()) );
00116 
00117        cdeConfig->writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
00118 //     cdeConfig->writeEntry( "TitlebarButtonMode", cbTitlebarButton->isChecked() );
00119        
00120        // Ensure others trying to read this config get updated
00121        cdeConfig->sync();
00122 }
00123 
00124 
00125 // Sets UI widget defaults which must correspond to style defaults
00126 void CdeConfig::defaults()
00127 {
00128        QRadioButton *button = (QRadioButton*)bgAlign->child( "AlignHCenter" );
00129        if ( button )
00130            button->setChecked( true );
00131 
00132        cbColorBorder->setChecked( true );
00133 //     cbTitlebarButton->setChecked( true );
00134 }
00135 
00136 #include "config.moc"
00137 // vim: ts=4