Skip to content

Commit

Permalink
Allow for users to manually push images/PDF files to the cloud from t…
Browse files Browse the repository at this point in the history
…he project folder panel (#5542)

* Allow for users to manually push images/PDF files to the cloud from the project folder panel

* Add a toaster message to avoid feedback-less UX
  • Loading branch information
nirvn committed Aug 10, 2024
1 parent d4636b7 commit 4bd923e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/utils/qfieldcloudutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class QFieldCloudUtils : public QObject
static const QMultiMap<QString, QString> getPendingAttachments();

//! Adds an \a fileName for a given \a projectId to the pending attachments list
static void addPendingAttachment( const QString &projectId, const QString &fileName );
Q_INVOKABLE static void addPendingAttachment( const QString &projectId, const QString &fileName );

//! Adds removes a \a fileName for a given \a projectId to the pending attachments list
static void removePendingAttachment( const QString &projectId, const QString &fileName );
Expand Down
26 changes: 20 additions & 6 deletions src/qml/QFieldLocalDataPickerScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,8 @@ Page {
property int itemType: ItemType
property string itemTitle: ItemTitle
property string itemPath: ItemPath
property bool itemMenuLoadable: !projectFolderView &&
(ItemMetaType === LocalFilesModel.Project || ItemMetaType === LocalFilesModel.Dataset)
property bool itemMenuVisible: (platformUtilities.capabilities & PlatformUtilities.CustomExport ||
platformUtilities.capabilities & PlatformUtilities.CustomSend) &&
(ItemMetaType === LocalFilesModel.Dataset
|| (ItemType === LocalFilesModel.SimpleFolder && table.model.currentPath !== 'root'))
property bool itemMenuLoadable: !projectFolderView && (ItemMetaType === LocalFilesModel.Project || ItemMetaType === LocalFilesModel.Dataset)
property bool itemMenuVisible: ((platformUtilities.capabilities & PlatformUtilities.CustomExport || platformUtilities.capabilities & PlatformUtilities.CustomSend) && (ItemMetaType === LocalFilesModel.Dataset || (ItemType === LocalFilesModel.SimpleFolder && table.model.currentPath !== 'root'))) || (ItemMetaType === LocalFilesModel.Dataset && ItemType === LocalFilesModel.RasterDataset && cloudProjectsModel.currentProjectId)

width: parent ? parent.width : undefined
height: line.height
Expand Down Expand Up @@ -392,6 +388,24 @@ Page {
onTriggered: { platformUtilities.sendDatasetTo(itemMenu.itemPath); }
}

MenuItem {
id: pushDatasetToCloud
enabled: itemMenu.itemMetaType == LocalFilesModel.Dataset && itemMenu.itemType == LocalFilesModel.RasterDataset && cloudProjectsModel.currentProjectId
visible: enabled

font: Theme.defaultFont
width: parent.width
height: enabled ? undefined : 0
leftPadding: Theme.menuItemLeftPadding

text: qsTr("Push to QFieldCloud...")
onTriggered: {
QFieldCloudUtils.addPendingAttachment(cloudProjectsModel.currentProjectId, itemMenu.itemPath);
platformUtilities.uploadPendingAttachments(cloudConnection);
displayToast(qsTr("‘%1’ is being uploaded to QFieldCloud").arg(FileUtils.fileName(itemMenu.itemPath)));
}
}

MenuItem {
id: exportDatasetTo
enabled: platformUtilities.capabilities & PlatformUtilities.CustomExport
Expand Down

1 comment on commit 4bd923e

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.