Commit a20e860e authored by Jan Möbius's avatar Jan Möbius

New Toolbox Interface ... This will break all Toolbox Plugins!!!

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7239 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a9892f15
......@@ -81,38 +81,14 @@ class ToolboxInterface {
/// Destructor
virtual ~ToolboxInterface() {};
/** \brief Initialize the Toolbar Widget
*
* Initialize the toolbar (create a widget and return a pointer to it ) \n
* \n
* Example : \n
* _widget = new QWidget(); \n
* \n
* In the widget you can add anything you want.
* @param _widget Pointer to the new Widget
* @return Return true if a widget has been created
*/
virtual bool initializeToolbox(QWidget*& /*_widget*/) = 0;
signals :
/** \brief Defines a new ViewMode for the Toolboxes
*
* Slot defines a new ViewMode e.g. a mode where only useful widgets
* are visible by default
* @param _mode name of the ViewMode
* @param _usedWidgets list of used Widgets names
*/
virtual void defineViewModeToolboxes(QString& /*_mode*/, QStringList& /*_usedWidgets*/){};
/** \brief Add a toolbox widget to the gui with the given name
*
* This signal adds a toolbox widget to the toolbar on the right.
*/
virtual void addToolbox( QString /* _name */ , QWidget* /*_widget*/ ) {};
};
Q_DECLARE_INTERFACE(ToolboxInterface,"OpenFlipper.ToolboxInterface/1.1")
......
......@@ -592,17 +592,6 @@ void Core::loadPlugin(QString filename, bool silent){
if ( toolboxPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Toolbox ";
QWidget* widget = 0;
if ( toolboxPlugin->initializeToolbox( widget ) ) {
info.toolboxWidgets.push_back( std::pair< QString,QWidget* >( info.name , widget) );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(info.name) ){
viewModes_[0]->visibleToolboxes << info.name;
viewModes_[0]->visibleToolboxes.sort();
}
}
if ( checkSignal(plugin, "addToolbox(QString,QWidget*)"))
connect(plugin, SIGNAL( addToolbox(QString,QWidget*) ),
......
......@@ -61,7 +61,33 @@
//== IMPLEMENTATION ==========================================================
void CoreWidget::slotAddToolbar(QToolBar* _toolbar) {
int id = -1;
// Find the plugin which added this Toolbox
for ( uint i = 0 ; i < plugins_.size(); ++i ) {
if ( plugins_[i].plugin == sender() ) {
id = i;
break;
}
}
// Find the scripting plugin because we assign this toolBox to it as we did not find the original sender
if ( id == -1 ) {
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 Toolbar!" << std::endl;
return;
}
}
for ( uint i = 0 ; i < toolbars_.size(); ++i ) {
if ( toolbars_[i]->windowTitle() == _toolbar->windowTitle() ) {
emit log(LOGERR,tr("slotAddToolbar: Toolbar already added to system: ") + _toolbar->windowTitle() );
......@@ -73,6 +99,8 @@ void CoreWidget::slotAddToolbar(QToolBar* _toolbar) {
toolbars_.push_back( _toolbar );
addToolBar( _toolbar );
plugins_[id].toolbars.push_back( std::pair< QString,QToolBar* >( _toolbar->windowTitle() , _toolbar) );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolbars.contains( _toolbar->windowTitle() ) ){
viewModes_[0]->visibleToolbars << _toolbar->windowTitle();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment