File indexing completed on 2024-12-15 04:54:44
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/aggregationconfigbutton.h" 0006 0007 #include "core/manager.h" 0008 #include "utils/aggregationcombobox.h" 0009 #include "utils/configureaggregationsdialog.h" 0010 0011 #include <KLocalizedString> 0012 0013 using namespace MessageList::Core; 0014 using namespace MessageList::Utils; 0015 0016 class MessageList::Utils::AggregationConfigButtonPrivate 0017 { 0018 public: 0019 AggregationConfigButtonPrivate(AggregationConfigButton *owner) 0020 : q(owner) 0021 { 0022 } 0023 0024 AggregationConfigButton *const q; 0025 0026 const AggregationComboBox *mAggregationComboBox = nullptr; 0027 0028 void slotConfigureAggregations(); 0029 }; 0030 0031 AggregationConfigButton::AggregationConfigButton(QWidget *parent, const AggregationComboBox *aggregationComboBox) 0032 : QPushButton(i18n("Configure..."), parent) 0033 , d(new AggregationConfigButtonPrivate(this)) 0034 { 0035 d->mAggregationComboBox = aggregationComboBox; 0036 connect(this, &AggregationConfigButton::pressed, this, [this]() { 0037 d->slotConfigureAggregations(); 0038 }); 0039 0040 // Keep aggregation combo up-to-date with any changes made in the configure dialog. 0041 if (d->mAggregationComboBox) { 0042 connect(this, &AggregationConfigButton::configureDialogCompleted, d->mAggregationComboBox, &AggregationComboBox::slotLoadAggregations); 0043 } 0044 setEnabled(Manager::instance()); 0045 } 0046 0047 AggregationConfigButton::~AggregationConfigButton() = default; 0048 0049 void AggregationConfigButtonPrivate::slotConfigureAggregations() 0050 { 0051 QString currentAggregationID; 0052 if (mAggregationComboBox) { 0053 currentAggregationID = mAggregationComboBox->currentAggregation(); 0054 } 0055 0056 auto dialog = new ConfigureAggregationsDialog(q->window()); 0057 dialog->selectAggregation(currentAggregationID); 0058 if (dialog->exec()) { 0059 Q_EMIT q->configureDialogCompleted(); 0060 } 0061 } 0062 0063 #include "moc_aggregationconfigbutton.cpp"