Improve connection menu

This commit is contained in:
Martchus 2016-09-17 19:13:49 +02:00
parent 7cd906d79e
commit da7bb0774a
2 changed files with 3 additions and 7 deletions

View File

@ -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<size_t>(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) {

View File

@ -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: