diff --git a/qmlUiKirigami/AlbumView.qml b/qmlUiKirigami/AlbumView.qml --- a/qmlUiKirigami/AlbumView.qml +++ b/qmlUiKirigami/AlbumView.qml @@ -71,6 +71,19 @@ enabled: model.hasSelectedImages onTriggered: model.clearSelections() }, + Kirigami.Action { + iconName: "emblem-shared-symbolic" + text: i18n("Share") + tooltip: i18n("Share the selected images") + enabled: model.hasSelectedImages + onTriggered: { + shareMenu.sheetOpen = true + shareMenu.inputData = { + "urls": model.selectedImages(), + "mimeType": "image/" + } + } + }, Kirigami.Action { iconName: "group-delete" text: i18n("Delete Selection") @@ -133,4 +146,19 @@ imageViewer.state = "open"; } + ShareDialog { + id: shareMenu + inputData: { urls: [] } + sheetOpen: false + onFinished: { + if (error==0 && output.url !== "") { + console.assert(output.url !== undefined); + var resultUrl = output.url; + console.log("Received", resultUrl) + notificationManager.showNotification( true, resultUrl); + } else { + notificationManager.showNotification( false); + } + } + } } diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -414,8 +414,4 @@ } } } - - Koko.NotificationManager { - id: notificationManager - } } diff --git a/qmlUiKirigami/Main.qml b/qmlUiKirigami/Main.qml --- a/qmlUiKirigami/Main.qml +++ b/qmlUiKirigami/Main.qml @@ -203,4 +203,7 @@ state: imagePathArgument == "" ? "closed" : "open" } + Koko.NotificationManager { + id: notificationManager + } } diff --git a/src/sortmodel.h b/src/sortmodel.h --- a/src/sortmodel.h +++ b/src/sortmodel.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,7 @@ Q_INVOKABLE void deleteSelection(); Q_INVOKABLE int proxyIndex(const int &indexValue); Q_INVOKABLE int sourceIndex(const int &indexValue); + Q_INVOKABLE QJsonArray selectedImages(); protected Q_SLOTS: void setContainImages(bool); diff --git a/src/sortmodel.cpp b/src/sortmodel.cpp --- a/src/sortmodel.cpp +++ b/src/sortmodel.cpp @@ -266,6 +266,18 @@ return mapToSource( index(indexValue, 0, QModelIndex())).row(); } +QJsonArray SortModel::selectedImages() +{ + QJsonArray arr; + + foreach( QModelIndex index, m_selectionModel->selectedIndexes()) + { + arr.push_back( QJsonValue (data( index, Roles::ImageUrlRole).toString())); + } + + return arr; +} + void SortModel::delayedPreview() { QHash::const_iterator i = m_filesToPreview.constBegin();