Files
86Box/src/qt/qt_specifydimensions.cpp

92 lines
2.7 KiB
C++
Raw Normal View History

2022-02-07 15:00:02 +06:00
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Specify dimensions UI module.
*
*
*
* Authors: Cacodemon345
*
* Copyright 2021-2022 Cacodemon345
*/
2021-12-12 01:16:27 +06:00
#include "qt_specifydimensions.h"
#include "ui_qt_specifydimensions.h"
#include "qt_mainwindow.hpp"
#include "ui_qt_mainwindow.h"
2021-12-12 01:16:27 +06:00
#include <QStatusBar>
#include <QMenuBar>
#include <QTimer>
2021-12-12 01:16:27 +06:00
extern "C"
{
#include <86box/86box.h>
#include <86box/plat.h>
#include <86box/ui.h>
#include <86box/video.h>
}
extern MainWindow* main_window;
SpecifyDimensions::SpecifyDimensions(QWidget *parent) :
QDialog(parent),
ui(new Ui::SpecifyDimensions)
{
ui->setupUi(this);
ui->checkBox->setChecked(vid_resize == 2);
2021-12-17 07:52:30 +02:00
ui->spinBoxWidth->setRange(16, 2048);
2021-12-12 01:16:27 +06:00
ui->spinBoxWidth->setValue(main_window->getRenderWidgetSize().width());
2021-12-17 07:52:30 +02:00
ui->spinBoxHeight->setRange(16, 2048);
2021-12-12 01:16:27 +06:00
ui->spinBoxHeight->setValue(main_window->getRenderWidgetSize().height());
}
SpecifyDimensions::~SpecifyDimensions()
{
delete ui;
}
void SpecifyDimensions::on_SpecifyDimensions_accepted()
{
if (ui->checkBox->isChecked())
{
vid_resize = 2;
main_window->setWindowFlag(Qt::WindowMaximizeButtonHint, false);
main_window->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint);
2021-12-12 01:16:27 +06:00
window_remember = 0;
fixed_size_x = ui->spinBoxWidth->value();
fixed_size_y = ui->spinBoxHeight->value();
2022-01-09 17:00:16 +02:00
main_window->setFixedSize(ui->spinBoxWidth->value(),
ui->spinBoxHeight->value()
+ (!hide_status_bar ? main_window->statusBar()->height() : 0)
+ (!hide_tool_bar ? main_window->ui->toolBar->height() : 0)
+ main_window->menuBar()->height());
2021-12-12 01:16:27 +06:00
emit main_window->updateMenuResizeOptions();
main_window->show();
main_window->ui->stackedWidget->switchRenderer((RendererStack::Renderer)vid_api);
2021-12-12 01:16:27 +06:00
}
else
{
main_window->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
main_window->ui->actionResizable_window->setChecked(false);
2021-12-12 01:16:27 +06:00
vid_resize = 0;
main_window->ui->actionResizable_window->trigger();
2021-12-12 01:16:27 +06:00
window_remember = 1;
window_w = ui->spinBoxWidth->value();
window_h = ui->spinBoxHeight->value();
main_window->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
emit main_window->resizeContents(ui->spinBoxWidth->value(), ui->spinBoxHeight->value());
vid_resize = 1;
emit main_window->updateMenuResizeOptions();
}
main_window->show();
2021-12-12 01:16:27 +06:00
emit main_window->updateWindowRememberOption();
}