2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2017 ~ 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-03-07 13:50:16 +08:00
|
|
|
|
|
|
|
#include "keyboardplugin.h"
|
2021-07-26 16:10:50 +08:00
|
|
|
#include "utils.h"
|
2018-03-07 13:50:16 +08:00
|
|
|
|
|
|
|
KeyboardPlugin::KeyboardPlugin(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyboardPlugin::~KeyboardPlugin()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString KeyboardPlugin::pluginName() const
|
|
|
|
{
|
|
|
|
return "keyboard";
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString KeyboardPlugin::pluginDisplayName() const
|
|
|
|
{
|
|
|
|
return "Keyboard";
|
|
|
|
}
|
|
|
|
|
|
|
|
void KeyboardPlugin::init(PluginProxyInterface *proxyInter)
|
|
|
|
{
|
|
|
|
m_proxyInter = proxyInter;
|
2019-11-30 20:31:22 +08:00
|
|
|
if (!m_dbusAdaptors) {
|
2018-03-07 13:50:16 +08:00
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
QString serverName = "org.deepin.dde.InputDevices1";
|
2019-11-30 20:31:22 +08:00
|
|
|
QDBusConnectionInterface *ifc = QDBusConnection::sessionBus().interface();
|
|
|
|
|
|
|
|
if (!ifc->isServiceRegistered(serverName)) {
|
|
|
|
connect(QDBusConnection::sessionBus().interface(), &QDBusConnectionInterface::serviceOwnerChanged, this,
|
|
|
|
[ = ](const QString & name, const QString & oldOwner, const QString & newOwner) {
|
|
|
|
Q_UNUSED(oldOwner);
|
|
|
|
if (name == serverName && !newOwner.isEmpty()) {
|
|
|
|
m_dbusAdaptors = new DBusAdaptors(this);
|
|
|
|
disconnect(ifc);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
m_dbusAdaptors = new DBusAdaptors(this);
|
|
|
|
}
|
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
QDBusConnection::sessionBus().registerService("org.deepin.dde.Dock1.KeyboardLayout");
|
|
|
|
QDBusConnection::sessionBus().registerObject("/org/deepin/dde/Dock1/KeyboardLayout", "org.deepin.dde.Dock1.KeyboardLayout", this);
|
2019-11-30 20:31:22 +08:00
|
|
|
}
|
2018-03-07 13:50:16 +08:00
|
|
|
}
|
|
|
|
|
2019-11-30 20:31:22 +08:00
|
|
|
QWidget *KeyboardPlugin::itemWidget(const QString &itemKey)
|
2018-03-07 13:50:16 +08:00
|
|
|
{
|
|
|
|
Q_UNUSED(itemKey);
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-11-30 20:31:22 +08:00
|
|
|
QWidget *KeyboardPlugin::itemTipsWidget(const QString &itemKey)
|
2018-03-07 13:50:16 +08:00
|
|
|
{
|
|
|
|
Q_UNUSED(itemKey);
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-07-22 20:38:24 +08:00
|
|
|
|
|
|
|
int KeyboardPlugin::itemSortKey(const QString &itemKey)
|
|
|
|
{
|
|
|
|
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
|
|
|
|
|
2020-08-03 11:28:48 +08:00
|
|
|
return m_proxyInter->getValue(this, key, 1).toInt();
|
2020-07-22 20:38:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeyboardPlugin::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);
|
|
|
|
}
|