From 74d7c67d8cb10b9c6065717a443228259dd53aef Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Mon, 30 May 2016 21:38:21 +0300 Subject: [PATCH] context menu translations, bug fixes --- src/list_items.py | 7 ++++++- src/mainscreen.py | 7 ++++++- src/profile.py | 8 ++++++-- src/widgets.py | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/list_items.py b/src/list_items.py index cdc91b7..ea2f8ce 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -7,7 +7,7 @@ import profile from file_transfers import TOX_FILE_TRANSFER_STATE from util import curr_directory, convert_time from messages import FILE_TRANSFER_MESSAGE_STATUS -from widgets import DataLabel +from widgets import DataLabel, create_menu class MessageEdit(QtGui.QTextEdit): @@ -27,6 +27,11 @@ class MessageEdit(QtGui.QTextEdit): self.setFixedHeight(self.document().size().height()) self.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse | QtCore.Qt.LinksAccessibleByMouse) + def contextMenuEvent(self, event): + menu = create_menu(self.createStandardContextMenu()) + menu.exec_(event.globalPos()) + del menu + class MessageItem(QtGui.QWidget): """ diff --git a/src/mainscreen.py b/src/mainscreen.py index bb48731..0cb6604 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -3,7 +3,7 @@ from menu import * from profile import * from list_items import * -from widgets import QRightClickButton, RubberBand +from widgets import QRightClickButton, RubberBand, create_menu import plugin_support @@ -34,6 +34,11 @@ class MessageArea(QtGui.QPlainTextEdit): self.timer.start(5000) super(MessageArea, self).keyPressEvent(event) + def contextMenuEvent(self, event): + menu = create_menu(self.createStandardContextMenu()) + menu.exec_(event.globalPos()) + del menu + class MainWindow(QtGui.QMainWindow): diff --git a/src/profile.py b/src/profile.py index 97baaf1..a0cb3b7 100644 --- a/src/profile.py +++ b/src/profile.py @@ -337,7 +337,8 @@ class Profile(Contact, Singleton): def set_status(self, status): super(Profile, self).set_status(status) - self._tox.self_set_status(status) + if status is not None: + self._tox.self_set_status(status) def set_name(self, value): super(self.__class__, self).set_name(value) @@ -366,6 +367,7 @@ class Profile(Contact, Singleton): filter_str = filter_str.lower() for index, friend in enumerate(self._friends): friend.visibility = (friend.status is not None or not show_online) and (filter_str in friend.name.lower()) + friend.visibility = friend.visibility or friend.messages if friend.visibility: self._screen.friends_list.item(index).setSizeHint(QtCore.QSize(250, 70)) else: @@ -555,6 +557,8 @@ class Profile(Contact, Singleton): friend.set_messages(True) friend.append_message( TextMessage(message.decode('utf-8'), MESSAGE_OWNER['FRIEND'], time.time(), message_type)) + if not friend.visibility: + self.update_filtration() def send_message(self, text): """ @@ -881,7 +885,7 @@ class Profile(Contact, Singleton): friend.status = None def close(self): - if hasattr(self, '_stop'): + if hasattr(self, '_call'): self._call.stop() del self._call diff --git a/src/widgets.py b/src/widgets.py index 5d310b0..1499e88 100644 --- a/src/widgets.py +++ b/src/widgets.py @@ -53,3 +53,38 @@ class RubberBand(QtGui.QRubberBand): self.painter.setPen(self.pen) self.painter.drawRect(event.rect()) self.painter.end() + + +def create_menu(menu): + for action in menu.actions(): + text = action.text() + if 'Link Location' in text: + text = text.replace('Copy Link Location', + QtGui.QApplication.translate("MainWindow", "Copy link location", None, + QtGui.QApplication.UnicodeUTF8)) + elif '&Copy' in text: + text = text.replace('&Copy', QtGui.QApplication.translate("MainWindow", "Copy", None, + QtGui.QApplication.UnicodeUTF8)) + elif 'All' in text: + text = text.replace('Select All', QtGui.QApplication.translate("MainWindow", "Select all", None, + QtGui.QApplication.UnicodeUTF8)) + elif 'Delete' in text: + text = text.replace('Delete', QtGui.QApplication.translate("MainWindow", "Delete", None, + QtGui.QApplication.UnicodeUTF8)) + elif '&Paste' in text: + text = text.replace('&Paste', QtGui.QApplication.translate("MainWindow", "Paste", None, + QtGui.QApplication.UnicodeUTF8)) + elif 'Cu&t' in text: + text = text.replace('Cu&t', QtGui.QApplication.translate("MainWindow", "Cut", None, + QtGui.QApplication.UnicodeUTF8)) + elif '&Undo' in text: + text = text.replace('&Undo', QtGui.QApplication.translate("MainWindow", "Undo", None, + QtGui.QApplication.UnicodeUTF8)) + elif '&Redo' in text: + text = text.replace('&Redo', QtGui.QApplication.translate("MainWindow", "Redo", None, + QtGui.QApplication.UnicodeUTF8)) + else: + menu.removeAction(action) + continue + action.setText(text) + return menu