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
13using namespace MessageList::Core;
14using namespace MessageList::Utils;
15
16class MessageList::Utils::AggregationConfigButtonPrivate
17{
18public:
19 AggregationConfigButtonPrivate(AggregationConfigButton *owner)
20 : q(owner)
21 {
22 }
23
25
26 const AggregationComboBox *mAggregationComboBox = nullptr;
27
28 void slotConfigureAggregations();
29};
30
32 : QPushButton(i18nc("@action:button", "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
47AggregationConfigButton::~AggregationConfigButton() = default;
48
49void 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"
A specialized QComboBox that lists all message list aggregations.
A specialized QPushButton that displays the aggregation configure dialog when pressed.
void configureDialogCompleted()
A signal emitted when configure dialog has been successfully completed.
AggregationConfigButton(QWidget *parent, const AggregationComboBox *aggregationComboBox=nullptr)
Constructor.
The dialog used for configuring MessageList::Aggregation sets.
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 Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.