Add tooltip to radio buttons on import file choices

This commit is contained in:
Keith Edmunds 2024-12-22 17:26:33 +00:00
parent a1709e92ae
commit 6da6f7044b

View File

@ -12,7 +12,6 @@ import shutil
from PyQt6.QtCore import (
pyqtSignal,
QObject,
Qt,
QThread,
)
from PyQt6.QtWidgets import (
@ -20,16 +19,13 @@ from PyQt6.QtWidgets import (
QDialog,
QHBoxLayout,
QLabel,
QMainWindow,
QMessageBox,
QPushButton,
QRadioButton,
QStatusBar,
QVBoxLayout,
)
# Third party imports
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.session import Session
# App imports
from classes import (
@ -329,17 +325,18 @@ class FileImporter:
f"({self.import_files_data[idx].tags.artist})"
)
# Build a list of (track title and artise, track_id)
choices: list[tuple[str, int]] = []
# Build a list of (track title and artist, track_id, track path)
choices: list[tuple[str, int, str]] = []
# First choice is always to import as a new track
choices.append((Config.DO_NOT_IMPORT, -2))
choices.append((Config.IMPORT_AS_NEW, 0))
choices.append((Config.DO_NOT_IMPORT, -2, ""))
choices.append((Config.IMPORT_AS_NEW, 0, ""))
for track_id in track_ids:
choices.append(
(
f"{self.existing_tracks[track_id].title} "
f"({self.existing_tracks[track_id].artist})",
track_id,
str(self.existing_tracks[track_id].path)
)
)
@ -444,7 +441,7 @@ class PickMatch(QDialog):
"""
def __init__(
self, new_track_details: str, items_with_ids: list[tuple[str, int]]
self, new_track_details: str, items_with_ids: list[tuple[str, int, str]]
) -> None:
super().__init__()
self.new_track_details = new_track_details
@ -472,7 +469,7 @@ class PickMatch(QDialog):
self.button_group = QButtonGroup()
# Add radio buttons for each item
for idx, (text, track_id) in enumerate(items_with_ids):
for idx, (text, track_id, track_path) in enumerate(items_with_ids):
if (
track_sequence.current
and track_id
@ -485,6 +482,7 @@ class PickMatch(QDialog):
self.button_group.addButton(radio_button, -1)
else:
radio_button = QRadioButton(text)
radio_button.setToolTip(track_path)
self.button_group.addButton(radio_button, track_id)
layout.addWidget(radio_button)
@ -498,8 +496,8 @@ class PickMatch(QDialog):
cancel_button = QPushButton("Cancel")
button_layout.addWidget(ok_button)
button_layout.addWidget(cancel_button)
layout.addLayout(button_layout)
self.setLayout(layout)
# Connect buttons to actions