Commit e7c3c4fb authored by Piyush Aggarwal's avatar Piyush Aggarwal 🎮
Browse files

indicator: open Configure menu on double click

parent d773959a
Pipeline #62844 passed with stage
in 3 minutes and 39 seconds
......@@ -7,6 +7,7 @@
#include <QApplication>
#include <QProcess>
#include <QThread>
#include <QPointer>
#ifdef QSYSTRAY
#include <QSystemTrayIcon>
......@@ -56,15 +57,22 @@ int main(int argc, char** argv)
model.setDisplayFilter(DevicesModel::Reachable | DevicesModel::Paired);
QMenu* menu = new QMenu;
QPointer<KCMultiDialog> dialog;
DaemonDbusInterface iface;
auto refreshMenu = [&iface, &model, &menu, &helper]() {
auto refreshMenu = [&iface, &model, &menu, &helper, &dialog]() {
menu->clear();
auto configure = menu->addAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure..."));
QObject::connect(configure, &QAction::triggered, configure, [](){
KCMultiDialog* dialog = new KCMultiDialog;
dialog->addModule(QStringLiteral("kcm_kdeconnect"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
QObject::connect(configure, &QAction::triggered, configure, [&dialog]() {
if (dialog == nullptr) {
dialog = new KCMultiDialog;
dialog->addModule(QStringLiteral("kcm_kdeconnect"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
} else {
dialog->activateWindow();
}
});
for (int i=0, count = model.rowCount(); i<count; ++i) {
DeviceDbusInterface* device = model.getDevice(i);
......@@ -125,6 +133,11 @@ int main(int argc, char** argv)
QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
});
QObject::connect(&systray, &QSystemTrayIcon::activated, [&iface](QSystemTrayIcon::ActivationReason reason) {
if (reason == QSystemTrayIcon::DoubleClick) {
iface.openConfiguration();
}
});
systray.setContextMenu(menu);
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment