Messagelib

aggregationconfigbutton.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/aggregationconfigbutton.h"
6 
7 #include "core/manager.h"
8 #include "utils/aggregationcombobox.h"
9 #include "utils/configureaggregationsdialog.h"
10 
11 #include <KLocalizedString>
12 
13 using namespace MessageList::Core;
14 using namespace MessageList::Utils;
15 
16 class MessageList::Utils::AggregationConfigButtonPrivate
17 {
18 public:
19  AggregationConfigButtonPrivate(AggregationConfigButton *owner)
20  : q(owner)
21  {
22  }
23 
24  AggregationConfigButton *const q;
25 
26  const AggregationComboBox *mAggregationComboBox = nullptr;
27 
28  void slotConfigureAggregations();
29 };
30 
31 AggregationConfigButton::AggregationConfigButton(QWidget *parent, const AggregationComboBox *aggregationComboBox)
32  : QPushButton(i18n("Configure..."), parent)
33  , d(new AggregationConfigButtonPrivate(this))
34 {
35  d->mAggregationComboBox = aggregationComboBox;
36  connect(this, &AggregationConfigButton::pressed, this, [this]() {
37  d->slotConfigureAggregations();
38  });
39 
40  // Keep aggregation combo up-to-date with any changes made in the configure dialog.
41  if (d->mAggregationComboBox) {
42  connect(this, &AggregationConfigButton::configureDialogCompleted, d->mAggregationComboBox, &AggregationComboBox::slotLoadAggregations);
43  }
44  setEnabled(Manager::instance());
45 }
46 
47 AggregationConfigButton::~AggregationConfigButton() = default;
48 
49 void AggregationConfigButtonPrivate::slotConfigureAggregations()
50 {
51  QString currentAggregationID;
52  if (mAggregationComboBox) {
53  currentAggregationID = mAggregationComboBox->currentAggregation();
54  }
55 
56  auto dialog = new ConfigureAggregationsDialog(q->window());
57  dialog->selectAggregation(currentAggregationID);
58  if (dialog->exec()) {
59  Q_EMIT q->configureDialogCompleted();
60  }
61 }
62 
63 #include "moc_aggregationconfigbutton.cpp"
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...)
void setEnabled(bool)
void configureDialogCompleted()
A signal emitted when configure dialog has been successfully completed.
The dialog used for configuring MessageList::Aggregation sets.
A specialized QPushButton that displays the aggregation configure dialog when pressed.
A specialized QComboBox that lists all message list aggregations.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.