if a new database is chosen, create and instantiate the tables in the sqlite file
This commit is contained in:
parent
f371960746
commit
f997fa80ed
@ -45,26 +45,12 @@ class PreferencesWindow(QDialog):
|
|||||||
|
|
||||||
# # Labels & input fields
|
# # Labels & input fields
|
||||||
self.input_fields = {}
|
self.input_fields = {}
|
||||||
# for category in self.config.sections():
|
|
||||||
# separator = QFrame()
|
|
||||||
# separator.setFrameShape(QFrame.HLine)
|
|
||||||
# self.content_layout.addWidget(separator)
|
|
||||||
# category_label = QLabel(f"{category}")
|
|
||||||
# category_label.setFont(QFont("Sans", weight=QFont.Bold)) # bold
|
|
||||||
# category_label.setStyleSheet("text-transform:uppercase;") # uppercase
|
|
||||||
# self.content_layout.addWidget(category_label)
|
|
||||||
# for key in self.config[category]:
|
|
||||||
# label = QLabel(key)
|
|
||||||
# input_field = QLineEdit(self.config[category][key])
|
|
||||||
# self.content_layout.addWidget(label)
|
|
||||||
# self.content_layout.addWidget(input_field)
|
|
||||||
# self.input_fields[key] = input_field
|
|
||||||
|
|
||||||
# Add widgets to the layout
|
# Add widgets to the layout
|
||||||
main_layout.addWidget(nav_pane)
|
main_layout.addWidget(nav_pane)
|
||||||
main_layout.addWidget(self.content_area)
|
main_layout.addWidget(self.content_area)
|
||||||
|
|
||||||
# # Set the layout
|
# Set the layout
|
||||||
self.setLayout(main_layout)
|
self.setLayout(main_layout)
|
||||||
|
|
||||||
def on_nav_item_clicked(self, item):
|
def on_nav_item_clicked(self, item):
|
||||||
@ -97,6 +83,7 @@ class PreferencesWindow(QDialog):
|
|||||||
child.widget().deleteLater()
|
child.widget().deleteLater()
|
||||||
|
|
||||||
def save_preferences(self):
|
def save_preferences(self):
|
||||||
|
print('im saving')
|
||||||
# Upcate the config fields
|
# Upcate the config fields
|
||||||
for key in self.input_fields:
|
for key in self.input_fields:
|
||||||
for category in self.config.sections():
|
for category in self.config.sections():
|
||||||
|
|||||||
19
main.py
19
main.py
@ -513,6 +513,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
preferences_window = PreferencesWindow(self.config)
|
preferences_window = PreferencesWindow(self.config)
|
||||||
preferences_window.exec_() # Display the preferences window modally
|
preferences_window.exec_() # Display the preferences window modally
|
||||||
self.reload_config()
|
self.reload_config()
|
||||||
|
self.tableView.load_music_table()
|
||||||
|
|
||||||
# Quick Actions
|
# Quick Actions
|
||||||
|
|
||||||
@ -570,18 +571,20 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# First run initialization
|
# Initialization
|
||||||
if not os.path.exists("config.ini"):
|
if not os.path.exists("config.ini"):
|
||||||
# Create config file from sample
|
# Create config file from sample
|
||||||
run(["cp", "sample_config.ini", "config.ini"])
|
run(["cp", "sample_config.ini", "config.ini"])
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read("config.ini")
|
config.read("config.ini")
|
||||||
db_name = config.get("db", "database")
|
db_filepath: str = config.get("db", "database")
|
||||||
db_path = db_name.split("/")
|
db_path: str = "/".join(db_filepath.split("/").pop())
|
||||||
db_path.pop()
|
# If the db file doesn't exist
|
||||||
db_path_as_string = "/".join(db_path)
|
if not os.path.exists(db_filepath):
|
||||||
if not os.path.exists(db_path_as_string):
|
# If the db directory doesn't exist
|
||||||
os.makedirs(db_path_as_string)
|
if not os.path.exists(db_path):
|
||||||
|
# Make the directory
|
||||||
|
os.makedirs(db_path)
|
||||||
# Create database on first run
|
# Create database on first run
|
||||||
with DBA.DBAccess() as db:
|
with DBA.DBAccess() as db:
|
||||||
with open("utils/init.sql", "r") as file:
|
with open("utils/init.sql", "r") as file:
|
||||||
@ -599,7 +602,7 @@ if __name__ == "__main__":
|
|||||||
format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
|
format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
|
||||||
handlers=handlers,
|
handlers=handlers,
|
||||||
)
|
)
|
||||||
# Allow for dynamic imports of my custom classes and utilities
|
# Allow for dynamic imports of my custom classes and utilities?
|
||||||
project_root = os.path.abspath(os.path.dirname(__file__))
|
project_root = os.path.abspath(os.path.dirname(__file__))
|
||||||
sys.path.append(project_root)
|
sys.path.append(project_root)
|
||||||
# Start the app
|
# Start the app
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user