[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [pim-sieve-editor] /: Use pimcommon purpose menu widget
From: Laurent Montel <null () kde ! org>
Date: 2018-09-27 5:58:27
Message-ID: E1g5PJj-0007aT-0Z () code ! kde ! org
[Download RAW message or body]
Git commit 442f36edb322928b9f85b24714df5c3240243e32 by Laurent Montel.
Committed on 27/09/2018 at 05:58.
Pushed by mlaurent into branch 'master'.
Use pimcommon purpose menu widget
M +0 -10 CMakeLists.txt
M +0 -1 config-sieveeditor.h.cmake
M +1 -4 src/CMakeLists.txt
M +12 -55 src/sieveeditormainwindow.cpp
M +0 -10 src/sieveeditormainwindow.h
A +44 -0 src/sievepurposemenuwidget.cpp [License: LGPL (v2+)]
A +38 -0 src/sievepurposemenuwidget.h [License: LGPL (v2+)]
https://commits.kde.org/pim-sieve-editor/442f36edb322928b9f85b24714df5c3240243e32
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3fd6047..c632ec2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,16 +61,6 @@ find_package(KF5Crash ${KF5_VERSION} REQUIRED)
find_package(KF5Bookmarks ${KF5_VERSION} REQUIRED)
find_package(KF5IconThemes ${KF5_VERSION} REQUIRED)
find_package(KF5KIO ${KF5_VERSION} REQUIRED)
-find_package(KF5Purpose CONFIG QUIET)
-set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "Support for sharing file"
- TYPE OPTIONAL
- )
-if (KF5Purpose_FOUND)
- message(STATUS "Found KF5 Purpose, filesharing enabled")
- set(KF5_USE_PURPOSE true)
-else()
- message(STATUS "KF5 Purpose not found, filesharing disabled")
-endif()
# Find KdepimLibs Package
find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED)
diff --git a/config-sieveeditor.h.cmake b/config-sieveeditor.h.cmake
index de85784..8b13789 100644
--- a/config-sieveeditor.h.cmake
+++ b/config-sieveeditor.h.cmake
@@ -1,2 +1 @@
-#cmakedefine KF5_USE_PURPOSE 1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d74a6de..8102f7d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -40,6 +40,7 @@ set(sieveeditor_LIB_SRCS
sieveeditorconfigureserverpage.cpp
sieveeditorbookmarks.cpp
sieveeditoremptytabwidgetlabel.cpp
+ sievepurposemenuwidget.cpp
${sieveeditor_importimapsettings_SRCS}
${sieveeditor_importimapsettings_check_SRCS}
)
@@ -70,10 +71,6 @@ target_link_libraries(libsieveeditor
KF5::KManageSieve
)
-if (KF5_USE_PURPOSE)
- target_link_libraries(libsieveeditor PRIVATE KF5::Purpose KF5::PurposeWidgets)
-endif()
-
set_target_properties(libsieveeditor
PROPERTIES OUTPUT_NAME sieveeditor VERSION ${KDEPIM_LIB_VERSION} SOVERSION \
${KDEPIM_LIB_SOVERSION} )
diff --git a/src/sieveeditormainwindow.cpp b/src/sieveeditormainwindow.cpp
index b92d812..94046a3 100644
--- a/src/sieveeditormainwindow.cpp
+++ b/src/sieveeditormainwindow.cpp
@@ -25,6 +25,7 @@
#include "sieveserversettings.h"
#include "sieveeditorcentralwidget.h"
#include "sieveeditorglobalconfig.h"
+#include "sievepurposemenuwidget.h"
#include "sieveeditorbookmarks.h"
#include "importwizard/importimapsettingwizard.h"
#include "PimCommon/KActionMenuChangeCase"
@@ -35,12 +36,6 @@
#include <KMessageBox>
#include <PimCommon/NetworkManager>
-#ifdef KF5_USE_PURPOSE
-#include <Purpose/AlternativesModel>
-#include <PurposeWidgets/Menu>
-#include <QJsonArray>
-#endif
-
#include <KLocalizedString>
#include <KConfigGroup>
#include <KStandardAction>
@@ -82,9 +77,6 @@ SieveEditorMainWindow::SieveEditorMainWindow(QWidget *parent)
SieveEditorMainWindow::~SieveEditorMainWindow()
{
-#ifdef KF5_USE_PURPOSE
- delete mTemporaryShareFile;
-#endif
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup group = config->group(QStringLiteral("SieveEditorMainWindow"));
group.writeEntry("Size", size());
@@ -193,16 +185,17 @@ void SieveEditorMainWindow::setupActions()
ac->addAction(QStringLiteral("import_script"), mImportAction);
mImportAction->setEnabled(false);
-#ifdef KF5_USE_PURPOSE
- mShareAction = new QAction(i18n("Share..."), this);
- ac->addAction(QStringLiteral("share_script"), mShareAction);
- mShareMenu = new Purpose::Menu(this);
- mShareMenu->model()->setPluginType(QStringLiteral("Export"));
- connect(mShareMenu, &Purpose::Menu::aboutToShow, this, \
&SieveEditorMainWindow::slotInitializeShareMenu);
- mShareAction->setMenu(mShareMenu);
- mShareAction->setIcon( QIcon::fromTheme(QStringLiteral("document-share")));
- connect(mShareMenu, &Purpose::Menu::finished, this, \
&SieveEditorMainWindow::slotShareActionFinished);
-#endif
+ SievePurposeMenuWidget *purposeMenu = new SievePurposeMenuWidget(this, this);
+ if (purposeMenu->menu()) {
+ mShareAction = new QAction(i18n("Share..."), this);
+ ac->addAction(QStringLiteral("share_script"), mShareAction);
+ mShareAction->setMenu(purposeMenu->menu());
+ mShareAction->setIcon(QIcon::fromTheme(QStringLiteral("document-share")));
+ purposeMenu->setEditorWidget(mMainWidget->sieveEditorMainWidget());
+ } else {
+ delete purposeMenu;
+ }
+
mShareHotNewStuffAction = new QAction(i18n("Share Script..."), this);
connect(mShareHotNewStuffAction, &QAction::triggered, \
mMainWidget->sieveEditorMainWidget(), \
&SieveEditorMainWidget::slotShareScript);
ac->addAction(QStringLiteral("share_hot_new_stuff_script"), \
mShareHotNewStuffAction); @@ -277,42 +270,6 @@ void \
SieveEditorMainWindow::setupActions()
connect(act, &QAction::triggered, this, \
&SieveEditorMainWindow::slotImportImapSettings); }
-void SieveEditorMainWindow::slotInitializeShareMenu()
-{
-#ifdef KF5_USE_PURPOSE
- delete mTemporaryShareFile;
- mTemporaryShareFile = new QTemporaryFile();
- mTemporaryShareFile->open();
- mTemporaryShareFile->setPermissions(QFile::ReadUser);
- mTemporaryShareFile->write(mMainWidget->sieveEditorMainWidget()->currentText().toUtf8());
- mTemporaryShareFile->close();
- mShareMenu->model()->setInputData(QJsonObject {
- { QStringLiteral("urls"), QJsonArray { \
{QUrl::fromLocalFile(mTemporaryShareFile->fileName()).toString()} } \
},
- { QStringLiteral("mimeType"), { QStringLiteral("text/plain") } }
- });
- mShareMenu->reload();
-#endif
-}
-
-void SieveEditorMainWindow::slotShareActionFinished(const QJsonObject &output, int \
error, const QString &message)
-{
-#ifdef KF5_USE_PURPOSE
- if (error) {
- KMessageBox::error(this, i18n("There was a problem sharing the document: \
%1", message),
- i18n("Share"));
- } else {
- const QString url = output[QLatin1String("url")].toString();
- if (url.isEmpty()) {
- KMessageBox::information(this, i18n("File was shared."));
- } else {
- KMessageBox::information(this, i18n("<qt>You can find the new request \
at:<br /><a href='%1'>%1</a> </qt>", url),
- QString(), QString(), KMessageBox::AllowLink);
- }
- }
-#endif
-}
-
-
void SieveEditorMainWindow::slotImportImapSettings()
{
QPointer<ImportImapSettingWizard> w = new ImportImapSettingWizard(this);
diff --git a/src/sieveeditormainwindow.h b/src/sieveeditormainwindow.h
index b5e454a..c108193 100644
--- a/src/sieveeditormainwindow.h
+++ b/src/sieveeditormainwindow.h
@@ -21,7 +21,6 @@
#define SIEVEEDITORMAINWINDOW_H
#include <KXmlGuiWindow>
-#include "config-sieveeditor.h"
#include "libsieveeditor_export.h"
class QAction;
class SieveEditorCentralWidget;
@@ -32,9 +31,6 @@ class QTemporaryFile;
namespace PimCommon {
class KActionMenuChangeCase;
}
-namespace Purpose {
-class Menu;
-}
class LIBSIEVEEDITOR_EXPORT SieveEditorMainWindow : public KXmlGuiWindow
{
Q_OBJECT
@@ -69,8 +65,6 @@ private:
void initStatusBar();
void readConfig();
void setupActions();
- void slotShareActionFinished(const QJsonObject &output, int error, const QString \
&message);
- void slotInitializeShareMenu();
QString currentText() const;
SieveEditorCentralWidget *mMainWidget = nullptr;
@@ -110,10 +104,6 @@ private:
QLabel *mStatusBarInfo = nullptr;
SieveEditorBookmarks *mSieveEditorBookmarks = nullptr;
KActionMenu *mBookmarkMenu = nullptr;
-#ifdef KF5_USE_PURPOSE
- Purpose::Menu *mShareMenu = nullptr;
- QTemporaryFile *mTemporaryShareFile = nullptr;
-#endif
bool mNetworkIsDown = false;
};
diff --git a/src/sievepurposemenuwidget.cpp b/src/sievepurposemenuwidget.cpp
new file mode 100644
index 0000000..63011d7
--- /dev/null
+++ b/src/sievepurposemenuwidget.cpp
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2018 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#include "sievepurposemenuwidget.h"
+#include "sieveeditormainwidget.h"
+#include <KSieveUi/SieveEditorWidget>
+
+SievePurposeMenuWidget::SievePurposeMenuWidget(QWidget *parentWidget, QObject \
*parent) + : PimCommon::PurposeMenuWidget(parentWidget, parent)
+{
+
+}
+
+SievePurposeMenuWidget::~SievePurposeMenuWidget()
+{
+}
+
+QByteArray SievePurposeMenuWidget::text()
+{
+ if (mSieveEditorWidget) {
+ return mSieveEditorWidget->currentText().toUtf8();
+ }
+ return {};
+}
+
+void SievePurposeMenuWidget::setEditorWidget(SieveEditorMainWidget *editor)
+{
+ mSieveEditorWidget = editor;
+}
diff --git a/src/sievepurposemenuwidget.h b/src/sievepurposemenuwidget.h
new file mode 100644
index 0000000..184eb3c
--- /dev/null
+++ b/src/sievepurposemenuwidget.h
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2018 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SIEVEPURPOSEMENUWIDGET_H
+#define SIEVEPURPOSEMENUWIDGET_H
+
+#include <PimCommon/PurposeMenuWidget>
+class SieveEditorMainWidget;
+class SievePurposeMenuWidget : public PimCommon::PurposeMenuWidget
+{
+ Q_OBJECT
+public:
+ explicit SievePurposeMenuWidget(QWidget *parentWidget, QObject *parent = \
nullptr); + ~SievePurposeMenuWidget() override;
+
+ QByteArray text() override;
+ void setEditorWidget(SieveEditorMainWidget *editor);
+private:
+ SieveEditorMainWidget *mSieveEditorWidget = nullptr;
+};
+
+#endif // SIEVEPURPOSEMENUWIDGET_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic