From 0820452e97b430231fb03d8f6711fc66e6c4f4ab Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Tue, 2 Aug 2022 18:59:10 +0300 Subject: [PATCH] some filesystem changes --- GtaBuyBaseGui.py | 4 +- gui/gui.py | 124 ++++++++- gui/gui.ui | 319 ++++++++++++++++++++++- gui/modules/core/__init__.py | 0 gui/modules/{ => core}/blur.py | 0 gui/modules/{ => core}/popup.py | 0 gui/modules/handlers/__init__.py | 0 gui/modules/handlers/fill_info.py | 36 +++ gui/modules/handlers/on_item_remove.py | 0 gui/modules/handlers/register.py | 7 + gui/modules/initialize/__init__.py | 0 gui/modules/{ => initialize}/setup_ui.py | 4 +- gui/modules/{ => initialize}/styles.py | 34 +++ 13 files changed, 520 insertions(+), 8 deletions(-) create mode 100644 gui/modules/core/__init__.py rename gui/modules/{ => core}/blur.py (100%) rename gui/modules/{ => core}/popup.py (100%) create mode 100644 gui/modules/handlers/__init__.py create mode 100644 gui/modules/handlers/fill_info.py create mode 100644 gui/modules/handlers/on_item_remove.py create mode 100644 gui/modules/handlers/register.py create mode 100644 gui/modules/initialize/__init__.py rename gui/modules/{ => initialize}/setup_ui.py (91%) rename gui/modules/{ => initialize}/styles.py (94%) diff --git a/GtaBuyBaseGui.py b/GtaBuyBaseGui.py index 65df4ac..34c0106 100644 --- a/GtaBuyBaseGui.py +++ b/GtaBuyBaseGui.py @@ -2,7 +2,8 @@ import threading from PyQt5 import QtWidgets from gui.gui import Ui_MainWindow from modules.core.exceptions import hook, thread_hook -from gui.modules import setup_ui +from gui.modules.initialize import setup_ui +from gui.modules.handlers.register import register_handlers import sys sys.excepthook = hook @@ -16,5 +17,6 @@ setup_ui.on_load(ui, MainWindow) MainWindow.show() +register_handlers(ui) sys.exit(app.exec_()) diff --git a/gui/gui.py b/gui/gui.py index 557a448..fad5bac 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -14,7 +14,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") - MainWindow.resize(800, 435) + MainWindow.resize(800, 489) + MainWindow.setMaximumSize(QtCore.QSize(16777215, 16777215)) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/img/img/icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) MainWindow.setWindowIcon(icon) @@ -83,12 +84,66 @@ class Ui_MainWindow(object): self.content_layout.setObjectName("content_layout") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.content_layout) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout_3.setSpacing(0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.logo_if_empty = QtWidgets.QTextBrowser(self.content_layout) - self.logo_if_empty.setMaximumSize(QtCore.QSize(16777215, 16777215)) + self.logo_if_empty.setMaximumSize(QtCore.QSize(0, 16777215)) self.logo_if_empty.setTextInteractionFlags(QtCore.Qt.NoTextInteraction) self.logo_if_empty.setObjectName("logo_if_empty") self.horizontalLayout_3.addWidget(self.logo_if_empty) + self.filter_lay = QtWidgets.QWidget(self.content_layout) + self.filter_lay.setMinimumSize(QtCore.QSize(0, 0)) + self.filter_lay.setMaximumSize(QtCore.QSize(0, 16777215)) + self.filter_lay.setObjectName("filter_lay") + self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.filter_lay) + self.verticalLayout_3.setContentsMargins(0, 0, 6, 0) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.filter_class_label = QtWidgets.QLabel(self.filter_lay) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.filter_class_label.sizePolicy().hasHeightForWidth()) + self.filter_class_label.setSizePolicy(sizePolicy) + self.filter_class_label.setObjectName("filter_class_label") + self.verticalLayout_3.addWidget(self.filter_class_label) + self.filter_class_box = QtWidgets.QComboBox(self.filter_lay) + self.filter_class_box.setObjectName("filter_class_box") + self.verticalLayout_3.addWidget(self.filter_class_box, 0, QtCore.Qt.AlignTop) + self.filter_type_label = QtWidgets.QLabel(self.filter_lay) + self.filter_type_label.setObjectName("filter_type_label") + self.verticalLayout_3.addWidget(self.filter_type_label) + self.filter_type_box = QtWidgets.QComboBox(self.filter_lay) + self.filter_type_box.setObjectName("filter_type_box") + self.verticalLayout_3.addWidget(self.filter_type_box) + self.filter_shop_label = QtWidgets.QLabel(self.filter_lay) + self.filter_shop_label.setObjectName("filter_shop_label") + self.verticalLayout_3.addWidget(self.filter_shop_label) + self.filter_shop_box = QtWidgets.QComboBox(self.filter_lay) + self.filter_shop_box.setObjectName("filter_shop_box") + self.verticalLayout_3.addWidget(self.filter_shop_box) + self.filter_min_price_label = QtWidgets.QLabel(self.filter_lay) + self.filter_min_price_label.setObjectName("filter_min_price_label") + self.verticalLayout_3.addWidget(self.filter_min_price_label) + self.filter_min_price_box = QtWidgets.QSpinBox(self.filter_lay) + self.filter_min_price_box.setStyleSheet("") + self.filter_min_price_box.setMaximum(10000000) + self.filter_min_price_box.setObjectName("filter_min_price_box") + self.verticalLayout_3.addWidget(self.filter_min_price_box) + self.filter_max_price_label = QtWidgets.QLabel(self.filter_lay) + self.filter_max_price_label.setObjectName("filter_max_price_label") + self.verticalLayout_3.addWidget(self.filter_max_price_label) + self.filter_max_price_box = QtWidgets.QSpinBox(self.filter_lay) + self.filter_max_price_box.setMaximum(10000000) + self.filter_max_price_box.setProperty("value", 10000000) + self.filter_max_price_box.setObjectName("filter_max_price_box") + self.verticalLayout_3.addWidget(self.filter_max_price_box) + spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.verticalLayout_3.addItem(spacerItem1) + self.filters_apply_button = QtWidgets.QPushButton(self.filter_lay) + self.filters_apply_button.setMinimumSize(QtCore.QSize(0, 0)) + self.filters_apply_button.setObjectName("filters_apply_button") + self.verticalLayout_3.addWidget(self.filters_apply_button) + self.horizontalLayout_3.addWidget(self.filter_lay) self.items_list = QtWidgets.QListWidget(self.content_layout) self.items_list.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.items_list.setStyleSheet("QListWidget:item {\n" @@ -98,6 +153,57 @@ class Ui_MainWindow(object): self.items_list.setIconSize(QtCore.QSize(16777215, 56)) self.items_list.setObjectName("items_list") self.horizontalLayout_3.addWidget(self.items_list) + self.item_properties_lay = QtWidgets.QWidget(self.content_layout) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.item_properties_lay.sizePolicy().hasHeightForWidth()) + self.item_properties_lay.setSizePolicy(sizePolicy) + self.item_properties_lay.setMinimumSize(QtCore.QSize(0, 0)) + self.item_properties_lay.setMaximumSize(QtCore.QSize(0, 16777215)) + self.item_properties_lay.setObjectName("item_properties_lay") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.item_properties_lay) + self.verticalLayout_2.setContentsMargins(9, 0, 0, 0) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.properties_image = QtWidgets.QLabel(self.item_properties_lay) + self.properties_image.setMinimumSize(QtCore.QSize(0, 0)) + self.properties_image.setMaximumSize(QtCore.QSize(480, 270)) + self.properties_image.setStyleSheet("") + self.properties_image.setText("") + self.properties_image.setScaledContents(True) + self.properties_image.setAlignment(QtCore.Qt.AlignCenter) + self.properties_image.setObjectName("properties_image") + self.verticalLayout_2.addWidget(self.properties_image) + self.properties_name = QtWidgets.QLabel(self.item_properties_lay) + self.properties_name.setStyleSheet("font: 16pt \"Segoe UI\";") + self.properties_name.setObjectName("properties_name") + self.verticalLayout_2.addWidget(self.properties_name) + self.properties_price = QtWidgets.QLabel(self.item_properties_lay) + self.properties_price.setObjectName("properties_price") + self.verticalLayout_2.addWidget(self.properties_price) + self.properties_class_type = QtWidgets.QLabel(self.item_properties_lay) + self.properties_class_type.setObjectName("properties_class_type") + self.verticalLayout_2.addWidget(self.properties_class_type) + self.properties_shop = QtWidgets.QLabel(self.item_properties_lay) + self.properties_shop.setObjectName("properties_shop") + self.verticalLayout_2.addWidget(self.properties_shop) + spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem2) + self.own_items_buttons = QtWidgets.QWidget(self.item_properties_lay) + self.own_items_buttons.setObjectName("own_items_buttons") + self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.own_items_buttons) + self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.own_button = QtWidgets.QPushButton(self.own_items_buttons) + self.own_button.setMinimumSize(QtCore.QSize(0, 30)) + self.own_button.setObjectName("own_button") + self.horizontalLayout_4.addWidget(self.own_button) + self.delete_item_button = QtWidgets.QPushButton(self.own_items_buttons) + self.delete_item_button.setMinimumSize(QtCore.QSize(0, 30)) + self.delete_item_button.setObjectName("delete_item_button") + self.horizontalLayout_4.addWidget(self.delete_item_button) + self.verticalLayout_2.addWidget(self.own_items_buttons) + self.horizontalLayout_3.addWidget(self.item_properties_lay) self.verticalLayout.addWidget(self.content_layout) self.content.addWidget(self.main_page) self.add_page = QtWidgets.QWidget() @@ -120,6 +226,20 @@ class Ui_MainWindow(object): "

