Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display main window maximized when first shown #636

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 13 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,20 @@ void MainWindow::loadUserSettings() {
}

void MainWindow::restoreWindowState() {
logInfo("Restoring main window geometry from previous session.");
QMap<QString, QByteArray> geometry = porymapConfig.getMainGeometry();
this->restoreGeometry(geometry.value("main_window_geometry"));
this->restoreState(geometry.value("main_window_state"));
this->ui->splitter_map->restoreState(geometry.value("map_splitter_state"));
this->ui->splitter_main->restoreState(geometry.value("main_splitter_state"));
this->ui->splitter_Metatiles->restoreState(geometry.value("metatiles_splitter_state"));
const QByteArray mainWindowGeometry = geometry.value("main_window_geometry");
if (mainWindowGeometry.isEmpty()) {
// If there's no saved geometry for the main window (i.e., first show) then we show it maximized.
// This simplifies the problem of picking a good window size depending on the screen.
setWindowState(Qt::WindowMaximized | Qt::WindowActive);
} else {
logInfo("Restoring main window geometry from previous session.");
restoreGeometry(mainWindowGeometry);
restoreState(geometry.value("main_window_state"));
ui->splitter_map->restoreState(geometry.value("map_splitter_state"));
ui->splitter_main->restoreState(geometry.value("main_splitter_state"));
ui->splitter_Metatiles->restoreState(geometry.value("metatiles_splitter_state"));
}
}

void MainWindow::setTheme(QString theme) {
Expand Down
Loading