Commit cc591031 authored by chriadam's avatar chriadam

Merge branch 'jb51280' into 'master'

[nemo-qml-plugin-calendar] Use mKCal::Notebook color as canonical color. Contributes to JB#51280

See merge request !72
parents 20c3c979 7ccf9e49
......@@ -689,13 +689,15 @@ void CalendarWorker::setNotebookColor(const QString &notebookUid, const QString
return;
if (mNotebooks.value(notebookUid).color != color) {
if (mKCal::Notebook::Ptr mkNotebook = mStorage->notebook(notebookUid)) {
mkNotebook->setColor(color);
mStorage->updateNotebook(mkNotebook);
}
CalendarData::Notebook notebook = mNotebooks.value(notebookUid);
notebook.color = color;
mNotebooks.insert(notebook.uid, notebook);
QSettings settings("nemo", "nemo-qml-plugin-calendar");
settings.setValue("colors/" + notebook.uid, notebook.color);
emit notebooksChanged(mNotebooks.values());
}
}
......@@ -950,11 +952,20 @@ void CalendarWorker::loadNotebooks()
notebook.excluded = true;
}
notebook.color = settings.value("colors/" + notebook.uid, QString()).toString();
if (notebook.color.isEmpty())
notebook.color = mkNotebook->color();
if (notebook.color.isEmpty())
notebook.color = defaultNotebookColors.at((nextDefaultNotebookColor++) % defaultNotebookColors.count());
const QString &confColor = settings.value("colors/" + notebook.uid, QString()).toString();
const QString &notebookColor = confColor.isEmpty() ? mkNotebook->color() : confColor;
const bool confHasColor = !confColor.isEmpty();
notebook.color = notebookColor.isEmpty()
? defaultNotebookColors.at((nextDefaultNotebookColor++) % defaultNotebookColors.count())
: notebookColor;
bool canRemoveConf = true;
if (notebook.color != mkNotebook->color()) {
mkNotebook->setColor(notebook.color);
canRemoveConf = mStorage->updateNotebook(mkNotebook);
}
if (confHasColor && canRemoveConf) {
settings.remove("colors/" + notebook.uid);
}
QString accountStr = mkNotebook->account();
if (!accountStr.isEmpty()) {
......
Markdown is supported
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