Stop using availableGeometry

This commit is contained in:
Luis Ángel San Martín 2021-10-01 20:00:19 +02:00
parent b07ec73ccc
commit 2a90b1c6ef
4 changed files with 31 additions and 9 deletions

View File

@ -3,9 +3,9 @@
#include <QGridLayout> #include <QGridLayout>
#include <QLabel> #include <QLabel>
#include <QApplication> #include <QApplication>
#include <QDesktopWidget>
#include <QFrame> #include <QFrame>
#include <QImage> #include <QImage>
#include <QScreen>
#include "bookmarks.h" #include "bookmarks.h"
@ -32,7 +32,12 @@ BookmarksDialog::BookmarksDialog(QWidget *parent)
label->setStyleSheet(labelsStyle); label->setStyleSheet(labelsStyle);
} }
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
int height, width; int height, width;
height = heightDesktopResolution * 0.50; height = heightDesktopResolution * 0.50;
width = height * 0.65; width = height * 0.65;

View File

@ -26,7 +26,6 @@
#include <algorithm> #include <algorithm>
#include <QApplication> #include <QApplication>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDesktopWidget>
#include <QToolButton> #include <QToolButton>
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
@ -146,8 +145,13 @@ void MainWindowViewer::setupUI()
connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic); connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic);
setCentralWidget(viewer); setCentralWidget(viewer);
int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); QScreen *screen = window()->screen();
int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
int widthDesktopResolution = screen != nullptr ? screen->size().height() : 1024;
int height, width; int height, width;
height = static_cast<int>(heightDesktopResolution * 0.84); height = static_cast<int>(heightDesktopResolution * 0.84);
width = static_cast<int>(height * 0.70); width = static_cast<int>(height * 0.70);

View File

@ -9,10 +9,15 @@ PageLabelWidget::PageLabelWidget(QWidget *parent)
animation->setDuration(150); animation->setDuration(150);
animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height())); animation->setEndValue(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
int verticalRes = QApplication::desktop()->screenGeometry().height(); QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int verticalRes = screen != nullptr ? screen->size().height() : 600;
auto layout = new QHBoxLayout; auto layout = new QHBoxLayout;
layout->setMargin(0); layout->setContentsMargins(0, 0, 0, 0);
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
QSize labelSize; QSize labelSize;

View File

@ -7,7 +7,7 @@
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QTextCodec> #include <QTextCodec>
#include <QDesktopWidget> #include <QScreen>
#include "yacreader_global.h" #include "yacreader_global.h"
@ -31,7 +31,15 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent)
layout->setContentsMargins(1, 3, 1, 1); layout->setContentsMargins(1, 3, 1, 1);
setLayout(layout); setLayout(layout);
resize(500, QApplication::desktop()->availableGeometry().height() * 0.83);
QScreen *screen = parent != nullptr ? parent->window()->screen() : nullptr;
if (screen == nullptr) {
screen = QApplication::screens().constFirst();
}
int heightDesktopResolution = screen != nullptr ? screen->size().height() : 600;
resize(500, heightDesktopResolution * 0.83);
} }
HelpAboutDialog::~HelpAboutDialog() HelpAboutDialog::~HelpAboutDialog()