r24359 by jghali - In ArrowChooser, use a proper enum class to describe arrow direction instead of a less readable boolean parameter

scribus-commit scribus-commit at lists.scribus.net
Mon Dec 28 21:03:46 UTC 2020


Author: jghali
Date: Mon Dec 28 21:03:46 2020
New Revision: 24359

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24359
Log:
In ArrowChooser, use a proper enum class to describe arrow direction instead of a less readable boolean parameter

Modified:
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/ui/arrowchooser.cpp
    trunk/Scribus/scribus/ui/arrowchooser.h
    trunk/Scribus/scribus/ui/prefs_itemtools.cpp
    trunk/Scribus/scribus/ui/propertiespalette_line.cpp

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24359&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h	(original)
+++ trunk/Scribus/scribus/scribusstructs.h	Mon Dec 28 21:03:46 2020
@@ -175,6 +175,12 @@
 	Bullet(QString n, QString ch) : name(n), charStr(ch), indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(nullptr) {}
 	Bullet(QString n, QString ch, double first, double ind, double tab, CharStyle* chStyle)
 	    { name = n; charStr = ch, firstLineIndent = first; indent = ind; tabPosition = tab; style = chStyle; }
+};
+
+enum class ArrowDirection
+{
+	StartArrow = 0,
+	EndArrow
 };
 
 struct ArrowDesc

Modified: trunk/Scribus/scribus/ui/arrowchooser.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24359&path=/trunk/Scribus/scribus/ui/arrowchooser.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/arrowchooser.cpp	(original)
+++ trunk/Scribus/scribus/ui/arrowchooser.cpp	Mon Dec 28 21:03:46 2020
@@ -16,18 +16,18 @@
 #include "scribusstructs.h"
 #include "util_math.h"
 
-ArrowChooser::ArrowChooser(QWidget* pa, bool direction) : QComboBox(pa)
+ArrowChooser::ArrowChooser(QWidget* pa, ArrowDirection direction) : QComboBox(pa)
 {
 	setEditable(false);
 	clear();
 	setIconSize(QSize(22, 22));
 	addItem(CommonStrings::tr_None);
-	setStartDirection(direction);
+	setArrowDirection(direction);
 }
 
-void ArrowChooser::setStartDirection(bool direction)
+void ArrowChooser::setArrowDirection(ArrowDirection direction)
 {
-	arrowDirection = direction;
+	m_arrowDirection = direction;
 }
 
 void ArrowChooser::rebuildList(QList<ArrowDesc> *arrowStyles)
@@ -57,7 +57,7 @@
 		FPoint max = path.widthHeight();
 		QTransform mm;
 		QTransform mm2;
-		if (arrowDirection)
+		if (m_arrowDirection == ArrowDirection::StartArrow)
 		{
 			mm2.scale(-1, 1);
 			mm2.translate(-max.x(), 0);

Modified: trunk/Scribus/scribus/ui/arrowchooser.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24359&path=/trunk/Scribus/scribus/ui/arrowchooser.h
==============================================================================
--- trunk/Scribus/scribus/ui/arrowchooser.h	(original)
+++ trunk/Scribus/scribus/ui/arrowchooser.h	Mon Dec 28 21:03:46 2020
@@ -8,23 +8,24 @@
 #define ARROWCHOOSER_H
 
 #include <QComboBox>
-#include "scribusapi.h"
 #include <QList>
 
-struct ArrowDesc;
+#include "scribusapi.h"
+#include "scribusstructs.h"
 
 class SCRIBUS_API ArrowChooser : public QComboBox
 {
     Q_OBJECT
 
 public:
-	ArrowChooser(QWidget* pa, bool direction=true);
+	ArrowChooser(QWidget* pa, ArrowDirection direction = ArrowDirection::StartArrow);
 	~ArrowChooser() {};
+
 	void rebuildList(QList<ArrowDesc> *arrowStyles);
-	void setStartDirection(bool);
+	void setArrowDirection(ArrowDirection direction);
 
 private:
-	bool arrowDirection;
+	ArrowDirection m_arrowDirection { ArrowDirection::StartArrow };
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/prefs_itemtools.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24359&path=/trunk/Scribus/scribus/ui/prefs_itemtools.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_itemtools.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_itemtools.cpp	Mon Dec 28 21:03:46 2020
@@ -34,7 +34,7 @@
 	m_caption = tr("Item Tools");
 	m_icon = "tools_16.png";
 
-	lineEndArrowComboBox->setStartDirection(false);
+	lineEndArrowComboBox->setArrowDirection(ArrowDirection::EndArrow);
 	shapeLineWidthSpinBox->setNewUnit(0);
 	shapeLineWidthSpinBox->setMaximum(36);
 	shapeLineWidthSpinBox->setDecimals(1);

Modified: trunk/Scribus/scribus/ui/propertiespalette_line.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24359&path=/trunk/Scribus/scribus/ui/propertiespalette_line.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_line.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertiespalette_line.cpp	Mon Dec 28 21:03:46 2020
@@ -47,12 +47,14 @@
 	startArrowLabel->setBuddy(startArrow);
 	endArrowLabel->setBuddy(endArrow);
 
-	startArrowScale->setMaximum( 1000 );
-	startArrowScale->setMinimum( 1 );
+	startArrow->setArrowDirection(ArrowDirection::StartArrow);
+	startArrowScale->setMaximum(1000);
+	startArrowScale->setMinimum(1);
 	startArrowScale->setDecimals(0);
 
-	endArrowScale->setMaximum( 1000 );
-	endArrowScale->setMinimum( 1 );
+	endArrow->setArrowDirection(ArrowDirection::EndArrow);
+	endArrowScale->setMaximum(1000);
+	endArrowScale->setMinimum(1);
 	endArrowScale->setDecimals(0);
 
 	lineWidthLabel->setBuddy(lineWidth);




More information about the scribus-commit mailing list