sound: support hide

Change-Id: I8004f39ced9d97fd5b1718893e0042b1a96ef68a
This commit is contained in:
石博文 2017-10-23 13:15:57 +08:00
parent 137ac55518
commit fde1d638f0
Notes: Deepin Code Review 2017-10-23 13:19:53 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Mon, 23 Oct 2017 13:19:52 +0800
Reviewed-on: https://cr.deepin.io/27301
Project: dde/dde-dock
Branch: refs/heads/master
2 changed files with 30 additions and 2 deletions

View File

@ -21,6 +21,8 @@
#include "soundplugin.h"
#define STATE_KEY "enable"
SoundPlugin::SoundPlugin(QObject *parent)
: QObject(parent),
m_soundItem(nullptr)
@ -33,6 +35,11 @@ const QString SoundPlugin::pluginName() const
return "sound";
}
const QString SoundPlugin::pluginDisplayName() const
{
return tr("Sound");
}
void SoundPlugin::init(PluginProxyInterface *proxyInter)
{
m_proxyInter = proxyInter;
@ -40,7 +47,23 @@ void SoundPlugin::init(PluginProxyInterface *proxyInter)
m_soundItem = new SoundItem;
connect(m_soundItem, &SoundItem::requestContextMenu, [this] {m_proxyInter->requestContextMenu(this, QString());});
m_proxyInter->itemAdded(this, QString());
if (m_settings.value(STATE_KEY).toBool())
m_proxyInter->itemAdded(this, QString());
}
void SoundPlugin::pluginStateSwitched()
{
m_settings.setValue(STATE_KEY, !m_settings.value(STATE_KEY, true).toBool());
if (m_settings.value(STATE_KEY).toBool())
m_proxyInter->itemAdded(this, QString());
else
m_proxyInter->itemRemoved(this, QString());
}
bool SoundPlugin::pluginIsDisable()
{
return !m_settings.value(STATE_KEY, true).toBool();
}
QWidget *SoundPlugin::itemWidget(const QString &itemKey)

View File

@ -25,7 +25,7 @@
#include "pluginsiteminterface.h"
#include "sounditem.h"
#include <QObject>
#include <QSettings>
class SoundPlugin : public QObject, PluginsItemInterface
{
@ -37,7 +37,11 @@ public:
explicit SoundPlugin(QObject *parent = 0);
const QString pluginName() const;
const QString pluginDisplayName() const;
void init(PluginProxyInterface *proxyInter);
void pluginStateSwitched();
bool pluginIsAllowDisable() { return true; }
bool pluginIsDisable();
QWidget *itemWidget(const QString &itemKey);
QWidget *itemTipsWidget(const QString &itemKey);
@ -47,6 +51,7 @@ public:
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
private:
QSettings m_settings;
SoundItem *m_soundItem;
};