somewhat working state
This commit is contained in:
@@ -71,8 +71,8 @@ class MainWindow(QMainWindow):
|
|||||||
super(MainWindow, self).__init__(*args, **kwargs)
|
super(MainWindow, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.setWindowTitle(_("KrowLog"))
|
self.setWindowTitle(_("KrowLog"))
|
||||||
self.setMinimumWidth(600)
|
self.setMinimumWidth(800)
|
||||||
self.setMinimumHeight(480)
|
self.setMinimumHeight(880)
|
||||||
bigger_text = BiggerText()
|
bigger_text = BiggerText()
|
||||||
self.setCentralWidget(bigger_text)
|
self.setCentralWidget(bigger_text)
|
||||||
self.status_bar = QStatusBar(self)
|
self.status_bar = QStatusBar(self)
|
||||||
@@ -236,7 +236,7 @@ class BiggerText(QWidget):
|
|||||||
# font = "JetBrains Mono"
|
# font = "JetBrains Mono"
|
||||||
# font = "Monospace" # not found
|
# font = "Monospace" # not found
|
||||||
# font = "ZedMono" # is not found
|
# font = "ZedMono" # is not found
|
||||||
# font = "Noto Sans Mono"
|
#font = "Noto Sans Mono"
|
||||||
font = "Noto Color Emoji"
|
font = "Noto Color Emoji"
|
||||||
font_size = 20
|
font_size = 20
|
||||||
|
|
||||||
@@ -316,6 +316,8 @@ class BiggerText(QWidget):
|
|||||||
painter.drawLine(QLine(273, 0, 273, self.height()))
|
painter.drawLine(QLine(273, 0, 273, self.height()))
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
|
# ----
|
||||||
|
|
||||||
self.font_metric: QFontMetrics = painter.fontMetrics()
|
self.font_metric: QFontMetrics = painter.fontMetrics()
|
||||||
self.char_height = self.font_metric.height()
|
self.char_height = self.font_metric.height()
|
||||||
lines_to_read = self.height() / self.char_height + 1
|
lines_to_read = self.height() / self.char_height + 1
|
||||||
@@ -323,8 +325,27 @@ class BiggerText(QWidget):
|
|||||||
self.lines_to_render: [Line] = self.file_model.read(0, lines_to_read, 200, self._encoding)
|
self.lines_to_render: [Line] = self.file_model.read(0, lines_to_read, 200, self._encoding)
|
||||||
|
|
||||||
painter.setPen(QColor(0, 0, 0))
|
painter.setPen(QColor(0, 0, 0))
|
||||||
line_on_screen = 1
|
line_on_screen = 0
|
||||||
|
|
||||||
|
for line in self.lines_to_render:
|
||||||
|
text = line.text()
|
||||||
|
text = text.replace("\n", "").replace("\r", "")
|
||||||
|
r = self.font_metric.boundingRect(text[0:1])
|
||||||
|
|
||||||
|
w = self.font_metric.horizontalAdvanceChar('…')
|
||||||
|
|
||||||
|
xpos = r.x() + r.width() + w + 1
|
||||||
|
|
||||||
|
elidet_text = self.font_metric.elidedText(text, Qt.TextElideMode.ElideRight, xpos)
|
||||||
|
|
||||||
|
print(f"-> {elidet_text} -- {text}")
|
||||||
|
|
||||||
|
y = int(line_on_screen * self.char_height)
|
||||||
|
painter.setBrush(QBrush(QColor(233, 233, 233)))
|
||||||
|
painter.drawRect(QRect(0, y, r.x() + r.width(), self.char_height))
|
||||||
|
line_on_screen = line_on_screen + 1
|
||||||
|
|
||||||
|
line_on_screen = 1
|
||||||
for line in self.lines_to_render:
|
for line in self.lines_to_render:
|
||||||
x_start = -1
|
x_start = -1
|
||||||
x_end = -1
|
x_end = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user