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,7 +1,7 @@
import plugin_super_class import plugin_super_class
import threading import threading
import time import time
from PySide import QtCore, QtGui from PyQt5 import QtCore, QtWidgets
from subprocess import check_output from subprocess import check_output
import json import json
@ -64,21 +64,21 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
def get_window(self): def get_window(self):
inst = self inst = self
class Window(QtGui.QWidget): class Window(QtWidgets.QWidget):
def __init__(self): def __init__(self):
super(Window, self).__init__() super(Window, self).__init__()
self.setGeometry(QtCore.QRect(450, 300, 350, 100)) self.setGeometry(QtCore.QRect(450, 300, 350, 100))
self.label = QtGui.QLabel(self) self.label = QtWidgets.QLabel(self)
self.label.setGeometry(QtCore.QRect(20, 0, 310, 35)) self.label.setGeometry(QtCore.QRect(20, 0, 310, 35))
self.label.setText(QtGui.QApplication.translate("AutoAwayStatusLinux", "Auto away time in minutes\n(0 - to disable)", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtWidgets.QApplication.translate("AutoAwayStatusLinux", "Auto away time in minutes\n(0 - to disable)"))
self.time = QtGui.QLineEdit(self) self.time = QtWidgets.QLineEdit(self)
self.time.setGeometry(QtCore.QRect(20, 40, 310, 25)) self.time.setGeometry(QtCore.QRect(20, 40, 310, 25))
self.time.setText(str(inst._time)) self.time.setText(str(inst._time))
self.setWindowTitle("AutoAwayStatusLinux") self.setWindowTitle("AutoAwayStatusLinux")
self.ok = QtGui.QPushButton(self) self.ok = QtWidgets.QPushButton(self)
self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25)) self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25))
self.ok.setText( self.ok.setText(
QtGui.QApplication.translate("AutoAwayStatusLinux", "Save", None, QtGui.QApplication.UnicodeUTF8)) QtWidgets.QApplication.translate("AutoAwayStatusLinux", "Save"))
self.ok.clicked.connect(self.update) self.ok.clicked.connect(self.update)
def update(self): def update(self):
@ -102,4 +102,4 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass):
if d > 60 * self._time: if d > 60 * self._time:
self.change_status() self.change_status()
elif self._profile.status == 1: elif self._profile.status == 1:
self.change_status(self._prev_status) self.change_status(self._prev_status)

View File

@ -1,7 +1,7 @@
import plugin_super_class import plugin_super_class
import threading import threading
import time import time
from PySide import QtCore, QtGui from PyQt5 import QtCore, QtWidgets
from ctypes import Structure, windll, c_uint, sizeof, byref from ctypes import Structure, windll, c_uint, sizeof, byref
import json import json
@ -68,29 +68,28 @@ class AutoAwayStatusWindows(plugin_super_class.PluginSuperClass):
self.save_settings('{"time": ' + str(self._time) + '}') self.save_settings('{"time": ' + str(self._time) + '}')
def change_status(self, status=1): def change_status(self, status=1):
if self._profile.status in (0, 2): if self._profile.status != 1:
self._prev_status = self._profile.status self._prev_status = self._profile.status
if status is not None: invoke_in_main_thread(self._profile.set_status, status)
invoke_in_main_thread(self._profile.set_status, status)
def get_window(self): def get_window(self):
inst = self inst = self
class Window(QtGui.QWidget): class Window(QtWidgets.QWidget):
def __init__(self): def __init__(self):
super(Window, self).__init__() super(Window, self).__init__()
self.setGeometry(QtCore.QRect(450, 300, 350, 100)) self.setGeometry(QtCore.QRect(450, 300, 350, 100))
self.label = QtGui.QLabel(self) self.label = QtWidgets.QLabel(self)
self.label.setGeometry(QtCore.QRect(20, 0, 310, 35)) self.label.setGeometry(QtCore.QRect(20, 0, 310, 35))
self.label.setText(QtGui.QApplication.translate("AutoAwayStatusWindows", "Auto away time in minutes\n(0 - to disable)", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtWidgets.QApplication.translate("AutoAwayStatusWindows", "Auto away time in minutes\n(0 - to disable)"))
self.time = QtGui.QLineEdit(self) self.time = QtWidgets.QLineEdit(self)
self.time.setGeometry(QtCore.QRect(20, 40, 310, 25)) self.time.setGeometry(QtCore.QRect(20, 40, 310, 25))
self.time.setText(str(inst._time)) self.time.setText(str(inst._time))
self.setWindowTitle("AutoAwayStatusWindows") self.setWindowTitle("AutoAwayStatusWindows")
self.ok = QtGui.QPushButton(self) self.ok = QtWidgets.QPushButton(self)
self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25)) self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25))
self.ok.setText( self.ok.setText(
QtGui.QApplication.translate("AutoAwayStatusWindows", "Save", None, QtGui.QApplication.UnicodeUTF8)) QtWidgets.QApplication.translate("AutoAwayStatusWindows", "Save"))
self.ok.clicked.connect(self.update) self.ok.clicked.connect(self.update)
def update(self): def update(self):

