Fix url
[kdepim.git] / kmail / agents / sendlateragent / sendlaterconfiguredialog.cpp
blobddfc9364aad57ceb7b403d2dda529f10b35bcbed
1 /*
2 Copyright (C) 2013-2016 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "sendlaterconfiguredialog.h"
21 #include "sendlaterconfigurewidget.h"
22 #include "kmail-version.h"
24 #include <KConfigGroup>
25 #include <KLocalizedString>
26 #include <KSharedConfig>
27 #include <KHelpMenu>
28 #include <QMenu>
29 #include <kaboutdata.h>
30 #include <KMessageBox>
31 #include <QIcon>
33 #include <QApplication>
35 SendLaterConfigureDialog::SendLaterConfigureDialog(QWidget *parent)
36 : QDialog(parent)
38 setWindowTitle(i18n("Configure"));
39 setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
40 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
41 QVBoxLayout *mainLayout = new QVBoxLayout(this);
42 setLayout(mainLayout);
43 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
44 okButton->setDefault(true);
45 okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
46 connect(buttonBox, &QDialogButtonBox::rejected, this, &SendLaterConfigureDialog::reject);
48 mWidget = new SendLaterWidget(this);
49 mWidget->setObjectName(QStringLiteral("sendlaterwidget"));
50 connect(mWidget, &SendLaterWidget::sendNow, this, &SendLaterConfigureDialog::sendNow);
51 mainLayout->addWidget(mWidget);
52 mainLayout->addWidget(buttonBox);
53 connect(okButton, &QPushButton::clicked, this, &SendLaterConfigureDialog::slotSave);
55 readConfig();
57 KAboutData aboutData = KAboutData(
58 QStringLiteral("sendlateragent"),
59 i18n("Send Later Agent"),
60 QStringLiteral(KDEPIM_VERSION),
61 i18n("Send emails later agent."),
62 KAboutLicense::GPL_V2,
63 i18n("Copyright (C) 2013-2016 Laurent Montel"));
65 aboutData.addAuthor(i18n("Laurent Montel"),
66 i18n("Maintainer"), QStringLiteral("montel@kde.org"));
68 QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
69 aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
70 i18nc("EMAIL OF TRANSLATORS", "Your emails"));
72 KHelpMenu *helpMenu = new KHelpMenu(this, aboutData, true);
73 //Initialize menu
74 QMenu *menu = helpMenu->menu();
75 helpMenu->action(KHelpMenu::menuAboutApp)->setIcon(QIcon::fromTheme(QStringLiteral("kmail")));
76 buttonBox->button(QDialogButtonBox::Help)->setMenu(menu);
79 SendLaterConfigureDialog::~SendLaterConfigureDialog()
81 writeConfig();
84 QList<Akonadi::Item::Id> SendLaterConfigureDialog::messagesToRemove() const
86 return mWidget->messagesToRemove();
89 void SendLaterConfigureDialog::slotSave()
91 mWidget->save();
92 accept();
95 void SendLaterConfigureDialog::slotNeedToReloadConfig()
97 mWidget->needToReload();
100 void SendLaterConfigureDialog::readConfig()
102 KConfigGroup group(KSharedConfig::openConfig(), "SendLaterConfigureDialog");
103 const QSize sizeDialog = group.readEntry("Size", QSize(800, 600));
104 if (sizeDialog.isValid()) {
105 resize(sizeDialog);
107 mWidget->restoreTreeWidgetHeader(group.readEntry("HeaderState", QByteArray()));
110 void SendLaterConfigureDialog::writeConfig()
112 KConfigGroup group(KSharedConfig::openConfig(), "SendLaterConfigureDialog");
113 group.writeEntry("Size", size());
114 mWidget->saveTreeWidgetHeader(group);