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; };