Messagelib

defaultgrantleeheaderstyleinterface.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "defaultgrantleeheaderstyleinterface.h"
8#include "globalsettings_base.h"
9#include "messageviewer/headerstyle.h"
10#include "messageviewer/headerstyleplugin.h"
11#include <GrantleeTheme/GrantleeThemeManager>
12#include <KActionCollection>
13#include <KToggleAction>
14#include <QStandardPaths>
15
16using namespace MessageViewer;
17DefaultGrantleeHeaderStyleInterface::DefaultGrantleeHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent)
18 : MessageViewer::HeaderStyleInterface(plugin, parent)
19{
20}
21
22DefaultGrantleeHeaderStyleInterface::~DefaultGrantleeHeaderStyleInterface() = default;
23
24void DefaultGrantleeHeaderStyleInterface::createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac)
25{
26 const QStringList defaultThemePath =
28 if (!defaultThemePath.isEmpty()) {
29 const QString themeName = DefaultGrantleeHeaderStylePluginSettings::self()->themeName();
30 mDefaultTheme =
31 GrantleeTheme::ThemeManager::loadTheme(defaultThemePath.at(0) + QLatin1Char('/') + themeName, themeName, QStringLiteral("kmail_default.desktop"));
32 }
33 mHeaderStylePlugin->headerStyle()->setTheme(mDefaultTheme);
34 auto act = new KToggleAction(mDefaultTheme.name(), this);
35 ac->addAction(QStringLiteral("default_grantlee_theme"), act);
36 connect(act, &KToggleAction::triggered, this, &DefaultGrantleeHeaderStyleInterface::slotDefaultGrantleeHeaders);
37 mAction.append(act);
38 addActionToMenu(menu, actionGroup);
39}
40
41void DefaultGrantleeHeaderStyleInterface::activateAction()
42{
43 mAction.at(0)->setChecked(true);
44}
45
46void DefaultGrantleeHeaderStyleInterface::slotDefaultGrantleeHeaders()
47{
48 mHeaderStylePlugin->headerStyle()->setTheme(mDefaultTheme);
49 slotStyleChanged();
50}
51
52#include "moc_defaultgrantleeheaderstyleinterface.cpp"
QAction * addAction(const QString &name, const QObject *receiver=nullptr, const char *member=nullptr)
The HeaderStyleInterface class.
The HeaderStylePlugin class.
void triggered(bool checked)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
bool isEmpty() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.