View File

@ -1,5 +1,5 @@
import plugin_super_class import plugin_super_class
from PySide import QtGui, QtCore from PyQt5 import QtWidgets, QtCore
import json import json
import importlib import importlib
@ -22,9 +22,9 @@ class BirthDay(plugin_super_class.PluginSuperClass):
if int(arr[0]) == now.day and int(arr[1]) == now.month: if int(arr[0]) == now.day and int(arr[1]) == now.month:
today[key] = now.year - int(arr[2]) today[key] = now.year - int(arr[2])
if len(today): if len(today):
msgbox = QtGui.QMessageBox() msgbox = QtWidgets.QMessageBox()
title = QtGui.QApplication.translate('BirthDay', "Birthday!", None, title = QtWidgets.QApplication.translate('BirthDay', "Birthday!", None,
QtGui.QApplication.UnicodeUTF8) QtWidgets.QApplication.UnicodeUTF8)
msgbox.setWindowTitle(title) msgbox.setWindowTitle(title)
text = ', '.join(self._profile.get_friend_by_number(self._tox.friend_by_public_key(x)).name + ' ({})'.format(today[x]) for x in today) text = ', '.join(self._profile.get_friend_by_number(self._tox.friend_by_public_key(x)).name + ' ({})'.format(today[x]) for x in today)
msgbox.setText('Birthdays: ' + text) msgbox.setText('Birthdays: ' + text)
@ -34,23 +34,23 @@ class BirthDay(plugin_super_class.PluginSuperClass):
inst = self inst = self
x = self._profile.tox_id[:64] x = self._profile.tox_id[:64]
class Window(QtGui.QWidget): class Window(QtWidgets.QWidget):
def __init__(self): def __init__(self):
super(Window, self).__init__() super(Window, self).__init__()
self.setGeometry(QtCore.QRect(450, 300, 350, 150)) self.setGeometry(QtCore.QRect(450, 300, 350, 150))
self.send = QtGui.QCheckBox(self) self.send = QtWidgets.QCheckBox(self)
self.send.setGeometry(QtCore.QRect(20, 10, 310, 25)) self.send.setGeometry(QtCore.QRect(20, 10, 310, 25))
self.send.setText(QtGui.QApplication.translate('BirthDay', "Send my birthday date to contacts", None, QtGui.QApplication.UnicodeUTF8)) self.send.setText(QtWidgets.QApplication.translate('BirthDay', "Send my birthday date to contacts"))
self.setWindowTitle(QtGui.QApplication.translate('BirthDay', "Birthday", None, QtGui.QApplication.UnicodeUTF8)) self.setWindowTitle(QtWidgets.QApplication.translate('BirthDay', "Birthday"))
self.send.clicked.connect(self.update) self.send.clicked.connect(self.update)
self.send.setChecked(inst._data['send_date']) self.send.setChecked(inst._data['send_date'])
self.date = QtGui.QLineEdit(self) self.date = QtWidgets.QLineEdit(self)
self.date.setGeometry(QtCore.QRect(20, 50, 310, 25)) self.date.setGeometry(QtCore.QRect(20, 50, 310, 25))
self.date.setPlaceholderText(QtGui.QApplication.translate('BirthDay', "Date in format dd.mm.yyyy", None, QtGui.QApplication.UnicodeUTF8)) self.date.setPlaceholderText(QtWidgets.QApplication.translate('BirthDay', "Date in format dd.mm.yyyy"))
self.set_date = QtGui.QPushButton(self) self.set_date = QtWidgets.QPushButton(self)
self.set_date.setGeometry(QtCore.QRect(20, 90, 310, 25)) self.set_date.setGeometry(QtCore.QRect(20, 90, 310, 25))
self.set_date.setText(QtGui.QApplication.translate('BirthDay', "Save date", None, QtGui.QApplication.UnicodeUTF8)) self.set_date.setText(QtWidgets.QApplication.translate('BirthDay', "Save date"))
self.set_date.clicked.connect(self.save_curr_date) self.set_date.clicked.connect(self.save_curr_date)
self.date.setText(inst._data[x] if x in inst._data else '') self.date.setText(inst._data[x] if x in inst._data else '')

