feat: add black/new background buttons and standard styling
This commit is contained in:
@@ -26,7 +26,7 @@ def main():
|
|||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setApplicationName("TeletextEditor")
|
app.setApplicationName("TeletextEditor")
|
||||||
app.setOrganizationName("DanielDybing")
|
app.setOrganizationName("DanielDybing")
|
||||||
app.setDesktopFileName("TeletextEditor") # Helps Linux DEs group windows
|
app.setDesktopFileName("no.ddybing.TeletextEditor") # Helps Linux DEs group windows
|
||||||
|
|
||||||
# Debug Image Formats
|
# Debug Image Formats
|
||||||
supported_formats = [str(fmt, 'utf-8') for fmt in QImageReader.supportedImageFormats()]
|
supported_formats = [str(fmt, 'utf-8') for fmt in QImageReader.supportedImageFormats()]
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ class MainWindow(QMainWindow):
|
|||||||
color_layout.addWidget(self.chk_graphics)
|
color_layout.addWidget(self.chk_graphics)
|
||||||
|
|
||||||
colors = [
|
colors = [
|
||||||
|
("Black", 0x00, "#000000"),
|
||||||
("Red", 0x01, "#FF0000"),
|
("Red", 0x01, "#FF0000"),
|
||||||
("Green", 0x02, "#00FF00"),
|
("Green", 0x02, "#00FF00"),
|
||||||
("Yellow", 0x03, "#FFFF00"),
|
("Yellow", 0x03, "#FFFF00"),
|
||||||
@@ -203,7 +204,20 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
for name, code, hex_color in colors:
|
for name, code, hex_color in colors:
|
||||||
btn = QPushButton(name)
|
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
|
# Use separate method to handle graphics check
|
||||||
btn.clicked.connect(lambda checked, c=code: self.insert_color(c))
|
btn.clicked.connect(lambda checked, c=code: self.insert_color(c))
|
||||||
color_layout.addWidget(btn)
|
color_layout.addWidget(btn)
|
||||||
@@ -216,6 +230,27 @@ class MainWindow(QMainWindow):
|
|||||||
color_layout.addStretch()
|
color_layout.addStretch()
|
||||||
center_layout.addLayout(color_layout)
|
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
|
# Canvas
|
||||||
self.canvas = TeletextCanvas()
|
self.canvas = TeletextCanvas()
|
||||||
self.canvas.cursorChanged.connect(self.on_cursor_changed)
|
self.canvas.cursorChanged.connect(self.on_cursor_changed)
|
||||||
|
|||||||
Reference in New Issue
Block a user