Do not create a new menu on every refreshMenu call
Seems to work better under Unity Reviewed by Aleix Pol
This commit is contained in:
parent
6f4dfb134e
commit
c2739f94f1
1 changed files with 7 additions and 4 deletions
|
@ -53,9 +53,11 @@ int main(int argc, char** argv)
|
||||||
systray.setIcon(QIcon::fromTheme("kdeconnect"));
|
systray.setIcon(QIcon::fromTheme("kdeconnect"));
|
||||||
systray.setVisible(true);
|
systray.setVisible(true);
|
||||||
|
|
||||||
DaemonDbusInterface iface;
|
|
||||||
auto refreshMenu = [&systray, &iface, &model]() {
|
|
||||||
QMenu *menu = new QMenu;
|
QMenu *menu = new QMenu;
|
||||||
|
|
||||||
|
DaemonDbusInterface iface;
|
||||||
|
auto refreshMenu = [&systray, &iface, &model, &menu]() {
|
||||||
|
menu->clear();
|
||||||
auto configure = menu->addAction(i18n("Configure..."));
|
auto configure = menu->addAction(i18n("Configure..."));
|
||||||
QObject::connect(configure, &QAction::triggered, configure, [](){
|
QObject::connect(configure, &QAction::triggered, configure, [](){
|
||||||
QProcess::startDetached("kcmshell5", {"kdeconnect"});
|
QProcess::startDetached("kcmshell5", {"kdeconnect"});
|
||||||
|
@ -78,7 +80,6 @@ int main(int argc, char** argv)
|
||||||
pairMenu->addAction(i18n("Reject"), dev, &DeviceDbusInterface::rejectPairing);
|
pairMenu->addAction(i18n("Reject"), dev, &DeviceDbusInterface::rejectPairing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
systray.setContextMenu(menu);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QObject::connect(&iface, &DaemonDbusInterface::pairingRequestsChangedProxy, &model, refreshMenu);
|
QObject::connect(&iface, &DaemonDbusInterface::pairingRequestsChangedProxy, &model, refreshMenu);
|
||||||
|
@ -89,6 +90,8 @@ int main(int argc, char** argv)
|
||||||
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
|
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
systray.setContextMenu(menu);
|
||||||
|
|
||||||
refreshMenu();
|
refreshMenu();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Reference in a new issue