mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 15:34:15 +02:00
progress bar
This commit is contained in:
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Minor GUI improvements
|
- Minor GUI improvements
|
||||||
- Notifying only new updates
|
- Notifying only new updates
|
||||||
- New icon
|
- New icon
|
||||||
|
- Progress bar
|
||||||
|
|
||||||
## [0.2.1] - 2019-06-24
|
## [0.2.1] - 2019-06-24
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class TrayIcon(QSystemTrayIcon):
|
|||||||
self.check_thread.signal.connect(self.notify_updates)
|
self.check_thread.signal.connect(self.notify_updates)
|
||||||
self.check_thread.start()
|
self.check_thread.start()
|
||||||
|
|
||||||
self.dialog_about = AboutDialog(self.locale_keys)
|
self.dialog_about = None
|
||||||
|
|
||||||
self.thread_database = LoadDatabase(manager)
|
self.thread_database = LoadDatabase(manager)
|
||||||
self.thread_database.signal_finished.connect(self._update_menu)
|
self.thread_database.signal_finished.connect(self._update_menu)
|
||||||
@@ -126,5 +126,8 @@ class TrayIcon(QSystemTrayIcon):
|
|||||||
|
|
||||||
def show_about(self):
|
def show_about(self):
|
||||||
|
|
||||||
|
if self.dialog_about is None:
|
||||||
|
self.dialog_about = AboutDialog(self.locale_keys)
|
||||||
|
|
||||||
if self.dialog_about.isHidden():
|
if self.dialog_about.isHidden():
|
||||||
self.dialog_about.show()
|
self.dialog_about.show()
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
from PyQt5.QtCore import QThread, pyqtSignal
|
from PyQt5.QtCore import QThread, pyqtSignal
|
||||||
|
|
||||||
from fpakman.core import flatpak
|
from fpakman.core import flatpak
|
||||||
@@ -153,3 +155,30 @@ class InstallApp(QThread):
|
|||||||
|
|
||||||
self.app = None
|
self.app = None
|
||||||
self.signal_finished.emit()
|
self.signal_finished.emit()
|
||||||
|
|
||||||
|
|
||||||
|
class AnimateProgress(QThread):
|
||||||
|
|
||||||
|
signal_change = pyqtSignal(int)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(AnimateProgress, self).__init__()
|
||||||
|
self.last_value = 0
|
||||||
|
self.increment = 5
|
||||||
|
self.stop = False
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
|
||||||
|
current_increment = self.increment
|
||||||
|
|
||||||
|
while not self.stop:
|
||||||
|
self.signal_change.emit(self.last_value)
|
||||||
|
|
||||||
|
if self.last_value == 100:
|
||||||
|
current_increment = -current_increment
|
||||||
|
if self.last_value == 0:
|
||||||
|
current_increment = self.increment
|
||||||
|
|
||||||
|
self.last_value += current_increment
|
||||||
|
|
||||||
|
time.sleep(0.05)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from typing import List
|
|||||||
from PyQt5.QtCore import QEvent
|
from PyQt5.QtCore import QEvent
|
||||||
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QPixmap
|
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QPixmap
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QCheckBox, QHeaderView, QToolButton, QToolBar, \
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QCheckBox, QHeaderView, QToolButton, QToolBar, \
|
||||||
QSizePolicy, QLabel, QPlainTextEdit, QLineEdit
|
QSizePolicy, QLabel, QPlainTextEdit, QLineEdit, QProgressBar
|
||||||
|
|
||||||
from fpakman.core import resource, flatpak
|
from fpakman.core import resource, flatpak
|
||||||
from fpakman.core.controller import FlatpakManager
|
from fpakman.core.controller import FlatpakManager
|
||||||
@@ -16,7 +16,7 @@ from fpakman.view.qt.history import HistoryDialog
|
|||||||
from fpakman.view.qt.info import InfoDialog
|
from fpakman.view.qt.info import InfoDialog
|
||||||
from fpakman.view.qt.root import is_root, ask_root_password
|
from fpakman.view.qt.root import is_root, ask_root_password
|
||||||
from fpakman.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \
|
from fpakman.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \
|
||||||
GetAppHistory, SearchApps, InstallApp
|
GetAppHistory, SearchApps, InstallApp, AnimateProgress
|
||||||
|
|
||||||
|
|
||||||
class ManageWindow(QWidget):
|
class ManageWindow(QWidget):
|
||||||
@@ -149,16 +149,29 @@ class ManageWindow(QWidget):
|
|||||||
self.thread_install.signal_output.connect(self._update_action_output)
|
self.thread_install.signal_output.connect(self._update_action_output)
|
||||||
self.thread_install.signal_finished.connect(self._finish_install)
|
self.thread_install.signal_finished.connect(self._finish_install)
|
||||||
|
|
||||||
|
self.thread_animate_progress = AnimateProgress()
|
||||||
|
self.thread_animate_progress.signal_change.connect(self._update_progress)
|
||||||
|
|
||||||
self.toolbar_bottom = QToolBar()
|
self.toolbar_bottom = QToolBar()
|
||||||
self.label_updates = QLabel('')
|
self.label_updates = QLabel('')
|
||||||
self.label_updates.setStyleSheet("color: #FF4500; font-weight: bold")
|
self.label_updates.setStyleSheet("color: #FF4500; font-weight: bold")
|
||||||
self.toolbar_bottom.addWidget(self.label_updates)
|
self.toolbar_bottom.addWidget(self.label_updates)
|
||||||
|
|
||||||
|
spacer = QWidget()
|
||||||
|
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
|
self.toolbar_bottom.addWidget(spacer)
|
||||||
|
|
||||||
|
self.progress_bar = QProgressBar()
|
||||||
|
self.progress_bar.setTextVisible(False)
|
||||||
|
self.ref_progress_bar = self.toolbar_bottom.addWidget(self.progress_bar)
|
||||||
|
|
||||||
spacer = QWidget()
|
spacer = QWidget()
|
||||||
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||||
self.toolbar_bottom.addWidget(spacer)
|
self.toolbar_bottom.addWidget(spacer)
|
||||||
|
|
||||||
self.label_flatpak = QLabel(self._get_flatpak_label())
|
self.label_flatpak = QLabel(self._get_flatpak_label())
|
||||||
self.toolbar_bottom.addWidget(self.label_flatpak)
|
self.toolbar_bottom.addWidget(self.label_flatpak)
|
||||||
|
|
||||||
self.layout.addWidget(self.toolbar_bottom)
|
self.layout.addWidget(self.toolbar_bottom)
|
||||||
|
|
||||||
self.centralize()
|
self.centralize()
|
||||||
@@ -363,6 +376,10 @@ class ManageWindow(QWidget):
|
|||||||
self.textarea_output.appendPlainText(output)
|
self.textarea_output.appendPlainText(output)
|
||||||
|
|
||||||
def _begin_action(self, action_label: str):
|
def _begin_action(self, action_label: str):
|
||||||
|
self.thread_animate_progress.stop = False
|
||||||
|
self.thread_animate_progress.start()
|
||||||
|
self.ref_progress_bar.setVisible(True)
|
||||||
|
self.progress_bar.setValue(50)
|
||||||
self.label_status.setText(action_label + "...")
|
self.label_status.setText(action_label + "...")
|
||||||
self.toolbar_search.setVisible(False)
|
self.toolbar_search.setVisible(False)
|
||||||
self.bt_upgrade.setEnabled(False)
|
self.bt_upgrade.setEnabled(False)
|
||||||
@@ -371,6 +388,10 @@ class ManageWindow(QWidget):
|
|||||||
self.table_apps.setEnabled(False)
|
self.table_apps.setEnabled(False)
|
||||||
|
|
||||||
def finish_action(self, clear_search: bool = True):
|
def finish_action(self, clear_search: bool = True):
|
||||||
|
self.thread_animate_progress.stop = True
|
||||||
|
self.ref_progress_bar.setVisible(False)
|
||||||
|
self.progress_bar.setValue(0)
|
||||||
|
self.progress_bar.setVisible(False)
|
||||||
self.bt_refresh.setEnabled(True)
|
self.bt_refresh.setEnabled(True)
|
||||||
self.toolbar_search.setVisible(True)
|
self.toolbar_search.setVisible(True)
|
||||||
self.checkbox_only_apps.setEnabled(True)
|
self.checkbox_only_apps.setEnabled(True)
|
||||||
@@ -470,3 +491,6 @@ class ManageWindow(QWidget):
|
|||||||
self.finish_action()
|
self.finish_action()
|
||||||
self._release_lock()
|
self._release_lock()
|
||||||
self.refresh(clear_output=False)
|
self.refresh(clear_output=False)
|
||||||
|
|
||||||
|
def _update_progress(self, value: int):
|
||||||
|
self.progress_bar.setValue(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user