-rw-r--r-- | libkdepim/kcmconfigs/kdepimconfigwidget.cpp | 26 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 6 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp index fbfbc45..93538ec 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp @@ -87,116 +87,125 @@ $Id$ #include "kdepimconfigwidget.h" #include <kprefs.h> #include <kmessagebox.h> KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) : KPrefsWidget(prefs, parent, name ) { mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); setupLocaleTab(); setupLocaleDateTab(); setupTimeZoneTab(); setupExternalAppTab(); setupStoreTab(); setupBackupTab(); } void KDEPIMConfigWidget::showTimeZoneTab() { tabWidget->setCurrentPage ( 3 ) ; } void KDEPIMConfigWidget::setupBackupTab() { QVBox *colorPage = new QVBox( this ); tabWidget->addTab( colorPage, i18n( "Backup" ) ); QWidget* topFrame = new QWidget( colorPage ); QVBoxLayout *topLayout = new QVBoxLayout(topFrame); KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); topLayout->addWidget((QWidget*)sb->checkBox()); QWidget* bupFrame = new QWidget( topFrame ); topLayout->addWidget((bupFrame)); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); sb = addWidBool(i18n("Use standard backup dir"), - &(KPimGlobalPrefs::instance()->mBackupEnabled),bupFrame); + &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); bupLayout->addWidget((QWidget*)sb->checkBox()); mBackupUrl = new KURLRequester( bupFrame ); mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); bupLayout->addWidget( mBackupUrl ); - + mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); + bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); QHBox *dummy = new QHBox(bupFrame); new QLabel(i18n("Number of Backups:"),dummy); mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); dummy = new QHBox(bupFrame); new QLabel(i18n("Make backup every "),dummy); mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); new QLabel(i18n(" days"),dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); + QString localKdeDir; + localKdeDir = readEnvPath("LOCALMICROKDEHOME"); + if ( ! localKdeDir.isEmpty() ) { + sb->checkBox()->setEnabled( false ); + sb->checkBox()->setChecked( true ); + mBackupUrl->setEnabled( false ); + KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; + } } void KDEPIMConfigWidget::setupStoreTab() { QVBox *colorPage = new QVBox( this ); tabWidget->addTab( colorPage, i18n( "Colors" ) ); QWidget* cw = new QWidget( colorPage ); KPrefsWidColor *holidayColor = addWidColor(i18n("Alternating background of list views"), &(KPimGlobalPrefs::instance()->mAlternateColor),cw); QHBoxLayout *topLayout = new QHBoxLayout(cw); topLayout->addWidget(holidayColor->label()); topLayout->addWidget( (QWidget* )holidayColor->button()); QVBox *storePage = new QVBox( this ); new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); mStoreUrl = new KURLRequester( storePage ); mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); #ifdef DESKTOP_VERSION QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( fi.exists() ) { KConfig cfg ( confFile ); cfg.setGroup("Global"); QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); if ( localKdeDir != "x_x_x" ) { mStoreUrl->setURL( localKdeDir ); qDebug("Reading config from %s ", confFile.latin1()); } } #endif new QLabel( i18n("New dirs are created automatically"), storePage ); QHBox *bb = new QHBox( storePage ); QPushButton * pb; if ( QApplication::desktop()->width() < 640 ) pb = new QPushButton ( i18n("Save"), bb ); else pb = new QPushButton ( i18n("Save settings"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); pb = new QPushButton ( i18n("Save standard"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); #ifdef DESKTOP_VERSION pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); #endif @@ -761,156 +770,163 @@ void KDEPIMConfigWidget::updateClientWidgets() enabled = true; } mChannel->setReadOnly(readonly); mMessage->setReadOnly(readonly); mParameters->setReadOnly(readonly); mMessage2->setReadOnly(readonly); mParameters2->setReadOnly(readonly); mChannel->setEnabled(enabled); mMessage->setEnabled(enabled); mParameters->setEnabled(enabled); mMessage2->setEnabled(enabled); mParameters2->setEnabled(enabled); mClient->setCurrentItem(mCurrentClient); // enable/disable the extra message/parameter field if (mCurrentApp == ExternalAppHandler::EMAIL) { } else { mMessage2->setText( "" ); mParameters2->setText( "" ); } if (enabled == true) { mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); } blockSignals( blocked ); } void KDEPIMConfigWidget::usrReadConfig() { KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); bool blocked = signalsBlocked(); blockSignals( true ); + if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir ) + mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); + else + mBackupUrl->setURL(prefs->mBackupDatadir); + mBackupNumbersSpin->setValue( prefs->mBackupNumbers ); + mBackupDayCountSpin->setValue( prefs->mBackupDayCount); + QString dummy = prefs->mUserDateFormatLong; mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); dummy = prefs->mUserDateFormatShort; mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); QDate current ( 2001, 1,1); mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); - - - mEmailClient = prefs->mEmailClient; mEmailOtherChannel = prefs->mEmailOtherChannel; mEmailOtherMessage = prefs->mEmailOtherMessage; mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; mEmailOtherMessage2 = prefs->mEmailOtherMessage2; mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; mPhoneClient = prefs->mPhoneClient; mPhoneOtherChannel = prefs->mPhoneOtherChannel; mPhoneOtherMessage = prefs->mPhoneOtherMessage; mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; mFaxClient = prefs->mFaxClient; mFaxOtherChannel = prefs->mFaxOtherChannel; mFaxOtherMessage = prefs->mFaxOtherMessage; mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; mSMSClient = prefs->mSMSClient; mSMSOtherChannel = prefs->mSMSOtherChannel; mSMSOtherMessage = prefs->mSMSOtherMessage; mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; mPagerClient = prefs->mPagerClient; mPagerOtherChannel = prefs->mPagerOtherChannel; mPagerOtherMessage = prefs->mPagerOtherMessage; mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; mSipClient = prefs->mSipClient; mSipOtherChannel = prefs->mSipOtherChannel; mSipOtherMessage = prefs->mSipOtherMessage; mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; mCurrentApp = ExternalAppHandler::EMAIL; mCurrentClient = mEmailClient; updateClientWidgets(); blockSignals( blocked ); } void KDEPIMConfigWidget::usrWriteConfig() { KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); saveEditFieldSettings(); + prefs->mBackupNumbers = mBackupNumbersSpin->value(); + prefs->mBackupDayCount = mBackupDayCountSpin->value(); + prefs->mBackupDatadir = mBackupUrl->url(); prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); prefs->mTimeZoneId = mTimeZoneCombo->currentText(); QDate date; date = mStartDateSavingEdit->date(); int sub = 0; if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) sub = 1; prefs->mDaylightsavingStart = date.dayOfYear()-sub; date = mEndDateSavingEdit->date(); if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) sub = 1; else sub = 0; prefs->mDaylightsavingEnd = date.dayOfYear()-sub; prefs->mEmailClient = mEmailClient; prefs->mEmailOtherChannel = mEmailOtherChannel; prefs->mEmailOtherMessage = mEmailOtherMessage; prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; prefs->mEmailOtherMessage2 = mEmailOtherMessage2; prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; prefs->mPhoneClient = mPhoneClient; prefs->mPhoneOtherChannel = mPhoneOtherChannel; prefs->mPhoneOtherMessage = mPhoneOtherMessage; prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; prefs->mFaxClient = mFaxClient; prefs->mFaxOtherChannel = mFaxOtherChannel; prefs->mFaxOtherMessage = mFaxOtherMessage; prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; prefs->mSMSClient = mSMSClient; prefs->mSMSOtherChannel = mSMSOtherChannel; prefs->mSMSOtherMessage = mSMSOtherMessage; prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; prefs->mPagerClient = mPagerClient; prefs->mPagerOtherChannel = mPagerOtherChannel; prefs->mPagerOtherMessage = mPagerOtherMessage; prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; prefs->mSipClient = mSipClient; diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 90321b2..9c28425 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp @@ -155,69 +155,75 @@ void KPimGlobalPrefs::setGlobalConfig() int br = 0; int nbr; nbr = text.find ( "},", br ); line = text.mid( br, nbr - br ); br = nbr+1; int se, ee, st, et; mLocaleDict = new QDict<QString>; mLocaleDict->setAutoDelete( true ); QString end = "{ \"\",\"\" }"; while ( (line != end) && (br > 1) ) { //qDebug("%d *%s* ", br, line.latin1()); se = line.find("\"")+1; et = line.findRev("\"",-1); ee = line.find("\",\""); st = ee+3; we = line.mid( se, ee-se ); if ( mPreferredLanguage == 4 ) wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); else wt = line.mid( st, et-st ); //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); mLocaleDict->insert( we, new QString (wt) ); nbr = text.find ( "}", br ); line = text.mid( br, nbr - br ); br = nbr+1; } //qDebug("end *%s* ", end.latin1()); setLocaleDict( mLocaleDict ); } else { qDebug("KO: Cannot find translation file %s",fileName.latin1() ); } } } KGlobal::locale()->setHore24Format( !mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); KGlobal::locale()->setLanguage( mPreferredLanguage ); QString dummy = mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, mDaylightsavingStart, mDaylightsavingEnd ); KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); + QString localKdeDir; + localKdeDir = readEnvPath("LOCALMICROKDEHOME"); + if ( ! localKdeDir.isEmpty() ) { + mBackupUseDefaultDir = true; + mBackupDatadir = KGlobalSettings::backupDataDir(); + } } KPimGlobalPrefs::~KPimGlobalPrefs() { if (sInstance == this) sInstance = staticDeleterGP.setObject(0); else qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); if ( mLocaleDict ) delete mLocaleDict; } KPimGlobalPrefs *KPimGlobalPrefs::instance() { if ( !sInstance ) { sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); sInstance->readConfig(); } return sInstance; } diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index d68ccb6..714d1b7 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -5,78 +5,81 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include "kpimprefs.h" KPimPrefs::KPimPrefs( const QString &name ) : KPrefs( name ) { #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif setCurrentGroup("SyncOptions"); addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); + + setCurrentGroup("BackupDate"); + addItemInt("LastBackupDate",&mLastBackupDate,0); } KPimPrefs::~KPimPrefs() { } void KPimPrefs::usrSetDefaults() { setCategoryDefaults(); } void KPimPrefs::usrReadConfig() { config()->setGroup("General"); mCustomCategories = config()->readListEntry("Custom Categories"); if (mCustomCategories.isEmpty()) setCategoryDefaults(); } void KPimPrefs::usrWriteConfig() { config()->setGroup("General"); config()->writeEntry("Custom Categories",mCustomCategories); } void KPimPrefs::setCategoryDefaults() { // empty implementation } diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index c177bd6..bf80042 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h @@ -16,58 +16,59 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KPIMPREFS_H #define KPIMPREFS_H #include <qstringlist.h> #include "kprefs.h" class KPimPrefs : public KPrefs { public: KPimPrefs( const QString &name = QString::null ); virtual ~KPimPrefs(); /** Set preferences to default values */ void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); public: QStringList mCustomCategories; QString mPassiveSyncPort; QString mPassiveSyncPw; bool mPassiveSyncWithDesktop; bool mPassiveSyncAutoStart; int mRingSyncAlgoPrefs; QString mLastSyncedLocalFile; + int mLastBackupDate; protected: virtual void setCategoryDefaults(); }; #endif |