File indexing completed on 2024-12-15 04:54:45
0001 /* SPDX-FileCopyrightText: 2009 James Bendig <james@imptalk.com> 0002 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 #include "utils/themeconfigbutton.h" 0006 0007 #include "core/manager.h" 0008 #include "utils/configurethemesdialog.h" 0009 #include "utils/themecombobox.h" 0010 0011 #include <KLocalizedString> 0012 0013 using namespace MessageList::Core; 0014 using namespace MessageList::Utils; 0015 0016 class MessageList::Utils::ThemeConfigButtonPrivate 0017 { 0018 public: 0019 explicit ThemeConfigButtonPrivate(ThemeConfigButton *owner) 0020 : q(owner) 0021 { 0022 } 0023 0024 ThemeConfigButton *const q; 0025 0026 const ThemeComboBox *mThemeComboBox = nullptr; 0027 0028 void slotConfigureThemes(); 0029 }; 0030 0031 void ThemeConfigButtonPrivate::slotConfigureThemes() 0032 { 0033 QString currentThemeID; 0034 if (mThemeComboBox) { 0035 currentThemeID = mThemeComboBox->currentTheme(); 0036 } 0037 0038 auto dialog = new ConfigureThemesDialog(q->window()); 0039 dialog->selectTheme(currentThemeID); 0040 if (dialog->exec()) { 0041 Q_EMIT q->configureDialogCompleted(); 0042 } 0043 } 0044 0045 ThemeConfigButton::ThemeConfigButton(QWidget *parent, const ThemeComboBox *themeComboBox) 0046 : QPushButton(i18n("Configure..."), parent) 0047 , d(new ThemeConfigButtonPrivate(this)) 0048 { 0049 d->mThemeComboBox = themeComboBox; 0050 connect(this, &ThemeConfigButton::pressed, this, [this]() { 0051 d->slotConfigureThemes(); 0052 }); 0053 0054 // Keep theme combo up-to-date with any changes made in the configure dialog. 0055 if (d->mThemeComboBox) { 0056 connect(this, &ThemeConfigButton::configureDialogCompleted, d->mThemeComboBox, &ThemeComboBox::slotLoadThemes); 0057 } 0058 setEnabled(Manager::instance()); 0059 } 0060 0061 ThemeConfigButton::~ThemeConfigButton() = default; 0062 0063 #include "moc_themeconfigbutton.cpp"