2 plugins
This commit is contained in:
parent
96894cd651
commit
6c9444ef5e
2
CopyableToxId/toxid.pro
Normal file
2
CopyableToxId/toxid.pro
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SOURCES = toxid.py
|
||||||
|
TRANSLATIONS = toxid/en_GB.ts toxid/ru_RU.ts
|
119
CopyableToxId/toxid.py
Normal file
119
CopyableToxId/toxid.py
Normal file
@ -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 <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)
|
||||||
|
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]
|
56
CopyableToxId/toxid/en_GB.ts
Normal file
56
CopyableToxId/toxid/en_GB.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS><TS version="1.1">
|
||||||
|
<context>
|
||||||
|
<name>TOXID</name>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="19"/>
|
||||||
|
<source>Plugin which allows you to copy TOX ID of your friend easily.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="29"/>
|
||||||
|
<source>Send my TOX ID to contacts</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="30"/>
|
||||||
|
<source>CopyableToxID</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="35"/>
|
||||||
|
<source>List of commands</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="60"/>
|
||||||
|
<source>Error</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="62"/>
|
||||||
|
<source>Tox ID cannot be copied</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="87"/>
|
||||||
|
<source>List of commands for plugin CopyableToxID</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="94"/>
|
||||||
|
<source>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</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="112"/>
|
||||||
|
<source>Copy TOX ID</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
BIN
CopyableToxId/toxid/ru_RU.qm
Normal file
BIN
CopyableToxId/toxid/ru_RU.qm
Normal file
Binary file not shown.
62
CopyableToxId/toxid/ru_RU.ts
Normal file
62
CopyableToxId/toxid/ru_RU.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.0" language="ru_RU">
|
||||||
|
<context>
|
||||||
|
<name>TOXID</name>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="19"/>
|
||||||
|
<source>Plugin which allows you to copy TOX ID of your friend easily.</source>
|
||||||
|
<translation>Плагин, который позволяет копировать TOX ID друзей с легкостью.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="29"/>
|
||||||
|
<source>Send my TOX ID to contacts</source>
|
||||||
|
<translation>Отправлять мой TOX ID контактам</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="30"/>
|
||||||
|
<source>CopyableToxID</source>
|
||||||
|
<translation>CopyableToxId</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="35"/>
|
||||||
|
<source>List of commands</source>
|
||||||
|
<translation>Список команд</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="60"/>
|
||||||
|
<source>Error</source>
|
||||||
|
<translation>Ошибка</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="62"/>
|
||||||
|
<source>Tox ID cannot be copied</source>
|
||||||
|
<translation>Tox ID не может быть скопирован</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="87"/>
|
||||||
|
<source>List of commands for plugin CopyableToxID</source>
|
||||||
|
<translation>Список команд для плагина CopyableToxID</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="94"/>
|
||||||
|
<source>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</source>
|
||||||
|
<translation>Команды:
|
||||||
|
copy: копировать TOX ID текущего друга
|
||||||
|
copy <номер_друга>: копировать TOX ID друга с заданным номером
|
||||||
|
enable: разрешить отправку TOX ID друзьям
|
||||||
|
disable: запретить отправку TOX ID друзьям
|
||||||
|
help: показать справку</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="toxid.py" line="112"/>
|
||||||
|
<source>Copy TOX ID</source>
|
||||||
|
<translation>Копировать TOX ID</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
1
CopyableToxId/toxid/settings.json
Normal file
1
CopyableToxId/toxid/settings.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"send_id": true, "id": []}
|
66
MarqueeStatus/mrq.py
Normal file
66
MarqueeStatus/mrq.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user