This commit is contained in:
ingvar1995 2017-06-20 20:55:11 +03:00
parent 937b577cee
commit 12a395616c
8 changed files with 72 additions and 62 deletions

View file

@ -1,5 +1,5 @@
import plugin_super_class
from PySide import QtGui, QtCore
from PyQt5 import QtCore, QtWidgets
import json
@ -15,25 +15,25 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
self.load_translator()
def get_description(self):
return QtGui.QApplication.translate("TOXID", 'Plugin which allows you to copy TOX ID of your friend easily.', None, QtGui.QApplication.UnicodeUTF8)
return QtWidgets.QApplication.translate("TOXID", 'Plugin which allows you to copy TOX ID of your friend easily.')
def get_window(self):
inst = self
class Window(QtGui.QWidget):
class Window(QtWidgets.QWidget):
def __init__(self):
super(Window, self).__init__()
self.setGeometry(QtCore.QRect(450, 300, 350, 100))
self.send = QtGui.QCheckBox(self)
self.send = QtWidgets.QCheckBox(self)
self.send.setGeometry(QtCore.QRect(20, 10, 310, 25))
self.send.setText(QtGui.QApplication.translate("TOXID", "Send my TOX ID to contacts", None, QtGui.QApplication.UnicodeUTF8))
self.setWindowTitle(QtGui.QApplication.translate("TOXID", "CopyableToxID", None, QtGui.QApplication.UnicodeUTF8))
self.send.setText(QtWidgets.QApplication.translate("TOXID", "Send my TOX ID to contacts"))
self.setWindowTitle(QtWidgets.QApplication.translate("TOXID", "CopyableToxID"))
self.send.clicked.connect(self.update)
self.send.setChecked(inst._data['send_id'])
self.help = QtGui.QPushButton(self)
self.help = QtWidgets.QPushButton(self)
self.help.setGeometry(QtCore.QRect(20, 40, 200, 25))
self.help.setText(QtGui.QApplication.translate("TOXID", "List of commands", None, QtGui.QApplication.UnicodeUTF8))
self.help.setText(QtWidgets.QApplication.translate("TOXID", "List of commands"))
self.help.clicked.connect(lambda: inst.command('help'))
def update(self):
@ -49,17 +49,17 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
if self._copy:
self._timer.stop()
self._copy = False
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(data)
self.save_settings(json.dumps(self._data))
elif self._data['send_id']:
self.send_lossless(self._tox.self_get_address(), friend_number)
def error(self):
msgbox = QtGui.QMessageBox()
title = QtGui.QApplication.translate("TOXID", "Error", None, QtGui.QApplication.UnicodeUTF8)
msgbox = QtWidgets.QMessageBox()
title = QtWidgets.QApplication.translate("TOXID", "Error")
msgbox.setWindowTitle(title.format(self._name))
text = QtGui.QApplication.translate("TOXID", "Tox ID cannot be copied", None, QtGui.QApplication.UnicodeUTF8)
text = QtWidgets.QApplication.translate("TOXID", "Tox ID cannot be copied")
msgbox.setText(text)
msgbox.exec_()
@ -70,7 +70,7 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
self._curr = -1
arr = list(filter(lambda x: x.startswith(public_key), self._data['id']))
if len(arr):
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(arr[0])
else:
self.error()
@ -97,15 +97,15 @@ class CopyableToxId(plugin_super_class.PluginSuperClass):
self._copy = False
return
elif text == 'help':
msgbox = QtGui.QMessageBox()
title = QtGui.QApplication.translate("TOXID", "List of commands for plugin CopyableToxID", None, QtGui.QApplication.UnicodeUTF8)
msgbox = QtWidgets.QMessageBox()
title = QtWidgets.QApplication.translate("TOXID", "List of commands for plugin CopyableToxID")
msgbox.setWindowTitle(title)
text = QtGui.QApplication.translate("TOXID", """Commands:
text = QtWidgets.QApplication.translate("TOXID", """Commands:
copy: copy TOX ID of current friend
copy <friend_number>: copy TOX ID of friend with specified number
enable: allow send your TOX ID to friends
disable: disallow send your TOX ID to friends
help: show this help""", None, QtGui.QApplication.UnicodeUTF8)
help: show this help""")
msgbox.setText(text)
msgbox.exec_()
return
@ -114,7 +114,7 @@ help: show this help""", None, QtGui.QApplication.UnicodeUTF8)
public_key = self._tox.friend_get_public_key(num)
arr = list(filter(lambda x: x.startswith(public_key), self._data['id']))
if self._profile.get_friend_by_number(num).status is None and len(arr):
clipboard = QtGui.QApplication.clipboard()
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(arr[0])
elif self._profile.get_friend_by_number(num).status is not None:
self._copy = True
@ -125,7 +125,7 @@ help: show this help""", None, QtGui.QApplication.UnicodeUTF8)
self.error()
def get_menu(self, menu, num):
act = QtGui.QAction(QtGui.QApplication.translate("TOXID", "Copy TOX ID", None, QtGui.QApplication.UnicodeUTF8), menu)
act = QtWidgets.QAction(QtWidgets.QApplication.translate("TOXID", "Copy TOX ID"), menu)
friend = self._profile.get_friend(num)
act.connect(act, QtCore.SIGNAL("triggered()"), lambda: self.command('copy ' + str(friend.number)))
return [act]