r24839 by craig - Qt6 compatibility replacements for QApplication::desktop

scribus-commit scribus-commit at lists.scribus.net
Sat Jan 29 22:44:03 UTC 2022


Author: craig
Date: Sat Jan 29 22:44:02 2022
New Revision: 24839

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24839
Log:
Qt6 compatibility replacements for QApplication::desktop

Modified:
    trunk/Scribus/scribus/canvasmode_eyedropper.cpp
    trunk/Scribus/scribus/plugins/gettext/textfilter/tfdia.cpp
    trunk/Scribus/scribus/plugins/picbrowser/imagedialog.cpp
    trunk/Scribus/scribus/plugins/picbrowser/imagedialog.h
    trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
    trunk/Scribus/scribus/ui/outputpreview_ps.cpp
    trunk/Scribus/scribus/ui/prefs_display.cpp
    trunk/Scribus/scribus/ui/printpreview.cpp
    trunk/Scribus/scribus/ui/scdockpalette.cpp
    trunk/Scribus/scribus/ui/scrpalettebase.cpp

Modified: trunk/Scribus/scribus/canvasmode_eyedropper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/canvasmode_eyedropper.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_eyedropper.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_eyedropper.cpp	Sat Jan 29 22:44:02 2022
@@ -156,7 +156,7 @@
 	QPixmap pm;
 	QScreen *screen = QGuiApplication::primaryScreen();
 	if (screen)
-		pm = screen->grabWindow( QApplication::desktop()->winId(), m->globalPos().x(), m->globalPos().y(), 1, 1);
+		pm = screen->grabWindow(0); // screen()->winId(), m->globalPos().x(), m->globalPos().y(), 1, 1);
 	QImage i = pm.toImage();
 	QColor selectedColor = i.pixel(0, 0);
 

Modified: trunk/Scribus/scribus/plugins/gettext/textfilter/tfdia.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/plugins/gettext/textfilter/tfdia.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/textfilter/tfdia.cpp	(original)
+++ trunk/Scribus/scribus/plugins/gettext/textfilter/tfdia.cpp	Sat Jan 29 22:44:02 2022
@@ -7,18 +7,18 @@
 #include "tfdia.h"
 
 #include <QApplication>
+#include <QBoxLayout>
 #include <QComboBox>
-#include <QDesktopWidget>
 #include <QFrame>
+#include <QHBoxLayout>
 #include <QLineEdit>
+#include <QPixmap>
 #include <QPushButton>
+#include <QRect>
+#include <QScreen>
 #include <QScrollArea>
-#include <QBoxLayout>
-#include <QHBoxLayout>
+#include <QToolTip>
 #include <QVBoxLayout>
-#include <QToolTip>
-#include <QPixmap>
-#include <QRect>
 
 #include "prefsmanager.h"
 #include "prefsfile.h"
@@ -26,6 +26,7 @@
 
 #include "commonstrings.h"
 #include "iconmanager.h"
+#include "scribuscore.h"
 #include "util.h"
 
 tfDia::tfDia()
@@ -39,14 +40,14 @@
 	//Get last window geometry values
 	int vleft   = qMax(0, prefs->getInt("x", 10));
 #if defined(Q_OS_MAC) || defined(_WIN32)
-	int vtop    = qMax(64, prefs->getInt("y", 10));
+	int vtop = qMax(64, prefs->getInt("y", 10));
 #else
-	int vtop    = qMax(0, prefs->getInt("y", 10));
+	int vtop = qMax(0, prefs->getInt("y", 10));
 #endif
 	int vwidth  = qMax(400, prefs->getInt("width", 400));
 	int vheight = qMax(300, prefs->getInt("height", 300));
 	// Check values against current available space
-	QRect scr = QApplication::desktop()->availableGeometry(this);
+	QRect scr = ScCore->primaryMainWindow()->screen()->availableGeometry();
 	if ( vleft >= scr.width() )
 		vleft = 0;
 	if ( vtop >= scr.height() )

