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
|
2018-10-28 15:50:20 +08:00
|
|
|
|
|
|
|
|
|
#ifndef SHUTDOWNPLUGIN_H
|
|
|
|
|
#define SHUTDOWNPLUGIN_H
|
|
|
|
|
|
|
|
|
|
#include "pluginsiteminterface.h"
|
2020-03-13 12:59:02 +08:00
|
|
|
|
#include "shutdownwidget.h"
|
2018-10-28 15:50:20 +08:00
|
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
2021-12-31 14:54:12 +08:00
|
|
|
|
class DBusPowerManager;
|
|
|
|
|
|
2020-06-29 15:35:51 +08:00
|
|
|
|
namespace Dock {
|
|
|
|
|
class TipsWidget;
|
|
|
|
|
}
|
2021-02-27 15:50:24 +08:00
|
|
|
|
class QGSettings;
|
2018-10-28 15:50:20 +08:00
|
|
|
|
class ShutdownPlugin : public QObject, PluginsItemInterface
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_INTERFACES(PluginsItemInterface)
|
|
|
|
|
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "shutdown.json")
|
|
|
|
|
|
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
|
explicit ShutdownPlugin(QObject *parent = nullptr);
|
2018-10-28 15:50:20 +08:00
|
|
|
|
|
|
|
|
|
const QString pluginName() const override;
|
|
|
|
|
const QString pluginDisplayName() const override;
|
|
|
|
|
void init(PluginProxyInterface *proxyInter) override;
|
|
|
|
|
|
|
|
|
|
void pluginStateSwitched() override;
|
|
|
|
|
bool pluginIsAllowDisable() override { return true; }
|
|
|
|
|
bool pluginIsDisable() override;
|
|
|
|
|
|
|
|
|
|
QWidget *itemWidget(const QString &itemKey) override;
|
|
|
|
|
QWidget *itemTipsWidget(const QString &itemKey) override;
|
|
|
|
|
const QString itemCommand(const QString &itemKey) override;
|
|
|
|
|
const QString itemContextMenu(const QString &itemKey) override;
|
|
|
|
|
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
|
|
|
|
void displayModeChanged(const Dock::DisplayMode displayMode) override;
|
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
|
int itemSortKey(const QString &itemKey) override;
|
|
|
|
|
void setSortKey(const QString &itemKey, const int order) override;
|
2018-10-28 15:50:20 +08:00
|
|
|
|
|
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;
|
2019-01-30 18:00:46 +08:00
|
|
|
|
|
2019-12-03 13:27:04 +08:00
|
|
|
|
// 休眠待机配置,保持和sessionshell一致
|
|
|
|
|
const QStringList session_ui_configs {
|
|
|
|
|
"/etc/lightdm/lightdm-deepin-greeter.conf",
|
|
|
|
|
"/etc/deepin/dde-session-ui.conf",
|
|
|
|
|
"/usr/share/dde-session-ui/dde-session-ui.conf"
|
|
|
|
|
};
|
|
|
|
|
template <typename T>
|
|
|
|
|
T findValueByQSettings(const QStringList &configFiles,
|
|
|
|
|
const QString &group,
|
|
|
|
|
const QString &key,
|
|
|
|
|
const QVariant &failback)
|
|
|
|
|
{
|
|
|
|
|
for (const QString &path : configFiles) {
|
|
|
|
|
QSettings settings(path, QSettings::IniFormat);
|
|
|
|
|
if (!group.isEmpty()) {
|
|
|
|
|
settings.beginGroup(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVariant& v = settings.value(key);
|
|
|
|
|
if (v.isValid()) {
|
|
|
|
|
T t = v.value<T>();
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return failback.value<T>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
T valueByQSettings(const QString & group,
|
|
|
|
|
const QString & key,
|
|
|
|
|
const QVariant &failback) {
|
|
|
|
|
return findValueByQSettings<T>(session_ui_configs,
|
|
|
|
|
group,
|
|
|
|
|
key,
|
|
|
|
|
failback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<bool, qint64> checkIsPartitionType(const QStringList &list);
|
|
|
|
|
qint64 get_power_image_size();
|
|
|
|
|
|
2018-10-28 15:50:20 +08:00
|
|
|
|
private:
|
|
|
|
|
void loadPlugin();
|
2019-01-15 09:54:45 +08:00
|
|
|
|
bool checkSwap();
|
2018-10-28 15:50:20 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool m_pluginLoaded;
|
|
|
|
|
|
2021-05-25 13:05:45 +08:00
|
|
|
|
QScopedPointer<ShutdownWidget> m_shutdownWidget;
|
|
|
|
|
QScopedPointer<Dock::TipsWidget> m_tipsLabel;
|
2020-10-30 15:25:37 +08:00
|
|
|
|
DBusPowerManager* m_powerManagerInter;
|
2021-03-20 12:10:45 +08:00
|
|
|
|
const QGSettings *m_gsettings;
|
2021-08-17 13:17:40 +08:00
|
|
|
|
const QGSettings *m_sessionShellGsettings;
|
2018-10-28 15:50:20 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SHUTDOWNPLUGIN_H
|