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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DBUSADAPTORS_H
|
|
|
|
#define DBUSADAPTORS_H
|
|
|
|
|
2019-03-06 15:57:44 +08:00
|
|
|
#include <QMenu>
|
2018-03-07 13:50:16 +08:00
|
|
|
#include <QtDBus/QtDBus>
|
2022-11-18 17:08:32 +08:00
|
|
|
#include "org_deepin_dde_inputdevice1_keyboard.h"
|
2018-03-08 16:44:12 +08:00
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
using Keyboard = org::deepin::dde::inputdevice1::Keyboard1;
|
2021-07-29 21:29:26 +08:00
|
|
|
class QGSettings;
|
2018-03-07 13:50:16 +08:00
|
|
|
|
|
|
|
class DBusAdaptors : public QDBusAbstractAdaptor
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-11-18 17:08:32 +08:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.Dock1.KeyboardLayout")
|
2019-03-06 15:57:44 +08:00
|
|
|
// Q_CLASSINFO("D-Bus Introspection", ""
|
2022-11-18 17:08:32 +08:00
|
|
|
// " <interface name=\"org.deepin.dde.Dock1.KeyboardLayout\">\n"
|
2019-03-06 15:57:44 +08:00
|
|
|
// " <property access=\"read\" type=\"s\" name=\"layout\"/>\n"
|
|
|
|
// " <signal name=\"layoutChanged\">"
|
|
|
|
// " <arg name=\"layout\" type=\"s\"/>"
|
|
|
|
// " </signal>"
|
|
|
|
// " </interface>\n"
|
|
|
|
// "")
|
2018-03-07 13:50:16 +08:00
|
|
|
|
|
|
|
public:
|
2021-05-31 17:37:21 +08:00
|
|
|
explicit DBusAdaptors(QObject *parent = nullptr);
|
2018-03-07 13:50:16 +08:00
|
|
|
~DBusAdaptors();
|
|
|
|
|
|
|
|
public:
|
2021-07-26 16:10:50 +08:00
|
|
|
Q_PROPERTY(QString layout READ layout WRITE setLayout NOTIFY layoutChanged)
|
2018-03-07 13:50:16 +08:00
|
|
|
QString layout() const;
|
2021-07-26 16:10:50 +08:00
|
|
|
void setLayout(const QString &str);
|
|
|
|
|
|
|
|
Keyboard *getCurrentKeyboard();
|
2018-03-07 13:50:16 +08:00
|
|
|
|
2018-05-23 22:02:02 +08:00
|
|
|
public slots:
|
2019-03-06 15:57:44 +08:00
|
|
|
void onClicked(int button, int x, int y);
|
2018-05-23 22:02:02 +08:00
|
|
|
|
2018-03-07 13:50:16 +08:00
|
|
|
signals:
|
|
|
|
void layoutChanged(QString text);
|
2018-03-08 16:44:12 +08:00
|
|
|
|
2019-03-06 15:57:44 +08:00
|
|
|
private slots:
|
|
|
|
void onCurrentLayoutChanged(const QString & value);
|
|
|
|
void onUserLayoutListChanged(const QStringList & value);
|
|
|
|
void initAllLayoutList();
|
|
|
|
void refreshMenu();
|
|
|
|
void refreshMenuSelection();
|
|
|
|
void handleActionTriggered(QAction *action);
|
|
|
|
|
2021-07-29 21:29:26 +08:00
|
|
|
private slots:
|
|
|
|
void onGSettingsChanged(const QString &key);
|
|
|
|
|
2019-03-06 15:57:44 +08:00
|
|
|
private:
|
|
|
|
QString duplicateCheck(const QString &kb);
|
|
|
|
|
2018-03-08 16:44:12 +08:00
|
|
|
private:
|
|
|
|
Keyboard *m_keyboard;
|
2021-11-19 16:12:49 +08:00
|
|
|
QMenu *m_menu;
|
2019-03-06 15:57:44 +08:00
|
|
|
QAction *m_addLayoutAction;
|
|
|
|
|
|
|
|
QString m_currentLayoutRaw;
|
|
|
|
QString m_currentLayout;
|
|
|
|
QStringList m_userLayoutList;
|
|
|
|
KeyboardLayoutList m_allLayoutList;
|
2021-07-29 21:29:26 +08:00
|
|
|
const QGSettings *m_gsettings;
|
2018-03-07 13:50:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|