allow to set https_proxy via preferences if not set via environment variable
This commit is contained in:
@ -862,6 +862,11 @@ General Settings:
|
||||
the plots in the *Charts* window in milliseconds. The default is to
|
||||
redraw the plots every 500 milliseconds. This is just for the drawing,
|
||||
data collection is managed with the previous setting.
|
||||
- *HTTPS proxy setting:* Allows to enter a URL for an HTTPS proxy. This
|
||||
may be needed when the LAMMPS input contains :doc:`geturl commands <geturl>`
|
||||
or for downloading tutorial files from the *Tutorials* menu. If the
|
||||
``https_proxy`` environment variable was set externally, its value is
|
||||
displayed but cannot be changed.
|
||||
|
||||
Accelerators:
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
@ -2,7 +2,6 @@ LAMMPS-GUI TODO list:
|
||||
|
||||
# Short term goals (v1.x)
|
||||
|
||||
- add a dialog to apply http(s) proxy settings for LAMMPS' geturl command
|
||||
- implement a timed "Auto-Save" feature that saves after some idle time. set timeout in Editor preferences.
|
||||
- add a "Filter data" checkbox to the "Charts" window to select whether data should be dropped.
|
||||
- add a "Charts tab" to the preferences with the following (default) settings:
|
||||
|
||||
@ -389,6 +389,11 @@ LammpsGui::LammpsGui(QWidget *parent, const QString &filename) :
|
||||
ui->textEdit->setReformatOnReturn(settings.value("return", false).toBool());
|
||||
ui->textEdit->setAutoComplete(settings.value("automatic", true).toBool());
|
||||
settings.endGroup();
|
||||
|
||||
// apply https proxy setting: prefer environment variable or fall back to preferences value
|
||||
auto https_proxy = QString::fromLocal8Bit(qgetenv("https_proxy"));
|
||||
if (https_proxy.isEmpty()) https_proxy = settings.value("https_proxy", "").toString();
|
||||
if (!https_proxy.isEmpty()) lammps.command(QString("shell putenv https_proxy=") + https_proxy);
|
||||
}
|
||||
|
||||
LammpsGui::~LammpsGui()
|
||||
@ -1238,6 +1243,11 @@ void LammpsGui::do_run(bool use_buffer)
|
||||
runner->setup_run(&lammps, nullptr, fname);
|
||||
}
|
||||
|
||||
// apply https proxy setting: prefer environment variable or fall back to preferences value
|
||||
auto https_proxy = QString::fromLocal8Bit(qgetenv("https_proxy"));
|
||||
if (https_proxy.isEmpty()) https_proxy = settings.value("https_proxy", "").toString();
|
||||
if (!https_proxy.isEmpty()) lammps.command(QString("shell putenv https_proxy=") + https_proxy);
|
||||
|
||||
connect(runner, &LammpsRunner::resultReady, this, &LammpsGui::run_done);
|
||||
connect(runner, &LammpsRunner::finished, runner, &QObject::deleteLater);
|
||||
runner->start();
|
||||
@ -2020,9 +2030,13 @@ void LammpsGui::setup_tutorial(int tutno, const QString &dir, bool purgedir, boo
|
||||
lammps.command("clear");
|
||||
lammps.command(QString("shell cd " + dir));
|
||||
|
||||
// apply https proxy setting: prefer environment variable or fall back to preferences value
|
||||
auto https_proxy = QString::fromLocal8Bit(qgetenv("https_proxy"));
|
||||
if (https_proxy.isEmpty()) https_proxy = QSettings().value("https_proxy", "").toString();
|
||||
if (!https_proxy.isEmpty()) lammps.command(QString("shell putenv https_proxy=") + https_proxy);
|
||||
|
||||
// download and process manifest for selected tutorial
|
||||
// must check for error after download, e.g. when there is no network.
|
||||
|
||||
lammps.command(geturl.arg(tutno).arg(".manifest"));
|
||||
if (lammps.has_error()) {
|
||||
lammps.get_last_error_message(errorbuf, BUFLEN);
|
||||
|
||||
@ -174,6 +174,9 @@ void Preferences::accept()
|
||||
spin = tabWidget->findChild<QSpinBox *>("updchart");
|
||||
if (spin) settings->setValue("updchart", spin->value());
|
||||
|
||||
field = tabWidget->findChild<QLineEdit *>("proxyval");
|
||||
if (field) settings->setValue("https_proxy", field->text());
|
||||
|
||||
if (need_relaunch) {
|
||||
QMessageBox msg(QMessageBox::Information, QString("Relaunching LAMMPS-GUI"),
|
||||
QString("LAMMPS library plugin path was changed.\n"
|
||||
@ -262,7 +265,7 @@ GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *pa
|
||||
connect(getallfont, &QPushButton::released, this, &GeneralTab::newallfont);
|
||||
connect(gettextfont, &QPushButton::released, this, &GeneralTab::newtextfont);
|
||||
|
||||
auto *freqlabel = new QLabel("Data update interval (ms)");
|
||||
auto *freqlabel = new QLabel("Data update interval (ms):");
|
||||
auto *freqval = new QSpinBox;
|
||||
freqval->setRange(1, 1000);
|
||||
freqval->setStepType(QAbstractSpinBox::AdaptiveDecimalStepType);
|
||||
@ -271,7 +274,7 @@ GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *pa
|
||||
gridlayout->addWidget(freqlabel, 1, 0);
|
||||
gridlayout->addWidget(freqval, 1, 1);
|
||||
|
||||
auto *chartlabel = new QLabel("Charts update interval (ms)");
|
||||
auto *chartlabel = new QLabel("Charts update interval (ms):");
|
||||
auto *chartval = new QSpinBox;
|
||||
chartval->setRange(1, 5000);
|
||||
chartval->setStepType(QAbstractSpinBox::AdaptiveDecimalStepType);
|
||||
@ -280,6 +283,19 @@ GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *pa
|
||||
gridlayout->addWidget(chartlabel, 2, 0);
|
||||
gridlayout->addWidget(chartval, 2, 1);
|
||||
|
||||
auto *proxylabel = new QLabel("HTTPS proxy setting (empty for no proxy):");
|
||||
gridlayout->addWidget(proxylabel, 3, 0);
|
||||
|
||||
auto https_proxy = QString::fromLocal8Bit(qgetenv("https_proxy"));
|
||||
if (https_proxy.isEmpty()) {
|
||||
https_proxy = settings->value("https_proxy", "").toString();
|
||||
auto *proxyedit = new QLineEdit(https_proxy);
|
||||
proxyedit->setObjectName("proxyval");
|
||||
gridlayout->addWidget(proxyedit, 3, 1);
|
||||
} else {
|
||||
gridlayout->addWidget(new QLabel(https_proxy), 3, 1);
|
||||
}
|
||||
|
||||
layout->addWidget(echo);
|
||||
layout->addWidget(cite);
|
||||
layout->addWidget(logv);
|
||||
|
||||
Reference in New Issue
Block a user