Commit 3dee2897 authored by Konrad Materka's avatar Konrad Materka
Browse files

[applets/systemtray] Add workaround for Dropbox

System Tray forgets Dropbox hidden state after logout+login

The SNI Id should be consistent between sessions, but Dropbox does not
follow the SNI specification - it adds PID as a suffix of Id.

As this is very popular application and it was not fixed upstream for
many years it is reasonable to add workaround in SystemTray.

BUG: 378910
FIXED-IN: 5.22.0
parent 62842ac6
......@@ -291,6 +291,16 @@ static QVariant extractIcon(const Plasma::DataEngine::Data &sniData, const QStri
}
}
static QString extractItemId(const Plasma::DataEngine::Data &sniData) {
const QString itemId = sniData.value(QStringLiteral("Id")).toString();
// Bug 378910: workaround for Dropbox not following the SNI specification
if (itemId.startsWith(QLatin1String("dropbox-client-"))) {
return QLatin1String("dropbox-client-PID");
} else {
return itemId;
}
}
QVariant StatusNotifierModel::data(const QModelIndex &index, int role) const
{
if (!checkIndex(index, CheckIndexOption::IndexIsValid)) {
......@@ -300,6 +310,7 @@ QVariant StatusNotifierModel::data(const QModelIndex &index, int role) const
StatusNotifierModel::Item item = m_items[index.row()];
Plasma::DataContainer *dataContainer = m_dataEngine->containerForSource(item.source);
const Plasma::DataEngine::Data &sniData = dataContainer->data();
const QString itemId = extractItemId(sniData);
if (role <= Qt::UserRole) {
switch (role) {
......@@ -317,7 +328,7 @@ QVariant StatusNotifierModel::data(const QModelIndex &index, int role) const
case BaseRole::ItemType:
return QStringLiteral("StatusNotifier");
case BaseRole::ItemId:
return sniData.value(QStringLiteral("Id"));
return itemId;
case BaseRole::CanRender:
return true;
case BaseRole::Category: {
......@@ -327,7 +338,7 @@ QVariant StatusNotifierModel::data(const QModelIndex &index, int role) const
case BaseRole::Status:
return extractStatus(sniData);
case BaseRole::EffectiveStatus:
return calculateEffectiveStatus(true, extractStatus(sniData), sniData.value(QStringLiteral("Id")).toString());
return calculateEffectiveStatus(true, extractStatus(sniData), itemId);
default:
return QVariant();
}
......@@ -353,7 +364,7 @@ QVariant StatusNotifierModel::data(const QModelIndex &index, int role) const
case Role::IconThemePath:
return sniData.value(QStringLiteral("IconThemePath"));
case Role::Id:
return sniData.value(QStringLiteral("Id"));
return itemId;
case Role::ItemIsMenu:
return sniData.value(QStringLiteral("ItemIsMenu"));
case Role::OverlayIconName:
......
Supports Markdown
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