Skip to content

Commit

Permalink
[transfer-engine] Update notification configuration. JB#50448
Browse files Browse the repository at this point in the history
- Set summary/body instead of previewSummary/previewBody.
- Notification previews are now shown by default, so explicitly
disable them if required for existing behavior.
- Use same group for all notifications.
  • Loading branch information
Bea Lam committed Jul 24, 2020
1 parent 72b5bc3 commit 33b03de
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/transferengine.cpp
Expand Up @@ -331,8 +331,7 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty
QString category;
QString body;
QString summary;
QString previewBody;
QString previewSummary;
bool showPreview = false;
bool useProgress = false;
Notification::Urgency urgency = Notification::Normal;
QString appIcon = QStringLiteral("icon-lock-transfer");
Expand All @@ -355,22 +354,22 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty
int notificationId = DbManager::instance()->notificationId(transferId);

if (status == TransferEngineData::TransferFinished) {
showPreview = true;

switch(type) {
case TransferEngineData::Upload:
category = TRANSFER_COMPLETE_EVENT_CATEGORY;
//: Notification for successful file upload
//% "File uploaded"
previewBody = qtTrId("transferengine-no-file-upload-success");
previewSummary = fileName;
category = TRANSFER_EVENT_CATEGORY; // Use "generic" transfer event for uploads
body = qtTrId("transferengine-no-file-upload-success");
summary = fileName;
break;
case TransferEngineData::Download:
category = TRANSFER_COMPLETE_EVENT_CATEGORY;
//: Notification for successful file download
//% "File downloaded"
body = qtTrId("transferengine-no-file-download-success");
summary = fileName;
previewBody = body;
previewSummary = summary;
break;
case TransferEngineData::Sync:
// Ok exit
Expand Down Expand Up @@ -406,8 +405,6 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty
}

summary = fileName;
previewSummary = summary;
previewBody = body;

} else if (status == TransferEngineData::TransferStarted) {
if (type == TransferEngineData::Upload || type == TransferEngineData::Download) {
Expand Down Expand Up @@ -453,22 +450,22 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty
//: Group name for notifications of successful transfers
//% "Transfers"
const QString transfersGroup(qtTrId("transferengine-notification_group"));
//: Group name for notifications of failed transfers
//% "Warnings"
const QString errorsGroup(qtTrId("transferengine-notification_errors_group"));

notification.setCategory(category);
notification.setAppName(category == TRANSFER_ERROR_EVENT_CATEGORY ? errorsGroup : transfersGroup);
notification.setAppName(transfersGroup);
notification.setSummary(summary);
notification.setBody(body);
notification.setPreviewSummary(previewSummary);
notification.setPreviewBody(previewBody);
notification.setUrgency(urgency);

if (!appIcon.isEmpty()) {
notification.setAppIcon(appIcon);
}

if (!showPreview) {
notification.clearPreviewSummary();
notification.clearPreviewBody();
}

if (useProgress) {
notification.setHintValue(TRANSFER_PROGRESS_HINT, static_cast<double>(progress));
}
Expand Down

0 comments on commit 33b03de

Please sign in to comment.