26 #include "preferences.moc"
28 #include <kalarmcal/identities.h>
30 #include <kpimidentities/identity.h>
31 #include <kpimidentities/identitymanager.h>
32 #include <kholidays/holidays.h>
35 #include <kconfiggroup.h>
36 #include <kmessagebox.h>
37 #include <ksystemtimezone.h>
45 using namespace KHolidays;
46 using namespace KAlarmCal;
52 static const char*
TEMP =
"Temp";
56 static const QString
FROM_KMAIL = QLatin1String(
"@KMail");
71 bool Preferences::mUsingDefaults =
false;
72 KTimeZone Preferences::mSystemTimeZone;
73 HolidayRegion* Preferences::mHolidays = 0;
74 QString Preferences::mPreviousVersion;
77 bool Preferences::mAutoStartChangedByUser =
false;
95 Preferences::Preferences()
97 QObject::connect(
this, SIGNAL(base_StartOfDayChanged(QDateTime)), SLOT(startDayChange(QDateTime)));
98 QObject::connect(
this, SIGNAL(base_TimeZoneChanged(QString)), SLOT(timeZoneChange(QString)));
99 QObject::connect(
this, SIGNAL(base_HolidayRegionChanged(QString)), SLOT(holidaysChange(QString)));
100 QObject::connect(
this, SIGNAL(base_WorkTimeChanged(QDateTime,QDateTime,
int)), SLOT(workTimeChange(QDateTime,QDateTime,
int)));
104 mPreviousVersion = version();
105 mPreviousBackend = backend();
125 mSystemTimeZone = KTimeZone();
126 QString timeZone =
self()->mBase_TimeZone;
128 if (!timeZone.isEmpty())
129 tz = KSystemTimeZones::zone(timeZone);
132 if (!mSystemTimeZone.isValid())
133 mSystemTimeZone = KSystemTimeZones::local();
134 tz = mSystemTimeZone;
141 self()->setBase_TimeZone(tz.isValid() ? tz.name() : QString());
144 void Preferences::timeZoneChange(
const QString& zone)
147 emit mInstance->timeZoneChanged(timeZone(
false));
152 QString regionCode =
self()->mBase_HolidayRegion;
153 if (!mHolidays || mHolidays->regionCode() != regionCode)
156 mHolidays =
new HolidayRegion(regionCode);
163 self()->setBase_HolidayRegion(regionCode);
166 void Preferences::holidaysChange(
const QString& regionCode)
168 Q_UNUSED(regionCode);
169 emit mInstance->holidaysChanged(holidays());
174 if (t !=
self()->mBase_StartOfDay.time())
176 self()->setBase_StartOfDay(QDateTime(QDate(1900,1,1), t));
177 emit mInstance->startOfDayChanged(t);
182 void Preferences::startDayChange(
const QDateTime& dt)
184 emit mInstance->startOfDayChanged(dt.time());
189 unsigned days =
self()->base_WorkDays();
190 QBitArray dayBits(7);
191 for (
int i = 0; i < 7; ++i)
192 dayBits.setBit(i, days & (1 << i));
199 for (
int i = 0; i < 7; ++i)
200 if (dayBits.testBit(i))
202 self()->setBase_WorkDays(days);
205 void Preferences::workTimeChange(
const QDateTime& start,
const QDateTime& end,
int days)
207 QBitArray dayBits(7);
208 for (
int i = 0; i < 7; ++i)
211 emit mInstance->workTimeChanged(start.time(), end.time(), dayBits);
216 QString
from =
self()->mBase_EmailFrom;
218 return MAIL_FROM_KMAIL;
220 return MAIL_FROM_SYS_SETTINGS;
221 return MAIL_FROM_ADDR;
229 QString
from =
self()->mBase_EmailFrom;
231 return Identities::identityManager()->defaultIdentity().fullEmailAddr();
242 case MAIL_FROM_KMAIL: out =
FROM_KMAIL;
break;
244 case MAIL_FROM_ADDR: out = address;
break;
247 self()->setBase_EmailFrom(out);
252 QString
from =
self()->mBase_EmailBccAddress;
254 return MAIL_FROM_SYS_SETTINGS;
255 return MAIL_FROM_ADDR;
260 QString
from =
self()->mBase_EmailBccAddress;
274 if (useSystemSettings)
278 self()->setBase_EmailBccAddress(out);
294 QObject::connect(
self(), signal, receiver, member);
301 void Preferences::setNotify(
const QString& messageID,
bool notify)
313 bool Preferences::notifying(
const QString& messageID)
330 QString cmd = cmdline;
331 if (cmdline.isEmpty())
334 QChar quote = cmdline[0];
335 char q = quote.toLatin1();
336 bool quoted = (q ==
'"' || q ==
'\'');
338 cmd = cmdline.mid(1);
340 for (
int i = 0, count = cmd.length(); i < count; ++i)
342 switch (cmd[i].toLatin1())
366 group.writePathEntry(
TEMP, cmd);
367 cmd = group.readEntry(
TEMP, QString());
371 group.writeEntry(
TEMP, cmd);
372 cmd = group.readPathEntry(
TEMP, QString());
374 group.deleteEntry(
TEMP);
376 return quote + cmd + params;
static void setEmailAddress(MailFrom, const QString &address)
static void setCmdXTermCommand(const QString &cmd)
static const char * GENERAL_SECTION
static QString controlCentreAddress()
static void setStartOfDay(const QTime &)
const bool default_confirmAlarmDeletion
static void setTimeZone(const KTimeZone &)
static const QString FROM_KMAIL
static void setAskAutoStart(bool yes)
const bool default_quitWarn
static QString cmdXTermCommand()
static void setHolidayRegion(const QString ®ionCode)
static MailFrom emailBccFrom()
static KTimeZone timeZone(bool reload=false)
static const QLatin1String QUIT_WARN
static const QLatin1String ASK_AUTO_START
static QString translateXTermPath(const QString &cmdline, bool write)
static void setContinueDefault(const QString &dontAskAgainName, ButtonCode defaultButton)
static const QLatin1String EMAIL_QUEUED_NOTIFY
static void connect(const char *signal, const QObject *receiver, const char *member)
static bool shouldBeShownContinue(const QString &dontShowAgainName)
const bool default_emailQueuedNotify
static const KHolidays::HolidayRegion & holidays()
static QBitArray workDays()
static const QLatin1String CONFIRM_ALARM_DELETION
static void setWorkDays(const QBitArray &)
static QString emailBccAddress()
static const QString FROM_SYS_SETTINGS
static QString emailAddress()
static void saveDontShowAgainYesNo(const QString &dontShowAgainName, bool dontShow=true, ButtonCode result=No)
static void saveDontShowAgainContinue(const QString &dontShowAgainName, bool dontShow=true)
static bool setDefaultShouldBeShownContinue(const QString &dontShowAgainName, bool defaultShow)
static void setEmailBccAddress(bool useSystemSettings, const QString &address)
static Preferences * self()
static bool emailBccUseSystemSettings()
static MailFrom emailFrom()