Commit ec272346 authored by Volker Krause's avatar Volker Krause
Browse files

Port from KCalPrefs::categoryColor to Akonadi::TagCache::tagColor

parent fe88be2b
Pipeline #214151 passed with stage
in 3 minutes and 49 seconds
......@@ -10,22 +10,18 @@
#include <CalendarSupport/KCalPrefs>
#include <Akonadi/TagCache>
#include <KLocalizedString>
QColor KOCoreHelper::categoryColor(const QStringList &categories)
{
if (categories.isEmpty()) {
return CalendarSupport::KCalPrefs::instance()->unsetCategoryColor();
}
// FIXME: Correctly treat events with multiple categories
const QString cat = categories.first();
QColor bgColor;
if (cat.isEmpty()) {
bgColor = CalendarSupport::KCalPrefs::instance()->unsetCategoryColor();
} else {
bgColor = CalendarSupport::KCalPrefs::instance()->categoryColor(cat);
if (!categories.isEmpty()) {
bgColor = Akonadi::TagCache::instance()->tagColor(categories.at(0));
}
return bgColor;
return bgColor.isValid() ? bgColor : CalendarSupport::KCalPrefs::instance()->unsetCategoryColor();
}
QString KOCoreHelper::holidayString(const QDate &dt)
......
......@@ -11,6 +11,7 @@
#include "koprefs.h"
#include <Akonadi/CollectionComboBox>
#include <Akonadi/EntityTreeModel>
#include <Akonadi/TagCache>
#include <Akonadi/TagSelectionComboBox>
#include <CalendarSupport/KCalPrefs>
#include <KColorButton>
......@@ -184,7 +185,7 @@ void KOPrefsDialogColorsAndFonts::usrWriteConfig()
{
QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin();
while (i != mCategoryDict.constEnd()) {
CalendarSupport::KCalPrefs::instance()->setCategoryColor(i.key(), i.value());
Akonadi::TagCache::instance()->setTagColor(i.key(), i.value());
++i;
}
......@@ -231,8 +232,7 @@ void KOPrefsDialogColorsAndFonts::updateCategoryColor()
const QString cat = mCategoryCombo->currentText();
QColor color = mCategoryDict.value(cat);
if (!color.isValid()) {
// TODO get this from the tag
color = CalendarSupport::KCalPrefs::instance()->categoryColor(cat);
color = Akonadi::TagCache::instance()->tagColor(cat);
}
if (color.isValid()) {
mCategoryButton->setColor(color);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment