[scribus] New ticket: Duplicate name handling in xyz-propertiespalette
Jonas Bechtel
post at jbechtel.de
Mon Feb 5 10:20:02 UTC 2018
Hello there,
I have following new ticket:
Category: Properties Palette
Reproducibility: everytime
Product version: 1.5.4.svn
Tags: gui,UI
Patch: Yes
Files: patch attached in plain text, see below.
Summary: Stress-free duplicate name handling in xyz-propertiespalette (and explicitely allow - as part of name.)
Description:
When 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.
BR
Jonas
__..--::°°""^^´´
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)
More information about the scribus
mailing list