mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[view.qt] info dialog: only show the 'open' button if 'xdg-open' is installed
This commit is contained in:
@@ -82,6 +82,7 @@ Key features
|
|||||||
- `snapd`: Snaps support
|
- `snapd`: Snaps support
|
||||||
- `python3-lxml`, `python3-bs4`: Web apps support
|
- `python3-lxml`, `python3-bs4`: Web apps support
|
||||||
- `python3-venv`: [isolated installation](#inst_iso)
|
- `python3-venv`: [isolated installation](#inst_iso)
|
||||||
|
- `xdg-utils`: to open URLs in the browsers (`xdg-open`)
|
||||||
|
|
||||||
##### Updating bauh
|
##### Updating bauh
|
||||||
|
|
||||||
@@ -126,7 +127,8 @@ makepkg -si
|
|||||||
- `axel`: multi-threaded downloads alternative
|
- `axel`: multi-threaded downloads alternative
|
||||||
- `libappindicator-gtk2`: tray-mode (GTK2 desktop environments)
|
- `libappindicator-gtk2`: tray-mode (GTK2 desktop environments)
|
||||||
- `libappindicator-gtk3`: tray-mode (GTK3 desktop environments)
|
- `libappindicator-gtk3`: tray-mode (GTK3 desktop environments)
|
||||||
- `wget`, `sqlite`, `fuse2`, `fuse3`: AppImage support
|
- `xdg-utils`: to open URLs in the browser (`xdg-open`)
|
||||||
|
- `sqlite`, `fuse2`, `fuse3`: AppImage support
|
||||||
- `flatpak`: Flatpak support
|
- `flatpak`: Flatpak support
|
||||||
- `snapd`: Snap support
|
- `snapd`: Snap support
|
||||||
- `pacman`: ArchLinux package management support
|
- `pacman`: ArchLinux package management support
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon, QCursor
|
from PyQt5.QtGui import QIcon, QCursor
|
||||||
@@ -19,10 +21,11 @@ IGNORED_ATTRS = {'name', '__app__'}
|
|||||||
|
|
||||||
class InfoDialog(QDialog):
|
class InfoDialog(QDialog):
|
||||||
|
|
||||||
def __init__(self, pkg_info: dict, icon_cache: MemoryCache, i18n: I18n):
|
def __init__(self, pkg_info: dict, icon_cache: MemoryCache, i18n: I18n, can_open_url: bool):
|
||||||
super(InfoDialog, self).__init__()
|
super(InfoDialog, self).__init__()
|
||||||
self.setWindowTitle(str(pkg_info['__app__']))
|
self.setWindowTitle(str(pkg_info['__app__']))
|
||||||
self.i18n = i18n
|
self.i18n = i18n
|
||||||
|
self._can_open_url = can_open_url
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
@@ -129,7 +132,7 @@ class InfoDialog(QDialog):
|
|||||||
|
|
||||||
def _gen_show_button(self, idx: int, val: str):
|
def _gen_show_button(self, idx: int, val: str):
|
||||||
|
|
||||||
is_url = bool(RE_URL.match(val)) if val else False
|
is_url = self._can_open_url and bool(RE_URL.match(val)) if val else False
|
||||||
|
|
||||||
if is_url:
|
if is_url:
|
||||||
bt_label = self.i18n["manage_window.info.open_url"]
|
bt_label = self.i18n["manage_window.info.open_url"]
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import os.path
|
import os.path
|
||||||
|
import shutil
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Type, Set, Tuple, Optional, Dict, Any
|
from typing import List, Type, Set, Tuple, Optional, Dict, Any
|
||||||
@@ -472,6 +473,7 @@ class ManageWindow(QWidget):
|
|||||||
self._register_groups()
|
self._register_groups()
|
||||||
self._screen_geometry: Optional[QRect] = None
|
self._screen_geometry: Optional[QRect] = None
|
||||||
self.searched_term: Optional[str] = None # last searched term
|
self.searched_term: Optional[str] = None # last searched term
|
||||||
|
self._can_open_urls: Optional[bool] = None # whether URLs can be opened in the browser
|
||||||
|
|
||||||
qt_utils.centralize(self)
|
qt_utils.centralize(self)
|
||||||
|
|
||||||
@@ -1368,7 +1370,8 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
if pkg_info:
|
if pkg_info:
|
||||||
if len(pkg_info) > 1:
|
if len(pkg_info) > 1:
|
||||||
dialog_info = InfoDialog(pkg_info=pkg_info, icon_cache=self.icon_cache, i18n=self.i18n)
|
dialog_info = InfoDialog(pkg_info=pkg_info, icon_cache=self.icon_cache, i18n=self.i18n,
|
||||||
|
can_open_url=self.can_open_urls)
|
||||||
dialog_info.exec_()
|
dialog_info.exec_()
|
||||||
else:
|
else:
|
||||||
dialog.show_message(title=self.i18n['warning'].capitalize(),
|
dialog.show_message(title=self.i18n['warning'].capitalize(),
|
||||||
@@ -1816,3 +1819,10 @@ class ManageWindow(QWidget):
|
|||||||
def closeEvent(self, event: QCloseEvent) -> None:
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
# needs to be stopped to avoid a Qt exception/crash
|
# needs to be stopped to avoid a Qt exception/crash
|
||||||
self.table_apps.stop_file_downloader(wait=True)
|
self.table_apps.stop_file_downloader(wait=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_open_urls(self) -> bool:
|
||||||
|
if self._can_open_urls is None:
|
||||||
|
self._can_open_urls = shutil.which("xdg-open")
|
||||||
|
|
||||||
|
return self._can_open_urls
|
||||||
|
|||||||
Reference in New Issue
Block a user