mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[screenshots] progress bar
This commit is contained in:
@@ -21,6 +21,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- not waiting for the categories file to be retrieved from the cloud during application boot ( reduces boot time )
|
- not waiting for the categories file to be retrieved from the cloud during application boot ( reduces boot time )
|
||||||
- caching cloud categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off )
|
- caching cloud categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off )
|
||||||
- minor thread improvements
|
- minor thread improvements
|
||||||
|
|
||||||
|
### UI
|
||||||
|
- Screenshots panel:
|
||||||
|
- "downloading" label replaced by a progress bar
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- application not initializing when there is no internet connection
|
- application not initializing when there is no internet connection
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
@@ -279,11 +280,17 @@ class FlatpakManager(SoftwareManager):
|
|||||||
flatpak.run(str(pkg.id))
|
flatpak.run(str(pkg.id))
|
||||||
|
|
||||||
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
||||||
res = self.http_client.get_json('{}/apps/{}'.format(FLATHUB_API_URL, pkg.id))
|
screenshots_url = '{}/apps/{}'.format(FLATHUB_API_URL, pkg.id)
|
||||||
urls = []
|
urls = []
|
||||||
if res and res.get('screenshots'):
|
try:
|
||||||
for s in res['screenshots']:
|
res = self.http_client.get_json(screenshots_url)
|
||||||
if s.get('imgDesktopUrl'):
|
|
||||||
urls.append(s['imgDesktopUrl'])
|
if res and res.get('screenshots'):
|
||||||
|
for s in res['screenshots']:
|
||||||
|
if s.get('imgDesktopUrl'):
|
||||||
|
urls.append(s['imgDesktopUrl'])
|
||||||
|
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
self.context.logger.error("Could not decode json from '{}'".format(screenshots_url))
|
||||||
|
|
||||||
return urls
|
return urls
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ from typing import List
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QIcon, QPixmap
|
from PyQt5.QtGui import QIcon, QPixmap
|
||||||
from PyQt5.QtWidgets import QDialog, QLabel, QPushButton, QToolBar, QVBoxLayout
|
from PyQt5.QtWidgets import QDialog, QLabel, QPushButton, QToolBar, QVBoxLayout, QProgressBar, QApplication
|
||||||
|
|
||||||
from bauh.api.abstract.cache import MemoryCache
|
from bauh.api.abstract.cache import MemoryCache
|
||||||
from bauh.api.http import HttpClient
|
from bauh.api.http import HttpClient
|
||||||
from bauh.view.qt import qt_utils
|
from bauh.view.qt import qt_utils
|
||||||
from bauh.view.qt.components import new_spacer
|
from bauh.view.qt.components import new_spacer
|
||||||
|
from bauh.view.qt.thread import AnimateProgress
|
||||||
from bauh.view.qt.view_model import PackageView
|
from bauh.view.qt.view_model import PackageView
|
||||||
|
|
||||||
|
|
||||||
@@ -28,6 +29,12 @@ class ScreenshotsDialog(QDialog):
|
|||||||
self.resize(1280, 720)
|
self.resize(1280, 720)
|
||||||
self.i18n = i18n
|
self.i18n = i18n
|
||||||
self.http_client = http_client
|
self.http_client = http_client
|
||||||
|
self.progress_bar = QProgressBar()
|
||||||
|
self.progress_bar.setMaximumHeight(10 if QApplication.instance().style().objectName().lower() == 'windows' else 6)
|
||||||
|
self.progress_bar.setTextVisible(False)
|
||||||
|
self.thread_progress = AnimateProgress()
|
||||||
|
self.thread_progress.signal_change.connect(self._update_progress)
|
||||||
|
self.thread_progress.start()
|
||||||
|
|
||||||
# THERE ARE CRASHES WITH SOME RARE ICONS ( like insomnia ). IT CAN BE A QT BUG. IN THE MEANTIME, ONLY THE TYPE ICON WILL BE RENDERED
|
# THERE ARE CRASHES WITH SOME RARE ICONS ( like insomnia ). IT CAN BE A QT BUG. IN THE MEANTIME, ONLY THE TYPE ICON WILL BE RENDERED
|
||||||
#
|
#
|
||||||
@@ -52,7 +59,9 @@ class ScreenshotsDialog(QDialog):
|
|||||||
|
|
||||||
self.img_label = QLabel()
|
self.img_label = QLabel()
|
||||||
self.img_label.setStyleSheet('QLabel { font-weight: bold; text-align: center }')
|
self.img_label.setStyleSheet('QLabel { font-weight: bold; text-align: center }')
|
||||||
self.bottom_bar.addWidget(self.img_label)
|
self.ref_img_label = self.bottom_bar.addWidget(self.img_label)
|
||||||
|
self.ref_img_label.setVisible(False)
|
||||||
|
self.ref_progress_bar = self.bottom_bar.addWidget(self.progress_bar)
|
||||||
self.bottom_bar.addWidget(new_spacer(50))
|
self.bottom_bar.addWidget(new_spacer(50))
|
||||||
|
|
||||||
self.bt_next = QPushButton(self.i18n['screenshots.bt_next.label'].capitalize())
|
self.bt_next = QPushButton(self.i18n['screenshots.bt_next.label'].capitalize())
|
||||||
@@ -69,6 +78,9 @@ class ScreenshotsDialog(QDialog):
|
|||||||
|
|
||||||
self._load_img()
|
self._load_img()
|
||||||
|
|
||||||
|
def _update_progress(self, val: int):
|
||||||
|
self.progress_bar.setValue(val)
|
||||||
|
|
||||||
def _load_img(self):
|
def _load_img(self):
|
||||||
if len(self.loaded_imgs) > self.img_idx:
|
if len(self.loaded_imgs) > self.img_idx:
|
||||||
img = self.loaded_imgs[self.img_idx]
|
img = self.loaded_imgs[self.img_idx]
|
||||||
@@ -79,9 +91,15 @@ class ScreenshotsDialog(QDialog):
|
|||||||
else:
|
else:
|
||||||
self.img_label.setText(img)
|
self.img_label.setText(img)
|
||||||
self.img.setPixmap(QPixmap())
|
self.img.setPixmap(QPixmap())
|
||||||
|
|
||||||
|
self.thread_progress.stop = True
|
||||||
|
self.ref_progress_bar.setVisible(False)
|
||||||
|
self.ref_img_label.setVisible(True)
|
||||||
else:
|
else:
|
||||||
self.img.setPixmap(QPixmap())
|
self.img.setPixmap(QPixmap())
|
||||||
self.img_label.setText('...{}...'.format(self.i18n['screenshots,download.running']))
|
self.ref_img_label.setVisible(False)
|
||||||
|
self.ref_progress_bar.setVisible(True)
|
||||||
|
self.thread_progress.start()
|
||||||
|
|
||||||
if len(self.screenshots) == 1:
|
if len(self.screenshots) == 1:
|
||||||
self.ref_bt_back.setVisible(False)
|
self.ref_bt_back.setVisible(False)
|
||||||
|
|||||||
Reference in New Issue
Block a user