diff --git a/.travis.yml b/.travis.yml index d4a7fae..378e5e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,7 @@ before_script: - sudo make install - echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf - sudo ldconfig + - cd .. script: - py.test tests/travis.py - py.test tests/tests.py diff --git a/toxygen/main.py b/toxygen/main.py index 232ad93..eca3ac3 100644 --- a/toxygen/main.py +++ b/toxygen/main.py @@ -9,7 +9,7 @@ __version__ = '0.5.0' def clean(): - """Removes all windows libs from libs folder""" + """Removes libs folder""" directory = util.get_libs_directory() util.remove(directory) @@ -25,10 +25,10 @@ def print_toxygen_version(): def main(): parser = argparse.ArgumentParser() parser.add_argument('--version', action='store_true', help='Prints Toxygen version') - parser.add_argument('--clean', action='store_true', help='Deletes toxcore libs from libs folder') - parser.add_argument('--reset', action='store_true', help='Resets default profile') - parser.add_argument('--uri', help='Adds specified TOX ID to friends') - parser.add_argument('profile', nargs='?', default=None, help='Path to TOX profile') + parser.add_argument('--clean', action='store_true', help='Delete toxcore libs from libs folder') + parser.add_argument('--reset', action='store_true', help='Reset default profile') + parser.add_argument('--uri', help='Add specified Tox ID to friends') + parser.add_argument('profile', nargs='?', default=None, help='Path to Tox profile') args = parser.parse_args() if args.version: diff --git a/toxygen/styles/dark_style.qss b/toxygen/styles/dark_style.qss index 714f946..3b2837b 100644 --- a/toxygen/styles/dark_style.qss +++ b/toxygen/styles/dark_style.qss @@ -1322,3 +1322,8 @@ ClickableLabel:hover { background-color: #4A4949; } + +#warningLabel +{ + color: #BC1C1C; +} diff --git a/toxygen/styles/style.qss b/toxygen/styles/style.qss index 26fbaf2..956ee63 100644 --- a/toxygen/styles/style.qss +++ b/toxygen/styles/style.qss @@ -27,3 +27,8 @@ MessageEdit { background-color: transparent; } + +#warningLabel +{ + color: #BC1C1C; +} diff --git a/toxygen/ui/menu.py b/toxygen/ui/menu.py index 6c9218c..07fbb85 100644 --- a/toxygen/ui/menu.py +++ b/toxygen/ui/menu.py @@ -254,82 +254,61 @@ class NetworkSettings(CenteredWidget): super().__init__() self._settings = settings self._reset = reset - self.initUI() - self.center() + uic.loadUi(get_views_path('network_settings_screen'), self) + self._update_ui() - def initUI(self): - self.setObjectName("NetworkSettings") - self.resize(300, 400) - self.setMinimumSize(QtCore.QSize(300, 400)) - self.setMaximumSize(QtCore.QSize(300, 400)) - self.setBaseSize(QtCore.QSize(300, 400)) - self.ipv = QtWidgets.QCheckBox(self) - self.ipv.setGeometry(QtCore.QRect(20, 10, 97, 22)) - self.ipv.setObjectName("ipv") - self.udp = QtWidgets.QCheckBox(self) - self.udp.setGeometry(QtCore.QRect(150, 10, 97, 22)) - self.udp.setObjectName("udp") - self.proxy = QtWidgets.QCheckBox(self) - self.proxy.setGeometry(QtCore.QRect(20, 40, 97, 22)) - self.http = QtWidgets.QCheckBox(self) - self.http.setGeometry(QtCore.QRect(20, 70, 97, 22)) - self.proxy.setObjectName("proxy") - self.proxyip = LineEdit(self) - self.proxyip.setGeometry(QtCore.QRect(40, 130, 231, 27)) - self.proxyip.setObjectName("proxyip") - self.proxyport = LineEdit(self) - self.proxyport.setGeometry(QtCore.QRect(40, 190, 231, 27)) - self.proxyport.setObjectName("proxyport") - self.label = QtWidgets.QLabel(self) - self.label.setGeometry(QtCore.QRect(40, 100, 66, 17)) - self.label_2 = QtWidgets.QLabel(self) - self.label_2.setGeometry(QtCore.QRect(40, 165, 66, 17)) - self.reconnect = QtWidgets.QPushButton(self) - self.reconnect.setGeometry(QtCore.QRect(40, 230, 231, 30)) - self.reconnect.clicked.connect(self.restart_core) - self.ipv.setChecked(self._settings['ipv6_enabled']) - self.udp.setChecked(self._settings['udp_enabled']) - self.proxy.setChecked(self._settings['proxy_type']) - self.proxyip.setText(self._settings['proxy_host']) - self.proxyport.setText(str(self._settings['proxy_port'])) - self.http.setChecked(self._settings['proxy_type'] == 1) - self.warning = QtWidgets.QLabel(self) - self.warning.setGeometry(QtCore.QRect(5, 270, 290, 60)) - self.warning.setStyleSheet('QLabel { color: #BC1C1C; }') - self.nodes = QtWidgets.QCheckBox(self) - self.nodes.setGeometry(QtCore.QRect(20, 350, 270, 22)) - self.nodes.setChecked(self._settings['download_nodes_list']) - self.retranslateUi() - self.proxy.stateChanged.connect(lambda x: self.activate()) - self.activate() - QtCore.QMetaObject.connectSlotsByName(self) + def _update_ui(self): + self.ipLineEdit = LineEdit(self) + self.ipLineEdit.setGeometry(100, 280, 270, 30) + self.portLineEdit = LineEdit(self) + self.portLineEdit.setGeometry(100, 325, 270, 30) + self.restartCorePushButton.clicked.connect(self._restart_core) + self.ipv6CheckBox.setChecked(self._settings['ipv6_enabled']) + self.udpCheckBox.setChecked(self._settings['udp_enabled']) + self.proxyCheckBox.setChecked(self._settings['proxy_type']) + self.ipLineEdit.setText(self._settings['proxy_host']) + self.portLineEdit.setText(str(self._settings['proxy_port'])) + self.httpProxyRadioButton.setChecked(self._settings['proxy_type'] == 1) + self.socksProxyRadioButton.setChecked(self._settings['proxy_type'] != 1) + self.downloadNodesCheckBox.setChecked(self._settings['download_nodes_list']) + self.lanCheckBox.setChecked(self._settings['lan_discovery']) + self._retranslate_ui() + self.proxyCheckBox.stateChanged.connect(lambda x: self._activate_proxy()) + self._activate_proxy() - def retranslateUi(self): + def _retranslate_ui(self): self.setWindowTitle(util_ui.tr("Network settings")) - self.ipv.setText(util_ui.tr("IPv6")) - self.udp.setText(util_ui.tr("UDP")) - self.proxy.setText(util_ui.tr("Proxy")) - self.label.setText(util_ui.tr("IP:")) - self.label_2.setText(util_ui.tr("Port:")) - self.reconnect.setText(util_ui.tr("Restart TOX core")) - self.http.setText(util_ui.tr("HTTP")) - self.nodes.setText(util_ui.tr("Download nodes list from tox.chat")) - self.warning.setText(util_ui.tr("WARNING:\nusing proxy with enabled UDP\ncan produce IP leak")) - - def activate(self): - bl = self.proxy.isChecked() - self.proxyip.setEnabled(bl) - self.http.setEnabled(bl) - self.proxyport.setEnabled(bl) - - def restart_core(self): + self.ipv6CheckBox.setText(util_ui.tr("IPv6")) + self.udpCheckBox.setText(util_ui.tr("UDP")) + self.lanCheckBox.setText(util_ui.tr("LAN")) + self.proxyCheckBox.setText(util_ui.tr("Proxy")) + self.ipLabel.setText(util_ui.tr("IP:")) + self.portLabel.setText(util_ui.tr("Port:")) + self.restartCorePushButton.setText(util_ui.tr("Restart TOX core")) + self.httpProxyRadioButton.setText(util_ui.tr("HTTP")) + self.socksProxyRadioButton.setText(util_ui.tr("Socks 5")) + self.downloadNodesCheckBox.setText(util_ui.tr("Download nodes list from tox.chat")) + self.warningLabel.setText(util_ui.tr("WARNING:\nusing proxy with enabled UDP\ncan produce IP leak")) + + def _activate_proxy(self): + bl = self.proxyCheckBox.isChecked() + self.ipLineEdit.setEnabled(bl) + self.portLineEdit.setEnabled(bl) + self.httpProxyRadioButton.setEnabled(bl) + self.socksProxyRadioButton.setEnabled(bl) + self.ipLabel.setEnabled(bl) + self.portLabel.setEnabled(bl) + + def _restart_core(self): try: - self._settings['ipv6_enabled'] = self.ipv.isChecked() - self._settings['udp_enabled'] = self.udp.isChecked() - self._settings['proxy_type'] = 2 - int(self.http.isChecked()) if self.proxy.isChecked() else 0 - self._settings['proxy_host'] = str(self.proxyip.text()) - self._settings['proxy_port'] = int(self.proxyport.text()) - self._settings['download_nodes_list'] = self.nodes.isChecked() + self._settings['ipv6_enabled'] = self.ipv6CheckBox.isChecked() + self._settings['udp_enabled'] = self.udpCheckBox.isChecked() + proxy_enabled = self.proxyCheckBox.isChecked() + self._settings['proxy_type'] = 2 - int(self.httpProxyRadioButton.isChecked()) if proxy_enabled else 0 + self._settings['proxy_host'] = str(self.ipLineEdit.text()) + self._settings['proxy_port'] = int(self.portLineEdit.text()) + self._settings['download_nodes_list'] = self.downloadNodesCheckBox.isChecked() + self._settings['lan_discovery'] = self.lanCheckBox.isChecked() self._settings.save() # recreate tox instance self._reset() diff --git a/toxygen/ui/views/network_settings_screen.ui b/toxygen/ui/views/network_settings_screen.ui new file mode 100644 index 0000000..aacf1e0 --- /dev/null +++ b/toxygen/ui/views/network_settings_screen.ui @@ -0,0 +1,180 @@ + + + Form + + + + 0 + 0 + 400 + 500 + + + + + 400 + 500 + + + + + 400 + 500 + + + + Form + + + + + 30 + 20 + 150 + 30 + + + + CheckBox + + + + + + 210 + 20 + 150 + 30 + + + + CheckBox + + + + + + 30 + 140 + 150 + 30 + + + + CheckBox + + + + + + 30 + 190 + 150 + 25 + + + + RadioButton + + + + + + 30 + 230 + 150 + 25 + + + + RadioButton + + + + + + 30 + 100 + 150 + 30 + + + + CheckBox + + + + + + 30 + 280 + 60 + 20 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 30 + 330 + 60 + 20 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 30 + 370 + 340 + 40 + + + + PushButton + + + + + + 30 + 60 + 340 + 30 + + + + CheckBox + + + + + + 30 + 420 + 340 + 65 + + + + TextLabel + + + + + +