Skip to content

Commit

Permalink
Improve text messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Oct 16, 2024
1 parent 97c3f21 commit 5936619
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions napari_plugin_manager/qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ def filter(self, text: str, starts_with_chars: int = 1):
id(item) not in shown and not item.widget.is_busy()
)
else:
print(self.count_visible(), self.count())
for i in range(self.count()):
item = self.item(i)
item.setHidden(False)
Expand Down Expand Up @@ -1151,7 +1152,7 @@ def _setup_ui(self):
lay.setContentsMargins(0, 2, 0, 2)
self.installed_label = QLabel(trans._("Installed Plugins"))
self.packages_search = QLineEdit()
self.packages_search.setPlaceholderText(trans._("search the hub..."))
self.packages_search.setPlaceholderText(trans._("search..."))
self.packages_search.setMaximumWidth(350)
self.packages_search.setClearButtonEnabled(True)
# self.packages_search.textChanged.connect(self._filter_timer.start)
Expand Down Expand Up @@ -1318,7 +1319,16 @@ def _update_plugin_count(self):

available_count = len(self._plugin_data) - self.installed_list.count()
available_count = available_count if available_count >= 0 else 0
if self._plugins_found > self.MAX_PLUGIN_SEARCH_ITEMS:

if self._plugins_found == 0:
self.avail_label.setText(
trans._(
"{amount} plugins available in the napari Hub",
found=self._plugins_found,
amount=available_count,
)
)
elif self._plugins_found > self.MAX_PLUGIN_SEARCH_ITEMS:
self.avail_label.setText(
trans._(
"Found ({found}) out of {amount} in the napari Hub. Displaying the first {max_count} plugins.",
Expand All @@ -1336,22 +1346,6 @@ def _update_plugin_count(self):
)
)

# if available_count == available_count_visible:
# self.avail_label.setText(
# trans._(
# "Available Plugins ({amount})",
# amount=available_count,
# )
# )
# else:
# self.avail_label.setText(
# trans._(
# "Available Plugins ({count}/{amount})",
# count=available_count_visible,
# amount=available_count,
# )
# )

def _install_packages(
self,
packages: Sequence[str] = (),
Expand Down Expand Up @@ -1454,6 +1448,7 @@ def _handle_yield(self, data: Tuple[npe2.PackageMetadata, bool, Dict]):
metadata, _, _ = data
self._plugin_data_map[metadata.name] = data
self.available_list.set_data(self._plugin_data)
self._update_plugin_count()

def _search_in_available(self, text):
idxs = []
Expand Down Expand Up @@ -1524,6 +1519,7 @@ def search(self, text: Optional[str] = None, skip=False) -> None:
self.packages_search.setText(text)

if len(text.strip()) == 0:
self.installed_list.filter('')
self.available_list.hideAll()
self._plugin_queue = None
self._add_items_timer.stop()
Expand All @@ -1533,9 +1529,9 @@ def search(self, text: Optional[str] = None, skip=False) -> None:
self._plugin_data[idx]
for idx in self._search_in_available(text)
]
print(text, len(items))

# Go over list and remove any not found
self.installed_list.filter(text.strip().lower())
self.available_list.filter(text.strip().lower())

if items:
Expand Down

0 comments on commit 5936619

Please sign in to comment.