summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-11-30 08:02:15 (GMT)
committerSwift Review <review@swift.im>2015-12-17 18:41:04 (GMT)
commit523dbfb769069663eda19e381ad35f466b1ef27c (patch)
tree0fb00c1655274b8734de517bd1761931eddb5b49 /Swift/QtUI/QtWebKitChatView.cpp
parent359799239fe61fae51a3a005e588af03a18d8a10 (diff)
downloadswift-523dbfb769069663eda19e381ad35f466b1ef27c.zip
swift-523dbfb769069663eda19e381ad35f466b1ef27c.tar.bz2
Show file-transfer description if provided
Test-Information: Tested by transferring a file between two Swift instances. Tested in WebKit chat views and in plain chat views. Change-Id: Ie46cbd7bac8a36478f64b4557cf55926e6d4af37
Diffstat (limited to 'Swift/QtUI/QtWebKitChatView.cpp')
-rw-r--r--Swift/QtUI/QtWebKitChatView.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp
index 7e0e505..260da8a 100644
--- a/Swift/QtUI/QtWebKitChatView.cpp
+++ b/Swift/QtUI/QtWebKitChatView.cpp
@@ -441,6 +441,11 @@ void QtWebKitChatView::setFileTransferStatus(QString id, const ChatWindow::FileT
QString newInnerHTML = "";
if (state == ChatWindow::Initialisation) {
+ QWebElement filenameSizeDescriptionElement = ftElement.parent().firstChild();
+ QString description = QtUtilities::htmlEscape(descriptions_[id]);
+ if (!description.isEmpty()) {
+ filenameSizeDescriptionElement.prependOutside(QString(" \"%1\"").arg(description));
+ }
newInnerHTML = tr("Preparing to transfer.") + "<br/>" +
buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, id);
}
@@ -660,17 +665,19 @@ QString QtWebKitChatView::buildChatWindowButton(const QString& name, const QStri
return html;
}
-std::string QtWebKitChatView::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes) {
+std::string QtWebKitChatView::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description) {
SWIFT_LOG(debug) << "addFileTransfer" << std::endl;
QString ft_id = QString("ft%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++)));
QString actionText;
QString htmlString;
QString formattedFileSize = P2QSTRING(formatSize(sizeInBytes));
+ QString sanitizedFileName = QtUtilities::htmlEscape(P2QSTRING(filename));
+ QString sanitizedDescription = QtUtilities::htmlEscape(P2QSTRING(description));
if (senderIsSelf) {
// outgoing
- filePaths_[ft_id] = P2QSTRING(filename);
- actionText = tr("Send file: %1 (%2)").arg(P2QSTRING(filename)).arg(formattedFileSize);
+ filePaths_[ft_id] = sanitizedFileName;
+ actionText = tr("Send file: %1 (%2)").arg(sanitizedFileName).arg(formattedFileSize);
htmlString = actionText + " <br/>" +
"<div id='" + ft_id + "'>" +
buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, ft_id) +
@@ -679,7 +686,10 @@ std::string QtWebKitChatView::addFileTransfer(const std::string& senderName, boo
"</div>";
} else {
// incoming
- actionText = tr("Receiving file: %1 (%2)").arg(P2QSTRING(filename)).arg(formattedFileSize);
+ actionText = tr("Receiving file: %1 (%2)").arg(sanitizedFileName).arg(formattedFileSize);
+ if (!sanitizedDescription.isEmpty()) {
+ actionText += QString(" \"%1\"").arg(sanitizedDescription);
+ }
htmlString = actionText + " <br/>" +
"<div id='" + ft_id + "'>" +
buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, ft_id) +