2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-06-15 17:44:38 +08:00
|
|
|
#ifndef DATETIMEPLUGIN_H
|
|
|
|
#define DATETIMEPLUGIN_H
|
|
|
|
|
|
|
|
#include "pluginsiteminterface.h"
|
2016-06-27 14:33:21 +08:00
|
|
|
#include "datetimewidget.h"
|
2016-06-15 17:44:38 +08:00
|
|
|
|
2016-06-16 17:48:19 +08:00
|
|
|
#include <QTimer>
|
2016-07-13 10:08:38 +08:00
|
|
|
#include <QLabel>
|
2018-03-06 15:18:53 +08:00
|
|
|
#include <QSettings>
|
2016-07-01 11:07:20 +08:00
|
|
|
|
2020-06-29 15:35:51 +08:00
|
|
|
namespace Dock{
|
|
|
|
class TipsWidget;
|
|
|
|
}
|
2019-09-03 09:37:59 +08:00
|
|
|
class QDBusInterface;
|
2016-06-15 17:44:38 +08:00
|
|
|
class DatetimePlugin : public QObject, PluginsItemInterface
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(PluginsItemInterface)
|
|
|
|
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "datetime.json")
|
|
|
|
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
explicit DatetimePlugin(QObject *parent = nullptr);
|
2016-06-16 16:56:21 +08:00
|
|
|
|
2020-11-06 17:52:08 +08:00
|
|
|
PluginSizePolicy pluginSizePolicy() const override;
|
|
|
|
|
2016-08-02 20:14:45 +08:00
|
|
|
const QString pluginName() const override;
|
2017-10-23 13:36:16 +08:00
|
|
|
const QString pluginDisplayName() const override;
|
2016-08-02 20:14:45 +08:00
|
|
|
void init(PluginProxyInterface *proxyInter) override;
|
2016-06-24 11:32:25 +08:00
|
|
|
|
2017-10-23 13:36:16 +08:00
|
|
|
void pluginStateSwitched() override;
|
|
|
|
bool pluginIsAllowDisable() override { return true; }
|
|
|
|
bool pluginIsDisable() override;
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
int itemSortKey(const QString &itemKey) override;
|
|
|
|
void setSortKey(const QString &itemKey, const int order) override;
|
2016-06-28 10:06:04 +08:00
|
|
|
|
2016-08-02 20:14:45 +08:00
|
|
|
QWidget *itemWidget(const QString &itemKey) override;
|
|
|
|
QWidget *itemTipsWidget(const QString &itemKey) override;
|
2016-06-24 11:32:25 +08:00
|
|
|
|
2016-08-02 20:14:45 +08:00
|
|
|
const QString itemCommand(const QString &itemKey) override;
|
2016-09-21 10:24:42 +08:00
|
|
|
const QString itemContextMenu(const QString &itemKey) override;
|
|
|
|
|
2017-06-19 14:15:16 +08:00
|
|
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
2016-07-13 10:08:38 +08:00
|
|
|
|
2019-01-30 18:00:46 +08:00
|
|
|
void pluginSettingsChanged() override;
|
|
|
|
|
2016-06-27 15:34:54 +08:00
|
|
|
private slots:
|
|
|
|
void updateCurrentTimeString();
|
2019-01-30 18:00:46 +08:00
|
|
|
void refreshPluginItemsVisible();
|
2019-09-03 09:37:59 +08:00
|
|
|
void propertiesChanged();
|
2016-06-27 15:34:54 +08:00
|
|
|
|
2019-09-04 11:07:02 +08:00
|
|
|
private:
|
|
|
|
void loadPlugin();
|
2019-09-20 17:57:33 +08:00
|
|
|
QDBusInterface *timedateInterface();
|
2019-09-04 11:07:02 +08:00
|
|
|
|
2016-06-16 17:48:19 +08:00
|
|
|
private:
|
2017-11-08 14:51:11 +08:00
|
|
|
QPointer<DatetimeWidget> m_centralWidget;
|
2020-06-29 15:35:51 +08:00
|
|
|
QPointer<Dock::TipsWidget> m_dateTipsLabel;
|
2016-06-16 17:48:19 +08:00
|
|
|
QTimer *m_refershTimer;
|
2016-06-27 15:34:54 +08:00
|
|
|
QString m_currentTimeString;
|
2019-09-03 09:37:59 +08:00
|
|
|
QDBusInterface *m_interface;
|
2019-09-04 11:07:02 +08:00
|
|
|
bool m_pluginLoaded;
|
2016-06-15 17:44:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DATETIMEPLUGIN_H
|