Messagelib

themeconfigbutton.cpp
1/* SPDX-FileCopyrightText: 2009 James Bendig <james@imptalk.com>
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
13using namespace MessageList::Core;
14using namespace MessageList::Utils;
15
16class MessageList::Utils::ThemeConfigButtonPrivate
17{
18public:
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
31void 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
46 : QPushButton(i18nc("@action:button", "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
61ThemeConfigButton::~ThemeConfigButton() = default;
62
63#include "moc_themeconfigbutton.cpp"
A specialized QComboBox that lists all message list themes.
A specialized QPushButton that displays the theme configure dialog when pressed.
ThemeConfigButton(QWidget *parent, const ThemeComboBox *themeComboBox=nullptr)
Constructor.
void configureDialogCompleted()
A signal emitted when configure dialog has been successfully completed.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setEnabled(bool)
QWidget * window() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.