Skip to content

Commit 85ed3a8

Browse files
authored
Fixing appearance of cells in search and downloads table in GUI (#130)
* fixing highlighting in GUI * fixing button view when thumbnail is not shown
1 parent b45a982 commit 85ed3a8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/onthespot/gui/mainui.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from urllib3.exceptions import MaxRetryError, NewConnectionError
77
from PyQt6 import uic, QtGui
88
from PyQt6.QtCore import QThread, QDir, Qt, pyqtSignal, QObject, QTimer
9-
from PyQt6.QtGui import QIcon
9+
from PyQt6.QtGui import QIcon, QColor
1010
from PyQt6.QtWidgets import QApplication, QMainWindow, QHeaderView, QLabel, QPushButton, QProgressBar, QTableWidgetItem, QFileDialog, QRadioButton, QHBoxLayout, QWidget, QColorDialog
1111
from ..accounts import get_account_token, FillAccountPool
1212
from ..api.apple_music import apple_music_add_account, apple_music_get_track_metadata
@@ -418,11 +418,13 @@ def add_item_to_download_list(self, item, item_metadata):
418418
item_service = item["item_service"]
419419
service_label = QTableWidgetItem(str(item_service).replace('_', ' ').title())
420420
service_label.setIcon(self.get_icon(item_service))
421+
service_label.setBackground(QColor(0, 0, 0, 0))
421422

422423
status_label = QLabel(self.tbl_dl_progress)
423424
status_label.setText(self.tr("Waiting"))
425+
status_label.setStyleSheet("background-color: transparent;")
424426
actions = DownloadActionsButtons(item['local_id'], item_metadata, pbar, copy_btn, cancel_btn, retry_btn, open_btn, locate_btn, delete_btn)
425-
427+
426428
rows = self.tbl_dl_progress.rowCount()
427429
self.tbl_dl_progress.insertRow(rows)
428430
if item_metadata.get('explicit'):
@@ -435,6 +437,10 @@ def add_item_to_download_list(self, item, item_metadata):
435437
else:
436438
item_label = QLabel(self.tbl_dl_progress)
437439
item_label.setText(title)
440+
item_label.setAlignment(Qt.AlignmentFlag.AlignLeft)
441+
item_label.setAlignment(Qt.AlignmentFlag.AlignVCenter)
442+
item_label.setStyleSheet("background-color: transparent;")
443+
438444
# Add To List
439445
self.tbl_dl_progress.setItem(rows, 0, QTableWidgetItem(str(item['local_id'])))
440446
self.tbl_dl_progress.setCellWidget(rows, 1, item_label)
@@ -875,6 +881,7 @@ def copy_btn_clicked(item_url):
875881
download_btn = QPushButton(self.tbl_search_results)
876882
download_btn.setIcon(self.get_icon('download'))
877883
download_btn.setMinimumHeight(30)
884+
download_btn.setStyleSheet("QPushButton { background-color: palette(button); }")
878885
download_btn.clicked.connect(lambda x,
879886
item_name=result['item_name'],
880887
item_url=result['item_url'],
@@ -887,13 +894,17 @@ def copy_btn_clicked(item_url):
887894
copy_btn = QPushButton(self.tbl_search_results)
888895
copy_btn.setIcon(self.get_icon('link'))
889896
copy_btn.setMinimumHeight(30)
897+
copy_btn.setStyleSheet("QPushButton { background-color: palette(button); }")
890898
copy_btn.clicked.connect(lambda x, item_url=result['item_url']: copy_btn_clicked(item_url))
891899

892900
btn_layout = QHBoxLayout()
901+
btn_layout.setContentsMargins(2, 2, 2, 2)
902+
btn_layout.setSpacing(4)
893903
btn_layout.addWidget(copy_btn)
894904
btn_layout.addWidget(download_btn)
895905

896906
btn_widget = QWidget()
907+
btn_widget.setStyleSheet("QWidget { background-color: transparent !important; }")
897908
btn_widget.setLayout(btn_layout)
898909

899910
service = QTableWidgetItem(result['item_service'].replace('_', ' ').title())
@@ -908,13 +919,17 @@ def copy_btn_clicked(item_url):
908919
else:
909920
item_label = QLabel(self.tbl_dl_progress)
910921
item_label.setText(result['item_name'])
922+
item_label.setStyleSheet("background-color: transparent;")
923+
911924

912925
self.tbl_search_results.setCellWidget(rows, 0, item_label)
913926
self.tbl_search_results.setItem(rows, 1, QTableWidgetItem(str(result['item_by'])))
914927
self.tbl_search_results.setItem(rows, 2, QTableWidgetItem(result['item_type'].replace('podcast_', '').title()))
915928
self.tbl_search_results.setItem(rows, 3, service)
916929
self.tbl_search_results.setCellWidget(rows, 4, btn_widget)
917930
self.tbl_search_results.horizontalHeader().resizeSection(0, 450)
931+
self.tbl_search_results.horizontalHeader().resizeSection(4, 100)
932+
918933

919934
self.search_term.setText('')
920935

src/onthespot/gui/thumb_listitem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, label, thumb_url):
2020
item_label.setText(label.strip())
2121
item_label.setWordWrap(True) # Allow text to wrap if necessary
2222
item_label.setAlignment(Qt.AlignmentFlag.AlignLeft)
23+
item_label.setAlignment(Qt.AlignmentFlag.AlignVCenter)
2324

2425
# Create the QLabel for the pixmap
2526
self.image_label = QLabel(self)

0 commit comments

Comments
 (0)