2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
2022-09-06 11:36:55 +08:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2017-09-18 14:33:44 +08:00
|
|
|
|
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:
|
2021-05-25 13:05:45 +08:00
|
|
|
QScopedPointer<DatetimeWidget> m_centralWidget;
|
|
|
|
QScopedPointer<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
|