r15635 by fschmid - Added a new custom widget to manage our installed palettes. In order to support a large number of palettes

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 24 16:52:29 CEST 2010


Author: fschmid
Date: Sun Oct 24 14:52:28 2010
New Revision: 15635

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15635
Log:
Added a new custom widget to manage our installed palettes. In order to support a large number of palettes
you can now add subdirectorys to the swatches directory. But keep in mind that all palettes must have a
unique name.

Added:
    trunk/Scribus/scribus/ui/swatchcombo.cpp
    trunk/Scribus/scribus/ui/swatchcombo.h
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/colorsetmanager.cpp
    trunk/Scribus/scribus/colorsetmanager.h
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/cmykfw.cpp
    trunk/Scribus/scribus/ui/cmykfw.h
    trunk/Scribus/scribus/ui/paintmanager.cpp
    trunk/Scribus/scribus/ui/paintmanager.h
    trunk/Scribus/scribus/ui/paintmanagerbase.ui

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Sun Oct 24 14:52:28 2010
@@ -384,6 +384,7 @@
   ui/stylemanager.h
   ui/styleselect.h
   ui/styleview.h
+  ui/swatchcombo.h
   ui/symbolpalette.h
   ui/tabcheckdoc.h
   ui/tabdisplay.h
@@ -762,6 +763,7 @@
   ui/stylemanager.cpp
   ui/styleselect.cpp
   ui/styleview.cpp
+  ui/swatchcombo.cpp
   ui/symbolpalette.cpp
   ui/tabcheckdoc.cpp
   ui/tabdisplay.cpp

Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Sun Oct 24 14:52:28 2010
@@ -134,22 +134,63 @@
 	}
 }
 
