Skip to content

Commit

Permalink
Qt5: QDesktopWidget is deprecated use QScreen [-Wdeprecated-declarati…
Browse files Browse the repository at this point in the history
…ons]
  • Loading branch information
wwmayer committed Jun 12, 2020
1 parent deb39c4 commit eced0cb
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Gui/Action.cpp
Expand Up @@ -37,6 +37,10 @@
# include <QToolButton>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

#include <Base/Tools.h>
#include "Action.h"
#include "Application.h"
Expand Down Expand Up @@ -420,7 +424,11 @@ void WorkbenchComboBox::showPopup()
int rows = count();
if (rows > 0) {
int height = view()->sizeHintForRow(0);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
int maxHeight = QApplication::primaryScreen()->size().height();
#else
int maxHeight = QApplication::desktop()->height();
#endif
view()->setMinimumHeight(qMin(height * rows, maxHeight/2));
}

Expand Down
8 changes: 8 additions & 0 deletions src/Gui/DlgPreferencesImp.cpp
Expand Up @@ -34,6 +34,10 @@
# include <QScrollBar>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

#include <Base/Exception.h>
#include <Base/Console.h>
#include <App/Application.h>
Expand Down Expand Up @@ -307,7 +311,11 @@ void DlgPreferencesImp::resizeEvent(QResizeEvent* ev)
if (canEmbedScrollArea) {
// embed the widget stack into a scroll area if the size is
// bigger than the available desktop
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRect rect = QApplication::primaryScreen()->availableGeometry();
#else
QRect rect = QApplication::desktop()->availableGeometry();
#endif
int maxHeight = rect.height() - 60;
int maxWidth = rect.width();
if (height() > maxHeight || width() > maxWidth) {
Expand Down
8 changes: 8 additions & 0 deletions src/Gui/MainWindow.cpp
Expand Up @@ -53,6 +53,10 @@
# include <QWhatsThis>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

// FreeCAD Base header
#include <Base/Parameter.h>
#include <Base/Exception.h>
Expand Down Expand Up @@ -1409,7 +1413,11 @@ void MainWindow::loadWindowSettings()
QString qtver = QString::fromLatin1("Qt%1.%2").arg(major).arg(minor);
QSettings config(vendor, application);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRect rect = QApplication::primaryScreen()->availableGeometry();
#else
QRect rect = QApplication::desktop()->availableGeometry();
#endif
int maxHeight = rect.height();
int maxWidth = rect.width();

Expand Down
8 changes: 8 additions & 0 deletions src/Gui/Splashscreen.cpp
Expand Up @@ -44,6 +44,10 @@
# include <QGLContext>
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

#include <LibraryVersions.h>
#include <zlib.h>
#include <boost/version.hpp>
Expand Down Expand Up @@ -234,7 +238,11 @@ AboutDialog::AboutDialog(bool showLic, QWidget* parent)

setModal(true);
ui->setupUi(this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRect rect = QApplication::primaryScreen()->availableGeometry();
#else
QRect rect = QApplication::desktop()->availableGeometry();
#endif
QPixmap image = getMainWindow()->splashImage();

// Make sure the image is not too big
Expand Down
8 changes: 8 additions & 0 deletions src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp
Expand Up @@ -64,6 +64,10 @@
#include <QtGui/QMouseEvent>
#include <math.h>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

#include "qtcolorpicker.h"

/*! \class QtColorPicker
Expand Down Expand Up @@ -312,7 +316,11 @@ void QtColorPicker::buttonPressed(bool toggled)
if (!toggled)
return;

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const QRect desktop = QApplication::primaryScreen()->geometry();
#else
const QRect desktop = QApplication::desktop()->geometry();
#endif
// Make sure the popup is inside the desktop.
QPoint pos = mapToGlobal(rect().bottomLeft());
if (pos.x() < desktop.left())
Expand Down
8 changes: 8 additions & 0 deletions src/Mod/Web/Gui/BrowserView.cpp
Expand Up @@ -71,6 +71,10 @@
# define QWEBPAGE QWebPage
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QScreen>
#endif

#include <QLatin1String>
#include <QRegExp>
#include "BrowserView.h"
Expand Down Expand Up @@ -239,7 +243,11 @@ WebView::WebView(QWidget *parent)
: QWEBVIEW(parent)
{
// Increase html font size for high DPI displays
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QRect mainScreenSize = QApplication::primaryScreen()->geometry();
#else
QRect mainScreenSize = QApplication::desktop()->screenGeometry();
#endif
if (mainScreenSize.width() > 1920){
setTextSizeMultiplier (mainScreenSize.width()/1920.0);
}
Expand Down

0 comments on commit eced0cb

Please sign in to comment.