diff options
| author | Warry <FunWarry@users.noreply.github.com> | 2025-11-29 14:15:51 +0100 |
|---|---|---|
| committer | Warry <FunWarry@users.noreply.github.com> | 2025-11-29 14:15:51 +0100 |
| commit | 8905ac7e75029a772d92dc2898976ebb0e79acd3 (patch) | |
| tree | 4bd94c299f3afb2cbe407184a2c2c9a31a346bd8 /tidal_dl_ng/gui.py | |
| parent | c4d999e8dc997e8cd2c45070b9569e42dbf845b4 (diff) | |
| download | tidal-dl-ng-8905ac7e75029a772d92dc2898976ebb0e79acd3.tar.gz | |
feat: enable rich text links for metadata fields and add search functionality
- Introduced clickable metadata links (tracks, albums, artists, playlists, videos).
- Left-click triggers in-app search; Ctrl+click or right-click opens browser search.
- Enhanced label interactions and added tooltips for actionable fields.
- Simplified artist, album, and playlist rendering with rich links.
- Extended search functionality with URL-safe encoding and type mapping.
Diffstat (limited to 'tidal_dl_ng/gui.py')
| -rw-r--r-- | tidal_dl_ng/gui.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py index 7c7b6ab..4a22035 100644 --- a/tidal_dl_ng/gui.py +++ b/tidal_dl_ng/gui.py @@ -48,6 +48,7 @@ import contextlib import math import sys import time +import urllib.parse from collections.abc import Callable, Iterable, Sequence from typing import Any @@ -863,6 +864,52 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): # Managers self.queue_manager.connect_signals() self.playlist_manager.connect_signals() + self.info_tab_widget.s_search_in_app.connect(self.on_search_in_app) + self.info_tab_widget.s_search_in_browser.connect(self.on_search_in_browser) + + def on_search_in_app(self, search_term: str, search_type: str): + """Perform a search within the application, selecting the correct category.""" + self.l_search.setText(search_term) + + # Map the search type string to the corresponding class + search_type_map = { + "artist": Artist, + "album": Album, + "track": Track, + "video": Video, + "playlist": Playlist, + } + # Default to the current selection if the type is unknown + search_category = search_type_map.get(search_type.lower(), self.cb_search_type.currentData()) + + # Find the index of the category in the combobox and set it + for i in range(self.cb_search_type.count()): + if self.cb_search_type.itemData(i) == search_category: + self.cb_search_type.setCurrentIndex(i) + break + + self.search_manager.search_populate_results(search_term, search_category) + + def on_search_in_browser(self, search_term: str, search_type: str): + """Open a search in the default web browser.""" + safe_term = urllib.parse.quote(search_term) + # Map the search type to the URL path component + search_path_map = { + "artist": "artists", + "album": "albums", + "track": "tracks", + "video": "videos", + "playlist": "playlists", + } + # Use a generic search if the type is not in the map + search_path = search_path_map.get(search_type.lower()) + + if search_path: + url = QtCore.QUrl(f"https://listen.tidal.com/search/{search_path}?q={safe_term}") + else: + url = QtCore.QUrl(f"https://listen.tidal.com/search?q={safe_term}") + + QtGui.QDesktopServices.openUrl(url) def on_logout(self) -> None: """Log out from TIDAL and close the application.""" |