-void ColorSetManager::findPalettes()
+void ColorSetManager::searchDir(QString path, QTreeWidgetItem* parent)
+{
+	QStringList exts;
+	exts << "xml" << "gpl" << "eps" << "ai" << "sla" << "soc";
+	QDir dirs(path, "*", QDir::Name,  QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
+	dirs.setSorting(QDir::Name | QDir::DirsFirst);
+	if ((dirs.exists()) && (dirs.count() != 0))
+	{
+		for (uint dc = 0; dc < dirs.count(); ++dc)
+		{
+			QFileInfo fi(path + dirs[dc]);
+			if (fi.isDir())
+			{
+				QString setName = fi.baseName();
+				setName.replace("_", " ");
+				QTreeWidgetItem* item = new QTreeWidgetItem(parent);
+				item->setFlags(Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+				item->setText(0, setName);
+				searchDir(path + dirs[dc] + "/", item);
+			}
+			else
+			{
+				if (exts.contains(fi.suffix().toLower()))
+				{
+					QString setName = fi.baseName();
+					setName.replace("_", " ");
+					palettes.insert(setName, fi.absoluteFilePath());
+					QTreeWidgetItem* item = new QTreeWidgetItem(parent);
+					item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+					item->setText(0, setName);
+				}
+			}
+		}
+	}
+}
+
+void ColorSetManager::findPalettes(QTreeWidgetItem* parent)
 {
 	palettes.clear();
 	QString path;
 	for ( QStringList::Iterator it = paletteLocations.begin(); it != paletteLocations.end(); ++it )
 	{
-		path=(*it);
-		QDir dir(path , "*.xml *.gpl *.eps *.ai *.sla *.soc", QDir::Name, QDir::Files | QDir::NoSymLinks);
-		if (dir.exists() && (dir.count() != 0))
-		{
-			for (uint i = 0; i < dir.count(); ++i) 
-			{
-				QFileInfo file(path + dir[i]);
-				QString setName=file.baseName();
-				setName.replace("_", " ");
-				palettes.insert(setName, file.absoluteFilePath());
+		path = (*it);
+		if (parent != NULL)
+			searchDir(path, parent);
+		else
+		{
+			QDir dir(path , "*.xml *.gpl *.eps *.ai *.sla *.soc", QDir::Name, QDir::Files | QDir::NoSymLinks);
+			if (dir.exists() && (dir.count() != 0))
+			{
+				for (uint i = 0; i < dir.count(); ++i) 
+				{
+					QFileInfo file(path + dir[i]);
+					QString setName=file.baseName();
+					setName.replace("_", " ");
+					palettes.insert(setName, file.absoluteFilePath());
+				}
 			}
 		}
 	}

Modified: trunk/Scribus/scribus/colorsetmanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/colorsetmanager.h
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.h (original)
+++ trunk/Scribus/scribus/colorsetmanager.h Sun Oct 24 14:52:28 2010
@@ -16,6 +16,7 @@
 #include <QMap>
 #include <QString>
 #include <QStringList>
+#include <QTreeWidget>
 
 struct ApplicationPrefs;
 
@@ -27,7 +28,8 @@
 		
 		void initialiseDefaultPrefs(struct ApplicationPrefs& appPrefs);
 		void findPaletteLocations();
-		void findPalettes();
+		void searchDir(QString path, QTreeWidgetItem* parent = NULL);
+		void findPalettes(QTreeWidgetItem* parent = NULL);
 		QStringList paletteNames();
 		QString paletteFileFromName(const QString& paletteName);
 		bool paletteLocationLocked(const QString& palettePath);

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Sun Oct 24 14:52:28 2010
@@ -146,8 +146,6 @@
 
 	ColorSetManager csm;
 	csm.initialiseDefaultPrefs(appPrefs);
-	csm.findPaletteLocations();
-	csm.findPalettes();
 
 	appPrefs.uiPrefs.wheelJump = 40;
 	/** Set Default window position and size to sane default values which should work on every screen */

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Oct 24 14:52:28 2010
@@ -9981,10 +9981,9 @@
 			propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
 			prefsManager->appPrefs.defaultGradients = dia->dialogGradients;
 		}
-	}
-	prefsManager->setColorSetName(dia->getColorSetName());
-//	if (!HaveDoc)
-	prefsManager->appPrefs.colorPrefs.CustomColorSets = dia->customColSet;
+		prefsManager->setColorSetName(dia->getColorSetName());
+		prefsManager->appPrefs.colorPrefs.CustomColorSets = dia->customColSet;
+	}
 	delete dia;
 	undoManager->setUndoEnabled(true);
 }

Modified: trunk/Scribus/scribus/ui/cmykfw.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/ui/cmykfw.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.cpp (original)
+++ trunk/Scribus/scribus/ui/cmykfw.cpp Sun Oct 24 14:52:28 2010
@@ -30,6 +30,7 @@
 #include <QByteArray>
 #include <QPixmap>
 #include <QAction>
+#include <QTreeWidget>
 #include <cstdlib>
 
 #include "colorchart.h"
@@ -41,6 +42,7 @@
 #include "scpaths.h"
 #include "scribusdoc.h"
 #include "scrspinbox.h"
+#include "swatchcombo.h"
 #include "util.h"
 #include "util_color.h"
 #include "util_formats.h"
@@ -125,12 +127,6 @@
 	Separations->setText( tr( "Is Spot Color" ) );
 	Separations->setChecked(orig.isSpotColor());
 	Layout23->addWidget( Separations );
-/*
-	Regist = new QCheckBox( this );
-	Regist->setText( tr( "Is Registration Color" ) );
-	Regist->setChecked(orig.isRegistrationColor());
-	Layout23->addWidget( Regist );
-*/
 	QSpacerItem* spacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding );
 	Layout23->addItem( spacer );
 
@@ -192,42 +188,35 @@
 	Frame4Layout->setSpacing( 5 );
 	Frame4Layout->setMargin( 0 );
 
-	Swatches = new ScComboBox( Frame4 );
-	Swatches->addItem( tr( "HSV Color Map" ) );
-/*
-	Swatches->insertItem("X11 RGB-Set");
-	Swatches->insertItem("X11 Grey-Set");
-	Swatches->insertItem("Gnome-Set");
-	Swatches->insertItem("SVG-Set");
-	Swatches->insertItem("OpenOffice.org-Set");
-*/
+	Swatches = new SwatchCombo( Frame4 );
+	hsvSelector = Swatches->addTopLevelItem( tr( "HSV Color Map" ) );
+	hsvSelector->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
 	csm.findPaletteLocations();
