diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp index 938f2f48..f39685db 100644 --- a/YACReader/bookmarks_dialog.cpp +++ b/YACReader/bookmarks_dialog.cpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include "bookmarks.h" @@ -32,7 +32,12 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) 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; height = heightDesktopResolution * 0.50; width = height * 0.65; diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index c00c8216..2faaee1f 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -146,8 +145,13 @@ void MainWindowViewer::setupUI() connect(viewer, &Viewer::openPreviousComic, this, &MainWindowViewer::openPreviousComic); setCentralWidget(viewer); - int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); - int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + QScreen *screen = window()->screen(); + 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; height = static_cast(heightDesktopResolution * 0.84); width = static_cast(height * 0.70); diff --git a/YACReader/page_label_widget.cpp b/YACReader/page_label_widget.cpp index fd30ba92..f257a201 100644 --- a/YACReader/page_label_widget.cpp +++ b/YACReader/page_label_widget.cpp @@ -9,10 +9,15 @@ PageLabelWidget::PageLabelWidget(QWidget *parent) animation->setDuration(150); 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; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0); QSize labelSize; diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 680e9210..c2e8db47 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "yacreader_global.h" @@ -31,7 +31,15 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent) layout->setContentsMargins(1, 3, 1, 1); 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()