\n" "

Press add button on top right corner to add item

\n" "

To use own options create profile on profile page

")) + self.filter_class_label.setText(_translate("MainWindow", "Item class:")) + self.filter_type_label.setText(_translate("MainWindow", "Item type:")) + self.filter_shop_label.setText(_translate("MainWindow", "Shop:")) + self.filter_min_price_label.setText(_translate("MainWindow", "Min price:")) + self.filter_min_price_box.setPrefix(_translate("MainWindow", "$")) + self.filter_max_price_label.setText(_translate("MainWindow", "Max price:")) + self.filter_max_price_box.setPrefix(_translate("MainWindow", "$")) + self.filters_apply_button.setText(_translate("MainWindow", "Apply filters")) + self.properties_name.setText(_translate("MainWindow", "item_name")) + self.properties_price.setText(_translate("MainWindow", "item_price")) + self.properties_class_type.setText(_translate("MainWindow", "item_class - item_type")) + self.properties_shop.setText(_translate("MainWindow", "item_shop")) + self.own_button.setText(_translate("MainWindow", "Mark this item as owned")) + self.delete_item_button.setText(_translate("MainWindow", "Delete this item")) import gui.images_rc diff --git a/gui/gui.ui b/gui/gui.ui index 305ad88..436229d 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -7,9 +7,15 @@ 0 0 800 - 435 + 489 + + + 16777215 + 16777215 + + GTABuyBase @@ -241,7 +247,27 @@ QTabBar::tab:left:only-one, QTabBar::tab:right:only-one { margin-bottom: 0; } - + +QSpinBox, +QSpinBox:editable, +QSpinBox:hover, +QSpinBox:pressed { + 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; +} @@ -426,6 +452,9 @@ QTabBar::tab:left:only-one, QTabBar::tab:right:only-one + + 0 + 0 @@ -442,7 +471,7 @@ QTabBar::tab:left:only-one, QTabBar::tab:right:only-one - 16777215 + 0 16777215 @@ -461,6 +490,138 @@ p, li { white-space: pre-wrap; } + + + + + 0 + 0 + + + + + 0 + 16777215 + + + + + 0 + + + 0 + + + 6 + + + 0 + + + + + + 0 + 0 + + + + Item class: + + + + + + + + + + Item type: + + + + + + + + + + Shop: + + + + + + + + + + Min price: + + + + + + + + + + $ + + + 10000000 + + + + + + + Max price: + + + + + + + $ + + + 10000000 + + + 10000000 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + Apply filters + + + + + + @@ -483,6 +644,158 @@ p, li { white-space: pre-wrap; } + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 16777215 + + + + + 9 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 480 + 270 + + + + + + + + + + true + + + Qt::AlignCenter + + + + + + + font: 16pt "Segoe UI"; + + + item_name + + + + + + + item_price + + + + + + + item_class - item_type + + + + + + + item_shop + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 30 + + + + Mark this item as owned + + + + + + + + 0 + 30 + + + + Delete this item + + + + + + + + + diff --git a/gui/modules/core/__init__.py b/gui/modules/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/modules/blur.py b/gui/modules/core/blur.py similarity index 100% rename from gui/modules/blur.py rename to gui/modules/core/blur.py diff --git a/gui/modules/popup.py b/gui/modules/core/popup.py similarity index 100% rename from gui/modules/popup.py rename to gui/modules/core/popup.py diff --git a/gui/modules/handlers/__init__.py b/gui/modules/handlers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/modules/handlers/fill_info.py b/gui/modules/handlers/fill_info.py new file mode 100644 index 0000000..ee33b40 --- /dev/null +++ b/gui/modules/handlers/fill_info.py @@ -0,0 +1,36 @@ +import requests +from PyQt5 import QtWidgets, QtGui, QtCore +from gui.gui import Ui_MainWindow +from modules.database import Database + + +def on_item_click(ui: Ui_MainWindow, mode: str): + item = Database.get().items[ + ui.items_list.currentItem().text().removesuffix(' - ' + ui.items_list.currentItem().text().split(' - ')[-1]) + ] + + pixmap = QtGui.QPixmap() + pixmap.loadFromData(requests.get(item.image).content) + ui.properties_image.setPixmap(pixmap) + + ui.properties_name.setText(item.item_name) + ui.properties_price.setText(f'${"{:,}".format(item.price)}') + ui.properties_class_type.setText(f'{item.item_class} - {item.item_type}') + ui.properties_shop.setText(item.shop) + + width = ui.item_properties_lay.geometry().width() + Ui_MainWindow.animation = QtCore.QPropertyAnimation(ui.item_properties_lay, b"minimumWidth") + Ui_MainWindow.animation.setDuration(300) + + if width == 0: + Ui_MainWindow.animation.setStartValue(0) + Ui_MainWindow.animation.setEndValue(480) + + Ui_MainWindow.animation.setEasingCurve(QtCore.QEasingCurve.InOutQuart) + Ui_MainWindow.animation.start() + elif mode == 'close': + Ui_MainWindow.animation.setStartValue(width) + Ui_MainWindow.animation.setEndValue(0) + + Ui_MainWindow.animation.setEasingCurve(QtCore.QEasingCurve.InOutQuart) + Ui_MainWindow.animation.start() diff --git a/gui/modules/handlers/on_item_remove.py b/gui/modules/handlers/on_item_remove.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/modules/handlers/register.py b/gui/modules/handlers/register.py new file mode 100644 index 0000000..3505345 --- /dev/null +++ b/gui/modules/handlers/register.py @@ -0,0 +1,7 @@ +from gui.gui import Ui_MainWindow +from gui.modules.handlers import fill_info + + +def register_handlers(ui: Ui_MainWindow): + ui.items_list.currentItemChanged.connect(lambda: fill_info.on_item_click(ui, 'open')) + ui.items_list.itemDoubleClicked.connect(lambda: fill_info.on_item_click(ui, 'close')) diff --git a/gui/modules/initialize/__init__.py b/gui/modules/initialize/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/modules/setup_ui.py b/gui/modules/initialize/setup_ui.py similarity index 91% rename from gui/modules/setup_ui.py rename to gui/modules/initialize/setup_ui.py index ee93fb7..275ef30 100644 --- a/gui/modules/setup_ui.py +++ b/gui/modules/initialize/setup_ui.py @@ -1,7 +1,7 @@ import requests from gui.gui import Ui_MainWindow -from .blur import GlobalBlur -from gui.modules import styles +from gui.modules.core.blur import GlobalBlur +from gui.modules.initialize import styles from PyQt5 import QtWidgets, QtGui from PyQt5.QtWidgets import QMainWindow from modules.config import Config diff --git a/gui/modules/styles.py b/gui/modules/initialize/styles.py similarity index 94% rename from gui/modules/styles.py rename to gui/modules/initialize/styles.py index 35a316c..f448a17 100644 --- a/gui/modules/styles.py +++ b/gui/modules/initialize/styles.py @@ -263,6 +263,23 @@ 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; +} """ menupage_b = """ @@ -511,6 +528,23 @@ 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; +} """ menupage_g = """