r14389 by cbradney - Add init utility function to colorcombo and hence remove duplicate code, remove colorcombo.h from propertiespalette.h to reduce build dependencies

scribus-commit scribus-commit at lists.scribus.net
Wed Dec 9 22:25:31 CET 2009


Revision: 14389
Author: cbradney
Date: 2009-12-09T10:42:55.568192Z
Commit message: Add init utility function to colorcombo and hence remove duplicate code, remove colorcombo.h from propertiespalette.h to reduce build dependencies

Changeset: 
M  /trunk/Scribus/scribus/ui/propertiespalette.cpp
M  /trunk/Scribus/scribus/ui/colorcombo.cpp
M  /trunk/Scribus/scribus/ui/prefs_itemtools.cpp
M  /trunk/Scribus/scribus/ui/propertiespalette.h
M  /trunk/Scribus/scribus/ui/colorcombo.h
M  /trunk/Scribus/scribus/ui/smlinestyle.cpp

Diffs:
Index: scribus/ui/prefs_itemtools.cpp
===================================================================
--- scribus/ui/prefs_itemtools.cpp	(revision 14388)
+++ scribus/ui/prefs_itemtools.cpp	(revision 14389)
@@ -76,58 +76,13 @@
 	}
 
 	textSizeSpinBox->setValue(prefsData->itemToolPrefs.textSize / 10);
-
-	textColorComboBox->clear();
-	textColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.textColor == CommonStrings::None)
-		textColorComboBox->setCurrentIndex(textColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		textColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.textColor)
-			textColorComboBox->setCurrentIndex(textColorComboBox->count()-1);
-	}
-
+	textColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textColor);
 	textColorShadingSpinBox->setValue(prefsData->itemToolPrefs.textShade);
-
-	textStrokeColorComboBox->clear();
-	textStrokeColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.textStrokeColor == CommonStrings::None)
-		textStrokeColorComboBox->setCurrentIndex(textStrokeColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		textStrokeColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.textStrokeColor)
-			textStrokeColorComboBox->setCurrentIndex(textStrokeColorComboBox->count()-1);
-	}
+	textStrokeColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textStrokeColor);
 	textStrokeShadingSpinBox->setValue(prefsData->itemToolPrefs.textStrokeShade);
-
-	textFrameFillColorComboBox->clear();
-	textFrameFillColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.textFillColor == CommonStrings::None)
-		textFrameFillColorComboBox->setCurrentIndex(textFrameFillColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		textFrameFillColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.textFillColor)
-			textFrameFillColorComboBox->setCurrentIndex(textFrameFillColorComboBox->count()-1);
-	}
+	textFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textFillColor);
 	textFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.textFillColorShade);
-
-	textFrameLineColorComboBox->clear();
-	textFrameLineColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.textLineColor == CommonStrings::None)
-		textFrameLineColorComboBox->setCurrentIndex(textFrameLineColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		textFrameLineColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.textLineColor)
-			textFrameLineColorComboBox->setCurrentIndex(textFrameLineColorComboBox->count()-1);
-	}
+	textFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textLineColor);
 	textFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.textLineColorShade);
 
 	textTabFillCharComboBox->clear();
@@ -187,19 +142,8 @@
 	imageVerticalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleY * 100));
 
 	imageKeepAspectRatioCheckBox->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
+	imageFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageFillColor);
 
-	imageFrameFillColorComboBox->clear();
-	imageFrameFillColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.imageFillColor == CommonStrings::None)
-		imageFrameFillColorComboBox->setCurrentIndex(imageFrameFillColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		imageFrameFillColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.imageFillColor)
-			imageFrameFillColorComboBox->setCurrentIndex(imageFrameFillColorComboBox->count()-1);
-	}
-
 	imageFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.imageFillColorShade );
 	imageUseEmbeddedClippingPathCheckBox->setChecked(prefsData->itemToolPrefs.imageUseEmbeddedPath);
 	switch (prefsData->itemToolPrefs.imageLowResType)
@@ -216,31 +160,9 @@
 	}
 
 	//Shape Tool
-	shapeFrameLineColorComboBox->clear();
-	shapeFrameLineColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.shapeLineColor == CommonStrings::None)
-		shapeFrameLineColorComboBox->setCurrentIndex(shapeFrameLineColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		shapeFrameLineColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.shapeLineColor)
-			shapeFrameLineColorComboBox->setCurrentIndex(shapeFrameLineColorComboBox->count()-1);
-	}
+	shapeFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeLineColor);
 	shapeFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.shapeLineColorShade);
