00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "configgeneral.h"
00019
00020 K_PLUGIN_FACTORY( ConfigGeneralFactory, registerPlugin<ConfigGeneral>(); )
00021 K_EXPORT_PLUGIN( ConfigGeneralFactory( "kcm_kshowmailconfiggeneral" ) )
00022
00023 ConfigGeneral::ConfigGeneral( QWidget * parent, const QVariantList & args )
00024 : KCModule( ConfigGeneralFactory::componentData(), parent, args )
00025 {
00026
00027
00028
00029
00030 QVBoxLayout* layMain = new QVBoxLayout( this );
00031
00032
00033 QGridLayout* layMainTop = new QGridLayout();
00034 layMainTop->setMargin( 20 );
00035 layMain->addLayout( layMainTop );
00036
00037
00038 QGroupBox* gboxAutomaticRefresh = new QGroupBox( i18n( "&Automatic Refresh" ), this );
00039 layMain->addWidget( gboxAutomaticRefresh );
00040
00041
00042 QGridLayout* layAutoRefresh = new QGridLayout();
00043 gboxAutomaticRefresh->setLayout( layAutoRefresh );
00044
00045
00046 QGroupBox* gBoxServerConnect = new QGroupBox( i18n( "Server Connect"), this );
00047 layMain->addWidget( gBoxServerConnect );
00048 QGridLayout* layServerConnect = new QGridLayout();
00049 gBoxServerConnect->setLayout( layServerConnect );
00050
00051
00052 chkConfirmClose = new QCheckBox( i18n( "Confirm Close" ), this );
00053 chkConfirmClose->setToolTip( i18n( "If checked, window close must be confirmed" ) );
00054 layMainTop->addWidget( chkConfirmClose, 0, 0 );
00055
00056 chkConfirmDelete = new QCheckBox( i18n( "Confirm delete" ), this );
00057 chkConfirmDelete->setToolTip( i18n( "If checked, message delete must be confirmed" ) );
00058 layMainTop->addWidget( chkConfirmDelete, 0, 1 );
00059
00060 chkStartMinimized = new QCheckBox( i18n( "Start Minimi&zed" ), this );
00061 chkStartMinimized->setToolTip( i18n( "Application is started as icon" ) );
00062 layMainTop->addWidget( chkStartMinimized, 1, 0 );
00063
00064 chkCloseToTray = new QCheckBox( i18n( "Close to tray" ), this );
00065 chkCloseToTray->setToolTip( i18n( "Close button leaves the application running in tray" ) );
00066 layMainTop->addWidget( chkCloseToTray, 1, 1 );
00067
00068 chkKeepNew = new QCheckBox( i18n( "&Keep mail as new" ), this );
00069 chkKeepNew->setToolTip( i18n( "Keep mail as new until termination" ) );
00070 layMainTop->addWidget( chkKeepNew, 2, 0 );
00071
00072
00073
00074 chkAutomaticRefresh = new QCheckBox( i18n( "Automatic refresh" ) );
00075 chkAutomaticRefresh->setToolTip( i18n( "Run refreshes of the mail list automatically") );
00076 layAutoRefresh->addWidget( chkAutomaticRefresh, 0, 0 );
00077 connect( chkAutomaticRefresh, SIGNAL( toggled( bool) ), this, SLOT( slotAutomaticRefreshChanged( bool ) ) );
00078
00079 lblTimerInitial = new QLabel( i18n( "Initial Timer:" ), gboxAutomaticRefresh );
00080 spbInitial = new QSpinBox( gboxAutomaticRefresh );
00081 spbInitial->setMinimum( 0 );
00082 spbInitial->setMaximum( 99999 );
00083 spbInitial->setSuffix( i18n( " Seconds") );
00084 spbInitial->setToolTip( i18n( "Seconds until first automatic refresh (0 = it refreshes immediately)" ) );
00085 lblTimerInitial->setToolTip( i18n( "Seconds until first automatic refresh (0 = it refreshes immediately)" ) );
00086 layAutoRefresh->addWidget( lblTimerInitial, 1, 0 );
00087 layAutoRefresh->addWidget( spbInitial, 1, 1 );
00088
00089 lblTimerInterval = new QLabel( i18n( "Interval Timer:" ), gboxAutomaticRefresh );
00090 spbInterval = new QSpinBox( gboxAutomaticRefresh );
00091 spbInterval->setMinimum( 1 );
00092 spbInterval->setMaximum( 99999 );
00093 spbInterval->setSuffix( i18n( " Minutes") );
00094 spbInterval->setToolTip( i18n( "Minutes between automatic refresh (0 = no automatic)" ) );
00095 lblTimerInterval->setToolTip( i18n( "Minutes between automatic refresh (0 = no automatic)" ) );
00096 layAutoRefresh->addWidget( lblTimerInterval, 2, 0 );
00097 layAutoRefresh->addWidget( spbInterval, 2, 1 );
00098
00099
00100 chkShowConnectionErrors = new QCheckBox( i18n( "Show Connection Errors" ), gBoxServerConnect );
00101 chkShowConnectionErrors->setToolTip( i18n( "If a connection error occurs (e.g. unknown server), an error message will be shown." ) );
00102 layServerConnect->addWidget( chkShowConnectionErrors, 0, 0 );
00103
00104
00105 QLabel* lblTimerTimeout = new QLabel( i18n( "Timeout:" ), gBoxServerConnect );
00106 spbTimeout = new QSpinBox( gBoxServerConnect );
00107 spbTimeout->setMinimum( MINIMUM_TIMEOUT_TIME );
00108 spbTimeout->setMaximum( 99999 );
00109 spbTimeout->setSuffix( i18n( " Seconds" ) );
00110 spbTimeout->setToolTip( i18n( "Seconds until a server connect will be canceled" ) );
00111 lblTimerTimeout->setToolTip( i18n( "Seconds until a server connect will be canceled" ) );
00112 layServerConnect->addWidget( lblTimerTimeout, 1, 0 );
00113 layServerConnect->addWidget( spbTimeout, 1, 1 );
00114
00115
00116
00117 connect( chkConfirmClose, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00118 connect( chkConfirmDelete, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00119 connect( chkStartMinimized, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00120 connect( chkCloseToTray, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00121 connect( chkShowConnectionErrors, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00122 connect( chkKeepNew, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00123 connect( spbInitial, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00124 connect( spbInterval, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00125 connect( spbTimeout, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00126 connect( chkAutomaticRefresh, SIGNAL( toggled( bool ) ), this, SLOT( slotChanged() ) );
00127
00128
00129
00130 config = KGlobal::config();
00131
00132
00133 load();
00134
00135 }
00136
00137 ConfigGeneral::~ConfigGeneral()
00138 {
00139 }
00140
00141 void ConfigGeneral::load( )
00142 {
00143 KConfigGroup* configGeneral = new KConfigGroup( config, CONFIG_GROUP_GENERAL );
00144
00145 chkConfirmClose->setChecked( configGeneral->readEntry( CONFIG_ENTRY_CONFIRM_CLOSE, DEFAULT_CONFIRM_CLOSE ) );
00146 chkConfirmDelete->setChecked( configGeneral->readEntry( CONFIG_ENTRY_CONFIRM_DELETE, DEFAULT_CONFIRM_DELETE ) );
00147 chkStartMinimized->setChecked( configGeneral->readEntry( CONFIG_ENTRY_START_MINIMIZED, DEFAULT_START_MINIMIZED ) );
00148 chkCloseToTray->setChecked( configGeneral->readEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, DEFAULT_CLOSE_TO_TRAY ) );
00149 chkShowConnectionErrors->setChecked( configGeneral->readEntry( CONFIG_ENTRY_SHOW_CONNECTION_ERRORS, DEFAULT_SHOW_CONNECTION_ERRORS ) );
00150 chkKeepNew->setChecked( configGeneral->readEntry( CONFIG_ENTRY_KEEP_NEW, DEFAULT_KEEP_NEW ) );
00151
00152
00153 chkAutomaticRefresh->setChecked( configGeneral->readEntry( CONFIG_ENTRY_AUTO_REFRESH, DEFAULT_AUTO_REFRESH ) );
00154 slotAutomaticRefreshChanged( chkAutomaticRefresh->isChecked() );
00155 spbInitial->setValue( configGeneral->readEntry( CONFIG_ENTRY_INITIAL_TIME, DEFAULT_INITIAL_TIME ) );
00156 spbInterval->setValue( configGeneral->readEntry( CONFIG_ENTRY_INTERVAL_TIME, DEFAULT_INTERVAL_TIME) );
00157 spbTimeout->setValue( configGeneral->readEntry( CONFIG_ENTRY_TIMEOUT_TIME, DEFAULT_TIMEOUT_TIME) );
00158 }
00159
00160 void ConfigGeneral::defaults( )
00161 {
00162 chkConfirmClose->setChecked( DEFAULT_CONFIRM_CLOSE );
00163 chkConfirmDelete->setChecked( DEFAULT_CONFIRM_DELETE );
00164 chkStartMinimized->setChecked( DEFAULT_START_MINIMIZED );
00165 chkCloseToTray->setChecked( DEFAULT_CLOSE_TO_TRAY );
00166 chkShowConnectionErrors->setChecked( DEFAULT_SHOW_CONNECTION_ERRORS );
00167 chkKeepNew->setChecked( DEFAULT_KEEP_NEW );
00168
00169 chkAutomaticRefresh->setChecked( DEFAULT_AUTO_REFRESH );
00170 slotAutomaticRefreshChanged( chkAutomaticRefresh->isChecked() );
00171 spbInitial->setValue( DEFAULT_INITIAL_TIME );
00172 spbInterval->setValue( DEFAULT_INTERVAL_TIME );
00173 spbTimeout->setValue( DEFAULT_TIMEOUT_TIME );
00174 }
00175
00176 void ConfigGeneral::save( )
00177 {
00178 KConfigGroup* configGeneral = new KConfigGroup( config, CONFIG_GROUP_GENERAL );
00179
00180 configGeneral->writeEntry( CONFIG_ENTRY_CONFIRM_CLOSE, chkConfirmClose->isChecked() );
00181 configGeneral->writeEntry( CONFIG_ENTRY_CONFIRM_DELETE, chkConfirmDelete->isChecked() );
00182 configGeneral->writeEntry( CONFIG_ENTRY_START_MINIMIZED, chkStartMinimized->isChecked() );
00183 configGeneral->writeEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, chkCloseToTray->isChecked() );
00184 configGeneral->writeEntry( CONFIG_ENTRY_SHOW_CONNECTION_ERRORS, chkShowConnectionErrors->isChecked() );
00185 configGeneral->writeEntry( CONFIG_ENTRY_KEEP_NEW, chkKeepNew->isChecked() );
00186 configGeneral->writeEntry( CONFIG_ENTRY_INITIAL_TIME, spbInitial->value() );
00187 configGeneral->writeEntry( CONFIG_ENTRY_INTERVAL_TIME, spbInterval->value() );
00188 configGeneral->writeEntry( CONFIG_ENTRY_TIMEOUT_TIME, spbTimeout->value() );
00189 configGeneral->writeEntry( CONFIG_ENTRY_AUTO_REFRESH, chkAutomaticRefresh->isChecked() );
00190
00191
00192 config->sync();
00193 }
00194
00195 void ConfigGeneral::slotChanged( )
00196 {
00197 KCModule::changed();
00198 }
00199
00200 void ConfigGeneral::slotAutomaticRefreshChanged( bool checked ) {
00201
00202 spbInitial->setEnabled( checked );
00203 spbInterval->setEnabled( checked );
00204 lblTimerInitial->setEnabled( checked );
00205 lblTimerInterval->setEnabled( checked );
00206 }
00207
00208 #include "configgeneral.moc"