View Issue Details

IDProjectCategoryView StatusLast Update
0017160ScribusScripterpublic2024-02-15 17:26
Reporterale Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version1.7.0.svn 
Summary0017160: PATCH: scripter: getFillColor() and getLineColor() do not get items by name if they are inside of a group
DescriptiongetFillColor() gets the color of the selected item, even if it's inside of a group.
but it does not get it if i use the item's name (item not found).

i have not tested it, but i feat that the problem is in GetUniqueItem().
i will have a look at it.
TagsNo tags attached.
PatchYes

Activities

ale

2024-02-15 13:09

manager   ~0050989

here is a patch for getPageItemByName()
get-item-in-groups.diff (724 bytes)   
diff --git a/scribus/plugins/scriptplugin/cmdutil.cpp b/scribus/plugins/scriptplugin/cmdutil.cpp
index bbb26392d..4359dea31 100644
--- a/scribus/plugins/scriptplugin/cmdutil.cpp
+++ b/scribus/plugins/scriptplugin/cmdutil.cpp
@@ -122,6 +122,16 @@ PageItem* getPageItemByName(const QString& name)
 	{
 		if (name == currentDoc->Items->at(i)->itemName())
 			return currentDoc->Items->at(i);
+		if (currentDoc->Items->at(i)->isGroup())
+		{
+			auto group = currentDoc->Items->at(i)->asGroupFrame();
+			for (const auto child: group->getAllChildren())
+			{
+				if (name == child->itemName())
+					return child;
+			}
+		}
+
 	}
 
 	PyErr_SetString(NoValidObjectError, QString("Object not found").toLocal8Bit().constData());
get-item-in-groups.diff (724 bytes)   

ale

2024-02-15 17:24

manager   ~0050990

this patch is useful for https://forums.scribus.net/index.php/topic,4934.0.html

ale

2024-02-15 17:26

manager   ~0050991

btw, the patch won't find groups that are inside of groups.

but i'm fine with it.
if somebody creates a script that has a reason to search by name for groups inside of groups, then it's rather easy to add the feature.

Issue History

Date Modified Username Field Change
2024-02-15 12:30 ale New Issue
2024-02-15 13:05 ale Summary scripter: getFillColor() and getLineColor() do not get items by name if they are inside of a group => PATCH: scripter: getFillColor() and getLineColor() do not get items by name if they are inside of a group
2024-02-15 13:05 ale Patch No => Yes
2024-02-15 13:09 ale Note Added: 0050989
2024-02-15 13:09 ale File Added: get-item-in-groups.diff
2024-02-15 17:24 ale Note Added: 0050990
2024-02-15 17:26 ale Note Added: 0050991