Skip to content

Commit

Permalink
fix(plugins): use a fixed default sort for plugins
Browse files Browse the repository at this point in the history
Change-Id: Ib801201f1efd5290bc037b423281e6f1e79f424f
  • Loading branch information
listenerri committed Sep 7, 2018
1 parent 009c03c commit e802e87
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
10 changes: 8 additions & 2 deletions plugins/datetime/datetimeplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ int DatetimePlugin::itemSortKey(const QString &itemKey)
{
Q_UNUSED(itemKey);

const QString key = QString("pos_%1").arg(displayMode());
return m_settings.value(key, 0).toInt();
Dock::DisplayMode mode = displayMode();
const QString key = QString("pos_%1").arg(mode);

if (mode == Dock::DisplayMode::Fashion) {
return m_settings.value(key, 5).toInt();
} else {
return m_settings.value(key, -1).toInt();
}
}

void DatetimePlugin::setSortKey(const QString &itemKey, const int order)
Expand Down
10 changes: 8 additions & 2 deletions plugins/network/networkplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ QWidget *NetworkPlugin::itemPopupApplet(const QString &itemKey)

int NetworkPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
return m_settings.value(key, 0).toInt();
Dock::DisplayMode mode = displayMode();
const QString key = QString("pos_%1_%2").arg(itemKey).arg(mode);

if (mode == Dock::DisplayMode::Fashion) {
return m_settings.value(key, 2).toInt();
} else {
return m_settings.value(key, 3).toInt();
}
}

void NetworkPlugin::setSortKey(const QString &itemKey, const int order)
Expand Down
12 changes: 10 additions & 2 deletions plugins/shutdown/shutdownplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,16 @@ void ShutdownPlugin::displayModeChanged(const Dock::DisplayMode displayMode)

int ShutdownPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
return m_settings.value(key, 0).toInt();
Dock::DisplayMode mode = displayMode();
const QString key = QString("pos_%1_%2").arg(itemKey).arg(mode);

//if (mode == Dock::DisplayMode::Fashion) {
//return m_settings.value(key, 4).toInt();
//} else {
//return m_settings.value(key, 4).toInt();
//}

return m_settings.value(key, 4).toInt();
}

void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
Expand Down
10 changes: 8 additions & 2 deletions plugins/sound/soundplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ int SoundPlugin::itemSortKey(const QString &itemKey)
{
Q_UNUSED(itemKey);

const QString key = QString("pos_%1").arg(displayMode());
return m_settings.value(key, 0).toInt();
Dock::DisplayMode mode = displayMode();
const QString key = QString("pos_%1").arg(mode);

if (mode == Dock::DisplayMode::Fashion) {
return m_settings.value(key, 1).toInt();
} else {
return m_settings.value(key, 2).toInt();
}
}

void SoundPlugin::setSortKey(const QString &itemKey, const int order)
Expand Down
10 changes: 8 additions & 2 deletions plugins/system-tray/systemtrayplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ bool SystemTrayPlugin::itemIsInContainer(const QString &itemKey)

int SystemTrayPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
return m_containerSettings->value(key, 0).toInt();
Dock::DisplayMode mode = displayMode();
const QString key = QString("pos_%1_%2").arg(itemKey).arg(mode);

if (mode == Dock::DisplayMode::Fashion) {
return m_containerSettings->value(key, 3).toInt();
} else {
return m_containerSettings->value(key, 1).toInt();
}
}

void SystemTrayPlugin::setSortKey(const QString &itemKey, const int order)
Expand Down

0 comments on commit e802e87

Please sign in to comment.