From 238f7e367a45da2197e558c80685d762d0d9a587 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Fri, 25 May 2018 00:16:21 +0300 Subject: [PATCH] update settings screen converted --- toxygen/app.py | 2 +- toxygen/ui/main_screen.py | 5 +- toxygen/ui/menu.py | 61 ++++++++------------ toxygen/ui/views/update_settings_screen.ui | 67 ++++++++++++++++++++++ toxygen/ui/widgets_factory.py | 2 +- 5 files changed, 97 insertions(+), 40 deletions(-) create mode 100644 toxygen/ui/views/update_settings_screen.ui diff --git a/toxygen/app.py b/toxygen/app.py index 29619fd..60bb8bf 100644 --- a/toxygen/app.py +++ b/toxygen/app.py @@ -361,7 +361,7 @@ class App: self._tray = tray.init_tray(self._profile, self._settings, self._ms, self._toxes) self._ms.set_dependencies(widgets_factory, self._tray, self._contacts_manager, self._messenger, self._profile, self._plugin_loader, self._file_transfer_handler, history, self._calls_manager, - self._groups_service) + self._groups_service, self._toxes) self._tray.show() self._ms.show() diff --git a/toxygen/ui/main_screen.py b/toxygen/ui/main_screen.py index 652bbe3..e88437a 100644 --- a/toxygen/ui/main_screen.py +++ b/toxygen/ui/main_screen.py @@ -17,13 +17,13 @@ class MainWindow(QtWidgets.QMainWindow): self._plugins_loader = None self.setAcceptDrops(True) self._saved = False - self._profile = None + self._profile = self._toxes = None self._file_transfer_handler = self._history_loader = self._groups_service = self._calls_manager = None self._should_show_group_peers_list = False self.initUI() def set_dependencies(self, widget_factory, tray, contacts_manager, messenger, profile, plugins_loader, - file_transfer_handler, history_loader, calls_manager, groups_service): + file_transfer_handler, history_loader, calls_manager, groups_service, toxes): self._widget_factory = widget_factory self._tray = tray self._contacts_manager = contacts_manager @@ -33,6 +33,7 @@ class MainWindow(QtWidgets.QMainWindow): self._history_loader = history_loader self._calls_manager = calls_manager self._groups_service = groups_service + self._toxes = toxes self._contacts_manager.active_contact_changed.add_callback(self._new_contact_selected) self.messageEdit.set_messenger(messenger) diff --git a/toxygen/ui/menu.py b/toxygen/ui/menu.py index 36930dd..fff95a9 100644 --- a/toxygen/ui/menu.py +++ b/toxygen/ui/menu.py @@ -946,55 +946,44 @@ class UpdateSettings(CenteredWidget): Updates settings form """ - def __init__(self, settings): + def __init__(self, settings, version): super().__init__() self._settings = settings - self.initUI() + self._version = version + uic.loadUi(get_views_path('update_settings_screen'), self) + self._update_ui() self.center() - def initUI(self): - self.setObjectName("updateSettingsForm") - self.resize(400, 150) - self.setMinimumSize(QtCore.QSize(400, 120)) - self.setMaximumSize(QtCore.QSize(400, 120)) - self.in_label = QtWidgets.QLabel(self) - self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20)) - font = QtGui.QFont() - font.setPointSize(16) - font.setBold(True) - font.setFamily(self._settings['font']) - self.in_label.setFont(font) - self.autoupdate = QtWidgets.QComboBox(self) - self.autoupdate.setGeometry(QtCore.QRect(25, 30, 350, 30)) - self.button = QtWidgets.QPushButton(self) - self.button.setGeometry(QtCore.QRect(25, 70, 350, 30)) - self.button.setEnabled(self._settings['update']) - self.button.clicked.connect(self.update_client) - - self.retranslateUi() - self.autoupdate.setCurrentIndex(self._settings['update']) - QtCore.QMetaObject.connectSlotsByName(self) - - def retranslateUi(self): - self.setWindowTitle(util_ui.tr("Update settings")) - self.in_label.setText(util_ui.tr("Select update mode:")) - self.button.setText(util_ui.tr("Update Toxygen")) - self.autoupdate.addItem(util_ui.tr("Disabled")) - self.autoupdate.addItem(util_ui.tr("Manual")) - self.autoupdate.addItem(util_ui.tr("Auto")) - def closeEvent(self, event): - self._settings['update'] = self.autoupdate.currentIndex() + self._settings['update'] = self.updateModeComboBox.currentIndex() self._settings.save() - def update_client(self): + def _update_ui(self): + self.updatePushButton.clicked.connect(self._update_client) + self.updateModeComboBox.currentIndexChanged.connect(self._update_mode_changed) + self._retranslate_ui() + self.updateModeComboBox.setCurrentIndex(self._settings['update']) + + def _update_mode_changed(self): + index = self.updateModeComboBox.currentIndex() + self.updatePushButton.setEnabled(index > 0) + + def _retranslate_ui(self): + self.setWindowTitle(util_ui.tr("Update settings")) + self.updateModeLabel.setText(util_ui.tr("Select update mode:")) + self.updatePushButton.setText(util_ui.tr("Update Toxygen")) + self.updateModeComboBox.addItem(util_ui.tr("Disabled")) + self.updateModeComboBox.addItem(util_ui.tr("Manual")) + self.updateModeComboBox.addItem(util_ui.tr("Auto")) + + def _update_client(self): if not updater.connection_available(): util_ui.message_box(util_ui.tr('Problems with internet connection'), util_ui.tr("Error")) return if not updater.updater_available(): util_ui.message_box(util_ui.tr('Updater not found'), util_ui.tr("Error")) return - version = updater.check_for_updates() + version = updater.check_for_updates(self._version, self._settings) if version is not None: updater.download(version) util_ui.close_all_windows() diff --git a/toxygen/ui/views/update_settings_screen.ui b/toxygen/ui/views/update_settings_screen.ui new file mode 100644 index 0000000..76e7c57 --- /dev/null +++ b/toxygen/ui/views/update_settings_screen.ui @@ -0,0 +1,67 @@ + + + Form + + + + 0 + 0 + 400 + 120 + + + + + 400 + 120 + + + + + 400 + 120 + + + + Form + + + + + 25 + 5 + 350 + 20 + + + + TextLabel + + + + + + 25 + 30 + 350 + 30 + + + + + + + 25 + 70 + 350 + 30 + + + + PushButton + + + + + + diff --git a/toxygen/ui/widgets_factory.py b/toxygen/ui/widgets_factory.py index 68583d6..ead09ce 100644 --- a/toxygen/ui/widgets_factory.py +++ b/toxygen/ui/widgets_factory.py @@ -38,7 +38,7 @@ class WidgetsFactory: return VideoSettings(self._settings) def create_update_settings_window(self): - return UpdateSettings(self._settings) + return UpdateSettings(self._settings, self._version) def create_plugins_settings_window(self): return PluginsSettings(self._plugin_loader)