Messagelib

defaultgrantleeheaderstyleinterface.cpp
1 /*
2  SPDX-FileCopyrightText: 2015-2021 Laurent Montel <[email protected]>
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 
16 using namespace MessageViewer;
17 DefaultGrantleeHeaderStyleInterface::DefaultGrantleeHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent)
18  : MessageViewer::HeaderStyleInterface(plugin, parent)
19 {
20 }
21 
22 DefaultGrantleeHeaderStyleInterface::~DefaultGrantleeHeaderStyleInterface() = default;
23 
24 void 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 
41 void DefaultGrantleeHeaderStyleInterface::activateAction()
42 {
43  mAction.at(0)->setChecked(true);
44 }
45 
46 void DefaultGrantleeHeaderStyleInterface::slotDefaultGrantleeHeaders()
47 {
48  mHeaderStylePlugin->headerStyle()->setTheme(mDefaultTheme);
49  slotStyleChanged();
50 }
void triggered(bool checked)
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
const T & at(int i) const const
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
The HeaderStyleInterface class.
bool isEmpty() const const
The HeaderStylePlugin class.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:16:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.