commit 5bc1bab418cca8c28c5d9797d89312eaefb86333 Author: Feroze Naina ferozenaina@gmail.com Date: Tue Apr 10 15:29:29 2012 +0530
Display Nickname and ORPort in window title if running as a relay --- changes/bug3634 | 3 +++ src/vidalia/MainWindow.cpp | 22 ++++++++++++++++++++++ src/vidalia/MainWindow.h | 3 +++ src/vidalia/config/ConfigDialog.cpp | 5 ++++- src/vidalia/config/ConfigDialog.h | 2 ++ src/vidalia/config/ConfigPage.h | 3 +++ src/vidalia/config/ServerPage.cpp | 8 +++++++- 7 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/changes/bug3634 b/changes/bug3634 new file mode 100644 index 0000000..6f17d8a --- /dev/null +++ b/changes/bug3634 @@ -0,0 +1,3 @@ + New features: + o Display the relay Nickname and ORPort in the window title when + Vidalia is running as a relay. Fixes bug 3634. diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp index 741f55e..c97ab35 100644 --- a/src/vidalia/MainWindow.cpp +++ b/src/vidalia/MainWindow.cpp @@ -185,6 +185,7 @@ MainWindow::createGUI() createMenuBar(); createToolBar(); createTrayIcon(); + updateTitle();
// We need to create this tab at the beggining // and we must specify the statusBar @@ -497,6 +498,25 @@ MainWindow::createConnections() this, SLOT(addTab(VidaliaTab *))); }
+/* Sets window title to "Nickname ORPort" if running as relay */ +void +MainWindow::updateTitle() +{ + ServerSettings settings(_torControl); + + QString baseTitle = tr("Vidalia Control Panel"); + + if (settings.isServerEnabled()) { + QString Nickname = settings.getNickname(); + QString ORPort = QString::number(settings.getORPort()); + setWindowTitle(QString("%1 - %2 %3").arg(baseTitle) + .arg(Nickname) + .arg(ORPort)); + } else { + setWindowTitle(baseTitle); + } +} + /** Called when the application is closing, by selecting "Exit" from the tray * menu. If we're running a Tor server, then ask if we want to kill Tor now, * or do a delayed shutdown. */ @@ -1778,6 +1798,8 @@ MainWindow::showConfigDialog(ConfigDialog::Page page) this, SLOT(showHelpDialog(QString))); connect(configDialog, SIGNAL(restartTor()), this, SLOT(restart())); + connect(configDialog, SIGNAL(configChanged()), + this, SLOT(updateTitle())); configDialog->showWindow(page); }
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h index 4a34ee3..50a84c0 100644 --- a/src/vidalia/MainWindow.h +++ b/src/vidalia/MainWindow.h @@ -171,6 +171,9 @@ private slots: /** Called when the Panic! button is pressed */ void panic();
+ /** Called when server configuration is changed */ + void updateTitle(); + #if defined(USE_AUTOUPDATE) /** Called when the user clicks the 'Check Now' button in the General * settings page. */ diff --git a/src/vidalia/config/ConfigDialog.cpp b/src/vidalia/config/ConfigDialog.cpp index 1724814..f87e1ab 100644 --- a/src/vidalia/config/ConfigDialog.cpp +++ b/src/vidalia/config/ConfigDialog.cpp @@ -66,6 +66,8 @@ ConfigDialog::ConfigDialog(QWidget* parent)
/* Used to connect restartTor signals */ AdvancedPage *advancedPage; + /* Used to connect configChanged signals */ + ServerPage *serverPage; /* Create the config pages and actions */ QActionGroup *grp = new QActionGroup(this); GeneralPage *generalPage = new GeneralPage(ui.stackPages); @@ -79,7 +81,7 @@ ConfigDialog::ConfigDialog(QWidget* parent) createPageAction(QIcon(IMAGE_NETWORK), tr("Network"), "Network", grp));
- ui.stackPages->add(new ServerPage(ui.stackPages), + ui.stackPages->add(serverPage = new ServerPage(ui.stackPages), createPageAction(QIcon(IMAGE_SERVER), tr("Sharing"), "Sharing", grp));
@@ -92,6 +94,7 @@ ConfigDialog::ConfigDialog(QWidget* parent) tr("Advanced"), "Advanced", grp));
connect(advancedPage, SIGNAL(restartTor()), this, SIGNAL(restartTor())); + connect(serverPage, SIGNAL(configChanged()), this, SIGNAL(configChanged()));
foreach (ConfigPage *page, ui.stackPages->pages()) { connect(page, SIGNAL(helpRequested(QString)), diff --git a/src/vidalia/config/ConfigDialog.h b/src/vidalia/config/ConfigDialog.h index 441a85d..3369200 100644 --- a/src/vidalia/config/ConfigDialog.h +++ b/src/vidalia/config/ConfigDialog.h @@ -51,6 +51,8 @@ signals: void checkForUpdates(); /** Emitted when the user changes torrc file to restart Tor */ void restartTor(); + /** Emitted when user changes server configuration */ + void configChanged();
protected: /** Called when the user changes the UI translation. */ diff --git a/src/vidalia/config/ConfigPage.h b/src/vidalia/config/ConfigPage.h index d939302..3e1e4dc 100644 --- a/src/vidalia/config/ConfigPage.h +++ b/src/vidalia/config/ConfigPage.h @@ -65,6 +65,9 @@ signals: /** Emitted when all the settings need to be reloaded */ void reloadAll();
+ /** Emitted when user changes server configuration */ + void configChanged(); + private: QString _title; /**< Title of this configuration page. */ }; diff --git a/src/vidalia/config/ServerPage.cpp b/src/vidalia/config/ServerPage.cpp index 52d311a..31660a4 100644 --- a/src/vidalia/config/ServerPage.cpp +++ b/src/vidalia/config/ServerPage.cpp @@ -284,7 +284,13 @@ ServerPage::changedSinceLastApply() bool ServerPage::apply(QString &errmsg) { - return _settings->apply(&errmsg); + if (_settings->apply(&errmsg)) { + /* Emits signal used to set Vidalia window title in MainWindow */ + emit configChanged(); + return true; + } + + return false; }
/** Returns true if the user has changed their server settings since the
tor-commits@lists.torproject.org