diff --git a/aqt/preferences.py b/aqt/preferences.py index 795bc3ffa..ee6060c5c 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -86,9 +86,6 @@ class Preferences(QDialog): self.connect(self.form.syncDeauth, SIGNAL("clicked()"), self.onSyncDeauth) self.form.proxyHost.setText(self.prof['proxyHost']) - self.form.proxyPort.setValue(self.prof['proxyPort']) - self.form.proxyUser.setText(self.prof['proxyUser']) - self.form.proxyPass.setText(self.prof['proxyPass']) def _hideAuth(self): self.form.syncDeauth.setShown(False) @@ -104,9 +101,6 @@ Not currently enabled; click the sync button in the main window to enable.""")) self.prof['autoSync'] = self.form.syncOnProgramOpen.isChecked() self.prof['syncMedia'] = self.form.syncMedia.isChecked() self.prof['proxyHost'] = unicode(self.form.proxyHost.text()) - self.prof['proxyPort'] = int(self.form.proxyPort.value()) - self.prof['proxyUser'] = unicode(self.form.proxyUser.text()) - self.prof['proxyPass'] = unicode(self.form.proxyPass.text()) # Backup ###################################################################### diff --git a/aqt/profiles.py b/aqt/profiles.py index 8507caa5f..a31ae2403 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -12,6 +12,8 @@ from anki.db import DB from anki.utils import isMac, isWin, intTime, checksum from anki.lang import langs from aqt.utils import showWarning, fontForPlatform +from httplib2 import ProxyInfo +import anki.sync import aqt.forms metaConf = dict( @@ -51,10 +53,7 @@ profileConf = dict( syncKey=None, syncMedia=True, autoSync=True, - proxyHost='', - proxyPort=8080, - proxyUser='', - proxyPass='', + proxyHost='', # despite the name, stores full URL proxyType=3, ) @@ -140,6 +139,20 @@ computer.""")) if name != "_global": self.name = name self.profile = prof + # export proxy settings + if prof['proxyHost'] == "off": + # force off; override environment + anki.sync.HTTP_PROXY = None + elif prof['proxyHost']: + url = prof['proxyHost'] + if url.lower().startswith("https"): + method = "https" + else: + method = "http" + anki.sync.HTTP_PROXY = ProxyInfo.from_url(url, method) + else: + # use environment + anki.sync.HTTP_PROXY = ProxyInfo.from_environment() return True def save(self): diff --git a/designer/preferences.ui b/designer/preferences.ui index a78d4dfc9..4d22dbeef 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -251,7 +251,7 @@ - <b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below. Leave "Host" blank to disable proxy support. + <b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below. true @@ -266,63 +266,13 @@ - Host + URL - - - - Port - - - - - - - - 60 - 0 - - - - 1 - - - 65535 - - - 8080 - - - - - - - Username - - - - - - - - - - Password - - - - - - - QLineEdit::Password - - - @@ -486,9 +436,6 @@ syncOnProgramOpen syncDeauth proxyHost - proxyPort - proxyUser - proxyPass numBackups buttonBox tabWidget