Mailcommon

filteractionmissingidentitydialog.cpp
1/*
2 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "filteractionmissingidentitydialog.h"
8#include "kernel/mailkernel.h"
9
10#include <KConfigGroup>
11#include <KLocalizedString>
12#include <KSharedConfig>
13
14#include <KWindowConfig>
15#include <QDialogButtonBox>
16#include <QLabel>
17#include <QPushButton>
18#include <QVBoxLayout>
19#include <QWindow>
20
21#include <KIdentityManagementWidgets/IdentityCombo>
22
23using namespace MailCommon;
24namespace
25{
26static const char myFilterActionMissingIdentityDialogConfigGroupName[] = "FilterActionMissingIdentityDialog";
27}
28FilterActionMissingIdentityDialog::FilterActionMissingIdentityDialog(const QString &filtername, QWidget *parent)
29 : QDialog(parent)
30{
31 setModal(true);
32 setWindowTitle(i18nc("@title:window", "Select Identity"));
33 auto mainLayout = new QVBoxLayout(this);
34
35 auto label = new QLabel(this);
36 label->setObjectName(QLatin1StringView("label"));
37 label->setText(
38 i18n("Filter identity is missing. "
39 "Please select an identity to use with filter \"%1\"",
40 filtername));
41 label->setWordWrap(true);
42 mainLayout->addWidget(label);
43 mComboBoxIdentity = new KIdentityManagementWidgets::IdentityCombo(KernelIf->identityManager(), this);
44 mComboBoxIdentity->setObjectName(QLatin1StringView("comboboxidentity"));
45 mainLayout->addWidget(mComboBoxIdentity);
46
48 buttonBox->setObjectName(QLatin1StringView("buttonbox"));
49
50 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
52 connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingIdentityDialog::accept);
53 connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingIdentityDialog::reject);
54 mainLayout->addWidget(buttonBox);
55 okButton->setDefault(true);
56
57 readConfig();
58}
59
60FilterActionMissingIdentityDialog::~FilterActionMissingIdentityDialog()
61{
62 writeConfig();
63}
64
65void FilterActionMissingIdentityDialog::readConfig()
66{
67 create(); // ensure a window is created
68 windowHandle()->resize(QSize(500, 300));
69 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingIdentityDialogConfigGroupName));
71 resize(windowHandle()->size()); // workaround for QTBUG-40584
72}
73
74void FilterActionMissingIdentityDialog::writeConfig()
75{
76 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingIdentityDialogConfigGroupName));
78 group.sync();
79}
80
81int FilterActionMissingIdentityDialog::selectedIdentity() const
82{
83 return mComboBoxIdentity->currentIdentity();
84}
85
86#include "moc_filteractionmissingidentitydialog.cpp"
KIdentityManagementCore::Identity::Id currentIdentity() const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal)
KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config)
The filter dialog.
void setShortcut(const QKeySequence &key)
void setDefault(bool)
Key_Return
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void create(WId window, bool initializeWindow, bool destroyOldWindow)
void resize(const QSize &)
QWindow * windowHandle() const const
void resize(const QSize &newSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:02:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.