File indexing completed on 2025-02-16 04:54:13

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "knoteutils.h"
0008 #include "attributes/notedisplayattribute.h"
0009 #include "knotes_debug.h"
0010 #include "knotesglobalconfig.h"
0011 
0012 #include <Akonadi/ServerManager>
0013 
0014 #include <QDBusInterface>
0015 
0016 void KNoteUtils::updateConfiguration()
0017 {
0018     QString service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, QStringLiteral("akonadi_notes_agent"));
0019 
0020     QDBusInterface interface(service, QStringLiteral("/NotesAgent"));
0021     if (interface.isValid()) {
0022         interface.call(QStringLiteral("configurationChanged"));
0023     } else {
0024         qCDebug(KNOTES_LOG) << " Agent not launched";
0025     }
0026 }
0027 
0028 void KNoteUtils::setDefaultValue(Akonadi::Item &item)
0029 {
0030     auto attribute = item.attribute<NoteShared::NoteDisplayAttribute>(Akonadi::Item::AddIfMissing);
0031 
0032     attribute->setBackgroundColor(KNotesGlobalConfig::self()->bgColor());
0033     attribute->setForegroundColor(KNotesGlobalConfig::self()->fgColor());
0034     attribute->setSize(QSize(KNotesGlobalConfig::self()->width(), KNotesGlobalConfig::self()->height()));
0035     attribute->setRememberDesktop(KNotesGlobalConfig::self()->rememberDesktop());
0036     attribute->setTabSize(KNotesGlobalConfig::self()->tabSize());
0037     attribute->setFont(KNotesGlobalConfig::self()->font());
0038     attribute->setTitleFont(KNotesGlobalConfig::self()->titleFont());
0039     attribute->setDesktop(KNotesGlobalConfig::self()->desktop());
0040     attribute->setIsHidden(KNotesGlobalConfig::self()->hideNote());
0041     attribute->setPosition(KNotesGlobalConfig::self()->position());
0042     attribute->setShowInTaskbar(KNotesGlobalConfig::self()->showInTaskbar());
0043     attribute->setKeepAbove(KNotesGlobalConfig::self()->keepAbove());
0044     attribute->setKeepBelow(KNotesGlobalConfig::self()->keepBelow());
0045     attribute->setAutoIndent(KNotesGlobalConfig::self()->autoIndent());
0046 }