mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: 新增飞行模式
笔记本上,新增飞行模式,显示在任务栏托盘 Log: 新增飞行模式 Task: https://pms.uniontech.com/zentao/task-view-89206.html Influence: 任务栏托盘中飞行模式功能 Change-Id: I81e78491285bcfa2c0f601174e8aa32c837f92a7
This commit is contained in:
parent
836bb57d1c
commit
f6f048eda1
@ -367,6 +367,22 @@
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/airplane-mode/" id="com.deepin.dde.dock.module.airplane-mode" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
<summary>Blocking event</summary>
|
||||
<description>
|
||||
Blocking mouse events
|
||||
</description>
|
||||
</key>
|
||||
<key type="b" name="enable">
|
||||
<default>false</default>
|
||||
<summary>Module Enable</summary>
|
||||
<description>
|
||||
Control Module Enable
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/module/tray/" id="com.deepin.dde.dock.module.tray" gettext-domain="DDE">
|
||||
<key type="b" name="control">
|
||||
<default>false</default>
|
||||
@ -519,7 +535,7 @@
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
<schema path="/com/deepin/dde/dock/touch/" id="com.deepin.dde.dock.touch" gettext-domain="DDE">
|
||||
<schema path="/com/deepin/dde/dock/touch/" id="com.deepin.dde.dock.touch" gettext-domain="DDE">
|
||||
<key type="i" name="resize-height">
|
||||
<default>7</default>
|
||||
<summary>Controling the drag height of touch screen</summary>
|
||||
|
@ -35,6 +35,7 @@ namespace Dock {
|
||||
#define PLUGIN_BACKGROUND_MIN_SIZE 20
|
||||
|
||||
#define PLUGIN_ICON_MAX_SIZE 20
|
||||
#define PLUGIN_ITEM_WIDTH 300
|
||||
|
||||
// 需求变更成插件图标始终保持20x20,但16x16的资源还在。所以暂时保留此宏
|
||||
#define PLUGIN_ICON_MIN_SIZE 20
|
||||
|
@ -12,3 +12,4 @@ add_subdirectory("show-desktop")
|
||||
add_subdirectory("multitasking")
|
||||
add_subdirectory("bluetooth")
|
||||
add_subdirectory("dcc-dock-plugin")
|
||||
add_subdirectory("airplane-mode")
|
||||
|
38
plugins/airplane-mode/CMakeLists.txt
Normal file
38
plugins/airplane-mode/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
set(PLUGIN_NAME "airplane-mode")
|
||||
|
||||
project(${PLUGIN_NAME})
|
||||
|
||||
# Sources files
|
||||
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp" "../../frame/util/imageutil.h" "../../frame/util/imageutil.cpp")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5Svg REQUIRED)
|
||||
find_package(Qt5DBus REQUIRED)
|
||||
find_package(DtkWidget REQUIRED)
|
||||
|
||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
|
||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||
add_library(${PLUGIN_NAME} SHARED ${SRCS} resources/airplane_mode.qrc)
|
||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../system-trays)
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
../../interfaces
|
||||
../../widgets
|
||||
../../frame
|
||||
../../frame/util
|
||||
)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||
${DtkWidget_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${Qt5Widgets_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)
|
4
plugins/airplane-mode/airplanemode.json
Normal file
4
plugins/airplane-mode/airplanemode.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"api": "1.1.1",
|
||||
"depends-daemon-dbus-service": ""
|
||||
}
|
59
plugins/airplane-mode/airplanemodeapplet.cpp
Normal file
59
plugins/airplane-mode/airplanemodeapplet.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "airplanemodeapplet.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <DSwitchButton>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
AirplaneModeApplet::AirplaneModeApplet(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_switchBtn(new DSwitchButton(this))
|
||||
{
|
||||
setMinimumWidth(PLUGIN_ITEM_WIDTH);
|
||||
setFixedHeight(30);
|
||||
QLabel *title = new QLabel(this);
|
||||
title->setText(tr("Airplane Mode"));
|
||||
QHBoxLayout *appletlayout = new QHBoxLayout;
|
||||
appletlayout->setMargin(0);
|
||||
appletlayout->setSpacing(0);
|
||||
appletlayout->addSpacing(0);
|
||||
appletlayout->addWidget(title);
|
||||
appletlayout->addStretch();
|
||||
appletlayout->addWidget(m_switchBtn);
|
||||
appletlayout->addSpacing(0);
|
||||
setLayout(appletlayout);
|
||||
|
||||
connect(m_switchBtn, &DSwitchButton::checkedChanged, this, &AirplaneModeApplet::enableChanged);
|
||||
}
|
||||
|
||||
void AirplaneModeApplet::setEnabled(bool enable)
|
||||
{
|
||||
m_switchBtn->blockSignals(true);
|
||||
m_switchBtn->setChecked(enable);
|
||||
m_switchBtn->blockSignals(false);
|
||||
}
|
50
plugins/airplane-mode/airplanemodeapplet.h
Normal file
50
plugins/airplane-mode/airplanemodeapplet.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef AIRPLANEMODEAPPLET_H
|
||||
#define AIRPLANEMODEAPPLET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Dtk {
|
||||
namespace Widget {
|
||||
class DSwitchButton;
|
||||
}
|
||||
}
|
||||
|
||||
class QLabel;
|
||||
class AirplaneModeApplet : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AirplaneModeApplet(QWidget *parent = nullptr);
|
||||
void setEnabled(bool enable);
|
||||
|
||||
signals:
|
||||
void enableChanged(bool enable);
|
||||
|
||||
private:
|
||||
Dtk::Widget::DSwitchButton *m_switchBtn;
|
||||
};
|
||||
|
||||
#endif // AIRPLANEMODEAPPLET_H
|
165
plugins/airplane-mode/airplanemodeitem.cpp
Normal file
165
plugins/airplane-mode/airplanemodeitem.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "airplanemodeitem.h"
|
||||
#include "constants.h"
|
||||
#include "tipswidget.h"
|
||||
#include "imageutil.h"
|
||||
#include "utils.h"
|
||||
#include "airplanemodeapplet.h"
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
#include <DDBusSender>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QJsonDocument>
|
||||
#include <QDBusConnection>
|
||||
|
||||
DGUI_USE_NAMESPACE
|
||||
|
||||
#define SHIFT "shift"
|
||||
#define SETTINGS "settings"
|
||||
|
||||
AirplaneModeItem::AirplaneModeItem(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_tipsLabel(new Dock::TipsWidget(this))
|
||||
, m_applet(new AirplaneModeApplet(this))
|
||||
, m_airplaneModeInter(new DBusAirplaneMode("com.deepin.daemon.AirplaneMode",
|
||||
"/com/deepin/daemon/AirplaneMode",
|
||||
QDBusConnection::systemBus(),
|
||||
this))
|
||||
{
|
||||
m_tipsLabel->setText(tr("Airplane mode enabled"));
|
||||
m_tipsLabel->setVisible(false);
|
||||
m_applet->setVisible(false);
|
||||
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &AirplaneModeItem::refreshIcon);
|
||||
connect(m_applet, &AirplaneModeApplet::enableChanged, m_airplaneModeInter, &DBusAirplaneMode::Enable);
|
||||
connect(m_airplaneModeInter, &DBusAirplaneMode::EnabledChanged, this, [this](bool enable) {
|
||||
m_applet->setEnabled(enable);
|
||||
refreshIcon();
|
||||
|
||||
Utils::SettingSaveValue("com.deepin.dde.dock.module.airplane-mode", QByteArray(), "enable", enable);
|
||||
});
|
||||
|
||||
m_applet->setEnabled(m_airplaneModeInter->enabled());
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
QWidget *AirplaneModeItem::tipsWidget()
|
||||
{
|
||||
return m_tipsLabel;
|
||||
}
|
||||
|
||||
QWidget *AirplaneModeItem::popupApplet()
|
||||
{
|
||||
return m_applet;
|
||||
}
|
||||
|
||||
const QString AirplaneModeItem::contextMenu() const
|
||||
{
|
||||
QList<QVariant> items;
|
||||
items.reserve(2);
|
||||
|
||||
QMap<QString, QVariant> shift;
|
||||
shift["itemId"] = SHIFT;
|
||||
if (m_airplaneModeInter->enabled())
|
||||
shift["itemText"] = tr("Turn off");
|
||||
else
|
||||
shift["itemText"] = tr("Turn on");
|
||||
shift["isActive"] = true;
|
||||
items.push_back(shift);
|
||||
|
||||
QMap<QString, QVariant> settings;
|
||||
settings["itemId"] = SETTINGS;
|
||||
settings["itemText"] = tr("Airplane Mode settings");
|
||||
settings["isActive"] = true;
|
||||
items.push_back(settings);
|
||||
|
||||
QMap<QString, QVariant> menu;
|
||||
menu["items"] = items;
|
||||
menu["checkableMenu"] = false;
|
||||
menu["singleCheck"] = false;
|
||||
|
||||
return QJsonDocument::fromVariant(menu).toJson();
|
||||
}
|
||||
|
||||
void AirplaneModeItem::invokeMenuItem(const QString menuId, const bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
|
||||
/* 控制中心暂未实现
|
||||
if (menuId == SHIFT)
|
||||
m_airplaneModeInter->Enable(!m_airplaneModeInter->enabled());
|
||||
else if (menuId == SETTINGS)
|
||||
DDBusSender()
|
||||
.service("com.deepin.dde.ControlCenter")
|
||||
.interface("com.deepin.dde.ControlCenter")
|
||||
.path("/com/deepin/dde/ControlCenter")
|
||||
.method(QString("ShowPage"))
|
||||
.arg(QString("network"))
|
||||
.arg(QString("Airplane Mode"))
|
||||
.call();
|
||||
*/
|
||||
}
|
||||
|
||||
void AirplaneModeItem::refreshIcon()
|
||||
{
|
||||
QString iconString;
|
||||
if (m_airplaneModeInter->enabled())
|
||||
iconString = "airplane-on";
|
||||
else
|
||||
iconString = "airplane-off";
|
||||
|
||||
const auto ratio = devicePixelRatioF();
|
||||
int iconSize = PLUGIN_ICON_MAX_SIZE;
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
|
||||
iconString.append(PLUGIN_MIN_ICON_NAME);
|
||||
m_iconPixmap = ImageUtil::loadSvg(iconString, ":/", iconSize, ratio);
|
||||
update();
|
||||
}
|
||||
|
||||
void AirplaneModeItem::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
|
||||
const Dock::Position position = qApp->property(PROP_POSITION).value<Dock::Position>();
|
||||
if (position == Dock::Bottom || position == Dock::Top) {
|
||||
setMaximumWidth(height());
|
||||
setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
} else {
|
||||
setMaximumHeight(width());
|
||||
setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
}
|
||||
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void AirplaneModeItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
|
||||
QPainter painter(this);
|
||||
const QRectF &rf = QRectF(rect());
|
||||
const QRectF &rfp = QRectF(m_iconPixmap.rect());
|
||||
painter.drawPixmap(rf.center() - rfp.center() / m_iconPixmap.devicePixelRatioF(), m_iconPixmap);
|
||||
}
|
61
plugins/airplane-mode/airplanemodeitem.h
Normal file
61
plugins/airplane-mode/airplanemodeitem.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef AIRPLANEMODEITEM_H
|
||||
#define AIRPLANEMODEITEM_H
|
||||
|
||||
#include <com_deepin_daemon_airplanemode.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
using DBusAirplaneMode = com::deepin::daemon::AirplaneMode;
|
||||
|
||||
namespace Dock {
|
||||
class TipsWidget;
|
||||
}
|
||||
|
||||
class AirplaneModeApplet;
|
||||
class AirplaneModeItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AirplaneModeItem(QWidget *parent = nullptr);
|
||||
|
||||
QWidget *tipsWidget();
|
||||
QWidget *popupApplet();
|
||||
const QString contextMenu() const;
|
||||
void invokeMenuItem(const QString menuId, const bool checked);
|
||||
void refreshIcon();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private:
|
||||
Dock::TipsWidget *m_tipsLabel;
|
||||
AirplaneModeApplet *m_applet;
|
||||
DBusAirplaneMode *m_airplaneModeInter;
|
||||
QPixmap m_iconPixmap;
|
||||
};
|
||||
|
||||
#endif // AIRPLANEMODEITEM_H
|
131
plugins/airplane-mode/airplanemodeplugin.cpp
Normal file
131
plugins/airplane-mode/airplanemodeplugin.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "airplanemodeplugin.h"
|
||||
#include "airplanemodeitem.h"
|
||||
|
||||
#define AIRPLANEMODE_KEY "airplane-mode-key"
|
||||
#define STATE_KEY "enable"
|
||||
|
||||
AirplaneModePlugin::AirplaneModePlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_item(new AirplaneModeItem)
|
||||
{
|
||||
}
|
||||
|
||||
const QString AirplaneModePlugin::pluginName() const
|
||||
{
|
||||
return "airplane-mode";
|
||||
}
|
||||
|
||||
const QString AirplaneModePlugin::pluginDisplayName() const
|
||||
{
|
||||
return tr("Airplane Mode");
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::init(PluginProxyInterface *proxyInter)
|
||||
{
|
||||
m_proxyInter = proxyInter;
|
||||
|
||||
if (!pluginIsDisable())
|
||||
m_proxyInter->itemAdded(this, AIRPLANEMODE_KEY);
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::pluginStateSwitched()
|
||||
{
|
||||
m_proxyInter->saveValue(this, STATE_KEY, pluginIsDisable());
|
||||
}
|
||||
|
||||
bool AirplaneModePlugin::pluginIsDisable()
|
||||
{
|
||||
return !m_proxyInter->getValue(this, STATE_KEY, true).toBool();
|
||||
}
|
||||
|
||||
QWidget *AirplaneModePlugin::itemWidget(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
return m_item;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *AirplaneModePlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
return m_item->tipsWidget();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *AirplaneModePlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
return nullptr; // 禁用左键点击功能
|
||||
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
return m_item->popupApplet();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QString AirplaneModePlugin::itemContextMenu(const QString &itemKey)
|
||||
{
|
||||
return QString(); // 禁用右键菜单
|
||||
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
return m_item->contextMenu();
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked)
|
||||
{
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
m_item->invokeMenuItem(menuId, checked);
|
||||
}
|
||||
}
|
||||
|
||||
int AirplaneModePlugin::itemSortKey(const QString &itemKey)
|
||||
{
|
||||
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
|
||||
|
||||
return m_proxyInter->getValue(this, key, 4).toInt();
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::setSortKey(const QString &itemKey, const int order)
|
||||
{
|
||||
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
|
||||
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void AirplaneModePlugin::refreshIcon(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == AIRPLANEMODE_KEY) {
|
||||
m_item->refreshIcon();
|
||||
}
|
||||
}
|
||||
|
||||
|
57
plugins/airplane-mode/airplanemodeplugin.h
Normal file
57
plugins/airplane-mode/airplanemodeplugin.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ~ 2022 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
* Maintainer: weizhixiang <weizhixiang@uniontech.com>
|
||||
*
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef AIRPLANEMODEPLUGIN_H
|
||||
#define AIRPLANEMODEPLUGIN_H
|
||||
|
||||
#include "pluginsiteminterface.h"
|
||||
|
||||
class AirplaneModeItem;
|
||||
class AirplaneModePlugin : public QObject, PluginsItemInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginsItemInterface)
|
||||
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "airplanemode.json")
|
||||
|
||||
public:
|
||||
explicit AirplaneModePlugin(QObject *parent = nullptr);
|
||||
|
||||
const QString pluginName() const Q_DECL_OVERRIDE;
|
||||
const QString pluginDisplayName() const Q_DECL_OVERRIDE;
|
||||
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
|
||||
void pluginStateSwitched() Q_DECL_OVERRIDE;
|
||||
bool pluginIsAllowDisable() Q_DECL_OVERRIDE { return true; }
|
||||
bool pluginIsDisable() Q_DECL_OVERRIDE;
|
||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
const QString itemContextMenu(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) Q_DECL_OVERRIDE;
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
AirplaneModeItem *m_item;
|
||||
};
|
||||
|
||||
#endif // AIRPLANEMODEPLUGIN_H
|
3
plugins/airplane-mode/resources/airplane-off-dark.svg
Normal file
3
plugins/airplane-mode/resources/airplane-off-dark.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||
<path fill-opacity=".3" fill-rule="evenodd" d="M6.77032574,17.5 C6.71509727,17.5 6.67032574,17.4552285 6.67032574,17.4 C6.67032574,17.3708075 6.68308201,17.3430726 6.7052466,17.3240743 L8.5,15.786 L8.5,10.792 L3,14 L3,12.5 L8.5,7.5 L8.5,3 C8.5,2.17157288 9.17157288,1.5 10,1.5 C10.8284271,1.5 11.5,2.17157288 11.5,3 L11.5,7.5 L17,12.5 L17,14 L11.5,10.792 L11.5,15.786 L13.2947534,17.3240743 C13.336686,17.3600166 13.3415421,17.4231466 13.3055999,17.4650791 C13.2866017,17.4872437 13.2588667,17.5 13.2296743,17.5 L10,17.5 L10,17.5 L6.77032574,17.5 Z" transform="rotate(90 10 9.5)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 675 B |
10
plugins/airplane-mode/resources/airplane-off.svg
Normal file
10
plugins/airplane-mode/resources/airplane-off.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>4</title>
|
||||
<g id="4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group-25">
|
||||
<polygon id="Fill-100" opacity="0" points="0 20 20 20 20 0 0 0"></polygon>
|
||||
<path d="M6.77032574,17.5 C6.71509727,17.5 6.67032574,17.4552285 6.67032574,17.4 C6.67032574,17.3708075 6.68308201,17.3430726 6.7052466,17.3240743 L8.5,15.786 L8.5,10.792 L3,14 L3,12.5 L8.5,7.5 L8.5,3 C8.5,2.17157288 9.17157288,1.5 10,1.5 C10.8284271,1.5 11.5,2.17157288 11.5,3 L11.5,7.5 L17,12.5 L17,14 L11.5,10.792 L11.5,15.786 L13.2947534,17.3240743 C13.336686,17.3600166 13.3415421,17.4231466 13.3055999,17.4650791 C13.2866017,17.4872437 13.2588667,17.5 13.2296743,17.5 L6.77032574,17.5 Z" id="形状结合" fill="#FFFFFF" opacity="0.3" transform="translate(10.000000, 9.500000) rotate(-270.000000) translate(-10.000000, -9.500000) "></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
3
plugins/airplane-mode/resources/airplane-on-dark.svg
Normal file
3
plugins/airplane-mode/resources/airplane-on-dark.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M6.77032574,17.5 C6.71509727,17.5 6.67032574,17.4552285 6.67032574,17.4 C6.67032574,17.3708075 6.68308201,17.3430726 6.7052466,17.3240743 L8.5,15.786 L8.5,10.792 L3,14 L3,12.5 L8.5,7.5 L8.5,3 C8.5,2.17157288 9.17157288,1.5 10,1.5 C10.8284271,1.5 11.5,2.17157288 11.5,3 L11.5,7.5 L17,12.5 L17,14 L11.5,10.792 L11.5,15.786 L13.2947534,17.3240743 C13.336686,17.3600166 13.3415421,17.4231466 13.3055999,17.4650791 C13.2866017,17.4872437 13.2588667,17.5 13.2296743,17.5 L10,17.5 L10,17.5 L6.77032574,17.5 Z" transform="rotate(90 10 9.5)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 657 B |
10
plugins/airplane-mode/resources/airplane-on.svg
Normal file
10
plugins/airplane-mode/resources/airplane-on.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>3</title>
|
||||
<g id="3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group-26">
|
||||
<polygon id="Fill-40" opacity="0" points="0 20 20 20 20 0 0 0"></polygon>
|
||||
<path d="M6.77032574,17.5 C6.71509727,17.5 6.67032574,17.4552285 6.67032574,17.4 C6.67032574,17.3708075 6.68308201,17.3430726 6.7052466,17.3240743 L8.5,15.786 L8.5,10.792 L3,14 L3,12.5 L8.5,7.5 L8.5,3 C8.5,2.17157288 9.17157288,1.5 10,1.5 C10.8284271,1.5 11.5,2.17157288 11.5,3 L11.5,7.5 L17,12.5 L17,14 L11.5,10.792 L11.5,15.786 L13.2947534,17.3240743 C13.336686,17.3600166 13.3415421,17.4231466 13.3055999,17.4650791 C13.2866017,17.4872437 13.2588667,17.5 13.2296743,17.5 L6.77032574,17.5 Z" id="形状结合" fill="#FFFFFF" transform="translate(10.000000, 9.500000) rotate(-270.000000) translate(-10.000000, -9.500000) "></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.0 KiB |
8
plugins/airplane-mode/resources/airplane_mode.qrc
Normal file
8
plugins/airplane-mode/resources/airplane_mode.qrc
Normal file
@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>airplane-on.svg</file>
|
||||
<file>airplane-off.svg</file>
|
||||
<file>airplane-off-dark.svg</file>
|
||||
<file>airplane-on-dark.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
Loading…
x
Reference in New Issue
Block a user