r14385 by cbradney - A few more working widgets on the item tools dialog

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 8 21:05:27 CET 2009


Revision: 14385
Author: cbradney
Date: 2009-12-08T09:28:52.858559Z
Commit message: A few more working widgets on the item tools dialog

Changeset: 
M  /trunk/Scribus/scribus/ui/arrowchooser.cpp
M  /trunk/Scribus/scribus/ui/prefs_itemtools.cpp
M  /trunk/Scribus/scribus/ui/arrowchooser.h
M  /trunk/Scribus/scribus/ui/prefs_itemtools.h
M  /trunk/Scribus/scribus/ui/prefs_itemtoolsbase.ui

Diffs:
Index: scribus/ui/prefs_itemtools.cpp
===================================================================
--- scribus/ui/prefs_itemtools.cpp	(revision 14384)
+++ scribus/ui/prefs_itemtools.cpp	(revision 14385)
@@ -6,14 +6,32 @@
 */
 
 #include "ui/prefs_itemtools.h"
+#include "ui/arrowchooser.h"
 #include "prefsstructs.h"
 #include "scrspinbox.h"
+#include "scribusdoc.h"
 #include "units.h"
+//#include "colorcombo.h"
+//#include "colorlistbox.h"
+#include "commonstrings.h"
+#include "prefsmanager.h"
 
 Prefs_ItemTools::Prefs_ItemTools(QWidget* parent)
-	: Prefs_Pane(parent)
+	: Prefs_Pane(parent),
+	m_doc(NULL)
 {
 	setupUi(this);
+	lineEndArrowComboBox->setStartDirection(false);
+	shapeLineWidthSpinBox->setNewUnit(0);
+	lineWidthSpinBox->setNewUnit(0);
+	shapeLineWidthSpinBox->setMaximum(36);
+	lineWidthSpinBox->setMaximum(36);
+	shapeLineWidthSpinBox->setDecimals(1);
+	lineWidthSpinBox->setDecimals(1);
+	shapeLineWidthSpinBox->setSpecialValueText( tr("Hairline"));
+	lineWidthSpinBox->setSpecialValueText( tr("Hairline"));
+
+
 	languageChange();
 }
 
