diff --git a/retroshare-gui/src/gui/StartDialog.cpp b/retroshare-gui/src/gui/StartDialog.cpp index 237d1bb83..e53af6455 100644 --- a/retroshare-gui/src/gui/StartDialog.cpp +++ b/retroshare-gui/src/gui/StartDialog.cpp @@ -29,7 +29,6 @@ #include #include -#include #include @@ -49,7 +48,7 @@ StartDialog::StartDialog(QWidget *parent) Settings->loadWidgetInformation(this); /* Put the Login dialog in the screen center */ - const QRect screen = QApplication::desktop()->screenGeometry(); + const QRect screen = RsApplication::primaryScreenGeometry(); this->move( screen.center() - this->rect().center() ); /* get all available pgp private certificates.... diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 2341039cd..423149164 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -19,7 +19,6 @@ *******************************************************************************/ #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include +#include "rshare.h" #include "Emoticons.h" #include "util/HandleRichText.h" #include "retroshare/rsinit.h" @@ -261,7 +261,7 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s //Get widget's size QSize sizeWidget = smWidget->sizeHint(); //Get screen's size - QSize sizeScreen = QApplication::desktop()->size(); + QSize sizeScreen = RsApplication::primaryScreenGeometry().size(); //Calculate left distance to screen start int distToScreenLeft = butTopLeft.x(); @@ -437,7 +437,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * //Get widget's size QSize sizeWidget = smWidget->sizeHint(); //Get screen's size - QSize sizeScreen = QApplication::desktop()->size(); + QSize sizeScreen = RsApplication::primaryScreenGeometry().size(); //Calculate left distance to screen start int distToScreenLeft = butTopLeft.x(); diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 43861c4c6..fc42150c7 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -31,9 +31,9 @@ #include "util/QtVersion.h" #include "util/DateTime.h" -#include #include #include +#include #include @@ -192,8 +192,11 @@ void GroupTreeWidget::addToolButton(QToolButton *toolButton) /* Initialize button */ int i = qt_defaultDpi(); - auto desktopWidget = QApplication::desktop(); - auto y = desktopWidget->logicalDpiY(); + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + int y = i; + if (primaryScreen) { + y = primaryScreen->logicalDotsPerInchY(); + } toolButton->setAutoRaise(true); toolButton->setIconSize(QSize(24*y/i,24*y/i)); diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.cpp b/retroshare-gui/src/gui/common/RSGraphWidget.cpp index dab0645c4..c2a4a4581 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.cpp +++ b/retroshare-gui/src/gui/common/RSGraphWidget.cpp @@ -33,6 +33,7 @@ #include #include +#include "rshare.h" #include "RSGraphWidget.h" #if QT_VERSION < 0x040700 @@ -314,8 +315,7 @@ void RSGraphWidget::setFiltering(bool b) int RSGraphWidget::getNumPoints() { - QDesktopWidget *desktop = QApplication::desktop(); - int width = desktop->width(); + int width = RsApplication::primaryScreenGeometry().width(); return width; } diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h index e08a45eb9..6a5c35901 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.h +++ b/retroshare-gui/src/gui/common/RSGraphWidget.h @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/retroshare-gui/src/gui/common/rwindow.cpp b/retroshare-gui/src/gui/common/rwindow.cpp index 31fe12d9e..5d819c9cc 100644 --- a/retroshare-gui/src/gui/common/rwindow.cpp +++ b/retroshare-gui/src/gui/common/rwindow.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "rwindow.h" diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 4236b6f04..e3999912d 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d2dee5ac4..fb19e8e24 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -29,6 +29,7 @@ #include +#include "rshare.h" #include "MainWindow.h" #include "toaster/OnlineToaster.h" #include "toaster/MessageToaster.h" @@ -49,7 +50,6 @@ #include "retroshare/rsplugin.h" -#include #include #include //#include @@ -1040,8 +1040,7 @@ void NotifyQt::startWaitingToasters() /* Calculate positions */ QSize size = toaster->widget->size(); - QDesktopWidget *desktop = QApplication::desktop(); - QRect desktopGeometry = desktop->availableGeometry(desktop->primaryScreen()); + QRect desktopGeometry = RsApplication::primaryScreenGeometry(); switch (toaster->position) { case RshareSettings::TOASTERPOS_TOPLEFT: diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h index ffc9a32b0..12701cfc3 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/retroshare-gui/src/idle/idle_platform.cpp b/retroshare-gui/src/idle/idle_platform.cpp index ddae72f17..71928dc59 100644 --- a/retroshare-gui/src/idle/idle_platform.cpp +++ b/retroshare-gui/src/idle/idle_platform.cpp @@ -24,7 +24,9 @@ #ifdef HAVE_XSS #include +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) #include +#endif #include #include diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index d867f1545..1cb0b5766 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef __APPLE__ #include #endif @@ -676,3 +677,25 @@ bool RsApplication::updateLocalServer() } return false; } + +/** Get available geometry of primary screen */ +QRect RsApplication::availablePrimaryScreenGeometry() +{ + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (!primaryScreen) { + return QRect(0, 0, 0, 0); + } + + return primaryScreen->availableGeometry(); +} + +/** Get geometry of primary screen */ +QRect RsApplication::primaryScreenGeometry() +{ + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (!primaryScreen) { + return QRect(0, 0, 0, 0); + } + + return primaryScreen->geometry(); +} diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index be6af336c..ff079b1e8 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -154,6 +154,11 @@ public: static void createShortcut(const QKeySequence &key, QWidget *sender, QWidget *receiver, const char *slot); + /** Get available geometry of primary screen */ + static QRect availablePrimaryScreenGeometry(); + /** Get geometry of primary screen */ + static QRect primaryScreenGeometry(); + #ifdef __APPLE__ /**To process event from Mac system */ bool event(QEvent *);