From 80a12e506a25e60b34e6c30d47daff55d982c69b Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 25 Jan 2017 01:19:44 +0100 Subject: [PATCH] Let the indicator accept and reject pairings --- indicator/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/indicator/main.cpp b/indicator/main.cpp index 99ef35de4..0552f6c06 100644 --- a/indicator/main.cpp +++ b/indicator/main.cpp @@ -53,7 +53,8 @@ int main(int argc, char** argv) systray.setIcon(QIcon::fromTheme("kdeconnect")); systray.setVisible(true); - auto refreshMenu = [&systray, &model]() { + DaemonDbusInterface iface; + auto refreshMenu = [&systray, &iface, &model]() { QMenu *menu = new QMenu; auto configure = menu->addAction(i18n("Configure...")); QObject::connect(configure, &QAction::triggered, configure, [](){ @@ -66,9 +67,21 @@ int main(int argc, char** argv) menu->addMenu(indicator); } + const QStringList requests = iface.pairingRequests(); + if (!requests.isEmpty()) { + menu->addSection(i18n("Pairing requests")); + + for(const auto &req: requests) { + DeviceDbusInterface *dev = new DeviceDbusInterface(req, menu); + auto pairMenu = menu->addMenu(dev->name()); + pairMenu->addAction(i18n("Pair"), dev, &DeviceDbusInterface::acceptPairing); + pairMenu->addAction(i18n("Reject"), dev, &DeviceDbusInterface::rejectPairing); + } + } systray.setContextMenu(menu); }; + QObject::connect(&iface, &DaemonDbusInterface::pairingRequestsChangedProxy, &model, refreshMenu); QObject::connect(&model, &DevicesModel::rowsInserted, &model, refreshMenu); QObject::connect(&model, &DevicesModel::rowsRemoved, &model, refreshMenu);