Skip to content

Commit dd993aa

Browse files
committed
Improvements to filename display in window titles
1 parent 59aa913 commit dd993aa

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

gui/source/post/ResultWindow.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,20 @@
55
#include <QMessageBox>
66
#include <QFileDialog>
77

8-
ResultWindow::ResultWindow() {
8+
ResultWindow::ResultWindow(const QString& filePath, const BowResult& data) {
99
// Main window properties
10-
this->setWindowTitle("Results");
10+
this->setWindowFilePath(filePath);
1111
this->setWindowIcon(QIcon(":/icons/logo.svg"));
1212
this->setStyleSheet("QMainWindow { background-image:url(:/icons/background.png); background-position: center; background-repeat: no-repeat; }");
1313
this->menuBar()->setAutoFillBackground(true);
1414
this->resize({1000, 700}); // Initial size, overwritten by stored window geometry if present
1515

16-
// Load geometry and state
16+
// Load state and geometry
1717
UserSettings settings;
1818
restoreState(settings.value("OutputWindow/state").toByteArray());
1919
restoreGeometry(settings.value("OutputWindow/geometry").toByteArray());
20-
}
21-
22-
void ResultWindow::closeEvent(QCloseEvent *event) {
23-
// Save state and geometry
24-
UserSettings settings;
25-
settings.setValue("OutputWindow/state", saveState());
26-
settings.setValue("OutputWindow/geometry", saveGeometry());
27-
}
2820

29-
void ResultWindow::load(const BowResult& data) {
21+
// Try to load output data
3022
try {
3123
this->data = data;
3224
this->setCentralWidget(new OutputWidget(this->data));
@@ -35,3 +27,10 @@ void ResultWindow::load(const BowResult& data) {
3527
QMessageBox::critical(this, "Error", "Failed to open result data:\n" + QString(e.what()));
3628
}
3729
}
30+
31+
void ResultWindow::closeEvent(QCloseEvent *event) {
32+
// Save state and geometry
33+
UserSettings settings;
34+
settings.setValue("OutputWindow/state", saveState());
35+
settings.setValue("OutputWindow/geometry", saveGeometry());
36+
}

gui/source/post/ResultWindow.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class RecentFilesMenu;
66

77
class ResultWindow: public QMainWindow {
88
public:
9-
ResultWindow();
10-
void load(const BowResult& data);
9+
ResultWindow(const QString& filePath, const BowResult& data);
1110

1211
private:
1312
BowResult data;

gui/source/pre/MainWindow.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ void MainWindow::runSimulation(Mode mode) {
274274
BowResult result;
275275
SimulationDialog dialog(this, mainModel->getBow(), result, mode);
276276
if(dialog.exec() == QDialog::Accepted) {
277-
auto window = new ResultWindow();
278-
window->load(result);
277+
auto window = new ResultWindow(this->windowFilePath(), result);
279278
window->show();
280279
}
281280
}
@@ -344,10 +343,13 @@ QString MainWindow::showSaveFileDialog() {
344343
// Filename to display at the top of the window, which is either the actual name of the current file
345344
// or the default name if no file is loaded
346345
QString MainWindow::displayPath() {
347-
if(mainModel->currentFile().isEmpty()) {
348-
return DEFAULT_NAME;
349-
}
350-
else {
346+
if(!mainModel->currentFile().isEmpty()) {
351347
return mainModel->currentFile();
352348
}
349+
350+
if(mainModel->hasBow()) {
351+
return DEFAULT_NAME;
352+
}
353+
354+
return "";
353355
}

0 commit comments

Comments
 (0)