diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 98a4b17f3..af94de5f5 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -23,7 +23,7 @@ class MainWindow(QMainWindow): self.status = StatusBar(self.cwidget) self.vbox.addWidget(self.status) - self.tabs.cur_progress.connect(self.status.lbl.set_progress) + self.tabs.cur_progress.connect(self.status.prog.set_progress) #self.retranslateUi(MainWindow) #self.tabWidget.setCurrentIndex(0) diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index 1463014d3..9fc783c07 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -1,4 +1,4 @@ -from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget, QShortcut +from PyQt5.QtWidgets import QLineEdit, QHBoxLayout, QLabel, QWidget, QShortcut, QProgressBar, QSizePolicy from PyQt5.QtCore import pyqtSignal, Qt from PyQt5.QtGui import QValidator, QKeySequence @@ -18,6 +18,9 @@ class StatusBar(QWidget): self.lbl = StatusText(self) self.hbox.addWidget(self.lbl) + self.prog = StatusProgress(self) + self.hbox.addWidget(self.prog) + def bg_color(self, fg, bg): self.setStyleSheet(""" * { @@ -30,15 +33,35 @@ class StatusBar(QWidget): self.bg_color('white', 'red') self.lbl.setText('Error: {}'.format(text)) +class StatusProgress(QProgressBar): + def __init__(self, parent): + super().__init__(parent) + self.setObjectName(self.__class__.__name__) + + #self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) + #self.setStyleSheet("padding-right: 1px") + self.hide() + + # FIXME this size foo doesn't work right. + # Maybe here we should just reimplement the drawing part. + + def minimumSizeHint(self): + status_size = parent.size() + return QSize(20, status_size.height()) + + def sizeHint(self): + return minimumSizeHint() + + def set_progress(self, prog): + self.show() + self.setValue(prog) + class StatusText(QLabel): def __init__(self, parent): super().__init__(parent) self.setObjectName(self.__class__.__name__) self.setStyleSheet("padding-right: 1px") - def set_progress(self, prog): - self.setText('{}%'.format(prog)) - class StatusCommand(QLineEdit): got_cmd = pyqtSignal(str)