View Issue Details

IDProjectCategoryView StatusLast Update
0017120ScribusScripterpublic2024-01-11 07:52
Reporterale Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version1.7.0.svn 
Summary0017120: [PATCH] scripter: add a clearClipboard() command
Descriptiona script should always clear the clipboard after having used copyObjects()
Tagspatch
PatchYes

Activities

ale

2024-01-11 07:49

manager   ~0050879

clear_clipboard.diff (2,802 bytes)   
diff --git a/scribus/plugins/scriptplugin/cmdobj.cpp b/scribus/plugins/scriptplugin/cmdobj.cpp
index 1b4f0091d..ee99ed320 100644
--- a/scribus/plugins/scriptplugin/cmdobj.cpp
+++ b/scribus/plugins/scriptplugin/cmdobj.cpp
@@ -6,6 +6,8 @@ for which a new license (GPL+exception) is in place.
 */
 #include "cmdobj.h"
 
+#include <QApplication>
+
 #include "appmodes.h"
 #include "cmdutil.h"
 #include "commonstrings.h"
@@ -1069,6 +1071,12 @@ PyObject *scribus_pasteobjects(PyObject * /* self */, PyObject * /*args*/)
 	return pyList;
 }
 
+PyObject *scribus_clearclipboard(PyObject * /* self */)
+{
+	QApplication::clipboard()->clear();
+	Py_RETURN_NONE;
+}
+
 
 PyObject *scribus_getitempagenumber(PyObject *, PyObject *args)
 {
@@ -1094,7 +1102,8 @@ PV */
 void cmdobjdocwarnings()
 {
 	QStringList s;
-	s << scribus_copyobject__doc__
+	s << scribus_clearclipboard__doc__
+	  << scribus_copyobject__doc__
 	  << scribus_copyobjects__doc__
 	  << scribus_createbezierline__doc__
 	  << scribus_createellipse__doc__
diff --git a/scribus/plugins/scriptplugin/cmdobj.h b/scribus/plugins/scriptplugin/cmdobj.h
index 1e8e46cdb..b0912f0c9 100644
--- a/scribus/plugins/scriptplugin/cmdobj.h
+++ b/scribus/plugins/scriptplugin/cmdobj.h
@@ -401,6 +401,17 @@ Returns the names of the newly created object in a list.\n\
 "));
 PyObject *scribus_pasteobjects(PyObject * /* self */, PyObject *args);
 
+/*! docstring */
+PyDoc_STRVAR(scribus_clearclipboard__doc__,
+QT_TR_NOOP("clearClipboard()\n\
+\n\
+Clear the clipboard contents.\n\
+\n\
+In most cases, you should clear the clipboard contents after having used copyObjects()\n\
+and pasteObjects() in your scripts.\n\
+"));
+PyObject *scribus_clearclipboard(PyObject * /* self */);
+
 /*! docstring */
 PyDoc_STRVAR(scribus_getitempagenumber__doc__,
 QT_TR_NOOP("getItemPageNumber([name])\n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index 467ee8cf4..b641e0662 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -613,6 +613,7 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("duplicateObjects"), scribus_duplicateobjects, METH_VARARGS, tr(scribus_duplicateobjects__doc__)},
 	{const_cast<char*>("pasteObject"), scribus_pasteobject, METH_NOARGS, tr(scribus_pasteobject__doc__)}, // Deprecated
 	{const_cast<char*>("pasteObjects"), scribus_pasteobjects, METH_NOARGS, tr(scribus_pasteobjects__doc__)},
+	{const_cast<char*>("clearClipboard"), (PyCFunction)scribus_clearclipboard, METH_NOARGS, tr(scribus_clearclipboard__doc__)},
 	// by Tj (hacker@iam.tj>
 	{const_cast<char*>("combinePolygons"), (PyCFunction)scribus_combinepolygons, METH_NOARGS, tr(scribus_combinepolygons__doc__)},
 	// Internal methods - Not for public use
clear_clipboard.diff (2,802 bytes)   

Issue History

Date Modified Username Field Change
2024-01-11 06:55 ale New Issue
2024-01-11 07:49 ale Note Added: 0050879
2024-01-11 07:49 ale File Added: clear_clipboard.diff
2024-01-11 07:52 ale Summary scripter: add a clearClipboard() command => [PATCH] scripter: add a clearClipboard() command
2024-01-11 07:52 ale Patch No => Yes
2024-01-11 07:52 ale Tag Attached: patch