fixed(keyboard-layout):refresh keyboard layout for tray

注销后不显示键盘布局
This commit is contained in:
shaojun 2019-11-30 20:31:22 +08:00
parent bf41b1ebb6
commit 6c19ff5e58
3 changed files with 25 additions and 6 deletions

View File

@ -92,6 +92,8 @@ void DBusAdaptors::onUserLayoutListChanged(const QStringList &value)
m_userLayoutList = value; m_userLayoutList = value;
refreshMenu(); refreshMenu();
emit layoutChanged(layout());
} }
void DBusAdaptors::initAllLayoutList() void DBusAdaptors::initAllLayoutList()

View File

@ -41,20 +41,37 @@ const QString KeyboardPlugin::pluginDisplayName() const
void KeyboardPlugin::init(PluginProxyInterface *proxyInter) void KeyboardPlugin::init(PluginProxyInterface *proxyInter)
{ {
m_proxyInter = proxyInter; m_proxyInter = proxyInter;
m_dbusAdaptors = new DBusAdaptors(this); if (!m_dbusAdaptors) {
QDBusConnection::sessionBus().registerService("com.deepin.dde.Keyboard"); QString serverName = "com.deepin.daemon.InputDevices";
QDBusConnection::sessionBus().registerObject("/com/deepin/dde/Keyboard", "com.deepin.dde.Keyboard", this); 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);
}
QDBusConnection::sessionBus().registerService("com.deepin.dde.Keyboard");
QDBusConnection::sessionBus().registerObject("/com/deepin/dde/Keyboard", "com.deepin.dde.Keyboard", this);
}
} }
QWidget* KeyboardPlugin::itemWidget(const QString &itemKey) QWidget *KeyboardPlugin::itemWidget(const QString &itemKey)
{ {
Q_UNUSED(itemKey); Q_UNUSED(itemKey);
return nullptr; return nullptr;
} }
QWidget* KeyboardPlugin::itemTipsWidget(const QString &itemKey) QWidget *KeyboardPlugin::itemTipsWidget(const QString &itemKey)
{ {
Q_UNUSED(itemKey); Q_UNUSED(itemKey);

View File

@ -41,7 +41,7 @@ public:
QWidget *itemTipsWidget(const QString &itemKey) override; QWidget *itemTipsWidget(const QString &itemKey) override;
private: private:
DBusAdaptors *m_dbusAdaptors; DBusAdaptors *m_dbusAdaptors = nullptr;
}; };
#endif #endif