def keyPressEvent(self, event): key = event.key() modifier = event.modifiers() is_goto_prev_tab = (modifier == QtCore.Qt.ControlModifier) and (key == QtCore.Qt.Key_BracketLeft) is_goto_next_tab = (modifier == QtCore.Qt.ControlModifier) and (key == QtCore.Qt.Key_BracketRight) is_send_msg = key == QtCore.Qt.Key_Return is_close_tab = key == QtCore.Qt.Key_Escape is_switch_tab = (modifier == QtCore.Qt.ControlModifier) and (key >= QtCore.Qt.Key_1 and key <= QtCore.Qt.Key_9) CHAR_START_AT = 48 if is_close_tab: if not self.convTab.count(): self.hide() return no_input = self.convTab.currentWidget().toPlainText() if not no_input: self._close_current_tab() else: msg = "Pressing the ESC key will close this conversation. <br />" \ "Are you sure you want to continue ?" if popup_confirm(self, msg): self._close_current_tab() elif is_send_msg: widget = self.convTab.currentWidget() msg = widget.toPlainText() if not msg: return widget.clear() self.send_msg(qstr_to_unicode_obj(msg)) elif is_switch_tab: count = self.convTab.count() k = key.real - CHAR_START_AT if 1 > k and k > 9: return if k < count + 1: self.convTab.setCurrentIndex(k - 1) elif is_goto_prev_tab: count = self.convTab.count() cur_idx = self.convTab.currentIndex() if count == 1: return elif cur_idx == 0: self.convTab.setCurrentIndex(count - 1) else: self.convTab.setCurrentIndex(cur_idx - 1) elif is_goto_next_tab: count = self.convTab.count() cur_idx = self.convTab.currentIndex() if count == 1: return elif (count - 1) == cur_idx: self.convTab.setCurrentIndex(0) else: self.convTab.setCurrentIndex(cur_idx + 1)
def get_return(self): data = { "accept": self.accept_radio_btn.isChecked(), "decline_add_req_forever": self.decline_add_req_check_box.isChecked(), "refuse_reason": qstr_to_unicode_obj(self.reason_line_edit.text()), } return data
def get_return(self): account = str(self.account_line_edit.text().toUtf8()) name = qstr_to_unicode_obj(self.name_line_edit.text()) data = { "account": account, "name": name, "add_buddy_phrases": self.msg_combo_box.currentIndex(), } return data