Added "No Results" Text to GUI

This commit is contained in:
Vxrtrauter
2025-10-14 10:42:41 +02:00
parent 6de5337e77
commit 43baeed7d3
2 changed files with 22 additions and 6 deletions
+15
View File
@@ -51,6 +51,12 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.softwareList = QListWidget() self.softwareList = QListWidget()
self.post_author_list = QListWidget() self.post_author_list = QListWidget()
self.libraryList = QListWidget() self.libraryList = QListWidget()
self.emptyResults = QLabel("No Results")
self.emptyResults.setAlignment(Qt.AlignCenter)
self.emptyResults.hide()
self.download_model = None self.download_model = None
self.downloadList = QTableView() self.downloadList = QTableView()
self.emptyLibrary = QLabel("No items in library.") self.emptyLibrary = QLabel("No items in library.")
@@ -117,6 +123,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
self.horizontal_layout = QHBoxLayout() self.horizontal_layout = QHBoxLayout()
self.horizontal_layout.addWidget(self.softwareList, stretch=3) self.horizontal_layout.addWidget(self.softwareList, stretch=3)
self.horizontal_layout.addWidget(self.emptyResults, stretch=3)
self.horizontal_layout.addWidget(self.post_author_list) self.horizontal_layout.addWidget(self.post_author_list)
self.tab1 = create_tab("Search", self.searchbar, self.softwareList, self.tabs, self.dlbutton, self.horizontal_layout) self.tab1 = create_tab("Search", self.searchbar, self.softwareList, self.tabs, self.dlbutton, self.horizontal_layout)
@@ -173,3 +180,11 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
def update_progress(self): def update_progress(self):
progress = dlprogress() progress = dlprogress()
self.progressbar.setValue(progress) self.progressbar.setValue(progress)
def show_empty_results(self, show: bool):
if show:
self.softwareList.hide()
self.emptyResults.show()
else:
self.emptyResults.hide()
self.softwareList.show()
+7 -6
View File
@@ -25,13 +25,14 @@ def return_pressed(self):
self.post_author_list.addItems(state.post_author) self.post_author_list.addItems(state.post_author)
if state.tracker == "rutracker": if state.tracker == "rutracker":
_, state.posts, _, _, cached = split_data(response) _, state.posts, _, _, cached = split_data(response)
if state.posts == []: if state.posts == []:
if state.debug: if state.debug:
print(f"No Results found for \"{search_text}\"") print(f"No Results found for \"{search_text}\"")
self.softwareList.clear() self.softwareList.clear()
self.softwareList.addItem("No Results") # replace with no results text in center self.show_empty_results(True)
else:
state.post_titles, _, state.post_author = format_data(state.posts) state.post_titles, _, state.post_author = format_data(state.posts)
self.show_empty_results(False)
self.post_author_list.clear() self.post_author_list.clear()
self.post_author_list.addItems(state.post_author) self.post_author_list.addItems(state.post_author)
self.softwareList.clear() self.softwareList.clear()