Commit 6f151067 authored by Martin Straka's avatar Martin Straka

Added open attachment in send message page

parent c10d2c9a
......@@ -341,6 +341,22 @@ Item {
width: parent.width
height: listItemHeight
color: datovkaPalette.base
MouseArea {
anchors.fill: parent
onClicked: {
var filePath = sendMsgAttachmentModel.get(index).path
if (files.isZfoFile(getFileNameFromPath(filePath))) {
pageView.push(pageMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
"rawZfoContent": files.rawFileContent(filePath)
})
} else {
files.openAttachmentFromPath(filePath)
}
}
}
Image {
id: imageAttachment
anchors.left: parent.left
......
......@@ -291,6 +291,30 @@ void Files::openAttachment(const QString &fileName, const QByteArray &base64Data
if (!filePath.isEmpty()) {
qInfo() << "Creating temporary file" << filePath;
openAttachmentFromPath(filePath);
} else {
qCritical() << "Cannot create temporary file for" << fileName;
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Open attachment error"),
tr("Cannot save selected file to disk for opening."),
QString());
}
}
void Files::openAttachmentFromPath(const QString &filePath)
{
Q_ASSERT(!filePath.isEmpty());
if (filePath.isEmpty()) {
qCritical() << "File path is empty!";
return;
}
if (isZfoFile(filePath)) {
/* Don't open zfo files from here. */
Q_ASSERT(0);
qCritical() << "This should open ZFO files by itself.";
return;
}
#if defined Q_OS_IOS
UrlOpener urlOpener;
......@@ -307,13 +331,6 @@ void Files::openAttachment(const QString &fileName, const QByteArray &base64Data
tr("File: '%1'").arg(filePath));
}
#endif /* defined Q_OS_IOS */
} else {
qCritical() << "Cannot create temporary file for" << fileName;
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Open attachment error"),
tr("Cannot save selected file to disk for opening."),
QString());
}
}
void Files::sendAttachmentsWithEmailFromDb(const QString &userName,
......
......@@ -92,6 +92,12 @@ public:
void openAttachment(const QString &fileName,
const QByteArray &base64Data);
/*!
* @brief Open attachment from path in default application.
*/
Q_INVOKABLE static
void openAttachmentFromPath(const QString &filePath);
/*!
* @brief Send attachments from database with email application.
*
......
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