Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements #27

Merged
merged 6 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ indent-width = 4

[tool.ruff.lint]
select = ["E", "F", "W", "N", "D", "Q", "PL", "R", "C", "B", "C4", "G", "PT", "RET", "RUF", "SIM", "UP"]
ignore = ["D212", "D203", "D400", "RET505", "D100", "PLR0915", "RET504", "PLE1205", "UP015", "PLC2401", "PLR0913"]
ignore = ["D212", "D203", "D400", "RET505", "D100", "PLR0915", "RET504", "PLE1205", "UP015", "PLC2401", "PLR0913", "PT001"]

[tool.ruff.format]
quote-style = "double"
Expand Down
28 changes: 16 additions & 12 deletions typstwriter/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ def load(self, path):
self.isloaded = True
self.changed_on_disk = False

self.filesystemwatcher.removePaths(self.filesystemwatcher.files())
if self.filesystemwatcher.files():
self.filesystemwatcher.removePaths(self.filesystemwatcher.files())
self.filesystemwatcher.addPath(path)

self.savestatechanged.emit(self.issaved)
Expand All @@ -407,7 +408,7 @@ def load(self, path):

def write(self):
"""Write file to disk."""
logger.info("Saving to: {!r}.", self.path)
logger.debug("Saving to: {!r}.", self.path)

try:
with open(self.path, "w") as f:
Expand Down Expand Up @@ -514,24 +515,26 @@ def show_error(self, msg):
"""Show an error page."""
self.edit.deleteLater()

self.gridLayout = QtWidgets.QGridLayout()
self.HLayout = QtWidgets.QHBoxLayout()
self.verticalLayout.addLayout(self.HLayout)

self.label_w = QtWidgets.QLabel()
if QtGui.QIcon.hasThemeIcon("data-warning"):
self.label_w.setPixmap(QtGui.QIcon.fromTheme("data-warning").pixmap(64))
else:
self.label_w.setPixmap(QtGui.QPixmap(util.icon_path("warning.svg")))
self.label_t = QtWidgets.QLabel("<h1>" + msg + "</h1>")

self.gridLayout.addWidget(self.label_w, 0, 1)
self.gridLayout.addWidget(self.label_t, 0, 2)

self.gridLayout.setColumnStretch(0, 1)
self.gridLayout.setColumnStretch(1, 0)
self.gridLayout.setColumnStretch(2, 0)
self.gridLayout.setColumnStretch(3, 1)
self.label_t = QtWidgets.QLabel(msg)
font = self.label_t.font()
font.setPointSize(font.pointSize() * 2)
font.setBold(True)
self.label_t.setFont(font)
self.label_t.setWordWrap(True)

self.verticalLayout.addLayout(self.gridLayout)
self.HLayout.addStretch()
self.HLayout.addWidget(self.label_w, alignment=QtCore.Qt.AlignmentFlag.AlignRight)
self.HLayout.addWidget(self.label_t, alignment=QtCore.Qt.AlignmentFlag.AlignLeft)
self.HLayout.addStretch()


class FileChangedWarning(QtWidgets.QFrame):
Expand All @@ -555,6 +558,7 @@ def __init__(self, path):

self.label_text = QtWidgets.QLabel()
self.label_text.setText(f"The file '{path!r}' has been changed on disk.")
self.label_text.setWordWrap(True)
self.horizontalLayout.addWidget(self.label_text)

icon = QtGui.QIcon.fromTheme(QtGui.QIcon.ViewRefresh, QtGui.QIcon(util.icon_path("reload.svg")))
Expand Down
Binary file removed typstwriter/icons/typstwriter.png
Binary file not shown.
Loading