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

KDE's Doxygen guidelines are available online.