Skip to content
Permalink
Browse files
Adds Settings frame to Network Map with optional Relay columns.
  • Loading branch information
sirop committed Apr 22, 2012
1 parent 5feff41 commit f4bbf3f44f061049b3d435709638bc1477adcd2e
@@ -0,0 +1,3 @@
New features:
o Adds Settings frame for Network Map with optional
columns for Relay panel. Resolves ticket 2731.
@@ -51,6 +51,20 @@
#define DEFAULT_SPLITTER_MAP QByteArray()
#define DEFAULT_SPLITTER_ROUT QByteArray()

/* Settings key for IP column */
#define SETTING_IP_COLUMN "RelayPanel/ShowIPColumn"
/* Settings key for Bandwidth column */
#define SETTING_BW_COLUMN "RelayPanel/ShowBandwidthColumn"
/* Settings key for Uptime column */
#define SETTING_UPTIME_COLUMN "RelayPanel/ShowUptimeColumn"

/* Default key value for IP column */
#define DEFAULT_IP_COLUMN false
/* Default key value for Bandwidth column */
#define DEFAULT_BW_COLUMN false
/* Default key value for Uptime column */
#define DEFAULT_UPTIME_COLUMN false

/** Constructor. Loads settings from VidaliaSettings.
* \param parent The parent widget of this NetViewer object.\
*/
@@ -63,6 +77,8 @@ NetViewer::NetViewer(QWidget *parent)
ui.lblConsensus->setVisible(false);
ui.lblOffline->setVisible(false);

loadSettings();
ui.frmSettings->setVisible(false);
#if defined(Q_WS_MAC)
ui.actionHelp->setShortcut(QString("Ctrl+?"));
#endif
@@ -161,7 +177,10 @@ NetViewer::NetViewer(QWidget *parent)
this, SLOT(onRouterSearch()));
connect(ui.lineRouterSearch, SIGNAL(textChanged(QString)),
ui.treeRouterList, SLOT(onRouterSearch(QString)));

connect(ui.btnSaveSettings, SIGNAL(clicked()),
this, SLOT(saveSettings()));
connect(ui.btnCancelSettings, SIGNAL(clicked()),
this, SLOT(cancelChanges()));
setupGeoIpResolver();

QToolBar *tb = new QToolBar();
@@ -171,10 +190,11 @@ NetViewer::NetViewer(QWidget *parent)
tb->addAction(ui.actionZoomOut);
tb->addAction(ui.actionZoomToFit);
tb->addAction(ui.actionZoomFullScreen);
tb->addAction(ui.actionSettings);

tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.horizontalLayout->addWidget(tb);

/* Restore the state of each splitter */
ui.spltMain->restoreState(getSetting(SETTING_SPLITTER_MAIN,
DEFAULT_SPLITTER_MAIN)
@@ -609,3 +629,60 @@ NetViewer::linkActivated(const QString &url)
{
emit helpRequested(url);
}

/** Saves the Network Map settings and
* then hides the settings frame. */
void
NetViewer::saveSettings()
{
ui.treeRouterList->setColumnHidden(RouterListWidget::IPnumberColumn,
!(ui.chkShowIP->isChecked()));
ui.treeRouterList->setColumnHidden(RouterListWidget::BandwidthColumn,
!(ui.chkShowBW->isChecked()));
ui.treeRouterList->setColumnHidden(RouterListWidget::UptimeColumn,
!(ui.chkShowUptime->isChecked()));
saveSetting(SETTING_IP_COLUMN, ui.chkShowIP->isChecked());
saveSetting(SETTING_BW_COLUMN, ui.chkShowBW->isChecked());
saveSetting(SETTING_UPTIME_COLUMN, ui.chkShowUptime->isChecked());
}

/** Simply restores the previously saved settings and hides the settings
* frame. */
void
NetViewer::cancelChanges()
{
/* Hide the settings frame and reset toggle button */
ui.actionSettings->toggle();
/* Reload the settings */
loadSettings();
}

/** Loads the saved Network Map settings
* except Splitter settings. */
void
NetViewer::loadSettings()
{
/* Add optional columns to Relay Panel if their setting values are
* true, otherwise use default values. */
ui.treeRouterList->setColumnHidden(RouterListWidget::IPnumberColumn,
!(getSetting(SETTING_IP_COLUMN,
DEFAULT_IP_COLUMN).
toBool()));
ui.chkShowIP->setChecked(getSetting(SETTING_IP_COLUMN,
DEFAULT_IP_COLUMN).
toBool());
ui.treeRouterList->setColumnHidden(RouterListWidget::BandwidthColumn,
!(getSetting(SETTING_BW_COLUMN,
DEFAULT_BW_COLUMN).
toBool()));
ui.chkShowBW->setChecked(getSetting(SETTING_BW_COLUMN,
DEFAULT_BW_COLUMN).
toBool());
ui.treeRouterList->setColumnHidden(RouterListWidget::UptimeColumn,
!(getSetting(SETTING_UPTIME_COLUMN,
DEFAULT_UPTIME_COLUMN).
toBool()));
ui.chkShowUptime->setChecked(getSetting(SETTING_UPTIME_COLUMN,
DEFAULT_UPTIME_COLUMN).
toBool());
}
@@ -118,6 +118,16 @@ private slots:
/** Called when the user clicks on a QLabel containing a hyperlink. */
void linkActivated(const QString &url);

/** Saves the Network Map settings and
* then hides the settings frame. */
void saveSettings();
/** Loads the saved Network Map settings
* except Splitter settings. */
void loadSettings();
/** Simply restores the previously saved settings and hides the settings
* frame. */
void cancelChanges();

private:
/** */
void setupGeoIpResolver();
@@ -7,13 +7,13 @@
<x>0</x>
<y>0</y>
<width>740</width>
<height>614</height>
<height>786</height>
</rect>
</property>
<property name="windowTitle">
<string>Network Map</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QSplitter" name="spltMain">
<property name="orientation">
@@ -145,7 +145,7 @@
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
<number>6</number>
</property>
<column>
<property name="text">
@@ -162,6 +162,21 @@
<string>Relay</string>
</property>
</column>
<column>
<property name="text">
<string>IP</string>
</property>
</column>
<column>
<property name="text">
<string>Bandwidth</string>
</property>
</column>
<column>
<property name="text">
<string>Uptime</string>
</property>
</column>
</widget>
</item>
</layout>
@@ -355,6 +370,164 @@
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="frmSettings">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>550</width>
<height>140</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="visible">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="grpRelayPanel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>110</height>
</size>
</property>
<property name="title">
<string>Add columns to Relay panel:</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="chkShowIP">
<property name="text">
<string>IP</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkShowBW">
<property name="text">
<string>Bandwidth</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkShowUptime">
<property name="text">
<string>Uptime</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnSaveSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>85</width>
<height>27</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="toolTip">
<string>Saves the current Network Map settings</string>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancelSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>85</width>
<height>27</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="toolTip">
<string>Cancels changes made to settings</string>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
<action name="actionRefresh">
<property name="enabled">
@@ -485,6 +658,24 @@
<string>Ctrl+F</string>
</property>
</action>
<action name="actionSettings">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../res/vidalia.qrc">
<normaloff>:/images/32x32/preferences-other.png</normaloff>:/images/32x32/preferences-other.png</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
<property name="statusTip">
<string>Adjust Network Map Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+T</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@@ -506,5 +697,22 @@
<resources>
<include location="../res/vidalia.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>actionSettings</sender>
<signal>toggled(bool)</signal>
<receiver>frmSettings</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>264</x>
<y>424</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit f4bbf3f

Please sign in to comment.