mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
Fix: layout is empty
Change-Id: I6a445afc97b226ebae48cc0c472bad8a5df39ea3
This commit is contained in:
parent
26ff05c56d
commit
59aaed5434
Notes:
gerrit
2018-05-24 14:08:17 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: sbwtw <sbw@sbw.so> Submitted-by: sbwtw <sbw@sbw.so> Submitted-at: Thu, 24 May 2018 14:08:17 +0800 Reviewed-on: https://cr.deepin.io/34980 Project: dde/dde-dock Branch: refs/heads/master
@ -26,10 +26,7 @@ DBusAdaptors::DBusAdaptors(QObject *parent)
|
||||
"/com/deepin/daemon/InputDevice/Keyboard",
|
||||
QDBusConnection::sessionBus(), this))
|
||||
{
|
||||
connect(m_keyboard, &Keyboard::CurrentLayoutChanged, this,
|
||||
[=] {
|
||||
emit layoutChanged(layout());
|
||||
});
|
||||
connect(m_keyboard, &Keyboard::CurrentLayoutChanged, this, &DBusAdaptors::onLayoutChanged);
|
||||
}
|
||||
|
||||
DBusAdaptors::~DBusAdaptors()
|
||||
@ -38,5 +35,20 @@ DBusAdaptors::~DBusAdaptors()
|
||||
|
||||
QString DBusAdaptors::layout() const
|
||||
{
|
||||
return QString(m_keyboard->currentLayout()).split(';').first();
|
||||
const auto layouts = m_keyboard->currentLayout().split(';');
|
||||
|
||||
if (!layouts.isEmpty())
|
||||
return layouts.first();
|
||||
|
||||
qWarning() << Q_FUNC_INFO << "layouts is Empty!!";
|
||||
|
||||
// re-fetch data.
|
||||
QTimer::singleShot(1000, this, &DBusAdaptors::onLayoutChanged);
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void DBusAdaptors::onLayoutChanged()
|
||||
{
|
||||
emit layoutChanged(layout());
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
Q_PROPERTY(QString layout READ layout NOTIFY layoutChanged)
|
||||
QString layout() const;
|
||||
|
||||
public slots:
|
||||
void onLayoutChanged();
|
||||
|
||||
signals:
|
||||
void layoutChanged(QString text);
|
||||
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
auto propertyNameCStr = propertyName.toStdString();
|
||||
propertyInterfaceNames.insert(key, dbusInterface);
|
||||
propertyNames.insert(key, QString::fromStdString(propertyNameCStr));
|
||||
callback(interface.property(propertyNameCStr.c_str()));
|
||||
QDBusConnection::sessionBus().connect(dbusService,
|
||||
dbusPath,
|
||||
"org.freedesktop.DBus.Properties",
|
||||
@ -93,6 +92,8 @@ public:
|
||||
"s",
|
||||
q,
|
||||
propertyChangedSlot);
|
||||
|
||||
callback(interface.property(propertyNameCStr.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +178,7 @@ void IndicatorTrayWidget::updateIcon()
|
||||
|
||||
const QImage IndicatorTrayWidget::trayImage()
|
||||
{
|
||||
return grab().toImage();
|
||||
return d_ptr->label->grab().toImage();
|
||||
}
|
||||
|
||||
void IndicatorTrayWidget::sendClick(uint8_t buttonIndex, int x, int y)
|
||||
|
Loading…
x
Reference in New Issue
Block a user