Commit 2fd209d9 authored by Camilo Higuita's avatar Camilo Higuita

share from contextual menu

parent 43b3d1a0
......@@ -10,8 +10,6 @@ import QtQuick.Controls.Material 2.1
import "widgets"
import "widgets/views"
import "widgets/sidebar"
import "widgets/dialogs/share"
import "widgets_templates"
import "Index.js" as INX
......@@ -139,6 +137,8 @@ Maui.ApplicationWindow
browser.selectionBar.animate("red")
}else browser.remove([path])
}
onShareClicked: shareDialog.show(path)
}
NewDialog
......
......@@ -23,9 +23,6 @@
<file>widgets/views/Previewer/TextPreview.qml</file>
<file>widgets/views/Previewer/VideoPreview.qml</file>
<file>widgets/views/Previewer/DefaultPreview.qml</file>
<file>widgets/dialogs/share/ShareDelegate.qml</file>
<file>widgets/dialogs/share/ShareDialog.qml</file>
<file>widgets/dialogs/share/ShareGrid.qml</file>
<file>widgets_templates/IndexPopup.qml</file>
</qresource>
</RCC>
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.2 as Kirigami
ItemDelegate
{
property int iconSize : iconSizes.big
property string labelColor: GridView.isCurrentItem ? highlightedTextColor : textColor
background: Rectangle
{
color: "transparent"
}
ColumnLayout
{
anchors.fill: parent
Item
{
Layout.fillHeight: true
Layout.fillWidth: true
Kirigami.Icon
{
anchors.centerIn: parent
source: serviceIcon
isMask: false
height: iconSize
width: iconSize
}
}
Item
{
Layout.fillHeight: true
Layout.fillWidth: true
Label
{
text: serviceLabel
width: parent.width
height: parent.height * 0.8
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
wrapMode: Text.Wrap
font.pointSize: fontSizes.default
color: labelColor
}
}
}
}
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import "../../../widgets_templates"
IndexPopup
{
property string picUrl : ""
padding: contentMargins
maxWidth: parent.width / 2
height: parent.height * 0.3
parent: parent
ColumnLayout
{
anchors.fill: parent
height: parent.height
width:parent.width
Label
{
text: qsTr("Open with...")
width: parent.width
Layout.fillWidth: true
horizontalAlignment: Qt.AlignHCenter
elide: Qt.ElideRight
font.pointSize: fontSizes.big
padding: contentMargins
font.bold: true
font.weight: Font.Bold
}
ShareGrid
{
id: shareGrid
Layout.fillHeight: true
Layout.fillWidth: true
width: parent.width
onServiceClicked: triggerService(index)
}
}
onOpened: populate()
function show(url)
{
picUrl = url
open()
}
function populate()
{
shareGrid.model.clear()
var services = inx.openWith(picUrl)
var devices = inx.getKDEConnectDevices()
shareGrid.model.append({serviceIcon: "internet-mail", serviceLabel: "eMail", email: true})
if(devices.length > 0)
for(var i in devices)
{
devices[i].serviceIcon = "smartphone"
shareGrid.model.append(devices[i])
}
if(services.length > 0)
for(i in services)
shareGrid.model.append(services[i])
}
function triggerService(index)
{
var obj = shareGrid.model.get(index)
if(obj.serviceKey)
inx.sendToDevice(obj.serviceLabel, obj.serviceKey, picUrl)
else if(obj.email)
inx.attachToEmail(picUrl)
else
inx.runApplication(obj.actionArgument, picUrl)
shareDialog.close()
}
}
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
GridView
{
id: grid
clip: true
signal serviceClicked(int index)
property int itemSize : isMobile ? iconSizes.big : iconSizes.big
property int itemSpacing: isMobile ? space.large : space.huge
width: parent.width
height: parent.height
cellWidth: itemSize + itemSpacing
cellHeight: itemSize + itemSpacing
focus: true
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickDirection
snapMode: GridView.SnapToRow
model: ListModel {id: gridModel}
highlightFollowsCurrentItem: true
highlight: Rectangle
{
width: cellWidth
height: cellHeight
color: highlightColor
radius: 3
}
delegate: ShareDelegate
{
id: delegate
iconSize : itemSize
height: grid.cellHeight
width: grid.cellWidth * 0.8
Connections
{
target: delegate
onClicked:
{
currentIndex = index
serviceClicked(index)
}
}
}
onWidthChanged:
{
var amount = parseInt(grid.width/(itemSize + itemSpacing),10)
var leftSpace = parseInt(grid.width-(amount*(itemSize + itemSpacing)), 10)
var size = parseInt((itemSize + itemSpacing)+(parseInt(leftSpace/amount, 10)), 10)
size = size > itemSize + itemSpacing ? size : itemSize + itemSpacing
grid.cellWidth = size
// grid.cellHeight = size
}
}
......@@ -105,8 +105,6 @@ Menu
onTriggered: browser.selectionBar.append(browser.grid.model.get(browser.grid.currentIndex))
}
function show(url)
{
if(!inx.isCustom(browser.currentPath))
......
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