r18353 by fschmid - Qt5 port: fixed selection rectangle with Qt-5.1.0

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 7 11:37:29 UTC 2013


Author: fschmid
Date: Sun Jul  7 11:37:29 2013
New Revision: 18353

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18353
Log:
Qt5 port: fixed selection rectangle with Qt-5.1.0

Modified:
    trunk/Scribus/scribus/canvasgesture_rectselect.cpp
    trunk/Scribus/scribus/canvasmode_drawbezier.cpp
    trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
    trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/canvasmode_framelinks.cpp
    trunk/Scribus/scribus/canvasmode_magnifier.cpp
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/canvasmode_rotate.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/scribusview.cpp

Modified: trunk/Scribus/scribus/canvasgesture_rectselect.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasgesture_rectselect.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rectselect.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_rectselect.cpp Sun Jul  7 11:37:29 2013
@@ -38,12 +38,12 @@
 void RectSelect::prepare(QPoint start)
 {
 	if (!m_rectangle)
-		m_rectangle = new QRubberBand(QRubberBand::Rectangle);
+		m_rectangle = new QRubberBand(QRubberBand::Rectangle, m_view);
 	setStart(start);
 #ifdef USE_QT5
 	m_rectangle->setWindowOpacity(0.5);
 #endif
-	m_rectangle->setGeometry(m_start.x(), m_start.y(), 1, 1);
+	m_rectangle->setGeometry(QRect(m_view->mapFromGlobal(start), m_view->mapFromGlobal(start)));
 }
 
 void RectSelect::clear()
@@ -71,17 +71,15 @@
 
 void RectSelect::setEnd(QPoint globalPos)
 {
-	m_rectangle->setGeometry(QRect(m_start.x(), 
-								   m_start.y(), 
-								   globalPos.x()-m_start.x(), 
-								   globalPos.y()-m_start.y())
-							 .normalized());	
+	m_rectangle->setGeometry(QRect(m_view->mapFromGlobal(m_start), m_view->mapFromGlobal(globalPos)).normalized());
 }
 
 
 QRectF RectSelect::result() const
