Skip to content

Commit

Permalink
Hack for restoring maximized window
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Jan 3, 2024
1 parent 51f0617 commit f0cb527
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions emulator/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QAction>
#include <QClipboard>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDockWidget>
#include <QFileDialog>
#include <QLabel>
Expand Down Expand Up @@ -207,9 +208,11 @@ void MainWindow::changeEvent(QEvent *e)
}
}

void MainWindow::closeEvent(QCloseEvent *)
void MainWindow::closeEvent(QCloseEvent * event)
{
saveSettings(Global_getSettings());

QMainWindow::closeEvent(event);
}

void MainWindow::saveSettings(QSettings * settings)
Expand All @@ -233,12 +236,17 @@ void MainWindow::restoreSettings(QSettings * settings)
int scrViewMode = Global_getSettings()->value("MainWindow/ScreenMode").toInt();
m_screen->setMode(scrViewMode);

//Update centralWidget size
// Update centralWidget size
ui->centralWidget->setMaximumHeight(m_screen->maximumHeight() + m_keyboard->maximumHeight());
ui->centralWidget->setMaximumWidth(m_screen->maximumWidth());
int maxwid = m_screen->maximumWidth() > m_keyboard->maximumWidth() ? m_screen->maximumWidth() : m_keyboard->maximumWidth();
ui->centralWidget->setMaximumWidth(maxwid);

restoreGeometry(settings->value("MainWindow/Geometry").toByteArray());
restoreState(settings->value("MainWindow/WindowState").toByteArray());
QByteArray geometry = Global_getSettings()->value("MainWindow/Geometry").toByteArray();
if (!geometry.isEmpty())
restoreGeometry(geometry);
if (isMaximized()) //HACK for restoring maximized window, see https://bugreports.qt.io/browse/QTBUG-46620
setGeometry(QApplication::desktop()->availableGeometry(this));
restoreState(Global_getSettings()->value("MainWindow/WindowState").toByteArray());

m_keyboard->setVisible(settings->value("MainWindow/KeyboardView", true).toBool());
m_dockConsole->setVisible(settings->value("MainWindow/ConsoleView", false).toBool());
Expand Down
2 changes: 1 addition & 1 deletion emulator/qkeyboardview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ QKeyboardView::QKeyboardView(QWidget *parent) :
m_nKeyPressedScan = m_nKeyPressedCode = 0;

setMinimumSize(551 + 8, 216 + 8);
setMaximumSize(904, 216 + 20);
setMaximumSize(1024, 216 + 24);
}

void QKeyboardView::paintEvent(QPaintEvent *)
Expand Down
2 changes: 1 addition & 1 deletion emulator/qscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void QEmulatorScreen::createDisplay()
m_image = new QImage(cxScreenWidth, cyScreenHeight, QImage::Format_RGB32);

setMinimumSize(cxScreenWidth + 8, cyScreenHeight + 8);
setMaximumSize(cxScreenWidth + 100, cyScreenHeight + 20);
setMaximumSize(std::max(cxScreenWidth + 100, 1024), cyScreenHeight + 24);
}

void QEmulatorScreen::paintEvent(QPaintEvent * /*event*/)
Expand Down

0 comments on commit f0cb527

Please # to comment.