load back into library working again
This commit is contained in:
parent
176ea1360a
commit
3a9f7a27d3
3
DBA.py
3
DBA.py
@ -1,5 +1,4 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import logging
|
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from appdirs import user_config_dir
|
from appdirs import user_config_dir
|
||||||
@ -7,7 +6,7 @@ from appdirs import user_config_dir
|
|||||||
|
|
||||||
class DBAccess:
|
class DBAccess:
|
||||||
def __init__(self, db_name=None):
|
def __init__(self, db_name=None):
|
||||||
logging.info("Instantiating DBAccess")
|
# logging.info("Instantiating DBAccess")
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
cfg_file = (
|
cfg_file = (
|
||||||
Path(user_config_dir(appname="musicpom", appauthor="billypom"))
|
Path(user_config_dir(appname="musicpom", appauthor="billypom"))
|
||||||
|
|||||||
@ -2,7 +2,6 @@ from configparser import ConfigParser
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from appdirs import user_config_dir
|
from appdirs import user_config_dir
|
||||||
from dataclasses import dataclass, asdict
|
from dataclasses import dataclass, asdict
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -47,8 +46,8 @@ class HeaderTags:
|
|||||||
)
|
)
|
||||||
self.config = ConfigParser()
|
self.config = ConfigParser()
|
||||||
self.config.read(cfg_file)
|
self.config.read(cfg_file)
|
||||||
print("header tag config")
|
# print("header tag config")
|
||||||
print(self.config)
|
# print(self.config)
|
||||||
self.user_fields: list = str(self.config["table"]["columns"]).split(",")
|
self.user_fields: list = str(self.config["table"]["columns"]).split(",")
|
||||||
self.editable_fields: list = [
|
self.editable_fields: list = [
|
||||||
"title",
|
"title",
|
||||||
|
|||||||
@ -721,10 +721,11 @@ class MusicTable(QTableView):
|
|||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
params = ""
|
params = ""
|
||||||
|
debug(f'playlist_id: {playlist_id}')
|
||||||
# Load a playlist
|
# Load a playlist
|
||||||
if playlist_id:
|
if len(playlist_id) > 0:
|
||||||
self.selected_playlist_id = playlist_id[0]
|
self.selected_playlist_id = playlist_id[0]
|
||||||
if self.selected_playlist_id:
|
debug('load music table a playlist')
|
||||||
try:
|
try:
|
||||||
with DBA.DBAccess() as db:
|
with DBA.DBAccess() as db:
|
||||||
query = f"SELECT id, {
|
query = f"SELECT id, {
|
||||||
@ -747,6 +748,7 @@ class MusicTable(QTableView):
|
|||||||
return
|
return
|
||||||
# Load the entire library
|
# Load the entire library
|
||||||
else:
|
else:
|
||||||
|
debug('load music table a Whole Table')
|
||||||
try:
|
try:
|
||||||
with DBA.DBAccess() as db:
|
with DBA.DBAccess() as db:
|
||||||
query = f"SELECT id, {fields} FROM song"
|
query = f"SELECT id, {fields} FROM song"
|
||||||
@ -793,14 +795,14 @@ class MusicTable(QTableView):
|
|||||||
|
|
||||||
# reloading the model destroys and makes new indexes
|
# reloading the model destroys and makes new indexes
|
||||||
# so we look for the new index of the current song on load
|
# so we look for the new index of the current song on load
|
||||||
current_song_filepath = self.get_current_song_filepath()
|
# current_song_filepath = self.get_current_song_filepath()
|
||||||
debug(f"load_music_table() | current filepath: {current_song_filepath}")
|
# debug(f"load_music_table() | current filepath: {current_song_filepath}")
|
||||||
for row in range(self.model2.rowCount()):
|
# for row in range(self.model2.rowCount()):
|
||||||
real_index = self.model2.index(
|
# real_index = self.model2.index(
|
||||||
row, self.headers.user_fields.index("filepath")
|
# row, self.headers.user_fields.index("filepath")
|
||||||
)
|
# )
|
||||||
if real_index.data() == current_song_filepath:
|
# if real_index.data() == current_song_filepath:
|
||||||
self.current_song_qmodel_index = real_index
|
# self.current_song_qmodel_index = real_index
|
||||||
self.model2.layoutChanged.emit() # emits a signal that the view should be updated
|
self.model2.layoutChanged.emit() # emits a signal that the view should be updated
|
||||||
|
|
||||||
db_name: str = self.config.get("settings", "db").split("/").pop()
|
db_name: str = self.config.get("settings", "db").split("/").pop()
|
||||||
|
|||||||
13
main.py
13
main.py
@ -85,7 +85,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# UI
|
# UI
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.setWindowTitle("musicpom")
|
self.setWindowTitle("musicpom")
|
||||||
self.setup_fonts()
|
self.setup_labels()
|
||||||
|
|
||||||
# self.vLayoutAlbumArt.SetFixedSize()
|
# self.vLayoutAlbumArt.SetFixedSize()
|
||||||
self.status_bar: QStatusBar = QStatusBar()
|
self.status_bar: QStatusBar = QStatusBar()
|
||||||
@ -360,8 +360,8 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# | |
|
# | |
|
||||||
# |____________________|
|
# |____________________|
|
||||||
|
|
||||||
def setup_fonts(self):
|
def setup_labels(self):
|
||||||
"""Initializes font sizes and behaviors for various UI components"""
|
"""Initializes attributes and behaviors for various UI labels"""
|
||||||
font: QFont = QFont()
|
font: QFont = QFont()
|
||||||
font.setPointSize(12)
|
font.setPointSize(12)
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
@ -370,6 +370,8 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.artistLabel.setTextInteractionFlags(
|
self.artistLabel.setTextInteractionFlags(
|
||||||
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
||||||
)
|
)
|
||||||
|
self.artistLabel.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.artistLabel.setWordWrap(True)
|
||||||
|
|
||||||
font.setPointSize(12)
|
font.setPointSize(12)
|
||||||
font.setBold(False)
|
font.setBold(False)
|
||||||
@ -377,13 +379,18 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.titleLabel.setTextInteractionFlags(
|
self.titleLabel.setTextInteractionFlags(
|
||||||
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
||||||
)
|
)
|
||||||
|
self.titleLabel.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.titleLabel.setWordWrap(True)
|
||||||
|
|
||||||
font.setPointSize(12)
|
font.setPointSize(12)
|
||||||
font.setItalic(True)
|
font.setItalic(True)
|
||||||
|
self.albumLabel: QLabel
|
||||||
self.albumLabel.setFont(font)
|
self.albumLabel.setFont(font)
|
||||||
self.albumLabel.setTextInteractionFlags(
|
self.albumLabel.setTextInteractionFlags(
|
||||||
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
QtCore.Qt.TextInteractionFlag.TextSelectableByMouse
|
||||||
)
|
)
|
||||||
|
self.albumLabel.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
||||||
|
self.albumLabel.setWordWrap(True)
|
||||||
|
|
||||||
def load_config(self) -> None:
|
def load_config(self) -> None:
|
||||||
"""does what it says"""
|
"""does what it says"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user