mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 01:34:15 +02:00
[feature][flatpak] registering Flathub at system level
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import re
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from typing import List, Type, Set
|
||||
from typing import List, Type, Set, Tuple
|
||||
|
||||
import requests
|
||||
from PyQt5.QtCore import QThread, pyqtSignal
|
||||
@@ -28,11 +28,13 @@ class AsyncAction(QThread, ProcessWatcher):
|
||||
signal_status = pyqtSignal(str) # changes the GUI status message
|
||||
signal_substatus = pyqtSignal(str) # changes the GUI substatus message
|
||||
signal_progress = pyqtSignal(int)
|
||||
signal_root_password = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
super(AsyncAction, self).__init__()
|
||||
self.wait_confirmation = False
|
||||
self.confirmation_res = None
|
||||
self.root_password = None
|
||||
self.stop = False
|
||||
|
||||
def request_confirmation(self, title: str, body: str, components: List[InputViewComponent] = None, confirmation_label: str = None, deny_label: str = None) -> bool:
|
||||
@@ -41,10 +43,22 @@ class AsyncAction(QThread, ProcessWatcher):
|
||||
self.wait_user()
|
||||
return self.confirmation_res
|
||||
|
||||
def request_root_password(self) -> Tuple[str, bool]:
|
||||
self.wait_confirmation = True
|
||||
self.signal_root_password.emit()
|
||||
self.wait_user()
|
||||
res = self.root_password
|
||||
self.root_password = None
|
||||
return res
|
||||
|
||||
def confirm(self, res: bool):
|
||||
self.confirmation_res = res
|
||||
self.wait_confirmation = False
|
||||
|
||||
def set_root_password(self, password: str, valid: bool):
|
||||
self.root_password = (password, valid)
|
||||
self.wait_confirmation = False
|
||||
|
||||
def wait_user(self):
|
||||
while self.wait_confirmation:
|
||||
time.sleep(0.01)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import logging
|
||||
import operator
|
||||
import time
|
||||
from functools import reduce
|
||||
from pathlib import Path
|
||||
from typing import List, Type, Set
|
||||
|
||||
@@ -17,9 +15,10 @@ from bauh.api.abstract.controller import SoftwareManager
|
||||
from bauh.api.abstract.model import SoftwarePackage, PackageAction
|
||||
from bauh.api.abstract.view import MessageType
|
||||
from bauh.api.http import HttpClient
|
||||
from bauh.commons import user
|
||||
from bauh.commons.html import bold
|
||||
from bauh.view.core.controller import GenericSoftwareManager
|
||||
from bauh.view.qt import dialog, commons, qt_utils
|
||||
from bauh.view.qt import dialog, commons, qt_utils, root
|
||||
from bauh.view.qt.about import AboutDialog
|
||||
from bauh.view.qt.apps_table import AppsTable, UpdateToggleButton
|
||||
from bauh.view.qt.components import new_spacer, InputFilter, IconButton
|
||||
@@ -27,7 +26,7 @@ from bauh.view.qt.confirmation import ConfirmationDialog
|
||||
from bauh.view.qt.gem_selector import GemSelectorPanel
|
||||
from bauh.view.qt.history import HistoryDialog
|
||||
from bauh.view.qt.info import InfoDialog
|
||||
from bauh.view.qt.root import is_root, ask_root_password
|
||||
from bauh.view.qt.root import ask_root_password
|
||||
from bauh.view.qt.screenshots import ScreenshotsDialog
|
||||
from bauh.view.qt.styles import StylesComboBox
|
||||
from bauh.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \
|
||||
@@ -49,6 +48,7 @@ class ManageWindow(QWidget):
|
||||
__BASE_HEIGHT__ = 400
|
||||
|
||||
signal_user_res = pyqtSignal(bool)
|
||||
signal_root_password = pyqtSignal(str, bool)
|
||||
signal_table_update = pyqtSignal()
|
||||
|
||||
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size, config: dict,
|
||||
@@ -396,8 +396,10 @@ class ManageWindow(QWidget):
|
||||
action.signal_status.connect(self._change_label_status)
|
||||
action.signal_substatus.connect(self._change_label_substatus)
|
||||
action.signal_progress.connect(self._update_process_progress)
|
||||
action.signal_root_password.connect(self._ask_root_password)
|
||||
|
||||
self.signal_user_res.connect(action.confirm)
|
||||
self.signal_root_password.connect(action.set_root_password)
|
||||
|
||||
return action
|
||||
|
||||
@@ -414,6 +416,12 @@ class ManageWindow(QWidget):
|
||||
self.thread_animate_progress.animate()
|
||||
self.signal_user_res.emit(res)
|
||||
|
||||
def _ask_root_password(self):
|
||||
self.thread_animate_progress.pause()
|
||||
password, valid = root.ask_root_password(self.i18n)
|
||||
self.thread_animate_progress.animate()
|
||||
self.signal_root_password.emit(password, valid)
|
||||
|
||||
def _show_message(self, msg: dict):
|
||||
self.thread_animate_progress.pause()
|
||||
dialog.show_message(title=msg['title'], body=msg['body'], type_=msg['type'])
|
||||
@@ -549,7 +557,7 @@ class ManageWindow(QWidget):
|
||||
pwd = None
|
||||
requires_root = self.manager.requires_root('uninstall', app.model)
|
||||
|
||||
if not is_root() and requires_root:
|
||||
if not user.is_root() and requires_root:
|
||||
pwd, ok = ask_root_password(self.i18n)
|
||||
|
||||
if not ok:
|
||||
@@ -865,7 +873,7 @@ class ManageWindow(QWidget):
|
||||
widgets=[UpdateToggleButton(None, self, self.i18n, clickable=False)]):
|
||||
pwd = None
|
||||
|
||||
if not is_root() and requires_root:
|
||||
if not user.is_root() and requires_root:
|
||||
pwd, ok = ask_root_password(self.i18n)
|
||||
|
||||
if not ok:
|
||||
@@ -983,7 +991,7 @@ class ManageWindow(QWidget):
|
||||
pwd = None
|
||||
requires_root = self.manager.requires_root('downgrade', pkgv.model)
|
||||
|
||||
if not is_root() and requires_root:
|
||||
if not user.is_root() and requires_root:
|
||||
pwd, ok = ask_root_password(self.i18n)
|
||||
|
||||
if not ok:
|
||||
@@ -1076,7 +1084,7 @@ class ManageWindow(QWidget):
|
||||
pwd = None
|
||||
requires_root = self.manager.requires_root('install', pkg.model)
|
||||
|
||||
if not is_root() and requires_root:
|
||||
if not user.is_root() and requires_root:
|
||||
pwd, ok = ask_root_password(self.i18n)
|
||||
|
||||
if not ok:
|
||||
@@ -1131,7 +1139,7 @@ class ManageWindow(QWidget):
|
||||
def execute_custom_action(self, pkg: PackageView, action: PackageAction):
|
||||
pwd = None
|
||||
|
||||
if not is_root() and action.requires_root:
|
||||
if not user.is_root() and action.requires_root:
|
||||
pwd, ok = ask_root_password(self.i18n)
|
||||
|
||||
if not ok:
|
||||
|
||||
Reference in New Issue
Block a user