mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
setting flathub remote if it is not set (#18)
This commit is contained in:
@@ -1 +1 @@
|
|||||||
__version__ = '0.3.0'
|
__version__ = '0.3.1'
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from fpakman.util import util
|
|||||||
from fpakman.core.controller import FlatpakManager
|
from fpakman.core.controller import FlatpakManager
|
||||||
from fpakman.util.cache import Cache
|
from fpakman.util.cache import Cache
|
||||||
from fpakman.util.memory import CacheCleaner
|
from fpakman.util.memory import CacheCleaner
|
||||||
|
from fpakman.view.qt import common
|
||||||
from fpakman.view.qt.systray import TrayIcon
|
from fpakman.view.qt.systray import TrayIcon
|
||||||
|
|
||||||
app_name = 'fpakman'
|
app_name = 'fpakman'
|
||||||
@@ -51,6 +52,10 @@ if args.check_interval <= 0:
|
|||||||
if args.update_notification == 0:
|
if args.update_notification == 0:
|
||||||
log_msg('updates notifications are disabled', Fore.YELLOW)
|
log_msg('updates notifications are disabled', Fore.YELLOW)
|
||||||
|
|
||||||
|
locale_keys = util.get_locale_keys(args.locale)
|
||||||
|
|
||||||
|
common.check_flatpak_installed(locale_keys)
|
||||||
|
|
||||||
caches = []
|
caches = []
|
||||||
flatpak_api_cache = Cache(expiration_time=args.cache_exp)
|
flatpak_api_cache = Cache(expiration_time=args.cache_exp)
|
||||||
caches.append(flatpak_api_cache)
|
caches.append(flatpak_api_cache)
|
||||||
@@ -58,8 +63,6 @@ caches.append(flatpak_api_cache)
|
|||||||
icon_cache = Cache(expiration_time=args.icon_exp)
|
icon_cache = Cache(expiration_time=args.icon_exp)
|
||||||
caches.append(icon_cache)
|
caches.append(icon_cache)
|
||||||
|
|
||||||
locale_keys = util.get_locale_keys(args.locale)
|
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setWindowIcon(QIcon(resource.get_path('img/logo.svg')))
|
app.setWindowIcon(QIcon(resource.get_path('img/logo.svg')))
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class FlatpakManager:
|
|||||||
self.http_session = requests.Session()
|
self.http_session = requests.Session()
|
||||||
self.lock_read = Lock()
|
self.lock_read = Lock()
|
||||||
self.async_data_loader = FlatpakAsyncDataLoaderManager(api_cache=self.api_cache)
|
self.async_data_loader = FlatpakAsyncDataLoaderManager(api_cache=self.api_cache)
|
||||||
|
flatpak.set_default_remotes()
|
||||||
|
|
||||||
def _map_to_model(self, app: dict) -> FlatpakApplication:
|
def _map_to_model(self, app: dict) -> FlatpakApplication:
|
||||||
|
|
||||||
|
|||||||
@@ -212,3 +212,8 @@ def search(word: str) -> List[dict]:
|
|||||||
|
|
||||||
def install_and_stream(app_id: str, origin: str):
|
def install_and_stream(app_id: str, origin: str):
|
||||||
return system.stream_cmd([BASE_CMD, 'install', origin, app_id, '-y'])
|
return system.stream_cmd([BASE_CMD, 'install', origin, app_id, '-y'])
|
||||||
|
|
||||||
|
|
||||||
|
def set_default_remotes():
|
||||||
|
system.run_cmd('flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo')
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class AppsTable(QTableWidget):
|
|||||||
'flatpak.info.version',
|
'flatpak.info.version',
|
||||||
'manage_window.columns.latest_version',
|
'manage_window.columns.latest_version',
|
||||||
'flatpak.info.branch',
|
'flatpak.info.branch',
|
||||||
'flatpak.info.arch',
|
|
||||||
'flatpak.info.description',
|
'flatpak.info.description',
|
||||||
'flatpak.info.origin',
|
'flatpak.info.origin',
|
||||||
'manage_window.columns.installed',
|
'manage_window.columns.installed',
|
||||||
@@ -113,11 +112,7 @@ class AppsTable(QTableWidget):
|
|||||||
if app_v.visible and app_v.status == ApplicationViewStatus.LOADING and app_v.model.status == ApplicationStatus.READY:
|
if app_v.visible and app_v.status == ApplicationViewStatus.LOADING and app_v.model.status == ApplicationStatus.READY:
|
||||||
self.network_man.get(QNetworkRequest(QUrl(app_v.model.base_data.icon_url)))
|
self.network_man.get(QNetworkRequest(QUrl(app_v.model.base_data.icon_url)))
|
||||||
self.item(idx, 2).setText(app_v.model.base_data.latest_version)
|
self.item(idx, 2).setText(app_v.model.base_data.latest_version)
|
||||||
|
self._set_col_description(self.item(idx, 4), app_v)
|
||||||
desc = app_v.get_async_attr('description', strip_html=True)
|
|
||||||
self.item(idx, 5).setText(desc)
|
|
||||||
self.item(idx, 5).setToolTip(desc)
|
|
||||||
app_v.status = ApplicationViewStatus.READY
|
|
||||||
|
|
||||||
visible, ready = 0, 0
|
visible, ready = 0, 0
|
||||||
|
|
||||||
@@ -219,39 +214,36 @@ class AppsTable(QTableWidget):
|
|||||||
col_branch.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
col_branch.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||||
self.setItem(idx, 3, col_branch)
|
self.setItem(idx, 3, col_branch)
|
||||||
|
|
||||||
col_arch = QTableWidgetItem()
|
|
||||||
col_arch.setText(app_v.model.arch if isinstance(app_v.model, FlatpakApplication) else '')
|
|
||||||
col_arch.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
|
||||||
self.setItem(idx, 4, col_arch)
|
|
||||||
|
|
||||||
desc = app_v.get_async_attr('description', strip_html=True)
|
|
||||||
col_description = QTableWidgetItem()
|
col_description = QTableWidgetItem()
|
||||||
col_description.setText(desc)
|
|
||||||
col_description.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
col_description.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||||
|
self._set_col_description(col_description, app_v)
|
||||||
|
|
||||||
if app_v.model.status == ApplicationStatus.READY:
|
self.setItem(idx, 4, col_description)
|
||||||
col_description.setToolTip(desc)
|
|
||||||
|
|
||||||
self.setItem(idx, 5, col_description)
|
|
||||||
|
|
||||||
col_origin = QTableWidgetItem()
|
col_origin = QTableWidgetItem()
|
||||||
col_origin.setText(app_v.model.origin if isinstance(app_v.model, FlatpakApplication) else '')
|
col_origin.setText(app_v.model.origin if isinstance(app_v.model, FlatpakApplication) else '')
|
||||||
col_origin.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
col_origin.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||||
self.setItem(idx, 6, col_origin)
|
self.setItem(idx, 5, col_origin)
|
||||||
|
|
||||||
col_installed = QLabel()
|
col_installed = QLabel()
|
||||||
col_installed.setPixmap((QPixmap(resource.get_path('img/{}.svg'.format('checked' if app_v.model.installed else 'red_cross')))))
|
col_installed.setPixmap((QPixmap(resource.get_path('img/{}.svg'.format('checked' if app_v.model.installed else 'red_cross')))))
|
||||||
col_installed.setAlignment(Qt.AlignCenter)
|
col_installed.setAlignment(Qt.AlignCenter)
|
||||||
|
|
||||||
self.setCellWidget(idx, 7, col_installed)
|
self.setCellWidget(idx, 6, col_installed)
|
||||||
|
|
||||||
col_update = UpdateToggleButton(app_v, self.window, self.window.locale_keys, app_v.model.update) if app_v.model.update else None
|
col_update = UpdateToggleButton(app_v, self.window, self.window.locale_keys, app_v.model.update) if app_v.model.update else None
|
||||||
self.setCellWidget(idx, 8, col_update)
|
self.setCellWidget(idx, 7, col_update)
|
||||||
|
|
||||||
|
def _set_col_description(self, col: QTableWidgetItem, app_v: ApplicationView):
|
||||||
|
desc = app_v.get_async_attr('description', strip_html=True)
|
||||||
|
|
||||||
|
if desc:
|
||||||
|
col.setText(desc[0:25] + '...')
|
||||||
|
|
||||||
|
if app_v.model.status == ApplicationStatus.READY:
|
||||||
|
col.setToolTip(desc)
|
||||||
|
|
||||||
def change_headers_policy(self, policy: QHeaderView = QHeaderView.ResizeToContents):
|
def change_headers_policy(self, policy: QHeaderView = QHeaderView.ResizeToContents):
|
||||||
header_horizontal = self.horizontalHeader()
|
header_horizontal = self.horizontalHeader()
|
||||||
for i in range(self.columnCount()):
|
for i in range(self.columnCount()):
|
||||||
if i == 5:
|
|
||||||
header_horizontal.setSectionResizeMode(i, QHeaderView.Stretch)
|
|
||||||
else:
|
|
||||||
header_horizontal.setSectionResizeMode(i, policy)
|
header_horizontal.setSectionResizeMode(i, policy)
|
||||||
|
|||||||
10
fpakman/view/qt/common.py
Normal file
10
fpakman/view/qt/common.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from fpakman.core import flatpak
|
||||||
|
from fpakman.view.qt import dialog
|
||||||
|
|
||||||
|
|
||||||
|
def check_flatpak_installed(locale_keys: dict):
|
||||||
|
|
||||||
|
if not flatpak.is_installed():
|
||||||
|
dialog.show_error(title=locale_keys['popup.flatpak_not_installed.title'],
|
||||||
|
body=locale_keys['popup.flatpak_not_installed.msg'] + '...')
|
||||||
|
exit(1)
|
||||||
@@ -12,7 +12,7 @@ from fpakman.core import resource, flatpak
|
|||||||
from fpakman.core.controller import FlatpakManager
|
from fpakman.core.controller import FlatpakManager
|
||||||
from fpakman.core.model import Application, FlatpakApplication
|
from fpakman.core.model import Application, FlatpakApplication
|
||||||
from fpakman.util.cache import Cache
|
from fpakman.util.cache import Cache
|
||||||
from fpakman.view.qt import dialog
|
from fpakman.view.qt import dialog, common
|
||||||
from fpakman.view.qt.apps_table import AppsTable
|
from fpakman.view.qt.apps_table import AppsTable
|
||||||
from fpakman.view.qt.history import HistoryDialog
|
from fpakman.view.qt.history import HistoryDialog
|
||||||
from fpakman.view.qt.info import InfoDialog
|
from fpakman.view.qt.info import InfoDialog
|
||||||
@@ -205,11 +205,7 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
def _check_flatpak_installed(self):
|
def _check_flatpak_installed(self):
|
||||||
|
|
||||||
if not flatpak.is_installed():
|
common.check_flatpak_installed(self.locale_keys)
|
||||||
dialog.show_error(title=self.locale_keys['popup.flatpak_not_installed.title'],
|
|
||||||
body=self.locale_keys['popup.flatpak_not_installed.msg'] + '...',
|
|
||||||
icon=self.icon_flathub)
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if self.label_flatpak:
|
if self.label_flatpak:
|
||||||
self.label_flatpak.setText(self._get_flatpak_label())
|
self.label_flatpak.setText(self._get_flatpak_label())
|
||||||
|
|||||||
Reference in New Issue
Block a user