feat(shortcut): 修改shortcut插件接口,接口版本号和安装位置,统一翻译文件加载

This commit is contained in:
hewenfei 2023-12-29 14:47:28 +08:00
parent 0aef652af3
commit 4fe8700026
59 changed files with 559 additions and 198 deletions

View File

@ -14,6 +14,7 @@ include_directories(interface)
set(SOURCE_FILES
short-cut-manager.cpp
interface/status-info.cpp
interface/ukui-shortcut-plugin.cpp
)
set(LIBRARY_HEADERS
@ -21,6 +22,7 @@ set(LIBRARY_HEADERS
interface/value-type.h
interface/plugin-common-data.h
interface/ukui-shortcut_global.h
interface/ukui-shortcut.h
interface/ukui-shortcut-plugin.h
interface/status-info.h
)

View File

@ -2,5 +2,8 @@
set(PLUGIN_INSTALL_DIRS "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-shortcut-plugins")
add_compile_definitions(PLUGIN_INSTALL_DIRS="${PLUGIN_INSTALL_DIRS}")
#
set(SHORTCUT_DATA_INSTALL_DIR "/usr/share/ukui-sidebar/ukui-shortcut/shortcuts")
set(SHORTCUT_DATA_INSTALL_DIR "/usr/share/ukui-sidebar/shortcuts")
add_compile_definitions(SHORTCUT_DATA_INSTALL_DIR="${SHORTCUT_DATA_INSTALL_DIR}")
#
set(SHORTCUT_TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/translations")
add_compile_definitions(SHORTCUT_TRANSLATION_FILE_DIR="${SHORTCUT_TRANSLATION_FILE_DIR}")

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2022, KylinSoft Co., Ltd.
*
* 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
* (at your option) 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
* hxf <hewenfei@kylinos.cn>
*
*/
#include "ukui-shortcut-plugin.h"
namespace UkuiShortcut {
UkuiShortcutPlugin::UkuiShortcutPlugin(QObject *parent) : QObject(parent)
{
}
UkuiShortcutPlugin::~UkuiShortcutPlugin()
{
}
} // Shortcut

View File

@ -18,43 +18,52 @@
* hxf <hewenfei@kylinos.cn>
*
*/
#ifndef UKUISHORTCUTPLUGIN_H
#define UKUISHORTCUTPLUGIN_H
#define UKUI_SHORTCUT_PLUGIN_IFACE_IID "org.ukui.shortcut.UkuiShortcutPluginIface"
#define UKUI_SHORTCUT_PLUGIN_IFACE_VERSION "1.0.0"
#include <QtPlugin>
#include <QObject>
#include <QMap>
#include "ukui-shortcut_global.h"
#include "plugin-common-data.h"
#include "status-info.h"
#ifndef UKUI_SIDEBAR_UKUI_SHORTCUT_PLUGIN_H
#define UKUI_SIDEBAR_UKUI_SHORTCUT_PLUGIN_H
#define UKUI_SHORTCUT_PLUGIN_IFACE_IID "org.ukui.shortcut.UkuiShortcutPluginIface"
#define UKUI_SHORTCUT_PLUGIN_IFACE_TYPE "UKUI_SHORT_CUT"
#define UKUI_SHORTCUT_PLUGIN_IFACE_VERSION "1.0.1"
#include <QtPlugin>
#include <QStringList>
#include "ukui-shortcut.h"
namespace UkuiShortcut {
class UKUISHORTCUT_EXPORT Shortcut : public QObject
class UkuiShortcutPlugin : public QObject
{
Q_OBJECT
public:
explicit Shortcut(QObject *parent = nullptr) : QObject(parent) {}
//插件标识
virtual QString pluginId() = 0;
//插件类型(样式), 需要指定不同模式下的按钮
virtual QMap<PluginMetaType::SystemMode, PluginMetaData> pluginMetaData() = 0;
//实现响应前端用户操作
virtual void active(PluginMetaType::Action action) = 0;
//进度条样式需要从写该函数
virtual void setValue(int value) {Q_UNUSED(value)}
//返回插件当前的状态信息
virtual const StatusInfo currentStatus() = 0;
//是否启用
virtual bool isEnable() { return true; }
explicit UkuiShortcutPlugin(QObject *parent = nullptr);
~UkuiShortcutPlugin() override;
Q_SIGNALS:
void statusChanged(const StatusInfo &info);
void enableStatusChanged(bool isEnable);
/**
* id名称
* @return id
*/
virtual QString pluginId() = 0;
/**
*
* eg: auto-rotation-shortcut_zh_CN.qm "auto-rotation-shortcut"
*
*
* @return
*/
virtual QStringList translations() = 0;
/**
*
* @return Shortcut*
*/
virtual Shortcut *createShortcut() = 0;
};
}
Q_DECLARE_INTERFACE(UkuiShortcut::Shortcut, UKUI_SHORTCUT_PLUGIN_IFACE_IID)
#endif // UKUISHORTCUTPLUGIN_H
} // Shortcut
Q_DECLARE_INTERFACE(UkuiShortcut::UkuiShortcutPlugin, UKUI_SHORTCUT_PLUGIN_IFACE_IID)
#endif //UKUI_SIDEBAR_UKUI_SHORTCUT_PLUGIN_H

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2022, KylinSoft Co., Ltd.
*
* 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
* (at your option) 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 <https://www.gnu.org/licenses/>.
*
* Authors: iaom <zhangpengfei@kylinos.cn>
* hxf <hewenfei@kylinos.cn>
*
*/
#ifndef UKUISHORTCUTPLUGIN_H
#define UKUISHORTCUTPLUGIN_H
#include <QObject>
#include <QMap>
#include "ukui-shortcut_global.h"
#include "plugin-common-data.h"
#include "status-info.h"
namespace UkuiShortcut {
class UKUISHORTCUT_EXPORT Shortcut : public QObject
{
Q_OBJECT
public:
explicit Shortcut(QObject *parent = nullptr) : QObject(parent) {}
//插件标识
virtual QString pluginId() = 0;
//插件类型(样式), 需要指定不同模式下的按钮
virtual QMap<PluginMetaType::SystemMode, PluginMetaData> pluginMetaData() = 0;
//实现响应前端用户操作
virtual void active(PluginMetaType::Action action) = 0;
//进度条样式需要从写该函数
virtual void setValue(int value) {Q_UNUSED(value)}
//返回插件当前的状态信息
virtual const StatusInfo currentStatus() = 0;
//是否启用
virtual bool isEnable() { return true; }
Q_SIGNALS:
void statusChanged(const StatusInfo &info);
void enableStatusChanged(bool isEnable);
};
}
Q_DECLARE_INTERFACE(UkuiShortcut::Shortcut, UKUI_SHORTCUT_PLUGIN_IFACE_IID)
#endif // UKUISHORTCUTPLUGIN_H

View File

@ -22,6 +22,8 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QPluginLoader>
#include <QTranslator>
#include <QCoreApplication>
#include <QDebug>
using namespace UkuiShortcut;
@ -38,20 +40,24 @@ public:
void UkuiShortcut::ShortcutManagerPrivate::findShortcuts()
{
const QString pluginType(UKUI_SHORTCUT_PLUGIN_IFACE_TYPE);
const QString translationsDir(SHORTCUT_TRANSLATION_FILE_DIR);
// 宏 "PLUGIN_INSTALL_DIRS" 定义在 libukui-shortcut.pro 中
QDir pluginsDir(PLUGIN_INSTALL_DIRS);
pluginsDir.setFilter(QDir::Files);
for(const QString& fileName : pluginsDir.entryList(QDir::Files)) {
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
QJsonObject metaData = pluginLoader.metaData().value("MetaData").toObject();
QString type =metaData.value("Type").toString();
QString type = metaData.value("Type").toString();
QString version = metaData.value("Version").toString();
if(type == "UKUI_SHORT_CUT") {
if(version != UKUI_SHORTCUT_PLUGIN_IFACE_VERSION) {
qWarning() << "UKUI_SHORT_CUT version check failed:" << fileName << "version:" << version << "iface version : " << UKUI_SHORTCUT_PLUGIN_IFACE_VERSION;
continue;
}
} else {
if (type != pluginType) {
continue;
}
if (version != UKUI_SHORTCUT_PLUGIN_IFACE_VERSION) {
qWarning() << "UKUI_SHORT_CUT version check failed:" << fileName << "version:" << version
<< "iface version : " << UKUI_SHORTCUT_PLUGIN_IFACE_VERSION;
continue;
}
@ -59,11 +65,30 @@ void UkuiShortcut::ShortcutManagerPrivate::findShortcuts()
if (!obj) {
continue;
}
Shortcut *plugin = qobject_cast<Shortcut*>(obj);
UkuiShortcutPlugin *plugin = qobject_cast<UkuiShortcutPlugin *>(obj);
if (!plugin) {
obj->deleteLater();
continue;
}
m_allShortcuts.push_back(plugin);
// 加载翻译
for (const auto &trName : plugin->translations()) {
auto translator = new QTranslator(QCoreApplication::instance());
if (translator->load(QLocale(), trName, QStringLiteral("_"), translationsDir)) {
// 加载翻译成功
QCoreApplication::installTranslator(translator);
} else {
delete translator;
}
}
Shortcut *shortcut = plugin->createShortcut();
if (shortcut) {
m_allShortcuts.append(shortcut);
}
plugin->deleteLater();
}
}

View File

@ -21,7 +21,7 @@ file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp")
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}" "*.ts")
qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
#

View File

@ -20,7 +20,6 @@
#include <QDBusReply>
#include <QDebug>
#include <QTranslator>
#include <QApplication>
static const QString SERVICE = QStringLiteral("com.kylin.statusmanager.interface");
@ -36,22 +35,15 @@ static const QString IS_SUPPORTED_AUTOROTATION = QStringLiteral("is_supported_au
static const QString AUTO_ROTATION_ICON = QStringLiteral("ukui-automatic-rotation-symbolic");
using namespace UkuiShortcut;
AutoRotationShortcut::AutoRotationShortcut()
AutoRotationShortcut::AutoRotationShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/auto-rotation-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "AutoRotationShortcut load translations file" << QLocale::system().name() << "failed!";
}
//set initial status info
m_currentStatusInfo.setColor(Color::ColorRole::BaseColor);
m_currentStatusInfo.setName(tr("Auto Rotation"));
m_currentStatusInfo.setToolTip(tr("Auto Rotation"));
m_currentStatusInfo.setIcon(AUTO_ROTATION_ICON);
PluginMetaData pc {false};
PluginMetaData pc {true, 1, PluginMetaType::PluginType::Icon};
PluginMetaData tablet {true, 1, PluginMetaType::PluginType::Icon};
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
@ -65,7 +57,7 @@ AutoRotationShortcut::AutoRotationShortcut()
QDBusReply<bool> rotationEnable = m_statusManagerIface->call(IS_SUPPORTED_AUTOROTATION);
if (rotationEnable.isValid()) {
if (rotationEnable.value() == false) {
if (rotationEnable.value()) {
m_isEnable = false;
return;
}
@ -143,3 +135,19 @@ QMap<PluginMetaType::SystemMode, PluginMetaData> AutoRotationShortcut::pluginMet
{
return m_metaData;
}
// == plugin == //
QStringList AutoRotationShortcutPlugin::translations()
{
return {QStringLiteral("auto-rotation-shortcut")};
}
Shortcut *AutoRotationShortcutPlugin::createShortcut()
{
return new AutoRotationShortcut;
}
AutoRotationShortcutPlugin::AutoRotationShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}

View File

@ -23,14 +23,26 @@
#include <QDBusInterface>
namespace UkuiShortcut {
class AutoRotationShortcut : public Shortcut
class AutoRotationShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "auto-rotation-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
AutoRotationShortcut();
~AutoRotationShortcut();
explicit AutoRotationShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("AutoRotationShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class AutoRotationShortcut : public Shortcut
{
Q_OBJECT
public:
explicit AutoRotationShortcut(QObject *parent = nullptr);
~AutoRotationShortcut() override;
QString pluginId() override {return QStringLiteral("AutoRotationShortcut");}
QMap<PluginMetaType::SystemMode, PluginMetaData> pluginMetaData() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -30,13 +30,6 @@
using namespace UkuiShortcut;
BluetoothShortcut::BluetoothShortcut()
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/bluetooth-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "BluetoothShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_statusInfo.setIcon(BLUETOOTH_ACTIVE_SYMBOLIC);
m_statusInfo.setColor(Color::Danger);
m_statusInfo.setName(tr("Bluetooth"));
@ -260,3 +253,18 @@ void BluetoothShortcut::updateState()
}
Q_EMIT enableStatusChanged(m_isEnable);
}
BluetoothShortcutPlugin::BluetoothShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList BluetoothShortcutPlugin::translations()
{
return {QStringLiteral("bluetooth-shortcut")};
}
Shortcut *BluetoothShortcutPlugin::createShortcut()
{
return new BluetoothShortcut;
}

View File

@ -24,12 +24,23 @@
#include <QMutex>
namespace UkuiShortcut {
class BluetoothShortcut: public Shortcut
class BluetoothShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "bluetooth-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit BluetoothShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("BluetoothShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class BluetoothShortcut: public Shortcut
{
Q_OBJECT
public:
BluetoothShortcut();

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -31,14 +31,6 @@ BrightnessShortcut::BrightnessShortcut(QObject *parent) : Shortcut(parent)
{
initMetaData();
init();
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/brightness-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "BrightnessShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatusInfo.setToolTip(tr("Brightness"));
}
@ -156,3 +148,18 @@ void BrightnessShortcut::onEnableChanged(bool enable)
Q_EMIT enableStatusChanged(m_isEnable);
}
BrightnessShortcutPlugin::BrightnessShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList BrightnessShortcutPlugin::translations()
{
return {QStringLiteral("brightness-shortcut")};
}
Shortcut *BrightnessShortcutPlugin::createShortcut()
{
return new BrightnessShortcut;
}

View File

@ -25,11 +25,22 @@ class QDBusInterface;
namespace UkuiShortcut {
class BrightnessShortcut : public Shortcut
class BrightnessShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "brightness-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit BrightnessShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("BrightnessShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class BrightnessShortcut : public Shortcut
{
Q_OBJECT
public:
explicit BrightnessShortcut(QObject *parent = nullptr);
~BrightnessShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -38,7 +38,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -47,14 +47,6 @@ FlightModeShortcut::FlightModeShortcut()
m_isEnable = false;
}
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/flight-mode-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "FlightModeShortcut load translations file" << QLocale::system().name() << "failed!";
}
connect(m_gsettings, &QGSettings::changed, this, [ & ](const QString & key) {
if(key == RFKILL_STATE) {
int state = m_gsettings->get(RFKILL_STATE).toInt();
@ -129,3 +121,18 @@ void FlightModeShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
FlightModeShortcutPlugin::FlightModeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList FlightModeShortcutPlugin::translations()
{
return {QStringLiteral("flight-mode-shortcut")};
}
Shortcut *FlightModeShortcutPlugin::createShortcut()
{
return new FlightModeShortcut;
}

View File

@ -22,11 +22,23 @@
#include <QGSettings>
namespace UkuiShortcut {
class FlightModeShortcut : public Shortcut
class FlightModeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "flight-mode-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit FlightModeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("FlightModeShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class FlightModeShortcut : public Shortcut
{
Q_OBJECT
public:
FlightModeShortcut();

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -26,14 +26,6 @@
using namespace UkuiShortcut;
MultiScreenShortcut::MultiScreenShortcut()
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/multi-screen-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "MultiScreenShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_statusInfo.setName(tr("Multi-Screen"));
m_statusInfo.setToolTip(tr("Multi-Screen"));
m_statusInfo.setIcon(PROJECTION_ICON);
@ -68,3 +60,18 @@ void MultiScreenShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
MultiScreenShortcutPlugin::MultiScreenShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList MultiScreenShortcutPlugin::translations()
{
return {QStringLiteral("multi-screen-shortcut")};
}
Shortcut *MultiScreenShortcutPlugin::createShortcut()
{
return new MultiScreenShortcut;
}

View File

@ -21,11 +21,23 @@
#include "ukui-shortcut-plugin.h"
namespace UkuiShortcut {
class MultiScreenShortcut : public Shortcut
class MultiScreenShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "multi-screen-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit MultiScreenShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("MultiScreenShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class MultiScreenShortcut : public Shortcut
{
Q_OBJECT
public:
MultiScreenShortcut();

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -38,7 +38,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -31,14 +31,6 @@ using namespace UkuiShortcut;
UkuiShortcut::NightModeShortcut::NightModeShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/night-mode-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "NightModeShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatus.setName(tr("Night mode"));
m_currentStatus.setIcon(UKUI_NIGHTMODE_SYMBOLIC);
m_currentStatus.setToolTip("Night Mode");
@ -127,3 +119,18 @@ void NightModeShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
NightModeShortcutPlugin::NightModeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList NightModeShortcutPlugin::translations()
{
return {QStringLiteral("night-mode-shortcut")};
}
Shortcut *NightModeShortcutPlugin::createShortcut()
{
return new NightModeShortcut;
}

View File

@ -25,17 +25,27 @@
namespace UkuiShortcut {
class NightModeShortcut : public Shortcut
class NightModeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "night-mode-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit NightModeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("NightModeShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class NightModeShortcut : public Shortcut
{
Q_OBJECT
public:
explicit NightModeShortcut(QObject *parent = nullptr);
~NightModeShortcut() override;
QString pluginId() override {return QStringLiteral("FlightModeShortcut");}
QString pluginId() override {return QStringLiteral("NightModeShortcut");}
QMap<PluginMetaType::SystemMode, PluginMetaData> pluginMetaData() override;
void active(PluginMetaType::Action action) override;
const StatusInfo currentStatus() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -62,19 +62,9 @@ PowerModeShortcut::PowerModeShortcut()
}
m_isEnable = true;
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/power-mode-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "PowerModeShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatus.setName(tr("Power-Saving Mode"));
m_currentStatus.setIcon("ukui-eco-symbolic");
m_currentStatus.setToolTip(tr("Power-Saving Mode"));
}
PowerModeShortcut::~PowerModeShortcut()
@ -141,3 +131,18 @@ void PowerModeShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
PowerModeShortcutPlugin::PowerModeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList PowerModeShortcutPlugin::translations()
{
return {QStringLiteral("power-mode-shortcut")};
}
Shortcut *PowerModeShortcutPlugin::createShortcut()
{
return new PowerModeShortcut;
}

View File

@ -23,12 +23,23 @@
#include "ukui-shortcut-plugin.h"
namespace UkuiShortcut {
class PowerModeShortcut : public Shortcut
class PowerModeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "power-mode-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit PowerModeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("PowerModeShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class PowerModeShortcut : public Shortcut
{
Q_OBJECT
public:
PowerModeShortcut();
~PowerModeShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -29,14 +29,6 @@ using namespace UkuiShortcut;
UkuiShortcut::ScreenShotShortcut::ScreenShotShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/screenshot-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "ScreenShotShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatus.setName(tr("Screen Shot"));
m_currentStatus.setIcon(UKUI_SCREENSHOT_SYMBOLIC);
m_currentStatus.setToolTip(tr("Screen Shot"));
@ -129,3 +121,18 @@ void ScreenShotShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
ScreenShotShortcutPlugin::ScreenShotShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList ScreenShotShortcutPlugin::translations()
{
return {QStringLiteral("screenshot-shortcut")};
}
Shortcut *ScreenShotShortcutPlugin::createShortcut()
{
return new ScreenShotShortcut;
}

View File

@ -28,12 +28,22 @@
#include <QtDBus/QDBusInterface>
namespace UkuiShortcut {
class ScreenShotShortcut : public Shortcut
class ScreenShotShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "screenshot-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit ScreenShotShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("ScreenShot"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class ScreenShotShortcut : public Shortcut
{
Q_OBJECT
public:
explicit ScreenShotShortcut(QObject *parent = nullptr);
~ScreenShotShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -36,7 +36,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -30,15 +30,6 @@ using namespace UkuiShortcut;
UkuiShortcut::SoftFreezeShortcut::SoftFreezeShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
qWarning() << translator->load(QString(TRANSLATION_FILE_DIR) + "/soft-freeze-shortcut_" + QLocale::system().name() + ".qm");
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/soft-freeze-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QCoreApplication::installTranslator(translator);
} catch(...) {
qWarning() << "SoftFreezeShortcut load translations file" << QLocale::system().name() << "failed!";
}
initMetaData();
QString iconName = QIcon::fromTheme(UKUI_SOFTFREEZE_SYMBOLIC).isNull() ? "://icon/ukui-soft-freeze-symbolic.svg" : UKUI_SOFTFREEZE_SYMBOLIC;
@ -127,3 +118,18 @@ void SoftFreezeShortcut::freezeStateChanged(bool state)
m_state = state;
Q_EMIT statusChanged(m_currentStatus);
}
SoftFreezeShortcutPlugin::SoftFreezeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList SoftFreezeShortcutPlugin::translations()
{
return {QStringLiteral("soft-freeze-shortcut")};
}
Shortcut *SoftFreezeShortcutPlugin::createShortcut()
{
return new SoftFreezeShortcut;
}

View File

@ -24,12 +24,22 @@
#include <QGSettings>
namespace UkuiShortcut {
class SoftFreezeShortcut : public Shortcut
class SoftFreezeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "soft-freeze-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit SoftFreezeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("SoftFreeze"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class SoftFreezeShortcut : public Shortcut
{
Q_OBJECT
public:
explicit SoftFreezeShortcut(QObject *parent = nullptr);
~SoftFreezeShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -38,7 +38,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -180,3 +180,18 @@ void StatusChangeShortcut::enableChanged(bool isEnable)
Q_EMIT enableStatusChanged(m_isEnable);
}
StatusChangeShortcutPlugin::StatusChangeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList StatusChangeShortcutPlugin::translations()
{
return {QStringLiteral("status-change-shortcut")};
}
Shortcut *StatusChangeShortcutPlugin::createShortcut()
{
return new StatusChangeShortcut;
}

View File

@ -25,12 +25,23 @@
#include <QDBusInterface>
namespace UkuiShortcut {
class StatusChangeShortcut : public Shortcut
class StatusChangeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "status-change-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit StatusChangeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("StatusChangeShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class StatusChangeShortcut : public Shortcut
{
Q_OBJECT
public:
StatusChangeShortcut();
~StatusChangeShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -24,7 +24,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -31,13 +31,6 @@
using namespace UkuiShortcut;
SystemSettingShortcut::SystemSettingShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/system-setting-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "SystemSettingShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatusInfo.setColor(Color::ColorRole::BaseColor);//当前状态信息初始化
m_currentStatusInfo.setName(tr("Settings"));
m_currentStatusInfo.setIcon("applications-system-symbolic");
@ -115,3 +108,18 @@ void SystemSettingShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
SystemSettingShortcutPlugin::SystemSettingShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList SystemSettingShortcutPlugin::translations()
{
return {QStringLiteral("system-setting-shortcut")};
}
Shortcut *SystemSettingShortcutPlugin::createShortcut()
{
return new SystemSettingShortcut;
}

View File

@ -26,11 +26,22 @@
namespace UkuiShortcut {
class SystemSettingShortcut : public Shortcut
class SystemSettingShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "system-setting-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit SystemSettingShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("SystemSetting"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class SystemSettingShortcut : public Shortcut
{
Q_OBJECT
public:
explicit SystemSettingShortcut(QObject *parent = nullptr);
~SystemSettingShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -38,7 +38,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -33,14 +33,6 @@ using namespace UkuiShortcut;
VolumeShortcut::VolumeShortcut(QObject *parent) : Shortcut(parent)
{
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/volume-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "VolumeShortcut load translations file" << QLocale::system().name() << "failed!";
}
initMetaData();
m_currentStatusInfo.setValue(0);
@ -174,3 +166,18 @@ void VolumeShortcut::updateStatus(int volume)
Q_EMIT statusChanged(m_currentStatusInfo);
}
VolumeShortcutPlugin::VolumeShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList VolumeShortcutPlugin::translations()
{
return {QStringLiteral("volume-shortcut")};
}
Shortcut *VolumeShortcutPlugin::createShortcut()
{
return new VolumeShortcut;
}

View File

@ -23,11 +23,23 @@
#include "ukui-shortcut-plugin.h"
namespace UkuiShortcut {
class VolumeShortcut : public Shortcut
class VolumeShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "volume-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit VolumeShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("VolumeShortcut"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class VolumeShortcut : public Shortcut
{
Q_OBJECT
public:
explicit VolumeShortcut(QObject *parent = nullptr);
~VolumeShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}

View File

@ -38,7 +38,7 @@ qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
# [.so]
add_library(${PROJECT_NAME} SHARED ${HEADERS} ${SOURCES} ${QM_FILES})
set(TRANSLATION_FILE_DIR "${SHORTCUT_DATA_INSTALL_DIR}/${PROJECT_NAME}/translations")
set(TRANSLATION_FILE_DIR "${SHORTCUT_TRANSLATION_FILE_DIR}")
#
target_compile_definitions(${PROJECT_NAME}
PRIVATE TRANSLATION_FILE_DIR="${TRANSLATION_FILE_DIR}"

View File

@ -62,14 +62,6 @@ void WiFiShortcut::initMemberVariables()
connect(this, &WiFiShortcut::toQueryUsedWifiConnect, m_wifiDbusQuery, &WifiDbusQuery::queryUsedWifiConnect);
connect(m_wifiDbusQuery, &WifiDbusQuery::usedWifiName, this, &WiFiShortcut::handleUsedWifiConnect);
QTranslator *translator = new QTranslator(this);
try {
if(!translator->load(QString(TRANSLATION_FILE_DIR) + "/wifi-shortcut_" + QLocale::system().name() + ".qm")) throw -1;
QApplication::installTranslator(translator);
} catch(...) {
qWarning() << "WiFiShortcut load translations file" << QLocale::system().name() << "failed!";
}
m_currentStatus.setName(tr("WiFi"));
m_currentStatus.setIcon(KYLIN_WIFI_PATH);
m_currentStatus.setToolTip(tr("WiFi"));
@ -261,3 +253,18 @@ void WiFiShortcut::initMetaData()
m_metaData.insert(PluginMetaType::SystemMode::PC, pc);
m_metaData.insert(PluginMetaType::SystemMode::Tablet, tablet);
}
WiFiShortcutPlugin::WiFiShortcutPlugin(QObject *parent) : UkuiShortcutPlugin(parent)
{
}
QStringList WiFiShortcutPlugin::translations()
{
return {QStringLiteral("wifi-shortcut")};
}
Shortcut *WiFiShortcutPlugin::createShortcut()
{
return new WiFiShortcut;
}

View File

@ -49,12 +49,22 @@
namespace UkuiShortcut {
class WiFiShortcut : public Shortcut
class WiFiShortcutPlugin : public UkuiShortcutPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID UKUI_SHORTCUT_PLUGIN_IFACE_IID FILE "wifi-shortcut.json")
Q_INTERFACES(UkuiShortcut::UkuiShortcutPlugin)
public:
explicit WiFiShortcutPlugin(QObject *parent = nullptr);
QString pluginId() override { return QStringLiteral("WiFi"); };
QStringList translations() override;
Shortcut *createShortcut() override;
};
class WiFiShortcut : public Shortcut
{
Q_OBJECT
public:
explicit WiFiShortcut(QObject *parent = nullptr);
~WiFiShortcut() override;

View File

@ -1,5 +1,4 @@
{
"Type": "UKUI_SHORT_CUT",
"Version": "1.0.0"
"Version": "1.0.1"
}