[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim-addons/Applications/16.08] plugins/messageviewer/bodypartformatter: Add own dialog box so we
From:       Montel Laurent <montel () kde ! org>
Date:       2016-08-05 11:29:28
Message-ID: E1bVdJg-0003e2-Uf () code ! kde ! org
[Download RAW message or body]

Git commit 597b62357b40e2ce8d8810cde48163403fb590cd by Montel Laurent.
Committed on 05/08/2016 at 11:28.
Pushed by mlaurent into branch 'Applications/16.08'.

Add own dialog box so we can save/load dialog size. We can use own plaintexteditor \
with modern feature

M  +12   -0    plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
A  +56   -0    plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.cpp \
[License: GPL (v2+)] A  +36   -0    \
plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.h    \
[License: GPL (v2+)] M  +4    -1    \
plugins/messageviewer/bodypartformatter/calendar/CMakeLists.txt A  +75   -0    \
plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp     \
[License: GPL (v2+)] A  +43   -0    \
plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h     \
[License: GPL (v2+)] M  +18   -9    \
plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp

http://commits.kde.org/kdepim-addons/597b62357b40e2ce8d8810cde48163403fb590cd

diff --git a/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt \
b/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt index \
                2c9cf6a..a187479 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
+++ b/plugins/messageviewer/bodypartformatter/autotests/CMakeLists.txt
@@ -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")
diff --git a/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.cpp \
b/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.cpp
 new file mode 100644
index 0000000..d927bd3
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.cpp
 @@ -0,0 +1,56 @@
+/*
+   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)
diff --git a/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.h \
b/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.h \
new file mode 100644 index 0000000..4125847
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/autotests/reactiontoinvitationdialogtest.h
 @@ -0,0 +1,36 @@
+/*
+   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
diff --git a/plugins/messageviewer/bodypartformatter/calendar/CMakeLists.txt \
b/plugins/messageviewer/bodypartformatter/calendar/CMakeLists.txt index \
                6e863c0..abbafe2 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/CMakeLists.txt
+++ b/plugins/messageviewer/bodypartformatter/calendar/CMakeLists.txt
@@ -1,7 +1,9 @@
 
 
 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})
diff --git a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp \
b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp new \
file mode 100644 index 0000000..d21996f
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp
@@ -0,0 +1,75 @@
+/*
+   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();
+}
diff --git a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h \
b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h new \
file mode 100644 index 0000000..820e964
--- /dev/null
+++ b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h
@@ -0,0 +1,43 @@
+/*
+   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
diff --git a/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp \
b/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp index \
                9e1e76e..ebb344a 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp
+++ b/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp
@@ -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,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic