Mailcommon

filteractionmissingsoundurldialog.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 "filteractionmissingsoundurldialog.h"
8
9#include <KConfigGroup>
10#include <KLocalizedString>
11#include <KSharedConfig>
12#include <KUrlRequester>
13#include <KWindowConfig>
14#include <QDialogButtonBox>
15#include <QLabel>
16#include <QPushButton>
17#include <QVBoxLayout>
18#include <QWindow>
19
20using namespace MailCommon;
21namespace
22{
23static const char myFilterActionMissingSoundUrlDialogGroupName[] = "FilterActionMissingSoundUrlDialog";
24}
25
26FilterActionMissingSoundUrlDialog::FilterActionMissingSoundUrlDialog(const QString &filtername, const QString &argStr, QWidget *parent)
27 : QDialog(parent)
28 , mUrlWidget(new KUrlRequester(this))
29{
30 setModal(true);
31 setWindowTitle(i18nc("@title:window", "Select sound"));
32
33 auto mainLayout = new QVBoxLayout(this);
34
35 auto label = new QLabel(i18nc("@label:textbox", "Sound file was \"%1\".", argStr));
36 label->setObjectName(QLatin1StringView("oldlabel"));
37 mainLayout->addWidget(label);
38
39 label = new QLabel(this);
40 label->setObjectName(QLatin1StringView("selectlabel"));
41 label->setText(
42 i18n("Sound file is missing. "
43 "Please select a sound to use with filter \"%1\"",
44 filtername));
45 label->setWordWrap(true);
46 mainLayout->addWidget(label);
47 mUrlWidget->setObjectName(QLatin1StringView("urlwidget"));
48 mainLayout->addWidget(mUrlWidget);
49
51 buttonBox->setObjectName(QLatin1StringView("buttonbox"));
52 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
53 okButton->setDefault(true);
55 connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingSoundUrlDialog::accept);
56 connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingSoundUrlDialog::reject);
57
58 mainLayout->addWidget(buttonBox);
59 readConfig();
60}
61
62FilterActionMissingSoundUrlDialog::~FilterActionMissingSoundUrlDialog()
63{
64 writeConfig();
65}
66
67QString FilterActionMissingSoundUrlDialog::soundUrl() const
68{
69 return mUrlWidget->url().path();
70}
71
72void FilterActionMissingSoundUrlDialog::readConfig()
73{
74 create(); // ensure a window is created
75 windowHandle()->resize(QSize(500, 300));
76 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingSoundUrlDialogGroupName));
78 resize(windowHandle()->size()); // workaround for QTBUG-40584
79}
80
81void FilterActionMissingSoundUrlDialog::writeConfig()
82{
83 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myFilterActionMissingSoundUrlDialogGroupName));
85 group.sync();
86}
87
88#include "moc_filteractionmissingsoundurldialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QUrl url() const
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)
QString path(ComponentFormattingOptions options) const const
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 Sat Dec 21 2024 17:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.