mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr965'
This commit is contained in:
commit
75331af311
16
src/core.cpp
16
src/core.cpp
|
@ -121,7 +121,7 @@ void Core::make_tox()
|
|||
// IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options.
|
||||
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
|
||||
bool forceTCP = Settings::getInstance().getForceTCP();
|
||||
bool useProxy = Settings::getInstance().getUseProxy();
|
||||
ProxyType proxyType = Settings::getInstance().getProxyType();
|
||||
|
||||
if (enableIPv6)
|
||||
qDebug() << "Core starting with IPv6 enabled";
|
||||
|
@ -133,11 +133,11 @@ void Core::make_tox()
|
|||
toxOptions.udp_disabled = forceTCP;
|
||||
|
||||
// No proxy by default
|
||||
toxOptions.proxy_enabled = false;
|
||||
toxOptions.proxy_type = TOX_PROXY_NONE;
|
||||
toxOptions.proxy_address[0] = 0;
|
||||
toxOptions.proxy_port = 0;
|
||||
|
||||
if (useProxy)
|
||||
if (proxyType != ProxyType::ptNone)
|
||||
{
|
||||
QString proxyAddr = Settings::getInstance().getProxyAddr();
|
||||
int proxyPort = Settings::getInstance().getProxyPort();
|
||||
|
@ -149,7 +149,11 @@ void Core::make_tox()
|
|||
else if (proxyAddr != "" && proxyPort > 0)
|
||||
{
|
||||
qDebug() << "Core: using proxy" << proxyAddr << ":" << proxyPort;
|
||||
toxOptions.proxy_enabled = true;
|
||||
// protection against changings in TOX_PROXY_TYPE enum
|
||||
if (proxyType == ProxyType::ptSOCKS5)
|
||||
toxOptions.proxy_type = TOX_PROXY_SOCKS5;
|
||||
else if (proxyType == ProxyType::ptHTTP)
|
||||
toxOptions.proxy_type = TOX_PROXY_HTTP;
|
||||
uint16_t sz = CString::fromString(proxyAddr, (unsigned char*)toxOptions.proxy_address);
|
||||
toxOptions.proxy_address[sz] = 0;
|
||||
toxOptions.proxy_port = proxyPort;
|
||||
|
@ -165,7 +169,7 @@ void Core::make_tox()
|
|||
tox = tox_new(&toxOptions);
|
||||
if (tox == nullptr)
|
||||
{
|
||||
if (toxOptions.proxy_enabled)
|
||||
if (toxOptions.proxy_type != TOX_PROXY_NONE)
|
||||
{
|
||||
//QMessageBox::critical(Widget::getInstance(), tr("Proxy failure", "popup title"),
|
||||
//tr("toxcore failed to start with your proxy settings. qTox cannot run; please modify your "
|
||||
|
@ -183,7 +187,7 @@ void Core::make_tox()
|
|||
else
|
||||
qWarning() << "Core failed to start with IPv6, falling back to IPv4. LAN discovery may not work properly.";
|
||||
}
|
||||
else if (toxOptions.proxy_enabled)
|
||||
else if (toxOptions.proxy_type != TOX_PROXY_NONE)
|
||||
{
|
||||
emit badProxy();
|
||||
return;
|
||||
|
|
|
@ -130,7 +130,7 @@ void Settings::load()
|
|||
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||
closeToTray = s.value("closeToTray", false).toBool();
|
||||
forceTCP = s.value("forceTCP", false).toBool();
|
||||
useProxy = s.value("useProxy", false).toBool();
|
||||
setProxyType(s.value("proxyType", static_cast<int>(ProxyType::ptNone)).toInt());
|
||||
proxyAddr = s.value("proxyAddr", "").toString();
|
||||
proxyPort = s.value("proxyPort", 0).toInt();
|
||||
currentProfile = s.value("currentProfile", "").toString();
|
||||
|
@ -282,7 +282,7 @@ void Settings::save(QString path, bool writeFriends)
|
|||
s.setValue("showSystemTray", showSystemTray);
|
||||
s.setValue("autostartInTray",autostartInTray);
|
||||
s.setValue("closeToTray", closeToTray);
|
||||
s.setValue("useProxy", useProxy);
|
||||
s.setValue("proxyType", static_cast<int>(proxyType));
|
||||
s.setValue("forceTCP", forceTCP);
|
||||
s.setValue("proxyAddr", proxyAddr);
|
||||
s.setValue("proxyPort", proxyPort);
|
||||
|
@ -584,13 +584,17 @@ void Settings::setForceTCP(bool newValue)
|
|||
forceTCP = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getUseProxy() const
|
||||
ProxyType Settings::getProxyType() const
|
||||
{
|
||||
return useProxy;
|
||||
return proxyType;
|
||||
}
|
||||
void Settings::setUseProxy(bool newValue)
|
||||
|
||||
void Settings::setProxyType(int newValue)
|
||||
{
|
||||
useProxy = newValue;
|
||||
if (newValue >= 0 && newValue <= 2)
|
||||
proxyType = static_cast<ProxyType>(newValue);
|
||||
else
|
||||
proxyType = ProxyType::ptNone;
|
||||
}
|
||||
|
||||
QString Settings::getProxyAddr() const
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
struct ToxID;
|
||||
namespace Db { enum class syncType; }
|
||||
|
||||
enum ProxyType {ptNone, ptSOCKS5, ptHTTP};
|
||||
|
||||
class Settings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -89,8 +91,8 @@ public:
|
|||
QString getProxyAddr() const;
|
||||
void setProxyAddr(const QString& newValue);
|
||||
|
||||
bool getUseProxy() const;
|
||||
void setUseProxy(bool newValue);
|
||||
ProxyType getProxyType() const;
|
||||
void setProxyType(int newValue);
|
||||
|
||||
int getProxyPort() const;
|
||||
void setProxyPort(int newValue);
|
||||
|
@ -257,7 +259,7 @@ private:
|
|||
|
||||
bool forceTCP;
|
||||
|
||||
bool useProxy;
|
||||
ProxyType proxyType;
|
||||
QString proxyAddr;
|
||||
int proxyPort;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void AddFriendForm::onSendTriggered()
|
|||
this->toxId.clear();
|
||||
this->message.clear();
|
||||
} else {
|
||||
if (Settings::getInstance().getUseProxy())
|
||||
if (Settings::getInstance().getProxyType() != ProxyType::ptNone)
|
||||
{
|
||||
QMessageBox::StandardButton btn = QMessageBox::warning(main, "qTox", tr("qTox needs to use the Tox DNS, but can't do it through a proxy.\n\
|
||||
Ignore the proxy and connect to the Internet directly?"), QMessageBox::Ok|QMessageBox::No, QMessageBox::No);
|
||||
|
|
|
@ -111,7 +111,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
if (port != -1)
|
||||
bodyUI->proxyPort->setValue(port);
|
||||
|
||||
bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy());
|
||||
bodyUI->proxyType->setCurrentIndex(static_cast<int>(Settings::getInstance().getProxyType()));
|
||||
onUseProxyUpdated();
|
||||
|
||||
//general
|
||||
|
@ -139,7 +139,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
//connection
|
||||
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
|
||||
connect(bodyUI->cbEnableUDP, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
|
||||
connect(bodyUI->cbUseProxy, &QCheckBox::stateChanged, this, &GeneralForm::onUseProxyUpdated);
|
||||
connect(bodyUI->proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(onUseProxyUpdated()));
|
||||
connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited);
|
||||
connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int)));
|
||||
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
|
||||
|
@ -286,11 +286,11 @@ void GeneralForm::onProxyPortEdited(int port)
|
|||
|
||||
void GeneralForm::onUseProxyUpdated()
|
||||
{
|
||||
bool state = bodyUI->cbUseProxy->isChecked();
|
||||
int proxytype = bodyUI->proxyType->currentIndex();
|
||||
|
||||
bodyUI->proxyAddr->setEnabled(state);
|
||||
bodyUI->proxyPort->setEnabled(state);
|
||||
Settings::getInstance().setUseProxy(state);
|
||||
bodyUI->proxyAddr->setEnabled(proxytype);
|
||||
bodyUI->proxyPort->setEnabled(proxytype);
|
||||
Settings::getInstance().setProxyType(proxytype);
|
||||
}
|
||||
|
||||
void GeneralForm::onReconnectClicked()
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>513</width>
|
||||
<height>819</height>
|
||||
<y>-173</y>
|
||||
<width>511</width>
|
||||
<height>797</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
|
@ -216,6 +216,9 @@
|
|||
<property name="toolTip">
|
||||
<string>Set to 0 to disable</string>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> minutes</string>
|
||||
</property>
|
||||
|
@ -225,9 +228,6 @@
|
|||
<property name="maximum">
|
||||
<number>2147483647</number>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -294,6 +294,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -317,23 +320,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="styleLabel">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="styleBrowser">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
|
||||
<property name="sizeConstraint">
|
||||
|
@ -391,6 +377,23 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="styleLabel">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="styleBrowser">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="themeColorLabel">
|
||||
<property name="text">
|
||||
|
@ -462,7 +465,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignTop">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="connectionGroup">
|
||||
<property name="title">
|
||||
<string>Connection Settings</string>
|
||||
|
@ -492,12 +495,41 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbUseProxy">
|
||||
<layout class="QHBoxLayout" name="proxyLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Use proxy (SOCKS5)</string>
|
||||
<string>Proxy type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="proxyType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SOCKS5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HTTP</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="proxyLayout">
|
||||
<property name="spacing">
|
||||
|
|
Loading…
Reference in New Issue
Block a user