Mailcommon

filteractionmissingsoundurldialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2016-2022 Laurent Montel <[email protected]>
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 <QDialogButtonBox>
14 #include <QLabel>
15 #include <QPushButton>
16 #include <QVBoxLayout>
17 
18 using namespace MailCommon;
19 
20 FilterActionMissingSoundUrlDialog::FilterActionMissingSoundUrlDialog(const QString &filtername, const QString &argStr, QWidget *parent)
21  : QDialog(parent)
22  , mUrlWidget(new KUrlRequester(this))
23 {
24  setModal(true);
25  setWindowTitle(i18nc("@title:window", "Select sound"));
26 
27  auto mainLayout = new QVBoxLayout(this);
28 
29  auto label = new QLabel(i18n("Sound file was \"%1\".", argStr));
30  label->setObjectName(QStringLiteral("oldlabel"));
31  mainLayout->addWidget(label);
32 
33  label = new QLabel(this);
34  label->setObjectName(QStringLiteral("selectlabel"));
35  label->setText(
36  i18n("Sound file is missing. "
37  "Please select a sound to use with filter \"%1\"",
38  filtername));
39  label->setWordWrap(true);
40  mainLayout->addWidget(label);
41  mUrlWidget->setObjectName(QStringLiteral("urlwidget"));
42  mainLayout->addWidget(mUrlWidget);
43 
45  buttonBox->setObjectName(QStringLiteral("buttonbox"));
46  QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
47  okButton->setDefault(true);
48  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
49  connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingSoundUrlDialog::accept);
50  connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingSoundUrlDialog::reject);
51 
52  mainLayout->addWidget(buttonBox);
53  readConfig();
54 }
55 
56 FilterActionMissingSoundUrlDialog::~FilterActionMissingSoundUrlDialog()
57 {
58  writeConfig();
59 }
60 
61 QString FilterActionMissingSoundUrlDialog::soundUrl() const
62 {
63  return mUrlWidget->url().path();
64 }
65 
66 void FilterActionMissingSoundUrlDialog::readConfig()
67 {
68  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingSoundUrlDialog");
69 
70  const QSize size = group.readEntry("Size", QSize(500, 300));
71  if (size.isValid()) {
72  resize(size);
73  }
74 }
75 
76 void FilterActionMissingSoundUrlDialog::writeConfig()
77 {
78  KConfigGroup group(KSharedConfig::openStateConfig(), "FilterActionMissingSoundUrlDialog");
79  group.writeEntry("Size", size());
80 }
bool isValid() const const
void setShortcut(const QKeySequence &key)
void readConfig()
QString i18n(const char *text, const TYPE &arg...)
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
Key_Return
QString label(StandardShortcut id)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void setDefault(bool)
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.