Compare commits

..

3 Commits

Author SHA1 Message Date
233eed1ca7 fix: set desktop file name before QApplication init to resolve QDBusError
All checks were successful
Build Linux / Build Linux (push) Successful in 1m28s
Build Windows / Build Windows (push) Successful in 2m58s
2026-01-23 21:33:05 +01:00
4c3d860dc4 ui: replace file closed dialog with status bar message 2026-01-23 21:31:30 +01:00
670a2d9f8c ui: move graphics and color controls to right sidebar 2026-01-23 21:29:16 +01:00
2 changed files with 45 additions and 30 deletions

View File

@@ -23,10 +23,10 @@ def main():
myappid = 'ddybing.teletexteditor.1.0' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
QApplication.setDesktopFileName("no.ddybing.TeletextEditor") # Helps Linux DEs group windows
app = QApplication(sys.argv)
app.setApplicationName("TeletextEditor")
app.setOrganizationName("DanielDybing")
app.setDesktopFileName("no.ddybing.TeletextEditor") # Helps Linux DEs group windows
# Debug Image Formats
supported_formats = [str(fmt, 'utf-8') for fmt in QImageReader.supportedImageFormats()]

View File

@@ -6,7 +6,7 @@ from PyQt6.QtWidgets import (
QCheckBox, QDialog, QGridLayout
)
from PyQt6.QtGui import QAction, QKeyEvent, QPainter, QBrush, QColor
from PyQt6.QtCore import Qt, QRect
from PyQt6.QtCore import Qt, QRect, QTimer
from .io import load_t42, save_t42
from .renderer import TeletextCanvas, create_blank_packet
@@ -183,13 +183,30 @@ class MainWindow(QMainWindow):
center_layout.addLayout(top_bar)
# Color Shortcuts
color_layout = QHBoxLayout()
# Middle Layout (Canvas + Right Sidebar)
middle_layout = QHBoxLayout()
center_layout.addLayout(middle_layout, 1)
# Canvas
self.canvas = TeletextCanvas()
self.canvas.cursorChanged.connect(self.on_cursor_changed)
middle_layout.addWidget(self.canvas, 1) # Expand
# Right Sidebar
right_sidebar = QWidget()
right_sidebar.setFixedWidth(160)
right_layout = QVBoxLayout(right_sidebar)
right_layout.setContentsMargins(5, 0, 0, 0)
middle_layout.addWidget(right_sidebar)
# Color Shortcuts
# Graphics Mode Toggle
self.chk_graphics = QCheckBox("Graphics")
self.chk_graphics.setToolTip("If checked, inserts Graphics Color codes (e.g. Red Graphics 0x11) instead of Alpha (0x01)")
color_layout.addWidget(self.chk_graphics)
right_layout.addWidget(self.chk_graphics)
colors_grid = QGridLayout()
colors_grid.setSpacing(5)
colors = [
("Black", 0x00, "#000000"),
@@ -202,9 +219,10 @@ class MainWindow(QMainWindow):
("White", 0x07, "#FFFFFF"),
]
row, col = 0, 0
for name, code, hex_color in colors:
btn = QPushButton(name)
btn.setFixedSize(60, 30) # Fixed size for uniformity
btn.setFixedSize(60, 30)
# Common style
style = f"background-color: {hex_color}; font-weight: bold; border: 1px solid #555; border-radius: 3px;"
@@ -220,20 +238,25 @@ class MainWindow(QMainWindow):
# Use separate method to handle graphics check
btn.clicked.connect(lambda checked, c=code: self.insert_color(c))
color_layout.addWidget(btn)
colors_grid.addWidget(btn, row, col)
col += 1
if col > 1:
col = 0
row += 1
right_layout.addLayout(colors_grid)
# Mosaics Button
btn_mosaic = QPushButton("Mosaics...")
btn_mosaic.clicked.connect(self.open_mosaic_dialog)
color_layout.addWidget(btn_mosaic)
right_layout.addWidget(btn_mosaic)
color_layout.addStretch()
center_layout.addLayout(color_layout)
right_layout.addSpacing(10)
# Background Controls
bg_layout = QHBoxLayout()
bg_label = QLabel("Background:")
bg_layout.addWidget(bg_label)
right_layout.addWidget(bg_label)
# New Background (0x1D)
btn_new_bg = QPushButton("New BG")
@@ -241,7 +264,7 @@ class MainWindow(QMainWindow):
btn_new_bg.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
btn_new_bg.setToolTip("Sets the current foreground color as the new background color (0x1D)")
btn_new_bg.clicked.connect(lambda: self.insert_char(0x1D))
bg_layout.addWidget(btn_new_bg)
right_layout.addWidget(btn_new_bg)
# Black Background (0x1C)
btn_black_bg = QPushButton("Black BG")
@@ -249,15 +272,13 @@ class MainWindow(QMainWindow):
btn_black_bg.setStyleSheet("background-color: black; color: white; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
btn_black_bg.setToolTip("Resets the background color to Black (0x1C)")
btn_black_bg.clicked.connect(lambda: self.insert_char(0x1C))
bg_layout.addWidget(btn_black_bg)
right_layout.addWidget(btn_black_bg)
bg_layout.addStretch()
center_layout.addLayout(bg_layout)
right_layout.addSpacing(10)
# Graphics Control
gfx_ctrl_layout = QHBoxLayout()
gfx_ctrl_label = QLabel("Graphics Control:")
gfx_ctrl_layout.addWidget(gfx_ctrl_label)
right_layout.addWidget(gfx_ctrl_label)
# Hold Graphics (0x1E)
btn_hold = QPushButton("Hold Gfx")
@@ -265,7 +286,7 @@ class MainWindow(QMainWindow):
btn_hold.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
btn_hold.setToolTip("Hold Graphics (0x1E): Displays the last graphic char in place of subsequent control codes.")
btn_hold.clicked.connect(lambda: self.insert_char(0x1E))
gfx_ctrl_layout.addWidget(btn_hold)
right_layout.addWidget(btn_hold)
# Release Graphics (0x1F)
btn_release = QPushButton("Release Gfx")
@@ -273,15 +294,9 @@ class MainWindow(QMainWindow):
btn_release.setStyleSheet("background-color: #CCCCCC; color: black; font-weight: bold; border: 1px solid #555; border-radius: 3px;")
btn_release.setToolTip("Release Graphics (0x1F): Ends the 'Hold Graphics' effect.")
btn_release.clicked.connect(lambda: self.insert_char(0x1F))
gfx_ctrl_layout.addWidget(btn_release)
right_layout.addWidget(btn_release)
gfx_ctrl_layout.addStretch()
center_layout.addLayout(gfx_ctrl_layout)
# Canvas
self.canvas = TeletextCanvas()
self.canvas.cursorChanged.connect(self.on_cursor_changed)
center_layout.addWidget(self.canvas, 1) # Expand
right_layout.addStretch()
self.layout.addLayout(center_layout, 1)
@@ -461,8 +476,8 @@ class MainWindow(QMainWindow):
self.undo_stack.clear()
self.redo_stack.clear()
QMessageBox.information(self, "Closed", "File closed.")
self.status_label.setText("Ready")
self.status_label.setText("File closed.")
QTimer.singleShot(3000, lambda: self.status_label.setText("Ready"))
self.set_modified(False)