-	csm.findPalettes();
-	QStringList allSets(csm.paletteNames());
-	for ( QStringList::Iterator it = allSets.begin(); it != allSets.end(); ++it )
-	{
-		Swatches->addItem((*it));
-	}
-	customSetStartIndex=Swatches->count();
-
+	systemSwatches = Swatches->addTopLevelItem( tr("Scribus Swatches"));
+	csm.findPalettes(systemSwatches);
+	Swatches->addSubItem("Scribus Small", systemSwatches);
+	systemSwatches->setExpanded(true);
+	userSwatches = Swatches->addTopLevelItem( tr("User Swatches"));
 	if (Cust.count() != 0)
 	{
 		QStringList realEx;
 		realEx.clear();
 		for (int m = 0; m < Cust.count(); ++m)
 		{
-			QString Cpfad = QDir::convertSeparators( ScPaths::getApplicationDataDir() + Cust[m]);
+			QString Cpfad = QDir::convertSeparators(ScPaths::getApplicationDataDir() + Cust[m] + ".xml");
 			QFileInfo cfi(Cpfad);
 			if (cfi.exists())
 			{
 				QString setName = cfi.baseName();
 				setName.replace("_", " ");
-				Swatches->addItem(setName);
+				Swatches->addSubItem(setName, userSwatches);
 				realEx.append(Cust[m]);
 			}
 		}
 		CColSet = realEx;
 	}
+	userSwatches->setExpanded(true);
+	Swatches->setCurrentComboItem( tr( "HSV Color Map" ));
 	Frame4Layout->addWidget( Swatches );
 
 	TabStack = new QStackedWidget( Frame4 );
@@ -404,7 +393,8 @@
 	connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
 	connect( ColorMap, SIGNAL( ColorVal(int, int, bool)), this, SLOT( setColor2(int, int, bool)));
 	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
-	connect( Swatches, SIGNAL(activated(int)), this, SLOT(SelSwatch(int)));
+//	connect( Swatches, SIGNAL(activated(int)), this, SLOT(SelSwatch(int)));
+	connect(Swatches, SIGNAL(activated(const QString &)), this, SLOT(SelSwatch()));
 	connect(ColorSwatch, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( SelFromSwatch(QListWidgetItem*) ) );
 	connect(Separations, SIGNAL(clicked()), this, SLOT(setSpot()));
 //	connect(Regist, SIGNAL(clicked()), this, SLOT(setRegist()));
@@ -594,44 +584,42 @@
 	return image0;
 }
 
