From 972a073cb96b76c85195f76463dfed4c6c5f0ecb Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 11 Apr 2017 21:38:00 +0300 Subject: [PATCH] missed translations fix, travis fix, updates --- .travis.yml | 6 ++--- setup.py | 5 ++-- toxygen/avwidgets.py | 6 ++--- toxygen/list_items.py | 3 +-- toxygen/mainscreen.py | 3 +-- toxygen/mainscreen_widgets.py | 47 +++++++++++------------------------ toxygen/menu.py | 26 ++++++++----------- toxygen/passwordscreen.py | 32 ++++++++---------------- toxygen/profile.py | 21 ++++++---------- toxygen/widgets.py | 24 ++++++------------ 10 files changed, 61 insertions(+), 112 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6002d8f..2e9b6df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,14 @@ language: python python: - - "3.4" + - "3.5" + - "3.6" before_install: - sudo apt-get update - sudo apt-get install -y checkinstall build-essential - sudo apt-get install portaudio19-dev - sudo apt-get install libconfig-dev libvpx-dev check -qq + - sudo apt-get install python3-pyqt5 install: - - pip install PySide --no-index --find-links https://parkin.github.io/python-wheelhouse/; - - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install - pip install pyaudio before_script: # OPUS diff --git a/setup.py b/setup.py index 86141f5..dc90b3c 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ version = program_version + '.0' MODULES = [] if system() in ('Windows', 'Darwin'): - MODULES = ['PyAudio', 'PySide'] + MODULES = ['PyAudio', 'PyQt5'] else: try: import pyaudio @@ -58,7 +58,8 @@ setup(name='Toxygen', include_package_data=True, classifiers=[ 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], entry_points={ 'console_scripts': ['toxygen=toxygen.main:main'], diff --git a/toxygen/avwidgets.py b/toxygen/avwidgets.py index c5c91e2..80b9034 100644 --- a/toxygen/avwidgets.py +++ b/toxygen/avwidgets.py @@ -120,8 +120,7 @@ class AudioMessageRecorder(widgets.CenteredWidget): self.record = QtWidgets.QPushButton(self) self.record.setGeometry(QtCore.QRect(20, 100, 150, 150)) - self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Start recording", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Start recording")) self.record.clicked.connect(self.start_or_stop_recording) self.recording = False self.friend_num = friend_number @@ -129,8 +128,7 @@ class AudioMessageRecorder(widgets.CenteredWidget): def start_or_stop_recording(self): if not self.recording: self.recording = True - self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Stop recording", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.record.setText(QtWidgets.QApplication.translate("MenuWindow", "Stop recording")) else: self.close() diff --git a/toxygen/list_items.py b/toxygen/list_items.py index 9e84d41..af373f9 100644 --- a/toxygen/list_items.py +++ b/toxygen/list_items.py @@ -534,8 +534,7 @@ class InlineImageItem(QtWidgets.QScrollArea): elif event.button() == QtCore.Qt.RightButton: # save inline directory = QtWidgets.QFileDialog.getExistingDirectory(self, QtWidgets.QApplication.translate("MainWindow", - 'Choose folder', None, - QtWidgets.QApplication.UnicodeUTF8), + 'Choose folder'), curr_directory(), QtWidgets.QFileDialog.ShowDirsOnly | QtWidgets.QFileDialog.DontUseNativeDialog) if directory: diff --git a/toxygen/mainscreen.py b/toxygen/mainscreen.py index fb7d19b..5d72c5f 100644 --- a/toxygen/mainscreen.py +++ b/toxygen/mainscreen.py @@ -494,8 +494,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton): msgBox.setWindowTitle( QtWidgets.QApplication.translate("MainWindow", "Cannot lock app")) msgBox.setText( - QtWidgets.QApplication.translate("MainWindow", 'Error. Profile password is not set.', None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("MainWindow", 'Error. Profile password is not set.')) msgBox.exec_() def show_menu(self): diff --git a/toxygen/mainscreen_widgets.py b/toxygen/mainscreen_widgets.py index 91a98df..53d969b 100644 --- a/toxygen/mainscreen_widgets.py +++ b/toxygen/mainscreen_widgets.py @@ -331,51 +331,39 @@ class WelcomeScreen(CenteredWidget): self.text.setOpenExternalLinks(True) self.checkbox = QtWidgets.QCheckBox(self) self.checkbox.setGeometry(QtCore.QRect(5, 170, 240, 30)) - self.checkbox.setText(QtWidgets.QApplication.translate('WelcomeScreen', "Don't show again", - None, QtWidgets.QApplication.UnicodeUTF8)) - self.setWindowTitle(QtWidgets.QApplication.translate('WelcomeScreen', 'Tip of the day', - None, QtWidgets.QApplication.UnicodeUTF8)) + self.checkbox.setText(QtWidgets.QApplication.translate('WelcomeScreen', "Don't show again")) + self.setWindowTitle(QtWidgets.QApplication.translate('WelcomeScreen', 'Tip of the day')) import random num = random.randint(0, 10) if num == 0: - text = QtWidgets.QApplication.translate('WelcomeScreen', 'Press Esc if you want hide app to tray.', - None, QtWidgets.QApplication.UnicodeUTF8) + text = QtWidgets.QApplication.translate('WelcomeScreen', 'Press Esc if you want hide app to tray.') elif num == 1: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Right click on screenshot button hides app to tray during screenshot.', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Right click on screenshot button hides app to tray during screenshot.') elif num == 2: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'You can use Tox over Tor. For more info read this post', - None, QtWidgets.QApplication.UnicodeUTF8) + 'You can use Tox over Tor. For more info read this post') elif num == 3: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Use Settings -> Interface to customize interface.', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Use Settings -> Interface to customize interface.') elif num == 4: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Set profile password via Profile -> Settings. Password allows Toxygen encrypt your history and settings.') elif num == 5: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Since v0.1.3 Toxygen supports plugins. Read more', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Since v0.1.3 Toxygen supports plugins. Read more') elif num in (6, 7): text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Toxygen supports faux offline messages and file transfers. Send message or file to offline friend and he will get it later.', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Toxygen supports faux offline messages and file transfers. Send message or file to offline friend and he will get it later.') elif num == 8: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Delete single message in chat: make right click on spinner or message time and choose "Delete" in menu') elif num == 9: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Use right click on inline image to save it', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Use right click on inline image to save it') else: text = QtWidgets.QApplication.translate('WelcomeScreen', - 'Set new NoSpam to avoid spam friend requests: Profile -> Settings -> Set new NoSpam.', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Set new NoSpam to avoid spam friend requests: Profile -> Settings -> Set new NoSpam.') self.text.setHtml(text) self.checkbox.stateChanged.connect(self.not_show) QtCore.QTimer.singleShot(1000, self.show) @@ -455,8 +443,7 @@ class SearchScreen(QtWidgets.QWidget): self.retranslateUi() def retranslateUi(self): - self.search_text.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "Search", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.search_text.setPlaceholderText(QtWidgets.QApplication.translate("MainWindow", "Search")) def show(self): super().show() @@ -514,13 +501,9 @@ class SearchScreen(QtWidgets.QWidget): def not_found(text): mbox = QtWidgets.QMessageBox() mbox_text = QtWidgets.QApplication.translate("MainWindow", - 'Text "{}" was not found', - None, - QtWidgets.QApplication.UnicodeUTF8) + 'Text "{}" was not found') mbox.setText(mbox_text.format(text)) mbox.setWindowTitle(QtWidgets.QApplication.translate("MainWindow", - 'Not found', - None, - QtWidgets.QApplication.UnicodeUTF8)) + 'Not found')) mbox.exec_() diff --git a/toxygen/menu.py b/toxygen/menu.py index 3d89f0b..c3958e9 100644 --- a/toxygen/menu.py +++ b/toxygen/menu.py @@ -141,12 +141,12 @@ class ProfileSettings(CenteredWidget): self.profilepass.setFont(font) self.password = LineEdit(self) self.password.setGeometry(QtCore.QRect(40, 380, 300, 30)) - self.password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) + self.password.setEchoMode(QtWidgets.QLineEdit.Password) self.leave_blank = QtWidgets.QLabel(self) self.leave_blank.setGeometry(QtCore.QRect(350, 380, 300, 30)) self.confirm_password = LineEdit(self) self.confirm_password.setGeometry(QtCore.QRect(40, 420, 300, 30)) - self.confirm_password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) + self.confirm_password.setEchoMode(QtWidgets.QLineEdit.Password) self.set_password = QtWidgets.QPushButton(self) self.set_password.setGeometry(QtCore.QRect(40, 470, 300, 30)) self.set_password.clicked.connect(self.new_password) @@ -202,12 +202,10 @@ class ProfileSettings(CenteredWidget): Settings.set_auto_profile(ProfileHelper.get_path(), Settings.get_instance().name) self.auto = not self.auto if self.auto: - self.default.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as not default profile", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.default.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as not default profile")) else: self.default.setText( - QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as default profile", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("ProfileSettingsForm", "Mark as default profile")) def new_password(self): if self.password.text() == self.confirm_password.text(): @@ -217,12 +215,10 @@ class ProfileSettings(CenteredWidget): self.close() else: self.not_match.setText( - QtWidgets.QApplication.translate("ProfileSettingsForm", "Password must be at least 8 symbols", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("ProfileSettingsForm", "Password must be at least 8 symbols")) self.not_match.setVisible(True) else: - self.not_match.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Passwords do not match", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.not_match.setText(QtWidgets.QApplication.translate("ProfileSettingsForm", "Passwords do not match")) self.not_match.setVisible(True) def copy(self): @@ -686,21 +682,19 @@ class InterfaceSettings(CenteredWidget): def new_font(self): settings = Settings.get_instance() - font, ok = QtGui.QFontDialog.getFont(QtGui.QFont(settings['font'], 10), self) + font, ok = QtWidgets.QFontDialog.getFont(QtGui.QFont(settings['font'], 10), self) if ok: settings['font'] = font.family() settings.save() msgBox = QtWidgets.QMessageBox() - text = QtWidgets.QApplication.translate("interfaceForm", 'Restart app to apply settings', None, - QtWidgets.QApplication.UnicodeUTF8) - msgBox.setWindowTitle(QtWidgets.QApplication.translate("interfaceForm", 'Restart required', None, - QtWidgets.QApplication.UnicodeUTF8)) + text = QtWidgets.QApplication.translate("interfaceForm", 'Restart app to apply settings') + msgBox.setWindowTitle(QtWidgets.QApplication.translate("interfaceForm", 'Restart required')) msgBox.setText(text) msgBox.exec_() def select_color(self): settings = Settings.get_instance() - col = QtGui.QColorDialog.getColor(settings['unread_color']) + col = QtWidgets.QColorDialog.getColor(QtGui.QColor(settings['unread_color'])) if col.isValid(): name = col.name() diff --git a/toxygen/passwordscreen.py b/toxygen/passwordscreen.py index 9d427a7..6d872b6 100644 --- a/toxygen/passwordscreen.py +++ b/toxygen/passwordscreen.py @@ -1,8 +1,5 @@ from widgets import CenteredWidget, LineEdit -try: - from PyQt5 import QtCore, QtGui -except ImportError: - from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets class PasswordArea(LineEdit): @@ -10,7 +7,7 @@ class PasswordArea(LineEdit): def __init__(self, parent): super(PasswordArea, self).__init__(parent) self.parent = parent - self.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) + self.setEchoMode(QtWidgets.QLineEdit.Password) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Return: @@ -116,10 +113,10 @@ class SetProfilePasswordScreen(CenteredWidget): self.setMaximumSize(QtCore.QSize(700, 200)) self.password = LineEdit(self) self.password.setGeometry(QtCore.QRect(40, 10, 300, 30)) - self.password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) + self.password.setEchoMode(QtWidgets.QLineEdit.Password) self.confirm_password = LineEdit(self) self.confirm_password.setGeometry(QtCore.QRect(40, 50, 300, 30)) - self.confirm_password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) + self.confirm_password.setEchoMode(QtWidgets.QLineEdit.Password) self.set_password = QtWidgets.QPushButton(self) self.set_password.setGeometry(QtCore.QRect(40, 100, 300, 30)) self.set_password.clicked.connect(self.new_password) @@ -132,21 +129,16 @@ class SetProfilePasswordScreen(CenteredWidget): self.warning.setStyleSheet('QLabel { color: #BC1C1C; }') def retranslateUi(self): - self.setWindowTitle(QtWidgets.QApplication.translate("PasswordScreen", "Profile password", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.setWindowTitle(QtWidgets.QApplication.translate("PasswordScreen", "Profile password")) self.password.setPlaceholderText( - QtWidgets.QApplication.translate("PasswordScreen", "Password (at least 8 symbols)", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("PasswordScreen", "Password (at least 8 symbols)")) self.confirm_password.setPlaceholderText( - QtWidgets.QApplication.translate("PasswordScreen", "Confirm password", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("PasswordScreen", "Confirm password")) self.set_password.setText( QtWidgets.QApplication.translate("PasswordScreen", "Set password")) - self.not_match.setText(QtWidgets.QApplication.translate("PasswordScreen", "Passwords do not match", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.not_match.setText(QtWidgets.QApplication.translate("PasswordScreen", "Passwords do not match")) self.warning.setText( - QtWidgets.QApplication.translate("PasswordScreen", "There is no way to recover lost passwords", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("PasswordScreen", "There is no way to recover lost passwords")) def new_password(self): if self.password.text() == self.confirm_password.text(): @@ -155,10 +147,8 @@ class SetProfilePasswordScreen(CenteredWidget): self.close() else: self.not_match.setText( - QtWidgets.QApplication.translate("PasswordScreen", "Password must be at least 8 symbols", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("PasswordScreen", "Password must be at least 8 symbols")) self.not_match.setVisible(True) else: - self.not_match.setText(QtWidgets.QApplication.translate("PasswordScreen", "Passwords do not match", None, - QtWidgets.QApplication.UnicodeUTF8)) + self.not_match.setText(QtWidgets.QApplication.translate("PasswordScreen", "Passwords do not match")) self.not_match.setVisible(True) diff --git a/toxygen/profile.py b/toxygen/profile.py index 81a1aa9..41e4752 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -96,8 +96,7 @@ class Profile(basecontact.BaseContact, Singleton): tmp = self.name super(Profile, self).set_name(value.encode('utf-8')) self._tox.self_set_name(self._name.encode('utf-8')) - message = QtWidgets.QApplication.translate("MainWindow", 'User {} is now known as {}', None, - QtWidgets.QApplication.UnicodeUTF8) + message = QtWidgets.QApplication.translate("MainWindow", 'User {} is now known as {}') message = message.format(tmp, value) for friend in self._contacts: friend.append_message(InfoMessage(message, time.time())) @@ -663,12 +662,10 @@ class Profile(basecontact.BaseContact, Singleton): friend = self._contacts[num] name = friend.name dialog = QtWidgets.QApplication.translate('MainWindow', - "Enter new alias for friend {} or leave empty to use friend's name:", - None, QtWidgets.QApplication.UnicodeUTF8) + "Enter new alias for friend {} or leave empty to use friend's name:") dialog = dialog.format(name) title = QtWidgets.QApplication.translate('MainWindow', - 'Set alias', - None, QtWidgets.QApplication.UnicodeUTF8) + 'Set alias') text, ok = QtGui.QInputDialog.getText(None, title, dialog, @@ -1204,11 +1201,9 @@ class Profile(basecontact.BaseContact, Singleton): self._call(num, audio, video) self._screen.active_call() if video: - text = QtWidgets.QApplication.translate("incoming_call", "Outgoing video call", None, - QtWidgets.QApplication.UnicodeUTF8) + text = QtWidgets.QApplication.translate("incoming_call", "Outgoing video call") else: - text = QtWidgets.QApplication.translate("incoming_call", "Outgoing audio call", None, - QtWidgets.QApplication.UnicodeUTF8) + text = QtWidgets.QApplication.translate("incoming_call", "Outgoing audio call") self.get_curr_friend().append_message(InfoMessage(text, time.time())) self.create_message_item(text, time.time(), '', MESSAGE_TYPE['INFO_MESSAGE']) self._messages.scrollToBottom() @@ -1223,11 +1218,9 @@ class Profile(basecontact.BaseContact, Singleton): return friend = self.get_friend_by_number(friend_number) if video: - text = QtWidgets.QApplication.translate("incoming_call", "Incoming video call", None, - QtWidgets.QApplication.UnicodeUTF8) + text = QtWidgets.QApplication.translate("incoming_call", "Incoming video call") else: - text = QtWidgets.QApplication.translate("incoming_call", "Incoming audio call", None, - QtWidgets.QApplication.UnicodeUTF8) + text = QtWidgets.QApplication.translate("incoming_call", "Incoming audio call") friend.append_message(InfoMessage(text, time.time())) self._incoming_calls.add(friend_number) if friend_number == self.get_active_number(): diff --git a/toxygen/widgets.py b/toxygen/widgets.py index ada5d93..6e68047 100644 --- a/toxygen/widgets.py +++ b/toxygen/widgets.py @@ -85,29 +85,21 @@ def create_menu(menu): text = action.text() if 'Link Location' in text: text = text.replace('Copy &Link Location', - QtWidgets.QApplication.translate("MainWindow", "Copy link location", None, - QtWidgets.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("MainWindow", "Copy link location")) elif '&Copy' in text: - text = text.replace('&Copy', QtWidgets.QApplication.translate("MainWindow", "Copy", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('&Copy', QtWidgets.QApplication.translate("MainWindow", "Copy")) elif 'All' in text: - text = text.replace('Select All', QtWidgets.QApplication.translate("MainWindow", "Select all", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('Select All', QtWidgets.QApplication.translate("MainWindow", "Select all")) elif 'Delete' in text: - text = text.replace('Delete', QtWidgets.QApplication.translate("MainWindow", "Delete", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('Delete', QtWidgets.QApplication.translate("MainWindow", "Delete")) elif '&Paste' in text: - text = text.replace('&Paste', QtWidgets.QApplication.translate("MainWindow", "Paste", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('&Paste', QtWidgets.QApplication.translate("MainWindow", "Paste")) elif 'Cu&t' in text: - text = text.replace('Cu&t', QtWidgets.QApplication.translate("MainWindow", "Cut", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('Cu&t', QtWidgets.QApplication.translate("MainWindow", "Cut")) elif '&Undo' in text: - text = text.replace('&Undo', QtWidgets.QApplication.translate("MainWindow", "Undo", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('&Undo', QtWidgets.QApplication.translate("MainWindow", "Undo")) elif '&Redo' in text: - text = text.replace('&Redo', QtWidgets.QApplication.translate("MainWindow", "Redo", None, - QtWidgets.QApplication.UnicodeUTF8)) + text = text.replace('&Redo', QtWidgets.QApplication.translate("MainWindow", "Redo")) else: menu.removeAction(action) continue