Changeset 9b513f6 in confclerk_git


Ignore:
Timestamp:
10/05/17 22:50:44 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master
Children:
e618f18
Parents:
68efead
Message:

AppSettings? returns the proxy type as QNetworkProxy instead of int now.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/app/appsettings.cpp

    r68efead r9b513f6  
    3737}
    3838
    39 //QNetworkProxy::ProxyType
    40 int AppSettings::proxyType()
     39QNetworkProxy::ProxyType AppSettings::proxyType()
    4140{
    42     return mSettings.value(PROXY_TYPE_SETTING).toInt();
     41    bool ok;
     42    int proxyType = mSettings.value(PROXY_TYPE_SETTING).toInt(&ok);
     43    if (!ok || proxyType < 0 || proxyType > 5) return QNetworkProxy::DefaultProxy;
     44    return QNetworkProxy::ProxyType(proxyType);
    4345}
    4446
     
    5860}
    5961
    60 // QNetworkProxy::ProxyType
    61 void AppSettings::setProxyType(const int aType)
     62void AppSettings::setProxyType(QNetworkProxy::ProxyType aProxyType)
    6263{
    63     mSettings.setValue(PROXY_TYPE_SETTING, aType);
     64    mSettings.setValue(PROXY_TYPE_SETTING, aProxyType);
    6465}
    6566
  • src/app/appsettings.h

    r68efead r9b513f6  
    3737        static QString proxyAddress();
    3838        static quint16 proxyPort();
    39         static int proxyType(); // QNetworkProxy::ProxyType
     39        static QNetworkProxy::ProxyType proxyType();
    4040        static bool isDirectConnection();
    4141
    4242        static void setProxyAddress(const QString &aAddress);
    4343        static void setProxyPort(const quint16 aPort);
    44         static void setProxyType(const int aProxyType); // QNetworkProxy::ProxyType
     44        static void setProxyType(QNetworkProxy::ProxyType aProxyType);
    4545        static void setDirectConnection(bool aDirectConnection);
    4646        static int preEventAlarmSec() {return 60*15;} ///< seconds that alarm should ring before an event starts
  • src/gui/settingsdialog.cpp

    r68efead r9b513f6  
    3636    address->setText(AppSettings::proxyAddress());
    3737    port->setValue(AppSettings::proxyPort());
    38     const int proxyType = AppSettings::proxyType(); // QNetworkProxy::ProxyType
    39     proxyTypeHTTP->setChecked(proxyType != 1); // HTTP=3, but we enable it by default, i.e. unless SOCKS5=1
    40     proxyTypeSOCKS5->setChecked(proxyType == 1);
     38    const QNetworkProxy::ProxyType proxyType = AppSettings::proxyType();
     39    proxyTypeHTTP->setChecked(proxyType != QNetworkProxy::Socks5Proxy); // we enable it by default unless SOCKS5=1
     40    proxyTypeSOCKS5->setChecked(proxyType == QNetworkProxy::Socks5Proxy);
    4141    directConnection->setChecked(AppSettings::isDirectConnection());
    4242    proxyWidget->setDisabled(directConnection->isChecked());
     
    4949    AppSettings::setProxyAddress(address->text());
    5050    AppSettings::setProxyPort(port->value());
    51     AppSettings::setProxyType(proxyTypeHTTP->isChecked() ? 3 : proxyTypeSOCKS5->isChecked() ? 1 : 0);
     51    AppSettings::setProxyType(proxyTypeHTTP->isChecked() ? QNetworkProxy::HttpProxy : proxyTypeSOCKS5->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::DefaultProxy);
    5252    AppSettings::setDirectConnection(directConnection->isChecked());
    5353}
Note: See TracChangeset for help on using the changeset viewer.