2018-03-07 13:50:16 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
*
|
|
|
|
* Author: rekols <rekols@foxmail.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 "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);
|
|
|
|
}
|