Commit aedc397e authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Change "open externally" options with "save to xxxx" and add feedback

parent dc10ef59
......@@ -2,10 +2,26 @@ import QtQuick 2.6;
import QtQmlTricks 3.0;
import Sailfish.Silica 1.0;
import harbour.Telegrame 1.0;
import QtQml.Models 2.2;
DelegateAbstractMessageContent {
id: self;
spacing: Theme.paddingMedium;
additionalContextMenuItems: ObjectModel {
MenuItem {
text: qsTr ("Save a copy in 'Downloads'");
visible: (documentItem !== null);
enabled: (documentItem &&
documentItem.document &&
documentItem.document.local &&
documentItem.document.local.isDownloadingCompleted);
onClicked: {
TD_Global.downloadDocument (documentItem);
emblem.visible = true;
}
}
}
property TD_MessageDocument messageContentItem : null;
......@@ -126,4 +142,13 @@ DelegateAbstractMessageContent {
}
}
}
LabelFixed {
id: emblem;
text: qsTr ("(copied in 'Downloads')");
opacity: 0.65;
visible: TD_Global.isDocumentDownloaded (documentItem);
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Theme.fontSizeExtraSmall;
ExtraAnchors.horizontalFill: parent;
}
}
......@@ -59,9 +59,10 @@ DelegateAbstractMessageContent {
}
LabelFixed {
id: emblem;
text: qsTr ("(Saved in gallery)");
text: qsTr ("(saved in gallery)");
opacity: 0.65;
visible: TD_Global.isPhotoSavedToGallery (photoSizeItem.photo);
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Theme.fontSizeExtraSmall;
ExtraAnchors.horizontalFill: img;
}
......
......@@ -10,10 +10,11 @@ DelegateAbstractMessageContent {
optimalWidth: vid.width;
additionalContextMenuItems: ObjectModel {
MenuItem {
text: qsTr ("Open video with player");
text: qsTr ("Save video to gallery");
enabled: (videoItem && videoItem.video && videoItem.video.local && videoItem.video.local.isDownloadingCompleted);
onClicked: {
Qt.openUrlExternally (TD_Global.urlFromLocalPath (videoItem.video.local.path));
TD_Global.saveVideoToGallery (videoItem.video);
emblem.visible = true;
}
}
}
......@@ -114,4 +115,13 @@ DelegateAbstractMessageContent {
ExtraAnchors.leftDock: parent;
}
}
LabelFixed {
id: emblem;
text: qsTr ("(saved in gallery)");
opacity: 0.65;
visible: TD_Global.isVideoSavedToGallery (videoItem.video);
horizontalAlignment: Text.AlignHCenter;
font.pixelSize: Theme.fontSizeExtraSmall;
ExtraAnchors.horizontalFill: vid;
}
}
......@@ -14,7 +14,7 @@ Name: harbour-telegrame
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 16
Release: 17
Group: Qt/Qt
License: WTFPL
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
......
Name: harbour-telegrame
Summary: A native Telegram client for Sailfish OS
Version: 0.9
Release: 16
Release: 17
Group: Qt/Qt
URL: http://gitlab.unique-conception.org/sailfish-app/telegra-me
......
......@@ -617,7 +617,9 @@ void QtTdLibGlobal::sendMessageEdit (QtTdLibChat * chatItem, const QString & tex
set_editingMessageId (QString { });
}
static const QString DIR_PHOTOS { QStringLiteral ("/home/nemo/Pictures/Telegrame") };
static const QString DIR_PHOTOS { QStringLiteral ("/home/nemo/Pictures/Telegrame") };
static const QString DIR_VIDEOS { QStringLiteral ("/home/nemo/Videos/Telegrame") };
static const QString DIR_DOWNLOADS { QStringLiteral ("/home/nemo/Downloads/Telegrame") };
void QtTdLibGlobal::savePhotoToGallery (QtTdLibFile * fileItem) {
if (fileItem != Q_NULLPTR) {
......@@ -636,6 +638,38 @@ bool QtTdLibGlobal::isPhotoSavedToGallery (QtTdLibFile * fileItem) const {
return ret;
}
void QtTdLibGlobal::saveVideoToGallery (QtTdLibFile * fileItem) {
if (fileItem != Q_NULLPTR) {
QDir ().mkpath (DIR_VIDEOS);
QFileInfo info { fileItem->get_local ()->get_path () };
QFile::copy (info.absoluteFilePath (), (DIR_VIDEOS % '/' % info.fileName ()));
}
}
bool QtTdLibGlobal::isVideoSavedToGallery (QtTdLibFile * fileItem) const {
bool ret { false };
if (fileItem != Q_NULLPTR) {
QFileInfo info { fileItem->get_local ()->get_path () };
ret = QFile::exists (DIR_VIDEOS % '/' % info.fileName ());
}
return ret;
}
void QtTdLibGlobal::downloadDocument (QtTdLibDocument * documentItem) {
if (documentItem != Q_NULLPTR) {
QDir ().mkpath (DIR_DOWNLOADS);
QFile::copy (documentItem->get_document ()->get_local ()->get_path (), (DIR_DOWNLOADS % '/' % documentItem->get_fileName ()));
}
}
bool QtTdLibGlobal::isDocumentDownloaded (QtTdLibDocument * documentItem) const {
bool ret { false };
if (documentItem != Q_NULLPTR) {
ret = QFile::exists ((DIR_DOWNLOADS % '/' % documentItem->get_fileName ()));
}
return ret;
}
void QtTdLibGlobal::sendMessagePhoto (QtTdLibChat * chatItem, const bool groupInAlbum, const QString & caption) {
if (chatItem != Q_NULLPTR && !m_selectedPhotosList.isEmpty ()) {
if (groupInAlbum) {
......
......@@ -132,6 +132,12 @@ public:
Q_INVOKABLE void savePhotoToGallery (QtTdLibFile * fileItem);
Q_INVOKABLE bool isPhotoSavedToGallery (QtTdLibFile * fileItem) const;
Q_INVOKABLE void saveVideoToGallery (QtTdLibFile * fileItem);
Q_INVOKABLE bool isVideoSavedToGallery (QtTdLibFile * fileItem) const;
Q_INVOKABLE void downloadDocument (QtTdLibDocument * documentItem);
Q_INVOKABLE bool isDocumentDownloaded (QtTdLibDocument * documentItem) const;
signals:
void showChatRequested (QtTdLibChat * chatItem);
void editTextRequested (QtTdLibFormattedText * formattedText);
......
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