Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb53987-share-api' into 'master'
[transferengine] Add TransferMethodInfo::SupportsMultipleFiles. JB#53987 OMP#JOLLA-75

See merge request mer-core/transfer-engine!24
  • Loading branch information
blam committed May 11, 2021
2 parents f82591e + 084a21f commit 6cb4490
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 39 deletions.
73 changes: 35 additions & 38 deletions example/ExampleShareUI.qml
@@ -1,6 +1,6 @@
/******************************************************************************
Copyright (c) <2014>, Jolla Ltd.
Contact: Marko Mattila <marko.mattila@jolla.com>
Copyright (c) 2014 - 2021 Jolla Ltd.
Copyright (c) 2021 Open Mobile Platform LLC.
All rights reserved.
Expand All @@ -27,61 +27,58 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

import QtQuick 2.0
import QtQuick 2.6
import Sailfish.Silica 1.0
import org.nemomobile.thumbnailer 1.0
import Sailfish.TransferEngine 1.0

ShareDialog {
SilicaFlickable {
id: root

property int viewWidth: root.isPortrait ? Screen.width : Screen.width / 2
property var sailfishTransfer

onAccepted: {
shareItem.start()
}
width: Screen.width
height: Math.min(Screen.height, contentHeight)
contentHeight: contentColumn.height

Thumbnail {
id: thumbnail
width: viewWidth
height: parent.height / 2
source: root.source
sourceSize.width: Screen.width
sourceSize.height: Screen.height / 2
}
Column {
id: contentColumn

width: parent.width
spacing: Theme.paddingLarge
bottomPadding: Theme.paddingLarge

Item {
anchors {
top: root.isPortrait ? thumbnail.bottom : parent.top
left: root.isPortrait ? parent.left: thumbnail.right
right: parent.right
bottom: parent.bottom
Thumbnail {
width: Screen.width
height: Screen.height / 2
source: root.sailfishTransfer.source
sourceSize.width: Screen.width
sourceSize.height: Screen.height / 2
}

Label {
anchors.centerIn:parent
width: viewWidth
width: Screen.width
//: Label for example share UI
//% "Example Test Share UI"
text: qsTrId("example-test-share-ui-la-id")
horizontalAlignment: Text.AlignHCenter
}
}

SailfishShare {
id: shareItem
source: root.source
metadataStripped: true
serviceId: root.methodId
userData: {"description": "Random Text which can be what ever",
"accountId": root.accountId,
"scalePercent": root.scalePercent}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
//% "Start"
text: qsTrId("example-test-share-ui-la-start")

DialogHeader {
//: Header for example share plugin
//% "Example Share"
acceptText: qsTrId("example-share-he-id")
onClicked: {
sailfishTransfer.metadataStripped = true
sailfishTransfer.userData = {
"description": "Random Text which can be what ever",
"accountId": root.sailfishTransfer.transferMethodInfo.accountId,
"scalePercent": 0.5
}
sailfishTransfer.start()
}
}
}
}

18 changes: 18 additions & 0 deletions lib/transfermethodinfo.cpp
Expand Up @@ -25,6 +25,12 @@
#include "transfermethodinfo.h"
#include "metatypedeclarations.h"

namespace {

const QString KeySupportsMultipleFiles = "SupportsMultipleFiles";

}

/*!
\class TransferMethodInfo
\brief The TransferMethodInfo class encapsulate information of a single transfer method.
Expand Down Expand Up @@ -176,11 +182,23 @@ QVariant TransferMethodInfo::value(int index) const
return accountId;
case AccountIcon:
return accountIcon;
case SupportsMultipleFiles:
return supportsMultipleFiles();
default:
return QVariant();
}
}

void TransferMethodInfo::setSupportsMultipleFiles(bool supportsMultipleFiles)
{
hints.insert(KeySupportsMultipleFiles, supportsMultipleFiles);
}

bool TransferMethodInfo::supportsMultipleFiles() const
{
return hints.value(KeySupportsMultipleFiles).toBool();
}

QDBusArgument &operator<<(QDBusArgument &argument, const TransferMethodInfoDeprecated &info)
{
argument.beginStructure();
Expand Down
6 changes: 5 additions & 1 deletion lib/transfermethodinfo.h
Expand Up @@ -56,7 +56,8 @@ class TransferMethodInfo
AccountId, // id the account, needed in a case of multiple accounts
AccountIcon, // account icon source url
ShareUIPath, // path to the share ui QML plugin
Capabilities // list of supported mimetypes
Capabilities, // list of supported mimetypes
SupportsMultipleFiles
};

TransferMethodInfo();
Expand All @@ -71,6 +72,9 @@ class TransferMethodInfo

QVariant value(int index) const;

void setSupportsMultipleFiles(bool supportsMultipleFiles);
bool supportsMultipleFiles() const;

QString displayName;
QString userName;
QString methodId;
Expand Down

0 comments on commit 6cb4490

Please sign in to comment.