r23336 by jghali - Small refactoring + code style fixes

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 6 00:25:15 UTC 2019


Author: jghali
Date: Wed Nov  6 00:25:15 2019
New Revision: 23336

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23336
Log:
Small refactoring + code style fixes

Modified:
    trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp

Modified: trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23336&path=/trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp	Wed Nov  6 00:25:15 2019
@@ -563,8 +563,8 @@
 {
 	if (!m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	disconnect(xposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
-	disconnect(yposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
+	bool sigBlocked1 = xposSpin->blockSignals(true);
+	bool sigBlocked2 = yposSpin->blockSignals(true);
 	bool useLineMode = false;
 	bool tmp = m_haveItem;
 	double inX, inY, b, h, r, dummy1, dummy2;
@@ -620,35 +620,34 @@
 			inY -= m_doc->currentPage()->yOffset();
 		}
 	}
-	xposSpin->setValue(inX*m_unitRatio);
-	yposSpin->setValue(inY*m_unitRatio);
+	xposSpin->setValue(inX * m_unitRatio);
+	yposSpin->setValue(inY * m_unitRatio);
 	if (useLineMode)
 		showWH(m_item->width(), m_item->height());
 	m_haveItem = tmp;
-	connect(xposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
-	connect(yposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
+	xposSpin->blockSignals(sigBlocked1);
+	yposSpin->blockSignals(sigBlocked2);
 }
 
 void PropertiesPalette_XYZ::showWH(double x, double y)
 {
 	if (!m_ScMW || m_ScMW->scriptIsRunning())
 		return;
-	QTransform ma;
-	QPoint dp;
 	bool sigBlocked1 = widthSpin->blockSignals(true);
 	bool sigBlocked2 = heightSpin->blockSignals(true);
 	if ((m_lineMode) && (m_item->asLine()))
 	{
-		ma.translate(static_cast<double>(xposSpin->value()) / m_unitRatio, static_cast<double>(yposSpin->value()) / m_unitRatio);
-		ma.rotate(static_cast<double>(rotationSpin->value())*(-1));
-		dp = QPoint(static_cast<int>(x), static_cast<int>(y)) * ma;
-		widthSpin->setValue(dp.x()*m_unitRatio);
-		heightSpin->setValue(dp.y()*m_unitRatio);
+		QTransform ma;
+		ma.translate(xposSpin->value() / m_unitRatio, yposSpin->value() / m_unitRatio);
+		ma.rotate(rotationSpin->value() * (-1));
+		QPointF dp = QPointF(x, 0.0) * ma;
+		widthSpin->setValue(dp.x() * m_unitRatio);
+		heightSpin->setValue(dp.y() * m_unitRatio);
 	}
 	else
 	{
-		widthSpin->setValue(x*m_unitRatio);
-		heightSpin->setValue(y*m_unitRatio);
+		widthSpin->setValue(x * m_unitRatio);
+		heightSpin->setValue(y * m_unitRatio);
 	}
 	widthSpin->blockSignals(sigBlocked1);
 	heightSpin->blockSignals(sigBlocked2);
@@ -717,8 +716,8 @@
 					w += m_doc->currentPage()->xOffset();
 					h += m_doc->currentPage()->yOffset();
 				}
-				double r = atan2(h-y,w-x)*(180.0/M_PI);
-				w = sqrt(pow(w-x,2)+pow(h-y,2));
+				double r = atan2(h - y, w - x) * (180.0 / M_PI);
+				w = sqrt(pow(w - x, 2) + pow(h - y, 2));
 				m_item->setXYPos(x, m_item->yPos(), true);
 				m_item->setRotation(r, true);
 				m_doc->sizeItem(w, m_item->height(), m_item, true);
@@ -796,8 +795,8 @@
 				w += m_doc->currentPage()->xOffset();
 				h += m_doc->currentPage()->yOffset();
 			}
-			double r = atan2(h-y,w-x)*(180.0/M_PI);
-			w = sqrt(pow(w-x,2)+pow(h-y,2));
+			double r = atan2(h - y, w - x) * (180.0 / M_PI);
+			w = sqrt(pow(w - x, 2) + pow(h - y, 2));
 			m_doc->moveItem(0, y - m_item->yPos(), m_item);
 			m_item->setXYPos(m_item->xPos(), y, true);
 			m_item->setRotation(r, true);
@@ -831,6 +830,88 @@
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	
+	double x, y, w, h, gx, gy, gh, gw;
+	x = xposSpin->value() / m_unitRatio;
+	y = yposSpin->value() / m_unitRatio;
+	w = widthSpin->value() / m_unitRatio;
+	h = heightSpin->value() / m_unitRatio;
+	double oldW = (m_item->width()  != 0.0) ? m_item->width()  : 1.0;
+	double oldH = (m_item->height() != 0.0) ? m_item->height() : 1.0;
+	if (m_doc->m_Selection->isMultipleSelection())
+	{
+		if (!_userActionOn)
+			m_ScMW->view->startGroupTransaction();
+		m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+		if (keepFrameWHRatioButton->isChecked())
+		{
+			m_doc->scaleGroup(w / gw, w / gw, false);
+			showWH(w, (w / gw) * gh);
+		}
+		else
+		{
+			m_doc->scaleGroup(w / gw, 1.0, false);
+			m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+			showWH(gw, gh);
+		}
+		if (!_userActionOn)
+		{
+			m_ScMW->view->endGroupTransaction();
+		}
+	}
+	else
+	{
+		bool oldS = m_item->Sizing;
+		m_item->Sizing = false;
+		m_item->OldB2 = m_item->width();
+		m_item->OldH2 = m_item->height();
+		if (m_item->asLine())
+		{
+			if (m_lineMode)
+			{
+				double r = atan2(h - y, w - x) * (180.0 / M_PI);
+				m_item->setRotation(r, true);
+				w = sqrt(pow(w - x, 2) + pow(h - y, 2));
+			}
+			m_doc->sizeItem(w, m_item->height(), m_item, true, true, false);
+		}
+		else
+		{
+			if (keepFrameWHRatioButton->isChecked())
+			{
+				showWH(w, (w / oldW) * m_item->height());
+				m_doc->sizeItem(w, (w / oldW) * m_item->height(), m_item, true, true, false);
+			}
+			else
+				m_doc->sizeItem(w, m_item->height(), m_item, true, true, false);
+		}
+		if (m_item->isArc())
+		{
+			double dw = w - oldW;
+			double dh = h - oldH;
+			PageItem_Arc* item = m_item->asArc();
+			double dsch = item->arcHeight / oldH;
+			double dscw = item->arcWidth / oldW;
+			item->arcWidth += dw * dscw;
+			item->arcHeight += dh * dsch;
+			item->recalcPath();
+		}
+		if (m_item->isSpiral())
+		{
+			PageItem_Spiral* item = m_item->asSpiral();
+			item->recalcPath();
+		}
+		m_item->Sizing = oldS;
+	}
+	m_doc->changed();
+	m_doc->regionsChanged()->update(QRect());
+	m_ScMW->setStatusBarTextSelectedItemInfo();
+}
+
+void PropertiesPalette_XYZ::handleNewH()
+{
+	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
+		return;
+
 	double x,y,w,h, gx, gy, gh, gw;
 	x = xposSpin->value() / m_unitRatio;
 	y = yposSpin->value() / m_unitRatio;
@@ -845,12 +926,12 @@
 		m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 		if (keepFrameWHRatioButton->isChecked())
 		{
-			m_doc->scaleGroup(w / gw, w / gw, false);
-			showWH(w, (w / gw) * gh);
+			m_doc->scaleGroup(h / gh, h / gh, false);
+			showWH((h / gh) * gw, h);
 		}
 		else
 		{
-			m_doc->scaleGroup(w / gw, 1.0, false);
+			m_doc->scaleGroup(1.0, h / gh, false);
 			m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 			showWH(gw, gh);
 		}
@@ -869,91 +950,9 @@
 		{
 			if (m_lineMode)
 			{
-				double r = atan2(h-y,w-x)*(180.0/M_PI);
+				double r = atan2(h - y, w - x) * (180.0 / M_PI);
 				m_item->setRotation(r, true);
-				w = sqrt(pow(w-x,2)+pow(h-y,2));
-			}
-			m_doc->sizeItem(w, m_item->height(), m_item, true, true, false);
-		}
-		else
-		{
-			if (keepFrameWHRatioButton->isChecked())
-			{
-				showWH(w, (w / oldW) * m_item->height());
-				m_doc->sizeItem(w, (w / oldW) * m_item->height(), m_item, true, true, false);
-			}
-			else
-				m_doc->sizeItem(w, m_item->height(), m_item, true, true, false);
-		}
-		if (m_item->isArc())
-		{
-			double dw = w - oldW;
-			double dh = h - oldH;
-			PageItem_Arc* item = m_item->asArc();
-			double dsch = item->arcHeight / oldH;
-			double dscw = item->arcWidth / oldW;
-			item->arcWidth += dw * dscw;
-			item->arcHeight += dh * dsch;
-			item->recalcPath();
-		}
-		if (m_item->isSpiral())
-		{
-			PageItem_Spiral* item = m_item->asSpiral();
-			item->recalcPath();
-		}
-		m_item->Sizing = oldS;
-	}
-	m_doc->changed();
-	m_doc->regionsChanged()->update(QRect());
-	m_ScMW->setStatusBarTextSelectedItemInfo();
-}
-
-void PropertiesPalette_XYZ::handleNewH()
-{
-	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
-		return;
-
-	double x,y,w,h, gx, gy, gh, gw;
-	x = xposSpin->value() / m_unitRatio;
-	y = yposSpin->value() / m_unitRatio;
-	w = widthSpin->value() / m_unitRatio;
-	h = heightSpin->value() / m_unitRatio;
-	double oldW = (m_item->width()  != 0.0) ? m_item->width()  : 1.0;
-	double oldH = (m_item->height() != 0.0) ? m_item->height() : 1.0;
-	if (m_doc->m_Selection->isMultipleSelection())
-	{
-		if (!_userActionOn)
-			m_ScMW->view->startGroupTransaction();
-		m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-		if (keepFrameWHRatioButton->isChecked())
-		{
-			m_doc->scaleGroup(h / gh, h / gh, false);
-			showWH((h / gh) * gw, h);
-		}
-		else
-		{
-			m_doc->scaleGroup(1.0, h / gh, false);
-			m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
-			showWH(gw, gh);
-		}
-		if (!_userActionOn)
-		{
-			m_ScMW->view->endGroupTransaction();
-		}
-	}
-	else
-	{
-		bool oldS = m_item->Sizing;
-		m_item->Sizing = false;
-		m_item->OldB2 = m_item->width();
-		m_item->OldH2 = m_item->height();
-		if (m_item->asLine())
-		{
-			if (m_lineMode)
-			{
-				double r = atan2(h-y,w-x)*(180.0/M_PI);
-				m_item->setRotation(r, true);
-				w = sqrt(pow(w-x,2)+pow(h-y,2));
+				w = sqrt(pow(w - x, 2) + pow(h - y, 2));
 			}
 			m_doc->sizeItem(w, m_item->height(), m_item, true, true, false);
 		}




More information about the scribus-commit mailing list