mirror of https://github.com/mgba-emu/mgba.git
Qt: Cap window size to monitor size
This commit is contained in:
parent
a32cb5cc5e
commit
6af4ddefdd
1
CHANGES
1
CHANGES
|
@ -41,6 +41,7 @@ Misc:
|
||||||
- Qt: Support switching webcams
|
- Qt: Support switching webcams
|
||||||
- Core: Add keysRead callback
|
- Core: Add keysRead callback
|
||||||
- Vita: Improved frame drawing speed
|
- Vita: Improved frame drawing speed
|
||||||
|
- Qt: Cap window size on start to monitor size
|
||||||
|
|
||||||
0.7.1: (2019-02-24)
|
0.7.1: (2019-02-24)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QScreen>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "ArchiveInspector.h"
|
#include "ArchiveInspector.h"
|
||||||
|
@ -200,6 +201,15 @@ void Window::argumentsPassed(mArguments* args) {
|
||||||
|
|
||||||
void Window::resizeFrame(const QSize& size) {
|
void Window::resizeFrame(const QSize& size) {
|
||||||
QSize newSize(size);
|
QSize newSize(size);
|
||||||
|
if (windowHandle()) {
|
||||||
|
QRect geom = windowHandle()->screen()->availableGeometry();
|
||||||
|
if (newSize.width() > geom.width()) {
|
||||||
|
newSize.setWidth(geom.width());
|
||||||
|
}
|
||||||
|
if (newSize.height() > geom.height()) {
|
||||||
|
newSize.setHeight(geom.height());
|
||||||
|
}
|
||||||
|
}
|
||||||
m_screenWidget->setSizeHint(newSize);
|
m_screenWidget->setSizeHint(newSize);
|
||||||
newSize -= m_screenWidget->size();
|
newSize -= m_screenWidget->size();
|
||||||
newSize += this->size();
|
newSize += this->size();
|
||||||
|
@ -595,7 +605,7 @@ void Window::showEvent(QShowEvent* event) {
|
||||||
m_wasOpened = true;
|
m_wasOpened = true;
|
||||||
resizeFrame(m_screenWidget->sizeHint());
|
resizeFrame(m_screenWidget->sizeHint());
|
||||||
QVariant windowPos = m_config->getQtOption("windowPos");
|
QVariant windowPos = m_config->getQtOption("windowPos");
|
||||||
QRect geom = QApplication::desktop()->availableGeometry(this);
|
QRect geom = windowHandle()->screen()->availableGeometry();
|
||||||
if (!windowPos.isNull() && geom.contains(windowPos.toPoint())) {
|
if (!windowPos.isNull() && geom.contains(windowPos.toPoint())) {
|
||||||
move(windowPos.toPoint());
|
move(windowPos.toPoint());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue