Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions qtfred/src/ui/FredView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QProcess>
#include <QSignalBlocker>
#include <QSettings>
#include <QDateTime>

#include <project.h>

Expand Down Expand Up @@ -448,6 +449,7 @@ bool FredView::saveMissionToCurrentPath() {

save.save_mission_file(saveName.replace('/', DIR_SEPARATOR_CHAR).toUtf8().constData());
_missionModified = false;
setLastSaved(QDateTime::currentDateTime());

if (fixCount > 0)
QMessageBox::information(this, tr("Auto-corrections Applied"),
Expand Down Expand Up @@ -488,6 +490,7 @@ bool FredView::saveMissionAs() {

save.save_mission_file(saveName.replace('/', DIR_SEPARATOR_CHAR).toUtf8().constData());
_missionModified = false;
setLastSaved(QDateTime::currentDateTime());

if (fixCount > 0)
QMessageBox::information(this, tr("Auto-corrections Applied"),
Expand Down Expand Up @@ -747,6 +750,9 @@ void FredView::on_mission_loaded(const std::string& filepath) {
// Clear browsed head ANIs so the new mission's message scan starts fresh.
fso::fred::dialogs::MissionEventsDialogModel::clearBrowsedHeadAnis();

// A freshly loaded or newly created mission has not been saved this session yet.
setLastSaved(QDateTime());

if (_errorCheckerDialog) {
_errorCheckerDialog->clearErrors();
}
Expand Down Expand Up @@ -903,6 +909,12 @@ void FredView::initializeStatusBar() {
_statusBarObjectCount->setAlignment(Qt::AlignCenter);
statusBar()->addWidget(_statusBarObjectCount, 1);

// Sits just right of the (centered, stretched) object count, near the middle.
_statusBarLastSaved = new QLabel();
_statusBarLastSaved->setContentsMargins(16, 0, 0, 0);
statusBar()->addWidget(_statusBarLastSaved);
setLastSaved(QDateTime());

_statusBarViewmode = new QLabel();
_statusBarViewmode->setContentsMargins(8, 0, 0, 0);
statusBar()->addPermanentWidget(_statusBarViewmode);
Expand All @@ -912,6 +924,17 @@ void FredView::initializeStatusBar() {
statusBar()->addPermanentWidget(_statusBarUnitsLabel);
}

void FredView::setLastSaved(const QDateTime& when) {
if (!_statusBarLastSaved)
return;

if (when.isValid()) {
_statusBarLastSaved->setText(tr("Last Saved: %1").arg(when.toString(QStringLiteral("MMM d, yyyy h:mm:ss AP"))));
} else {
_statusBarLastSaved->setText(tr("Last Saved: Never"));
}
}

// ---------------------------------------------------------------------------
// Context toolbar (top, below the primary toolbar)
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -2507,6 +2530,7 @@ void FredView::on_actionLoadout_triggered(bool) {
}
void FredView::on_actionVariables_triggered(bool) {
auto editorDialog = new dialogs::VariableDialog(this, _viewport);
editorDialog->setAttribute(Qt::WA_DeleteOnClose);
editorDialog->show();
}

Expand Down
5 changes: 5 additions & 0 deletions qtfred/src/ui/FredView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <ui/widgets/ObjectComboBox.h>

class waypoint_list;
class QDateTime;

namespace fso {
namespace fred {
Expand Down Expand Up @@ -247,9 +248,13 @@ class FredView: public QMainWindow, public IDialogProvider {
void onSetGroup(int group);

QLabel* _statusBarObjectCount = nullptr;
QLabel* _statusBarLastSaved = nullptr;
QLabel* _statusBarViewmode = nullptr;
QLabel* _statusBarUnitsLabel = nullptr;

// Updates the "Last Saved" status bar label: pass an empty time to show "Never".
void setLastSaved(const QDateTime& when);

SceneBrowserPanel* _browserPanel = nullptr;

QMenu* _viewPopup = nullptr;
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/AsteroidEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ void AsteroidEditorDialog::reject()
void AsteroidEditorDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void AsteroidEditorDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/BriefingEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,15 @@ void BriefingEditorDialog::reject()
void BriefingEditorDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void BriefingEditorDialog::setupMapWidget()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/CommandBriefingDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ void CommandBriefingDialog::reject()
void CommandBriefingDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void CommandBriefingDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/DebriefingDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ void DebriefingDialog::reject()
void DebriefingDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void DebriefingDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/FictionViewerDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ void FictionViewerDialog::reject()
void FictionViewerDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void FictionViewerDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionCutscenesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ void MissionCutscenesDialog::reject()
void MissionCutscenesDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void MissionCutscenesDialog::updateUi()
Expand Down
12 changes: 10 additions & 2 deletions qtfred/src/ui/dialogs/MissionEventsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,15 @@ bool MissionEventsDialog::hasDefaultMessageParameter()
void MissionEventsDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void MissionEventsDialog::initMessageWidgets() {
Expand Down Expand Up @@ -701,7 +709,7 @@ void MissionEventsDialog::on_chainedCheckBox_stateChanged(int state)
updateEventUi();
}

void MissionEventsDialog::on_chainedDelayBox_valueChanged(int value)
void MissionEventsDialog::on_chainDelayBox_valueChanged(int value)
{
_model->setChainDelay(value);
}
Expand Down
2 changes: 1 addition & 1 deletion qtfred/src/ui/dialogs/MissionEventsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private slots:
void on_triggerCountBox_valueChanged(int value);
void on_intervalTimeBox_valueChanged(int value);
void on_chainedCheckBox_stateChanged(int state);
void on_chainedDelayBox_valueChanged(int value);
void on_chainDelayBox_valueChanged(int value);
void on_useMsecsCheckBox_stateChanged(int state);
void on_scoreBox_valueChanged(int value);
void on_teamCombo_currentIndexChanged(int index);
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionGoalsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ void MissionGoalsDialog::reject()
void MissionGoalsDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void MissionGoalsDialog::updateUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ void MissionSpecDialog::reject()

void MissionSpecDialog::closeEvent(QCloseEvent* e) {
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void MissionSpecDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecs/CustomDataDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ void CustomDataDialog::reject()
void CustomDataDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void CustomDataDialog::setInitial(const SCP_map<SCP_string, SCP_string>& items)
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecs/CustomStringsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ void CustomStringsDialog::reject()
void CustomStringsDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void CustomStringsDialog::setInitial(const SCP_vector<custom_string>& items)
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecs/CustomWingNamesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ void CustomWingNamesDialog::reject()

void CustomWingNamesDialog::closeEvent(QCloseEvent * e) {
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void CustomWingNamesDialog::setInitialStartingWings(const std::array<SCP_string, MAX_STARTING_WINGS>& startingWings) {
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecs/SoundEnvironmentDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ void SoundEnvironmentDialog::closeEvent(QCloseEvent* e)
reject();
closeWave();
disableEnvPreview();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void SoundEnvironmentDialog::enableOrDisableFields()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/MissionSpecs/SupportRearmDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ SupportRearmSettings SupportRearmDialog::settings() const
void SupportRearmDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore();
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

QString SupportRearmDialog::weaponEntryText(int weaponClass) const
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/ObjectOrientEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ void ObjectOrientEditorDialog::reject()
void ObjectOrientEditorDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}

void ObjectOrientEditorDialog::initializeUi()
Expand Down
10 changes: 9 additions & 1 deletion qtfred/src/ui/dialogs/ReinforcementsEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ void ReinforcementsDialog::reject()
void ReinforcementsDialog::closeEvent(QCloseEvent* e)
{
reject();
e->ignore(); // Don't let the base class close the window
// reject() hides the dialog when it actually closes. Let that close
// proceed (so a dialog created with WA_DeleteOnClose is destroyed),
// and only veto it when reject() decided to keep the dialog open (e.g.
// the user cancelled the unsaved-changes prompt).
if (isVisible()) {
e->ignore();
} else {
e->accept();
}
}


Expand Down
Loading
Loading