From 12a395616c6d1cd5fee22e5fd679ac6b5aa1e720 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 20 Jun 2017 20:55:11 +0300 Subject: [PATCH] initial --- AutoAwayStatusLinux/awayl.py | 16 +++++++------- AutoAwayStatusWindows/awayw.py | 19 ++++++++--------- BirthDay/bday.py | 24 ++++++++++----------- Bot/bot.py | 2 +- Chess/chess.py | 12 +++++------ CopyableToxId/toxid.py | 38 +++++++++++++++++----------------- Garland/garland.py | 9 +++++--- MarqueeStatus/mrq.py | 14 +++++++++++-- 8 files changed, 72 insertions(+), 62 deletions(-) diff --git a/AutoAwayStatusLinux/awayl.py b/AutoAwayStatusLinux/awayl.py index f30c531..7a3067a 100644 --- a/AutoAwayStatusLinux/awayl.py +++ b/AutoAwayStatusLinux/awayl.py @@ -1,7 +1,7 @@ import plugin_super_class import threading import time -from PySide import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from subprocess import check_output import json @@ -64,21 +64,21 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass): 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.label = QtGui.QLabel(self) + self.label = QtWidgets.QLabel(self) 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.time = QtGui.QLineEdit(self) + self.label.setText(QtWidgets.QApplication.translate("AutoAwayStatusLinux", "Auto away time in minutes\n(0 - to disable)")) + self.time = QtWidgets.QLineEdit(self) self.time.setGeometry(QtCore.QRect(20, 40, 310, 25)) self.time.setText(str(inst._time)) self.setWindowTitle("AutoAwayStatusLinux") - self.ok = QtGui.QPushButton(self) + self.ok = QtWidgets.QPushButton(self) self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25)) self.ok.setText( - QtGui.QApplication.translate("AutoAwayStatusLinux", "Save", None, QtGui.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("AutoAwayStatusLinux", "Save")) self.ok.clicked.connect(self.update) def update(self): @@ -102,4 +102,4 @@ class AutoAwayStatusLinux(plugin_super_class.PluginSuperClass): if d > 60 * self._time: self.change_status() elif self._profile.status == 1: - self.change_status(self._prev_status) + self.change_status(self._prev_status) \ No newline at end of file diff --git a/AutoAwayStatusWindows/awayw.py b/AutoAwayStatusWindows/awayw.py index 062cf80..5c4b768 100644 --- a/AutoAwayStatusWindows/awayw.py +++ b/AutoAwayStatusWindows/awayw.py @@ -1,7 +1,7 @@ import plugin_super_class import threading import time -from PySide import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from ctypes import Structure, windll, c_uint, sizeof, byref import json @@ -68,29 +68,28 @@ class AutoAwayStatusWindows(plugin_super_class.PluginSuperClass): self.save_settings('{"time": ' + str(self._time) + '}') def change_status(self, status=1): - if self._profile.status in (0, 2): + if self._profile.status != 1: 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): 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.label = QtGui.QLabel(self) + self.label = QtWidgets.QLabel(self) 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.time = QtGui.QLineEdit(self) + self.label.setText(QtWidgets.QApplication.translate("AutoAwayStatusWindows", "Auto away time in minutes\n(0 - to disable)")) + self.time = QtWidgets.QLineEdit(self) self.time.setGeometry(QtCore.QRect(20, 40, 310, 25)) self.time.setText(str(inst._time)) self.setWindowTitle("AutoAwayStatusWindows") - self.ok = QtGui.QPushButton(self) + self.ok = QtWidgets.QPushButton(self) self.ok.setGeometry(QtCore.QRect(20, 70, 310, 25)) self.ok.setText( - QtGui.QApplication.translate("AutoAwayStatusWindows", "Save", None, QtGui.QApplication.UnicodeUTF8)) + QtWidgets.QApplication.translate("AutoAwayStatusWindows", "Save")) self.ok.clicked.connect(self.update) def update(self): diff --git a/BirthDay/bday.py b/BirthDay/bday.py index 5428db3..a341929 100644 --- a/BirthDay/bday.py +++ b/BirthDay/bday.py @@ -1,5 +1,5 @@ import plugin_super_class -from PySide import QtGui, QtCore +from PyQt5 import QtWidgets, QtCore import json import importlib @@ -22,9 +22,9 @@ class BirthDay(plugin_super_class.PluginSuperClass): if int(arr[0]) == now.day and int(arr[1]) == now.month: today[key] = now.year - int(arr[2]) if len(today): - msgbox = QtGui.QMessageBox() - title = QtGui.QApplication.translate('BirthDay', "Birthday!", None, - QtGui.QApplication.UnicodeUTF8) + msgbox = QtWidgets.QMessageBox() + title = QtWidgets.QApplication.translate('BirthDay', "Birthday!", None, + QtWidgets.QApplication.UnicodeUTF8) 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) msgbox.setText('Birthdays: ' + text) @@ -34,23 +34,23 @@ class BirthDay(plugin_super_class.PluginSuperClass): inst = self x = self._profile.tox_id[:64] - class Window(QtGui.QWidget): + class Window(QtWidgets.QWidget): def __init__(self): super(Window, self).__init__() 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.setText(QtGui.QApplication.translate('BirthDay', "Send my birthday date to contacts", None, QtGui.QApplication.UnicodeUTF8)) - self.setWindowTitle(QtGui.QApplication.translate('BirthDay', "Birthday", None, QtGui.QApplication.UnicodeUTF8)) + self.send.setText(QtWidgets.QApplication.translate('BirthDay', "Send my birthday date to contacts")) + self.setWindowTitle(QtWidgets.QApplication.translate('BirthDay', "Birthday")) self.send.clicked.connect(self.update) 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.setPlaceholderText(QtGui.QApplication.translate('BirthDay', "Date in format dd.mm.yyyy", None, QtGui.QApplication.UnicodeUTF8)) - self.set_date = QtGui.QPushButton(self) + self.date.setPlaceholderText(QtWidgets.QApplication.translate('BirthDay', "Date in format dd.mm.yyyy")) + self.set_date = QtWidgets.QPushButton(self) 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.date.setText(inst._data[x] if x in inst._data else '') diff --git a/Bot/bot.py b/Bot/bot.py index 9616331..18031ae 100644 --- a/Bot/bot.py +++ b/Bot/bot.py @@ -1,5 +1,5 @@ import plugin_super_class -from PySide import QtCore +from PyQt5 import QtCore import time diff --git a/Chess/chess.py b/Chess/chess.py index 9a4894a..7c992a9 100644 --- a/Chess/chess.py +++ b/Chess/chess.py @@ -1,16 +1,14 @@ # -*- coding: utf-8 -*- import collections -import random import re -import datetime -import itertools import math import plugin_super_class -from PySide.QtCore import * -from PySide.QtGui import * -from PySide.QtSvg import * +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.QtSvg import * 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): 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] diff --git a/CopyableToxId/toxid.py b/CopyableToxId/toxid.py index be79803..0808f68 100644 --- a/CopyableToxId/toxid.py +++ b/CopyableToxId/toxid.py @@ -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 : 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] diff --git a/Garland/garland.py b/Garland/garland.py index 7b0d66c..cd216be 100644 --- a/Garland/garland.py +++ b/Garland/garland.py @@ -1,7 +1,7 @@ import plugin_super_class import threading import time -from PySide import QtCore +from PyQt5 import QtCore class InvokeEvent(QtCore.QEvent): @@ -49,12 +49,15 @@ class Garland(plugin_super_class.PluginSuperClass): def command(self, command): if command.startswith('time'): - self._time = max(int(command.split(' ')[1]), 0) / 1000 + self._time = max(int(command.split(' ')[1]), 300) / 1000 else: super().command(command) + def update(self): + self._profile.set_status((self._profile.status + 1) % 3) + def change_status(self): time.sleep(5) while self._exec: - invoke_in_main_thread(self._profile.change_status) + invoke_in_main_thread(self.update) time.sleep(self._time) diff --git a/MarqueeStatus/mrq.py b/MarqueeStatus/mrq.py index e71ff00..30adeb9 100644 --- a/MarqueeStatus/mrq.py +++ b/MarqueeStatus/mrq.py @@ -1,7 +1,7 @@ import plugin_super_class import threading import time -from PySide import QtCore +from PyQt5 import QtCore class InvokeEvent(QtCore.QEvent): @@ -34,6 +34,7 @@ class MarqueeStatus(plugin_super_class.PluginSuperClass): self._thread = None self._exec = None self.active = False + self.left = True def close(self): self.stop() @@ -48,9 +49,18 @@ class MarqueeStatus(plugin_super_class.PluginSuperClass): self._thread = threading.Thread(target=self.change_status) 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): 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): self._profile.status_message = bytes(self._profile.status_message.strip() + ' ', 'utf-8')