diff --git a/doc/src/Howto_lammps_gui.rst b/doc/src/Howto_lammps_gui.rst index c8f6bd0505..adf0c836fb 100644 --- a/doc/src/Howto_lammps_gui.rst +++ b/doc/src/Howto_lammps_gui.rst @@ -726,7 +726,7 @@ Tutorials The *Tutorials* menu is to support the set of LAMMPS tutorials for beginners and intermediate LAMMPS users documented in (:ref:`Gravelle1 -`). From the dropdown menu you can select which of the eight +`). From the drop down menu you can select which of the eight currently available tutorial sessions you want to start and then will be taken to a 'wizard' dialog where you can choose in which folder you want to work, whether you want that folder to be cleared, and also whether @@ -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 ` + 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: ^^^^^^^^^^^^^ diff --git a/tools/lammps-gui/TODO.md b/tools/lammps-gui/TODO.md index 3f95dec6a0..b978931f0c 100644 --- a/tools/lammps-gui/TODO.md +++ b/tools/lammps-gui/TODO.md @@ -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: diff --git a/tools/lammps-gui/lammpsgui.cpp b/tools/lammps-gui/lammpsgui.cpp index 003345de57..09a180683d 100644 --- a/tools/lammps-gui/lammpsgui.cpp +++ b/tools/lammps-gui/lammpsgui.cpp @@ -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); diff --git a/tools/lammps-gui/preferences.cpp b/tools/lammps-gui/preferences.cpp index ab6397f7bd..aba3d9d61c 100644 --- a/tools/lammps-gui/preferences.cpp +++ b/tools/lammps-gui/preferences.cpp @@ -174,6 +174,9 @@ void Preferences::accept() spin = tabWidget->findChild("updchart"); if (spin) settings->setValue("updchart", spin->value()); + field = tabWidget->findChild("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);