-{ 
-	return m_canvas->globalToCanvas(m_rectangle->geometry());
+{
+	QRect geom = m_rectangle->geometry().normalized();
+	geom = QRect(m_view->mapToGlobal(geom.topLeft()), m_view->mapToGlobal(geom.bottomRight()));
+	return m_canvas->globalToCanvas(geom);
 }
 
 void RectSelect::mousePressEvent(QMouseEvent *m)

Modified: trunk/Scribus/scribus/canvasmode_drawbezier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_drawbezier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawbezier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawbezier.cpp Sun Jul  7 11:37:29 2013
@@ -224,14 +224,8 @@
 				newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
 				SeRx = newX;
 				SeRy = newY;
-				/*
-				if (m_doc->appMode == modeDrawTable)
-					m_view->redrawMarker->setGeometry(QRect(Dxp, Dyp, m->globalPos().x() - Dxp, m->globalPos().y() - Dyp).normalized());
-				else
-					m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
-				*/
 				QPoint startP = m_canvas->canvasToGlobal(QPointF(Mxp, Myp));
-				m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+				m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 				if (!m_view->redrawMarker->isVisible())
 					m_view->redrawMarker->show();
 				m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawcalligraphic.cpp Sun Jul  7 11:37:29 2013
@@ -172,7 +172,7 @@
 			SeRx = newX;
 			SeRy = newY;
 			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
-			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();
 			m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_drawfreehand.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_drawfreehand.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_drawfreehand.cpp Sun Jul  7 11:37:29 2013
@@ -160,7 +160,7 @@
 			SeRx = newX;
 			SeRy = newY;
 			QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
-			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();
 			m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Sun Jul  7 11:37:29 2013
@@ -475,11 +475,8 @@
 			newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
 			SeRx = newX;
 			SeRy = newY;
-			/*
-			m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
-			*/
 			QPoint startP = m_canvas->canvasToGlobal(QPointF(Mxp, Myp));
-			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();
 			m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/canvasmode_framelinks.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_framelinks.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_framelinks.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_framelinks.cpp Sun Jul  7 11:37:29 2013
@@ -127,11 +127,8 @@
 	{
 		SeRx = qRound(mousePointDoc.x()); //m_view->translateToDoc(m->x(), m->y()).x());
 		SeRy = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
-		/*
-		m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
-		*/
 		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
-		m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+		m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 		if (!m_view->redrawMarker->isVisible())
 			m_view->redrawMarker->show();
 		m_view->HaveSelRect = true;
@@ -141,8 +138,6 @@
 
 void CanvasMode_FrameLinks::mousePressEvent(QMouseEvent *m)
 {
-// 	const double mouseX = m->globalX();
-// 	const double mouseY = m->globalY();
 	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
 
 	double Rxp = 0;

Modified: trunk/Scribus/scribus/canvasmode_magnifier.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_magnifier.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_magnifier.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_magnifier.cpp Sun Jul  7 11:37:29 2013
@@ -111,8 +111,6 @@
 
 void CanvasMode_Magnifier::mouseMoveEvent(QMouseEvent *m)
 {
-// 	const double mouseX = m->globalX();
-// 	const double mouseY = m->globalY();
 	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
 	
 	m_lastPosWasOverGuide = false;
@@ -126,11 +124,8 @@
 		newY = qRound(Myp + ((SeRx - Mxp) * m_view->visibleHeight()) / m_view->visibleWidth());
 		SeRx = newX;
 		SeRy = newY;
-		/*
-		m_view->redrawMarker->setGeometry(QRect(Mxp, Myp, m->globalPos().x() - Mxp, m->globalPos().y() - Myp).normalized());
-		*/
 		QPoint startP = m_canvas->canvasToGlobal(m_doc->appMode == modeDrawTable2 ? QPointF(Dxp, Dyp) : QPointF(Mxp, Myp));
-		m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+		m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 		if (!m_view->redrawMarker->isVisible())
 			m_view->redrawMarker->show();
 		m_view->HaveSelRect = true;
@@ -201,6 +196,7 @@
 		if (m_view->HaveSelRect)
 		{
 			QRect geom = m_view->redrawMarker->geometry().normalized();
+			geom = QRect(m_view->mapToGlobal(geom.topLeft()), m_view->mapToGlobal(geom.bottomRight()));
 			FPoint nx = m_canvas->globalToCanvas(QPoint(geom.x() + geom.width() / 2, geom.y() + geom.height() / 2));
 			double scaleH = m_view->visibleWidth() / static_cast<double>(qMax(geom.width(), 1));
 			double scaleV = m_view->visibleHeight() / static_cast<double>(qMax(geom.height(), 1));

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Sun Jul  7 11:37:29 2013
@@ -825,7 +825,7 @@
 			newY = qRound(mousePointDoc.y()); //m_view->translateToDoc(m->x(), m->y()).y());
 			m_mouseSavedPoint.setXY(newX, newY);
 			QPoint startP = m_canvas->canvasToGlobal(m_mousePressPoint);
-			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();
 			m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/canvasmode_rotate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/canvasmode_rotate.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_rotate.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_rotate.cpp Sun Jul  7 11:37:29 2013
@@ -445,7 +445,7 @@
 		if ((m_canvas->m_viewMode.m_MouseButtonPressed) && (m->buttons() & Qt::LeftButton))
 		{
 			QPoint startP = m_canvas->canvasToGlobal(m_canvasPressCoord);
-			m_view->redrawMarker->setGeometry(QRect(startP, m->globalPos()).normalized());
+			m_view->redrawMarker->setGeometry(QRect(m_view->mapFromGlobal(startP), m_view->mapFromGlobal(m->globalPos())).normalized());
 			if (!m_view->redrawMarker->isVisible())
 				m_view->redrawMarker->show();
 			m_view->HaveSelRect = true;

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Jul  7 11:37:29 2013
@@ -2234,7 +2234,7 @@
 	double sc = maxSize / qMax(igWidth, igHeight);
 	bool savedFlag = m_Doc->guidesPrefs().framesShown;
 	m_Doc->guidesPrefs().framesShown = false;
-	QImage retImg = QImage(qRound(igWidth * sc), qRound(igHeight * sc), QImage::Format_ARGB32_Premultiplied);
+	QImage retImg = QImage(qMax(qRound(igWidth * sc), 1), qMax(qRound(igHeight * sc), 1), QImage::Format_ARGB32_Premultiplied);
 	retImg.fill( qRgba(0, 0, 0, 0) );
 	ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
 	painter->setZoomFactor(sc);

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18353&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Sun Jul  7 11:37:29 2013
@@ -326,7 +326,7 @@
 	m_previousMode = -1;
 	redrawMode = 0;
 	redrawCount = 0;
-	redrawMarker = new QRubberBand(QRubberBand::Rectangle);
+	redrawMarker = new QRubberBand(QRubberBand::Rectangle, this);
 #ifdef USE_QT5
 	redrawMarker->setWindowOpacity(0.5);
 #endif




More information about the scribus-commit mailing list