# HG changeset patch # User Torsten Lilge # Date 1591383022 -7200 # Node ID ed8d11b1027d6254497a8cdd36b9c872ed3e6599 # Parent 99ffd1058beca0de5fc2319b8c8a010a2efc842e reorganize network preferences in settings dialog * gui-preferences-global.h: new lists with proxy types and flags for those requiring manual input from the user in the dialog * settings-dialog.cc (settings_dialog): fill the combo box of proxy types witht the list defined in gui-preferences, connect signal for des-/enabling dialog elements depending on changed selections, new names for the elements avoiding camel-case (proxy_items_update): slot for changes in proxy settings, des-/enabling the line edits for the proxy accordingly (write_changed_settings): new variable names * settings-dialog.h: new slot proxy_items_update * settings-dialog.ui: reordering network preferences in groups, new variable names for proxy settings, removed realted signals and slots for dis-/enabling elements which are now in settings_dialog diff -r 99ffd1058bec -r ed8d11b1027d libgui/src/gui-preferences-global.h --- a/libgui/src/gui-preferences-global.h Fri Jun 05 11:40:49 2020 -0400 +++ b/libgui/src/gui-preferences-global.h Fri Jun 05 20:50:22 2020 +0200 @@ -126,4 +126,13 @@ const gui_pref global_proxy_pass ("proxyPassword", QVariant (QString ())); +const QStringList +global_proxy_all_types (QStringList () + << QT_TRANSLATE_NOOP ("octave::settings_dialog", "HttpProxy") + << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Socks5Proxy") +// << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Environment Varaibles") +); +const QList +global_proxy_manual_types (QList () << 0 << 1); + #endif diff -r 99ffd1058bec -r ed8d11b1027d libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Fri Jun 05 11:40:49 2020 -0400 +++ b/libgui/src/settings-dialog.cc Fri Jun 05 20:50:22 2020 +0200 @@ -397,21 +397,33 @@ le_file_browser_extensions->setText (settings->value (fb_txt_file_ext).toString ()); checkbox_allow_web_connect->setChecked (settings->value (nr_allow_connection).toBool ()); - useProxyServer->setChecked ( - settings->value (global_use_proxy.key, global_use_proxy.def).toBool ()); - proxyHostName->setText (settings->value (global_proxy_host.key, global_proxy_host.def).toString ()); - int currentIndex = 0; - QString proxyTypeString = settings->value (global_proxy_type.key, global_proxy_type.def).toString (); - while ((currentIndex < proxyType->count ()) - && (proxyType->currentText () != proxyTypeString)) + // Proxy + bool use_proxy = settings->value (global_use_proxy.key, global_use_proxy.def).toBool (); + use_proxy_server->setChecked (use_proxy); + // Fill combo box and activate current one + QString proxy_type_string = settings->value (global_proxy_type.key, global_proxy_type.def).toString (); + proxy_type->addItems (global_proxy_all_types); + for (int i = 0; i < global_proxy_all_types.length (); i++) { - currentIndex++; - proxyType->setCurrentIndex (currentIndex); + if (proxy_type->itemText (i) == proxy_type_string) + { + proxy_type->setCurrentIndex (i); + break; + } } - proxyPort->setText (settings->value (global_proxy_port.key, global_proxy_port.def).toString ()); - proxyUserName->setText (settings->value (global_proxy_user.key, global_proxy_user.def).toString ()); - proxyPassword->setText (settings->value (global_proxy_pass.key, global_proxy_pass.def).toString ()); + // Fill all line edits + proxy_host_name->setText (settings->value (global_proxy_host.key, global_proxy_host.def).toString ()); + proxy_port->setText (settings->value (global_proxy_port.key, global_proxy_port.def).toString ()); + proxy_username->setText (settings->value (global_proxy_user.key, global_proxy_user.def).toString ()); + proxy_password->setText (settings->value (global_proxy_pass.key, global_proxy_pass.def).toString ()); + // Connect relevant signals for dis-/enabling some elements + connect (proxy_type, SIGNAL (currentIndexChanged (int)), + this, SLOT (proxy_items_update (void))); + connect (use_proxy_server, SIGNAL (toggled (bool)), + this, SLOT (proxy_items_update (void))); + // Check whehter line edits have to be enabled + proxy_items_update (); // Workspace read_workspace_colors (settings); @@ -596,6 +608,32 @@ } } + // slot for updating enabled state of proxy settings + void settings_dialog::proxy_items_update (void) + { + bool use_proxy = use_proxy_server->isChecked (); + + bool manual = false; + for (int i = 0; i < global_proxy_manual_types.length (); i++) + { + if (proxy_type->currentIndex () == global_proxy_manual_types.at (i)) + { + manual = true; + break; + } + } + + proxy_type->setEnabled (use_proxy); + proxy_host_name_label->setEnabled (use_proxy && manual); + proxy_host_name->setEnabled (use_proxy && manual); + proxy_port_label->setEnabled (use_proxy && manual); + proxy_port->setEnabled (use_proxy && manual); + proxy_username_label->setEnabled (use_proxy && manual); + proxy_username->setEnabled (use_proxy && manual); + proxy_password_label->setEnabled (use_proxy && manual); + proxy_password->setEnabled (use_proxy && manual); + } + // slots for import/export of shortcut sets void settings_dialog::import_shortcut_set (void) @@ -951,12 +989,12 @@ settings->setValue (fb_txt_file_ext.key, le_file_browser_extensions->text ()); settings->setValue (nr_allow_connection.key, checkbox_allow_web_connect->isChecked ()); - settings->setValue (global_use_proxy.key, useProxyServer->isChecked ()); - settings->setValue (global_proxy_type.key, proxyType->currentText ()); - settings->setValue (global_proxy_host.key, proxyHostName->text ()); - settings->setValue (global_proxy_port.key, proxyPort->text ()); - settings->setValue (global_proxy_user.key, proxyUserName->text ()); - settings->setValue (global_proxy_pass.key, proxyPassword->text ()); + settings->setValue (global_use_proxy.key, use_proxy_server->isChecked ()); + settings->setValue (global_proxy_type.key, proxy_type->currentText ()); + settings->setValue (global_proxy_host.key, proxy_host_name->text ()); + settings->setValue (global_proxy_port.key, proxy_port->text ()); + settings->setValue (global_proxy_user.key, proxy_username->text ()); + settings->setValue (global_proxy_pass.key, proxy_password->text ()); settings->setValue (cs_cursor_use_fgcol.key, terminal_cursorUseForegroundColor->isChecked ()); settings->setValue (mw_dir_list.key, terminal_focus_command->isChecked ()); settings->setValue (cs_dbg_location.key, terminal_print_dbg_location->isChecked ()); diff -r 99ffd1058bec -r ed8d11b1027d libgui/src/settings-dialog.h --- a/libgui/src/settings-dialog.h Fri Jun 05 11:40:49 2020 -0400 +++ b/libgui/src/settings-dialog.h Fri Jun 05 20:50:22 2020 +0200 @@ -65,6 +65,7 @@ void get_file_browser_dir (void); void get_dir (QLineEdit*, const QString&); void set_disabled_pref_file_browser_dir (bool disable); + void proxy_items_update (void); // slots for dialog's buttons void button_clicked (QAbstractButton *button); diff -r 99ffd1058bec -r ed8d11b1027d libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Fri Jun 05 11:40:49 2020 -0400 +++ b/libgui/src/settings-dialog.ui Fri Jun 05 20:50:22 2020 +0200 @@ -32,7 +32,7 @@ - 2 + 7 @@ -841,7 +841,7 @@ 0 - -898 + 0 1021 1529 @@ -2829,124 +2829,151 @@ - - - - - Allow Octave to connect to the Octave web site to display current news and information - - - - - - - - - false - - - Hostname: - - - - - - - false - - - - HttpProxy - - - - - Socks5Proxy - - - - - - - - false - - - Username: - - - - - - - Use proxy server - - - - - - - false - - - Proxy type: - - - - - - - false - - - Port: - - - - - - - false - - - Password: - - - - - - - false - - - - - - - false - - - - - - - false - - - - - - - false - - - QLineEdit::Password - - - - - - + + + General + + + + + + Allow Octave to connect to the Octave web site to display current news and information + + + + + + + + + + Proxy Server + + + + + + + + + + false + + + Hostname: + + + + + + + true + + + <html><head/><body><p>Select <span style=" font-style:italic;">HttpProxy</span>, <span style=" font-style:italic;">Sock5Proxy</span> or <span style=" font-style:italic;">Environment Variables</span>. With the last selection, the proxy is taken from the first non-empty environment variable ALL_PROXY, HTTP_PROXY or HTTPS_PROXY .</p></body></html> + + + + + + + false + + + Username: + + + + + + + true + + + Proxy type: + + + + + + + false + + + Port: + + + + + + + false + + + Password: + + + + + + + false + + + + + + + false + + + + + + + false + + + + + + + false + + + QLineEdit::Password + + + + + + + Use proxy server + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + @@ -2981,102 +3008,6 @@ - useProxyServer - toggled(bool) - label_4 - setEnabled(bool) - - - 249 - 59 - - - 69 - 122 - - - - - useProxyServer - toggled(bool) - label_3 - setEnabled(bool) - - - 249 - 59 - - - 59 - 91 - - - - - useProxyServer - toggled(bool) - proxyHostName - setEnabled(bool) - - - 249 - 59 - - - 291 - 124 - - - - - useProxyServer - toggled(bool) - label_5 - setEnabled(bool) - - - 249 - 59 - - - 44 - 152 - - - - - useProxyServer - toggled(bool) - proxyType - setEnabled(bool) - - - 249 - 59 - - - 291 - 91 - - - - - useProxyServer - toggled(bool) - proxyPort - setEnabled(bool) - - - 249 - 59 - - - 364 - 154 - - - - useCustomFileEditor toggled(bool) customFileEditor @@ -3093,70 +3024,6 @@ - useProxyServer - toggled(bool) - label_7 - setEnabled(bool) - - - 249 - 59 - - - 67 - 212 - - - - - useProxyServer - toggled(bool) - label_6 - setEnabled(bool) - - - 249 - 59 - - - 68 - 182 - - - - - useProxyServer - toggled(bool) - proxyPassword - setEnabled(bool) - - - 249 - 59 - - - 364 - 214 - - - - - useProxyServer - toggled(bool) - proxyUserName - setEnabled(bool) - - - 249 - 59 - - - 364 - 184 - - - - useCustomFileEditor toggled(bool) customEditorLabel