r20149 by jghali - #13116: fix HSV map not selected by default in swatch combo when opening color editor

scribus-commit scribus-commit at lists.scribus.net
Sat Jun 6 15:26:25 UTC 2015


Author: jghali
Date: Sat Jun  6 15:26:25 2015
New Revision: 20149

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20149
Log:
#13116: fix HSV map not selected by default in swatch combo when opening color editor

Modified:
    trunk/Scribus/scribus/ui/cmykfw.cpp
    trunk/Scribus/scribus/ui/cmykfw.h
    trunk/Scribus/scribus/ui/swatchcombo.cpp

Modified: trunk/Scribus/scribus/ui/cmykfw.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20149&path=/trunk/Scribus/scribus/ui/cmykfw.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.cpp (original)
+++ trunk/Scribus/scribus/ui/cmykfw.cpp Sat Jun  6 15:26:25 2015
@@ -184,7 +184,11 @@
 	csm.findUserPalettes(userSwatches);
 	customColSet = csm.userPaletteNames();
 	userSwatches->setExpanded(true);
-	Swatches->setCurrentComboItem( tr( "HSV Color Map" ));
+	// Swatches combo uses elided text strings, so we cannot
+	// set default combo item in constructor: at that point
+	// the swatch combo widget does not know its width yet.
+	// We set it in the dialog showEvent().
+	// Swatches->setCurrentComboItem( tr( "HSV Color Map" ));
 	Frame4Layout->addWidget( Swatches );
 
 	TabStack = new QStackedWidget( Frame4 );
@@ -1054,6 +1058,13 @@
 	BlackSL->blockSignals(false);
 }
 
+void CMYKChoose::showEvent(QShowEvent * event)
+{
+	if (!event->spontaneous())
+		Swatches->setCurrentComboItem( tr( "HSV Color Map" ));
+	QDialog::showEvent(event);
+}
+
 void CMYKChoose::leave()
 {
 	// if condition 10/21/2004 pv #1191 - just be sure that user cannot create "None" color

Modified: trunk/Scribus/scribus/ui/cmykfw.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20149&path=/trunk/Scribus/scribus/ui/cmykfw.h
==============================================================================
--- trunk/Scribus/scribus/ui/cmykfw.h (original)
+++ trunk/Scribus/scribus/ui/cmykfw.h Sat Jun  6 15:26:25 2015
@@ -123,6 +123,8 @@
 	QTreeWidgetItem *hsvSelector;
 	QStringList customColSet;
 	
+	virtual void showEvent(QShowEvent * event);
+
 	QPixmap sliderPix(int farbe);
 	QPixmap sliderBlack();
 };

Modified: trunk/Scribus/scribus/ui/swatchcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20149&path=/trunk/Scribus/scribus/ui/swatchcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/swatchcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/swatchcombo.cpp Sat Jun  6 15:26:25 2015
@@ -44,19 +44,16 @@
 
 void SwatchCombo::itemActivated(QTreeWidgetItem* item)
 {
-	if (item)
+	if (item && (item->flags() & Qt::ItemIsSelectable))
 	{
-		if (item->flags() & Qt::ItemIsSelectable)
-		{
-			menu()->hide();
-			setText(item->text(0));
-			QFontMetrics fm(font());
-			QString elText = fm.elidedText(item->text(0), Qt::ElideMiddle, width());
-			setText(elText);
-			setToolTip(item->text(0));
-			emit activated(item->text(0));
-			emit activated(item);
-		}
+		menu()->hide();
+		setText(item->text(0));
+		QFontMetrics fm(font());
+		QString elText = fm.elidedText(item->text(0), Qt::ElideMiddle, width());
+		setText(elText);
+		setToolTip(item->text(0));
+		emit activated(item->text(0));
+		emit activated(item);
 	}
 }
 
@@ -99,19 +96,31 @@
 	lg = dataTree->findItems(txt, Qt::MatchExactly | Qt::MatchRecursive);
 	if (lg.count() <= 0) return;
 
-	QString dText = fo.absolutePath();
-	for (int a = 0; a < lg.count(); a++)
+	// Case of HSV map in new color dialog
+	if (fo.isRelative() && (lg.count() == 1))
 	{
-		if (dText == lg[a]->data(0, Qt::UserRole).toString())
+		if ((lg[0]->flags() & Qt::ItemIsSelectable))
 		{
 			dataTree->setCurrentItem(lg[0]);
+			QString elText = fm.elidedText(txt, Qt::ElideMiddle, width());
+			setText(elText);
+			return;
+		}
+	}
+
+	QString dText = fo.absolutePath();
+	for (int i = 0; i < lg.count(); i++)
+	{
+		if (dText == lg[i]->data(0, Qt::UserRole).toString())
+		{
+			dataTree->setCurrentItem(lg[i]);
 			QString elText = fm.elidedText(txt, Qt::ElideMiddle, width());
 			setText(elText);
 			break;
 		}
 	}
 
-	if(!dataTree->currentItem())
+	if (!dataTree->currentItem())
 		setCurrentComboItem("Scribus Small");
 }
 




More information about the scribus-commit mailing list