From 6c9444ef5ef9f60b0f823e3868107c1853df2060 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 28 May 2016 23:08:40 +0300 Subject: [PATCH] 2 plugins --- CopyableToxId/toxid.pro | 2 + CopyableToxId/toxid.py | 119 ++++++++++++++++++++++++++++++ CopyableToxId/toxid/en_GB.ts | 56 ++++++++++++++ CopyableToxId/toxid/ru_RU.qm | Bin 0 -> 1628 bytes CopyableToxId/toxid/ru_RU.ts | 62 ++++++++++++++++ CopyableToxId/toxid/settings.json | 1 + MarqueeStatus/mrq.py | 66 +++++++++++++++++ 7 files changed, 306 insertions(+) create mode 100644 CopyableToxId/toxid.pro create mode 100644 CopyableToxId/toxid.py create mode 100644 CopyableToxId/toxid/en_GB.ts create mode 100644 CopyableToxId/toxid/ru_RU.qm create mode 100644 CopyableToxId/toxid/ru_RU.ts create mode 100644 CopyableToxId/toxid/settings.json create mode 100644 MarqueeStatus/mrq.py diff --git a/CopyableToxId/toxid.pro b/CopyableToxId/toxid.pro new file mode 100644 index 0000000..119f11d --- /dev/null +++ b/CopyableToxId/toxid.pro @@ -0,0 +1,2 @@ +SOURCES = toxid.py +TRANSLATIONS = toxid/en_GB.ts toxid/ru_RU.ts diff --git a/CopyableToxId/toxid.py b/CopyableToxId/toxid.py new file mode 100644 index 0000000..c304cd7 --- /dev/null +++ b/CopyableToxId/toxid.py @@ -0,0 +1,119 @@ +import plugin_super_class +from PySide import QtGui, QtCore +import json + + +class CopyableToxId(plugin_super_class.PluginSuperClass): + + def __init__(self, *args): + super(CopyableToxId, self).__init__('CopyableToxId', 'toxid', *args) + self._data = json.loads(self.load_settings()) + self._copy = False + self._timer = QtCore.QTimer() + self._timer.timeout.connect(lambda: self.timer()) + 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) + + def get_window(self): + inst = self + + class Window(QtGui.QWidget): + + def __init__(self): + super(Window, self).__init__() + self.setGeometry(QtCore.QRect(450, 300, 350, 100)) + self.send = QtGui.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.clicked.connect(self.update) + self.send.setChecked(inst._data['send_id']) + self.help = QtGui.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.clicked.connect(lambda: inst.command('help')) + + def update(self): + inst._data['send_id'] = self.send.isChecked() + inst.save_settings(json.dumps(inst._data)) + + return Window() + + def lossless_packet(self, data, friend_number): + if len(data): + self._data['id'] = filter(lambda x: not x.startswith(data[:64]), self._data['id']) + self._data['id'].append(data) + if self._copy: + self._timer.stop() + self._copy = False + clipboard = QtGui.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.setWindowTitle(title.format(self._name)) + text = QtGui.QApplication.translate("TOXID", "Tox ID cannot be copied", None, QtGui.QApplication.UnicodeUTF8) + msgbox.setText(text) + msgbox.exec_() + + def timer(self): + self._copy = False + self.error() + self._timer.stop() + + def friend_connected(self, friend_number): + self.send_lossless('', friend_number) + + def command(self, text): + if text == 'copy': + num = self._profile.get_active_number() + if num == -1: + return + elif text.startswith('copy '): + num = int(text[5:]) + if num < 0: + return + elif text == 'enable': + self._copy = True + return + elif text == 'disable': + 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.setWindowTitle(title) + text = QtGui.QApplication.translate("TOXID", """Commands: +copy: copy TOX ID of current friend +copy : 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) + msgbox.setText(text) + msgbox.exec_() + return + else: + return + public_key = self._tox.friend_get_public_key(num) + arr = filter(lambda x: x.startswith(public_key), self._data['id']) + if len(arr): + clipboard = QtGui.QApplication.clipboard() + clipboard.setText(arr[0]) + elif self._profile.get_friend_by_number(num).status is not None: + self._copy = True + self.send_lossless('', num) + self._timer.start(2000) + else: + self.error() + + def get_menu(self, menu, num): + act = QtGui.QAction(QtGui.QApplication.translate("TOXID", "Copy TOX ID", None, QtGui.QApplication.UnicodeUTF8), menu) + friend = self._profile.get_friend(num) + act.connect(act, QtCore.SIGNAL("triggered()"), lambda: self.command('copy ' + str(friend.number))) + return [act] diff --git a/CopyableToxId/toxid/en_GB.ts b/CopyableToxId/toxid/en_GB.ts new file mode 100644 index 0000000..758162e --- /dev/null +++ b/CopyableToxId/toxid/en_GB.ts @@ -0,0 +1,56 @@ + + + + TOXID + + + Plugin which allows you to copy TOX ID of your friend easily. + + + + + Send my TOX ID to contacts + + + + + CopyableToxID + + + + + List of commands + + + + + Error + + + + + Tox ID cannot be copied + + + + + List of commands for plugin CopyableToxID + + + + + 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 + + + + + Copy TOX ID + + + + diff --git a/CopyableToxId/toxid/ru_RU.qm b/CopyableToxId/toxid/ru_RU.qm new file mode 100644 index 0000000000000000000000000000000000000000..cf31170c9c3d56e3fe9b0697c5797a052dd09391 GIT binary patch literal 1628 zcmbVMO=}ZT6uoV4Y)M;C6x1O4>aI{qn-5#lB+Zx5(9j6&q8qLGn3#ddOqiL_2E>&M z|9}h8O}DOH=t2~_6LcXit!sBhx^hwUyqU=~PO*xM`FJz;-E+>p=f2dd#-;ZM&!2pl zy7Knk?wkEQ5v@@9X^m(kI&$~&JFJPfv2*5`UL@k+XP4 z5tZjM3EH3vZQ@y?B4YBKKwN=Kc*Zz`FLA^d@IE(?O;8FL5-Y)3+8T(-{4>&VUcouw zEPzqm;hyGIPT`A>Ad!HskWN*qk%l*^CyVF>+!MS4RgM}&=AlvkiAo(O^tq@DT;__C zvq36Zzh#v?WQGJX{cqM57;31yWVsAZNr$Odan21g9Fwg-gX>GdXt%3+!%BwhMyHn) z@-8+io1#<{MpM+grm5(*Xqu{`H=G!eau-{Aw_Q`r%!xhjZ?Ub~En#((y4qBghH#_9 zie9a0N>Wrc&Da(el8T*}HFx4Xk%y<%Yj~Qf`;*H;kQ9F_2(_uR7kDmmTuA zgl?IpVFp4YJcYI`qIqa1+A4?18#RC9*|KWcPOrRH26C+ZIR`Svd5J5IVU}Q*7_ib9 zI`K!1MIU!Mh%1_gDLPvBzN(AU^grZl0QJCV#*>wYv@B-urb8x!8H?fz$jO=TVovQH zV)}EIaI(nxUc&B}Q?{I(RbHc6UqJe{%XPb@)?2P2Eonvp69&e>v8d;3rD~~KZ#Gcn z44Qg;2uRxQ(U5`&ND3TyvX5y*%z>J`r+iY8bvY7ke+C^cx?Qc?RuB<6rSJNOXqpoc zEb(r5C7VY%T^2c~1cT*E`-m6eQ914Ps;(Qhs3}rBCUyYsF{Wqo+|beV_|FT&d^8h2 F{|om|HiZBH literal 0 HcmV?d00001 diff --git a/CopyableToxId/toxid/ru_RU.ts b/CopyableToxId/toxid/ru_RU.ts new file mode 100644 index 0000000..d79c3a6 --- /dev/null +++ b/CopyableToxId/toxid/ru_RU.ts @@ -0,0 +1,62 @@ + + + + + TOXID + + + Plugin which allows you to copy TOX ID of your friend easily. + Плагин, который позволяет копировать TOX ID друзей с легкостью. + + + + Send my TOX ID to contacts + Отправлять мой TOX ID контактам + + + + CopyableToxID + CopyableToxId + + + + List of commands + Список команд + + + + Error + Ошибка + + + + Tox ID cannot be copied + Tox ID не может быть скопирован + + + + List of commands for plugin CopyableToxID + Список команд для плагина CopyableToxID + + + + 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 + Команды: +copy: копировать TOX ID текущего друга +copy <номер_друга>: копировать TOX ID друга с заданным номером +enable: разрешить отправку TOX ID друзьям +disable: запретить отправку TOX ID друзьям +help: показать справку + + + + Copy TOX ID + Копировать TOX ID + + + diff --git a/CopyableToxId/toxid/settings.json b/CopyableToxId/toxid/settings.json new file mode 100644 index 0000000..b25f6db --- /dev/null +++ b/CopyableToxId/toxid/settings.json @@ -0,0 +1 @@ +{"send_id": true, "id": []} diff --git a/MarqueeStatus/mrq.py b/MarqueeStatus/mrq.py new file mode 100644 index 0000000..1876e53 --- /dev/null +++ b/MarqueeStatus/mrq.py @@ -0,0 +1,66 @@ +import plugin_super_class +import threading +import time +from PySide import QtCore + + +class InvokeEvent(QtCore.QEvent): + EVENT_TYPE = QtCore.QEvent.Type(QtCore.QEvent.registerEventType()) + + def __init__(self, fn, *args, **kwargs): + QtCore.QEvent.__init__(self, InvokeEvent.EVENT_TYPE) + self.fn = fn + self.args = args + self.kwargs = kwargs + + +class Invoker(QtCore.QObject): + + def event(self, event): + event.fn(*event.args, **event.kwargs) + return True + +_invoker = Invoker() + + +def invoke_in_main_thread(fn, *args, **kwargs): + QtCore.QCoreApplication.postEvent(_invoker, InvokeEvent(fn, *args, **kwargs)) + + +class MarqueeStatus(plugin_super_class.PluginSuperClass): + + def __init__(self, *args): + super(MarqueeStatus, self).__init__('MarqueeStatus', 'mrq', *args) + self._thread = threading.Thread(target=self.change_status) + self._exec = None + self.active = False + + def close(self): + self.stop() + + def stop(self): + self._exec = False + if self.active: + self._thread.join() + + def start(self): + self._exec = True + self._thread.start() + + def set_status_message(self): + self._profile.status_message = self._profile.status_message[1:] + self._profile.status_message[0] + + def init_status(self): + self._profile.status_message = self._profile.status_message.strip() + ' ' + + def change_status(self): + self.active = True + tmp = self._profile.status_message + time.sleep(10) + invoke_in_main_thread(self.init_status) + while self._exec: + time.sleep(1) + if self._profile.status is not None: + invoke_in_main_thread(self.set_status_message) + invoke_in_main_thread(self._profile.set_status_message, tmp) + self.active = False