r16861 by jghali - #10174: the return of the brownish color

scribus-commit scribus-commit at lists.scribus.net
Thu Sep 29 21:52:52 UTC 2011


Author: jghali
Date: Thu Sep 29 21:52:51 2011
New Revision: 16861

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16861
Log:
#10174: the return of the brownish color

Modified:
    trunk/Scribus/scribus/ui/colorcombo.cpp
    trunk/Scribus/scribus/ui/colorlistbox.cpp
    trunk/Scribus/scribus/ui/colorlistbox.h

Modified: trunk/Scribus/scribus/ui/colorcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16861&path=/trunk/Scribus/scribus/ui/colorcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/colorcombo.cpp Thu Sep 29 21:52:51 2011
@@ -54,7 +54,10 @@
 	{
 		clb->clear();
 		if ( insertNone )
+		{
 			clb->addItem(CommonStrings::tr_NoneColor);
+			clb->item(0)->setData(Qt::UserRole, CommonStrings::None);
+		}
 		if ( pixType == ColorCombo::fancyPixmaps )
 			clb->insertItems(list, ColorListBox::fancyPixmap);
 		else if ( pixType == ColorCombo::widePixmaps )
@@ -102,7 +105,7 @@
 void ColorCombo::initColorList(ColorList *colorList, ScribusDoc *doc, QString colorValue)
 {
 	clear();
-	addItem(CommonStrings::tr_NoneColor);
+	addItem(CommonStrings::tr_NoneColor, CommonStrings::None);
 	if (colorValue == CommonStrings::None)
 		setCurrentIndex(count()-1);
 	ColorList::Iterator endOfColorList(colorList->end());

Modified: trunk/Scribus/scribus/ui/colorlistbox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16861&path=/trunk/Scribus/scribus/ui/colorlistbox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.cpp (original)
+++ trunk/Scribus/scribus/ui/colorlistbox.cpp Thu Sep 29 21:52:51 2011
@@ -202,6 +202,30 @@
 	connect(this, SIGNAL(showContextMenue()), this, SLOT(slotRightClick()));
 }
 
+void ColorListBox::changeEvent(QEvent *e)
+{
+	if (e->type() == QEvent::LanguageChange)
+	{
+		languageChange();
+		return;
+	}
+	QListWidget::changeEvent(e);
+}
+
+void ColorListBox::languageChange()
+{
+	if (this->count() > 0)
+	{
+		QModelIndexList result;
+		QModelIndex start = model()->index(0, 0, this->rootIndex());
+		result =  model()->match(start, Qt::UserRole, CommonStrings::None, 1, Qt::MatchExactly | Qt::MatchCaseSensitive);
+		if (result.isEmpty())
+			return;
+		int index = result.first().row();
+		QListWidgetItem* item = this->item(index);
+		item->setText(CommonStrings::tr_NoneColor);
+	}
+}
 
 QString ColorListBox::currentColor() const
 {
@@ -292,6 +316,11 @@
 void ColorListBox::addItem(QString text)
 {
 	QListWidget::addItem(text);
+	if (text == CommonStrings::None || text == CommonStrings::tr_NoneColor)
+	{
+		QListWidgetItem* item = this->item(count() - 1);
+		item->setData(Qt::UserRole, CommonStrings::None);
+	}
 }
 
 void ColorListBox::insertSmallPixmapItems(ColorList& list)

Modified: trunk/Scribus/scribus/ui/colorlistbox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16861&path=/trunk/Scribus/scribus/ui/colorlistbox.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorlistbox.h (original)
+++ trunk/Scribus/scribus/ui/colorlistbox.h Thu Sep 29 21:52:51 2011
@@ -80,6 +80,8 @@
 		/*! \brief Standard QListBox like constructor.
 		Just there are initialized pixmaps for icon drawing. */
 		ColorListBox(QWidget * parent = 0);
+		
+		virtual void changeEvent(QEvent *e);
 
 		QString currentColor() const;
 
@@ -116,13 +118,14 @@
 		ColorList *cList;
 	private slots:
 		void slotRightClick();
+	protected slots:
+		virtual void languageChange();
 	signals:
 		void showContextMenue();
 	protected:
 		bool viewportEvent(QEvent *event);
 		static int initialized;
 		static int sortRule;
-		int m_selectedRow;
 		ColorListBox::PixmapType m_type;
 };
 




More information about the scribus-commit mailing list