kaddressbook
configuretableviewdialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QtCore/QString>
00025 #include <QtGui/QCheckBox>
00026 #include <QtGui/QGroupBox>
00027 #include <QtGui/QHBoxLayout>
00028 #include <QtGui/QRadioButton>
00029 #include <QtGui/QVBoxLayout>
00030 #include <QtGui/QWidget>
00031
00032 #include <kconfig.h>
00033 #include <kdeversion.h>
00034 #include <kglobal.h>
00035 #include <kiconloader.h>
00036 #include <kimageio.h>
00037 #include <klineedit.h>
00038 #include <klocale.h>
00039 #include <kurlrequester.h>
00040
00041 #include "configuretableviewdialog.h"
00042
00043 ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
00044 QWidget *parent )
00045 : ViewConfigureWidget( ab, parent )
00046 {
00047 QWidget *page = addPage( i18n( "Look & Feel" ), QString(),
00048 KIconLoader::global()->loadIcon( "configure",
00049 KIconLoader::Panel ) );
00050
00051 mPage = new LookAndFeelPage( page );
00052 }
00053
00054 ConfigureTableViewWidget::~ConfigureTableViewWidget()
00055 {
00056 }
00057
00058 void ConfigureTableViewWidget::restoreSettings( const KConfigGroup &config )
00059 {
00060 ViewConfigureWidget::restoreSettings( config );
00061
00062 mPage->restoreSettings( config );
00063 }
00064
00065 void ConfigureTableViewWidget::saveSettings( KConfigGroup &config )
00066 {
00067 ViewConfigureWidget::saveSettings( config );
00068
00069 mPage->saveSettings( config );
00070 }
00071
00072
00073
00074 LookAndFeelPage::LookAndFeelPage(QWidget *parent)
00075 : QWidget(parent)
00076 {
00077 initGUI();
00078
00079
00080 enableBackgroundToggled(mBackgroundBox->isChecked());
00081 }
00082
00083 void LookAndFeelPage::restoreSettings( const KConfigGroup &config )
00084 {
00085 mAlternateButton->setChecked(config.readEntry("ABackground", true));
00086 mLineButton->setChecked(config.readEntry("SingleLine", false));
00087 mToolTipBox->setChecked(config.readEntry("ToolTips", true));
00088
00089 if (!mAlternateButton->isChecked() && !mLineButton->isChecked())
00090 mNoneButton->setChecked(true);
00091
00092 mBackgroundBox->setChecked(config.readEntry("Background", false));
00093 mBackgroundName->lineEdit()->setText(config.readPathEntry("BackgroundName", QString()));
00094 mIMPresenceBox->setChecked( config.readEntry( "InstantMessagingPresence", false ) );
00095 }
00096
00097 void LookAndFeelPage::saveSettings( KConfigGroup &config )
00098 {
00099 config.writeEntry("ABackground", mAlternateButton->isChecked());
00100 config.writeEntry("SingleLine", mLineButton->isChecked());
00101 config.writeEntry("ToolTips", mToolTipBox->isChecked());
00102 config.writeEntry("Background", mBackgroundBox->isChecked());
00103 config.writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text());
00104 config.writeEntry( "InstantMessagingPresence", mIMPresenceBox->isChecked() );
00105 }
00106
00107 void LookAndFeelPage::initGUI()
00108 {
00109 QVBoxLayout *layout = new QVBoxLayout(this);
00110 layout->setSpacing(KDialog::spacingHint());
00111 layout->setMargin(0);
00112
00113 QGroupBox *group = new QGroupBox(i18n("Row Separator"));
00114 layout->addWidget(group);
00115
00116 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"));
00117 mAlternateButton->setObjectName( "mAlternateButton" );
00118 mLineButton = new QRadioButton(i18n("Single line"));
00119 mLineButton->setObjectName( "mLineButton" );
00120 mNoneButton = new QRadioButton(i18n("None"));
00121 mNoneButton->setObjectName( "mNoneButton" );
00122 QVBoxLayout *updateLayout = new QVBoxLayout;
00123 updateLayout->addWidget(mNoneButton);
00124 updateLayout->addWidget(mLineButton);
00125 updateLayout->addWidget(mAlternateButton);
00126
00127 group->setLayout(updateLayout);
00128
00129
00130
00131 QHBoxLayout *backgroundLayout = new QHBoxLayout();
00132 layout->addLayout(backgroundLayout);
00133
00134 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this );
00135 mBackgroundBox->setObjectName( "mBackgroundBox" );
00136 connect(mBackgroundBox, SIGNAL(toggled(bool)),
00137 SLOT(enableBackgroundToggled(bool)));
00138 backgroundLayout->addWidget(mBackgroundBox);
00139
00140 mBackgroundName = new KUrlRequester(this);
00141 mBackgroundName->setObjectName( "mBackgroundName");
00142 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
00143 KFile::LocalOnly);
00144 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
00145 backgroundLayout->addWidget(mBackgroundName);
00146
00147
00148 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this );
00149 mToolTipBox->setObjectName( "mToolTipBox");
00150 layout->addWidget(mToolTipBox);
00151 mIMPresenceBox = new QCheckBox( i18n( "Show instant messaging presence" ), this );
00152 mIMPresenceBox->setObjectName( "mIMPresenceBox" );
00153 layout->addWidget( mIMPresenceBox );
00154 }
00155
00156 void LookAndFeelPage::enableBackgroundToggled(bool enabled)
00157 {
00158 mBackgroundName->setEnabled(enabled);
00159 }
00160
00161 #include "configuretableviewdialog.moc"