Put the file name of the code editor into the satus bar instead of the title bar

This commit is contained in:
Carl Philipp Klemm 2025-10-13 15:32:47 +02:00
parent 73aa61a13b
commit b6fb6ca7d4
2 changed files with 12 additions and 19 deletions

View file

@ -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()

View file

@ -42,7 +42,7 @@ private slots:
private:
void enumerateDevices();
void generateExample();
void updateTitle();
void updateStatus();
QString currentFilePath;
bool isFileModified;
};