switching databases
This commit is contained in:
@@ -267,6 +267,13 @@ QSpinBox::up-button {
|
|||||||
QSpinBox::down-button {
|
QSpinBox::down-button {
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
QToolBox::tab {
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-color: #303030;
|
||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def refill_list(ui: Ui_MainWindow):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
list_item = QtWidgets.QListWidgetItem()
|
list_item = QtWidgets.QListWidgetItem()
|
||||||
if Config.get().profile:
|
if Config.get().profile in list(Database.get().profiles):
|
||||||
ui.own_button.setEnabled(True)
|
ui.own_button.setEnabled(True)
|
||||||
|
|
||||||
if item.item_name in Database.get_profile().owned_items:
|
if item.item_name in Database.get_profile().owned_items:
|
||||||
@@ -47,7 +47,7 @@ def refill_list(ui: Ui_MainWindow):
|
|||||||
|
|
||||||
list_item.setText(
|
list_item.setText(
|
||||||
f''
|
f''
|
||||||
f'{"☑" if Config.get().profile and item.item_name in Database.get_profile().owned_items else ""}'
|
f'{"☑" if Config.get().profile in list(Database.get().profiles) and item.item_name in Database.get_profile().owned_items else ""}'
|
||||||
f'{item.item_name} - ${"{:,}".format(item.price)}'
|
f'{item.item_name} - ${"{:,}".format(item.price)}'
|
||||||
)
|
)
|
||||||
pixmap = QtGui.QPixmap()
|
pixmap = QtGui.QPixmap()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def on_item_click(ui: Ui_MainWindow, mode: str):
|
|||||||
ui.properties_image.clear()
|
ui.properties_image.clear()
|
||||||
print(f"Failed to load {item.image}, {e}")
|
print(f"Failed to load {item.image}, {e}")
|
||||||
|
|
||||||
if Config.get().profile:
|
if Config.get().profile in list(Database.get().profiles):
|
||||||
ui.own_button.setEnabled(True)
|
ui.own_button.setEnabled(True)
|
||||||
|
|
||||||
if item.item_name in Database.get_profile().owned_items:
|
if item.item_name in Database.get_profile().owned_items:
|
||||||
|
|||||||
@@ -280,6 +280,13 @@ QSpinBox::down-button {
|
|||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QToolBox::tab {
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-color: rgba(48, 48, 48, 0);
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
menupage_b = """
|
menupage_b = """
|
||||||
@@ -545,6 +552,13 @@ QSpinBox::down-button {
|
|||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QToolBox::tab {
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-color: #303030;
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
menupage_g = """
|
menupage_g = """
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
from .on_settings_open import *
|
from .on_settings_open import *
|
||||||
|
from .db import *
|
||||||
|
from .visual import *
|
||||||
from .handlers import *
|
from .handlers import *
|
||||||
12
gui/modules/settings/db.py
Normal file
12
gui/modules/settings/db.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from gui.gui import Ui_MainWindow
|
||||||
|
from modules.config import Config
|
||||||
|
from gui.modules.core import items_list
|
||||||
|
|
||||||
|
|
||||||
|
def on_load_another_db_click(ui: Ui_MainWindow):
|
||||||
|
Config.update("database", ui.database_list_box.currentText())
|
||||||
|
items_list.refill_list(ui)
|
||||||
|
|
||||||
|
|
||||||
|
def register_db_handlers(ui: Ui_MainWindow):
|
||||||
|
ui.load_this_db_button.clicked.connect(lambda: on_load_another_db_click(ui))
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
from . import *
|
from . import *
|
||||||
|
from gui.gui import Ui_MainWindow
|
||||||
|
|
||||||
|
|
||||||
def register_handlers(ui: Ui_MainWindow):
|
def register_handlers(ui: Ui_MainWindow):
|
||||||
ui.open_settings_button.clicked.connect(lambda: on_settings_button_click(ui))
|
ui.open_settings_button.clicked.connect(lambda: on_settings_open.on_settings_button_click(ui))
|
||||||
ui.cancel_settings_button.clicked.connect(lambda: ui.content.setCurrentWidget(ui.main_page))
|
ui.cancel_settings_button.clicked.connect(lambda: ui.content.setCurrentWidget(ui.main_page))
|
||||||
|
|
||||||
|
ui.save_gui_setting_button.clicked.connect(lambda: visual.on_save_visual_click(ui))
|
||||||
|
|
||||||
|
db.register_db_handlers(ui)
|
||||||
|
|||||||
6
gui/modules/settings/visual.py
Normal file
6
gui/modules/settings/visual.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from gui.gui import Ui_MainWindow
|
||||||
|
from modules.config import Config
|
||||||
|
|
||||||
|
|
||||||
|
def on_save_visual_click(ui: Ui_MainWindow):
|
||||||
|
Config.update("theme", ui.app_theme_box.currentText())
|
||||||
@@ -12,6 +12,8 @@ class Database:
|
|||||||
print(f"Cannot load database: {e}. Writing default database")
|
print(f"Cannot load database: {e}. Writing default database")
|
||||||
print("Old data:")
|
print("Old data:")
|
||||||
print(open(Config.get().database).read())
|
print(open(Config.get().database).read())
|
||||||
|
with open("error.baseback", 'w') as f:
|
||||||
|
f.write(open(Config.get().database).read())
|
||||||
with open(Config.get().database, 'w') as f:
|
with open(Config.get().database, 'w') as f:
|
||||||
json.dump(default_database, f, indent=4)
|
json.dump(default_database, f, indent=4)
|
||||||
return DatabaseModel.from_dict(default_database)
|
return DatabaseModel.from_dict(default_database)
|
||||||
|
|||||||
Reference in New Issue
Block a user