Commit d20a1533 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[WIP/RFC] Use Purpose for sharing

Summary:
Use Purpose for the sharing menu.

The question is what to do with the old KIPI sharing infrastructure. It covers some services that Purpose doesn't. Getting rid of them without a replacement would probably upset some users. Ideally all KIPI plugins should be ported to Purpose, but that's a huge task.

Test Plan: Open an image, Share it

Reviewers: #gwenview, ngraham

Reviewed By: #gwenview, ngraham

Subscribers: ngraham

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D21468
parent 99ff04e6
......@@ -68,6 +68,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
WindowSystem
IconThemes
Notifications
Purpose
)
find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS
Activities
......
......@@ -79,6 +79,7 @@ add_executable(gwenview ${gwenview_SRCS})
target_link_libraries(gwenview
KF5::ItemModels
KF5::Notifications
KF5::PurposeWidgets
gwenviewlib
)
......
......@@ -106,7 +106,7 @@
<Action name="rotate_left" />
<Action name="rotate_right" />
<Separator/>
<Action name="kipi_export" />
<Action name="share" />
</ToolBar>
</kpartgui>
......@@ -38,6 +38,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef Q_OS_OSX
#include <QFileOpenEvent>
#endif
#include <QJsonArray>
#include <QJsonObject>
// KDE
#include <KActionCategory>
......@@ -57,6 +59,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KToolBar>
#include <KXMLGUIFactory>
#include <KDirLister>
#include <PurposeWidgets/Menu>
#include <Purpose/AlternativesModel>
// Local
#include "configdialog.h"
......@@ -195,6 +199,8 @@ struct MainWindow::Private
QAction * mToggleSlideShowAction;
KToggleAction* mShowMenuBarAction;
KToggleAction* mShowStatusBarAction;
Purpose::Menu* mShareMenu;
KToolBarPopupAction* mShareAction;
#ifdef KIPI_FOUND
KIPIExportAction* mKIPIExportAction;
#endif
......@@ -504,8 +510,12 @@ struct MainWindow::Private
#ifdef KIPI_FOUND
mKIPIExportAction = new KIPIExportAction(q);
actionCollection->addAction("kipi_export", mKIPIExportAction);
#endif
mShareAction = new KToolBarPopupAction(QIcon::fromTheme("document-share"), "Share", q);
actionCollection->addAction("share", mShareAction);
mShareMenu = new Purpose::Menu(q);
mShareAction->setMenu(mShareMenu);
}
void setupUndoActions()
......@@ -708,6 +718,18 @@ struct MainWindow::Private
actionCollection->action("file_save")->setEnabled(canSave && isModified);
actionCollection->action("file_save_as")->setEnabled(canSave);
actionCollection->action("file_print")->setEnabled(isRasterImage);
if (url.isEmpty()) {
mShareAction->setEnabled(false);
} else {
mShareAction->setEnabled(true);
mShareMenu->model()->setInputData(QJsonObject{
{ QStringLiteral("mimeType"), MimeTypeUtils::urlMimeType(url) },
{ QStringLiteral("urls"), QJsonArray{url.toString()} }
});
mShareMenu->model()->setPluginType( QStringLiteral("Export") );
mShareMenu->reload();
}
}
bool sideBarVisibility() const
......
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