Messagelib

themeconfigbutton.cpp
1 /* SPDX-FileCopyrightText: 2009 James Bendig <[email protected]>
2 
3  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
4 */
5 #include "utils/themeconfigbutton.h"
6 
7 #include "core/manager.h"
8 #include "core/theme.h"
9 #include "utils/configurethemesdialog.h"
10 #include "utils/themecombobox.h"
11 #include "utils/themecombobox_p.h"
12 
13 #include <KLocalizedString>
14 
15 using namespace MessageList::Core;
16 using namespace MessageList::Utils;
17 
18 class MessageList::Utils::ThemeConfigButtonPrivate
19 {
20 public:
21  explicit ThemeConfigButtonPrivate(ThemeConfigButton *owner)
22  : q(owner)
23  {
24  }
25 
26  ThemeConfigButton *const q;
27 
28  const ThemeComboBox *mThemeComboBox = nullptr;
29 
30  void slotConfigureThemes();
31 };
32 
33 void ThemeConfigButtonPrivate::slotConfigureThemes()
34 {
35  QString currentThemeID;
36  if (mThemeComboBox) {
37  currentThemeID = mThemeComboBox->currentTheme();
38  }
39 
40  auto dialog = new ConfigureThemesDialog(q->window());
41  dialog->selectTheme(currentThemeID);
42  if (dialog->exec()) {
43  Q_EMIT q->configureDialogCompleted();
44  }
45 }
46 
47 ThemeConfigButton::ThemeConfigButton(QWidget *parent, const ThemeComboBox *themeComboBox)
48  : QPushButton(i18n("Configure..."), parent)
49  , d(new ThemeConfigButtonPrivate(this))
50 {
51  d->mThemeComboBox = themeComboBox;
52  connect(this, &ThemeConfigButton::pressed, this, [this]() {
53  d->slotConfigureThemes();
54  });
55 
56  // Keep theme combo up-to-date with any changes made in the configure dialog.
57  if (d->mThemeComboBox) {
58  connect(this, &ThemeConfigButton::configureDialogCompleted, d->mThemeComboBox, &ThemeComboBox::slotLoadThemes);
59  }
60  setEnabled(Manager::instance());
61 }
62 
63 ThemeConfigButton::~ThemeConfigButton() = default;
64 
65 #include "moc_themeconfigbutton.cpp"
The implementation independent part of the MessageList library.
Definition: aggregation.h:21
void configureDialogCompleted()
A signal emitted when configure dialog has been successfully completed.
A specialized QPushButton that displays the theme configure dialog when pressed.
void setEnabled(bool)
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
A specialized QComboBox that lists all message list themes.
Definition: themecombobox.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Dec 4 2021 23:12:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.