1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Centralises window title responsibility.

This commit is contained in:
Thomas Harte 2020-06-28 23:08:40 -04:00
parent f6e5a2fb04
commit b9e117cdcf
2 changed files with 10 additions and 5 deletions

View File

@ -201,8 +201,8 @@ void MainWindow::insertFile(const QString &fileName) {
void MainWindow::launchFile(const QString &fileName) {
targets = Analyser::Static::GetTargets(fileName.toStdString());
if(!targets.empty()) {
openFileName = QFileInfo(fileName).fileName();
launchMachine();
setWindowTitle(QFileInfo(fileName).fileName());
}
}
@ -335,7 +335,6 @@ void MainWindow::launchMachine() {
configurable->set_options(Machine::AllOptionsByMachineName()[longMachineName]);
}
// If this is a timed machine, start up the timer.
const auto timedMachine = machine->timed_machine();
if(timedMachine) {
@ -349,9 +348,6 @@ void MainWindow::launchMachine() {
insertAction->setEnabled(true);
}
// Update the window title. TODO: clearly I need a proper functional solution for the window title.
setWindowTitle(QString::fromStdString(longMachineName));
// Add machine-specific UI.
const std::string settingsPrefix = Machine::ShortNameForTargetMachine(machineType);
switch(machineType) {
@ -731,7 +727,15 @@ void MainWindow::setUIPhase(UIPhase phase) {
case UIPhase::RequestingROMs:
setWindowTitle(tr("Provide ROMs..."));
break;
default:
// Update the window title. TODO: clearly I need a proper functional solution for the window title.
if(openFileName.isEmpty()) {
const auto machineType = targets[0]->machine;
setWindowTitle(QString::fromStdString(Machine::LongNameForTargetMachine(machineType)));
} else {
setWindowTitle(openFileName);
}
break;
}

View File

@ -43,6 +43,7 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
enum class UIPhase {
SelectingMachine, RequestingROMs, RunningMachine
} uiPhase = UIPhase::SelectingMachine;
QString openFileName;
void setUIPhase(UIPhase);
void launchMachine();