Put the file name of the code editor into the satus bar instead of the title bar
This commit is contained in:
parent
73aa61a13b
commit
b6fb6ca7d4
|
@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent):
|
||||||
// Connect text changed signal to track modifications
|
// Connect text changed signal to track modifications
|
||||||
connect(&codeEditor, &QTextEdit::textChanged, this, [this]() {
|
connect(&codeEditor, &QTextEdit::textChanged, this, [this]() {
|
||||||
isFileModified = true;
|
isFileModified = true;
|
||||||
updateTitle();
|
updateStatus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,16 +52,16 @@ MainWindow::~MainWindow()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateTitle()
|
void MainWindow::updateStatus()
|
||||||
{
|
{
|
||||||
QString windowTitle = "EisMultiplexer-Qt";
|
|
||||||
if (!currentFilePath.isEmpty()) {
|
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()
|
void MainWindow::onActionOpenTriggered()
|
||||||
|
@ -87,7 +87,7 @@ void MainWindow::onActionOpenTriggered()
|
||||||
codeEditor.setPlainText(content);
|
codeEditor.setPlainText(content);
|
||||||
currentFilePath = filePath;
|
currentFilePath = filePath;
|
||||||
isFileModified = false;
|
isFileModified = false;
|
||||||
updateTitle();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onActionSaveTriggered()
|
void MainWindow::onActionSaveTriggered()
|
||||||
|
@ -108,7 +108,7 @@ void MainWindow::onActionSaveTriggered()
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
isFileModified = false;
|
isFileModified = false;
|
||||||
updateTitle();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onActionSaveAsTriggered()
|
void MainWindow::onActionSaveAsTriggered()
|
||||||
|
@ -121,13 +121,6 @@ void MainWindow::onActionSaveAsTriggered()
|
||||||
return;
|
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);
|
QFile file(filePath);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QMessageBox::warning(this, tr("Error"), tr("Could not save file: %1").arg(filePath));
|
QMessageBox::warning(this, tr("Error"), tr("Could not save file: %1").arg(filePath));
|
||||||
|
@ -140,7 +133,7 @@ void MainWindow::onActionSaveAsTriggered()
|
||||||
|
|
||||||
currentFilePath = filePath;
|
currentFilePath = filePath;
|
||||||
isFileModified = false;
|
isFileModified = false;
|
||||||
updateTitle();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::enumerateDevices()
|
void MainWindow::enumerateDevices()
|
||||||
|
|
|
@ -42,7 +42,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
void enumerateDevices();
|
void enumerateDevices();
|
||||||
void generateExample();
|
void generateExample();
|
||||||
void updateTitle();
|
void updateStatus();
|
||||||
QString currentFilePath;
|
QString currentFilePath;
|
||||||
bool isFileModified;
|
bool isFileModified;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue