use signals to trigger rendering update

This commit is contained in:
2022-02-20 08:51:32 +01:00
parent 916eac5134
commit e24954889d

View File

@@ -39,7 +39,7 @@ class FileObserver(FileSystemEventHandler):
# block the UI thread and make the UI unresponsive. # block the UI thread and make the UI unresponsive.
# Note: we don't miss events, because they are queued and de-duplicated # Note: we don't miss events, because they are queued and de-duplicated
time.sleep(0.5) time.sleep(0.5)
self.big_text.update() self.big_text.trigger_update.emit()
class FileWatchdogThread(QRunnable): class FileWatchdogThread(QRunnable):
@@ -60,6 +60,7 @@ class FileWatchdogThread(QRunnable):
class BigText(QWidget): class BigText(QWidget):
trigger_update = Signal()
def __init__(self, model: LogFileModel): def __init__(self, model: LogFileModel):
super(BigText, self).__init__() super(BigText, self).__init__()
@@ -68,6 +69,7 @@ class BigText(QWidget):
self.watchdog = FileWatchdogThread(self, model.get_file()) self.watchdog = FileWatchdogThread(self, model.get_file())
QThreadPool.globalInstance().start(self.watchdog) QThreadPool.globalInstance().start(self.watchdog)
self.trigger_update.connect(self.update)
self.grid = QGridLayout() self.grid = QGridLayout()
self.grid.setContentsMargins(0, 0, 0, 0) self.grid.setContentsMargins(0, 0, 0, 0)
@@ -371,7 +373,7 @@ class InnerBigText(QWidget):
self.update() self.update()
def paintEvent(self, event: QPaintEvent) -> None: def paintEvent(self, event: QPaintEvent) -> None:
# print("paintEvent") # print("paintEvent %s" % (self.model.get_file()))
painter = QPainter(self) painter = QPainter(self)
# painter.setFont(self.model.settings.font()) # painter.setFont(self.model.settings.font())
# Courier New, DejaVu Sans Mono, Monospace, Liberation Mono, Noto Mono, Nimbus Mono L, Tlwg Mono, Ubuntu Mono, FreeMono, Mitra Mono # Courier New, DejaVu Sans Mono, Monospace, Liberation Mono, Noto Mono, Nimbus Mono L, Tlwg Mono, Ubuntu Mono, FreeMono, Mitra Mono
@@ -380,8 +382,6 @@ class InnerBigText(QWidget):
painter.setPen(QColor(0, 0, 0)) painter.setPen(QColor(0, 0, 0))
self.update_font_metrics(painter) self.update_font_metrics(painter)
tab_string = " " * constants.tab_width
lines_to_show = self.lines_shown() lines_to_show = self.lines_shown()
# print("%s / %s = %s" %(self.height(), float(self.char_height), lines_to_show)) # print("%s / %s = %s" %(self.height(), float(self.char_height), lines_to_show))