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{
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"
The HeaderStyleInterface class.
The HeaderStylePlugin class.
void triggered(bool checked)
void append(const T &value)
const T & at(int i) const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
T qobject_cast(QObject *object)
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:37:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.