예제 #1
0
void NetworkSettings::loadProxySettings()
{
    // load current proxy settings
    Mirall::MirallConfigFile cfgFile;
    int type = cfgFile.proxyType();
    switch (type) {
    case QNetworkProxy::NoProxy:
        _ui->noProxyRadioButton->setChecked(true);
        break;
    case QNetworkProxy::DefaultProxy:
        _ui->systemProxyRadioButton->setChecked(true);
        break;
    case QNetworkProxy::Socks5Proxy:
    case QNetworkProxy::HttpProxy:
        _ui->typeComboBox->setCurrentIndex(_ui->typeComboBox->findData(type));
        _ui->manualProxyRadioButton->setChecked(true);
        break;
    default:
        break;
    }

    _ui->hostLineEdit->setText(cfgFile.proxyHostName());
    int port = cfgFile.proxyPort();
    if (port == 0)
        port = 8080;
    _ui->portSpinBox->setValue(port);
    if (!cfgFile.proxyUser().isEmpty())
    {
        _ui->authRequiredcheckBox->setChecked(true);
        _ui->userLineEdit->setText(cfgFile.proxyUser());
        _ui->passwordLineEdit->setText(cfgFile.proxyPassword());
    }
}
예제 #2
0
Mirall::ProxyDialog::ProxyDialog( QWidget* parent )
    : QDialog(parent)
{
    setupUi(this);

    // designer is buggy, so do it programmatically
    manualSettings->setEnabled(false);

#if QT_VERSION >= 0x040700
    hostLineEdit->setPlaceholderText(tr("Hostname of proxy server"));
    userLineEdit->setPlaceholderText(tr("Username for proxy server"));
    passwordLineEdit->setPlaceholderText(tr("Password for proxy server"));
#endif

    // load current proxy settings
    Mirall::MirallConfigFile cfgFile;
    if (cfgFile.proxyType() == QNetworkProxy::NoProxy)
        noProxyRadioButton->setChecked(true);
    if (cfgFile.proxyType() == QNetworkProxy::DefaultProxy)
        systemProxyRadioButton->setChecked(true);
    if (cfgFile.proxyType() == QNetworkProxy::Socks5Proxy)
    {
        manualProxyRadioButton->setChecked(true);
        hostLineEdit->setText(cfgFile.proxyHostName());
        portSpinBox->setValue(cfgFile.proxyPort());
        if (!cfgFile.proxyUser().isEmpty())
        {
            authRequiredcheckBox->setChecked(true);
            userLineEdit->setText(cfgFile.proxyUser());
            passwordLineEdit->setText(cfgFile.proxyPassword());
        }
    }
}