Modified: trunk/Scribus/scribus/plugins/picbrowser/imagedialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/plugins/picbrowser/imagedialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/picbrowser/imagedialog.cpp	(original)
+++ trunk/Scribus/scribus/plugins/picbrowser/imagedialog.cpp	Sat Jan 29 22:44:02 2022
@@ -7,15 +7,15 @@
 #include "imagedialog.h"
 
 #include <QApplication>
-#include <QDesktopWidget>
+#include <QScreen>
 
 Imagedialog::Imagedialog ( const QString& imageFile, ScribusDoc* doc , QWidget *parent ) : QDialog ( parent )
 {
 	setupUi ( this );
 	setAttribute ( Qt::WA_DeleteOnClose );
 	setWindowTitle ( imageFile );
-	m_hRatio = double(QApplication::desktop()->logicalDpiX()) / 72.0;
-	m_vRatio = double(QApplication::desktop()->logicalDpiY()) / 72.0;
+	m_hRatio = double(ScCore->primaryMainWindow()->screen()->logicalDpiX()) / 72.0;
+	m_vRatio = double(ScCore->primaryMainWindow()->screen()->logicalDpiY()) / 72.0;
 
 //no realCMYK
 	bool mode=false;

Modified: trunk/Scribus/scribus/plugins/picbrowser/imagedialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/plugins/picbrowser/imagedialog.h
==============================================================================
--- trunk/Scribus/scribus/plugins/picbrowser/imagedialog.h	(original)
+++ trunk/Scribus/scribus/plugins/picbrowser/imagedialog.h	Sat Jan 29 22:44:02 2022
@@ -7,10 +7,13 @@
 #ifndef IMAGEDIALOG_H
 #define IMAGEDIALOG_H
 
+#include <QDialog>
 #include <QScrollArea>
+#include <QString>
 //#include <QMessageBox>
 
 #include "scimage.h"
+#include "scribusdoc.h"
 #include "scribusstructs.h"
 #include "cmsettings.h"
 

Modified: trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outputpreview_pdf.cpp	(original)
+++ trunk/Scribus/scribus/ui/outputpreview_pdf.cpp	Sat Jan 29 22:44:02 2022
@@ -6,8 +6,8 @@
 */
 
 #include <QApplication>
-#include <QDesktopWidget>
 #include <QMap>
+#include <QScreen>
 #include <QTemporaryFile>
 
 #include "outputpreview_pdf.h"
@@ -190,7 +190,7 @@
 	m_uiBase->pageSelector->setGUIForPage(m_doc->currentPage()->pageNr());
 
 	int w = m_previewLabel->width() + inkTableWidth + 50;
-	resize(qMin(QApplication::desktop()->width() - 30, w), 500);
+	resize(qMin(ScCore->primaryMainWindow()->screen()->size().width() - 30, w), 500);
 
 	//signals and slots
 	connect(m_uiBase->pageSelector, SIGNAL(pageChanged(int)), this, SLOT(jumpToPage(int)));

Modified: trunk/Scribus/scribus/ui/outputpreview_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/outputpreview_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outputpreview_ps.cpp	(original)
+++ trunk/Scribus/scribus/ui/outputpreview_ps.cpp	Sat Jan 29 22:44:02 2022
@@ -8,10 +8,10 @@
 #include <algorithm>
 
 #include <QApplication>
-#include <QDesktopWidget>
 #include <QMap>
+#include <QScreen>
+#include <QTemporaryFile>
 #include <QTransform>
-#include <QTemporaryFile>
 
 #include "outputpreview_ps.h"
 #include "commonstrings.h"
@@ -212,7 +212,7 @@
 	m_uiBase->pageSelector->setGUIForPage(m_doc->currentPage()->pageNr());
 
 	int w = m_previewLabel->width() + inkTableWidth + 50;
-	resize(qMin(QApplication::desktop()->width() - 30, w), 500);
+	resize(qMin(ScCore->primaryMainWindow()->screen()->size().width() - 30, w), 500);
 
 	//signals and slots
 	connect(m_uiBase->pageSelector, SIGNAL(pageChanged(int)), this, SLOT(jumpToPage(int)));

Modified: trunk/Scribus/scribus/ui/prefs_display.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/prefs_display.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_display.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_display.cpp	Sat Jan 29 22:44:02 2022
@@ -8,7 +8,7 @@
 #include <QApplication>
 #include <QColor>
 #include <QColorDialog>
-#include <QDesktopWidget>
+#include <QScreen>
 #include <QPainter>
 
 #include "iconmanager.h"
@@ -262,7 +262,7 @@
 void Prefs_Display::restoreDisScale()
 {
 	disconnect(adjustDisplaySlider, SIGNAL(valueChanged(int)), this, SLOT(setDisScale()));
-	int dpi = QApplication::desktop()->logicalDpiX();
+	int dpi = ScCore->primaryMainWindow()->screen()->logicalDotsPerInchX();
 	if ((dpi < 60) || (dpi > 500))
 		dpi = 72;
 	displayScale = dpi / 72.0;

Modified: trunk/Scribus/scribus/ui/printpreview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/printpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/printpreview.cpp	(original)
+++ trunk/Scribus/scribus/ui/printpreview.cpp	Sat Jan 29 22:44:02 2022
@@ -36,6 +36,7 @@
 #include <QPainter>
 #include <QPixmap>
 #include <QPushButton>
+#include <QScreen>
 #include <QScrollArea>
 #include <QSpacerItem>
 #include <QSpinBox>
@@ -245,7 +246,7 @@
 	m_ui->pageSelector->setGUIForPage(m_doc->currentPage()->pageNr());
 
 	int w = m_previewLabel->width() + inkTableWidth + 50;
-	resize(qMin(QApplication::desktop()->width() - 30, w), 500);
+	resize(qMin(ScCore->primaryMainWindow()->screen()->size().width() - 30, w), 500);
 
 	// tooltips
 	m_ui->antiAliasing->setToolTip( "<qt>" + tr( "Provides a more pleasant view of Type 1 fonts, TrueType Fonts, OpenType Fonts, EPS, PDF and vector graphics in the preview, at the expense of a slight slowdown in previewing" ) + "</qt>" );

Modified: trunk/Scribus/scribus/ui/scdockpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/scdockpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scdockpalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/scdockpalette.cpp	Sat Jan 29 22:44:02 2022
@@ -26,10 +26,10 @@
 
 #include <QApplication>
 #include <QCloseEvent>
-#include <QDesktopWidget>
 #include <QHideEvent>
 #include <QMainWindow>
 #include <QPoint>
+#include <QScreen>
 
 #include "iconmanager.h"
 #include "prefscontext.h"
@@ -153,22 +153,19 @@
 	// events as spontaneous events are delivered after dialog has been shown
 	if (m_palettePrefs && !showEvent->spontaneous() && isFloating())
 	{
-		QDesktopWidget *d = QApplication::desktop();
+		QScreen *s = ScCore->primaryMainWindow()->screen();
 		if (m_palettePrefs->contains("left"))
 		{
-			QRect scr = QApplication::desktop()->availableGeometry(this);
+			QRect scr = s->availableGeometry(this);
 			// all palettes should have enough room for 3x3 min widgets
-			int vwidth  = qMin(qMax(0, m_palettePrefs->getInt("width")),
-			                   d->width());
-			int vheight = qMin(qMax(0, m_palettePrefs->getInt("height")),
-			                   d->height());
+			int vwidth  = qMin(qMax(0, m_palettePrefs->getInt("width")), s->width());
+			int vheight = qMin(qMax(0, m_palettePrefs->getInt("height")), s->height());
 			// palettes should not use too much screen space
-			if (vwidth > d->width() / 3 && vheight > d->height()/3)
-				vwidth = d->width() / 3;
+			if (vwidth > s->width() / 3 && vheight > s->height()/3)
+				vwidth = s->width() / 3;
 			// and should be partly visible
-			int vleft   = qMin(qMax(scr.left() - vwidth, m_palettePrefs->getInt("left")),
-							   scr.right());
-			int vtop = qMin(m_palettePrefs->getInt("top"), d->height());
+			int vleft   = qMin(qMax(scr.left() - vwidth, m_palettePrefs->getInt("left")), scr.right());
+			int vtop = qMin(m_palettePrefs->getInt("top"), s->height());
 #if defined(Q_OS_MAC) || defined(_WIN32)
 			// on Mac and Windows you're dead if the titlebar is not on screen
 			vtop    = qMax(64, vtop);
@@ -203,41 +200,37 @@
 
 void ScDockPalette::hide()
 {
-	if (isVisible())
-	{
-		storePosition();
-		storeSize();
-		storeDockState();
-		QDockWidget::hide();
-	}
+	if (!isVisible())
+		return;
+	storePosition();
+	storeSize();
+	storeDockState();
+	QDockWidget::hide();
 }
 
 void ScDockPalette::storePosition()
 {
+	if (!m_palettePrefs)
+		return;
+	QPoint geo = pos();
+	m_palettePrefs->set("left", geo.x());
+	m_palettePrefs->set("top", geo.y());
+}
+
+void ScDockPalette::storePosition(int newX, int newY)
+{
+	if (!m_palettePrefs)
+		return;
+	m_palettePrefs->set("left", newX);
+	m_palettePrefs->set("top", newY);
+}
+
+void ScDockPalette::storeSize()
+{
 	if (m_palettePrefs)
-	{
-		QPoint geo = pos();
-		m_palettePrefs->set("left", geo.x());
-		m_palettePrefs->set("top", geo.y());
-	}
-}
-
-void ScDockPalette::storePosition(int newX, int newY)
-{
-	if (m_palettePrefs)
-	{
-		m_palettePrefs->set("left", newX);
-		m_palettePrefs->set("top", newY);
-	}
-}
-
-void ScDockPalette::storeSize()
-{
-	if (m_palettePrefs)
-	{
-		m_palettePrefs->set("width", width());
-		m_palettePrefs->set("height", height());
-	}
+		return;
+	m_palettePrefs->set("width", width());
+	m_palettePrefs->set("height", height());
 }
 
 void ScDockPalette::storeVisibility(bool vis)
@@ -248,14 +241,13 @@
 
 void ScDockPalette::storeDockState()
 {
-	if (m_palettePrefs)
-	{
-		m_palettePrefs->set("floating", isFloating());
-		Qt::DockWidgetArea area = Qt::NoDockWidgetArea;
-		QMainWindow* mainWindow = qobject_cast<QMainWindow*>(parent());
-		if (mainWindow)
-			area = mainWindow->dockWidgetArea(this);
-		m_palettePrefs->set("area", (int) area);
-	}
-}
-
+	if (!m_palettePrefs)
+		return;
+	m_palettePrefs->set("floating", isFloating());
+	Qt::DockWidgetArea area = Qt::NoDockWidgetArea;
+	QMainWindow* mainWindow = qobject_cast<QMainWindow*>(parent());
+	if (mainWindow)
+		area = mainWindow->dockWidgetArea(this);
+	m_palettePrefs->set("area", (int) area);
+}
+

Modified: trunk/Scribus/scribus/ui/scrpalettebase.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24839&path=/trunk/Scribus/scribus/ui/scrpalettebase.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrpalettebase.cpp	(original)
+++ trunk/Scribus/scribus/ui/scrpalettebase.cpp	Sat Jan 29 22:44:02 2022
@@ -26,14 +26,15 @@
 
 #include <QApplication>
 #include <QCloseEvent>
-#include <QDesktopWidget>
 #include <QHideEvent>
 #include <QPoint>
+#include <QScreen>
 
 #include "iconmanager.h"
 #include "prefscontext.h"
 #include "prefsfile.h"
 #include "prefsmanager.h"
+#include "scribuscore.h"
 #include "scrpalettebase.h"
 #include "util.h"
 
@@ -157,22 +158,19 @@
 	// events as spontaneous events are delivered after dialog has been shown
 	if (m_palettePrefs && !showEvent->spontaneous())
 	{
-		QDesktopWidget *d = QApplication::desktop();
+		QScreen *s = ScCore->primaryMainWindow()->screen();
 		if (m_palettePrefs->contains("left"))
 		{
-			QRect scr = QApplication::desktop()->availableGeometry(this);
+			QRect scr = s->availableGeometry(this);
 			// all palettes should have enough room for 3x3 min widgets
-			int vwidth  = qMin(qMax(0, m_palettePrefs->getInt("width")),
-			                   d->width());
-			int vheight = qMin(qMax(0, m_palettePrefs->getInt("height")),
-			                   d->height());
+			int vwidth  = qMin(qMax(0, m_palettePrefs->getInt("width")), s->width());
+			int vheight = qMin(qMax(0, m_palettePrefs->getInt("height")), s->height());
 			// palettes should not use too much screen space
-			if (vwidth > d->width()/3 && vheight > d->height()/3)
-				vwidth = d->width()/3;
+			if (vwidth > s->width()/3 && vheight > s->height()/3)
+				vwidth = s->width()/3;
 			// and should be partly visible
-			int vleft   = qMin(qMax(scr.left() - vwidth, m_palettePrefs->getInt("left")),
-							   scr.right());
-			int vtop = qMin(m_palettePrefs->getInt("top"), d->height());
+			int vleft   = qMin(qMax(scr.left() - vwidth, m_palettePrefs->getInt("left")), scr.right());
+			int vtop = qMin(m_palettePrefs->getInt("top"), s->height());
 #if defined(Q_OS_MAC) || defined(_WIN32)
 			// on Mac and Windows you're dead if the titlebar is not on screen
 			vtop    = qMax(64, vtop);
@@ -205,12 +203,11 @@
 
 void ScrPaletteBase::hide()
 {
-	if (isVisible())
-	{
-		storePosition();
-		storeSize();
-		QDialog::hide();
-	}
+	if (!isVisible())
+		return;
+	storePosition();
+	storeSize();
+	QDialog::hide();
 }
 
 void ScrPaletteBase::reject()
@@ -221,30 +218,27 @@
 
 void ScrPaletteBase::storePosition()
 {
-	if (m_palettePrefs)
-	{
-		QPoint geo = pos();
-		m_palettePrefs->set("left", geo.x());
-		m_palettePrefs->set("top", geo.y());
-	}
+	if (!m_palettePrefs)
+		return;
+	QPoint geo = pos();
+	m_palettePrefs->set("left", geo.x());
+	m_palettePrefs->set("top", geo.y());
 }
 
 void ScrPaletteBase::storePosition(int newX, int newY)
 {
-	if (m_palettePrefs)
-	{
-		m_palettePrefs->set("left", newX);
-		m_palettePrefs->set("top", newY);
-	}
+	if (!m_palettePrefs)
+		return;
+	m_palettePrefs->set("left", newX);
+	m_palettePrefs->set("top", newY);
 }
 
 void ScrPaletteBase::storeSize()
 {
-	if (m_palettePrefs)
-	{
-		m_palettePrefs->set("width", width());
-		m_palettePrefs->set("height", height());
-	}
+	if (!m_palettePrefs)
+		return;
+	m_palettePrefs->set("width", width());
+	m_palettePrefs->set("height", height());
 }
 
 void ScrPaletteBase::storeVisibility(bool vis)




More information about the scribus-commit mailing list