From 97fa1322025746d04813315992b7d87d6b782ce0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 14 Nov 2015 09:38:18 -0800 Subject: [PATCH] Move proxy initialization into shared code This way we can use the same code on desktop and mobile app. Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 11 ++--------- subsurface-core/qt-gui.h | 1 + subsurface-mobile-helper.cpp | 13 +++++++++++++ subsurface-mobile-main.cpp | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d31a2379f..632e32462 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -41,6 +41,7 @@ #include "windowtitleupdate.h" #include "locationinformation.h" #include "preferences/preferencesdialog.h" +#include "qt-gui.h" #ifndef NO_USERMANUAL #include "usermanual.h" @@ -1234,15 +1235,7 @@ void MainWindow::readSettings() default_dive_computer_device = getSetting(s, "dive_computer_device"); default_dive_computer_download_mode = s.value("dive_computer_download_mode").toInt(); s.endGroup(); - QNetworkProxy proxy; - proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type)); - proxy.setHostName(prefs.proxy_host); - proxy.setPort(prefs.proxy_port); - if (prefs.proxy_auth) { - proxy.setUser(prefs.proxy_user); - proxy.setPassword(prefs.proxy_pass); - } - QNetworkProxy::setApplicationProxy(proxy); + init_proxy(); // now make sure that the cloud menu items are enabled IFF cloud account is verified enableDisableCloudActions(); diff --git a/subsurface-core/qt-gui.h b/subsurface-core/qt-gui.h index ca038b145..bb381d1d3 100644 --- a/subsurface-core/qt-gui.h +++ b/subsurface-core/qt-gui.h @@ -5,6 +5,7 @@ void init_qt_late(); void init_ui(); +void init_proxy(); void run_ui(); void exit_ui(); diff --git a/subsurface-mobile-helper.cpp b/subsurface-mobile-helper.cpp index f7eaca10f..170317100 100644 --- a/subsurface-mobile-helper.cpp +++ b/subsurface-mobile-helper.cpp @@ -27,6 +27,19 @@ void init_ui() init_qt_late(); } +void init_proxy() +{ + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type)); + proxy.setHostName(prefs.proxy_host); + proxy.setPort(prefs.proxy_port); + if (prefs.proxy_auth) { + proxy.setUser(prefs.proxy_user); + proxy.setPassword(prefs.proxy_pass); + } + QNetworkProxy::setApplicationProxy(proxy); +} + void run_ui() { qmlRegisterType("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); diff --git a/subsurface-mobile-main.cpp b/subsurface-mobile-main.cpp index 4877f7e7e..6d412deed 100644 --- a/subsurface-mobile-main.cpp +++ b/subsurface-mobile-main.cpp @@ -57,6 +57,7 @@ int main(int argc, char **argv) taglist_init_global(); init_ui(); loadPreferences(); + init_proxy(); if (no_filenames) { if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) { QString defaultFile(prefs.default_filename);