show file size and name in status bar
This commit is contained in:
@@ -4,7 +4,7 @@ import threading
|
||||
import time
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt6.QtGui import QBrush, QColor, QPen
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
|
||||
from highlight_regex import HighlightRegex
|
||||
from highlighting import Highlighting
|
||||
@@ -16,6 +16,12 @@ from settings import Settings
|
||||
class LogFileModel:
|
||||
_query_highlight: Optional[HighlightRegex] = None
|
||||
|
||||
file_size_changed = pyqtSignal(str)
|
||||
"""Fires when the file size changed. **Note:** uses strings,
|
||||
because int in Qt signal are limited to 32bit."""
|
||||
|
||||
_file_size = -1
|
||||
|
||||
def __init__(self, file: str, settings: Settings):
|
||||
self.settings = settings
|
||||
self._file = os.path.realpath(file)
|
||||
@@ -117,7 +123,11 @@ class LogFileModel:
|
||||
return result
|
||||
|
||||
def byte_count(self) -> int:
|
||||
return os.stat(self._file).st_size
|
||||
size = os.stat(self._file).st_size
|
||||
if self._file_size != size:
|
||||
# self.file_size_changed.emit(str(size))
|
||||
self._file_size = size
|
||||
return size
|
||||
|
||||
def write_line(self, line: str):
|
||||
with open(self._file, 'a+b') as f:
|
||||
|
||||
Reference in New Issue
Block a user