From 443825b79e22e85cb2243d336f134391936b39f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 9 Mar 2009 18:59:22 +0000 Subject: [PATCH] Fix slot descriptions for core make addToolbox slot scriptable git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5265 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.cc | 23 ++++++++++++++++++----- Core/Core.hh | 8 +++++--- Core/PluginLoader.cc | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Core/Core.cc b/Core/Core.cc index 8d102e69..c11c7ff1 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -1126,27 +1126,40 @@ void Core::setDescriptions(){ emit setSlotDescription("loadObject()", "Show the dialog to load an object. (only works if GUI is available)",QStringList(), QStringList()); emit setSlotDescription("loadSettings()", "Show the dialog to load settings. (only works if GUI is available)",QStringList(), QStringList()); emit setSlotDescription("loadSettings(QString)", "load settings from file.",QStringList(), QStringList()); - emit setSlotDescription("createWidget(QString,QString);", "Create a widget from an ui file", + + emit setSlotDescription("createWidget(QString,QString)", "Create a widget from an ui file", QString("Object name,ui file").split(","), QString("Name of the new widget in script,ui file to load").split(",")); + emit setSlotDescription("addToolbox(QString,QWidget*)", "Add a widget as a toolbox", + QString("Toolbox Entry name,Widget").split(","), + QString("Name of the new widget in the toolbox,Pointer to the new widget").split(",")); } -void Core::slotAddToolbox(QString _name ,QWidget* _widget) { +void Core::addToolbox(QString _name ,QWidget* _widget) { int id = -1; for ( uint i = 0 ; i < plugins.size(); ++i ) { if ( plugins[i].plugin == sender() ) { id = i; - std::cerr << "Found" << std::endl; break; } } if ( id == -1 ) { - std::cerr << "Unknown sender plugin when adding Toolbox!" << std::endl; - return; + for ( uint i = 0 ; i < plugins.size(); ++i ) { + if ( plugins[i].name == "Scripting" ) { + id = i; + break; + } + } + + + if ( id == -1 ) { + std::cerr << "Unknown sender plugin when adding Toolbox!" << std::endl; + return; + } } plugins[id].widgets.push_back( std::pair< QString,QWidget* >( _name , _widget) ); diff --git a/Core/Core.hh b/Core/Core.hh index 6931a28a..2902c27b 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -401,9 +401,6 @@ private: /// The current Toolbox item has changed // void slotToolboxSwitched(int _index); - /// Add a Toolbox from a plugin - void slotAddToolbox(QString _name ,QWidget* _widget); - /// Slot adding empty object from Menu void slotAddEmptyObjectMenu(); @@ -415,6 +412,11 @@ private: /// Open Recent file void slotRecentOpen(QAction* _action); + + public slots: + + /// Add a Toolbox from a plugin or from scripting + void addToolbox(QString _name ,QWidget* _widget); private : diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc index 3453a0ff..630c5235 100644 --- a/Core/PluginLoader.cc +++ b/Core/PluginLoader.cc @@ -605,7 +605,7 @@ void Core::loadPlugin(QString filename, bool silent){ if ( checkSignal(plugin, "addToolbox(QString,QWidget*)")) connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ), - this, SLOT( slotAddToolbox(QString,QWidget*) ),Qt::DirectConnection ); + this, SLOT( addToolbox(QString,QWidget*) ),Qt::DirectConnection ); -- GitLab