-void CMYKChoose::SelSwatch(int n)
-{
-	if (n == 0)
+void CMYKChoose::SelSwatch()
+{
+	QTreeWidgetItem *c = Swatches->currentItem();
+	if (c == hsvSelector)
 		TabStack->setCurrentIndex(0);
 	else
 	{
 		CurrSwatch.clear();
 		QString pfadC2 = "";
-		if (n < customSetStartIndex)
-			pfadC2 = csm.paletteFileFromName(Swatches->itemText(n));
+		if ( c->parent() != userSwatches)
+			pfadC2 = csm.paletteFileFromName(c->text(0));
 		else
 		{
-			QString listText = Swatches->itemText(n);
+			QString listText = c->text(0);
 			listText.replace(" ", "_");
 			listText += ".xml";
 			pfadC2 = QDir::convertSeparators(ScPaths::getApplicationDataDir() + listText);
 		}
-		if (n != 0)
-		{
-			if (importColorsFromFile(pfadC2, CurrSwatch))
-			{
-				CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
-				CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
-			}
-			else
-			{
-				CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
-				CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
-				ScColor cc = ScColor(255, 255, 255, 255);
-				cc.setRegistrationColor(true);
-				CurrSwatch.insert("Registration", cc);
-				CurrSwatch.insert("Blue", ScColor(255, 255, 0, 0));
-				CurrSwatch.insert("Cyan", ScColor(255, 0, 0, 0));
-				CurrSwatch.insert("Green", ScColor(255, 0, 255, 0));
-				CurrSwatch.insert("Red", ScColor(0, 255, 255, 0));
-				CurrSwatch.insert("Yellow", ScColor(0, 0, 255, 0));
-				CurrSwatch.insert("Magenta", ScColor(0, 255, 0, 0));
-			}
+		if (importColorsFromFile(pfadC2, CurrSwatch))
+		{
+			CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
+			CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
+		}
+		else
+		{
+			CurrSwatch.insert("White", ScColor(0, 0, 0, 0));
+			CurrSwatch.insert("Black", ScColor(0, 0, 0, 255));
+			ScColor cc = ScColor(255, 255, 255, 255);
+			cc.setRegistrationColor(true);
+			CurrSwatch.insert("Registration", cc);
+			CurrSwatch.insert("Blue", ScColor(255, 255, 0, 0));
+			CurrSwatch.insert("Cyan", ScColor(255, 0, 0, 0));
+			CurrSwatch.insert("Green", ScColor(255, 0, 255, 0));
+			CurrSwatch.insert("Red", ScColor(0, 255, 255, 0));
+			CurrSwatch.insert("Yellow", ScColor(0, 0, 255, 0));
+			CurrSwatch.insert("Magenta", ScColor(0, 255, 0, 0));
 		}
 		ColorSwatch->clear();
 		ColorSwatch->insertFancyPixmapItems(CurrSwatch);
@@ -639,19 +627,7 @@
 		TabStack->setCurrentIndex(1);
 	}
 }
-/*
-void CMYKChoose::setRegist()
-{
-	disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
-	if (Regist->isChecked())
-	{
-		ComboBox1->setCurrentIndex( 0 );
-		Separations->setChecked(false);
-		SelModel( tr("CMYK"));
-	}
-	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
-}
-*/
+
 void CMYKChoose::setSpot()
 {
 	disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(SelModel(const QString&)));
@@ -709,10 +685,6 @@
 		MagentaP->setPixmap(SliderPix(300));
 		YellowP->setPixmap(SliderPix(60));
 		BlackP->setPixmap(SliderBlack());
-/*		BlackP->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
-		BlackSL->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
-		BlackSp->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
-		BlackT->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); */
 		BlackP->show();
 		BlackSL->show();
 		BlackSp->show();
@@ -721,7 +693,6 @@
 		setValues();
 	}
 	else
-		//	if (mod == tr("RGB"))
 	{
 		CMYKmode = false;
 		Wsave = false;
@@ -753,10 +724,6 @@
 		MagentaP->setPixmap(SliderPix(120));
 		YellowP->setPixmap(SliderPix(240));
 		Layout2x->setSizeConstraint(QLayout::SetFixedSize);
-/*		BlackP->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
-		BlackSL->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
-		BlackSp->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
-		BlackT->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored)); */
 		BlackP->hide();
 		BlackSL->hide();
 		BlackSp->hide();

Modified: trunk/Scribus/scribus/ui/cmykfw.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/ui/cmykfw.h
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.h (original)
+++ trunk/Scribus/scribus/ui/cmykfw.h Sun Oct 24 14:52:28 2010
@@ -20,6 +20,7 @@
 class QSlider;
 class QPixmap;
 class QListWidgetItem;
+class QTreeWidget;
 
 #include "colorsetmanager.h"
 #include "sccolor.h"
@@ -29,6 +30,7 @@
 class ScribusDoc;
 class ScrSpinBox;
 class ScComboBox;
+class SwatchCombo;
 class ColorListBox;
 class ColorChart;
 
@@ -44,8 +46,7 @@
 	QLabel* TextLabel3;
 	ScComboBox* ComboBox1;
 	QCheckBox* Separations;
-//	QCheckBox* Regist;
-	ScComboBox* Swatches;
+	SwatchCombo* Swatches;
 	QLabel* TextLabel5_2;
 	QLabel* OldC;
 	QLabel* TextLabel5;
@@ -96,9 +97,8 @@
 	void ToggleSL();
 	QPixmap SliderPix(int farbe);
 	QPixmap SliderBlack();
-	void SelSwatch(int n);
+	void SelSwatch();
 	void setSpot();
-//	void setRegist();
 	void SelModel(const QString& mod);
 	void setColor();
 	void setColor2(int h, int s, bool ende);
@@ -121,8 +121,10 @@
 	QVBoxLayout* Layout1_2_4;
 	
 	ColorSetManager csm;
-	int customSetStartIndex;
 	ScribusDoc* m_doc;
+	QTreeWidgetItem *systemSwatches;
+	QTreeWidgetItem *userSwatches;
+	QTreeWidgetItem *hsvSelector;
 };
 
 #endif // CMYKFARBEN_H

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Sun Oct 24 14:52:28 2010
@@ -52,8 +52,6 @@
 #include "util_formats.h"
 #include "util_icon.h"
 
-#include <QDebug>
-
 PaintManagerDialog::PaintManagerDialog(QWidget* parent, QMap<QString, VGradient> *docGradients, ColorList doco, QString docColSet, QStringList custColSet, ScribusDoc *doc, ScribusMainWindow *scMW) : QDialog(parent)
 {
 	setupUi(this);
@@ -75,13 +73,13 @@
 	}
 	origGradients = docGradients->keys();
 	customColSet = custColSet;
-	
-	int setCount = 1;
+
 	csm.findPaletteLocations();
-	csm.findPalettes();
-	QStringList allSets(csm.paletteNames());
-	LoadColSet->addItems(allSets);
-	customSetStartIndex = setCount+allSets.count();
+	systemSwatches = LoadColSet->addTopLevelItem( tr("Scribus Swatches"));
+	csm.findPalettes(systemSwatches);
+	LoadColSet->addSubItem("Scribus Small", systemSwatches);
+	systemSwatches->setExpanded(true);
+	userSwatches = LoadColSet->addTopLevelItem( tr("User Swatches"));
 	if (custColSet.count() != 0)
 	{
 		QStringList realEx;
@@ -94,13 +92,14 @@
 			{
 				QString setName = cfi.baseName();
 				setName.replace("_", " ");
-				LoadColSet->addItem(setName);
+				LoadColSet->addSubItem(setName, userSwatches);
 				realEx.append(custColSet[m]);
 			}
 		}
 		customColSet = realEx;
 	}
