mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
datetime: support hide plugin
Change-Id: If39a7f316be13fb9d541fc5e5691cee33d1584cd
This commit is contained in:
parent
fde1d638f0
commit
1aa5922f80
Notes:
Deepin Code Review
2017-10-23 13:53:18 +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:53:18 +0800 Reviewed-on: https://cr.deepin.io/27304 Project: dde/dde-dock Branch: refs/heads/master
@ -56,11 +56,32 @@ const QString DatetimePlugin::pluginName() const
|
|||||||
return "datetime";
|
return "datetime";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString DatetimePlugin::pluginDisplayName() const
|
||||||
|
{
|
||||||
|
return tr("Datetime");
|
||||||
|
}
|
||||||
|
|
||||||
void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
void DatetimePlugin::init(PluginProxyInterface *proxyInter)
|
||||||
{
|
{
|
||||||
m_proxyInter = proxyInter;
|
m_proxyInter = proxyInter;
|
||||||
|
|
||||||
m_proxyInter->itemAdded(this, QString());
|
if (m_centralWidget->enabled())
|
||||||
|
m_proxyInter->itemAdded(this, QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatetimePlugin::pluginStateSwitched()
|
||||||
|
{
|
||||||
|
m_centralWidget->setEnabled(!m_centralWidget->enabled());
|
||||||
|
|
||||||
|
if (m_centralWidget->enabled())
|
||||||
|
m_proxyInter->itemAdded(this, QString());
|
||||||
|
else
|
||||||
|
m_proxyInter->itemRemoved(this, QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DatetimePlugin::pluginIsDisable()
|
||||||
|
{
|
||||||
|
return !m_centralWidget->enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DatetimePlugin::itemSortKey(const QString &itemKey)
|
int DatetimePlugin::itemSortKey(const QString &itemKey)
|
||||||
|
@ -39,8 +39,13 @@ public:
|
|||||||
~DatetimePlugin();
|
~DatetimePlugin();
|
||||||
|
|
||||||
const QString pluginName() const override;
|
const QString pluginName() const override;
|
||||||
|
const QString pluginDisplayName() const override;
|
||||||
void init(PluginProxyInterface *proxyInter) override;
|
void init(PluginProxyInterface *proxyInter) override;
|
||||||
|
|
||||||
|
void pluginStateSwitched() override;
|
||||||
|
bool pluginIsAllowDisable() override { return true; }
|
||||||
|
bool pluginIsDisable() override;
|
||||||
|
|
||||||
int itemSortKey(const QString &itemKey) override;
|
int itemSortKey(const QString &itemKey) override;
|
||||||
|
|
||||||
QWidget *itemWidget(const QString &itemKey) override;
|
QWidget *itemWidget(const QString &itemKey) override;
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
#define PLUGIN_STATE_KEY "enable"
|
||||||
|
|
||||||
DatetimeWidget::DatetimeWidget(QWidget *parent)
|
DatetimeWidget::DatetimeWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
|
||||||
@ -38,6 +40,16 @@ DatetimeWidget::DatetimeWidget(QWidget *parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatetimeWidget::enabled()
|
||||||
|
{
|
||||||
|
return m_settings.value(PLUGIN_STATE_KEY, true).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatetimeWidget::setEnabled(const bool b)
|
||||||
|
{
|
||||||
|
m_settings.setValue(PLUGIN_STATE_KEY, b);
|
||||||
|
}
|
||||||
|
|
||||||
void DatetimeWidget::toggleHourFormat()
|
void DatetimeWidget::toggleHourFormat()
|
||||||
{
|
{
|
||||||
m_24HourFormat = !m_24HourFormat;
|
m_24HourFormat = !m_24HourFormat;
|
||||||
|
@ -33,6 +33,8 @@ public:
|
|||||||
explicit DatetimeWidget(QWidget *parent = 0);
|
explicit DatetimeWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
bool is24HourFormat() const { return m_24HourFormat; }
|
bool is24HourFormat() const { return m_24HourFormat; }
|
||||||
|
bool enabled();
|
||||||
|
void setEnabled(const bool b);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestUpdateGeometry() const;
|
void requestUpdateGeometry() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user