-
-	shapeFrameFillColorComboBox->clear();
-	shapeFrameFillColorComboBox->addItem( tr("None"));
-	if (prefsData->itemToolPrefs.shapeFillColor == CommonStrings::None)
-		shapeFrameFillColorComboBox->setCurrentIndex(shapeFrameFillColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		shapeFrameFillColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.shapeFillColor)
-			shapeFrameFillColorComboBox->setCurrentIndex(shapeFrameFillColorComboBox->count()-1);
-	}
-
+	shapeFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.shapeFillColor);
 	shapeFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.shapeFillColorShade);
 	shapeFrameLineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.shapeLineStyle) - 1);
 	shapeLineWidthSpinBox->setValue(prefsData->itemToolPrefs.shapeLineWidth);
@@ -264,17 +186,8 @@
 
 
 	//Line Tool
-	lineFillColorComboBox->clear();
-	lineFillColorComboBox->addItem(CommonStrings::tr_NoneColor);
-	if (prefsData->itemToolPrefs.lineColor == CommonStrings::None)
-		lineFillColorComboBox->setCurrentIndex(lineFillColorComboBox->count()-1);
-	endOfColorList=colorList->end();
-	for (itc = colorList->begin(); itc != endOfColorList; ++itc)
-	{
-		lineFillColorComboBox->insertFancyItem( itc.value(), m_doc, itc.key() );
-		if (itc.key() == prefsData->itemToolPrefs.lineColor)
-			lineFillColorComboBox->setCurrentIndex(lineFillColorComboBox->count()-1);
-	}
+	lineFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.lineColor);
+
 	lineFillColorShadingSpinBox->setValue(prefsData->itemToolPrefs.lineColorShade);
 	lineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.lineStyle) - 1);
 	if (m_doc != 0)
Index: scribus/ui/colorcombo.h
===================================================================
--- scribus/ui/colorcombo.h	(revision 14388)
+++ scribus/ui/colorcombo.h	(revision 14389)
@@ -69,6 +69,7 @@
 	void insertSmallItem( const ScColor& col, ScribusDoc* doc, const QString& colName );
 	void insertWideItem ( const ScColor& col, ScribusDoc* doc, const QString& colName );
 	void insertFancyItem( const ScColor& col, ScribusDoc* doc, const QString& colName );
+	void initColorList(ColorList* colorList, ScribusDoc* doc, QString colorValue);
 };
 
 #endif
Index: scribus/ui/colorcombo.cpp
===================================================================
--- scribus/ui/colorcombo.cpp	(revision 14388)
+++ scribus/ui/colorcombo.cpp	(revision 14389)
@@ -99,3 +99,17 @@
 		clb->addItem( new ColorPixmapItem(ColorPixmapValue(col, doc, colName)), ColorListBox::fancyPixmap );
 }
 
+void ColorCombo::initColorList(ColorList *colorList, ScribusDoc *doc, QString colorValue)
+{
+	clear();
+	addItem(CommonStrings::tr_NoneColor);
+	if (colorValue == CommonStrings::None)
+		setCurrentIndex(count()-1);
+	ColorList::Iterator endOfColorList(colorList->end());
+	for (ColorList::Iterator itc = colorList->begin(); itc != endOfColorList; ++itc)
+	{
+		insertFancyItem( itc.value(), doc, itc.key() );
+		if (itc.key() == colorValue)
+			setCurrentIndex(count()-1);
+	}
+}
Index: scribus/ui/smlinestyle.cpp
===================================================================
--- scribus/ui/smlinestyle.cpp	(revision 14388)
+++ scribus/ui/smlinestyle.cpp	(revision 14389)
@@ -7,6 +7,7 @@
 
 #include <QEvent>
 
+#include "colorcombo.h"
 #include "smlinestyle.h"
 #include "smlinestylewidget.h"
 #include "scribus.h"
Index: scribus/ui/propertiespalette.h
===================================================================
--- scribus/ui/propertiespalette.h	(revision 14388)
+++ scribus/ui/propertiespalette.h	(revision 14389)
@@ -41,8 +41,6 @@
 #include "linkbutton.h"
 #include "linecombo.h"
 #include "spalette.h"
-#include "fontcombo.h"
-#include "colorcombo.h"
 #include "alignselect.h"
 #include "shadebutton.h"
 #include "sclistboxpixmap.h"
@@ -61,6 +59,8 @@
 class DashEditor;
 class Selection;
 class BasePointWidget;
+class ColorCombo;
+class FontComboH;
 
 
 struct SCRIBUS_API LineFormatValue
Index: scribus/ui/propertiespalette.cpp
===================================================================
--- scribus/ui/propertiespalette.cpp	(revision 14388)
+++ scribus/ui/propertiespalette.cpp	(revision 14389)
@@ -71,6 +71,8 @@
 #include "util_math.h"
 #include "text/nlsconfig.h"
 #include "dasheditor.h"
+#include "fontcombo.h"
+#include "colorcombo.h"
 
 //using namespace std;
 




More information about the scribus-commit mailing list