mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat(plugins): keep order
Change-Id: Iaa9dd11750999fca6faf2d3b1d3bbb60f6ba740b
This commit is contained in:
parent
0d2c94fe11
commit
e281f088ac
Notes:
gerrit
2018-03-08 03:45:26 +00:00
Verified+1: Anonymous Coward #1000004 Verified+1: <zhaofangfang@linuxdeepin.com> Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: Rekols <rekols@foxmail.com> Submitted-at: Thu, 08 Mar 2018 03:45:26 +0000 Reviewed-on: https://cr.deepin.io/32259 Project: dde/dde-dock Branch: refs/heads/master
@ -308,15 +308,15 @@ void DockItemController::pluginItemInserted(PluginsItem *item)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
insertIndex = m_itemList.size();
|
insertIndex = m_itemList.size();
|
||||||
for (int i(firstPluginPosition); i != m_itemList.size(); ++i)
|
for (int i(firstPluginPosition + 1); i != m_itemList.size() + 1; ++i)
|
||||||
{
|
{
|
||||||
PluginsItem *pItem = static_cast<PluginsItem *>(m_itemList[i]);
|
PluginsItem *pItem = static_cast<PluginsItem *>(m_itemList[i - 1]);
|
||||||
Q_ASSERT(pItem);
|
Q_ASSERT(pItem);
|
||||||
|
|
||||||
const int sortKey = pItem->itemSortKey();
|
const int sortKey = pItem->itemSortKey();
|
||||||
if (sortKey != -1 && itemSortKey > sortKey)
|
if (sortKey != -1 && itemSortKey > sortKey)
|
||||||
continue;
|
continue;
|
||||||
insertIndex = i;
|
insertIndex = i - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,15 @@
|
|||||||
#include "datetimeplugin.h"
|
#include "datetimeplugin.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
DatetimePlugin::DatetimePlugin(QObject *parent)
|
DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
|
||||||
m_dateTipsLabel(new QLabel),
|
m_dateTipsLabel(new QLabel),
|
||||||
|
|
||||||
m_refershTimer(new QTimer(this))
|
m_refershTimer(new QTimer(this)),
|
||||||
|
m_settings("deepin", "dde-dock-datetime")
|
||||||
{
|
{
|
||||||
m_dateTipsLabel->setObjectName("datetime");
|
m_dateTipsLabel->setObjectName("datetime");
|
||||||
m_dateTipsLabel->setStyleSheet("color:white;"
|
m_dateTipsLabel->setStyleSheet("color:white;"
|
||||||
@ -82,7 +84,16 @@ int DatetimePlugin::itemSortKey(const QString &itemKey)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(itemKey);
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
return -1;
|
const QString key = QString("pos_%1").arg(displayMode());
|
||||||
|
return m_settings.value(key, 0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatetimePlugin::setSortKey(const QString &itemKey, const int order)
|
||||||
|
{
|
||||||
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
|
const QString key = QString("pos_%1").arg(displayMode());
|
||||||
|
m_settings.setValue(key, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DatetimePlugin::itemWidget(const QString &itemKey)
|
QWidget *DatetimePlugin::itemWidget(const QString &itemKey)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
class DatetimePlugin : public QObject, PluginsItemInterface
|
class DatetimePlugin : public QObject, PluginsItemInterface
|
||||||
{
|
{
|
||||||
@ -45,7 +46,8 @@ public:
|
|||||||
bool pluginIsAllowDisable() override { return true; }
|
bool pluginIsAllowDisable() override { return true; }
|
||||||
bool pluginIsDisable() override;
|
bool pluginIsDisable() override;
|
||||||
|
|
||||||
int itemSortKey(const QString &itemKey) override;
|
int itemSortKey(const QString &itemKey);
|
||||||
|
void setSortKey(const QString &itemKey, const int order);
|
||||||
|
|
||||||
QWidget *itemWidget(const QString &itemKey) override;
|
QWidget *itemWidget(const QString &itemKey) override;
|
||||||
QWidget *itemTipsWidget(const QString &itemKey) override;
|
QWidget *itemTipsWidget(const QString &itemKey) override;
|
||||||
@ -65,6 +67,7 @@ private:
|
|||||||
QTimer *m_refershTimer;
|
QTimer *m_refershTimer;
|
||||||
|
|
||||||
QString m_currentTimeString;
|
QString m_currentTimeString;
|
||||||
|
QSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATETIMEPLUGIN_H
|
#endif // DATETIMEPLUGIN_H
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
const QString pluginDisplayName() const override;
|
const QString pluginDisplayName() const override;
|
||||||
void init(PluginProxyInterface *proxyInter) override;
|
void init(PluginProxyInterface *proxyInter) override;
|
||||||
|
|
||||||
QWidget *itemWidget(const QString &itemKey) override;
|
QWidget *itemWidget(const QString &itemKey);
|
||||||
QWidget *itemTipsWidget(const QString &itemKey);
|
QWidget *itemTipsWidget(const QString &itemKey);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -143,6 +143,18 @@ QWidget *NetworkPlugin::itemPopupApplet(const QString &itemKey)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NetworkPlugin::itemSortKey(const QString &itemKey)
|
||||||
|
{
|
||||||
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
return m_settings.value(key, 0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkPlugin::setSortKey(const QString &itemKey, const int order)
|
||||||
|
{
|
||||||
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
m_settings.setValue(key, order);
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkPlugin::deviceAdded(const NetworkDevice &device)
|
void NetworkPlugin::deviceAdded(const NetworkDevice &device)
|
||||||
{
|
{
|
||||||
DeviceItem *item = nullptr;
|
DeviceItem *item = nullptr;
|
||||||
|
@ -51,6 +51,9 @@ public:
|
|||||||
QWidget *itemTipsWidget(const QString &itemKey);
|
QWidget *itemTipsWidget(const QString &itemKey);
|
||||||
QWidget *itemPopupApplet(const QString &itemKey);
|
QWidget *itemPopupApplet(const QString &itemKey);
|
||||||
|
|
||||||
|
int itemSortKey(const QString &itemKey);
|
||||||
|
void setSortKey(const QString &itemKey, const int order);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void deviceAdded(const NetworkDevice &device);
|
void deviceAdded(const NetworkDevice &device);
|
||||||
void deviceRemoved(const NetworkDevice &device);
|
void deviceRemoved(const NetworkDevice &device);
|
||||||
|
@ -228,6 +228,18 @@ void ShutdownPlugin::displayModeChanged(const Dock::DisplayMode displayMode)
|
|||||||
updateBatteryVisible();
|
updateBatteryVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ShutdownPlugin::itemSortKey(const QString &itemKey)
|
||||||
|
{
|
||||||
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
return m_settings.value(key, 0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
|
||||||
|
{
|
||||||
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
m_settings.setValue(key, order);
|
||||||
|
}
|
||||||
|
|
||||||
void ShutdownPlugin::updateBatteryVisible()
|
void ShutdownPlugin::updateBatteryVisible()
|
||||||
{
|
{
|
||||||
const bool exist = !m_powerInter->batteryPercentage().isEmpty();
|
const bool exist = !m_powerInter->batteryPercentage().isEmpty();
|
||||||
|
@ -56,6 +56,9 @@ public:
|
|||||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
||||||
void displayModeChanged(const Dock::DisplayMode displayMode) override;
|
void displayModeChanged(const Dock::DisplayMode displayMode) override;
|
||||||
|
|
||||||
|
int itemSortKey(const QString &itemKey);
|
||||||
|
void setSortKey(const QString &itemKey, const int order);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateBatteryVisible();
|
void updateBatteryVisible();
|
||||||
void requestContextMenu(const QString &itemKey);
|
void requestContextMenu(const QString &itemKey);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "soundplugin.h"
|
#include "soundplugin.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#define STATE_KEY "enable"
|
#define STATE_KEY "enable"
|
||||||
|
|
||||||
@ -28,7 +29,6 @@ SoundPlugin::SoundPlugin(QObject *parent)
|
|||||||
m_settings("deepin", "dde-dock-sound"),
|
m_settings("deepin", "dde-dock-sound"),
|
||||||
m_soundItem(nullptr)
|
m_soundItem(nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString SoundPlugin::pluginName() const
|
const QString SoundPlugin::pluginName() const
|
||||||
@ -101,3 +101,19 @@ void SoundPlugin::invokedMenuItem(const QString &itemKey, const QString &menuId,
|
|||||||
|
|
||||||
m_soundItem->invokeMenuItem(menuId, checked);
|
m_soundItem->invokeMenuItem(menuId, checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SoundPlugin::itemSortKey(const QString &itemKey)
|
||||||
|
{
|
||||||
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
|
const QString key = QString("pos_%1").arg(displayMode());
|
||||||
|
return m_settings.value(key, 0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundPlugin::setSortKey(const QString &itemKey, const int order)
|
||||||
|
{
|
||||||
|
Q_UNUSED(itemKey);
|
||||||
|
|
||||||
|
const QString key = QString("pos_%1").arg(displayMode());
|
||||||
|
m_settings.setValue(key, order);
|
||||||
|
}
|
||||||
|
@ -50,6 +50,9 @@ public:
|
|||||||
const QString itemContextMenu(const QString &itemKey);
|
const QString itemContextMenu(const QString &itemKey);
|
||||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
|
||||||
|
|
||||||
|
int itemSortKey(const QString &itemKey);
|
||||||
|
void setSortKey(const QString &itemKey, const int order);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings m_settings;
|
QSettings m_settings;
|
||||||
SoundItem *m_soundItem;
|
SoundItem *m_soundItem;
|
||||||
|
@ -129,9 +129,14 @@ bool SystemTrayPlugin::itemIsInContainer(const QString &itemKey)
|
|||||||
|
|
||||||
int SystemTrayPlugin::itemSortKey(const QString &itemKey)
|
int SystemTrayPlugin::itemSortKey(const QString &itemKey)
|
||||||
{
|
{
|
||||||
Q_UNUSED(itemKey);
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
return m_containerSettings->value(key, 0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
void SystemTrayPlugin::setSortKey(const QString &itemKey, const int order)
|
||||||
|
{
|
||||||
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||||
|
m_containerSettings->setValue(key, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTrayPlugin::setItemIsInContainer(const QString &itemKey, const bool container)
|
void SystemTrayPlugin::setItemIsInContainer(const QString &itemKey, const bool container)
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
bool itemAllowContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
bool itemAllowContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
bool itemIsInContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
bool itemIsInContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||||
|
void setSortKey(const QString &itemKey, const int order);
|
||||||
void setItemIsInContainer(const QString &itemKey, const bool container) Q_DECL_OVERRIDE;
|
void setItemIsInContainer(const QString &itemKey, const bool container) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user