@@ -33,8 +51,16 @@
 
 void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData)
 {
+	enableSignals(false);
 	int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
 	unitChange(docUnitIndex);
+
+	PrefsManager* prefsManager=PrefsManager::instance();
+	ColorList::Iterator itc, endOfColorList;
+	//ColorList* colorList = (docu != 0) ? (&docu->PageColors) : prefsManager->colorSetPtr();
+	ColorList* colorList = prefsManager->colorSetPtr();
+
+
 	/*
 	textFrameFillColorComboBox
 			textFrameLineColorComboBox
@@ -67,13 +93,8 @@
 			onscreenResolutionNormalRadioButton
 			onscreenResolutionLowRadioButton
 
-			shapeFrameFillColorComboBox
-			shapeFrameLineColorComboBox
-			shapeFrameLineStyleComboBox
-			shapeLineWidthSpinBox
-			shapeFrameFillShadingSpinBox
-			shapeFrameLineShadingSpinBox
-
+*/
+/*
 			polygonCornerCountSpinBox
 			polygonRotationSpinBox
 			applyFactorCheckBox
@@ -83,19 +104,169 @@
 			polygonCurvatureSlider
 			polygonPreviewWidet
 
-			lineFillColorComboBox
-			lineStyleComboBox
-			lineWidthSpinBox
-			lineStartArrowComboBox
-			lineEndArrowComboBox
-			lineFillColorShadingSpinBox
+			*/
 
 
+	//Shape Tool
 
+//			shapeFrameFillColorComboBox
+//			shapeFrameLineColorComboBox
+//			shapeFrameLineStyleComboBox
+//			shapeLineWidthSpinBox
+//			shapeFrameFillShadingSpinBox
+//			shapeFrameLineShadingSpinBox
 
-			*/
+
+
+
+	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);
+	}
+	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);
+	}
+
+	shapeFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.shapeFillColorShade);
+	shapeFrameLineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.shapeLineStyle) - 1);
+	shapeLineWidthSpinBox->setValue(prefsData->itemToolPrefs.shapeLineWidth);
+
+	//Polygon Tool
+//	polygonCornerCountSpinBox
+//	polygonRotationSpinBox
+//	applyFactorCheckBox
+//	polygonFactorSpinBox
+//	polygonFactorSlider
+//	polygonCurvatureSpinBox
+//	polygonCurvatureSlider
+//
+//
+//	prefsData->polyCorners,
+//									   prefsData->polyFactorGuiVal,
+//									   prefsData->polyFactor,
+//									   prefsData->polyUseFactor,
+//									   prefsData->polyRotation,
+//									   prefsData->polyCurvature
+
+
+	//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);
+	}
+	lineFillColorShadingSpinBox->setValue(prefsData->itemToolPrefs.lineColorShade);
+	lineStyleComboBox->setCurrentIndex(static_cast<int>(prefsData->itemToolPrefs.lineStyle) - 1);
+	if (m_doc != 0)
+	{
+		lineStartArrowComboBox->rebuildList(&m_doc->arrowStyles);
+		lineEndArrowComboBox->rebuildList(&m_doc->arrowStyles);
+	}
+	else
+	{
+		lineStartArrowComboBox->rebuildList(&prefsData->arrowStyles);
+		lineEndArrowComboBox->rebuildList(&prefsData->arrowStyles);
+	}
+	lineStartArrowComboBox->setCurrentIndex(prefsData->itemToolPrefs.lineStartArrow);
+	lineEndArrowComboBox->setCurrentIndex(prefsData->itemToolPrefs.lineEndArrow);
+	lineWidthSpinBox->setValue(prefsData->itemToolPrefs.lineWidth);
+	//
+
+
+	enableSignals(true);
 }
 
 void Prefs_ItemTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
 {
+
+	//Shape tool
+	prefsData->itemToolPrefs.shapeLineColor = shapeFrameLineColorComboBox->currentText();
+	if (prefsData->itemToolPrefs.shapeLineColor == CommonStrings::tr_NoneColor)
+		prefsData->itemToolPrefs.shapeLineColor = CommonStrings::None;
+	prefsData->itemToolPrefs.shapeFillColor = shapeFrameFillColorComboBox->currentText();
+	if (prefsData->itemToolPrefs.shapeFillColor == CommonStrings::tr_NoneColor)
+		prefsData->itemToolPrefs.shapeFillColor = CommonStrings::None;
+	prefsData->itemToolPrefs.shapeFillColorShade = shapeFrameFillShadingSpinBox->value();
+	prefsData->itemToolPrefs.shapeLineColorShade = shapeFrameLineShadingSpinBox->value();
+	prefsData->itemToolPrefs.shapeLineStyle = static_cast<Qt::PenStyle>(shapeFrameLineStyleComboBox->currentIndex()) + 1;
+	prefsData->itemToolPrefs.shapeLineWidth = shapeLineWidthSpinBox->value();
+
+
+
+	//Polygon Tool
+//	polygonCornerCountSpinBox
+//	polygonRotationSpinBox
+//	applyFactorCheckBox
+//	polygonFactorSpinBox
+//	polygonFactorSlider
+//	polygonCurvatureSpinBox
+//	polygonCurvatureSlider
+//	polygonPreviewWidet
+
+	//Line Tool
+	prefsData->itemToolPrefs.lineColor = lineFillColorComboBox->currentText();
+	if (prefsData->itemToolPrefs.lineColor == CommonStrings::tr_NoneColor)
+		prefsData->itemToolPrefs.lineColor = CommonStrings::None;
+	prefsData->itemToolPrefs.lineColorShade = lineFillColorShadingSpinBox->value();
+	prefsData->itemToolPrefs.lineStyle = static_cast<Qt::PenStyle>(lineStyleComboBox->currentIndex()) + 1;
+	prefsData->itemToolPrefs.lineWidth = lineWidthSpinBox->value();
+	prefsData->itemToolPrefs.lineStartArrow = lineStartArrowComboBox->currentIndex();
+	prefsData->itemToolPrefs.lineEndArrow = lineEndArrowComboBox->currentIndex();
 }
+
+void Prefs_ItemTools::enableSignals(bool on)
+{
+	if (on)
+	{
+//		connect(fontComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		connect(sizeComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		connect(colorComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		connect(colorComboTextBackground, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		connect(shadingTextBack, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+//		connect(shadingText, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+//		connect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
+//		connect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
+//		connect(chainButton, SIGNAL(clicked()), this, SLOT(toggleChain()));
+//		connect(scalingHorizontal, SIGNAL(valueChanged(int)), this, SLOT(hChange()));
+//		connect(scalingVertical, SIGNAL(valueChanged(int)), this, SLOT(vChange()));
+//		connect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
+	}
+	else
+	{
+//		disconnect(fontComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		disconnect(sizeComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		disconnect(colorComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		disconnect(colorComboTextBackground, SIGNAL(activated(int)), this, SLOT(setSample()));
+//		disconnect(shadingTextBack, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+//		disconnect(shadingText, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+//		disconnect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
+//		disconnect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
+//		disconnect(chainButton, SIGNAL(clicked()), this, SLOT(toggleChain()));
+//		disconnect(scalingHorizontal, SIGNAL(valueChanged(int)), this, SLOT(hChange()));
+//		disconnect(scalingVertical, SIGNAL(valueChanged(int)), this, SLOT(vChange()));
+//		disconnect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
+	}
+}
Index: scribus/ui/arrowchooser.cpp
===================================================================
--- scribus/ui/arrowchooser.cpp	(revision 14384)
+++ scribus/ui/arrowchooser.cpp	(revision 14385)
@@ -13,12 +13,17 @@
 #include "commonstrings.h"
 #include "scribusstructs.h"
 
-ArrowChooser::ArrowChooser(QWidget* pa, bool direction)  : QComboBox(pa)
+ArrowChooser::ArrowChooser(QWidget* pa, bool direction) : QComboBox(pa)
 {
 	setEditable(false);
 	clear();
 	setIconSize(QSize(22, 22));
 	addItem(CommonStrings::tr_None);
+	setStartDirection(direction);
+}
+
+void ArrowChooser::setStartDirection(bool direction)
+{
 	arrowDirection = direction;
 }
 
Index: scribus/ui/prefs_itemtoolsbase.ui
===================================================================
--- scribus/ui/prefs_itemtoolsbase.ui	(revision 14384)
+++ scribus/ui/prefs_itemtoolsbase.ui	(revision 14385)
@@ -123,7 +123,7 @@
                 <widget class="QSpinBox" name="textTabWidthSpinBox"/>
                </item>
                <item row="0" column="1">
-                <widget class="QComboBox" name="textFrameFillColorComboBox"/>
+                <widget class="ColorCombo" name="textFrameFillColorComboBox"/>
                </item>
                <item row="0" column="0">
                 <widget class="QLabel" name="label_30">
@@ -140,7 +140,7 @@
                 </widget>
                </item>
                <item row="1" column="1">
-                <widget class="QComboBox" name="textFrameLineColorComboBox"/>
+                <widget class="ColorCombo" name="textFrameLineColorComboBox"/>
                </item>
               </layout>
              </item>
@@ -249,7 +249,7 @@
                   </widget>
                  </item>
                  <item row="0" column="1">
-                  <widget class="QComboBox" name="textFontComboBox"/>
+                  <widget class="FontCombo" name="textFontComboBox"/>
                  </item>
                  <item row="1" column="0">
                   <widget class="QLabel" name="label_4">
@@ -273,7 +273,7 @@
                   </widget>
                  </item>
                  <item row="0" column="1">
-                  <widget class="QComboBox" name="textColorComboBox"/>
+                  <widget class="ColorCombo" name="textColorComboBox"/>
                  </item>
                  <item row="1" column="0">
                   <widget class="QLabel" name="label_6">
@@ -283,7 +283,7 @@
                   </widget>
                  </item>
                  <item row="1" column="1">
-                  <widget class="QComboBox" name="textStrokeColorComboBox"/>
+                  <widget class="ColorCombo" name="textStrokeColorComboBox"/>
                  </item>
                 </layout>
                </item>
@@ -458,7 +458,7 @@
             </widget>
            </item>
            <item row="0" column="1">
-            <widget class="QComboBox" name="imageFrameFillColorComboBox"/>
+            <widget class="ColorCombo" name="imageFrameFillColorComboBox"/>
            </item>
            <item row="1" column="0">
             <widget class="QLabel" name="label_26">
@@ -468,7 +468,7 @@
             </widget>
            </item>
            <item row="1" column="1">
-            <widget class="QComboBox" name="imageFrameLineColorComboBox"/>
+            <widget class="ColorCombo" name="imageFrameLineColorComboBox"/>
            </item>
           </layout>
          </item>
@@ -750,7 +750,7 @@
             </widget>
            </item>
            <item row="0" column="1">
-            <widget class="QComboBox" name="shapeFrameFillColorComboBox"/>
+            <widget class="ColorCombo" name="shapeFrameFillColorComboBox"/>
            </item>
            <item row="1" column="0">
             <widget class="QLabel" name="label_28">
@@ -760,7 +760,7 @@
             </widget>
            </item>
            <item row="1" column="1">
-            <widget class="QComboBox" name="shapeFrameLineColorComboBox"/>
+            <widget class="ColorCombo" name="shapeFrameLineColorComboBox"/>
            </item>
            <item row="2" column="0">
             <widget class="QLabel" name="label_7">
@@ -777,10 +777,10 @@
             </widget>
            </item>
            <item row="2" column="1">
-            <widget class="QComboBox" name="shapeFrameLineStyleComboBox"/>
+            <widget class="LineCombo" name="shapeFrameLineStyleComboBox"/>
            </item>
            <item row="3" column="1">
-            <widget class="QSpinBox" name="shapeLineWidthSpinBox"/>
+            <widget class="ScrSpinBox" name="shapeLineWidthSpinBox"/>
            </item>
           </layout>
          </item>
@@ -817,10 +817,24 @@
             </widget>
            </item>
            <item row="1" column="1">
-            <widget class="QSpinBox" name="shapeFrameLineShadingSpinBox"/>
+            <widget class="QSpinBox" name="shapeFrameLineShadingSpinBox">
+             <property name="suffix">
+              <string> %</string>
+             </property>
+             <property name="maximum">
+              <number>100</number>
+             </property>
+            </widget>
            </item>
            <item row="0" column="1">
-            <widget class="QSpinBox" name="shapeFrameFillShadingSpinBox"/>
+            <widget class="QSpinBox" name="shapeFrameFillShadingSpinBox">
+             <property name="suffix">
+              <string> %</string>
+             </property>
+             <property name="maximum">
+              <number>100</number>
+             </property>
+            </widget>
            </item>
           </layout>
          </item>
@@ -1026,7 +1040,7 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="QComboBox" name="lineFillColorComboBox"/>
+           <widget class="ColorCombo" name="lineFillColorComboBox"/>
           </item>
           <item row="1" column="0">
            <widget class="QLabel" name="label_36">
@@ -1036,7 +1050,7 @@
            </widget>
           </item>
           <item row="1" column="1">
-           <widget class="QComboBox" name="lineStyleComboBox"/>
+           <widget class="LineCombo" name="lineStyleComboBox"/>
           </item>
           <item row="2" column="0">
            <widget class="QLabel" name="label_37">
