Commit 597b6235 authored by Laurent Montel's avatar Laurent Montel 😁

Add own dialog box so we can save/load dialog size. We can use own...

Add own dialog box so we can save/load dialog size. We can use own plaintexteditor with modern feature
parent 73d5dcca
......@@ -15,3 +15,15 @@ macro(add_kdepimaddons_unittest _source)
endmacro ()
add_kdepimaddons_unittest(rendertest.cpp)
macro(add_messageviewer_bodyformatter_class_unittest _source _additional)
set( _test ${_source} ${common_SRCS} ${_additional})
get_filename_component(_name ${_source} NAME_WE)
ecm_add_test(${_test}
TEST_NAME ${_name}
NAME_PREFIX "messageviewerplugins-"
LINK_LIBRARIES KF5::MessageViewer Qt5::Test KF5::PimTextEdit KF5::I18n
)
endmacro ()
add_messageviewer_bodyformatter_class_unittest(reactiontoinvitationdialogtest.cpp "../calendar/reactiontoinvitationdialog.cpp")
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "reactiontoinvitationdialogtest.h"
#include "../calendar/reactiontoinvitationdialog.h"
#include <QDialogButtonBox>
#include <QTest>
#include <QLabel>
#include <kpimtextedit/plaintexteditorwidget.h>
ReactionToInvitationDialogTest::ReactionToInvitationDialogTest(QObject *parent)
: QObject(parent)
{
}
ReactionToInvitationDialogTest::~ReactionToInvitationDialogTest()
{
}
void ReactionToInvitationDialogTest::shouldHaveDefaultValue()
{
ReactionToInvitationDialog w;
QLabel *label = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(label);
KPIMTextEdit::PlainTextEditorWidget *mPlainTextEditor = w.findChild<KPIMTextEdit::PlainTextEditorWidget *>(QStringLiteral("plaintexteditor"));
QVERIFY(mPlainTextEditor);
QVERIFY(mPlainTextEditor->toPlainText().isEmpty());
QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QVERIFY(w.comment().isEmpty());
}
QTEST_MAIN(ReactionToInvitationDialogTest)
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef REACTIONTOINVITATIONDIALOGTEST_H
#define REACTIONTOINVITATIONDIALOGTEST_H
#include <QObject>
class ReactionToInvitationDialogTest : public QObject
{
Q_OBJECT
public:
explicit ReactionToInvitationDialogTest(QObject *parent = Q_NULLPTR);
~ReactionToInvitationDialogTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // REACTIONTOINVITATIONDIALOGTEST_H
add_definitions(-DTRANSLATION_DOMAIN=\"messageviewer_text_calendar_plugin\")
set(messageviewer_bodypartformatter_text_calendar_PART_SRCS text_calendar.cpp delegateselector.cpp attendeeselector.cpp memorycalendarmemento.cpp syncitiphandler.cpp)
set(messageviewer_bodypartformatter_text_calendar_PART_SRCS
text_calendar.cpp delegateselector.cpp attendeeselector.cpp memorycalendarmemento.cpp syncitiphandler.cpp
reactiontoinvitationdialog.cpp)
ecm_qt_declare_logging_category(messageviewer_bodypartformatter_text_calendar_PART_SRCS HEADER text_calendar_debug.h IDENTIFIER TEXT_CALENDAR_LOG CATEGORY_NAME log_text_calendar)
......@@ -27,6 +29,7 @@ target_link_libraries(messageviewer_bodypartformatter_text_calendar
KF5::Libkdepim
KF5::MessageViewer
KF5::IncidenceEditor
KF5::PimTextEdit
)
install(TARGETS messageviewer_bodypartformatter_text_calendar DESTINATION ${KDE_INSTALL_PLUGINDIR})
......
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "reactiontoinvitationdialog.h"
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QLabel>
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
#include "kpimtextedit/plaintexteditorwidget.h"
ReactionToInvitationDialog::ReactionToInvitationDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setObjectName(QStringLiteral("layout"));
QLabel *label = new QLabel(i18n("Comment:"), this);
label->setObjectName(QStringLiteral("label"));
layout->addWidget(label);
mPlainTextEditor = new KPIMTextEdit::PlainTextEditorWidget(this);
mPlainTextEditor->setObjectName(QStringLiteral("plaintexteditor"));
layout->addWidget(mPlainTextEditor);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
layout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ReactionToInvitationDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ReactionToInvitationDialog::reject);
readConfig();
}
ReactionToInvitationDialog::~ReactionToInvitationDialog()
{
writeConfig();
}
QString ReactionToInvitationDialog::comment() const
{
return mPlainTextEditor->toPlainText();
}
void ReactionToInvitationDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "ReactionToInvitationDialog");
const QSize size = group.readEntry("Size", QSize(600, 400));
if (size.isValid()) {
resize(size);
}
}
void ReactionToInvitationDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "ReactionToInvitationDialog");
group.writeEntry("Size", size());
group.sync();
}
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef REACTIONTOINVITATIONDIALOG_H
#define REACTIONTOINVITATIONDIALOG_H
#include <QDialog>
namespace KPIMTextEdit {
class PlainTextEditorWidget;
}
class ReactionToInvitationDialog : public QDialog
{
Q_OBJECT
public:
explicit ReactionToInvitationDialog(QWidget *parent = Q_NULLPTR);
~ReactionToInvitationDialog();
QString comment() const;
private:
void writeConfig();
void readConfig();
KPIMTextEdit::PlainTextEditorWidget *mPlainTextEditor;
};
#endif // REACTIONTOINVITATIONDIALOG_H
......@@ -35,6 +35,7 @@
#include "delegateselector.h"
#include "memorycalendarmemento.h"
#include "syncitiphandler.h"
#include "reactiontoinvitationdialog.h"
#include <MessageViewer/BodyPartURLHandler>
#include <MessageViewer/MessageViewerSettings>
......@@ -81,6 +82,7 @@ using namespace KCalCore;
#include <QDesktopServices>
#include <QInputDialog>
#include <QMenu>
#include <QPointer>
using namespace MailTransport;
......@@ -881,12 +883,16 @@ public:
// get comment for tentative acceptance
if (askForComment(status)) {
bool ok = false;
const QString comment = QInputDialog::getMultiLineText(0,
i18n("Reaction to Invitation"), i18n("Comment:"), QString(), &ok);
if (!ok) {
QPointer<ReactionToInvitationDialog> dlg = new ReactionToInvitationDialog(0);
dlg->setWindowTitle(i18n("Reaction to Invitation"));
QString comment;
if (dlg->exec()) {
comment = dlg->comment();
} else {
delete dlg;
return true;
}
if (comment.isEmpty()) {
KMessageBox::error(
0,
......@@ -1205,13 +1211,16 @@ public:
}
Incidence::Ptr incidence(stringToIncidence(iCal));
if (askForComment(Attendee::Declined)) {
bool ok = false;
const QString comment(
QInputDialog::getMultiLineText(0,
i18n("Decline Counter Proposal"), i18n("Comment:"), QString(), &ok));
if (!ok) {
QPointer<ReactionToInvitationDialog> dlg = new ReactionToInvitationDialog(0);
dlg->setWindowTitle(i18n("Decline Counter Proposal"));
QString comment;
if (dlg->exec()) {
comment = dlg->comment();
} else {
delete dlg;
return true;
}
if (comment.isEmpty()) {
KMessageBox::error(
0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment