From 3e98bd49e220438f7429b9004e89d1716be1117f Mon Sep 17 00:00:00 2001 From: Nick Tiskov Date: Sun, 13 Jan 2013 17:44:14 +0400 Subject: [PATCH 1/2] Show human readable interface names (mostly affects Windows) --- src/preferences/advancedsettings.h | 16 ++++++++++++++++ src/preferences/preferences.h | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index b56823c47..1bb299273 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -89,8 +89,16 @@ public slots: if (combo_iface.currentIndex() == 0) { // All interfaces (default) pref.setNetworkInterface(QString::null); +#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) + pref.setNetworkInterfaceName(QString::null); +#endif } else { +#if QT_VERSION < QT_VERSION_CHECK(4,5,0) pref.setNetworkInterface(combo_iface.currentText()); +#else + pref.setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString()); + pref.setNetworkInterfaceName(combo_iface.currentText()); +#endif } // Network address QHostAddress addr(txt_network_address.text().trimmed()); @@ -213,7 +221,11 @@ private slots: int i = 1; foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) { if (iface.flags() & QNetworkInterface::IsLoopBack) continue; +#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) + combo_iface.addItem(iface.humanReadableName(),iface.name()); +#else combo_iface.addItem(iface.name()); +#endif if (!current_iface.isEmpty() && iface.name() == current_iface) { combo_iface.setCurrentIndex(i); interface_exists = true; @@ -222,7 +234,11 @@ private slots: } // Saved interface does not exist, show it anyway if (!interface_exists) { +#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) + combo_iface.addItem(pref.getNetworkInterfaceName(),current_iface); +#else combo_iface.addItem(current_iface); +#endif combo_iface.setCurrentIndex(i); } setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface); diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 0d219ba36..d47533b79 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -1042,6 +1042,16 @@ public: QString getNetworkInterface() const { return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString(); } + +#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) + void setNetworkInterfaceName(const QString& iface) { + setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface); + } + + QString getNetworkInterfaceName() const { + return value(QString::fromUtf8("Preferences/Connection/InterfaceName"), QString()).toString(); + } +#endif void setNetworkAddress(const QString& addr) { setValue(QString::fromUtf8("Preferences/Connection/InetAddress"), addr); From 104b2aecdc18a52abe7afd2c3078086a86f3ceb4 Mon Sep 17 00:00:00 2001 From: Nick Tiskov Date: Sat, 26 Jan 2013 21:24:38 +0400 Subject: [PATCH 2/2] fixup! Show human readable interface names (mostly affects Windows) --- src/preferences/advancedsettings.h | 14 -------------- src/preferences/preferences.h | 2 -- 2 files changed, 16 deletions(-) diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index 1bb299273..06dcf69a4 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -89,16 +89,10 @@ public slots: if (combo_iface.currentIndex() == 0) { // All interfaces (default) pref.setNetworkInterface(QString::null); -#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) pref.setNetworkInterfaceName(QString::null); -#endif } else { -#if QT_VERSION < QT_VERSION_CHECK(4,5,0) - pref.setNetworkInterface(combo_iface.currentText()); -#else pref.setNetworkInterface(combo_iface.itemData(combo_iface.currentIndex()).toString()); pref.setNetworkInterfaceName(combo_iface.currentText()); -#endif } // Network address QHostAddress addr(txt_network_address.text().trimmed()); @@ -221,11 +215,7 @@ private slots: int i = 1; foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) { if (iface.flags() & QNetworkInterface::IsLoopBack) continue; -#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) combo_iface.addItem(iface.humanReadableName(),iface.name()); -#else - combo_iface.addItem(iface.name()); -#endif if (!current_iface.isEmpty() && iface.name() == current_iface) { combo_iface.setCurrentIndex(i); interface_exists = true; @@ -234,11 +224,7 @@ private slots: } // Saved interface does not exist, show it anyway if (!interface_exists) { -#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) combo_iface.addItem(pref.getNetworkInterfaceName(),current_iface); -#else - combo_iface.addItem(current_iface); -#endif combo_iface.setCurrentIndex(i); } setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface); diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index d47533b79..53afceb65 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -1043,7 +1043,6 @@ public: return value(QString::fromUtf8("Preferences/Connection/Interface"), QString()).toString(); } -#if QT_VERSION >= QT_VERSION_CHECK(4,5,0) void setNetworkInterfaceName(const QString& iface) { setValue(QString::fromUtf8("Preferences/Connection/InterfaceName"), iface); } @@ -1051,7 +1050,6 @@ public: QString getNetworkInterfaceName() const { return value(QString::fromUtf8("Preferences/Connection/InterfaceName"), QString()).toString(); } -#endif void setNetworkAddress(const QString& addr) { setValue(QString::fromUtf8("Preferences/Connection/InetAddress"), addr);