From da7bb0774afea8acc68f685ce3640c33d3e6c408 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 17 Sep 2016 19:13:49 +0200 Subject: [PATCH] Improve connection menu --- gui/traywidget.cpp | 9 +++------ gui/traywidget.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/gui/traywidget.cpp b/gui/traywidget.cpp index 64acd7b..0fbb76a 100644 --- a/gui/traywidget.cpp +++ b/gui/traywidget.cpp @@ -91,7 +91,8 @@ TrayWidget::TrayWidget(TrayMenu *parent) : // setup connection menu m_connectionsActionGroup = new QActionGroup(m_connectionsMenu = new QMenu(tr("Connection"), this)); m_connectionsMenu->setIcon(QIcon::fromTheme(QStringLiteral("network-connect"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/network-connect.svg")))); - connect(m_ui->connectionsPushButton, &QPushButton::clicked, this, &TrayWidget::showConnectionsMenu); + m_ui->connectionsPushButton->setText(Settings::primaryConnectionSettings().label); + m_ui->connectionsPushButton->setMenu(m_connectionsMenu); // apply settings, this also establishes the connection to Syncthing applySettings(); @@ -403,6 +404,7 @@ void TrayWidget::handleConnectionSelected(QAction *connectionAction) m_selectedConnection = (index == 0) ? &Settings::primaryConnectionSettings() : &Settings::secondaryConnectionSettings()[static_cast(index - 1)]; + m_ui->connectionsPushButton->setText(m_selectedConnection->label); m_connection.reconnect(*m_selectedConnection); #ifndef SYNCTHINGTRAY_NO_WEBVIEW if(m_webViewDlg) { @@ -412,11 +414,6 @@ void TrayWidget::handleConnectionSelected(QAction *connectionAction) } } -void TrayWidget::showConnectionsMenu() -{ - m_connectionsMenu->exec(QCursor::pos()); -} - void TrayWidget::showDialog(QWidget *dlg) { if(m_menu) { diff --git a/gui/traywidget.h b/gui/traywidget.h index 03a7710..ede9807 100644 --- a/gui/traywidget.h +++ b/gui/traywidget.h @@ -67,7 +67,6 @@ private slots: #endif void handleNewNotification(ChronoUtilities::DateTime when, const QString &msg); void handleConnectionSelected(QAction *connectionAction); - void showConnectionsMenu(); void showDialog(QWidget *dlg); private: