fixed:dock default value

dde-session-daemon比dock晚启动,导致dock获取的默认值错误
This commit is contained in:
shaojun 2019-12-02 15:01:38 +08:00
parent b3114922bb
commit d4702c748c
3 changed files with 43 additions and 11 deletions

View File

@ -58,6 +58,8 @@ DockSettings::DockSettings(QWidget *parent)
, m_displayInter(new DBusDisplay(this))
, m_itemManager(DockItemManager::instance(this))
{
checkService();
m_primaryRawRect = m_displayInter->primaryRawRect();
m_screenRawHeight = m_displayInter->screenRawHeight();
m_screenRawWidth = m_displayInter->screenRawWidth();
@ -563,3 +565,27 @@ void DockSettings::onWindowSizeChanged()
emit windowGeometryChanged();
}
void DockSettings::checkService()
{
// com.deepin.dde.daemon.Dock服务比dock晚启动导致dock启动后的状态错误
QString serverName = "com.deepin.dde.daemon.Dock";
QDBusConnectionInterface *ifc = QDBusConnection::sessionBus().interface();
if (!ifc->isServiceRegistered(serverName)) {
connect(ifc, &QDBusConnectionInterface::serviceOwnerChanged, this, [ = ](const QString & name, const QString & oldOwner, const QString & newOwner) {
if (name == serverName && !newOwner.isEmpty()) {
m_dockInter = new DBusDock(serverName, "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this);
onPositionChanged();
onDisplayModeChanged();
hideModeChanged();
hideStateChanged();
onOpacityChanged(m_dockInter->opacity());
onWindowSizeChanged();
disconnect(ifc);
}
});
}
}

View File

@ -111,6 +111,7 @@ private:
bool test(const Position pos, const QList<QRect> &otherScreens) const;
void calculateWindowConfig();
void gtkIconThemeChanged();
void checkService();
private:
int m_dockWindowSize;

View File

@ -115,6 +115,9 @@ bool TrayPlugin::pluginIsDisable()
return true;
}
if (!m_proxyInter)
return true;
return !m_proxyInter->getValue(this, PLUGIN_ENABLED_KEY, true).toBool();
}
@ -428,8 +431,7 @@ void TrayPlugin::trayIndicatorAdded(const QString &itemKey, const QString &indic
if (!m_indicatorMap.keys().contains(indicatorName)) {
indicatorTray = new IndicatorTray(indicatorName);
m_indicatorMap[indicatorName] = indicatorTray;
}
else {
} else {
indicatorTray = m_indicatorMap[itemKey];
}
@ -479,6 +481,9 @@ void TrayPlugin::xembedItemChanged(quint32 winId)
void TrayPlugin::switchToMode(const Dock::DisplayMode mode)
{
if (!m_proxyInter)
return;
if (mode == Dock::Fashion) {
for (auto itemKey : m_trayMap.keys()) {
m_proxyInter->itemRemoved(this, itemKey);