View File

@ -1,5 +1,5 @@
import plugin_super_class import plugin_super_class
from PySide import QtCore from PyQt5 import QtCore
import time import time

View File

@ -1,16 +1,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import collections import collections
import random
import re import re
import datetime
import itertools
import math import math
import plugin_super_class import plugin_super_class
from PySide.QtCore import * from PyQt5.QtCore import *
from PySide.QtGui import * from PyQt5.QtWidgets import *
from PySide.QtSvg import * from PyQt5.QtGui import *
from PyQt5.QtSvg import *
START_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" START_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
@ -1682,5 +1680,5 @@ class Chess(plugin_super_class.PluginSuperClass):
def get_menu(self, menu, num): def get_menu(self, menu, num):
act = QAction(QApplication.translate("Chess", "Start chess game", None, QApplication.UnicodeUTF8), menu) act = QAction(QApplication.translate("Chess", "Start chess game", None, QApplication.UnicodeUTF8), menu)
act.connect(act, SIGNAL("triggered()"), lambda: self.start_game(num)) act.triggered.connect(lambda: self.start_game(num))
return [act] return [act]

View File

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

View File

@ -1,7 +1,7 @@
import plugin_super_class import plugin_super_class
import threading import threading
import time import time
from PySide import QtCore from PyQt5 import QtCore
class InvokeEvent(QtCore.QEvent): class InvokeEvent(QtCore.QEvent):
@ -49,12 +49,15 @@ class Garland(plugin_super_class.PluginSuperClass):
def command(self, command): def command(self, command):
if command.startswith('time'): if command.startswith('time'):
self._time = max(int(command.split(' ')[1]), 0) / 1000 self._time = max(int(command.split(' ')[1]), 300) / 1000
else: else:
super().command(command) super().command(command)
def update(self):
self._profile.set_status((self._profile.status + 1) % 3)
def change_status(self): def change_status(self):
time.sleep(5) time.sleep(5)
while self._exec: while self._exec:
invoke_in_main_thread(self._profile.change_status) invoke_in_main_thread(self.update)
time.sleep(self._time) time.sleep(self._time)

View File

@ -1,7 +1,7 @@
import plugin_super_class import plugin_super_class
import threading import threading
import time import time
from PySide import QtCore from PyQt5 import QtCore
class InvokeEvent(QtCore.QEvent): class InvokeEvent(QtCore.QEvent):
@ -34,6 +34,7 @@ class MarqueeStatus(plugin_super_class.PluginSuperClass):
self._thread = None self._thread = None
self._exec = None self._exec = None
self.active = False self.active = False
self.left = True
def close(self): def close(self):
self.stop() self.stop()
@ -48,9 +49,18 @@ class MarqueeStatus(plugin_super_class.PluginSuperClass):
self._thread = threading.Thread(target=self.change_status) self._thread = threading.Thread(target=self.change_status)
self._thread.start() self._thread.start()
def command(self, command):
if command == 'rev':
self.left = not self.left
else:
super(MarqueeStatus, self).command(command)
def set_status_message(self): def set_status_message(self):
message = self._profile.status_message message = self._profile.status_message
self._profile.set_status_message(bytes(message[1:] + message[0], 'utf-8')) if self.left:
self._profile.set_status_message(bytes(message[1:] + message[0], 'utf-8'))
else:
self._profile.set_status_message(bytes(message[-1] + message[:-1], 'utf-8'))
def init_status(self): def init_status(self):
self._profile.status_message = bytes(self._profile.status_message.strip() + ' ', 'utf-8') self._profile.status_message = bytes(self._profile.status_message.strip() + ' ', 'utf-8')