from PyQt5 import QtCore, QtWidgets, QtGui
+
class Settings(QtWidgets.QMainWindow):
"""
Settings window.
"""
- def __init__(self, common):
+ def __init__(self, common, app):
super(Settings, self).__init__()
self.common = common
+ self.app = app
# Set up the window
self.setWindowTitle(_("Tor Browser Launcher Settings"))
self.setWindowIcon(QtGui.QIcon(self.common.paths['icon_file']))
# Download over system tor
- self.tor_download_checkbox = QtWidgets.QCheckBox()
- self.tor_download_checkbox.setText(_("Download over system Tor"))
-
- try:
- import txsocksx
- self.txsocks_found = True
- except ImportError:
- self.txsocks_found = False
-
- if self.txsocks_found:
- self.tor_download_checkbox.setToolTip(_("This option is only available when using a system wide Tor installation."))
+ self.tor_download_checkbox = QtWidgets.QCheckBox(_("Download over system Tor"))
+ if self.common.settings['download_over_tor']:
+ self.tor_download_checkbox.setCheckState(QtCore.Qt.Checked)
else:
- self.tor_download_checkbox.setToolTip(_("This option requires the python-txsocksx package."))
- self.tor_download_checkbox.setEnabled(False)
-
- self.tor_download_checkbox.setCheckState(self.common.settings['download_over_tor'] and self.txsocks_found)
-
- # Modem sound
- self.modem_checkbox = QtWidgets.QCheckBox()
- self.modem_checkbox.setText(_("Play modem sound, because Tor is slow :]"))
-
- try:
- import pygame
- self.modem_checkbox.setCheckState(bool(self.common.settings['modem_sound']))
- except ImportError:
- self.modem_checkbox.setCheckState(False)
- self.modem_checkbox.setEnabled(False)
- self.modem_checkbox.setToolTip(_("This option requires python-pygame to be installed"))
+ self.tor_download_checkbox.setCheckState(QtCore.Qt.Unchecked)
# Force en-US, only display if language isn't already en-US
- self.force_en_checkbox = QtWidgets.QCheckBox()
- self.force_en_checkbox.setText(_("Force downloading English version of Tor Browser"))
- self.force_en_checkbox.setCheckState(bool(self.common.settings['force_en-US']))
+ self.force_en_checkbox = QtWidgets.QCheckBox(_("Force downloading English version of Tor Browser"))
+ if self.common.settings['force_en-US']:
+ self.force_en_checkbox.setCheckState(QtCore.Qt.Checked)
+ else:
+ self.force_en_checkbox.setCheckState(QtCore.Qt.Unchecked)
if self.common.language == 'en-US':
self.force_en_checkbox.hide()
# Settings layout
settings_layout = QtWidgets.QVBoxLayout()
settings_layout.addWidget(self.tor_download_checkbox)
- settings_layout.addWidget(self.modem_checkbox)
settings_layout.addWidget(self.force_en_checkbox)
settings_layout.addLayout(tor_addr_layout)
# Install button
install_button = QtWidgets.QPushButton(_("Install Tor Browser"))
+ install_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogApplyButton))
install_button.clicked.connect(self.install)
- # TODO: add apply icon
# Reinstall buttons
reinstall_button = QtWidgets.QPushButton(_("Reinstall Tor Browser"))
+ reinstall_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogApplyButton))
reinstall_button.clicked.connect(self.reinstall)
- # TODO: add apply icon
if(self.common.settings['installed']):
install_button.hide()
mirror_layout.addWidget(self.mirror)
# Save & Exit button
- self.save_exit_button = QtWidgets.QPushButton(_("Save & Exit"))
+ self.save_exit_button = QtWidgets.QPushButton(_("Save && Exit"))
+ self.save_exit_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogApplyButton))
self.save_exit_button.clicked.connect(self.save_exit)
- # TODO: add apply icon
# Cancel button
self.cancel_button = QtWidgets.QPushButton(_("Cancel"))
+ self.cancel_button.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DialogCancelButton))
self.cancel_button.clicked.connect(self.close)
- # TODO: add cancel icon
# Buttons layout
buttons_layout = QtWidgets.QHBoxLayout()
central_widget = QtWidgets.QWidget()
central_widget.setLayout(layout)
self.setCentralWidget(central_widget)
- self.show()
# Install
def install(self):
def save(self):
# Checkbox options
self.common.settings['download_over_tor'] = self.tor_download_checkbox.isChecked()
- self.common.settings['modem_sound'] = self.modem_checkbox.isChecked()
self.common.settings['force_en-US'] = self.force_en_checkbox.isChecked()
self.common.settings['tor_socks_address'] = self.tor_addr.text()