Messagelib

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

KDE's Doxygen guidelines are available online.