-	setCurrentComboItem(LoadColSet, docColSet);
+	userSwatches->setExpanded(true);
+	LoadColSet->setCurrentComboItem(docColSet);
 
 	importButton->setEnabled(false);
 	newButton->setEnabled(false);
@@ -893,8 +892,7 @@
 
 void PaintManagerDialog::loadDefaults(const QString &txt)
 {
-	int c = LoadColSet->currentIndex();
-	setCurrentComboItem(LoadColSet, txt);
+	QTreeWidgetItem *c = LoadColSet->currentItem();
 	if (m_doc == NULL)
 	{
 		m_colorList.clear();
@@ -903,7 +901,6 @@
 	QString pfadC2 = "";
 	if (txt == "Scribus Small")
 	{
-		setCurrentComboItem(LoadColSet, "Scribus Small");
 		m_colorList.insert("White", ScColor(0, 0, 0, 0));
 		m_colorList.insert("Black", ScColor(0, 0, 0, 255));
 		ScColor cc = ScColor(255, 255, 255, 255);
@@ -919,7 +916,7 @@
 	}
 	else
 	{
-		if ( c < customSetStartIndex)
+		if ( c->parent() != userSwatches)
 			pfadC2 = csm.paletteFileFromName(txt);
 		else
 		{
@@ -941,7 +938,6 @@
 		}
 		else
 		{
-			setCurrentComboItem(LoadColSet, "Scribus Small");
 			m_colorList.insert("White", ScColor(0, 0, 0, 0));
 			m_colorList.insert("Black", ScColor(0, 0, 0, 255));
 			ScColor cc = ScColor(255, 255, 255, 255);
@@ -963,7 +959,7 @@
 void PaintManagerDialog::saveDefaults()
 {
 	QString Cpfad = QDir::convertSeparators(ScPaths::getApplicationDataDir());
-	QString Name = LoadColSet->currentText();
+	QString Name = LoadColSet->text();
 	Query* dia = new Query(this, "Name", 1, 0, tr("&Name:"), tr("Choose a Name"));
 	if ((Name == "Scribus Basic") || (Name == "Scribus Small") || (Name == "X11 RGB-Set") || (Name == "OpenOffice.org-Set")
 	        || (Name == "X11 Grey-Set") || (Name == "Gnome-Set") || (Name == "SVG-Set"))
@@ -1027,8 +1023,10 @@
 				nameC.replace(" ", "_");
 				nameC += ".xml";
 				customColSet.append(nameC);
-				LoadColSet->addItem(dia->getEditText());
-				setCurrentComboItem(LoadColSet, dia->getEditText());
+				LoadColSet->addSubItem(dia->getEditText(), userSwatches);
+				disconnect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
+				LoadColSet->setCurrentComboItem(dia->getEditText());
+				connect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
 			}
 		}
 	}
@@ -1036,7 +1034,7 @@
 
 QString PaintManagerDialog::getColorSetName()
 {
-	return LoadColSet->currentText();
+	return LoadColSet->text();
 }
 
 ScColor PaintManagerDialog::selectedColor()

Modified: trunk/Scribus/scribus/ui/paintmanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/ui/paintmanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.h (original)
+++ trunk/Scribus/scribus/ui/paintmanager.h Sun Oct 24 14:52:28 2010
@@ -82,10 +82,11 @@
 		void addGimpColor(QString &colorName, double r, double g, double b);
 		void loadScribusFormat(QString fileName);
 		ColorSetManager csm;
-		int customSetStartIndex;
 		bool paletteLocked;
 		QTreeWidgetItem *colorItems;
 		QTreeWidgetItem *gradientItems;
+		QTreeWidgetItem *systemSwatches;
+		QTreeWidgetItem *userSwatches;
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/paintmanagerbase.ui
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15635&path=/trunk/Scribus/scribus/ui/paintmanagerbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanagerbase.ui (original)
+++ trunk/Scribus/scribus/ui/paintmanagerbase.ui Sun Oct 24 14:52:28 2010
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>411</height>
+    <width>412</width>
+    <height>412</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -20,6 +20,9 @@
    <bool>true</bool>
   </property>
   <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
+   <property name="spacing">
+    <number>5</number>
+   </property>
    <property name="margin">
     <number>5</number>
    </property>
@@ -46,10 +49,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QVBoxLayout" name="verticalLayout">
-     <property name="sizeConstraint">
-      <enum>QLayout::SetDefaultConstraint</enum>
-     </property>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
      <item>
       <widget class="QPushButton" name="importButton">
        <property name="toolTip">
@@ -121,7 +121,7 @@
        <property name="title">
         <string>Color Sets</string>
        </property>
-       <layout class="QVBoxLayout" name="verticalLayout_3">
+       <layout class="QVBoxLayout" name="verticalLayout">
         <property name="spacing">
          <number>5</number>
         </property>
@@ -136,15 +136,19 @@
          </widget>
         </item>
         <item>
-         <widget class="QComboBox" name="LoadColSet">
-          <property name="toolTip">
-           <string>Choose a color set to load</string>
-          </property>
-          <item>
-           <property name="text">
-            <string>Scribus Small</string>
-           </property>
-          </item>
+         <widget class="SwatchCombo" name="LoadColSet">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string>...</string>
+          </property>
+          <property name="popupMode">
+           <enum>QToolButton::MenuButtonPopup</enum>
+          </property>
          </widget>
         </item>
         <item>
@@ -201,6 +205,13 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>SwatchCombo</class>
+   <extends>QToolButton</extends>
+   <header>ui/swatchcombo.h</header>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>




More information about the scribus-commit mailing list