Fix: layout is empty

Change-Id: I6a445afc97b226ebae48cc0c472bad8a5df39ea3
This commit is contained in:
石博文 2018-05-23 22:02:02 +08:00
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
3 changed files with 23 additions and 7 deletions

View File

@ -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());
}

View File

@ -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);

View File

@ -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)