@@ -1046,7 +1060,7 @@
            </widget>
           </item>
           <item row="2" column="1">
-           <widget class="QSpinBox" name="lineWidthSpinBox"/>
+           <widget class="ScrSpinBox" name="lineWidthSpinBox"/>
           </item>
           <item row="3" column="0">
            <widget class="QLabel" name="label_34">
@@ -1063,10 +1077,10 @@
            </widget>
           </item>
           <item row="3" column="1">
-           <widget class="QComboBox" name="lineStartArrowComboBox"/>
+           <widget class="ArrowChooser" name="lineStartArrowComboBox"/>
           </item>
           <item row="4" column="1">
-           <widget class="QComboBox" name="lineEndArrowComboBox"/>
+           <widget class="ArrowChooser" name="lineEndArrowComboBox"/>
           </item>
          </layout>
         </item>
@@ -1075,9 +1089,12 @@
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
+          <property name="sizeType">
+           <enum>QSizePolicy::Minimum</enum>
+          </property>
           <property name="sizeHint" stdset="0">
            <size>
-            <width>40</width>
+            <width>20</width>
             <height>20</height>
            </size>
           </property>
@@ -1096,7 +1113,14 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="QSpinBox" name="lineFillColorShadingSpinBox"/>
+           <widget class="QSpinBox" name="lineFillColorShadingSpinBox">
+            <property name="suffix">
+             <string> %</string>
+            </property>
+            <property name="maximum">
+             <number>100</number>
+            </property>
+           </widget>
           </item>
          </layout>
         </item>
@@ -1120,6 +1144,33 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>FontCombo</class>
+   <extends>QComboBox</extends>
+   <header>ui/fontcombo.h</header>
+  </customwidget>
+  <customwidget>
+   <class>ColorCombo</class>
+   <extends>QComboBox</extends>
+   <header>ui/colorcombo.h</header>
+  </customwidget>
+  <customwidget>
+   <class>ArrowChooser</class>
+   <extends>QComboBox</extends>
+   <header>ui/arrowchooser.h</header>
+  </customwidget>
+  <customwidget>
+   <class>LineCombo</class>
+   <extends>QComboBox</extends>
+   <header>ui/linecombo.h</header>
+  </customwidget>
+  <customwidget>
+   <class>ScrSpinBox</class>
+   <extends>QSpinBox</extends>
+   <header location="global">ui/scrspinbox.h</header>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>
Index: scribus/ui/prefs_itemtools.h
===================================================================
--- scribus/ui/prefs_itemtools.h	(revision 14384)
+++ scribus/ui/prefs_itemtools.h	(revision 14385)
@@ -12,6 +12,8 @@
 #include "prefs_pane.h"
 #include "scribusapi.h"
 
+class ScribusDoc;
+
 class SCRIBUS_API Prefs_ItemTools : public Prefs_Pane, Ui::Prefs_ItemTools
 {
 	Q_OBJECT
@@ -21,9 +23,16 @@
 		~Prefs_ItemTools();
 		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
 		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
+
 	public slots:
 		void languageChange();
 		void unitChange(int newIndex);
+
+	protected slots:
+		void enableSignals(bool on);
+
+	protected:
+		ScribusDoc* m_doc;
 };
 
 #endif // PREFS_ITEMTOOLS_H
Index: scribus/ui/arrowchooser.h
===================================================================
--- scribus/ui/arrowchooser.h	(revision 14384)
+++ scribus/ui/arrowchooser.h	(revision 14385)
@@ -18,9 +18,10 @@
     Q_OBJECT
 
 public:
-	ArrowChooser(QWidget* pa, bool direction);
+	ArrowChooser(QWidget* pa, bool direction=true);
 	~ArrowChooser() {};
 	void rebuildList(QList<ArrowDesc> *arrowStyles);
+	void setStartDirection(bool);
 
 private:
 	bool arrowDirection;




More information about the scribus-commit mailing list