From b6fb6ca7d43348510b9c03934b8431fb5af88b82 Mon Sep 17 00:00:00 2001 From: Carl Philipp Klemm Date: Mon, 13 Oct 2025 15:32:47 +0200 Subject: [PATCH] Put the file name of the code editor into the satus bar instead of the title bar --- mainwindow.cpp | 29 +++++++++++------------------ mainwindow.h | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 2537ad9..89f86a3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent): // Connect text changed signal to track modifications connect(&codeEditor, &QTextEdit::textChanged, this, [this]() { isFileModified = true; - updateTitle(); + updateStatus(); }); } @@ -52,16 +52,16 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::updateTitle() +void MainWindow::updateStatus() { - QString windowTitle = "EisMultiplexer-Qt"; if (!currentFilePath.isEmpty()) { - windowTitle = QString("%1 - %2").arg(currentFilePath); + QString status = "EisMultiplexer-Qt"; + status = QString("%1").arg(currentFilePath); + if (isFileModified) { + status += " - [Unsaved Changes]"; + } + ui->statusbar->showMessage(status); } - if (isFileModified) { - windowTitle += "[*]"; - } - setWindowTitle(windowTitle); } void MainWindow::onActionOpenTriggered() @@ -87,7 +87,7 @@ void MainWindow::onActionOpenTriggered() codeEditor.setPlainText(content); currentFilePath = filePath; isFileModified = false; - updateTitle(); + updateStatus(); } void MainWindow::onActionSaveTriggered() @@ -108,7 +108,7 @@ void MainWindow::onActionSaveTriggered() file.close(); isFileModified = false; - updateTitle(); + updateStatus(); } void MainWindow::onActionSaveAsTriggered() @@ -121,13 +121,6 @@ void MainWindow::onActionSaveAsTriggered() return; } - // Ensure the file has a .py extension if it's a Python file - if (filePath.endsWith(".py", Qt::CaseInsensitive)) { - // File already has .py extension - } else { - filePath += ".py"; - } - QFile file(filePath); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::warning(this, tr("Error"), tr("Could not save file: %1").arg(filePath)); @@ -140,7 +133,7 @@ void MainWindow::onActionSaveAsTriggered() currentFilePath = filePath; isFileModified = false; - updateTitle(); + updateStatus(); } void MainWindow::enumerateDevices() diff --git a/mainwindow.h b/mainwindow.h index 508f1c2..70bbc2f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -42,7 +42,7 @@ private slots: private: void enumerateDevices(); void generateExample(); - void updateTitle(); + void updateStatus(); QString currentFilePath; bool isFileModified; };