commit 51f1d6d831758077d06db22544be959ce4b8d516 Author: BarsTiger Date: Sat Aug 27 15:45:03 2022 +0300 Added code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d88e25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.idea/ +/venv/ +/build/ +/tests/ +*.spec +*/config.json \ No newline at end of file diff --git a/ConsistentLibraryOfBabel.py b/ConsistentLibraryOfBabel.py new file mode 100644 index 0000000..9df00f7 --- /dev/null +++ b/ConsistentLibraryOfBabel.py @@ -0,0 +1,16 @@ +from ui.gui import Ui_MainWindow +from PyQt5 import QtWidgets +from ui.modules.initialize import setup_ui +import sys + +sys.setrecursionlimit(2_147_483_647) + +app = QtWidgets.QApplication(sys.argv) +MainWindow = QtWidgets.QMainWindow() +ui = Ui_MainWindow() +ui.setupUi(MainWindow) +setup_ui.on_load(ui, MainWindow) + +MainWindow.show() + +sys.exit(app.exec_()) diff --git a/README.md b/README.md new file mode 100644 index 0000000..5b6e1f8 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Consistent Library of Babel + +## Everything was written already + +It is consistent version of **Library of Everything** + +Some example charsets for `config.json` (space will be added automatically) + +English lowercase - `"abcdefghijklmnopqrstuvwxyz"` + +English full - `"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"` + +English full with symbols - `"!?(),.:;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"` + +Russian + Ukrainian + English + Symbols - `"!?(),.:;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzЁІЇАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяёіїҐґ"` + diff --git a/modules/__init__.py b/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modules/config/__init__.py b/modules/config/__init__.py new file mode 100644 index 0000000..eeb0a97 --- /dev/null +++ b/modules/config/__init__.py @@ -0,0 +1 @@ +from .config import charset diff --git a/modules/config/config.py b/modules/config/config.py new file mode 100644 index 0000000..331574d --- /dev/null +++ b/modules/config/config.py @@ -0,0 +1,11 @@ +import json + +try: + config = json.load(open('config.json', encoding='utf-8')) +except: + config = { + "charset": "abcdefghijklmnopqrstuvwxyz" + } + json.dump(config, open('config.json', 'w', encoding='utf-8'), indent=4) + +charset = ''.join(sorted(list(set(' ' + config['charset'])))) diff --git a/modules/generator/__init__.py b/modules/generator/__init__.py new file mode 100644 index 0000000..fde88ff --- /dev/null +++ b/modules/generator/__init__.py @@ -0,0 +1 @@ +from .pages import Page, Index diff --git a/modules/generator/pages.py b/modules/generator/pages.py new file mode 100644 index 0000000..fece184 --- /dev/null +++ b/modules/generator/pages.py @@ -0,0 +1,42 @@ +from modules.config import charset +from ezzthread import threaded + + +def encode(n): + try: + return charset[n] + except IndexError: + raise Exception(f"Cannot encode {n}") + + +def decode(s): + try: + return charset.index(s) + except ValueError: + raise Exception(f"Cannot decode {s}") + + +def dec_to_base(dec=0, base=16): + if dec < base: + return encode(dec) + else: + return dec_to_base(dec // base, base) + encode(dec % base) + + +def base_to_dec(s, base=16, rec_pow=0): + if s == str(): + return 0 + else: + return decode(s[-1]) * (base ** rec_pow) + base_to_dec(s[0:-1], base, rec_pow + 1) + + +class Page: + @staticmethod + def from_index(index: int) -> str: + return dec_to_base(index, len(charset)) + + +class Index: + @staticmethod + def from_page(page: str) -> int: + return base_to_dec(page, len(charset)) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3d7ef7b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +wheel +PyQt5 +pyinstaller \ No newline at end of file diff --git a/ui/__init__.py b/ui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/gui.py b/ui/gui.py new file mode 100644 index 0000000..82631ef --- /dev/null +++ b/ui/gui.py @@ -0,0 +1,361 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'gui.ui' +# +# Created by: PyQt5 UI code generator 5.15.7 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(800, 400) + MainWindow.setStyleSheet("QWidget {\n" +" background-color: rgba(30, 30, 30, 0.1);\n" +" color: white;\n" +" font: 10pt \"Segoe UI\";\n" +"}\n" +"\n" +"\n" +"QScrollBar:vertical,\n" +"QScrollBar:horizontal {\n" +" border: none;\n" +" background: rgba(30, 30, 30, 0);\n" +" width: 10px;\n" +" margin: 15px 0 15px 0;\n" +" border-radius: 0px;\n" +"}\n" +"\n" +"QScrollBar::handle:vertical,\n" +"QScrollBar::handle:horizontal { \n" +" background-color: rgba(139, 139, 139, 0);\n" +" min-height: 30px;\n" +" border-radius: 5px;\n" +"}\n" +"\n" +"QScrollBar::handle:vertical:hover,\n" +"QScrollBar::handle:vertical:pressed,\n" +"QScrollBar::handle:horizontal:hover,\n" +"QScrollBar::handle:horizontal:pressed { \n" +" background-color: rgba(149, 149, 149, 0);\n" +"}\n" +"\n" +"QScrollBar::sub-line:vertical,\n" +"QScrollBar::add-line:vertical,\n" +"QScrollBar::up-arrow:vertical,\n" +"QScrollBar::down-arrow:vertical {\n" +" height: 0px;\n" +"}\n" +"\n" +"QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical,\n" +"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, \n" +"QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal,\n" +"QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {\n" +" background: none;\n" +"}\n" +"\n" +"\n" +"QPushButton {\n" +" color: white;\n" +" border-width: 1px;\n" +" border-radius:6px;\n" +" border-style: solid;\n" +" border-color: rgba(48, 48, 48, 0.5);\n" +" background-color: rgba(44, 45, 46, 0.3);\n" +"}\n" +"QPushButton:hover {\n" +" border-width: 2px;\n" +" background-color: rgba(50, 50, 50, 0.7);\n" +"}\n" +"QPushButton:pressed {\n" +" background-color: rgba(38, 39, 40, 0.7);\n" +"}\n" +"QPushButton:disabled {\n" +" background-color: rgba(67, 67, 67, 0.7);\n" +" border-color: rgba(0, 0, 0, 0.7);\n" +"}\n" +"\n" +"\n" +"QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit {\n" +" border-width: 1px;\n" +" border-radius: 5px;\n" +" border-style: solid;\n" +" border-color: rgba(48, 48, 48);\n" +" background-color: rgba(36, 36, 36, 0);\n" +" font: 10pt \"Segoe UI\";\n" +"}\n" +"\n" +"\n" +"QListWidget {\n" +" border-width: 1px;\n" +" border-radius: 15px;\n" +" border-style: solid;\n" +" border-color: rgba(48, 48, 48);\n" +" padding: 10px;\n" +" background-color: rgba(100, 100, 100, 0);\n" +" font: 10pt \"Segoe UI\";\n" +"}\n" +"QListWidget:item {\n" +" background-color: rgba(36, 36, 36, 0);\n" +" selection-color: white;\n" +"}\n" +"QListWidget:item:hover {\n" +" background-color: rgba(50, 50, 50, 0);\n" +"}\n" +"QListWidget:item:selected {\n" +" background-color: rgba(119, 119, 119, 1);\n" +"}\n" +"\n" +"\n" +"QComboBox\n" +"{\n" +" border-width: 1px;\n" +" border-radius:6px;\n" +" border-style: solid;\n" +" border-color: rgba(48, 48, 48);\n" +" background-color: rgba(44, 45, 46, 0);\n" +" color: white;\n" +"}\n" +"\n" +"QComboBox::disabled\n" +"{\n" +" background-color: rgba(67, 67, 67, 0);\n" +" color: #656565;\n" +" border-color: rgba(67, 67, 67);\n" +"}\n" +"\n" +"QComboBox:hover\n" +"{\n" +" background-color: rgba(50, 50, 50, 0);\n" +"}\n" +"\n" +"QComboBox:on\n" +"{\n" +" background-color: rgba(67, 67, 67, 0);\n" +"}\n" +"\n" +"QComboBox QAbstractItemView\n" +"{\n" +" background-color: rgba(67, 67, 67, 0);\n" +" color: #ffffff;\n" +" selection-background-color: rgba(119, 119, 119, 0);\n" +" selection-color: white;\n" +" outline: 0;\n" +"}\n" +"\n" +"QComboBox::drop-down\n" +"{\n" +" subcontrol-origin: padding;\n" +" subcontrol-position: top right;\n" +" border-radius: 6px; \n" +"}\n" +"\n" +"\n" +"QTabBar::tab\n" +"{\n" +" background-color: rgba(44, 45, 46, 0);\n" +" color: #ffffff;\n" +" border-style: solid;\n" +" border-width: 1px;\n" +" border-top-left-radius: 3px;\n" +" border-top-right-radius: 3px;\n" +" border-color: rgba(48, 48, 48);\n" +" padding: 5px;\n" +"}\n" +"\n" +"QTabBar::tab:disabled\n" +"{\n" +" background-color: rgba(101, 101, 101, 0);\n" +" color: #656565;\n" +"}\n" +"\n" +"QTabWidget::pane \n" +"{\n" +" background-color: rgba(160, 160, 160, 0);\n" +" color: #ffffff;\n" +" border: 3px solid;\n" +" border-radius: 15px;\n" +" border-color: rgba(28, 28, 28);\n" +"}\n" +"\n" +"QTabBar::tab:selected\n" +"{\n" +" background-color: rgba(38, 39, 40, 0);\n" +" color: #ffffff;\n" +" border-style: solid;\n" +" border-width: 1px;\n" +" border-top-left-radius: 3px;\n" +" border-top-right-radius: 3px;\n" +" border-color: rgba(48, 48, 48);\n" +" padding: 5px;\n" +"}\n" +"\n" +"QTabBar::tab:selected:disabled\n" +"{\n" +" background-color: rgba(64, 64, 64, 0);\n" +" color: #656565;\n" +"}\n" +"\n" +"QTabBar::tab:!selected \n" +"{\n" +" background-color: rgba(38, 38, 38, 0);\n" +"}\n" +"\n" +"QTabBar::tab:!selected:hover \n" +"{\n" +" background-color: rgba(50, 50, 50, 0);\n" +"}\n" +"\n" +"QTabBar::tab:top:!selected \n" +"{\n" +" margin-top: 3px;\n" +"}\n" +"\n" +"QTabBar::tab:bottom:!selected \n" +"{\n" +" margin-bottom: 3px;\n" +"}\n" +"\n" +"QTabBar::tab:top, QTabBar::tab:bottom \n" +"{\n" +" min-width: 8ex;\n" +" margin-right: -1px;\n" +" padding: 5px 10px 5px 10px;\n" +"}\n" +"\n" +"QTabBar::tab:top:selected \n" +"{\n" +" border-bottom-color: none;\n" +"}\n" +"\n" +"QTabBar::tab:bottom:selected \n" +"{\n" +" border-top-color: none;\n" +"}\n" +"\n" +"QTabBar::tab:top:last, QTabBar::tab:bottom:last,\n" +"QTabBar::tab:top:only-one, QTabBar::tab:bottom:only-one \n" +"{\n" +" margin-right: 0;\n" +"}\n" +"\n" +"QTabBar::tab:left:!selected \n" +"{\n" +" margin-right: 3px;\n" +"}\n" +"\n" +"QTabBar::tab:right:!selected\n" +"{\n" +" margin-left: 3px;\n" +"}\n" +"\n" +"QTabBar::tab:left, QTabBar::tab:right \n" +"{\n" +" min-height: 8ex;\n" +" margin-bottom: -1px;\n" +" padding: 10px 5px 10px 5px;\n" +"}\n" +"\n" +"QTabBar::tab:left:selected \n" +"{\n" +" border-left-color: none;\n" +"}\n" +"\n" +"QTabBar::tab:right:selected \n" +"{\n" +" border-right-color: none;\n" +"}\n" +"\n" +"QTabBar::tab:left:last, QTabBar::tab:right:last,\n" +"QTabBar::tab:left:only-one, QTabBar::tab:right:only-one \n" +"{\n" +" margin-bottom: 0;\n" +"}\n" +"\n" +"QSpinBox {\n" +" border-width: 1px;\n" +" border-radius: 5px;\n" +" border-style: solid;\n" +" border-color: rgba(48, 48, 48);\n" +" background-color: rgba(36, 36, 36, 0);\n" +" font: 10pt \"Segoe UI\";\n" +"}\n" +"QSpinBox::up-button {\n" +" border: none;\n" +" background: none;\n" +"}\n" +"QSpinBox::down-button {\n" +" border: none;\n" +" background: none;\n" +"}\n" +"\n" +"QToolBox::tab {\n" +" border-style: solid;\n" +" border-width: 1px;\n" +" border-radius: 5px;\n" +" border-color: rgba(48, 48, 48, 0);\n" +"}") + MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.page_text = QtWidgets.QPlainTextEdit(self.centralwidget) + self.page_text.setStyleSheet("font: 14pt \"Segoe UI\";") + self.page_text.setObjectName("page_text") + self.verticalLayout.addWidget(self.page_text) + self.index_widget = QtWidgets.QWidget(self.centralwidget) + self.index_widget.setObjectName("index_widget") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.index_widget) + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.back_button = QtWidgets.QPushButton(self.index_widget) + self.back_button.setMinimumSize(QtCore.QSize(64, 64)) + self.back_button.setMaximumSize(QtCore.QSize(64, 64)) + self.back_button.setText("") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/img/img/back.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.back_button.setIcon(icon) + self.back_button.setIconSize(QtCore.QSize(40, 40)) + self.back_button.setObjectName("back_button") + self.horizontalLayout.addWidget(self.back_button) + self.page_index = QtWidgets.QLineEdit(self.index_widget) + self.page_index.setMinimumSize(QtCore.QSize(0, 64)) + self.page_index.setMaxLength(2932) + self.page_index.setObjectName("page_index") + self.horizontalLayout.addWidget(self.page_index) + self.next_button = QtWidgets.QPushButton(self.index_widget) + self.next_button.setMinimumSize(QtCore.QSize(64, 64)) + self.next_button.setMaximumSize(QtCore.QSize(64, 64)) + self.next_button.setText("") + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(":/img/img/next.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.next_button.setIcon(icon1) + self.next_button.setIconSize(QtCore.QSize(40, 40)) + self.next_button.setObjectName("next_button") + self.horizontalLayout.addWidget(self.next_button) + self.verticalLayout.addWidget(self.index_widget) + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "ConsistentLibraryOfBabel")) +import ui.images_rc + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + MainWindow = QtWidgets.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_()) diff --git a/ui/gui.ui b/ui/gui.ui new file mode 100644 index 0000000..3e4b3ac --- /dev/null +++ b/ui/gui.ui @@ -0,0 +1,411 @@ + + + MainWindow + + + + 0 + 0 + 800 + 400 + + + + ConsistentLibraryOfBabel + + + QWidget { + background-color: rgba(30, 30, 30, 0.1); + color: white; + font: 10pt "Segoe UI"; +} + + +QScrollBar:vertical, +QScrollBar:horizontal { + border: none; + background: rgba(30, 30, 30, 0); + width: 10px; + margin: 15px 0 15px 0; + border-radius: 0px; +} + +QScrollBar::handle:vertical, +QScrollBar::handle:horizontal { + background-color: rgba(139, 139, 139, 0); + min-height: 30px; + border-radius: 5px; +} + +QScrollBar::handle:vertical:hover, +QScrollBar::handle:vertical:pressed, +QScrollBar::handle:horizontal:hover, +QScrollBar::handle:horizontal:pressed { + background-color: rgba(149, 149, 149, 0); +} + +QScrollBar::sub-line:vertical, +QScrollBar::add-line:vertical, +QScrollBar::up-arrow:vertical, +QScrollBar::down-arrow:vertical { + height: 0px; +} + +QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical, +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, +QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal, +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { + background: none; +} + + +QPushButton { + color: white; + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: rgba(48, 48, 48, 0.5); + background-color: rgba(44, 45, 46, 0.3); +} +QPushButton:hover { + border-width: 2px; + background-color: rgba(50, 50, 50, 0.7); +} +QPushButton:pressed { + background-color: rgba(38, 39, 40, 0.7); +} +QPushButton:disabled { + background-color: rgba(67, 67, 67, 0.7); + border-color: rgba(0, 0, 0, 0.7); +} + + +QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(36, 36, 36, 0); + font: 10pt "Segoe UI"; +} + + +QListWidget { + border-width: 1px; + border-radius: 15px; + border-style: solid; + border-color: rgba(48, 48, 48); + padding: 10px; + background-color: rgba(100, 100, 100, 0); + font: 10pt "Segoe UI"; +} +QListWidget:item { + background-color: rgba(36, 36, 36, 0); + selection-color: white; +} +QListWidget:item:hover { + background-color: rgba(50, 50, 50, 0); +} +QListWidget:item:selected { + background-color: rgba(119, 119, 119, 1); +} + + +QComboBox +{ + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(44, 45, 46, 0); + color: white; +} + +QComboBox::disabled +{ + background-color: rgba(67, 67, 67, 0); + color: #656565; + border-color: rgba(67, 67, 67); +} + +QComboBox:hover +{ + background-color: rgba(50, 50, 50, 0); +} + +QComboBox:on +{ + background-color: rgba(67, 67, 67, 0); +} + +QComboBox QAbstractItemView +{ + background-color: rgba(67, 67, 67, 0); + color: #ffffff; + selection-background-color: rgba(119, 119, 119, 0); + selection-color: white; + outline: 0; +} + +QComboBox::drop-down +{ + subcontrol-origin: padding; + subcontrol-position: top right; + border-radius: 6px; +} + + +QTabBar::tab +{ + background-color: rgba(44, 45, 46, 0); + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: rgba(48, 48, 48); + padding: 5px; +} + +QTabBar::tab:disabled +{ + background-color: rgba(101, 101, 101, 0); + color: #656565; +} + +QTabWidget::pane +{ + background-color: rgba(160, 160, 160, 0); + color: #ffffff; + border: 3px solid; + border-radius: 15px; + border-color: rgba(28, 28, 28); +} + +QTabBar::tab:selected +{ + background-color: rgba(38, 39, 40, 0); + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: rgba(48, 48, 48); + padding: 5px; +} + +QTabBar::tab:selected:disabled +{ + background-color: rgba(64, 64, 64, 0); + color: #656565; +} + +QTabBar::tab:!selected +{ + background-color: rgba(38, 38, 38, 0); +} + +QTabBar::tab:!selected:hover +{ + background-color: rgba(50, 50, 50, 0); +} + +QTabBar::tab:top:!selected +{ + margin-top: 3px; +} + +QTabBar::tab:bottom:!selected +{ + margin-bottom: 3px; +} + +QTabBar::tab:top, QTabBar::tab:bottom +{ + min-width: 8ex; + margin-right: -1px; + padding: 5px 10px 5px 10px; +} + +QTabBar::tab:top:selected +{ + border-bottom-color: none; +} + +QTabBar::tab:bottom:selected +{ + border-top-color: none; +} + +QTabBar::tab:top:last, QTabBar::tab:bottom:last, +QTabBar::tab:top:only-one, QTabBar::tab:bottom:only-one +{ + margin-right: 0; +} + +QTabBar::tab:left:!selected +{ + margin-right: 3px; +} + +QTabBar::tab:right:!selected +{ + margin-left: 3px; +} + +QTabBar::tab:left, QTabBar::tab:right +{ + min-height: 8ex; + margin-bottom: -1px; + padding: 10px 5px 10px 5px; +} + +QTabBar::tab:left:selected +{ + border-left-color: none; +} + +QTabBar::tab:right:selected +{ + border-right-color: none; +} + +QTabBar::tab:left:last, QTabBar::tab:right:last, +QTabBar::tab:left:only-one, QTabBar::tab:right:only-one +{ + margin-bottom: 0; +} + +QSpinBox { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(36, 36, 36, 0); + font: 10pt "Segoe UI"; +} +QSpinBox::up-button { + border: none; + background: none; +} +QSpinBox::down-button { + border: none; + background: none; +} + +QToolBox::tab { + border-style: solid; + border-width: 1px; + border-radius: 5px; + border-color: rgba(48, 48, 48, 0); +} + + + Qt::ToolButtonIconOnly + + + + + + + font: 14pt "Segoe UI"; + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + :/img/img/back.png:/img/img/back.png + + + + 40 + 40 + + + + + + + + + 0 + 64 + + + + 2932 + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + :/img/img/next.png:/img/img/next.png + + + + 40 + 40 + + + + + + + + + + + + + + + diff --git a/ui/images.qrc b/ui/images.qrc new file mode 100644 index 0000000..d2fb7e0 --- /dev/null +++ b/ui/images.qrc @@ -0,0 +1,6 @@ + + + img/back.png + img/next.png + + diff --git a/ui/images_rc.py b/ui/images_rc.py new file mode 100644 index 0000000..1468fa4 --- /dev/null +++ b/ui/images_rc.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- + +# Resource object code +# +# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2) +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore + +qt_resource_data = b"\ +\x00\x00\x01\xb0\ +\x89\ +\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ +\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\ +\x00\x00\x00\x01\x73\x52\x47\x42\x00\xae\xce\x1c\xe9\x00\x00\x00\ +\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\x00\x00\ +\x09\x70\x48\x59\x73\x00\x00\x0e\xc3\x00\x00\x0e\xc3\x01\xc7\x6f\ +\xa8\x64\x00\x00\x01\x45\x49\x44\x41\x54\x78\x5e\xed\xdb\x3d\x4a\ +\xc4\x50\x18\x46\xe1\x20\xee\x40\xd4\x46\xb4\xb3\xb6\x72\x05\x2e\ +\x41\x45\xd4\xb5\xd8\xc4\x85\x45\x88\x45\xec\xf2\xe3\x52\x12\x49\ +\x32\xa3\x9e\xc0\x17\xe1\x12\x62\x21\x16\x7a\xbf\xf7\x69\x86\xcc\ +\xa4\x39\x2f\x33\x03\x13\x26\x89\x88\xfc\x8a\x3d\x1c\xc3\x0e\x7d\ +\x79\x40\xdf\xf7\xc3\x07\xb2\x2c\x7b\x3a\x84\xbd\x14\xbf\x33\x6c\ +\xb7\xdb\xf7\x29\x7e\xd6\x34\xcd\xab\x9b\x11\x6e\x60\xdd\x01\x37\ +\x23\x1c\xa1\x6d\xdb\xce\xba\x03\x6e\x46\xb8\xc4\x30\x0c\xa3\x75\ +\x07\xea\xba\x6e\x5c\x8c\x70\x8b\x71\x1c\x37\xd6\x1d\xa8\xaa\xaa\ +\x3e\x80\x9d\x1a\x2f\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\ +\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\ +\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x00\x8d\x80\x6b\xac\x5d\ +\x6d\x2e\x8a\xe2\x65\x17\x76\x6a\xbc\xbe\x7b\x27\x5c\xc0\x4e\xfb\ +\xb1\x1d\x7b\xfc\xb3\x36\x98\x62\xed\x30\xb0\xf6\x7c\x34\x5c\x7f\ +\x04\xee\xb0\xf6\xd6\x2f\xcb\xb2\xda\x87\x9d\x1a\x1f\xc5\x2b\x7e\ +\x49\xf1\x8a\x8f\x94\xe2\x15\xbf\xa4\x78\xc5\x47\x4a\xf1\x2b\xf1\ +\xd3\x05\x0e\xd7\xf1\x51\x5f\xdd\x51\xbc\xe2\x97\x14\xaf\xf8\x48\ +\x29\xde\x6b\xfc\x15\xdc\xfe\x5d\xfe\x04\x5d\xd7\xbd\x59\x6f\xc0\ +\xc5\x0d\x13\xf7\xb0\xde\x80\x9b\xbb\x45\xce\x61\xcd\x5f\x5c\xdd\ +\x34\x35\x49\xd3\xf4\x71\xfe\x02\xcc\xf3\xfc\xd9\x55\xfc\x6c\xfa\ +\x35\x77\x0a\x3b\x14\x91\xff\x20\x49\x3e\x01\xba\x26\x04\xe0\xd9\ +\xf1\x5c\x00\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ +\x00\x00\x01\x8a\ +\x89\ +\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ +\x00\x00\x40\x00\x00\x00\x40\x08\x06\x00\x00\x00\xaa\x69\x71\xde\ +\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0\xbd\ +\xa7\x93\x00\x00\x01\x3f\x49\x44\x41\x54\x78\x9c\xed\x9b\x31\x2e\ +\x04\x61\x00\x46\x1f\x71\x03\x59\xdb\x08\x9d\x88\x4a\xe5\x04\x8e\ +\x80\x02\x67\x51\x39\x97\x44\xa1\x51\xb2\xae\x42\x62\x37\x9e\xc2\ +\x12\x24\x33\x5b\xd8\x7f\x7e\x3b\xf3\xbd\x72\x36\x99\x7c\xef\x4d\ +\x66\x8a\xd9\x5d\x08\x21\xac\x12\xea\x8e\xba\x59\x7b\x47\xe7\xa8\ +\x63\xf5\xd6\x0f\x5e\xd5\xab\xda\x9b\x3a\x63\x2e\xff\xe4\x4f\xde\ +\xd4\xc3\xbf\x9e\x7b\x7d\x19\x03\x4b\xa2\x8e\x81\x1b\xe0\xe0\xd7\ +\x47\x6b\xc0\x7e\xf7\x8b\x3a\xa4\xe1\xca\x7f\xf2\xac\x6e\xd7\xde\ +\x58\x8c\xb9\xfc\xa4\x41\x7e\xaa\x9e\xd4\xde\x58\x0c\x75\x4b\x7d\ +\x6c\x90\x9f\xa9\xe7\xb5\x37\x16\x23\xf2\x91\x8f\x7c\xe4\x23\x1f\ +\xf9\xc8\x47\xbe\x97\x44\x3e\xf2\x91\x8f\x7c\xe4\x23\x1f\xf9\xc8\ +\xf7\x92\xc8\x0f\x58\x7e\x43\xbd\x6f\x90\x9f\xaa\x67\xb5\x37\x16\ +\x45\x3d\x5e\xe5\x2b\xbf\x8c\x6f\x86\x6c\x39\x3e\x5b\xc2\xf9\xff\ +\x37\x83\xbf\x05\x00\xd4\x91\xfa\xd0\x72\x2b\x5c\xd4\xde\x58\x9c\ +\x44\x20\x11\x80\x44\x00\x12\x01\x48\x04\x20\x11\x80\x44\x00\x12\ +\x01\x48\x04\x20\x11\x80\x44\x00\xbe\x22\xb4\xbd\x40\x19\x44\x84\ +\x45\x6f\x91\x12\x21\x11\x12\x21\x11\x12\x21\x11\x12\x61\xb8\x11\ +\x16\xfd\x5c\xfe\xb4\xf6\xc6\xe2\xd8\xfe\x87\x89\x17\x75\xb7\xf6\ +\xc6\xe2\x2c\x88\x70\x59\x7b\x5f\x27\xb4\x44\x38\xaa\xbd\xad\x33\ +\xe6\x11\xee\xbe\x3d\x08\xaf\x6b\x6f\xaa\x82\xba\xa7\x8e\x6a\xef\ +\x08\xa1\x27\xbc\x03\x85\x53\x0e\x31\xd2\xc1\xa0\x73\x00\x00\x00\ +\x00\x49\x45\x4e\x44\xae\x42\x60\x82\ +" + +qt_resource_name = b"\ +\x00\x03\ +\x00\x00\x70\x37\ +\x00\x69\ +\x00\x6d\x00\x67\ +\x00\x08\ +\x0c\xf7\x59\xc7\ +\x00\x6e\ +\x00\x65\x00\x78\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\ +\x00\x08\ +\x07\x9e\x5a\x47\ +\x00\x62\ +\x00\x61\x00\x63\x00\x6b\x00\x2e\x00\x70\x00\x6e\x00\x67\ +" + +qt_resource_struct_v1 = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x03\ +\x00\x00\x00\x22\x00\x00\x00\x00\x00\x01\x00\x00\x01\xb4\ +\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +" + +qt_resource_struct_v2 = b"\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x03\ +\x00\x00\x00\x00\x00\x00\x00\x00\ +\x00\x00\x00\x22\x00\x00\x00\x00\x00\x01\x00\x00\x01\xb4\ +\x00\x00\x01\x82\x5f\x53\x50\xd3\ +\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ +\x00\x00\x01\x82\x5f\x5d\x42\x4b\ +" + +qt_version = [int(v) for v in QtCore.qVersion().split('.')] +if qt_version < [5, 8, 0]: + rcc_version = 1 + qt_resource_struct = qt_resource_struct_v1 +else: + rcc_version = 2 + qt_resource_struct = qt_resource_struct_v2 + +def qInitResources(): + QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + +def qCleanupResources(): + QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + +qInitResources() diff --git a/ui/img/back.png b/ui/img/back.png new file mode 100644 index 0000000..ea24fdd Binary files /dev/null and b/ui/img/back.png differ diff --git a/ui/img/next.png b/ui/img/next.png new file mode 100644 index 0000000..4c5b0a8 Binary files /dev/null and b/ui/img/next.png differ diff --git a/ui/modules/__init__.py b/ui/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/modules/blur.py b/ui/modules/blur.py new file mode 100644 index 0000000..44af303 --- /dev/null +++ b/ui/modules/blur.py @@ -0,0 +1,133 @@ +# source: https://github.com/Opticos/GWSL-Source/blob/master/blur.py, +# https://www.cnblogs.com/zhiyiYo/p/14659981.html , +# https://github.com/ifwe/digsby/blob/master/digsby/src/gui/vista.py +import platform +import ctypes + + +if platform.system() == 'Windows': + from ctypes.wintypes import DWORD, BOOL, HRGN, HWND + + user32 = ctypes.windll.user32 + dwm = ctypes.windll.dwmapi + + + class ACCENTPOLICY(ctypes.Structure): + _fields_ = [ + ("AccentState", ctypes.c_uint), + ("AccentFlags", ctypes.c_uint), + ("GradientColor", ctypes.c_uint), + ("AnimationId", ctypes.c_uint) + ] + + + class WINDOWCOMPOSITIONATTRIBDATA(ctypes.Structure): + _fields_ = [ + ("Attribute", ctypes.c_int), + ("Data", ctypes.POINTER(ctypes.c_int)), + ("SizeOfData", ctypes.c_size_t) + ] + + + class DWM_BLURBEHIND(ctypes.Structure): + _fields_ = [ + ('dwFlags', DWORD), + ('fEnable', BOOL), + ('hRgnBlur', HRGN), + ('fTransitionOnMaximized', BOOL) + ] + + + class MARGINS(ctypes.Structure): + _fields_ = [("cxLeftWidth", ctypes.c_int), + ("cxRightWidth", ctypes.c_int), + ("cyTopHeight", ctypes.c_int), + ("cyBottomHeight", ctypes.c_int) + ] + + + SetWindowCompositionAttribute = user32.SetWindowCompositionAttribute + SetWindowCompositionAttribute.argtypes = (HWND, WINDOWCOMPOSITIONATTRIBDATA) + SetWindowCompositionAttribute.restype = ctypes.c_int + + +def ExtendFrameIntoClientArea(hwnd): + margins = MARGINS(-1, -1, -1, -1) + dwm.DwmExtendFrameIntoClientArea(hwnd, ctypes.byref(margins)) + + +def Win7Blur(hwnd, Acrylic): + if not Acrylic: + DWM_BB_ENABLE = 0x01 + bb = DWM_BLURBEHIND() + bb.dwFlags = DWM_BB_ENABLE + bb.fEnable = 1 + bb.hRgnBlur = 1 + dwm.DwmEnableBlurBehindWindow(hwnd, ctypes.byref(bb)) + else: + ExtendFrameIntoClientArea(hwnd) + + +def HEXtoRGBAint(HEX: str): + alpha = HEX[7:] + blue = HEX[5:7] + green = HEX[3:5] + red = HEX[1:3] + + gradient_color = alpha + blue + green + red + return int(gradient_color, base=16) + + +def blur(hwnd, hex_color=False, acrylic=False, dark=False): + accent = ACCENTPOLICY() + accent.AccentState = 3 # Default window Blur #ACCENT_ENABLE_BLURBEHIND + + gradient_color = 0 + + if hex_color: + gradient_color = HEXtoRGBAint(hex_color) + accent.AccentFlags = 2 # Window Blur With Accent Color #ACCENT_ENABLE_TRANSPARENTGRADIENT + + if acrylic: + accent.AccentState = 4 # UWP but LAG #ACCENT_ENABLE_ACRYLICBLURBEHIND + if not hex_color: # UWP without color is translucent + accent.AccentFlags = 2 + gradient_color = HEXtoRGBAint('#12121240') # placeholder color + + accent.GradientColor = gradient_color + + data = WINDOWCOMPOSITIONATTRIBDATA() + data.Attribute = 19 # WCA_ACCENT_POLICY + data.SizeOfData = ctypes.sizeof(accent) + data.Data = ctypes.cast(ctypes.pointer(accent), ctypes.POINTER(ctypes.c_int)) + + SetWindowCompositionAttribute(int(hwnd), data) + + if dark: + data.Attribute = 26 # WCA_USEDARKMODECOLORS + SetWindowCompositionAttribute(int(hwnd), data) + + +def BlurLinux(WID): # may not work in all distros (working in Deepin) + import os + + c = "xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id " + str(WID) + os.system(c) + + +def GlobalBlur(hwnd, hex_color=False, acrylic=False, dark=False): + release = platform.release() + system = platform.system() + + if system == 'Windows': + if release == 'Vista': + Win7Blur(hwnd, acrylic) + else: + release = int(float(release)) + if release == 10 or release == 8 or release == 11: + blur(hwnd, hex_color, acrylic, dark) + else: + Win7Blur(hwnd, acrylic) + + if system == 'Linux': + BlurLinux(hwnd) diff --git a/ui/modules/handlers/__init__.py b/ui/modules/handlers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/modules/handlers/buttons.py b/ui/modules/handlers/buttons.py new file mode 100644 index 0000000..37a98ee --- /dev/null +++ b/ui/modules/handlers/buttons.py @@ -0,0 +1,28 @@ +from ui.modules.updaters.page_index import update_page_text +from ui.gui import Ui_MainWindow + + +def on_back_button(ui: Ui_MainWindow): + ui.page_index.setText(str(int(ui.page_index.text()) - 1)) + update_page_text(ui) + + +def on_next_button(ui: Ui_MainWindow): + ui.page_index.setText(str(int(ui.page_index.text()) + 1)) + update_page_text(ui) + + +def on_back_button_press(ui: Ui_MainWindow): + ui.back_timer.start(10) + + +def on_back_button_release(ui: Ui_MainWindow): + ui.back_timer.stop() + + +def on_next_button_press(ui: Ui_MainWindow): + ui.next_timer.start(10) + + +def on_next_button_release(ui: Ui_MainWindow): + ui.next_timer.stop() diff --git a/ui/modules/initialize/__init__.py b/ui/modules/initialize/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/modules/initialize/handlers.py b/ui/modules/initialize/handlers.py new file mode 100644 index 0000000..237dfde --- /dev/null +++ b/ui/modules/initialize/handlers.py @@ -0,0 +1,19 @@ +from ui.modules import validators +from ui.modules.handlers import buttons +from ui.gui import Ui_MainWindow + + +def register_handlers(ui: Ui_MainWindow): + old_page_text_key_press_event = ui.page_text.keyPressEvent + ui.page_text.keyPressEvent = lambda event: validators.validate_page_text(ui, event, old_page_text_key_press_event) + old_page_index_key_press_event = ui.page_index.keyPressEvent + ui.page_index.keyPressEvent = lambda event: validators.validate_page_index(ui, event, + old_page_index_key_press_event) + + ui.back_timer.timeout.connect(lambda: buttons.on_back_button(ui)) + ui.next_timer.timeout.connect(lambda: buttons.on_next_button(ui)) + + ui.back_button.pressed.connect(lambda: buttons.on_back_button_press(ui)) + ui.back_button.released.connect(lambda: buttons.on_back_button_release(ui)) + ui.next_button.pressed.connect(lambda: buttons.on_next_button_press(ui)) + ui.next_button.released.connect(lambda: buttons.on_next_button_release(ui)) diff --git a/ui/modules/initialize/setup_ui.py b/ui/modules/initialize/setup_ui.py new file mode 100644 index 0000000..c129d51 --- /dev/null +++ b/ui/modules/initialize/setup_ui.py @@ -0,0 +1,16 @@ +from ui.gui import Ui_MainWindow +from ui.modules.blur import GlobalBlur +from PyQt5.QtWidgets import QMainWindow +from PyQt5.QtCore import QTimer +from ui.modules.initialize import handlers + + +def on_load(ui: Ui_MainWindow, MainWindow: QMainWindow): + ui.page_index.setText('0') + ui.page_index.setMaxLength(2_147_483_647) + ui.back_timer = QTimer() + ui.next_timer = QTimer() + + GlobalBlur(MainWindow.winId(), acrylic=True) + + handlers.register_handlers(ui) diff --git a/ui/modules/styles.py b/ui/modules/styles.py new file mode 100644 index 0000000..18e8dcc --- /dev/null +++ b/ui/modules/styles.py @@ -0,0 +1,582 @@ +centralwidget_b = """ +QWidget { + background-color: rgba(30, 30, 30, 0.1); + color: white; + font: 10pt "Segoe UI"; +} + + +QScrollBar:vertical, +QScrollBar:horizontal { + border: none; + background: rgba(30, 30, 30, 0); + width: 10px; + margin: 15px 0 15px 0; + border-radius: 0px; +} + +QScrollBar::handle:vertical, +QScrollBar::handle:horizontal { + background-color: rgba(139, 139, 139, 0); + min-height: 30px; + border-radius: 5px; +} + +QScrollBar::handle:vertical:hover, +QScrollBar::handle:vertical:pressed, +QScrollBar::handle:horizontal:hover, +QScrollBar::handle:horizontal:pressed { + background-color: rgba(149, 149, 149, 0); +} + +QScrollBar::sub-line:vertical, +QScrollBar::add-line:vertical, +QScrollBar::up-arrow:vertical, +QScrollBar::down-arrow:vertical { + height: 0px; +} + +QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical, +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, +QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal, +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { + background: none; +} + + +QPushButton { + color: white; + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: rgba(48, 48, 48, 0.5); + background-color: rgba(44, 45, 46, 0.3); +} +QPushButton:hover { + border-width: 2px; + background-color: rgba(50, 50, 50, 0.7); +} +QPushButton:pressed { + background-color: rgba(38, 39, 40, 0.7); +} +QPushButton:disabled { + background-color: rgba(67, 67, 67, 0.7); + border-color: rgba(0, 0, 0, 0.7); +} + + +QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(36, 36, 36, 0); + font: 10pt "Segoe UI"; +} + + +QListWidget { + border-width: 1px; + border-radius: 15px; + border-style: solid; + border-color: rgba(48, 48, 48); + padding: 10px; + background-color: rgba(100, 100, 100, 0); + font: 10pt "Segoe UI"; +} +QListWidget:item { + background-color: rgba(36, 36, 36, 0); + selection-color: white; +} +QListWidget:item:hover { + background-color: rgba(50, 50, 50, 0); +} +QListWidget:item:selected { + background-color: rgba(119, 119, 119, 1); +} + + +QComboBox +{ + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(44, 45, 46, 0); + color: white; +} + +QComboBox::disabled +{ + background-color: rgba(67, 67, 67, 0); + color: #656565; + border-color: rgba(67, 67, 67); +} + +QComboBox:hover +{ + background-color: rgba(50, 50, 50, 0); +} + +QComboBox:on +{ + background-color: rgba(67, 67, 67, 0); +} + +QComboBox QAbstractItemView +{ + background-color: rgba(67, 67, 67, 0); + color: #ffffff; + selection-background-color: rgba(119, 119, 119, 0); + selection-color: white; + outline: 0; +} + +QComboBox::drop-down +{ + subcontrol-origin: padding; + subcontrol-position: top right; + border-radius: 6px; +} + + +QTabBar::tab +{ + background-color: rgba(44, 45, 46, 0); + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: rgba(48, 48, 48); + padding: 5px; +} + +QTabBar::tab:disabled +{ + background-color: rgba(101, 101, 101, 0); + color: #656565; +} + +QTabWidget::pane +{ + background-color: rgba(160, 160, 160, 0); + color: #ffffff; + border: 3px solid; + border-radius: 15px; + border-color: rgba(28, 28, 28); +} + +QTabBar::tab:selected +{ + background-color: rgba(38, 39, 40, 0); + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: rgba(48, 48, 48); + padding: 5px; +} + +QTabBar::tab:selected:disabled +{ + background-color: rgba(64, 64, 64, 0); + color: #656565; +} + +QTabBar::tab:!selected +{ + background-color: rgba(38, 38, 38, 0); +} + +QTabBar::tab:!selected:hover +{ + background-color: rgba(50, 50, 50, 0); +} + +QTabBar::tab:top:!selected +{ + margin-top: 3px; +} + +QTabBar::tab:bottom:!selected +{ + margin-bottom: 3px; +} + +QTabBar::tab:top, QTabBar::tab:bottom +{ + min-width: 8ex; + margin-right: -1px; + padding: 5px 10px 5px 10px; +} + +QTabBar::tab:top:selected +{ + border-bottom-color: none; +} + +QTabBar::tab:bottom:selected +{ + border-top-color: none; +} + +QTabBar::tab:top:last, QTabBar::tab:bottom:last, +QTabBar::tab:top:only-one, QTabBar::tab:bottom:only-one +{ + margin-right: 0; +} + +QTabBar::tab:left:!selected +{ + margin-right: 3px; +} + +QTabBar::tab:right:!selected +{ + margin-left: 3px; +} + +QTabBar::tab:left, QTabBar::tab:right +{ + min-height: 8ex; + margin-bottom: -1px; + padding: 10px 5px 10px 5px; +} + +QTabBar::tab:left:selected +{ + border-left-color: none; +} + +QTabBar::tab:right:selected +{ + border-right-color: none; +} + +QTabBar::tab:left:last, QTabBar::tab:right:last, +QTabBar::tab:left:only-one, QTabBar::tab:right:only-one +{ + margin-bottom: 0; +} + +QSpinBox { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: rgba(48, 48, 48); + background-color: rgba(36, 36, 36, 0); + font: 10pt "Segoe UI"; +} +QSpinBox::up-button { + border: none; + background: none; +} +QSpinBox::down-button { + border: none; + background: none; +} + +QToolBox::tab { + border-style: solid; + border-width: 1px; + border-radius: 5px; + border-color: rgba(48, 48, 48, 0); +} +""" + +menupage_b = """ +QListWidget { + border-width: 0px; + border-radius: 0px; + border: none; + padding: 0px; + background-color: rgba(36, 36, 36, 0); + font: 10pt "Segoe UI"; +} +QListWidget:item { + padding-left: 10px; + height: 60px; + background-color: rgba(25, 25, 25, 0); + selection-color: rgba(255, 255, 255); +} +QListWidget:item:hover { + background-color: rgba(50, 50, 50, 0); +} +QListWidget:item:selected { + background-color: rgba(38, 39, 40, 0); +} +""" + +centralwidget_g = """ +QWidget { + background-color: rgb(30, 30, 30); + color: rgb(255, 255, 255); + font: 10pt "Segoe UI"; +} +QScrollBar:vertical, +QScrollBar:horizontal { + border: none; + background: rgb(30, 30, 30); + width: 10px; + margin: 15px 0 15px 0; + border-radius: 0px; +} +QScrollBar::handle:vertical, +QScrollBar::handle:horizontal { + background-color: rgb(139, 139, 139); + min-height: 30px; + border-radius: 5px; +} +QScrollBar::handle:vertical:hover, +QScrollBar::handle:vertical:pressed, +QScrollBar::handle:horizontal:hover, +QScrollBar::handle:horizontal:pressed { + background-color: rgb(149, 149, 149); +} +QScrollBar::sub-line:vertical, +QScrollBar::add-line:vertical, +QScrollBar::up-arrow:vertical, +QScrollBar::down-arrow:vertical { + height: 0px; +} +QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical, +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical, +QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal, +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { + background: none; +} +QPushButton { + color: white; + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: #303030; + background-color: #2c2d2e; +} +QPushButton:hover { + border-width: 2px; + background-color: #323232; +} +QPushButton:pressed { + background-color: #262728; +} +QPushButton:disabled { + background-color: #434343; + border-color: #0000; +} +QLineEdit, QTextBrowser, QPlainTextEdit, QTextEdit { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: #303030; + background-color: #242424; + font: 10pt "Segoe UI"; +} +QListWidget { + border-width: 1px; + border-radius: 15px; + border-style: solid; + border-color: #303030; + padding: 10px; + background-color: #242424; + font: 10pt "Segoe UI"; +} +QListWidget:item { + background-color: #242424; + selection-color: white; +} +QListWidget:item:hover { + background-color: #323232; +} +QListWidget:item:selected { + background-color: #777777; +} +QComboBox +{ + border-width: 1px; + border-radius:6px; + border-style: solid; + border-color: #303030; + background-color: #2c2d2e; + color: #ffffff; +} +QComboBox::disabled +{ + background-color: #434343; + color: #656565; + border-color: #434343; +} +QComboBox:hover +{ + background-color: #323232; +} +QComboBox:on +{ + background-color: #434343; +} +QComboBox QAbstractItemView +{ + background-color: #434343; + color: #ffffff; + selection-background-color: #777777; + selection-color: white; + outline: 0; +} +QComboBox::drop-down +{ + subcontrol-origin: padding; + subcontrol-position: top right; + border-radius: 6px; +} +QTabBar::tab +{ + background-color: #2c2d2e; + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: #303030; + padding: 5px; +} +QTabBar::tab:disabled +{ + background-color: #656565; + color: #656565; +} +QTabWidget::pane +{ + background-color: #a0a0a0; + color: #ffffff; + border: 3px solid; + border-radius: 15px; + border-color: #1c1c1c; +} +QTabBar::tab:selected +{ + background-color: #262728; + color: #ffffff; + border-style: solid; + border-width: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-color: #303030; + padding: 5px; +} +QTabBar::tab:selected:disabled +{ + background-color: #404040; + color: #656565; +} +QTabBar::tab:!selected +{ + background-color: #262626; +} +QTabBar::tab:!selected:hover +{ + background-color: #323232; +} +QTabBar::tab:top:!selected +{ + margin-top: 3px; +} +QTabBar::tab:bottom:!selected +{ + margin-bottom: 3px; +} +QTabBar::tab:top, QTabBar::tab:bottom +{ + min-width: 8ex; + margin-right: -1px; + padding: 5px 10px 5px 10px; +} +QTabBar::tab:top:selected +{ + border-bottom-color: none; +} +QTabBar::tab:bottom:selected +{ + border-top-color: none; +} +QTabBar::tab:top:last, QTabBar::tab:bottom:last, +QTabBar::tab:top:only-one, QTabBar::tab:bottom:only-one +{ + margin-right: 0; +} +QTabBar::tab:left:!selected +{ + margin-right: 3px; +} +QTabBar::tab:right:!selected +{ + margin-left: 3px; +} +QTabBar::tab:left, QTabBar::tab:right +{ + min-height: 8ex; + margin-bottom: -1px; + padding: 10px 5px 10px 5px; +} +QTabBar::tab:left:selected +{ + border-left-color: none; +} +QTabBar::tab:right:selected +{ + border-right-color: none; +} +QTabBar::tab:left:last, QTabBar::tab:right:last, +QTabBar::tab:left:only-one, QTabBar::tab:right:only-one +{ + margin-bottom: 0; +} + +QSpinBox { + border-width: 1px; + border-radius: 5px; + border-style: solid; + border-color: #303030; + background-color: #242424; + font: 10pt "Segoe UI"; +} +QSpinBox::up-button { + border: none; + background: none; +} +QSpinBox::down-button { + border: none; + background: none; +} + +QToolBox::tab { + border-style: solid; + border-width: 1px; + border-radius: 5px; + border-color: #303030; +} +""" + +menupage_g = """ +QListWidget { + border-width: 0px; + border-radius: 0px; + border: none; + padding: 0px; + background-color: #242424; + font: 10pt "Segoe UI"; +} +QListWidget:item { + padding-left: 10px; + height: 60px; + background-color: #191919; + selection-color: rgba(255, 255, 255); +} +QListWidget:item:hover { + background-color: #323232; +} +QListWidget:item:selected { + background-color: #262728; +} +""" diff --git a/ui/modules/updaters/__init__.py b/ui/modules/updaters/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ui/modules/updaters/page_index.py b/ui/modules/updaters/page_index.py new file mode 100644 index 0000000..d4e3447 --- /dev/null +++ b/ui/modules/updaters/page_index.py @@ -0,0 +1,13 @@ +from modules.generator.pages import Page +from ui.gui import Ui_MainWindow + + +def update_page_text(ui: Ui_MainWindow): + if ui.page_index.text() == str(): + ui.page_text.setPlainText('') + return + + try: + ui.page_text.setPlainText(Page.from_index(int(ui.page_index.text()))) + except: + ui.page_text.setPlainText('Something went wrong, change index or text here.') diff --git a/ui/modules/updaters/page_text.py b/ui/modules/updaters/page_text.py new file mode 100644 index 0000000..4ac81d6 --- /dev/null +++ b/ui/modules/updaters/page_text.py @@ -0,0 +1,6 @@ +from modules.generator.pages import Index +from ui.gui import Ui_MainWindow + + +def update_page_index(ui: Ui_MainWindow): + ui.page_index.setText(str(Index.from_page(ui.page_text.toPlainText()))) diff --git a/ui/modules/validators/__init__.py b/ui/modules/validators/__init__.py new file mode 100644 index 0000000..06eba60 --- /dev/null +++ b/ui/modules/validators/__init__.py @@ -0,0 +1,2 @@ +from .page_text import * +from .page_index import * diff --git a/ui/modules/validators/page_index.py b/ui/modules/validators/page_index.py new file mode 100644 index 0000000..e43e0c7 --- /dev/null +++ b/ui/modules/validators/page_index.py @@ -0,0 +1,14 @@ +from ui.modules.updaters.page_index import update_page_text +from ui.gui import Ui_MainWindow +from PyQt5 import QtGui + + +def validate_page_index(ui: Ui_MainWindow, event: QtGui.QKeyEvent, old_event): + old_event(event) + for char in ui.page_index.text(): + if char not in '0123456789': + ui.page_index.setText(''.join(c for c in ui.page_index.text() if c in '0123456789')) + ui.page_index.setCursorPosition(QtGui.QTextCursor.End) + break + + update_page_text(ui) diff --git a/ui/modules/validators/page_text.py b/ui/modules/validators/page_text.py new file mode 100644 index 0000000..1f61530 --- /dev/null +++ b/ui/modules/validators/page_text.py @@ -0,0 +1,15 @@ +from ui.modules.updaters.page_text import update_page_index +from modules.config import charset +from ui.gui import Ui_MainWindow +from PyQt5 import QtGui + + +def validate_page_text(ui: Ui_MainWindow, event: QtGui.QKeyEvent, old_event): + old_event(event) + for char in ui.page_text.toPlainText(): + if char not in charset: + ui.page_text.setPlainText(''.join(c for c in ui.page_text.toPlainText() if c in charset)) + ui.page_text.moveCursor(QtGui.QTextCursor.End) + break + + update_page_index(ui)