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
|
|
|
|
2018-11-13 20:07:52 +08:00
|
|
|
#ifndef POWERPLUGIN_H
|
|
|
|
#define POWERPLUGIN_H
|
2016-06-24 14:59:56 +08:00
|
|
|
|
|
|
|
#include "pluginsiteminterface.h"
|
2016-07-19 16:10:58 +08:00
|
|
|
#include "powerstatuswidget.h"
|
2016-07-08 09:39:47 +08:00
|
|
|
#include "dbus/dbuspower.h"
|
2016-06-24 14:59:56 +08:00
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
#include "org_deepin_dde_systempower1.h"
|
2019-05-13 16:15:37 +08:00
|
|
|
|
2016-07-14 10:31:34 +08:00
|
|
|
#include <QLabel>
|
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
using SystemPowerInter = org::deepin::dde::Power1;
|
2023-02-21 15:57:42 +08:00
|
|
|
|
|
|
|
DCORE_BEGIN_NAMESPACE
|
|
|
|
class DConfig;
|
|
|
|
DCORE_END_NAMESPACE
|
|
|
|
|
2020-06-29 15:35:51 +08:00
|
|
|
namespace Dock {
|
|
|
|
class TipsWidget;
|
|
|
|
}
|
2018-11-13 20:07:52 +08:00
|
|
|
class PowerPlugin : public QObject, PluginsItemInterface
|
2016-06-24 14:59:56 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-11-13 20:07:52 +08:00
|
|
|
Q_INTERFACES(PluginsItemInterface)
|
|
|
|
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "power.json")
|
2016-06-24 14:59:56 +08:00
|
|
|
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
explicit PowerPlugin(QObject *parent = nullptr);
|
2016-06-24 14:59:56 +08:00
|
|
|
|
2017-10-23 14:21:09 +08:00
|
|
|
const QString pluginName() const override;
|
|
|
|
const QString pluginDisplayName() const override;
|
|
|
|
void init(PluginProxyInterface *proxyInter) override;
|
|
|
|
bool pluginIsAllowDisable() override { return true; }
|
|
|
|
QWidget *itemWidget(const QString &itemKey) override;
|
|
|
|
QWidget *itemTipsWidget(const QString &itemKey) override;
|
|
|
|
const QString itemCommand(const QString &itemKey) override;
|
|
|
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
2020-06-13 19:19:30 +08:00
|
|
|
void refreshIcon(const QString &itemKey) override;
|
|
|
|
int itemSortKey(const QString &itemKey) override;
|
|
|
|
void setSortKey(const QString &itemKey, const int order) override;
|
2022-12-02 15:41:34 +08:00
|
|
|
QIcon icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType) override;
|
2022-11-28 14:37:54 +08:00
|
|
|
PluginFlags flags() const override;
|
2018-03-06 15:18:53 +08:00
|
|
|
|
2016-06-24 14:59:56 +08:00
|
|
|
private:
|
2016-07-19 16:10:58 +08:00
|
|
|
void updateBatteryVisible();
|
2018-07-31 23:03:37 +08:00
|
|
|
void loadPlugin();
|
2020-05-18 16:05:08 +08:00
|
|
|
void onGSettingsChanged(const QString &key);
|
2023-02-01 13:29:58 +08:00
|
|
|
void initUi();
|
|
|
|
void initConnection();
|
|
|
|
|
|
|
|
private slots:
|
2019-05-13 11:38:51 +08:00
|
|
|
void refreshTipsData();
|
2023-02-01 13:29:58 +08:00
|
|
|
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
2016-07-19 16:10:58 +08:00
|
|
|
|
|
|
|
private:
|
2018-07-31 23:03:37 +08:00
|
|
|
bool m_pluginLoaded;
|
2020-05-18 16:05:08 +08:00
|
|
|
bool m_showTimeToFull;
|
2018-07-31 23:03:37 +08:00
|
|
|
|
2021-05-25 13:05:45 +08:00
|
|
|
QScopedPointer<PowerStatusWidget> m_powerStatusWidget;
|
|
|
|
QScopedPointer<Dock::TipsWidget> m_tipsLabel;
|
2016-07-13 15:31:07 +08:00
|
|
|
|
2019-05-13 16:15:37 +08:00
|
|
|
SystemPowerInter *m_systemPowerInter;
|
2016-07-08 09:39:47 +08:00
|
|
|
DBusPower *m_powerInter;
|
2023-02-21 15:57:42 +08:00
|
|
|
Dtk::Core::DConfig *m_dconfig; // 配置
|
2020-06-11 10:54:56 +08:00
|
|
|
QTimer *m_preChargeTimer;
|
2023-01-30 13:14:32 +08:00
|
|
|
QWidget *m_quickPanel;
|
|
|
|
QLabel *m_imageLabel;
|
|
|
|
QLabel *m_labelText;
|
2016-06-24 14:59:56 +08:00
|
|
|
};
|
|
|
|
|
2018-11-13 20:07:52 +08:00
|
|
|
#endif // POWERPLUGIN_H
|