SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / korganizer / prefs / koprefsdialog.cpp
blob83cacb4a6276d8c768411352e7670c34004bccfe
1 /*
2 This file is part of KOrganizer.
4 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution.
26 #include "koprefsdialog.h"
27 #include "widgets/kitemiconcheckcombo.h"
28 #include "kocore.h"
29 #include "koglobals.h"
30 #include "koprefs.h"
31 #include "ui_kogroupwareprefspage.h"
32 #include <QDialog>
34 #include <CalendarSupport/KCalPrefs>
35 #include <CalendarSupport/CategoryConfig>
37 #include <IncidenceEditor/IncidenceEditorSettings>
38 #include <Libkdepim/TagSelectionCombo>
39 #include <libkdepim/tagwidgets.h>
41 #include <AkonadiCore/AgentFilterProxyModel>
42 #include <AkonadiCore/AgentInstanceCreateJob>
43 #include <AkonadiCore/AgentManager>
44 #include <AkonadiCore/EntityTreeModel>
45 #include <AkonadiWidgets/AgentTypeDialog>
46 #include <AkonadiWidgets/CollectionComboBox>
47 #include <akonadi/calendar/calendarsettings.h>
49 #include <KCalCore/Event>
50 #include <KCalCore/Journal>
52 #include <KHolidays/HolidayRegion>
54 #include <MailTransport/TransportManagementWidget>
56 #include "AkonadiWidgets/ManageAccountWidget"
58 #include <KColorButton>
59 #include <KComboBox>
60 #include <QHBoxLayout>
61 #include <QSpinBox>
62 #include <KMessageBox>
63 #include <KService>
65 #include <QTabWidget>
66 #include <KTimeComboBox>
67 #include <KUrlRequester>
68 #include <KWindowSystem>
69 #include "korganizer_debug.h"
70 #include <QIcon>
71 #include <QPushButton>
73 #include <QCheckBox>
74 #include <QFormLayout>
75 #include <QGridLayout>
76 #include <QGroupBox>
77 #include <QLabel>
78 #include <QListWidget>
79 #include <QRadioButton>
80 #include <QTimeEdit>
81 #include <QTreeWidget>
82 #include <QVBoxLayout>
83 #include <KLocalizedString>
84 #include <QStandardPaths>
85 #include <QLocale>
87 KOPrefsDialogMain::KOPrefsDialogMain(QWidget *parent)
88 : KPrefsModule(KOPrefs::instance(), parent)
90 QBoxLayout *topTopLayout = new QVBoxLayout(this);
91 QTabWidget *tabWidget = new QTabWidget(this);
92 topTopLayout->addWidget(tabWidget);
94 // Personal Settings
95 QWidget *personalFrame = new QWidget(this);
96 QVBoxLayout *personalLayout = new QVBoxLayout(personalFrame);
97 tabWidget->addTab(personalFrame, QIcon::fromTheme(QStringLiteral("preferences-desktop-personal")),
98 i18nc("@title:tab personal settings", "Personal"));
100 KPIM::KPrefsWidBool *emailControlCenter =
101 addWidBool(CalendarSupport::KCalPrefs::instance()->emailControlCenterItem(), personalFrame);
102 connect(emailControlCenter->checkBox(), &QAbstractButton::toggled, this, &KOPrefsDialogMain::toggleEmailSettings);
103 personalLayout->addWidget(emailControlCenter->checkBox());
105 mUserEmailSettings =
106 new QGroupBox(i18nc("@title:group email settings", "Email Settings"), personalFrame);
108 personalLayout->addWidget(mUserEmailSettings);
109 QFormLayout *emailSettingsLayout = new QFormLayout(mUserEmailSettings);
110 KPIM::KPrefsWidString *s =
111 addWidString(CalendarSupport::KCalPrefs::instance()->userNameItem(), mUserEmailSettings);
112 emailSettingsLayout->addRow(s->label(), s->lineEdit());
114 s = addWidString(CalendarSupport::KCalPrefs::instance()->userEmailItem(), mUserEmailSettings);
115 emailSettingsLayout->addRow(s->label(), s->lineEdit());
117 KPIM::KPrefsWidRadios *defaultEmailAttachMethod =
118 addWidRadios(
119 IncidenceEditorNG::IncidenceEditorSettings::self()->defaultEmailAttachMethodItem(), personalFrame);
120 personalLayout->addWidget(defaultEmailAttachMethod->groupBox());
121 personalLayout->addStretch(1);
123 // Save Settings
124 QFrame *saveFrame = new QFrame(this);
125 tabWidget->addTab(saveFrame, QIcon::fromTheme(QStringLiteral("document-save")),
126 i18nc("@title:tab", "Save"));
127 QVBoxLayout *saveLayout = new QVBoxLayout(saveFrame);
129 QGroupBox *saveGroupBox =
130 new QGroupBox(i18nc("@title:group", "Exporting Calendar"), saveFrame);
131 saveLayout->addWidget(saveGroupBox);
132 QVBoxLayout *saveGroupLayout = new QVBoxLayout;
133 saveGroupBox->setLayout(saveGroupLayout);
135 KPIM::KPrefsWidBool *autoExportHTML =
136 addWidBool(KOPrefs::instance()->autoExportItem(), saveGroupBox);
137 saveGroupLayout->addWidget(autoExportHTML->checkBox());
139 QBoxLayout *intervalLayout = new QHBoxLayout;
140 saveGroupLayout->addLayout(intervalLayout);
142 KPIM::KPrefsWidInt *autoExportInterval =
143 addWidInt(KOPrefs::instance()->autoExportIntervalItem(), saveGroupBox);
144 connect(autoExportHTML->checkBox(), &QAbstractButton::toggled,
145 autoExportInterval->label(), &QWidget::setEnabled);
146 connect(autoExportHTML->checkBox(), &QAbstractButton::toggled,
147 autoExportInterval->spinBox(), &QWidget::setEnabled);
148 intervalLayout->addWidget(autoExportInterval->label());
149 intervalLayout->addWidget(autoExportInterval->spinBox());
151 KPIM::KPrefsWidBool *confirmItem =
152 addWidBool(KOPrefs::instance()->confirmItem(), saveFrame);
153 saveLayout->addWidget(confirmItem->checkBox());
154 KPIM::KPrefsWidRadios *destinationItem =
155 addWidRadios(KOPrefs::instance()->destinationItem(), saveFrame);
156 autoExportInterval->spinBox()->setEnabled(autoExportHTML->checkBox()->isChecked());
157 autoExportInterval->label()->setEnabled(autoExportHTML->checkBox()->isChecked());
159 saveLayout->addWidget(destinationItem->groupBox());
160 saveLayout->addStretch(1);
162 // System Tray Settings
163 QFrame *systrayFrame = new QFrame(this);
164 QVBoxLayout *systrayLayout = new QVBoxLayout(systrayFrame);
165 tabWidget->addTab(systrayFrame, QIcon::fromTheme(QStringLiteral("preferences-other")),
166 i18nc("@title:tab systray settings", "System Tray"));
168 QGroupBox *systrayGroupBox =
169 new QGroupBox(i18nc("@title:group", "Show/Hide Options"), systrayFrame);
170 systrayLayout->addWidget(systrayGroupBox);
171 QVBoxLayout *systrayGroupLayout = new QVBoxLayout;
172 systrayGroupBox->setLayout(systrayGroupLayout);
174 KPIM::KPrefsWidBool *showReminderDaemonItem =
175 addWidBool(KOPrefs::instance()->showReminderDaemonItem(), systrayGroupBox);
176 systrayGroupLayout->addWidget(showReminderDaemonItem->checkBox());
177 showReminderDaemonItem->checkBox()->setToolTip(
178 i18nc("@info:tooltip", "Enable this setting to show the KOrganizer "
179 "reminder daemon in your system tray (recommended)."));
181 QLabel *note = new QLabel(
182 xi18nc("@info",
183 "<note>The daemon will continue running even if it is not shown "
184 "in the system tray.</note>"));
185 systrayGroupLayout->addWidget(note);
187 systrayLayout->addStretch(1);
189 //Calendar Account
190 QFrame *calendarFrame = new QFrame(this);
191 tabWidget->addTab(calendarFrame, QIcon::fromTheme(QStringLiteral("office-calendar")),
192 i18nc("@title:tab calendar account settings", "Calendars"));
193 QHBoxLayout *calendarFrameLayout = new QHBoxLayout;
194 calendarFrame->setLayout(calendarFrameLayout);
195 Akonadi::ManageAccountWidget *manageAccountWidget = new Akonadi::ManageAccountWidget(this);
196 calendarFrameLayout->addWidget(manageAccountWidget);
198 manageAccountWidget->setMimeTypeFilter(QStringList() << QStringLiteral("text/calendar"));
199 manageAccountWidget->setCapabilityFilter(QStringList() << QStringLiteral("Resource")); // show only resources, no agents
201 load();
204 void KOPrefsDialogMain::usrWriteConfig()
206 KPIM::KPrefsModule::usrWriteConfig();
207 IncidenceEditorNG::IncidenceEditorSettings::self()->save();
210 void KOPrefsDialogMain::toggleEmailSettings(bool on)
212 mUserEmailSettings->setEnabled(!on);
213 /* if (on) {
214 KEMailSettings settings;
215 mNameEdit->setText( settings.getSetting(KEMailSettings::RealName) );
216 mEmailEdit->setText( settings.getSetting(KEMailSettings::EmailAddress) );
217 } else {
218 mNameEdit->setText( CalendarSupport::KCalPrefs::instance()->mName );
219 mEmailEdit->setText( CalendarSupport::KCalPrefs::instance()->mEmail );
223 extern "C"
225 Q_DECL_EXPORT KCModule *create_korganizerconfigmain(QWidget *parent, const char *)
227 return new KOPrefsDialogMain(parent);
231 ////////////////////////////////////////////////////////////////////////////////
232 ////////////////////////////////////////////////////////////////////////////////
234 class KOPrefsDialogTime : public KPIM::KPrefsModule
236 public:
237 KOPrefsDialogTime(QWidget *parent)
238 : KPIM::KPrefsModule(KOPrefs::instance(), parent)
240 QVBoxLayout *layout = new QVBoxLayout(this);
241 QTabWidget *tabWidget = new QTabWidget(this);
242 layout->addWidget(tabWidget);
244 QFrame *regionalPage = new QFrame(parent);
245 tabWidget->addTab(regionalPage, QIcon::fromTheme(QStringLiteral("flag")),
246 i18nc("@title:tab", "Regional"));
248 QGridLayout *regionalLayout = new QGridLayout(regionalPage);
250 QGroupBox *datetimeGroupBox =
251 new QGroupBox(i18nc("@title:group", "General Time and Date"), regionalPage);
252 regionalLayout->addWidget(datetimeGroupBox, 0, 0);
254 QGridLayout *datetimeLayout = new QGridLayout(datetimeGroupBox);
256 KPIM::KPrefsWidTime *dayBegins =
257 addWidTime(KOPrefs::instance()->dayBeginsItem(), regionalPage);
258 datetimeLayout->addWidget(dayBegins->label(), 1, 0);
259 datetimeLayout->addWidget(dayBegins->timeEdit(), 1, 1);
261 QGroupBox *holidaysGroupBox =
262 new QGroupBox(i18nc("@title:group", "Holidays"), regionalPage);
263 regionalLayout->addWidget(holidaysGroupBox, 1, 0);
265 QGridLayout *holidaysLayout = new QGridLayout(holidaysGroupBox);
267 // holiday region selection
268 QWidget *holidayRegBox = new QWidget(regionalPage);
269 QHBoxLayout *holidayRegBoxHBoxLayout = new QHBoxLayout(holidayRegBox);
270 holidayRegBoxHBoxLayout->setMargin(0);
271 holidaysLayout->addWidget(holidayRegBox, 1, 0, 1, 2);
273 QLabel *holidayLabel = new QLabel(
274 i18nc("@label", "Use holiday region:"), holidayRegBox);
275 holidayLabel->setWhatsThis(KOPrefs::instance()->holidaysItem()->whatsThis());
277 mHolidayCombo = new KComboBox(holidayRegBox);
278 holidayRegBoxHBoxLayout->addWidget(mHolidayCombo);
279 connect(mHolidayCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KOPrefsDialogMain::slotWidChanged);
281 mHolidayCombo->setWhatsThis(KOPrefs::instance()->holidaysItem()->whatsThis());
283 QStringList regions = KHolidays::HolidayRegion::regionCodes();
284 QMap<QString, QString> regionsMap;
286 foreach (const QString &regionCode, regions) {
287 QString name = KHolidays::HolidayRegion::name(regionCode);
288 QLocale locale(KHolidays::HolidayRegion::languageCode(regionCode));
289 QString languageName = QLocale::languageToString(locale.language());
290 QString label;
291 if (languageName.isEmpty()) {
292 label = name;
293 } else {
294 label = i18nc("Holday region, region language", "%1 (%2)", name, languageName);
296 regionsMap.insert(label, regionCode);
299 mHolidayCombo->addItem(i18nc("No holiday region", "None"), QString());
300 QMapIterator<QString, QString> i(regionsMap);
301 while (i.hasNext()) {
302 i.next();
303 mHolidayCombo->addItem(i.key(), i.value());
306 if (KOGlobals::self()->holidays() && KOGlobals::self()->holidays()->isValid()) {
307 mHolidayCombo->setCurrentIndex(
308 mHolidayCombo->findData(KOGlobals::self()->holidays()->regionCode()));
309 } else {
310 mHolidayCombo->setCurrentIndex(0);
313 QGroupBox *workingHoursGroupBox =
314 new QGroupBox(i18nc("@title:group", "Working Period"), regionalPage);
315 regionalLayout->addWidget(workingHoursGroupBox, 2, 0);
317 QBoxLayout *workingHoursLayout = new QVBoxLayout(workingHoursGroupBox);
319 QBoxLayout *workDaysLayout = new QHBoxLayout;
320 workingHoursLayout->addLayout(workDaysLayout);
322 // Respect start of week setting
323 int weekStart = QLocale().firstDayOfWeek();
324 for (int i = 0; i < 7; ++i) {
325 QString weekDayName = QLocale().dayName((i + weekStart + 6) % 7 + 1, QLocale::ShortFormat);
326 int index = (i + weekStart + 6) % 7;
327 mWorkDays[ index ] = new QCheckBox(weekDayName);
328 mWorkDays[ index ]->setWhatsThis(
329 i18nc("@info:whatsthis",
330 "Check this box to make KOrganizer mark the "
331 "working hours for this day of the week. "
332 "If this is a work day for you, check "
333 "this box, or the working hours will not be "
334 "marked with color."));
336 connect(mWorkDays[ index ], &QCheckBox::stateChanged, this, &KPIM::KPrefsModule::slotWidChanged);
338 workDaysLayout->addWidget(mWorkDays[ index ]);
341 KPIM::KPrefsWidTime *workStart =
342 addWidTime(KOPrefs::instance()->workingHoursStartItem());
344 QHBoxLayout *workStartLayout = new QHBoxLayout;
345 workingHoursLayout->addLayout(workStartLayout);
347 workStartLayout->addWidget(workStart->label());
348 workStartLayout->addWidget(workStart->timeEdit());
350 KPIM::KPrefsWidTime *workEnd =
351 addWidTime(KOPrefs::instance()->workingHoursEndItem());
353 QHBoxLayout *workEndLayout = new QHBoxLayout;
354 workingHoursLayout->addLayout(workEndLayout);
356 workEndLayout->addWidget(workEnd->label());
357 workEndLayout->addWidget(workEnd->timeEdit());
359 KPIM::KPrefsWidBool *excludeHolidays =
360 addWidBool(KOPrefs::instance()->excludeHolidaysItem());
362 workingHoursLayout->addWidget(excludeHolidays->checkBox());
364 regionalLayout->setRowStretch(4, 1);
366 QFrame *defaultPage = new QFrame(parent);
367 tabWidget->addTab(defaultPage, QIcon::fromTheme(QStringLiteral("draw-eraser")),
368 i18nc("@title:tab", "Default Values"));
369 QGridLayout *defaultLayout = new QGridLayout(defaultPage);
371 QGroupBox *timesGroupBox =
372 new QGroupBox(i18nc("@title:group", "Appointments"), defaultPage);
373 defaultLayout->addWidget(timesGroupBox, 0, 0);
375 QGridLayout *timesLayout = new QGridLayout(timesGroupBox);
377 KPIM::KPrefsWidTime *defaultTime =
378 addWidTime(CalendarSupport::KCalPrefs::instance()->startTimeItem(), defaultPage);
379 timesLayout->addWidget(defaultTime->label(), 0, 0);
380 timesLayout->addWidget(defaultTime->timeEdit(), 0, 1);
382 KPIM::KPrefsWidDuration *defaultDuration =
383 addWidDuration(CalendarSupport::KCalPrefs::instance()->defaultDurationItem(),
384 QStringLiteral("hh:mm"), defaultPage);
386 timesLayout->addWidget(defaultDuration->label(), 1, 0);
387 timesLayout->addWidget(defaultDuration->timeEdit(), 1, 1);
389 QGroupBox *remindersGroupBox =
390 new QGroupBox(i18nc("@title:group", "Reminders"), defaultPage);
391 defaultLayout->addWidget(remindersGroupBox, 1, 0);
393 QGridLayout *remindersLayout = new QGridLayout(remindersGroupBox);
395 QLabel *reminderLabel =
396 new QLabel(i18nc("@label", "Default reminder time:"), defaultPage);
397 remindersLayout->addWidget(reminderLabel, 0, 0);
398 reminderLabel->setWhatsThis(
399 CalendarSupport::KCalPrefs::instance()->reminderTimeItem()->whatsThis());
400 mReminderTimeSpin = new QSpinBox(defaultPage);
401 mReminderTimeSpin->setWhatsThis(
402 CalendarSupport::KCalPrefs::instance()->reminderTimeItem()->whatsThis());
403 mReminderTimeSpin->setToolTip(
404 CalendarSupport::KCalPrefs::instance()->reminderTimeItem()->toolTip());
405 connect(mReminderTimeSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &KOPrefsDialogMain::slotWidChanged);
406 remindersLayout->addWidget(mReminderTimeSpin, 0, 1);
408 mReminderUnitsCombo = new KComboBox(defaultPage);
409 mReminderUnitsCombo->setToolTip(
410 CalendarSupport::KCalPrefs::instance()->reminderTimeUnitsItem()->toolTip());
411 mReminderUnitsCombo->setWhatsThis(
412 CalendarSupport::KCalPrefs::instance()->reminderTimeUnitsItem()->whatsThis());
413 connect(mReminderUnitsCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KOPrefsDialogMain::slotWidChanged);
414 mReminderUnitsCombo->addItem(
415 i18nc("@item:inlistbox reminder units in minutes", "minute(s)"));
416 mReminderUnitsCombo->addItem(
417 i18nc("@item:inlistbox reminder time units in hours", "hour(s)"));
418 mReminderUnitsCombo->addItem(
419 i18nc("@item:inlistbox reminder time units in days", "day(s)"));
420 remindersLayout->addWidget(mReminderUnitsCombo, 0, 2);
422 QCheckBox *cb =
423 addWidBool(
424 CalendarSupport::KCalPrefs::instance()->defaultAudioFileRemindersItem())->checkBox();
426 if (CalendarSupport::KCalPrefs::instance()->audioFilePathItem()->value().isEmpty()) {
427 const QString defAudioFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sound/") + QLatin1String("KDE-Sys-Warning.ogg"));
428 CalendarSupport::KCalPrefs::instance()->audioFilePathItem()->setValue(defAudioFile);
430 QString filter =
431 i18n("*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra|"
432 "Audio Files (*.ogg *.wav *.mp3 *.wma *.flac *.aiff *.raw *.au *.ra)");
433 KUrlRequester *rq = addWidPath(CalendarSupport::KCalPrefs::instance()->audioFilePathItem(),
434 Q_NULLPTR, filter)->urlRequester();
435 rq->setEnabled(cb->isChecked());
437 connect(cb, &QCheckBox::toggled, rq, &KUrlRequester::setEnabled);
439 QVBoxLayout *audioFileRemindersBox = new QVBoxLayout(remindersGroupBox);
440 audioFileRemindersBox->addWidget(cb);
441 audioFileRemindersBox->addWidget(rq);
443 remindersLayout->addLayout(audioFileRemindersBox, 1, 0);
444 remindersLayout->addWidget(
445 addWidBool(
446 CalendarSupport::KCalPrefs::instance()->defaultEventRemindersItem())->checkBox(), 2, 0);
447 remindersLayout->addWidget(
448 addWidBool(
449 CalendarSupport::KCalPrefs::instance()->defaultTodoRemindersItem())->checkBox(), 3, 0);
451 defaultLayout->setRowStretch(3, 1);
452 load();
455 protected:
456 void usrRead()
458 mReminderTimeSpin->setValue(CalendarSupport::KCalPrefs::instance()->mReminderTime);
459 mReminderUnitsCombo->setCurrentIndex(
460 CalendarSupport::KCalPrefs::instance()->mReminderTimeUnits);
461 for (int i = 0; i < 7; ++i) {
462 mWorkDays[i]->setChecked((1 << i) & (KOPrefs::instance()->mWorkWeekMask));
466 void usrSave()
468 KOPrefs::instance()->mHolidays =
469 mHolidayCombo->itemData(mHolidayCombo->currentIndex()).toString();
471 CalendarSupport::KCalPrefs::instance()->mReminderTime =
472 mReminderTimeSpin->value();
473 CalendarSupport::KCalPrefs::instance()->mReminderTimeUnits =
474 mReminderUnitsCombo->currentIndex();
476 int mask = 0;
477 for (int i = 0; i < 7; ++i) {
478 if (mWorkDays[i]->isChecked()) {
479 mask = mask | (1 << i);
482 KOPrefs::instance()->mWorkWeekMask = mask;
483 KOPrefs::instance()->save();
484 CalendarSupport::KCalPrefs::instance()->save();
487 void setCombo(KComboBox *combo, const QString &text, const QStringList *tags = Q_NULLPTR)
489 if (tags) {
490 int i = tags->indexOf(text);
491 if (i > 0) {
492 combo->setCurrentIndex(i);
494 } else {
495 for (int i = 0; i < combo->count(); ++i) {
496 if (combo->itemText(i) == text) {
497 combo->setCurrentIndex(i);
498 break;
504 private:
505 QStringList tzonenames;
506 KComboBox *mHolidayCombo;
507 QSpinBox *mReminderTimeSpin;
508 KComboBox *mReminderUnitsCombo;
509 QCheckBox *mWorkDays[7];
512 extern "C"
514 Q_DECL_EXPORT KCModule *create_korganizerconfigtime(QWidget *parent, const char *)
516 return new KOPrefsDialogTime(parent);
520 ////////////////////////////////////////////////////////////////////////////////
521 ////////////////////////////////////////////////////////////////////////////////
523 class KOPrefsDialogViews : public KPIM::KPrefsModule
525 public:
526 KOPrefsDialogViews(QWidget *parent)
527 : KPIM::KPrefsModule(KOPrefs::instance(), parent),
528 mMonthIconComboBox(new KItemIconCheckCombo(KItemIconCheckCombo::MonthType, this)),
529 mAgendaIconComboBox(new KItemIconCheckCombo(KItemIconCheckCombo::AgendaType, this))
531 QBoxLayout *topTopLayout = new QVBoxLayout(this);
532 QTabWidget *tabWidget = new QTabWidget(this);
533 topTopLayout->addWidget(tabWidget);
535 connect(mMonthIconComboBox, &KPIM::KCheckComboBox::checkedItemsChanged,
536 this, &KPIM::KPrefsModule::slotWidChanged);
537 connect(mAgendaIconComboBox, &KPIM::KCheckComboBox::checkedItemsChanged,
538 this, &KPIM::KPrefsModule::slotWidChanged);
540 // Tab: Views->General
541 QFrame *generalFrame = new QFrame(this);
542 tabWidget->addTab(generalFrame, QIcon::fromTheme(QStringLiteral("view-choose")),
543 i18nc("@title:tab general settings", "General"));
545 QBoxLayout *generalLayout = new QVBoxLayout(generalFrame);
547 // GroupBox: Views->General->Display Options
548 QVBoxLayout *gdisplayLayout = new QVBoxLayout;
549 QGroupBox *gdisplayBox = new QGroupBox(i18nc("@title:group", "Display Options"));
551 QBoxLayout *nextDaysLayout = new QHBoxLayout;
552 gdisplayLayout->addLayout(nextDaysLayout);
554 KPIM::KPrefsWidInt *nextDays =
555 addWidInt(KOPrefs::instance()->nextXDaysItem());
556 nextDays->spinBox()->setSuffix(
557 i18nc("@label suffix in the N days spin box", " days"));
559 nextDaysLayout->addWidget(nextDays->label());
560 nextDaysLayout->addWidget(nextDays->spinBox());
561 nextDaysLayout->addStretch(1);
563 gdisplayLayout->addWidget(
564 addWidBool(KOPrefs::instance()->enableToolTipsItem())->checkBox());
565 gdisplayLayout->addWidget(
566 addWidBool(KOPrefs::instance()->todosUseCategoryColorsItem())->checkBox());
567 gdisplayBox->setLayout(gdisplayLayout);
568 generalLayout->addWidget(gdisplayBox);
570 // GroupBox: Views->General->Date Navigator
571 QVBoxLayout *datenavLayout = new QVBoxLayout;
572 QGroupBox *datenavBox = new QGroupBox(i18nc("@title:group", "Date Navigator"));
573 datenavLayout->addWidget(
574 addWidBool(KOPrefs::instance()->dailyRecurItem())->checkBox());
575 datenavLayout->addWidget(
576 addWidBool(KOPrefs::instance()->weeklyRecurItem())->checkBox());
577 datenavLayout->addWidget(
578 addWidBool(KOPrefs::instance()->highlightTodosItem())->checkBox());
579 datenavLayout->addWidget(
580 addWidBool(KOPrefs::instance()->highlightJournalsItem())->checkBox());
581 datenavLayout->addWidget(
582 addWidBool(KOPrefs::instance()->weekNumbersShowWorkItem())->checkBox());
583 datenavBox->setLayout(datenavLayout);
584 generalLayout->addWidget(datenavBox);
585 generalLayout->addStretch(1);
587 // Tab: Views->Agenda View
588 QFrame *agendaFrame = new QFrame(this);
589 tabWidget->addTab(agendaFrame, QIcon::fromTheme(QStringLiteral("view-calendar-workweek")),
590 i18nc("@title:tab", "Agenda View"));
592 QBoxLayout *agendaLayout = new QVBoxLayout(agendaFrame);
594 // GroupBox: Views->Agenda View->Display Options
595 QVBoxLayout *adisplayLayout = new QVBoxLayout;
596 QGroupBox *adisplayBox = new QGroupBox(i18nc("@title:group", "Display Options"));
598 QHBoxLayout *hourSizeLayout = new QHBoxLayout;
599 adisplayLayout->addLayout(hourSizeLayout);
601 KPIM::KPrefsWidInt *hourSize =
602 addWidInt(KOPrefs::instance()->hourSizeItem());
603 hourSize->spinBox()->setSuffix(
604 i18nc("@label suffix in the hour size spin box", " pixels"));
606 hourSizeLayout->addWidget(hourSize->label());
607 hourSizeLayout->addWidget(hourSize->spinBox());
608 hourSizeLayout->addStretch(1);
610 adisplayLayout->addWidget(
611 addWidBool(KOPrefs::instance()->enableAgendaItemIconsItem())->checkBox());
612 adisplayLayout->addWidget(
613 addWidBool(KOPrefs::instance()->showTodosAgendaViewItem())->checkBox());
614 KPIM::KPrefsWidBool *marcusBainsEnabled =
615 addWidBool(KOPrefs::instance()->marcusBainsEnabledItem());
616 adisplayLayout->addWidget(marcusBainsEnabled->checkBox());
618 KPIM::KPrefsWidBool *marcusBainsShowSeconds =
619 addWidBool(KOPrefs::instance()->marcusBainsShowSecondsItem());
620 connect(marcusBainsEnabled->checkBox(), &QAbstractButton::toggled,
621 marcusBainsShowSeconds->checkBox(), &QWidget::setEnabled);
623 adisplayLayout->addWidget(marcusBainsShowSeconds->checkBox());
624 adisplayLayout->addWidget(
625 addWidBool(KOPrefs::instance()->selectionStartsEditorItem())->checkBox());
626 mAgendaIconComboBox->setCheckedIcons(
627 KOPrefs::instance()->eventViewsPreferences()->agendaViewIcons());
628 adisplayLayout->addWidget(mAgendaIconComboBox);
629 adisplayBox->setLayout(adisplayLayout);
630 agendaLayout->addWidget(adisplayBox);
632 // GroupBox: Views->Agenda View->Color Usage
633 agendaLayout->addWidget(
634 addWidRadios(KOPrefs::instance()->agendaViewColorsItem())->groupBox());
636 agendaLayout->addWidget(
637 addWidBool(KOPrefs::instance()->colorBusyDaysEnabledItem())->checkBox());
639 // GroupBox: Views->Agenda View->Multiple Calendars
640 agendaLayout->addWidget(
641 addWidRadios(KOPrefs::instance()->agendaViewCalendarDisplayItem())->groupBox());
643 agendaLayout->addStretch(1);
645 // Tab: Views->Month View
646 QFrame *monthFrame = new QFrame(this);
647 tabWidget->addTab(monthFrame, QIcon::fromTheme(QStringLiteral("view-calendar-month")),
648 i18nc("@title:tab", "Month View"));
650 QBoxLayout *monthLayout = new QVBoxLayout(monthFrame);
652 // GroupBox: Views->Month View->Display Options
653 QVBoxLayout *mdisplayLayout = new QVBoxLayout;
654 QGroupBox *mdisplayBox = new QGroupBox(i18nc("@title:group", "Display Options"));
655 /*mdisplayLayout->addWidget(
656 addWidBool( KOPrefs::instance()->enableMonthScrollItem() )->checkBox() );*/
657 mdisplayLayout->addWidget(
658 addWidBool(KOPrefs::instance()->showTimeInMonthViewItem())->checkBox());
659 mdisplayLayout->addWidget(
660 addWidBool(KOPrefs::instance()->enableMonthItemIconsItem())->checkBox());
661 mdisplayLayout->addWidget(
662 addWidBool(KOPrefs::instance()->showTodosMonthViewItem())->checkBox());
663 mdisplayLayout->addWidget(
664 addWidBool(KOPrefs::instance()->showJournalsMonthViewItem())->checkBox());
665 mdisplayBox->setLayout(mdisplayLayout);
667 mMonthIconComboBox->setCheckedIcons(
668 KOPrefs::instance()->eventViewsPreferences()->monthViewIcons());
669 mdisplayLayout->addWidget(mMonthIconComboBox);
671 monthLayout->addWidget(mdisplayBox);
673 monthLayout->addWidget(
674 addWidBool(KOPrefs::instance()->colorMonthBusyDaysEnabledItem())->checkBox());
676 // GroupBox: Views->Month View->Color Usage
677 monthLayout->addWidget(
678 addWidRadios(KOPrefs::instance()->monthViewColorsItem())->groupBox());
679 monthLayout->addStretch(1);
681 // Tab: Views->Todo View
682 QFrame *todoFrame = new QFrame(this);
683 tabWidget->addTab(todoFrame, QIcon::fromTheme(QStringLiteral("view-calendar-tasks")),
684 i18nc("@title:tab", "Todo View"));
686 QBoxLayout *todoLayout = new QVBoxLayout(todoFrame);
688 // GroupBox: Views->Todo View->Display Options
689 QVBoxLayout *tdisplayLayout = new QVBoxLayout;
690 QGroupBox *tdisplayBox = new QGroupBox(i18nc("@title:group", "Display Options"));
691 tdisplayLayout->addWidget(
692 addWidBool(KOPrefs::instance()->sortCompletedTodosSeparatelyItem())->checkBox());
693 tdisplayBox->setLayout(tdisplayLayout);
694 todoLayout->addWidget(tdisplayBox);
696 // GroupBox: Views->Todo View->Other
697 QVBoxLayout *otherLayout = new QVBoxLayout;
698 QGroupBox *otherBox = new QGroupBox(i18nc("@title:group", "Other Options"));
699 otherLayout->addWidget(
700 addWidBool(KOPrefs::instance()->recordTodosInJournalsItem())->checkBox());
701 otherBox->setLayout(otherLayout);
702 todoLayout->addWidget(otherBox);
703 todoLayout->addStretch(1);
705 load();
707 protected:
708 void usrSave()
710 KOPrefs::instance()->eventViewsPreferences()->setAgendaViewIcons(
711 mAgendaIconComboBox->checkedIcons());
712 KOPrefs::instance()->eventViewsPreferences()->setMonthViewIcons(
713 mMonthIconComboBox->checkedIcons());
715 private:
716 KItemIconCheckCombo *mMonthIconComboBox;
717 KItemIconCheckCombo *mAgendaIconComboBox;
720 extern "C"
722 Q_DECL_EXPORT KCModule *create_korganizerconfigviews(QWidget *parent, const char *)
724 return new KOPrefsDialogViews(parent);
728 ////////////////////////////////////////////////////////////////////////////////
729 ////////////////////////////////////////////////////////////////////////////////
731 KOPrefsDialogColorsAndFonts::KOPrefsDialogColorsAndFonts(QWidget *parent)
732 : KPIM::KPrefsModule(KOPrefs::instance(), parent)
734 QBoxLayout *topTopLayout = new QVBoxLayout(this);
735 QTabWidget *tabWidget = new QTabWidget(this);
736 topTopLayout->addWidget(tabWidget);
738 QWidget *colorFrame = new QWidget(this);
739 topTopLayout->addWidget(colorFrame);
740 QGridLayout *colorLayout = new QGridLayout(colorFrame);
741 tabWidget->addTab(colorFrame, QIcon::fromTheme(QStringLiteral("preferences-desktop-color")),
742 i18nc("@title:tab", "Colors"));
744 // Holiday Color
745 KPIM::KPrefsWidColor *holidayColor =
746 addWidColor(KOPrefs::instance()->agendaHolidaysBackgroundColorItem(), colorFrame);
747 colorLayout->addWidget(holidayColor->label(), 0, 0);
748 colorLayout->addWidget(holidayColor->button(), 0, 1);
750 // agenda view background color
751 KPIM::KPrefsWidColor *agendaBgColor =
752 addWidColor(KOPrefs::instance()->agendaGridBackgroundColorItem(), colorFrame);
753 colorLayout->addWidget(agendaBgColor->label(), 3, 0);
754 colorLayout->addWidget(agendaBgColor->button(), 3, 1);
756 // agenda view Marcus Bains line color
757 KPIM::KPrefsWidColor *mblColor =
758 addWidColor(KOPrefs::instance()->agendaMarcusBainsLineLineColorItem(), colorFrame);
759 colorLayout->addWidget(mblColor->label(), 5, 0);
760 colorLayout->addWidget(mblColor->button(), 5, 1);
762 KPIM::KPrefsWidColor *viewBgBusyColor =
763 addWidColor(KOPrefs::instance()->viewBgBusyColorItem(), colorFrame);
764 colorLayout->addWidget(viewBgBusyColor->label(), 4, 0);
765 colorLayout->addWidget(viewBgBusyColor->button(), 4, 1);
767 // working hours color
768 KPIM::KPrefsWidColor *agendaGridWorkHoursBackgroundColor =
769 addWidColor(KOPrefs::instance()->workingHoursColorItem(), colorFrame);
770 colorLayout->addWidget(agendaGridWorkHoursBackgroundColor->label(), 6, 0);
771 colorLayout->addWidget(agendaGridWorkHoursBackgroundColor->button(), 6, 1);
773 // Todo due today color
774 KPIM::KPrefsWidColor *todoDueTodayColor =
775 addWidColor(
776 KOPrefs::instance()->todoDueTodayColorItem(), colorFrame);
777 colorLayout->addWidget(todoDueTodayColor->label(), 7, 0);
778 colorLayout->addWidget(todoDueTodayColor->button(), 7, 1);
780 // Todo overdue color
781 KPIM::KPrefsWidColor *todoOverdueColor =
782 addWidColor(
783 KOPrefs::instance()->todoOverdueColorItem(), colorFrame);
784 colorLayout->addWidget(todoOverdueColor->label(), 8, 0);
785 colorLayout->addWidget(todoOverdueColor->button(), 8, 1);
787 // categories colors
788 QGroupBox *categoryGroup = new QGroupBox(i18nc("@title:group", "Categories"), colorFrame);
789 colorLayout->addWidget(categoryGroup, 9, 0, 1, 2);
791 QGridLayout *categoryLayout = new QGridLayout;
792 categoryGroup->setLayout(categoryLayout);
794 KPIM::KPrefsWidColor *unsetCategoryColor =
795 addWidColor(CalendarSupport::KCalPrefs::instance()->unsetCategoryColorItem(), categoryGroup);
796 categoryLayout->addWidget(unsetCategoryColor->label(), 0, 0);
797 categoryLayout->addWidget(unsetCategoryColor->button(), 0, 1);
798 unsetCategoryColor->label()->setWhatsThis(unsetCategoryColor->button()->whatsThis());
799 unsetCategoryColor->label()->setToolTip(unsetCategoryColor->button()->toolTip());
801 mCategoryCombo = new KPIM::TagCombo(categoryGroup);
802 mCategoryCombo->setWhatsThis(
803 i18nc("@info:whatsthis",
804 "Select here the event category you want to modify. "
805 "You can change the selected category color using "
806 "the button below."));
807 connect(mCategoryCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &KOPrefsDialogColorsAndFonts::updateCategoryColor);
808 categoryLayout->addWidget(mCategoryCombo, 1, 0);
810 mCategoryButton = new KColorButton(categoryGroup);
811 mCategoryButton->setWhatsThis(
812 i18nc("@info:whatsthis",
813 "Choose here the color of the event category selected "
814 "using the combo box above."));
815 connect(mCategoryButton, &KColorButton::changed, this, &KOPrefsDialogColorsAndFonts::setCategoryColor);
816 categoryLayout->addWidget(mCategoryButton, 1, 1);
818 updateCategoryColor();
820 // resources colors
821 QGroupBox *resourceGroup = new QGroupBox(i18nc("@title:group", "Resources"), colorFrame);
822 colorLayout->addWidget(resourceGroup, 10, 0, 1, 2);
824 QBoxLayout *resourceLayout = new QHBoxLayout;
825 resourceGroup->setLayout(resourceLayout);
827 mResourceCombo = new Akonadi::CollectionComboBox(resourceGroup);
828 //mResourceCombo->addExcludedSpecialResources(Akonadi::Collection::SearchResource);
829 QStringList mimetypes;
830 mimetypes << KCalCore::Todo::todoMimeType();
831 mimetypes << KCalCore::Journal::journalMimeType();
832 mimetypes << KCalCore::Event::eventMimeType();
834 mResourceCombo->setMimeTypeFilter(mimetypes);
835 mResourceCombo->setWhatsThis(
836 i18nc("@info:whatsthis",
837 "Select the calendar you want to modify. "
838 "You can change the selected calendar color using "
839 "the button below."));
840 connect(mResourceCombo, static_cast<void (Akonadi::CollectionComboBox::*)(int)>(&Akonadi::CollectionComboBox::activated), this, &KOPrefsDialogColorsAndFonts::updateResourceColor);
841 resourceLayout->addWidget(mResourceCombo);
843 mResourceButton = new KColorButton(resourceGroup);
844 mResourceButton->setWhatsThis(
845 i18nc("@info:whatsthis",
846 "Choose here the color of the calendar selected "
847 "using the combo box above."));
848 connect(mResourceButton, &KColorButton::changed, this, &KOPrefsDialogColorsAndFonts::setResourceColor);
849 resourceLayout->addWidget(mResourceButton);
851 colorLayout->setRowStretch(11, 1);
853 QWidget *fontFrame = new QWidget(this);
854 tabWidget->addTab(fontFrame, QIcon::fromTheme(QStringLiteral("preferences-desktop-font")),
855 i18nc("@title:tab", "Fonts"));
857 QGridLayout *fontLayout = new QGridLayout(fontFrame);
859 KPIM::KPrefsWidFont *timeBarFont =
860 addWidFont(KOPrefs::instance()->agendaTimeLabelsFontItem(), fontFrame,
861 QLocale().toString(QTime(12, 34), QLocale::ShortFormat));
862 fontLayout->addWidget(timeBarFont->label(), 0, 0);
863 fontLayout->addWidget(timeBarFont->preview(), 0, 1);
864 fontLayout->addWidget(timeBarFont->button(), 0, 2);
866 KPIM::KPrefsWidFont *monthViewFont =
867 addWidFont(KOPrefs::instance()->monthViewFontItem(), fontFrame,
868 QLocale().toString(QTime(12, 34), QLocale::ShortFormat) + QLatin1Char(' ') +
869 i18nc("@label", "Event text"));
871 fontLayout->addWidget(monthViewFont->label(), 1, 0);
872 fontLayout->addWidget(monthViewFont->preview(), 1, 1);
873 fontLayout->addWidget(monthViewFont->button(), 1, 2);
875 KPIM::KPrefsWidFont *agendaViewFont =
876 addWidFont(KOPrefs::instance()->agendaViewFontItem(), fontFrame,
877 i18nc("@label", "Event text"));
878 fontLayout->addWidget(agendaViewFont->label(), 2, 0);
879 fontLayout->addWidget(agendaViewFont->preview(), 2, 1);
880 fontLayout->addWidget(agendaViewFont->button(), 2, 2);
882 KPIM::KPrefsWidFont *marcusBainsFont =
883 addWidFont(KOPrefs::instance()->agendaMarcusBainsLineFontItem(), fontFrame,
884 QLocale().toString(QTime(12, 34, 23), QLocale::ShortFormat));
885 fontLayout->addWidget(marcusBainsFont->label(), 3, 0);
886 fontLayout->addWidget(marcusBainsFont->preview(), 3, 1);
887 fontLayout->addWidget(marcusBainsFont->button(), 3, 2);
889 fontLayout->setColumnStretch(1, 1);
890 fontLayout->setRowStretch(4, 1);
892 load();
895 void KOPrefsDialogColorsAndFonts::usrWriteConfig()
897 QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin();
898 while (i != mCategoryDict.constEnd()) {
899 CalendarSupport::KCalPrefs::instance()->setCategoryColor(i.key(), i.value());
900 ++i;
903 i = mResourceDict.constBegin();
904 while (i != mResourceDict.constEnd()) {
905 KOPrefs::instance()->setResourceColor(i.key(), i.value());
906 ++i;
909 //mCalendarViewsPrefs->writeConfig();
912 void KOPrefsDialogColorsAndFonts::usrReadConfig()
914 updateCategories();
915 updateResources();
916 //mCalendarViewsPrefs->readConfig();
919 void KOPrefsDialogColorsAndFonts::updateCategories()
921 updateCategoryColor();
924 void KOPrefsDialogColorsAndFonts::setCategoryColor()
926 mCategoryDict.insert(mCategoryCombo->currentText(), mCategoryButton->color());
927 slotWidChanged();
930 void KOPrefsDialogColorsAndFonts::updateCategoryColor()
932 const QString cat = mCategoryCombo->currentText();
933 QColor color = mCategoryDict.value(cat);
934 if (!color.isValid()) {
935 //TODO get this from the tag
936 color = CalendarSupport::KCalPrefs::instance()->categoryColor(cat);
938 if (color.isValid()) {
939 mCategoryButton->setColor(color);
943 void KOPrefsDialogColorsAndFonts::updateResources()
945 updateResourceColor();
948 void KOPrefsDialogColorsAndFonts::setResourceColor()
950 bool ok;
951 const QString id =
952 QString::number(mResourceCombo->itemData(
953 mResourceCombo->currentIndex(),
954 Akonadi::EntityTreeModel::CollectionIdRole).toLongLong(&ok));
955 if (! ok) {
956 return;
958 mResourceDict.insert(id, mResourceButton->color());
959 slotWidChanged();
962 void KOPrefsDialogColorsAndFonts::updateResourceColor()
964 bool ok;
965 const QString id =
966 QString::number(mResourceCombo->itemData(
967 mResourceCombo->currentIndex(),
968 Akonadi::EntityTreeModel::CollectionIdRole).toLongLong(&ok));
969 if (!ok) {
970 return;
972 qCDebug(KORGANIZER_LOG) << id << mResourceCombo->itemText(mResourceCombo->currentIndex());
974 QColor color = mResourceDict.value(id);
975 if (! color.isValid()) {
976 color = KOPrefs::instance()->resourceColor(id);
978 mResourceButton->setColor(color);
981 extern "C"
983 Q_DECL_EXPORT KCModule *create_korganizerconfigcolorsandfonts(QWidget *parent, const char *)
985 return new KOPrefsDialogColorsAndFonts(parent);
989 ////////////////////////////////////////////////////////////////////////////////
990 ////////////////////////////////////////////////////////////////////////////////
992 KOPrefsDialogGroupScheduling::KOPrefsDialogGroupScheduling(QWidget *parent)
993 : KPIM::KPrefsModule(KOPrefs::instance(), parent)
995 QBoxLayout *topTopLayout = new QVBoxLayout(this);
997 QWidget *topFrame = new QWidget(this);
998 topTopLayout->addWidget(topFrame);
1000 QGridLayout *topLayout = new QGridLayout(topFrame);
1002 KPIM::KPrefsWidBool *useGroupwareBool =
1003 addWidBool(CalendarSupport::KCalPrefs::instance()->useGroupwareCommunicationItem(), topFrame);
1004 topLayout->addWidget(useGroupwareBool->checkBox(), 0, 0, 1, 2);
1006 KPIM::KPrefsWidBool *bcc =
1007 addWidBool(Akonadi::CalendarSettings::self()->bccItem(), topFrame);
1008 topLayout->addWidget(bcc->checkBox(), 1, 0, 1, 2);
1010 QLabel *aTransportLabel = new QLabel(
1011 i18nc("@label", "Mail transport:"), topFrame);
1012 topLayout->addWidget(aTransportLabel, 2, 0, 1, 2);
1014 MailTransport::TransportManagementWidget *tmw =
1015 new MailTransport::TransportManagementWidget(topFrame);
1016 tmw->layout()->setContentsMargins(0, 0, 0, 0);
1017 topLayout->addWidget(tmw, 3, 0, 1, 2);
1019 //topLayout->setRowStretch( 2, 1 );
1021 load();
1024 void KOPrefsDialogGroupScheduling::usrReadConfig()
1028 void KOPrefsDialogGroupScheduling::usrWriteConfig()
1032 extern "C"
1034 Q_DECL_EXPORT KCModule *create_korganizerconfiggroupscheduling(QWidget *parent, const char *)
1036 return new KOPrefsDialogGroupScheduling(parent);
1040 ////////////////////////////////////////////////////////////////////////////////
1041 ////////////////////////////////////////////////////////////////////////////////
1043 KOPrefsDialogGroupwareScheduling::KOPrefsDialogGroupwareScheduling(QWidget *parent)
1044 : KPrefsModule(CalendarSupport::KCalPrefs::instance(), parent)
1046 mGroupwarePage = new Ui::KOGroupwarePrefsPage();
1047 QWidget *widget = new QWidget(this);
1048 widget->setObjectName(QStringLiteral("KOGrouparePrefsPage"));
1050 mGroupwarePage->setupUi(widget);
1052 mGroupwarePage->groupwareTab->setTabIcon(0, QIcon::fromTheme(QStringLiteral("go-up")));
1053 mGroupwarePage->groupwareTab->setTabIcon(1, QIcon::fromTheme(QStringLiteral("go-down")));
1055 // signals and slots connections
1057 connect(mGroupwarePage->publishDays, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1058 connect(mGroupwarePage->publishUrl, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1059 connect(mGroupwarePage->publishUser, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1060 connect(mGroupwarePage->publishPassword, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1061 connect(mGroupwarePage->publishSavePassword, &QCheckBox::toggled, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1062 connect(mGroupwarePage->retrieveEnable, &QCheckBox::toggled, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1063 connect(mGroupwarePage->retrieveUser, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1064 connect(mGroupwarePage->retrievePassword, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1065 connect(mGroupwarePage->retrieveSavePassword, &QCheckBox::toggled, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1066 connect(mGroupwarePage->retrieveUrl, &QLineEdit::textChanged, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1067 connect(mGroupwarePage->publishDelay, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1068 connect(mGroupwarePage->fullDomainRetrieval, &QCheckBox::toggled, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1069 connect(mGroupwarePage->publishEnable, &QCheckBox::toggled, this, &KOPrefsDialogGroupwareScheduling::slotWidChanged);
1071 (new QVBoxLayout(this))->addWidget(widget);
1073 load();
1076 KOPrefsDialogGroupwareScheduling::~KOPrefsDialogGroupwareScheduling()
1078 delete mGroupwarePage;
1081 void KOPrefsDialogGroupwareScheduling::usrReadConfig()
1083 mGroupwarePage->publishEnable->setChecked(
1084 Akonadi::CalendarSettings::self()->freeBusyPublishAuto());
1085 mGroupwarePage->publishDelay->setValue(
1086 Akonadi::CalendarSettings::self()->freeBusyPublishDelay());
1087 mGroupwarePage->publishDays->setValue(
1088 Akonadi::CalendarSettings::self()->freeBusyPublishDays());
1089 mGroupwarePage->publishUrl->setText(
1090 Akonadi::CalendarSettings::self()->freeBusyPublishUrl());
1091 mGroupwarePage->publishUser->setText(
1092 Akonadi::CalendarSettings::self()->freeBusyPublishUser());
1093 mGroupwarePage->publishPassword->setText(
1094 Akonadi::CalendarSettings::self()->freeBusyPublishPassword());
1095 mGroupwarePage->publishSavePassword->setChecked(
1096 Akonadi::CalendarSettings::self()->freeBusyPublishSavePassword());
1098 mGroupwarePage->retrieveEnable->setChecked(
1099 Akonadi::CalendarSettings::self()->freeBusyRetrieveAuto());
1100 mGroupwarePage->fullDomainRetrieval->setChecked(
1101 Akonadi::CalendarSettings::self()->freeBusyFullDomainRetrieval());
1102 mGroupwarePage->retrieveUrl->setText(
1103 Akonadi::CalendarSettings::self()->freeBusyRetrieveUrl());
1104 mGroupwarePage->retrieveUser->setText(
1105 Akonadi::CalendarSettings::self()->freeBusyRetrieveUser());
1106 mGroupwarePage->retrievePassword->setText(
1107 Akonadi::CalendarSettings::self()->freeBusyRetrievePassword());
1108 mGroupwarePage->retrieveSavePassword->setChecked(
1109 Akonadi::CalendarSettings::self()->freeBusyRetrieveSavePassword());
1112 void KOPrefsDialogGroupwareScheduling::usrWriteConfig()
1114 Akonadi::CalendarSettings::self()->setFreeBusyPublishAuto(
1115 mGroupwarePage->publishEnable->isChecked());
1116 Akonadi::CalendarSettings::self()->setFreeBusyPublishDelay(mGroupwarePage->publishDelay->value());
1117 Akonadi::CalendarSettings::self()->setFreeBusyPublishDays(
1118 mGroupwarePage->publishDays->value());
1119 Akonadi::CalendarSettings::self()->setFreeBusyPublishUrl(
1120 mGroupwarePage->publishUrl->text());
1121 Akonadi::CalendarSettings::self()->setFreeBusyPublishUser(
1122 mGroupwarePage->publishUser->text());
1123 Akonadi::CalendarSettings::self()->setFreeBusyPublishPassword(
1124 mGroupwarePage->publishPassword->text());
1125 Akonadi::CalendarSettings::self()->setFreeBusyPublishSavePassword(
1126 mGroupwarePage->publishSavePassword->isChecked());
1128 Akonadi::CalendarSettings::self()->setFreeBusyRetrieveAuto(
1129 mGroupwarePage->retrieveEnable->isChecked());
1130 Akonadi::CalendarSettings::self()->setFreeBusyFullDomainRetrieval(
1131 mGroupwarePage->fullDomainRetrieval->isChecked());
1132 Akonadi::CalendarSettings::self()->setFreeBusyRetrieveUrl(
1133 mGroupwarePage->retrieveUrl->text());
1134 Akonadi::CalendarSettings::self()->setFreeBusyRetrieveUser(
1135 mGroupwarePage->retrieveUser->text());
1136 Akonadi::CalendarSettings::self()->setFreeBusyRetrievePassword(
1137 mGroupwarePage->retrievePassword->text());
1138 Akonadi::CalendarSettings::self()->setFreeBusyRetrieveSavePassword(
1139 mGroupwarePage->retrieveSavePassword->isChecked());
1141 // clear the url cache for our user
1142 const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/korganizer/freebusyurls");
1143 KConfig cfg(configFile);
1144 cfg.deleteGroup(CalendarSupport::KCalPrefs::instance()->email());
1146 Akonadi::CalendarSettings::self()->save();
1149 extern "C"
1151 Q_DECL_EXPORT KCModule *create_korganizerconfigfreebusy(QWidget *parent, const char *)
1153 return new KOPrefsDialogGroupwareScheduling(parent);
1157 ////////////////////////////////////////////////////////////////////////////////
1158 ////////////////////////////////////////////////////////////////////////////////
1160 class PluginItem : public QTreeWidgetItem
1162 public:
1163 PluginItem(QTreeWidget *parent, const KService::Ptr &service)
1164 : QTreeWidgetItem(parent, QStringList(service->name())),
1165 mService(service) {}
1166 PluginItem(QTreeWidgetItem *parent, const KService::Ptr &service)
1167 : QTreeWidgetItem(parent, QStringList(service->name())),
1168 mService(service) {}
1170 KService::Ptr service()
1172 return mService;
1175 private:
1176 KService::Ptr mService;
1180 Dialog for selecting and configuring KOrganizer plugins
1182 KOPrefsDialogPlugins::KOPrefsDialogPlugins(QWidget *parent)
1183 : KPrefsModule(KOPrefs::instance(), parent)
1185 QBoxLayout *topTopLayout = new QVBoxLayout(this);
1187 QWidget *topFrame = new QWidget(this);
1188 topTopLayout->addWidget(topFrame);
1189 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
1191 mTreeWidget = new QTreeWidget(topFrame);
1192 mTreeWidget->setColumnCount(1);
1193 mTreeWidget->setHeaderLabel(i18nc("@title:column plugin name", "Name"));
1194 topLayout->addWidget(mTreeWidget);
1196 mDescription = new QLabel(topFrame);
1197 mDescription->setAlignment(Qt::AlignVCenter);
1198 mDescription->setWordWrap(true);
1199 mDescription->setFrameShape(QLabel::Panel);
1200 mDescription->setFrameShadow(QLabel::Sunken);
1201 mDescription->setMinimumSize(QSize(0, 55));
1202 QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
1203 policy.setHorizontalStretch(0);
1204 policy.setVerticalStretch(0);
1205 policy.setHeightForWidth(mDescription->sizePolicy().hasHeightForWidth());
1206 mDescription->setSizePolicy(policy);
1207 topLayout->addWidget(mDescription);
1209 QWidget *buttonRow = new QWidget(topFrame);
1210 QBoxLayout *buttonRowLayout = new QHBoxLayout(buttonRow);
1211 mConfigureButton = new QPushButton(buttonRow);
1212 KGuiItem::assign(mConfigureButton, KGuiItem(i18nc("@action:button", "Configure &Plugin..."),
1213 QStringLiteral("configure"), QString(),
1214 i18nc("@info:whatsthis",
1215 "This button allows you to configure"
1216 " the plugin that you have selected in the list above")));
1217 buttonRowLayout->addWidget(mConfigureButton);
1218 buttonRowLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding));
1219 topLayout->addWidget(buttonRow);
1221 mPositioningGroupBox = new QGroupBox(i18nc("@title:group", "Position"), topFrame);
1222 //mPositionMonthTop = new QCheckBox(
1223 //i18nc( "@option:check", "Show in the month view" ), mPositioningGroupBox );
1224 mPositionAgendaTop = new QRadioButton(
1225 i18nc("@option:check", "Show at the top of the agenda views"), mPositioningGroupBox);
1226 mPositionAgendaBottom = new QRadioButton(
1227 i18nc("@option:check", "Show at the bottom of the agenda views"), mPositioningGroupBox);
1228 QVBoxLayout *positioningLayout = new QVBoxLayout(mPositioningGroupBox);
1229 //positioningLayout->addWidget( mPositionMonthTop );
1230 positioningLayout->addWidget(mPositionAgendaTop);
1231 positioningLayout->addWidget(mPositionAgendaBottom);
1232 positioningLayout->addStretch(1);
1233 topLayout->addWidget(mPositioningGroupBox);
1235 connect(mConfigureButton, &QPushButton::clicked, this, &KOPrefsDialogPlugins::configure);
1237 //connect( mPositionMonthTop, SIGNAL(clicked()), SLOT(positioningChanged()) );
1238 connect(mPositionAgendaTop, &QRadioButton::clicked, this, &KOPrefsDialogPlugins::positioningChanged);
1239 connect(mPositionAgendaBottom, &QRadioButton::clicked, this, &KOPrefsDialogPlugins::positioningChanged);
1241 connect(mTreeWidget, &QTreeWidget::itemSelectionChanged, this, &KOPrefsDialogPlugins::selectionChanged);
1242 connect(mTreeWidget, &QTreeWidget::itemChanged, this, &KOPrefsDialogPlugins::selectionChanged);
1243 connect(mTreeWidget, &QTreeWidget::itemClicked, this, &KOPrefsDialogPlugins::slotWidChanged);
1245 load();
1247 selectionChanged();
1250 void KOPrefsDialogPlugins::usrReadConfig()
1252 mTreeWidget->clear();
1253 KService::List plugins = KOCore::self()->availablePlugins();
1254 plugins += KOCore::self()->availableParts();
1256 EventViews::PrefsPtr viewPrefs = KOPrefs::instance()->eventViewsPreferences();
1258 QStringList selectedPlugins = viewPrefs->selectedPlugins();
1260 QTreeWidgetItem *decorations =
1261 new QTreeWidgetItem(mTreeWidget, QStringList(
1262 i18nc("@title:group", "Calendar Decorations")));
1263 QTreeWidgetItem *others =
1264 new QTreeWidgetItem(mTreeWidget, QStringList(
1265 i18nc("@title:group", "Other Plugins")));
1267 KService::List::ConstIterator it;
1268 KService::List::ConstIterator end(plugins.constEnd());
1270 for (it = plugins.constBegin(); it != end; ++it) {
1271 QTreeWidgetItem *item = Q_NULLPTR;
1272 if ((*it)->hasServiceType(EventViews::CalendarDecoration::Decoration::serviceType())) {
1273 item = new PluginItem(decorations, *it);
1274 } else if (!(*it)->hasServiceType(QStringLiteral("KOrganizer/PrintPlugin"))) {
1275 // we specifically skip print plugins since we no longer support them
1276 item = new PluginItem(others, *it);
1277 } else {
1278 continue;
1280 if (selectedPlugins.contains((*it)->desktopEntryName())) {
1281 item->setCheckState(0, Qt::Checked);
1282 } else {
1283 item->setCheckState(0, Qt::Unchecked);
1287 decorations->setExpanded(true);
1288 others->setExpanded(true);
1290 mDecorationsAtMonthViewTop = KOPrefs::instance()->decorationsAtMonthViewTop().toSet();
1291 mDecorationsAtAgendaViewTop = viewPrefs->decorationsAtAgendaViewTop().toSet();
1292 mDecorationsAtAgendaViewBottom = viewPrefs->decorationsAtAgendaViewBottom().toSet();
1295 void KOPrefsDialogPlugins::usrWriteConfig()
1297 QStringList selectedPlugins;
1299 for (int i = 0; i < mTreeWidget->topLevelItemCount(); ++i) {
1300 QTreeWidgetItem *serviceTypeGroup = mTreeWidget->topLevelItem(i);
1301 for (int j = 0; j < serviceTypeGroup->childCount(); ++j) {
1302 PluginItem *item = static_cast<PluginItem *>(serviceTypeGroup->child(j));
1303 if (item->checkState(0) == Qt::Checked) {
1304 selectedPlugins.append(item->service()->desktopEntryName());
1308 EventViews::PrefsPtr viewPrefs = KOPrefs::instance()->eventViewsPreferences();
1309 viewPrefs->setSelectedPlugins(selectedPlugins);
1311 KOPrefs::instance()->setDecorationsAtMonthViewTop(mDecorationsAtMonthViewTop.toList());
1312 viewPrefs->setDecorationsAtAgendaViewTop(mDecorationsAtAgendaViewTop.toList());
1313 viewPrefs->setDecorationsAtAgendaViewBottom(mDecorationsAtAgendaViewBottom.toList());
1316 void KOPrefsDialogPlugins::configure()
1318 if (mTreeWidget->selectedItems().count() != 1) {
1319 return;
1322 PluginItem *item = static_cast<PluginItem *>(mTreeWidget->selectedItems().last());
1323 if (!item) {
1324 return;
1327 CalendarSupport::Plugin *plugin = KOCore::self()->loadPlugin(item->service());
1329 if (plugin) {
1330 plugin->configure(this);
1331 delete plugin;
1333 slotWidChanged();
1334 } else {
1335 KMessageBox::sorry(this,
1336 i18nc("@info", "Unable to configure this plugin"),
1337 QStringLiteral("PluginConfigUnable"));
1341 void KOPrefsDialogPlugins::positioningChanged()
1343 if (mTreeWidget->selectedItems().count() != 1) {
1344 return;
1347 PluginItem *item = dynamic_cast<PluginItem *>(mTreeWidget->selectedItems().last());
1348 if (!item) {
1349 return;
1352 QString decoration = item->service()->desktopEntryName();
1354 /*if ( mPositionMonthTop->checkState() == Qt::Checked ) {
1355 if ( !mDecorationsAtMonthViewTop.contains( decoration ) ) {
1356 mDecorationsAtMonthViewTop.insert( decoration );
1358 } else {
1359 mDecorationsAtMonthViewTop.remove( decoration );
1362 if (mPositionAgendaTop->isChecked()) {
1363 if (!mDecorationsAtAgendaViewTop.contains(decoration)) {
1364 mDecorationsAtAgendaViewTop.insert(decoration);
1366 } else {
1367 mDecorationsAtAgendaViewTop.remove(decoration);
1370 if (mPositionAgendaBottom->isChecked()) {
1371 if (!mDecorationsAtAgendaViewBottom.contains(decoration)) {
1372 mDecorationsAtAgendaViewBottom.insert(decoration);
1374 } else {
1375 mDecorationsAtAgendaViewBottom.remove(decoration);
1378 slotWidChanged();
1381 void KOPrefsDialogPlugins::selectionChanged()
1383 mPositioningGroupBox->hide();
1384 //mPositionMonthTop->setChecked( false );
1385 mPositionAgendaTop->setChecked(false);
1386 mPositionAgendaBottom->setChecked(false);
1388 if (mTreeWidget->selectedItems().count() != 1) {
1389 mConfigureButton->setEnabled(false);
1390 mDescription->setText(QString());
1391 return;
1394 PluginItem *item = dynamic_cast<PluginItem *>(mTreeWidget->selectedItems().last());
1395 if (!item) {
1396 mConfigureButton->setEnabled(false);
1397 mDescription->setText(QString());
1398 return;
1401 QVariant variant = item->service()->property(QStringLiteral("X-KDE-KOrganizer-HasSettings"));
1403 bool hasSettings = true;
1404 if (variant.isValid()) {
1405 hasSettings = variant.toBool();
1408 mDescription->setText(item->service()->comment());
1409 if (!hasSettings) {
1410 mConfigureButton->hide();
1411 } else {
1412 mConfigureButton->show();
1413 mConfigureButton->setEnabled(item->checkState(0) == Qt::Checked);
1416 bool hasPosition = false;
1417 if (item->service()->hasServiceType(
1418 EventViews::CalendarDecoration::Decoration::serviceType())) {
1419 QString decoration = item->service()->desktopEntryName();
1420 /*if ( mDecorationsAtMonthViewTop.contains( decoration ) ) {
1421 mPositionMonthTop->setChecked( true );
1422 hasPosition = true;
1424 if (mDecorationsAtAgendaViewTop.contains(decoration)) {
1425 mPositionAgendaTop->setChecked(true);
1426 hasPosition = true;
1428 if (mDecorationsAtAgendaViewBottom.contains(decoration)) {
1429 mPositionAgendaBottom->setChecked(true);
1430 hasPosition = true;
1433 if (!hasPosition) {
1434 // no position has been selected, so default to Agenda Top
1435 mDecorationsAtAgendaViewTop << decoration;
1436 mPositionAgendaTop->setChecked(true);
1439 mPositioningGroupBox->setEnabled(item->checkState(0) == Qt::Checked);
1440 mPositioningGroupBox->show();
1443 slotWidChanged();
1446 extern "C"
1448 Q_DECL_EXPORT KCModule *create_korganizerconfigplugins(QWidget *parent, const char *)
1450 return new KOPrefsDialogPlugins(parent);
1454 ////////////////////////////////////////////////////////////////////////////////
1455 ////////////////////////////////////////////////////////////////////////////////
1457 extern "C"
1459 Q_DECL_EXPORT KCModule *create_korgdesignerfields(QWidget *parent, const char *)
1461 return new KOPrefsDesignerFields(parent);
1465 KOPrefsDesignerFields::KOPrefsDesignerFields(QWidget *parent)
1466 : KCMDesignerFields(parent)
1470 QString KOPrefsDesignerFields::localUiDir()
1472 const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/korganizer/designer/event/");
1473 return dir;
1476 QString KOPrefsDesignerFields::uiPath()
1478 return QStringLiteral("korganizer/designer/event/");
1481 void KOPrefsDesignerFields::writeActivePages(const QStringList &activePages)
1483 CalendarSupport::KCalPrefs::instance()->setActiveDesignerFields(activePages);
1484 CalendarSupport::KCalPrefs::instance()->save();
1487 QStringList KOPrefsDesignerFields::readActivePages()
1489 return CalendarSupport::KCalPrefs::instance()->activeDesignerFields();
1492 QString KOPrefsDesignerFields::applicationName()
1494 return QStringLiteral("KORGANIZER");