indicator: open Configure menu on double click
This commit is contained in:
parent
d773959a5d
commit
e7c3c4fb7b
1 changed files with 19 additions and 6 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
#ifdef QSYSTRAY
|
#ifdef QSYSTRAY
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
@ -56,15 +57,22 @@ int main(int argc, char** argv)
|
||||||
model.setDisplayFilter(DevicesModel::Reachable | DevicesModel::Paired);
|
model.setDisplayFilter(DevicesModel::Reachable | DevicesModel::Paired);
|
||||||
QMenu* menu = new QMenu;
|
QMenu* menu = new QMenu;
|
||||||
|
|
||||||
|
QPointer<KCMultiDialog> dialog;
|
||||||
|
|
||||||
DaemonDbusInterface iface;
|
DaemonDbusInterface iface;
|
||||||
auto refreshMenu = [&iface, &model, &menu, &helper]() {
|
|
||||||
|
auto refreshMenu = [&iface, &model, &menu, &helper, &dialog]() {
|
||||||
menu->clear();
|
menu->clear();
|
||||||
auto configure = menu->addAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure..."));
|
auto configure = menu->addAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure..."));
|
||||||
QObject::connect(configure, &QAction::triggered, configure, [](){
|
QObject::connect(configure, &QAction::triggered, configure, [&dialog]() {
|
||||||
KCMultiDialog* dialog = new KCMultiDialog;
|
if (dialog == nullptr) {
|
||||||
dialog->addModule(QStringLiteral("kcm_kdeconnect"));
|
dialog = new KCMultiDialog;
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->addModule(QStringLiteral("kcm_kdeconnect"));
|
||||||
dialog->show();
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
dialog->show();
|
||||||
|
} else {
|
||||||
|
dialog->activateWindow();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
for (int i=0, count = model.rowCount(); i<count; ++i) {
|
for (int i=0, count = model.rowCount(); i<count; ++i) {
|
||||||
DeviceDbusInterface* device = model.getDevice(i);
|
DeviceDbusInterface* device = model.getDevice(i);
|
||||||
|
@ -125,6 +133,11 @@ int main(int argc, char** argv)
|
||||||
QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
|
QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
|
||||||
systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
|
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);
|
systray.setContextMenu(menu);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue