Skip to content

Commit

Permalink
Merge branch 'usb_strings' into 'master'
Browse files Browse the repository at this point in the history
[lipstick] Provide translation support for USB errors. Fixes JB#44006

See merge request mer-core/lipstick!96
  • Loading branch information
pvuorela committed Nov 29, 2018
2 parents 879b881 + 00d1cec commit eb03dea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/usbmodeselector.cpp
Expand Up @@ -26,7 +26,9 @@

#include <nemo-devicelock/devicelock.h>

QMap<QString, QString> USBModeSelector::s_errorCodeToTranslationID;
namespace {
QMap<QString, const char *> s_errorCodeToTranslationID;
}

USBModeSelector::USBModeSelector(NemoDeviceLock::DeviceLock *deviceLock, QObject *parent) :
QObject(parent),
Expand All @@ -36,8 +38,11 @@ USBModeSelector::USBModeSelector(NemoDeviceLock::DeviceLock *deviceLock, QObject
m_previousNotificationId(0)
{
if (s_errorCodeToTranslationID.isEmpty()) {
s_errorCodeToTranslationID.insert("qtn_usb_filessystem_inuse", "qtn_usb_filessystem_inuse");
s_errorCodeToTranslationID.insert("mount_failed", "qtn_usb_mount_failed");
// Note: not really clear which errors should trigger notifications, or if even these should in practice show
//% "USB filesystem in use"
s_errorCodeToTranslationID.insert("data_in_use", QT_TRID_NOOP("qtn_usb_filessystem_inuse"));
//% "USB mount failed"
s_errorCodeToTranslationID.insert("mount_failed", QT_TRID_NOOP("qtn_usb_mount_failed"));
}

connect(m_usbMode, SIGNAL(eventReceived(QString)), this, SLOT(handleUSBEvent(QString)));
Expand Down Expand Up @@ -183,8 +188,7 @@ void USBModeSelector::showError(const QString &errorCode)
NotificationManager *manager = NotificationManager::instance();
QVariantHash hints;
hints.insert(LipstickNotification::HINT_CATEGORY, "device.error");
//% "USB connection error occurred"
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, qtTrId(s_errorCodeToTranslationID.value(errorCode).toUtf8().constData()));
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, qtTrId(s_errorCodeToTranslationID.value(errorCode)));
manager->Notify(manager->systemApplicationName(), 0, QString(), QString(), QString(), QStringList(), hints, -1);
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/usbmodeselector.h
Expand Up @@ -121,11 +121,6 @@ private slots:
void notificationClosed(uint id);

private:

//! Error code to translation ID mapping
static QMap<QString, QString> s_errorCodeToTranslationID;

//! The volume control window
HomeWindow *m_window;

//! For getting and setting the USB mode
Expand Down

0 comments on commit eb03dea

Please sign in to comment.