commit 3e64bcb37ef6981ae9da229ceb451b1714f6dd1e
Author: Florian Stinglmayr <fstinglmayr(a)gmail.com>
Date: Sat Jan 5 17:29:29 2013 +0100
A fix for trac bug 6724, where vidalia won't complain about "bridge" anymore.
Now Vidalia will simply strip "bridge" from the front, when adding new bridges
to the list. Also the input was reworked to a multi line text box so one can
add more than one bridge at a time. This is helpful as one could paste all the
bridges from bridges.tpo in one pass. Also there was a small bug in applying
the settings as deleted bridges where not commited to the configuration.
---
src/vidalia/config/NetworkPage.cpp | 27 +++-
src/vidalia/config/NetworkPage.ui | 202 ++++++++++++++++----------------
src/vidalia/config/NetworkSettings.cpp | 2 +
3 files changed, 124 insertions(+), 107 deletions(-)
diff --git a/src/vidalia/config/NetworkPage.cpp b/src/vidalia/config/NetworkPage.cpp
index ea132e6..7374267 100644
--- a/src/vidalia/config/NetworkPage.cpp
+++ b/src/vidalia/config/NetworkPage.cpp
@@ -48,7 +48,6 @@ NetworkPage::NetworkPage(QWidget *parent)
this, SLOT(bridgeContextMenuRequested(QPoint)));
connect(ui.listBridges, SIGNAL(itemSelectionChanged()),
this, SLOT(bridgeSelectionChanged()));
- connect(ui.lineBridge, SIGNAL(returnPressed()), this, SLOT(addBridge()));
connect(ui.lblHelpFindBridges, SIGNAL(linkActivated(QString)),
this, SLOT(onLinkActivated(QString)));
connect(ui.cmboProxyType, SIGNAL(currentIndexChanged(int)),
@@ -120,15 +119,29 @@ NetworkPage::onLinkActivated(const QString &url)
void
NetworkPage::addBridge()
{
- QString input = ui.lineBridge->text().trimmed();
+ QString input = ui.teBridges->toPlainText().trimmed();
if (input.isEmpty())
return;
- if (!ui.listBridges->findItems(input, Qt::MatchFixedString).isEmpty())
- return; /* duplicate bridge */
- ui.listBridges->addItem(input);
- ui.lineBridge->clear();
+ QStringList lines = input.split("\n", QString::SkipEmptyParts);
+ QStringList parts;
+
+ foreach(QString line, lines) {
+ if (!ui.listBridges->findItems(line, Qt::MatchFixedString).isEmpty())
+ continue; /* duplicate bridge */
+
+ /* If the bridge part is still at the beginning, strip it away.
+ */
+ parts = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+ if (parts.size() > 1 && parts[0].toLower() == "bridge") {
+ parts.removeFirst();
+ }
+ QString bridge = parts.join(" ");
+
+ ui.listBridges->addItem(bridge);
+ }
+ ui.teBridges->setPlainText("");
}
/** Removes one or more selected bridges from the bridge list box. */
@@ -254,7 +267,7 @@ NetworkPage::save(QString &errmsg)
}
_settings->setReachablePorts(reachablePorts);
- if (!ui.lineBridge->text().trimmed().isEmpty())
+ if (!ui.teBridges->toPlainText().trimmed().isEmpty())
addBridge();
diff --git a/src/vidalia/config/NetworkPage.ui b/src/vidalia/config/NetworkPage.ui
index 3fc301b..c76416c 100644
--- a/src/vidalia/config/NetworkPage.ui
+++ b/src/vidalia/config/NetworkPage.ui
@@ -119,19 +119,6 @@
</item>
</layout>
</item>
- <item row="1" column="2">
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
<item row="2" column="0">
<widget class="QLabel" name="lblProxyType">
<property name="text">
@@ -145,6 +132,19 @@
<item row="2" column="1">
<widget class="QComboBox" name="cmboProxyType"/>
</item>
+ <item row="2" column="2">
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
@@ -232,13 +232,13 @@
<property name="title">
<string>Bridge Settings</string>
</property>
- <layout class="QVBoxLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lblAddBridge">
<property name="text">
- <string>Add a Bridge:</string>
+ <string>Add one or more bridges:</string>
</property>
</widget>
</item>
@@ -257,94 +257,95 @@
</item>
</layout>
</item>
- <item>
- <layout class="QHBoxLayout">
+ <item row="1" column="0">
+ <widget class="QPlainTextEdit" name="teBridges">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add one or several bridges by writing each bridge in a new line.</string>
+ </property>
+ <property name="tabChangesFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" rowspan="2">
+ <layout class="QVBoxLayout">
<item>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QLineEdit" name="lineBridge">
- <property name="maxLength">
- <number>100</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QListWidget" name="listBridges">
- <property name="contextMenuPolicy">
- <enum>Qt::CustomContextMenu</enum>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QToolButton" name="btnAddBridge">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../res/vidalia.qrc">
+ <normaloff>:/images/22x22/list-add.png</normaloff>:/images/22x22/list-add.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="btnRemoveBridge">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Remove the selected bridges from the list</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../res/vidalia.qrc">
+ <normaloff>:/images/22x22/list-remove.png</normaloff>:/images/22x22/list-remove.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="btnCopyBridge">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Copy the selected bridges to the clipboard</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../res/vidalia.qrc">
+ <normaloff>:/images/22x22/edit-copy.png</normaloff>:/images/22x22/edit-copy.png</iconset>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QToolButton" name="btnAddBridge">
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/list-add.png</normaloff>:/images/22x22/list-add.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="btnRemoveBridge">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Remove the selected bridges from the list</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/list-remove.png</normaloff>:/images/22x22/list-remove.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="btnCopyBridge">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Copy the selected bridges to the clipboard</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/edit-copy.png</normaloff>:/images/22x22/edit-copy.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <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>
+ <spacer>
+ <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>
- <item>
+ <item row="2" column="0">
+ <widget class="QListWidget" name="listBridges">
+ <property name="contextMenuPolicy">
+ <enum>Qt::CustomContextMenu</enum>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lblHelpFindBridges">
@@ -395,14 +396,15 @@
<tabstop>lineProxyPort</tabstop>
<tabstop>lineProxyUsername</tabstop>
<tabstop>lineProxyPassword</tabstop>
+ <tabstop>cmboProxyType</tabstop>
<tabstop>chkFascistFirewall</tabstop>
<tabstop>lineReachablePorts</tabstop>
<tabstop>chkUseBridges</tabstop>
- <tabstop>lineBridge</tabstop>
+ <tabstop>teBridges</tabstop>
<tabstop>btnAddBridge</tabstop>
+ <tabstop>listBridges</tabstop>
<tabstop>btnRemoveBridge</tabstop>
<tabstop>btnCopyBridge</tabstop>
- <tabstop>listBridges</tabstop>
</tabstops>
<resources>
<include location="../res/vidalia.qrc"/>
diff --git a/src/vidalia/config/NetworkSettings.cpp b/src/vidalia/config/NetworkSettings.cpp
index 21c41c7..3628772 100644
--- a/src/vidalia/config/NetworkSettings.cpp
+++ b/src/vidalia/config/NetworkSettings.cpp
@@ -145,6 +145,8 @@ NetworkSettings::apply(QString *errmsg)
if (useBridges && !bridges.isEmpty()) {
torrc->setValue(SETTING_USE_BRIDGES, "1");
torrc->setValue(SETTING_UPDATE_BRIDGES, "1");
+ /* Clear the old bridge lines to be have the new value. */
+ torrc->clear(QStringList() << SETTING_BRIDGE_LIST);
foreach (QString bridge, bridges) {
torrc->setValue(SETTING_BRIDGE_LIST, bridge);
}