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 <qstring.h>
00025 #include <qwidget.h>
00026 #include <qlayout.h>
00027 #include <qradiobutton.h>
00028 #include <qcheckbox.h>
00029 #include <qvbox.h>
00030 #include <qbuttongroup.h>
00031
00032 #include <kdeversion.h>
00033 #include <kglobal.h>
00034 #include <klocale.h>
00035 #include <klineedit.h>
00036 #include <kurlrequester.h>
00037 #include <kiconloader.h>
00038 #include <kimageio.h>
00039 #include <kconfig.h>
00040
00041 #include "configuretableviewdialog.h"
00042
00043 ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
00044 QWidget *parent,
00045 const char *name )
00046 : ViewConfigureWidget( ab, parent, name )
00047 {
00048 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
00049 KGlobal::iconLoader()->loadIcon( "looknfeel",
00050 KIcon::Panel ) );
00051
00052 mPage = new LookAndFeelPage( page );
00053 }
00054
00055 ConfigureTableViewWidget::~ConfigureTableViewWidget()
00056 {
00057 }
00058
00059 void ConfigureTableViewWidget::restoreSettings( KConfig *config )
00060 {
00061 ViewConfigureWidget::restoreSettings( config );
00062
00063 mPage->restoreSettings( config );
00064 }
00065
00066 void ConfigureTableViewWidget::saveSettings( KConfig *config )
00067 {
00068 ViewConfigureWidget::saveSettings( config );
00069
00070 mPage->saveSettings( config );
00071 }
00072
00073
00074
00075 LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
00076 : QWidget(parent, name)
00077 {
00078 initGUI();
00079
00080
00081 enableBackgroundToggled(mBackgroundBox->isChecked());
00082 }
00083
00084 void LookAndFeelPage::restoreSettings( KConfig *config )
00085 {
00086 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
00087 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
00088 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
00089
00090 if (!mAlternateButton->isChecked() && !mLineButton->isChecked())
00091 mNoneButton->setChecked(true);
00092
00093 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
00094 mBackgroundName->lineEdit()->setText(config->readPathEntry("BackgroundName"));
00095 #if KDE_IS_VERSION(3,2,90)
00096 mIMPresenceBox->setChecked( config->readBoolEntry( "InstantMessagingPresence", false ) );
00097 #endif
00098 }
00099
00100 void LookAndFeelPage::saveSettings( KConfig *config )
00101 {
00102 config->writeEntry("ABackground", mAlternateButton->isChecked());
00103 config->writeEntry("SingleLine", mLineButton->isChecked());
00104 config->writeEntry("ToolTips", mToolTipBox->isChecked());
00105 config->writeEntry("Background", mBackgroundBox->isChecked());
00106 config->writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text());
00107 #if KDE_IS_VERSION(3,2,90)
00108 config->writeEntry( "InstantMessagingPresence", mIMPresenceBox->isChecked() );
00109 #endif
00110 }
00111
00112 void LookAndFeelPage::initGUI()
00113 {
00114 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint());
00115
00116 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal,
00117 i18n("Row Separator"), this);
00118 layout->addWidget(group);
00119
00120 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
00121 group, "mAlternateButton");
00122 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
00123 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
00124
00125
00126 QHBoxLayout *backgroundLayout = new QHBoxLayout();
00127 layout->addLayout(backgroundLayout);
00128
00129 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this,
00130 "mBackgroundBox");
00131 connect(mBackgroundBox, SIGNAL(toggled(bool)),
00132 SLOT(enableBackgroundToggled(bool)));
00133 backgroundLayout->addWidget(mBackgroundBox);
00134
00135 mBackgroundName = new KURLRequester(this, "mBackgroundName");
00136 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
00137 KFile::LocalOnly);
00138 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
00139 backgroundLayout->addWidget(mBackgroundName);
00140
00141
00142 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this,
00143 "mToolTipBox");
00144 layout->addWidget(mToolTipBox);
00145 #if KDE_IS_VERSION(3,2,90)
00146 mIMPresenceBox = new QCheckBox( i18n( "Show instant messaging presence" ), this, "mIMPresenceBox" );
00147 layout->addWidget( mIMPresenceBox );
00148 #endif
00149 }
00150
00151 void LookAndFeelPage::enableBackgroundToggled(bool enabled)
00152 {
00153 mBackgroundName->setEnabled(enabled);
00154 }
00155
00156 #include "configuretableviewdialog.moc"