View Issue Details

IDProjectCategoryView StatusLast Update
0015133ScribusProperties Palettepublic2019-11-22 08:05
Reporteru ltd. Assigned Toale  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Platformamd64OSalike debianOS Version9
Product Version 
Target VersionFixed in Version 
Summary0015133: Stress-free duplicate name handling in xyz-propertiespalette (and explicitely allow - as part of name.)
DescriptionWhen you enter a duplicate name in the name field of the XYZ properties palette, you get a MessageBox and then the focus is set back to the field, but eventually the new wrong name is set back to the old unique name.

This is annoying for complex names when you made some small typo. After the field got set back you start from the beginning.

Solution: (Patch attached) Set the background color of the wrong name field to red, but leave the wrong name. This way you can fix the typo and you are done. If you don't know what the old name was, you can "escape" by deselecting and selecting the object.
Tagsgui, UI
PatchYes

Activities

u ltd.

2018-02-06 07:43

reporter  

scribus-20180205-095552-jonas-nameproperty.patch (2,418 bytes)
Index: scribus/ui/propertiespalette_utils.cpp
===================================================================
--- scribus/ui/propertiespalette_utils.cpp	(Revision 22369)
+++ scribus/ui/propertiespalette_utils.cpp	(Arbeitskopie)
@@ -98,7 +98,7 @@
 NameWidget::NameWidget(QWidget* parent) : QLineEdit(parent)
 {
 	setObjectName("namewidget");
-	QRegExp rx( "[\\w()]+" );
+	QRegExp rx( "[\\w()-]+" );
 	QValidator* validator = new QRegExpValidator( rx, this );
 	setValidator( validator );
 }
Index: scribus/ui/propertiespalette_xyz.cpp
===================================================================
--- scribus/ui/propertiespalette_xyz.cpp	(Revision 22369)
+++ scribus/ui/propertiespalette_xyz.cpp	(Arbeitskopie)
@@ -291,7 +291,9 @@
 
 	m_haveItem = false;
 	m_item = i;
-
+	
+	nameEdit->setPalette(QPalette()); // Default colors.
+	
 	nameEdit->setText(m_item->itemName());
 	levelLabel->setText( QString::number(m_item->level()) );
 
@@ -1199,6 +1201,9 @@
 		nameEdit->setText(NameOld);
 		return;
 	}
+	if (m_item->itemName() == nameEdit->text())
+		return;
+	
 	bool found = false;
 	QList<PageItem*> allItems;
 	for (int a = 0; a < m_doc->Items->count(); ++a)
@@ -1219,20 +1224,32 @@
 		}
 		allItems.clear();
 	}
+	
+	QPalette qpl = QPalette(); // Default colors.
+	
 	if (found)
 	{
 		ScMessageBox::warning(this, CommonStrings::trWarning, "<qt>"+ tr("Name \"%1\" isn't unique.<br/>Please choose another.").arg(NameNew)+"</qt>");
-		nameEdit->setText(NameOld);
 		nameEdit->setFocus();
+		
+		//qpl.setColor(QPalette::Base, QColor(50, 255, 255));
+		qpl.setColor(QPalette::Active, QPalette::Base, QColor(255, 160, 160));
+		qpl.setColor(QPalette::Inactive, QPalette::Base, QColor(255, 50, 50));
+		qpl.setColor(QPalette::Disabled, QPalette::Base, QColor(255, 255, 255));
+		qpl.setColor(QPalette::Disabled, QPalette::Text, QColor(255, 150, 150));
+		nameEdit->setPalette(qpl);
+		return;
 	}
-	else
-	{
-		if (m_item->itemName() != nameEdit->text())
-		{
-			m_item->setItemName(nameEdit->text());
-			m_doc->changed();
-		}
-	}
+	
+	// As we checked that the name is not duplicate, setItemName will
+	// not modify our new name proposal.
+	m_item->setItemName(nameEdit->text());
+	m_doc->changed();
+	
+	//nameEdit->setForegroundRole(qpl); //?
+	nameEdit->setPalette(qpl);
+	
+	// TODO: maybe test whether the change was successful?
 }
 
 void PropertiesPalette_XYZ::installSniffer(ScrSpinBox *spinBox)

ale

2019-11-22 08:05

manager   ~0047111

i've been changing a few similar situation in scribus by simply adding a (1) at the end.
no warning or other complex handling.
it's easy enough to replace the (#) at the and fix the name to be unique.

as soon as the xyz and advanced section patches are in, i will make a patch for this.

Issue History

Date Modified Username Field Change
2018-02-06 07:43 u ltd. New Issue
2018-02-06 07:43 u ltd. File Added: scribus-20180205-095552-jonas-nameproperty.patch
2018-02-06 07:43 u ltd. Tag Attached: gui
2018-02-06 07:43 u ltd. Tag Attached: UI
2019-11-21 08:02 ale Assigned To => ale
2019-11-21 08:02 ale Status new => assigned
2019-11-22 08:05 ale Note Added: 0047111