mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Merge pull request #6051 from Cacodemon345/resizable-fixes
Fix resizable window toggle on Windows
This commit is contained in:
@@ -1655,11 +1655,12 @@ MainWindow::focusOutEvent(QFocusEvent *event)
|
||||
void
|
||||
MainWindow::on_actionResizable_window_triggered(bool checked)
|
||||
{
|
||||
hide();
|
||||
if (checked) {
|
||||
vid_resize = 1;
|
||||
setWindowFlag(Qt::WindowMaximizeButtonHint, true);
|
||||
setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, false);
|
||||
setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, false);
|
||||
setWindowFlag(Qt::WindowMaximizeButtonHint, true);
|
||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||
if (monitors[i].target_buffer) {
|
||||
renderers[i]->setWindowFlag(Qt::WindowMaximizeButtonHint, true);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
#include <QStyleOption>
|
||||
#include <QMainWindow>
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
@@ -61,7 +62,14 @@ StyleOverride::polish(QWidget *widget)
|
||||
widget->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
widget->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
}
|
||||
widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, true);
|
||||
if (!qobject_cast<QMainWindow *>(widget)) {
|
||||
widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, true);
|
||||
}
|
||||
|
||||
if (qobject_cast<QMainWindow *>(widget)) {
|
||||
widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, vid_resize != 1);
|
||||
widget->setWindowFlag(Qt::WindowMaximizeButtonHint, vid_resize == 1);
|
||||
}
|
||||
}
|
||||
widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
class StyleOverride : public QProxyStyle {
|
||||
public:
|
||||
using QProxyStyle::QProxyStyle;
|
||||
|
||||
int styleHint(
|
||||
StyleHint hint,
|
||||
const QStyleOption *option = nullptr,
|
||||
|
||||
@@ -120,6 +120,32 @@ VMManagerMainWindow(QWidget *parent)
|
||||
connect(this, &VMManagerMainWindow::darkModeUpdated, vmm, &VMManagerMain::onDarkModeUpdated);
|
||||
#endif
|
||||
|
||||
{
|
||||
auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
this->ui->actionRemember_size_and_position->setChecked(!!config->getStringValue("window_remember").toInt());
|
||||
if (ui->actionRemember_size_and_position->isChecked()) {
|
||||
QStringList list = config->getStringValue("window_coordinates").split(',');
|
||||
for (auto& cur : list) {
|
||||
cur = cur.trimmed();
|
||||
}
|
||||
QRect geom;
|
||||
geom.setX(list[0].toInt());
|
||||
geom.setY(list[1].toInt());
|
||||
geom.setWidth(list[2].toInt());
|
||||
geom.setHeight(list[3].toInt());
|
||||
|
||||
setGeometry(geom);
|
||||
if (!!config->getStringValue("window_maximized").toInt()) {
|
||||
setWindowState(windowState() | Qt::WindowMaximized);
|
||||
}
|
||||
} else {
|
||||
config->setStringValue("window_remember", "");
|
||||
config->setStringValue("window_coordinates", "");
|
||||
config->setStringValue("window_maximized", "");
|
||||
}
|
||||
delete config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VMManagerMainWindow::~
|
||||
@@ -167,6 +193,15 @@ VMManagerMainWindow::saveSettings() const
|
||||
const auto currentSelection = vmm->getCurrentSelection();
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
config->setStringValue("last_selection", currentSelection);
|
||||
config->setStringValue("window_remember", QString::number(ui->actionRemember_size_and_position->isChecked()));
|
||||
if (ui->actionRemember_size_and_position->isChecked()) {
|
||||
config->setStringValue("window_coordinates", QString::asprintf("%i, %i, %i, %i", this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height()));
|
||||
config->setStringValue("window_maximized", this->isMaximized() ? "1" : "");
|
||||
} else {
|
||||
config->setStringValue("window_remember", "");
|
||||
config->setStringValue("window_coordinates", "");
|
||||
config->setStringValue("window_maximized", "");
|
||||
}
|
||||
// Sometimes required to ensure the settings save before the app exits
|
||||
config->sync();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<string>&Tools</string>
|
||||
</property>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="actionRemember_size_and_position"/>
|
||||
<addaction name="actionCheck_for_updates"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@@ -186,6 +187,14 @@
|
||||
<string>New machine...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemember_size_and_position">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R&emember size && position</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPreferences">
|
||||
<property name="text">
|
||||
<string>&Preferences...</string>
|
||||
|
||||
@@ -491,7 +491,7 @@ VMManagerSystem::launchSettings() {
|
||||
if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
|
||||
qInfo().nospace().noquote() << "Abnormal program termination while launching settings: exit code " << exitCode << ", exit status " << exitStatus;
|
||||
QMessageBox::critical(this, tr("Virtual machine crash"),
|
||||
tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString::number(exitCode)));
|
||||
tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(displayName, QString("%1 (0x%2)").arg(QString::number(exitCode), QString::number(exitCode, 16))));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user