Skip to content
Snippets Groups Projects
Unverified Commit 4bfe2690 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

datatransfer: add context menu to open location, export to downloads

Change-Id: I90fcbc735f084ab37abfa3b466b97cf56c640247
parent 5ddfab1b
No related branches found
No related tags found
No related merge requests found
......@@ -165,6 +165,7 @@
<file>src/mainview/components/MessageListView.qml</file>
<file>src/commoncomponents/MessageBubble.qml</file>
<file>src/constant/MsgSeq.qml</file>
<file>src/commoncomponents/SBSContextMenu.qml</file>
<file>src/commoncomponents/SBSMessageBase.qml</file>
<file>src/commoncomponents/GeneratedMessageDelegate.qml</file>
<file>src/commoncomponents/DataTransferMessageDelegate.qml</file>
......
......@@ -66,6 +66,9 @@ Loader {
showTime: root.showTime
seq: root.seq
author: Author
location: Body
transferName: TransferName
transferId: Id
formattedTime: MessagesAdapter.getFormattedTime(Timestamp)
extraHeight: progressBar.visible ? 18 : 0
innerContent.children: [
......@@ -232,6 +235,9 @@ Loader {
showTime: root.showTime
seq: root.seq
author: Author
location: Body
transferName: TransferName
transferId: Id
formattedTime: MessagesAdapter.getFormattedTime(Timestamp)
bubble.visible: false
innerContent.children: [
......
/*
* Copyright (C) 2021 by Savoir-faire Linux
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* 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 3 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. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.15
import net.jami.Models 1.1
import net.jami.Adapters 1.1
import net.jami.Constants 1.1
import "../commoncomponents"
import "../commoncomponents/contextmenu"
ContextMenuAutoLoader {
id: root
property string location
property string transferName
property string transferId
property list<GeneralMenuItem> menuItems: [
GeneralMenuItem {
id: saveFile
itemName: JamiStrings.saveFile
onClicked: {
MessagesAdapter.copyToDownloads(root.transferId, root.transferName)
}
},
GeneralMenuItem {
id: openLocation
itemName: JamiStrings.openLocation
onClicked: {
MessagesAdapter.openDirectory(root.location)
}
}
]
Component.onCompleted: menuItemsToLoad = menuItems
}
......@@ -38,7 +38,10 @@ Control {
property bool showTime
property int seq
property string author
property string transferId
property string transferName
property string formattedTime
property string location
property string hoveredLink
readonly property real senderMargin: 64
......@@ -124,13 +127,27 @@ Control {
}
}
SBSContextMenu {
id: ctxMenu
location: root.location
transferId: root.transferId
transferName: root.transferName
}
MouseArea {
id: itemMouseArea
anchors.fill: parent
z: -1
acceptedButtons: Qt.LeftButton
onClicked: {
if (root.hoveredLink)
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: function (mouse) {
if (mouse.button === Qt.RightButton && transferId !== "") {
// Context Menu for Transfers
ctxMenu.x = mouse.x
ctxMenu.y = mouse.y
ctxMenu.openMenu()
} else if (root.hoveredLink)
MessagesAdapter.openUrl(root.hoveredLink)
}
}
......
......@@ -368,6 +368,10 @@ Item {
property string networkError: qsTr("Network error")
property string somethingWentWrong: qsTr("Something went wrong")
// Context Menu
property string saveFile: qsTr("Save file")
property string openLocation: qsTr("Open location")
// Updates
property string betaInstall: qsTr("Install beta version")
property string checkForUpdates: qsTr("Check for updates now")
......
......@@ -195,6 +195,23 @@ MessagesAdapter::openUrl(const QString& url)
}
}
void
MessagesAdapter::openDirectory(const QString& path)
{
QString p = path;
QFileInfo f(p);
if (f.exists()) {
if (!f.isDir())
p = f.dir().absolutePath();
QString url;
if (!p.startsWith("file://"))
url = "file://" + p;
else
url = p;
openUrl(url);
}
}
void
MessagesAdapter::acceptFile(const QString& interactionId)
{
......
......@@ -97,6 +97,7 @@ protected:
Q_INVOKABLE void cancelFile(const QString& arg);
Q_INVOKABLE void openUrl(const QString& url);
Q_INVOKABLE void openFile(const QString& arg);
Q_INVOKABLE void openDirectory(const QString& arg);
Q_INVOKABLE void retryInteraction(const QString& interactionId);
Q_INVOKABLE void deleteInteraction(const QString& interactionId);
Q_INVOKABLE void copyToDownloads(const QString& interactionId, const QString& displayName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment