feat: add black/new background buttons and standard styling
All checks were successful
Build Linux / Build Linux (push) Successful in 1m33s
Build Windows / Build Windows (push) Successful in 2m55s

This commit is contained in:
2026-01-21 14:11:48 +01:00
parent 8475b512b8
commit 80cca7cd79
2 changed files with 37 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ def main():
app = QApplication(sys.argv)
app.setApplicationName("TeletextEditor")
app.setOrganizationName("DanielDybing")
app.setDesktopFileName("TeletextEditor") # Helps Linux DEs group windows
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

@@ -192,6 +192,7 @@ class MainWindow(QMainWindow):
color_layout.addWidget(self.chk_graphics)
colors = [
("Black", 0x00, "#000000"),
("Red", 0x01, "#FF0000"),
("Green", 0x02, "#00FF00"),
("Yellow", 0x03, "#FFFF00"),
@@ -203,7 +204,20 @@ class MainWindow(QMainWindow):
for name, code, hex_color in colors:
btn = QPushButton(name)
btn.setStyleSheet(f"background-color: {hex_color}; font-weight: bold; color: black;")
btn.setFixedSize(60, 30) # Fixed size for uniformity
# Common style
style = f"background-color: {hex_color}; font-weight: bold; border: 1px solid #555; border-radius: 3px;"
if name == "Black":
style += " color: white;"
elif name in ["Blue", "Red", "Magenta"]: # Darker backgrounds
style += " color: white;"
else:
style += " color: black;"
btn.setStyleSheet(style)
# Use separate method to handle graphics check
btn.clicked.connect(lambda checked, c=code: self.insert_color(c))
color_layout.addWidget(btn)
@@ -216,6 +230,27 @@ class MainWindow(QMainWindow):
color_layout.addStretch()
center_layout.addLayout(color_layout)
# Background Controls
bg_layout = QHBoxLayout()
bg_label = QLabel("Background:")
bg_layout.addWidget(bg_label)
# New Background (0x1D)
btn_new_bg = QPushButton("New BG")
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)
# Black Background (0x1C)
btn_black_bg = QPushButton("Black BG")
btn_black_bg.setToolTip("Resets the background color to Black (0x1C)")
btn_black_bg.setStyleSheet("background-color: black; color: white;")
btn_black_bg.clicked.connect(lambda: self.insert_char(0x1C))
bg_layout.addWidget(btn_black_bg)
bg_layout.addStretch()
center_layout.addLayout(bg_layout)
# Canvas
self.canvas = TeletextCanvas()
self.canvas.cursorChanged.connect(self.on_cursor_changed)