mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat: update all plugins to support take effect in time for Deepin-Sync
Change-Id: I6fec9ab494eede8a4b0f35e62ccd6f4c749ded09
This commit is contained in:
parent
07e8775371
commit
8ae30ec2d1
Notes:
gerrit
2019-01-30 18:08:56 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Wed, 30 Jan 2019 18:08:56 +0800 Reviewed-on: https://cr.deepin.io/41542 Project: dde/dde-dock Branch: refs/heads/dev/daemon-plugin-settings
@ -79,10 +79,7 @@ void DatetimePlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool DatetimePlugin::pluginIsDisable()
|
||||
@ -183,6 +180,13 @@ void DatetimePlugin::invokedMenuItem(const QString &itemKey, const QString &menu
|
||||
}
|
||||
}
|
||||
|
||||
void DatetimePlugin::pluginSettingsChanged()
|
||||
{
|
||||
m_centralWidget->set24HourFormat(m_proxyInter->getValue(this, TIME_FORMAT_KEY, true).toBool());
|
||||
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
void DatetimePlugin::updateCurrentTimeString()
|
||||
{
|
||||
const QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
@ -200,3 +204,11 @@ void DatetimePlugin::updateCurrentTimeString()
|
||||
m_currentTimeString = currentString;
|
||||
m_centralWidget->update();
|
||||
}
|
||||
|
||||
void DatetimePlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
else
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
}
|
||||
|
@ -58,8 +58,11 @@ public:
|
||||
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
||||
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
private slots:
|
||||
void updateCurrentTimeString();
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
QPointer<DatetimeWidget> m_centralWidget;
|
||||
|
@ -88,19 +88,7 @@ void NetworkPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (pluginIsDisable()) {
|
||||
for (auto itemKey : m_itemsMap.keys()) {
|
||||
m_proxyInter->itemRemoved(this, itemKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
onDeviceListChanged(m_networkModel->devices());
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool NetworkPlugin::pluginIsDisable()
|
||||
@ -171,6 +159,11 @@ void NetworkPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void NetworkPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool NetworkPlugin::isConnectivity()
|
||||
{
|
||||
return NetworkModel::connectivity() == Connectivity::Full;
|
||||
@ -329,3 +322,20 @@ void NetworkPlugin::onItemRequestSetAppletVisible(const bool visible)
|
||||
|
||||
m_proxyInter->requestSetAppletVisible(this, item->path(), visible);
|
||||
}
|
||||
|
||||
void NetworkPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable()) {
|
||||
for (auto itemKey : m_itemsMap.keys()) {
|
||||
m_proxyInter->itemRemoved(this, itemKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
onDeviceListChanged(m_networkModel->devices());
|
||||
}
|
||||
|
@ -54,12 +54,15 @@ public:
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
static bool isConnectivity();
|
||||
|
||||
private slots:
|
||||
void onDeviceListChanged(const QList<dde::network::NetworkDevice *> devices);
|
||||
void refreshWiredItemVisible();
|
||||
void onItemRequestSetAppletVisible(const bool visible);
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
DeviceItem *itemByPath(const QString &path);
|
||||
|
@ -73,16 +73,7 @@ void OnboardPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (pluginIsDisable())
|
||||
{
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool OnboardPlugin::pluginIsDisable()
|
||||
@ -151,6 +142,11 @@ void OnboardPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void OnboardPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
void OnboardPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
@ -165,3 +161,17 @@ void OnboardPlugin::loadPlugin()
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
displayModeChanged(displayMode());
|
||||
}
|
||||
|
||||
void OnboardPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable())
|
||||
{
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,11 @@ public:
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
private:
|
||||
void loadPlugin();
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
bool m_pluginLoaded;
|
||||
|
@ -94,15 +94,7 @@ void PowerPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (pluginIsDisable()) {
|
||||
m_proxyInter->itemRemoved(this, POWER_KEY);
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
updateBatteryVisible();
|
||||
}
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool PowerPlugin::pluginIsDisable()
|
||||
@ -171,6 +163,11 @@ void PowerPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void PowerPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
void PowerPlugin::updateBatteryVisible()
|
||||
{
|
||||
const bool exist = !m_powerInter->batteryPercentage().isEmpty();
|
||||
@ -197,3 +194,16 @@ void PowerPlugin::loadPlugin()
|
||||
|
||||
updateBatteryVisible();
|
||||
}
|
||||
|
||||
void PowerPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable()) {
|
||||
m_proxyInter->itemRemoved(this, POWER_KEY);
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
updateBatteryVisible();
|
||||
}
|
||||
}
|
||||
|
@ -55,10 +55,12 @@ public:
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
private:
|
||||
void updateBatteryVisible();
|
||||
void loadPlugin();
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
bool m_pluginLoaded;
|
||||
|
@ -83,16 +83,7 @@ void ShutdownPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, PLUGIN_STATE_KEY, !m_proxyInter->getValue(this, PLUGIN_STATE_KEY, true).toBool());
|
||||
|
||||
if (pluginIsDisable())
|
||||
{
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool ShutdownPlugin::pluginIsDisable()
|
||||
@ -219,6 +210,11 @@ void ShutdownPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void ShutdownPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
void ShutdownPlugin::loadPlugin()
|
||||
{
|
||||
if (m_pluginLoaded) {
|
||||
@ -247,3 +243,17 @@ bool ShutdownPlugin::checkSwap()
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShutdownPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable())
|
||||
{
|
||||
m_proxyInter->itemRemoved(this, pluginName());
|
||||
} else {
|
||||
if (!m_pluginLoaded) {
|
||||
loadPlugin();
|
||||
return;
|
||||
}
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
}
|
||||
}
|
||||
|
@ -55,9 +55,12 @@ public:
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
private:
|
||||
void loadPlugin();
|
||||
bool checkSwap();
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
bool m_pluginLoaded;
|
||||
|
@ -54,10 +54,7 @@ void SoundPlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, STATE_KEY, pluginIsDisable());
|
||||
|
||||
if (pluginIsDisable())
|
||||
m_proxyInter->itemRemoved(this, SOUND_KEY);
|
||||
else
|
||||
m_proxyInter->itemAdded(this, SOUND_KEY);
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
bool SoundPlugin::pluginIsDisable()
|
||||
@ -128,3 +125,16 @@ void SoundPlugin::refreshIcon(const QString &itemKey)
|
||||
m_soundItem->refreshIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void SoundPlugin::pluginSettingsChanged()
|
||||
{
|
||||
refreshPluginItemsVisible();
|
||||
}
|
||||
|
||||
void SoundPlugin::refreshPluginItemsVisible()
|
||||
{
|
||||
if (pluginIsDisable())
|
||||
m_proxyInter->itemRemoved(this, SOUND_KEY);
|
||||
else
|
||||
m_proxyInter->itemAdded(this, SOUND_KEY);
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ public:
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
private:
|
||||
void refreshPluginItemsVisible();
|
||||
|
||||
private:
|
||||
SoundItem *m_soundItem;
|
||||
|
@ -240,6 +240,11 @@ void FashionTrayItem::setRightSplitVisible(const bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
void FashionTrayItem::onPluginSettingsChanged()
|
||||
{
|
||||
m_controlWidget->setExpanded(m_trayPlugin->getValue(FASHION_MODE_ITEM_KEY, ExpandedKey, true).toBool());
|
||||
}
|
||||
|
||||
void FashionTrayItem::showEvent(QShowEvent *event)
|
||||
{
|
||||
requestResize();
|
||||
|
@ -60,6 +60,7 @@ public slots:
|
||||
void onExpandChanged(const bool expand);
|
||||
void setSuggestIconSize(QSize size);
|
||||
void setRightSplitVisible(const bool visible);
|
||||
void onPluginSettingsChanged();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "xcb/xcb_icccm.h"
|
||||
|
||||
#define PLUGIN_ENABLED_KEY "enable"
|
||||
#define FASHION_MODE_TRAYS_SORTED "fashion-mode-trays-sorted"
|
||||
|
||||
#define SNI_WATCHER_SERVICE "org.kde.StatusNotifierWatcher"
|
||||
@ -77,7 +78,7 @@ void TrayPlugin::init(PluginProxyInterface *proxyInter)
|
||||
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
if (!proxyInter->getValue(this, "enable", true).toBool()) {
|
||||
if (pluginIsDisable()) {
|
||||
qDebug() << "hide tray from config disable!!";
|
||||
return;
|
||||
}
|
||||
@ -96,9 +97,14 @@ void TrayPlugin::init(PluginProxyInterface *proxyInter)
|
||||
QTimer::singleShot(4000, this, &TrayPlugin::initXEmbed);
|
||||
}
|
||||
|
||||
bool TrayPlugin::pluginIsDisable()
|
||||
{
|
||||
return !m_proxyInter->getValue(this, PLUGIN_ENABLED_KEY, true).toBool();
|
||||
}
|
||||
|
||||
void TrayPlugin::displayModeChanged(const Dock::DisplayMode mode)
|
||||
{
|
||||
if (!m_proxyInter->getValue(this, "enable", true).toBool()) {
|
||||
if (pluginIsDisable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,7 +113,7 @@ void TrayPlugin::displayModeChanged(const Dock::DisplayMode mode)
|
||||
|
||||
void TrayPlugin::positionChanged(const Dock::Position position)
|
||||
{
|
||||
if (!m_proxyInter->getValue(this, "enable", true).toBool()) {
|
||||
if (pluginIsDisable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -208,6 +214,19 @@ void TrayPlugin::refreshIcon(const QString &itemKey)
|
||||
}
|
||||
}
|
||||
|
||||
void TrayPlugin::pluginSettingsChanged()
|
||||
{
|
||||
if (pluginIsDisable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (displayMode() == Dock::DisplayMode::Fashion) {
|
||||
m_fashionItem->onPluginSettingsChanged();
|
||||
m_fashionItem->clearTrayWidgets();
|
||||
m_fashionItem->setTrayWidgets(m_trayMap);
|
||||
}
|
||||
}
|
||||
|
||||
Dock::Position TrayPlugin::dockPosition() const
|
||||
{
|
||||
return position();
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
|
||||
const QString pluginName() const Q_DECL_OVERRIDE;
|
||||
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
|
||||
bool pluginIsDisable() override;
|
||||
void displayModeChanged(const Dock::DisplayMode mode) Q_DECL_OVERRIDE;
|
||||
void positionChanged(const Dock::Position position) Q_DECL_OVERRIDE;
|
||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
@ -59,6 +60,7 @@ public:
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void setItemIsInContainer(const QString &itemKey, const bool container) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void pluginSettingsChanged() override;
|
||||
|
||||
Dock::Position dockPosition() const;
|
||||
bool traysSortedInFashionMode();
|
||||
|
Loading…
x
Reference in New Issue
Block a user