Skip to content

Commit

Permalink
fix: sni tray context menu can not be initialize correctly after reboot
Browse files Browse the repository at this point in the history
linuxdeepin/internal-discussion#660

Change-Id: I51d95b7acf58d9550d1646a0d64ebfc8e952f918
  • Loading branch information
listenerri committed Dec 14, 2018
1 parent 4736eb3 commit 8870cbc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/tray/snitraywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ SNITrayWidget::SNITrayWidget(const QString &sniServicePath, QWidget *parent)
connect(m_sniInter, &StatusNotifierItem::NewAttentionIcon, this, &SNITrayWidget::refreshAttentionIcon);

QTimer::singleShot(0, this, &SNITrayWidget::refreshIcon);
QTimer::singleShot(300, this, &SNITrayWidget::initMenu);
}

SNITrayWidget::~SNITrayWidget()
Expand Down Expand Up @@ -114,9 +113,19 @@ bool SNITrayWidget::isValid()

void SNITrayWidget::initMenu()
{
qDebug() << "using sni service path:" << m_dbusService;

const QString &menuPath = m_sniInter->menu().path();
m_dbusMenuImporter = new DBusMenuImporter(m_dbusService, menuPath, SYNCHRONOUS, this);

qDebug() << "using sni menu path:" << menuPath;

m_dbusMenuImporter = new DBusMenuImporter(m_dbusService, menuPath, ASYNCHRONOUS, this);

qDebug() << "generate the sni menu object";

m_menu = m_dbusMenuImporter->menu();

qDebug() << "the sni menu obect is:" << m_menu;
}

/*
Expand Down Expand Up @@ -197,6 +206,10 @@ void SNITrayWidget::showContextMenu(int x, int y)
if (m_sniInter->menu().path().startsWith("/NO_DBUSMENU")) {
m_sniInter->ContextMenu(x, y);
} else {
if (!m_menu) {
qDebug() << "context menu has not be ready, init menu";
initMenu();
}
m_menu->popup(QPoint(x, y));
}
}
Expand Down

0 comments on commit 8870cbc

Please sign in to comment.