Mailcommon

selectthunderbirdfilterfilesdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "selectthunderbirdfilterfilesdialog.h"
8#include "selectthunderbirdfilterfileswidget.h"
9#include <KLocalizedString>
10#include <KSharedConfig>
11
12#include <KConfigGroup>
13#include <KWindowConfig>
14#include <QDialogButtonBox>
15#include <QPushButton>
16#include <QVBoxLayout>
17#include <QWindow>
18
19using namespace MailCommon;
20namespace
21{
22static const char mySelectThunderbirdFilterFilesDialogGroupName[] = "SelectThunderbirdFilterFilesDialog";
23}
24SelectThunderbirdFilterFilesDialog::SelectThunderbirdFilterFilesDialog(const QString &defaultSettingPath, QWidget *parent)
25 : QDialog(parent)
26 , mSelectFilterFilesWidget(new MailCommon::SelectThunderbirdFilterFilesWidget(defaultSettingPath, this))
27{
28 setWindowTitle(i18nc("@title:window", "Select thunderbird filter files"));
29 setModal(true);
30 auto mainLayout = new QVBoxLayout(this);
31
32 mainLayout->addWidget(mSelectFilterFilesWidget);
33
35 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
36 okButton->setDefault(true);
38 connect(buttonBox, &QDialogButtonBox::accepted, this, &SelectThunderbirdFilterFilesDialog::accept);
39 connect(buttonBox, &QDialogButtonBox::rejected, this, &SelectThunderbirdFilterFilesDialog::reject);
40 connect(mSelectFilterFilesWidget, &MailCommon::SelectThunderbirdFilterFilesWidget::enableOkButton, okButton, &QPushButton::setEnabled);
41 okButton->setEnabled(false);
42 mainLayout->addWidget(buttonBox);
43 readConfig();
44}
45
46SelectThunderbirdFilterFilesDialog::~SelectThunderbirdFilterFilesDialog()
47{
48 writeConfig();
49}
50
51QStringList SelectThunderbirdFilterFilesDialog::selectedFiles() const
52{
53 return mSelectFilterFilesWidget->selectedFiles();
54}
55
56void SelectThunderbirdFilterFilesDialog::setStartDir(const QUrl &url)
57{
58 mSelectFilterFilesWidget->setStartDir(url);
59}
60
61void SelectThunderbirdFilterFilesDialog::readConfig()
62{
63 create(); // ensure a window is created
64 windowHandle()->resize(QSize(500, 300));
65 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectThunderbirdFilterFilesDialogGroupName));
67 resize(windowHandle()->size()); // workaround for QTBUG-40584
68}
69
70void SelectThunderbirdFilterFilesDialog::writeConfig()
71{
72 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectThunderbirdFilterFilesDialogGroupName));
74 group.sync();
75}
76
77#include "moc_selectthunderbirdfilterfilesdialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
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 setEnabled(bool)
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.