2 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
3 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
5 Copyright (C) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
6 Author: Kevin Krammer, krake@kdab.com
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
27 #include "prefs_base.h"
29 #include <KGlobalSettings>
30 #include <KSystemTimeZone>
32 using namespace EventViews
;
34 QSet
<EventViews::EventView::ItemIcon
> iconArrayToSet( const QByteArray
&array
)
36 QSet
<EventViews::EventView::ItemIcon
> set
;
37 for ( int i
=0; i
<array
.count(); ++i
) {
38 if ( i
>= EventViews::EventView::IconCount
) {
39 kWarning() << "Icon array is too big: " << array
.count();
42 if ( array
[i
] != 0 ) {
43 set
.insert( static_cast<EventViews::EventView::ItemIcon
>( i
) );
49 QByteArray
iconSetToArray( const QSet
<EventViews::EventView::ItemIcon
> &set
)
52 for ( int i
=0; i
<EventViews::EventView::IconCount
; ++i
) {
53 const bool contains
= set
.contains( static_cast<EventViews::EventView::ItemIcon
>( i
) );
54 array
.append( contains
? 1 : 0 ) ;
60 QByteArray
agendaViewIconDefaults()
62 QByteArray iconDefaults
;
64 iconDefaults
[EventViews::EventView::CalendarCustomIcon
] = 1;
65 iconDefaults
[EventViews::EventView::TaskIcon
] = 1;
66 iconDefaults
[EventViews::EventView::JournalIcon
] = 1;
67 iconDefaults
[EventViews::EventView::RecurringIcon
] = 1;
68 iconDefaults
[EventViews::EventView::ReminderIcon
] = 1;
69 iconDefaults
[EventViews::EventView::ReadOnlyIcon
] = 1;
70 iconDefaults
[EventViews::EventView::ReplyIcon
] = 0;
75 QByteArray
monthViewIconDefaults()
77 QByteArray iconDefaults
;
79 iconDefaults
[EventViews::EventView::CalendarCustomIcon
] = 1;
80 iconDefaults
[EventViews::EventView::TaskIcon
] = 1;
81 iconDefaults
[EventViews::EventView::JournalIcon
] = 1;
82 iconDefaults
[EventViews::EventView::RecurringIcon
] = 0;
83 iconDefaults
[EventViews::EventView::ReminderIcon
] = 0;
84 iconDefaults
[EventViews::EventView::ReadOnlyIcon
] = 1;
85 iconDefaults
[EventViews::EventView::ReplyIcon
] = 0;
90 class BaseConfig
: public PrefsBase
95 void setResourceColor( const QString
&resource
, const QColor
&color
);
97 void setTimeScaleTimezones( const QStringList
&timeZones
);
98 QStringList
timeScaleTimezones() const;
101 QHash
<QString
,QColor
> mResourceColors
;
102 QColor mDefaultResourceColor
;
104 QFont mDefaultMonthViewFont
;
105 QFont mDefaultAgendaTimeLabelsFont
;
107 KDateTime::Spec mTimeSpec
;
108 QStringList mTimeScaleTimeZones
;
110 QSet
<EventViews::EventView::ItemIcon
> mAgendaViewIcons
;
111 QSet
<EventViews::EventView::ItemIcon
> mMonthViewIcons
;
114 void usrSetDefaults();
115 void usrReadConfig();
116 void usrWriteConfig();
118 void setTimeZoneDefault();
121 BaseConfig::BaseConfig() : PrefsBase()
123 mDefaultResourceColor
= QColor(); //Default is a color invalid
125 mDefaultAgendaTimeLabelsFont
= KGlobalSettings::generalFont();
126 // make a large default time bar font, at least 16 points.
127 mDefaultAgendaTimeLabelsFont
.setPointSize(
128 qMax( mDefaultAgendaTimeLabelsFont
.pointSize() + 4, 16 ) );
130 mDefaultMonthViewFont
= KGlobalSettings::generalFont();
131 // make it a bit smaller
132 mDefaultMonthViewFont
.setPointSize(
133 qMax( mDefaultMonthViewFont
.pointSize() - 2, 6 ) );
135 agendaTimeLabelsFontItem()->setDefaultValue( mDefaultAgendaTimeLabelsFont
);
136 agendaTimeLabelsFontItem()->setDefault();
137 monthViewFontItem()->setDefaultValue( mDefaultMonthViewFont
);
138 monthViewFontItem()->setDefault();
141 void BaseConfig::setResourceColor( const QString
&resource
, const QColor
&color
)
143 mResourceColors
.insert( resource
, color
);
146 void BaseConfig::setTimeScaleTimezones( const QStringList
&list
)
148 mTimeScaleTimeZones
= list
;
151 QStringList
BaseConfig::timeScaleTimezones() const
153 return mTimeScaleTimeZones
;
156 void BaseConfig::usrSetDefaults()
158 setAgendaTimeLabelsFont( mDefaultAgendaTimeLabelsFont
);
159 setMonthViewFont( mDefaultMonthViewFont
);
161 setTimeZoneDefault();
163 PrefsBase::usrSetDefaults();
166 void BaseConfig::usrReadConfig()
168 KConfigGroup
generalConfig( config(), "General" );
170 // Note that the [Category Colors] group was removed after 3.2 due to
171 // an algorithm change. That's why we now use [Category Colors2]
173 KConfigGroup
rColorsConfig( config(), "Resources Colors" );
174 const QStringList colorKeyList
= rColorsConfig
.keyList();
176 QStringList::ConstIterator it3
;
177 for ( it3
= colorKeyList
.begin(); it3
!= colorKeyList
.end(); ++it3
) {
178 QColor color
= rColorsConfig
.readEntry( *it3
, mDefaultResourceColor
);
179 //kDebug() << "key:" << (*it3) << "value:" << color;
180 setResourceColor( *it3
, color
);
183 if ( !mTimeSpec
.isValid() ) {
184 setTimeZoneDefault();
188 config()->setGroup( "FreeBusy" );
189 if ( mRememberRetrievePw
) {
191 KStringHandler::obscure( config()->readEntry( "Retrieve Server Password" ) );
194 KConfigGroup
defaultCalendarConfig( config(), "Calendar" );
196 KConfigGroup
timeScaleConfig( config(), "Timescale" );
197 setTimeScaleTimezones( timeScaleConfig
.readEntry( "Timescale Timezones", QStringList() ) );
199 KConfigGroup
monthViewConfig( config(), "Month View" );
200 KConfigGroup
agendaViewConfig( config(), "Agenda View" );
201 const QByteArray agendaIconArray
=
202 agendaViewConfig
.readEntry
<QByteArray
>( "agendaViewItemIcons", agendaViewIconDefaults() );
203 const QByteArray monthIconArray
=
204 monthViewConfig
.readEntry
<QByteArray
>( "monthViewItemIcons", monthViewIconDefaults() );
206 mAgendaViewIcons
= iconArrayToSet( agendaIconArray
);
207 mMonthViewIcons
= iconArrayToSet( monthIconArray
);
209 KConfigSkeleton::usrReadConfig();
212 void BaseConfig::usrWriteConfig()
214 KConfigGroup
generalConfig( config(), "General" );
216 KConfigGroup
rColorsConfig( config(), "Resources Colors" );
217 QHash
<QString
, QColor
>::const_iterator i
= mResourceColors
.constBegin();
218 while ( i
!= mResourceColors
.constEnd() ) {
219 rColorsConfig
.writeEntry( i
.key(), i
.value() );
224 if ( mRememberRetrievePw
) {
225 config()->writeEntry( "Retrieve Server Password",
226 KStringHandler::obscure( mRetrievePassword
) );
228 config()->deleteEntry( "Retrieve Server Password" );
232 KConfigGroup
timeScaleConfig( config(), "Timescale" );
233 timeScaleConfig
.writeEntry( "Timescale Timezones", timeScaleTimezones() );
235 KConfigGroup
monthViewConfig( config(), "Month View" );
236 KConfigGroup
agendaViewConfig( config(), "Agenda View" );
238 const QByteArray agendaIconArray
= iconSetToArray( mAgendaViewIcons
);
239 const QByteArray monthIconArray
= iconSetToArray( mMonthViewIcons
);
241 agendaViewConfig
.writeEntry
<QByteArray
>( "agendaViewItemIcons", agendaIconArray
);
242 monthViewConfig
.writeEntry
<QByteArray
>( "monthViewItemIcons", monthIconArray
);
244 KConfigSkeleton::usrWriteConfig();
247 void BaseConfig::setTimeZoneDefault()
249 KTimeZone zone
= KSystemTimeZones::local();
250 if ( !zone
.isValid() ) {
251 kError() << "KSystemTimeZones::local() return 0";
255 kDebug () << "----- time zone:" << zone
.name();
263 Private( Prefs
*parent
) : mAppConfig( 0 ), q( parent
) {}
264 Private( Prefs
*parent
, KCoreConfigSkeleton
*appConfig
)
265 : mAppConfig( appConfig
), q( parent
) {}
267 void setTimeZoneDefault();
269 KConfigSkeletonItem
*appConfigItem( const KConfigSkeletonItem
*baseConfigItem
) const;
271 void setBool( KCoreConfigSkeleton::ItemBool
*baseConfigItem
, bool value
);
272 bool getBool( const KCoreConfigSkeleton::ItemBool
*baseConfigItem
) const;
274 void setInt( KCoreConfigSkeleton::ItemInt
*baseConfigItem
, int value
);
275 int getInt( const KCoreConfigSkeleton::ItemInt
*baseConfigItem
) const;
277 void setString( KCoreConfigSkeleton::ItemString
*baseConfigItem
, const QString
&value
);
278 QString
getString( const KCoreConfigSkeleton::ItemString
*baseConfigItem
) const;
280 void setDateTime( KCoreConfigSkeleton::ItemDateTime
*baseConfigItem
, const QDateTime
&value
);
281 QDateTime
getDateTime( const KCoreConfigSkeleton::ItemDateTime
*baseConfigItem
) const;
283 void setStringList( KCoreConfigSkeleton::ItemStringList
*baseConfigItem
,
284 const QStringList
&value
);
285 QStringList
getStringList( const KCoreConfigSkeleton::ItemStringList
*baseConfigItem
) const;
287 void setColor( KConfigSkeleton::ItemColor
*baseConfigItem
, const QColor
&value
);
288 QColor
getColor( const KConfigSkeleton::ItemColor
*baseConfigItem
) const;
290 void setFont( KConfigSkeleton::ItemFont
*baseConfigItem
, const QFont
&value
);
291 QFont
getFont( const KConfigSkeleton::ItemFont
*baseConfigItem
) const;
294 BaseConfig mBaseConfig
;
295 KCoreConfigSkeleton
*mAppConfig
;
301 KConfigSkeletonItem
*Prefs::Private::appConfigItem(
302 const KConfigSkeletonItem
*baseConfigItem
) const
304 Q_ASSERT( baseConfigItem
);
307 return mAppConfig
->findItem( baseConfigItem
->name() );
313 void Prefs::Private::setBool( KCoreConfigSkeleton::ItemBool
*baseConfigItem
, bool value
)
315 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
317 KCoreConfigSkeleton::ItemBool
*item
= dynamic_cast<KCoreConfigSkeleton::ItemBool
*>( appItem
);
319 item
->setValue( value
);
321 kError() << "Application config item" << appItem
->name() << "is not of type Bool";
324 baseConfigItem
->setValue( value
);
328 bool Prefs::Private::getBool( const KCoreConfigSkeleton::ItemBool
*baseConfigItem
) const
330 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
332 KCoreConfigSkeleton::ItemBool
*item
= dynamic_cast<KCoreConfigSkeleton::ItemBool
*>( appItem
);
334 return item
->value();
336 kError() << "Application config item" << appItem
->name() << "is not of type Bool";
338 return baseConfigItem
->value();
341 void Prefs::Private::setInt( KCoreConfigSkeleton::ItemInt
*baseConfigItem
, int value
)
343 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
345 KCoreConfigSkeleton::ItemInt
*item
= dynamic_cast<KCoreConfigSkeleton::ItemInt
*>( appItem
);
347 item
->setValue( value
);
349 kError() << "Application config item" << appItem
->name() << "is not of type Int";
352 baseConfigItem
->setValue( value
);
356 int Prefs::Private::getInt( const KCoreConfigSkeleton::ItemInt
*baseConfigItem
) const
358 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
360 KCoreConfigSkeleton::ItemInt
*item
= dynamic_cast<KCoreConfigSkeleton::ItemInt
*>( appItem
);
362 return item
->value();
364 kError() << "Application config item" << appItem
->name() << "is not of type Int";
366 return baseConfigItem
->value();
369 void Prefs::Private::setString( KCoreConfigSkeleton::ItemString
*baseConfigItem
,
370 const QString
&value
)
372 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
374 KCoreConfigSkeleton::ItemString
*item
=
375 dynamic_cast<KCoreConfigSkeleton::ItemString
*>( appItem
);
378 item
->setValue( value
);
380 kError() << "Application config item" << appItem
->name() << "is not of type String";
383 baseConfigItem
->setValue( value
);
387 QString
Prefs::Private::getString( const KCoreConfigSkeleton::ItemString
*baseConfigItem
) const
389 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
391 KCoreConfigSkeleton::ItemString
*item
=
392 dynamic_cast<KCoreConfigSkeleton::ItemString
*>( appItem
);
395 return item
->value();
397 kError() << "Application config item" << appItem
->name() << "is not of type String";
399 return baseConfigItem
->value();
402 void Prefs::Private::setDateTime( KCoreConfigSkeleton::ItemDateTime
*baseConfigItem
,
403 const QDateTime
&value
)
405 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
407 KCoreConfigSkeleton::ItemDateTime
*item
=
408 dynamic_cast<KCoreConfigSkeleton::ItemDateTime
*>( appItem
);
411 item
->setValue( value
);
413 kError() << "Application config item" << appItem
->name() << "is not of type DateTime";
416 baseConfigItem
->setValue( value
);
420 QDateTime
Prefs::Private::getDateTime(
421 const KCoreConfigSkeleton::ItemDateTime
*baseConfigItem
) const
423 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
425 KCoreConfigSkeleton::ItemDateTime
*item
=
426 dynamic_cast<KCoreConfigSkeleton::ItemDateTime
*>( appItem
);
429 return item
->value();
431 kError() << "Application config item" << appItem
->name() << "is not of type DateTime";
433 return baseConfigItem
->value();
436 void Prefs::Private::setStringList( KCoreConfigSkeleton::ItemStringList
*baseConfigItem
,
437 const QStringList
&value
)
439 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
441 KCoreConfigSkeleton::ItemStringList
*item
=
442 dynamic_cast<KCoreConfigSkeleton::ItemStringList
*>( appItem
);
445 item
->setValue( value
);
447 kError() << "Application config item" << appItem
->name() << "is not of type StringList";
450 baseConfigItem
->setValue( value
);
454 QStringList
Prefs::Private::getStringList(
455 const KCoreConfigSkeleton::ItemStringList
*baseConfigItem
) const
457 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
459 KCoreConfigSkeleton::ItemStringList
*item
=
460 dynamic_cast<KCoreConfigSkeleton::ItemStringList
*>( appItem
);
463 return item
->value();
465 kError() << "Application config item" << appItem
->name() << "is not of type StringList";
467 return baseConfigItem
->value();
470 void Prefs::Private::setColor( KConfigSkeleton::ItemColor
*baseConfigItem
, const QColor
&value
)
472 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
474 KConfigSkeleton::ItemColor
*item
= dynamic_cast<KConfigSkeleton::ItemColor
*>( appItem
);
476 item
->setValue( value
);
478 kError() << "Application config item" << appItem
->name() << "is not of type Color";
481 baseConfigItem
->setValue( value
);
485 QColor
Prefs::Private::getColor( const KConfigSkeleton::ItemColor
*baseConfigItem
) const
487 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
489 KConfigSkeleton::ItemColor
*item
= dynamic_cast<KConfigSkeleton::ItemColor
*>( appItem
);
491 return item
->value();
493 kError() << "Application config item" << appItem
->name() << "is not of type Color";
495 return baseConfigItem
->value();
498 void Prefs::Private::setFont( KConfigSkeleton::ItemFont
*baseConfigItem
, const QFont
&value
)
500 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
502 KConfigSkeleton::ItemFont
*item
= dynamic_cast<KConfigSkeleton::ItemFont
*>( appItem
);
504 item
->setValue( value
);
506 kError() << "Application config item" << appItem
->name() << "is not of type Font";
509 baseConfigItem
->setValue( value
);
513 QFont
Prefs::Private::getFont( const KConfigSkeleton::ItemFont
*baseConfigItem
) const
515 KConfigSkeletonItem
*appItem
= appConfigItem( baseConfigItem
);
517 KConfigSkeleton::ItemFont
*item
= dynamic_cast<KConfigSkeleton::ItemFont
*>( appItem
);
519 return item
->value();
521 kError() << "Application config item" << appItem
->name() << "is not of type Font";
523 return baseConfigItem
->value();
526 Prefs::Prefs() : d( new Private( this ) )
530 Prefs::Prefs( KCoreConfigSkeleton
*appConfig
) : d( new Private( this, appConfig
) )
539 void Prefs::readConfig()
541 d
->mBaseConfig
.readConfig();
542 if ( d
->mAppConfig
) {
543 d
->mAppConfig
->readConfig();
547 void Prefs::writeConfig()
549 d
->mBaseConfig
.writeConfig();
550 if ( d
->mAppConfig
) {
551 d
->mAppConfig
->writeConfig();
555 void Prefs::setMarcusBainsShowSeconds( bool showSeconds
)
557 d
->setBool( d
->mBaseConfig
.marcusBainsShowSecondsItem(), showSeconds
);
560 bool Prefs::marcusBainsShowSeconds() const
562 return d
->getBool( d
->mBaseConfig
.marcusBainsShowSecondsItem() );
565 void Prefs::setAgendaMarcusBainsLineLineColor( const QColor
&color
)
567 d
->setColor( d
->mBaseConfig
.agendaMarcusBainsLineLineColorItem(), color
);
570 QColor
Prefs::agendaMarcusBainsLineLineColor() const
572 return d
->getColor( d
->mBaseConfig
.agendaMarcusBainsLineLineColorItem() );
575 void Prefs::setMarcusBainsEnabled( bool enabled
)
577 d
->setBool( d
->mBaseConfig
.marcusBainsEnabledItem(), enabled
);
580 bool Prefs::marcusBainsEnabled() const
582 return d
->getBool( d
->mBaseConfig
.marcusBainsEnabledItem() );
585 void Prefs::setAgendaMarcusBainsLineFont( const QFont
&font
)
587 d
->setFont( d
->mBaseConfig
.agendaMarcusBainsLineFontItem(), font
);
590 QFont
Prefs::agendaMarcusBainsLineFont() const
592 return d
->getFont( d
->mBaseConfig
.agendaMarcusBainsLineFontItem() );
595 void Prefs::setHourSize( int size
)
597 d
->setInt( d
->mBaseConfig
.hourSizeItem(), size
);
600 int Prefs::hourSize() const
602 return d
->getInt( d
->mBaseConfig
.hourSizeItem() );
605 void Prefs::setDayBegins( const QDateTime
&dateTime
)
607 d
->setDateTime( d
->mBaseConfig
.dayBeginsItem(), dateTime
);
610 QDateTime
Prefs::dayBegins() const
612 return d
->getDateTime( d
->mBaseConfig
.dayBeginsItem() );
615 void Prefs::setWorkingHoursStart( const QDateTime
&dateTime
)
617 d
->setDateTime( d
->mBaseConfig
.workingHoursStartItem(), dateTime
);
620 QDateTime
Prefs::workingHoursStart() const
622 return d
->getDateTime( d
->mBaseConfig
.workingHoursStartItem() );
625 void Prefs::setWorkingHoursEnd( const QDateTime
&dateTime
)
627 d
->setDateTime( d
->mBaseConfig
.workingHoursEndItem(), dateTime
);
630 QDateTime
Prefs::workingHoursEnd() const
632 return d
->getDateTime( d
->mBaseConfig
.workingHoursEndItem() );
635 void Prefs::setSelectionStartsEditor( bool startEditor
)
637 d
->setBool( d
->mBaseConfig
.selectionStartsEditorItem(), startEditor
);
640 bool Prefs::selectionStartsEditor() const
642 return d
->getBool( d
->mBaseConfig
.selectionStartsEditorItem() );
645 void Prefs::setAgendaGridWorkHoursBackgroundColor( const QColor
&color
)
647 d
->setColor( d
->mBaseConfig
.agendaGridWorkHoursBackgroundColorItem(), color
);
650 QColor
Prefs::agendaGridWorkHoursBackgroundColor() const
652 return d
->getColor( d
->mBaseConfig
.agendaGridWorkHoursBackgroundColorItem() );
655 void Prefs::setAgendaGridHighlightColor( const QColor
&color
)
657 d
->setColor( d
->mBaseConfig
.agendaGridHighlightColorItem(), color
);
660 QColor
Prefs::agendaGridHighlightColor() const
662 return d
->getColor( d
->mBaseConfig
.agendaGridHighlightColorItem() );
665 void Prefs::setAgendaGridBackgroundColor( const QColor
&color
)
667 d
->setColor( d
->mBaseConfig
.agendaGridBackgroundColorItem(), color
);
670 QColor
Prefs::agendaGridBackgroundColor() const
672 return d
->getColor( d
->mBaseConfig
.agendaGridBackgroundColorItem() );
675 void Prefs::setEnableAgendaItemIcons( bool enable
)
677 d
->setBool( d
->mBaseConfig
.enableAgendaItemIconsItem(), enable
);
680 bool Prefs::enableAgendaItemIcons() const
682 return d
->getBool( d
->mBaseConfig
.enableAgendaItemIconsItem() );
685 void Prefs::setTodosUseCategoryColors( bool useColors
)
687 d
->setBool( d
->mBaseConfig
.todosUseCategoryColorsItem(), useColors
);
690 bool Prefs::todosUseCategoryColors() const
692 return d
->getBool( d
->mBaseConfig
.todosUseCategoryColorsItem() );
695 void Prefs::setAgendaHolidaysBackgroundColor( const QColor
&color
) const
697 d
->setColor( d
->mBaseConfig
.agendaHolidaysBackgroundColorItem(), color
);
700 QColor
Prefs::agendaHolidaysBackgroundColor() const
702 return d
->getColor( d
->mBaseConfig
.agendaHolidaysBackgroundColorItem() );
705 void Prefs::setAgendaViewColors( int colors
)
707 d
->setInt( d
->mBaseConfig
.agendaViewColorsItem(), colors
);
710 int Prefs::agendaViewColors() const
712 return d
->getInt( d
->mBaseConfig
.agendaViewColorsItem() );
715 void Prefs::setAgendaViewFont( const QFont
&font
)
717 d
->setFont( d
->mBaseConfig
.agendaViewFontItem(), font
);
720 QFont
Prefs::agendaViewFont() const
722 return d
->getFont( d
->mBaseConfig
.agendaViewFontItem() );
725 void Prefs::setMonthViewFont( const QFont
&font
)
727 d
->setFont( d
->mBaseConfig
.monthViewFontItem(), font
);
730 QFont
Prefs::monthViewFont() const
732 return d
->getFont( d
->mBaseConfig
.monthViewFontItem() );
735 QColor
Prefs::monthGridBackgroundColor() const
737 return d
->getColor( d
->mBaseConfig
.monthGridBackgroundColorItem() );
740 void Prefs::setMonthGridBackgroundColor( const QColor
&color
)
742 d
->setColor( d
->mBaseConfig
.monthGridBackgroundColorItem(), color
);
745 QColor
Prefs::monthGridWorkHoursBackgroundColor() const
747 return d
->getColor( d
->mBaseConfig
.monthGridWorkHoursBackgroundColorItem() );
750 void Prefs::monthGridWorkHoursBackgroundColor( const QColor
&color
)
752 d
->setColor( d
->mBaseConfig
.monthGridWorkHoursBackgroundColorItem(), color
);
755 int Prefs::monthViewColors() const
757 return d
->getInt( d
->mBaseConfig
.monthViewColorsItem() );
760 void Prefs::setMonthViewColors( int colors
) const
762 d
->setInt( d
->mBaseConfig
.monthViewColorsItem(), colors
);
765 void Prefs::setEnableMonthItemIcons( bool enable
)
767 d
->setBool( d
->mBaseConfig
.enableMonthItemIconsItem(), enable
);
770 bool Prefs::enableMonthItemIcons() const
772 return d
->getBool( d
->mBaseConfig
.enableMonthItemIconsItem() );
775 bool Prefs::showTimeInMonthView() const
777 return d
->getBool( d
->mBaseConfig
.showTimeInMonthViewItem() );
780 void Prefs::setShowTimeInMonthView( bool show
)
782 d
->setBool( d
->mBaseConfig
.showTimeInMonthViewItem(), show
);
785 bool Prefs::showTodosMonthView() const
787 return d
->getBool( d
->mBaseConfig
.showTodosMonthViewItem() );
790 void Prefs::setShowTodosMonthView( bool enable
)
792 d
->setBool( d
->mBaseConfig
.showTodosMonthViewItem(), enable
);
795 bool Prefs::showJournalsMonthView() const
797 return d
->getBool( d
->mBaseConfig
.showJournalsMonthViewItem() );
800 void Prefs::setShowJournalsMonthView( bool enable
)
802 d
->setBool( d
->mBaseConfig
.showJournalsMonthViewItem(), enable
);
805 bool Prefs::fullViewMonth() const
807 return d
->getBool( d
->mBaseConfig
.fullViewMonthItem() );
810 void Prefs::setFullViewMonth( bool fullView
)
812 d
->setBool( d
->mBaseConfig
.fullViewMonthItem(), fullView
);
815 bool Prefs::sortCompletedTodosSeparately() const
817 return d
->getBool( d
->mBaseConfig
.sortCompletedTodosSeparatelyItem() );
820 void Prefs::setSortCompletedTodosSeparately( bool enable
)
822 d
->setBool( d
->mBaseConfig
.sortCompletedTodosSeparatelyItem(), enable
);
825 void Prefs::setEnableToolTips( bool enable
)
827 d
->setBool( d
->mBaseConfig
.enableToolTipsItem(), enable
);
830 bool Prefs::enableToolTips() const
832 return d
->getBool( d
->mBaseConfig
.enableToolTipsItem() );
835 void Prefs::setShowTodosAgendaView( bool show
)
837 d
->setBool( d
->mBaseConfig
.showTodosAgendaViewItem(), show
);
840 bool Prefs::showTodosAgendaView() const
842 return d
->getBool( d
->mBaseConfig
.showTodosAgendaViewItem() );
845 void Prefs::setAgendaTimeLabelsFont( const QFont
&font
)
847 d
->setFont( d
->mBaseConfig
.agendaTimeLabelsFontItem(), font
);
850 QFont
Prefs::agendaTimeLabelsFont() const
852 return d
->getFont( d
->mBaseConfig
.agendaTimeLabelsFontItem() );
855 KDateTime::Spec
Prefs::timeSpec() const
857 return KSystemTimeZones::local();
860 void Prefs::setTimeSpec( const KDateTime::Spec
&spec
)
862 d
->mBaseConfig
.mTimeSpec
= spec
;
865 bool Prefs::colorAgendaBusyDays() const
867 return d
->getBool( d
->mBaseConfig
.colorBusyDaysEnabledItem() );
870 bool Prefs::colorMonthBusyDays() const
872 return d
->getBool( d
->mBaseConfig
.colorMonthBusyDaysEnabledItem() );
875 QColor
Prefs::viewBgBusyColor() const
877 return d
->getColor( d
->mBaseConfig
.viewBgBusyColorItem() );
880 void Prefs::setViewBgBusyColor( const QColor
&color
)
882 d
->mBaseConfig
.mViewBgBusyColor
= color
;
885 QColor
Prefs::holidayColor() const
887 return d
->getColor( d
->mBaseConfig
.holidayColorItem() );
890 void Prefs::setHolidayColor( const QColor
&color
)
892 d
->mBaseConfig
.mHolidayColor
= color
;
895 QColor
Prefs::agendaViewBackgroundColor() const
897 return d
->getColor( d
->mBaseConfig
.agendaBgColorItem() );
900 void Prefs::setAgendaViewBackgroundColor( const QColor
&color
)
902 d
->mBaseConfig
.mAgendaBgColor
= color
;
905 QColor
Prefs::workingHoursColor() const
907 return d
->getColor( d
->mBaseConfig
.workingHoursColorItem() );
910 void Prefs::setWorkingHoursColor( const QColor
&color
)
912 d
->mBaseConfig
.mWorkingHoursColor
= color
;
915 QColor
Prefs::todoDueTodayColor() const
917 return d
->getColor( d
->mBaseConfig
.todoDueTodayColorItem() );
920 void Prefs::setTodoDueTodayColor( const QColor
&color
)
922 d
->mBaseConfig
.mTodoDueTodayColor
= color
;
925 QColor
Prefs::todoOverdueColor() const
927 return d
->getColor( d
->mBaseConfig
.todoOverdueColorItem() );
930 void Prefs::setTodoOverdueColor( const QColor
&color
)
932 d
->mBaseConfig
.mTodoOverdueColor
= color
;
935 void Prefs::setColorAgendaBusyDays( bool enable
)
937 d
->mBaseConfig
.mColorBusyDaysEnabled
= enable
;
940 void Prefs::setColorMonthBusyDays( bool enable
)
942 d
->mBaseConfig
.mColorMonthBusyDaysEnabled
= enable
;
945 void Prefs::setResourceColor ( const QString
&cal
, const QColor
&color
)
947 d
->mBaseConfig
.setResourceColor( cal
, color
);
950 QColor
Prefs::resourceColor( const QString
&cal
)
953 if ( !cal
.isEmpty() ) {
954 if ( d
->mBaseConfig
.mResourceColors
.contains( cal
) ) {
955 color
= d
->mBaseConfig
.mResourceColors
.value( cal
);
956 if ( !color
.isValid() ) {
961 return d
->mBaseConfig
.mDefaultResourceColor
;
964 // assign default color if enabled
965 if ( !cal
.isEmpty() && !color
.isValid() &&
966 d
->getBool( d
->mBaseConfig
.assignDefaultResourceColorsItem() ) ) {
967 QColor
defColor( 0x37, 0x7A, 0xBC );
968 const int seed
= d
->getInt( d
->mBaseConfig
.defaultResourceColorSeedItem() );
969 const QStringList colors
= d
->getStringList( d
->mBaseConfig
.defaultResourceColorsItem() );
970 if ( seed
> 0 && seed
- 1 < (int)colors
.size() ) {
971 defColor
= QColor( colors
[seed
-1] );
974 defColor
.getHsv( &h
, &s
, &v
);
975 h
= ( seed
% 12 ) * 30;
976 s
-= s
* static_cast<int>( ( ( seed
/ 12 ) % 2 ) * 0.5 );
977 defColor
.setHsv( h
, s
, v
);
979 d
->setInt( d
->mBaseConfig
.defaultResourceColorSeedItem(), ( seed
+ 1 ) );
980 d
->mBaseConfig
.setResourceColor( cal
, defColor
);
981 color
= d
->mBaseConfig
.mResourceColors
[cal
];
984 if ( color
.isValid() ) {
987 return d
->mBaseConfig
.mDefaultResourceColor
;
991 QStringList
Prefs::timeScaleTimezones() const
993 return d
->mBaseConfig
.timeScaleTimezones();
996 void Prefs::setTimeScaleTimezones( const QStringList
&list
)
998 d
->mBaseConfig
.setTimeScaleTimezones( list
);
1001 KConfigSkeleton::ItemFont
*Prefs::fontItem( const QString
&name
) const
1003 KConfigSkeletonItem
*item
= d
->mAppConfig
? d
->mAppConfig
->findItem( name
) : 0;
1006 item
= d
->mBaseConfig
.findItem( name
);
1009 return dynamic_cast<KConfigSkeleton::ItemFont
*>( item
);
1012 QStringList
Prefs::selectedPlugins() const
1014 return d
->mBaseConfig
.mSelectedPlugins
;
1017 QStringList
Prefs::decorationsAtAgendaViewTop() const
1019 return d
->mBaseConfig
.decorationsAtAgendaViewTop();
1022 QStringList
Prefs::decorationsAtAgendaViewBottom() const
1024 return d
->mBaseConfig
.decorationsAtAgendaViewBottom();
1027 void Prefs::setSelectedPlugins( const QStringList
&plugins
)
1029 d
->mBaseConfig
.setSelectedPlugins( plugins
);
1032 void Prefs::setDecorationsAtAgendaViewTop( const QStringList
&decorations
)
1034 d
->mBaseConfig
.setDecorationsAtAgendaViewTop( decorations
);
1037 void Prefs::setDecorationsAtAgendaViewBottom( const QStringList
&decorations
)
1039 d
->mBaseConfig
.setDecorationsAtAgendaViewBottom( decorations
);
1042 QSet
<EventViews::EventView::ItemIcon
> Prefs::agendaViewIcons() const
1044 return d
->mBaseConfig
.mAgendaViewIcons
;
1047 void Prefs::setAgendaViewIcons( const QSet
<EventViews::EventView::ItemIcon
> &icons
)
1049 d
->mBaseConfig
.mAgendaViewIcons
= icons
;
1052 QSet
<EventViews::EventView::ItemIcon
> Prefs::monthViewIcons() const
1054 return d
->mBaseConfig
.mMonthViewIcons
;
1057 void Prefs::setMonthViewIcons( const QSet
<EventViews::EventView::ItemIcon
> &icons
)
1059 d
->mBaseConfig
.mMonthViewIcons
= icons
;
1062 void Prefs::setFlatListTodo( bool enable
)
1064 d
->mBaseConfig
.mFlatListTodo
= enable
;
1067 bool Prefs::flatListTodo() const
1069 return d
->mBaseConfig
.mFlatListTodo
;
1072 void Prefs::setFullViewTodo( bool enable
)
1074 d
->mBaseConfig
.mFullViewTodo
= enable
;
1077 bool Prefs::fullViewTodo() const
1079 return d
->mBaseConfig
.mFullViewTodo
;
1082 bool Prefs::enableTodoQuickSearch() const
1084 return d
->mBaseConfig
.mEnableTodoQuickSearch
;
1087 void Prefs::setEnableTodoQuickSearch( bool enable
)
1089 d
->mBaseConfig
.mEnableTodoQuickSearch
= enable
;
1092 bool Prefs::enableQuickTodo() const
1094 return d
->mBaseConfig
.mEnableQuickTodo
;
1097 void Prefs::setEnableQuickTodo( bool enable
)
1099 d
->mBaseConfig
.mEnableQuickTodo
= enable
;
1102 bool Prefs::highlightTodos() const
1104 return d
->mBaseConfig
.mHighlightTodos
;
1107 void Prefs::setHighlightTodos( bool highlight
)
1109 d
->mBaseConfig
.mHighlightTodos
= highlight
;
1112 KConfig
*Prefs::config() const
1114 return d
->mAppConfig
? d
->mAppConfig
->config() : d
->mBaseConfig
.config();