mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 14:24:15 +02:00
Merge branch 'staging' into modules
This commit is contained in:
@@ -16,7 +16,7 @@ from fpakman.util import util
|
|||||||
from fpakman.view.qt import dialog
|
from fpakman.view.qt import dialog
|
||||||
from fpakman.view.qt.view_model import ApplicationView, ApplicationViewStatus
|
from fpakman.view.qt.view_model import ApplicationView, ApplicationViewStatus
|
||||||
|
|
||||||
INSTALL_BT_STYLE = 'background: {back}; color: white; margin-top: 6px; padding: 1px; font-size: 9px; font-weight: bold'
|
INSTALL_BT_STYLE = 'background: {back}; color: white; font-size: 9px; font-weight: bold'
|
||||||
|
|
||||||
|
|
||||||
class UpdateToggleButton(QToolButton):
|
class UpdateToggleButton(QToolButton):
|
||||||
@@ -136,13 +136,11 @@ class AppsTable(QTableWidget):
|
|||||||
def get_selected_app_icon(self) -> QIcon:
|
def get_selected_app_icon(self) -> QIcon:
|
||||||
return self.item(self.currentRow(), 0).icon()
|
return self.item(self.currentRow(), 0).icon()
|
||||||
|
|
||||||
def _uninstall_app(self):
|
def _uninstall_app(self, app_v: ApplicationView):
|
||||||
selected_app = self.get_selected_app()
|
|
||||||
|
|
||||||
if dialog.ask_confirmation(title=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.title'],
|
if dialog.ask_confirmation(title=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.title'],
|
||||||
body=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.body'].format(selected_app),
|
body=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.body'].format(app_v),
|
||||||
locale_keys=self.window.locale_keys):
|
locale_keys=self.window.locale_keys):
|
||||||
self.window.uninstall_app(selected_app)
|
self.window.uninstall_app(app_v)
|
||||||
|
|
||||||
def _downgrade_app(self):
|
def _downgrade_app(self):
|
||||||
selected_app = self.get_selected_app()
|
selected_app = self.get_selected_app()
|
||||||
@@ -161,15 +159,14 @@ class AppsTable(QTableWidget):
|
|||||||
def _get_app_history(self):
|
def _get_app_history(self):
|
||||||
self.window.get_app_history(self.get_selected_app())
|
self.window.get_app_history(self.get_selected_app())
|
||||||
|
|
||||||
def _install_app(self):
|
def _install_app(self, app_v: ApplicationView):
|
||||||
selected_app = self.get_selected_app()
|
|
||||||
|
|
||||||
if dialog.ask_confirmation(
|
if dialog.ask_confirmation(
|
||||||
title=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.title'],
|
title=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.title'],
|
||||||
body=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.body'].format(selected_app),
|
body=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.body'].format(app_v),
|
||||||
locale_keys=self.window.locale_keys):
|
locale_keys=self.window.locale_keys):
|
||||||
|
|
||||||
self.window.install_app(self.get_selected_app())
|
self.window.install_app(app_v)
|
||||||
|
|
||||||
def _load_icon_and_cache(self, http_response):
|
def _load_icon_and_cache(self, http_response):
|
||||||
icon_url = http_response.url().toString()
|
icon_url = http_response.url().toString()
|
||||||
@@ -218,26 +215,38 @@ class AppsTable(QTableWidget):
|
|||||||
|
|
||||||
self.setCellWidget(idx, 5, col_update)
|
self.setCellWidget(idx, 5, col_update)
|
||||||
|
|
||||||
|
def _gen_row_button(self, text: str, style: str, callback) -> QWidget:
|
||||||
|
col = QWidget()
|
||||||
|
col_bt = QPushButton()
|
||||||
|
col_bt.setText(text)
|
||||||
|
col_bt.setStyleSheet('QPushButton { ' + style + '}')
|
||||||
|
col_bt.clicked.connect(callback)
|
||||||
|
|
||||||
|
layout = QHBoxLayout()
|
||||||
|
layout.setContentsMargins(3, 3, 3, 3)
|
||||||
|
layout.setAlignment(Qt.AlignCenter)
|
||||||
|
layout.addWidget(col_bt)
|
||||||
|
col.setLayout(layout)
|
||||||
|
|
||||||
|
return col
|
||||||
|
|
||||||
def _set_col_installed(self, idx: int, app_v: ApplicationView):
|
def _set_col_installed(self, idx: int, app_v: ApplicationView):
|
||||||
|
|
||||||
if app_v.model.installed:
|
if app_v.model.installed:
|
||||||
if app_v.model.can_be_uninstalled():
|
if app_v.model.can_be_uninstalled():
|
||||||
col = QPushButton()
|
def uninstall():
|
||||||
col.setText(self.window.locale_keys['uninstall'].capitalize())
|
self._uninstall_app(app_v)
|
||||||
col.setStyleSheet('QPushButton { ' + INSTALL_BT_STYLE.format(back='#cc0000') + '}')
|
|
||||||
col.setMaximumHeight(20)
|
col = self._gen_row_button(self.window.locale_keys['uninstall'].capitalize(), INSTALL_BT_STYLE.format(back='#cc0000'), uninstall)
|
||||||
col.clicked.connect(self._uninstall_app)
|
|
||||||
else:
|
else:
|
||||||
col = QLabel()
|
col = QLabel()
|
||||||
col.setPixmap((QPixmap(resource.get_path('img/checked.svg'))))
|
col.setPixmap((QPixmap(resource.get_path('img/checked.svg'))))
|
||||||
col.setAlignment(Qt.AlignCenter)
|
col.setAlignment(Qt.AlignCenter)
|
||||||
col.setToolTip(self.window.locale_keys['installed'])
|
col.setToolTip(self.window.locale_keys['installed'])
|
||||||
elif app_v.model.can_be_installed():
|
elif app_v.model.can_be_installed():
|
||||||
col = QPushButton()
|
def install():
|
||||||
col.setText(self.window.locale_keys['install'].capitalize())
|
self._install_app(app_v)
|
||||||
col.setStyleSheet('QPushButton { ' + INSTALL_BT_STYLE.format(back='green') + '}')
|
col = self._gen_row_button(self.window.locale_keys['install'].capitalize(), INSTALL_BT_STYLE.format(back='green'), install)
|
||||||
col.setMaximumHeight(20)
|
|
||||||
col.clicked.connect(self._install_app)
|
|
||||||
else:
|
else:
|
||||||
col = None
|
col = None
|
||||||
|
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
def uninstall_app(self, app: ApplicationView):
|
def uninstall_app(self, app: ApplicationView):
|
||||||
pwd = None
|
pwd = None
|
||||||
requires_root = self.manager.requires_root('uninstall', self.table_apps.get_selected_app().model)
|
requires_root = self.manager.requires_root('uninstall', app.model)
|
||||||
|
|
||||||
if not is_root() and requires_root:
|
if not is_root() and requires_root:
|
||||||
pwd, ok = ask_root_password(self.locale_keys)
|
pwd, ok = ask_root_password(self.locale_keys)
|
||||||
@@ -639,7 +639,7 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
def install_app(self, app: ApplicationView):
|
def install_app(self, app: ApplicationView):
|
||||||
pwd = None
|
pwd = None
|
||||||
requires_root = self.manager.requires_root('install', self.table_apps.get_selected_app().model)
|
requires_root = self.manager.requires_root('install', app.model)
|
||||||
|
|
||||||
if not is_root() and requires_root:
|
if not is_root() and requires_root:
|
||||||
pwd, ok = ask_root_password(self.locale_keys)
|
pwd, ok = ask_root_password(self.locale_keys)
|
||||||
|
|||||||
Reference in New Issue
Block a user