mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-04-22 01:23:32 -04:00
app: add unsaved file indicator to window title
This commit is contained in:
parent
45f887c201
commit
61ca9a2958
2 changed files with 20 additions and 0 deletions
|
@ -177,6 +177,23 @@ void MainWindow::SetPanel(Panel *panel, si::Object *chunk)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::UpdateWindowTitleFlag(bool isFileModified)
|
||||
{
|
||||
QString title = windowTitle();
|
||||
|
||||
if (isFileModified) {
|
||||
if (!title.endsWith("*")) {
|
||||
title.append("*");
|
||||
setWindowTitle(title);
|
||||
}
|
||||
} else {
|
||||
if (title.endsWith("*")) {
|
||||
// trim off asterisk
|
||||
setWindowTitle(title.left(title.length() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ExtractObject(si::Object *obj)
|
||||
{
|
||||
QString filename = QString::fromStdString(obj->filename());
|
||||
|
@ -213,6 +230,7 @@ void MainWindow::ReplaceObject(si::Object *obj)
|
|||
#endif
|
||||
)) {
|
||||
static_cast<Panel*>(config_stack_->currentWidget())->ResetData();
|
||||
UpdateWindowTitleFlag(true);
|
||||
} else {
|
||||
QMessageBox::critical(this, QString(), tr("Failed to open to file \"%1\".").arg(s));
|
||||
}
|
||||
|
@ -318,6 +336,7 @@ bool MainWindow::SaveFile()
|
|||
);
|
||||
|
||||
if (r == Interleaf::ERROR_SUCCESS) {
|
||||
UpdateWindowTitleFlag(false);
|
||||
return true;
|
||||
} else {
|
||||
QMessageBox::critical(this, QString(), tr("Failed to write SI file: %1").arg(r));
|
||||
|
|
|
@ -29,6 +29,7 @@ private:
|
|||
void InitializeMenuBar();
|
||||
|
||||
void SetPanel(Panel *panel, si::Object *chunk);
|
||||
void UpdateWindowTitleFlag(bool isFileModified);
|
||||
|
||||
void ExtractObject(si::Object *obj);
|
||||
void ReplaceObject(si::Object *obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue