Skip to content

Commit

Permalink
Allow adding QToolButton's to the toolbars
Browse files Browse the repository at this point in the history
 * iface.addToolBarWidget()
 * iface.addRasterToolBarWidget()
 * iface.addVectorToolBarWidget()
 * iface.addDatabaseToolBarWidget()
 * iface.addWebToolBarWidget()
  • Loading branch information
m-kuhn committed Apr 28, 2013
1 parent ddbfb2e commit d90f167
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 0 deletions.
51 changes: 51 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -71,9 +71,29 @@ class QgisInterface : QObject
//! Add an icon to the plugins toolbar
virtual int addToolBarIcon( QAction *qAction ) = 0;

/**
* Add a widget to the plugins toolbar.
* To remove this widget again, call {@link removeToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
virtual QAction* addToolBarWidget( QWidget* widget ) = 0;

//! Remove an action (icon) from the plugin toolbar
virtual void removeToolBarIcon( QAction *qAction ) = 0;

/**
* Add a widget to the raster toolbar.
* To remove this widget again, call {@link removeRasterToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;

//! Add an icon to the Raster toolbar
//! @note added in 2.0
virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
Expand All @@ -84,8 +104,19 @@ class QgisInterface : QObject

//! Add an icon to the Vector toolbar
//! @note added in 2.0

virtual int addVectorToolBarIcon( QAction *qAction ) = 0;

/**
* Add a widget to the vector toolbar.
* To remove this widget again, call {@link removeVectorToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;

//! Remove an action (icon) from the Vector toolbar
//! @note added in 2.0
virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
Expand All @@ -94,6 +125,16 @@ class QgisInterface : QObject
//! @note added in 2.0
virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;

/**
* Add a widget to the database toolbar.
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;

//! Remove an action (icon) from the Database toolbar
//! @note added in 2.0
virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
Expand All @@ -102,6 +143,16 @@ class QgisInterface : QObject
//! @note added in 2.0
virtual int addWebToolBarIcon( QAction *qAction ) = 0;

/**
* Add a widget to the web toolbar.
* To remove this widget again, call {@link removeWebToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;

//! Remove an action (icon) from the Web toolbar
//! @note added in 2.0
virtual void removeWebToolBarIcon( QAction *qAction ) = 0;
Expand Down
25 changes: 25 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -7342,6 +7342,11 @@ int QgisApp::addPluginToolBarIcon( QAction * qAction )
return 0;
}

QAction*QgisApp::addPluginToolBarWidget( QWidget* widget )
{
return mPluginToolBar->addWidget( widget );
}

void QgisApp::removePluginToolBarIcon( QAction *qAction )
{
mPluginToolBar->removeAction( qAction );
Expand All @@ -7353,6 +7358,11 @@ int QgisApp::addRasterToolBarIcon( QAction * qAction )
return 0;
}

QAction*QgisApp::addRasterToolBarWidget( QWidget* widget )
{
return mRasterToolBar->addWidget( widget );
}

void QgisApp::removeRasterToolBarIcon( QAction *qAction )
{
mRasterToolBar->removeAction( qAction );
Expand All @@ -7364,6 +7374,11 @@ int QgisApp::addVectorToolBarIcon( QAction * qAction )
return 0;
}

QAction*QgisApp::addVectorToolBarWidget( QWidget* widget )
{
return mVectorToolBar->addWidget( widget );
}

void QgisApp::removeVectorToolBarIcon( QAction *qAction )
{
mVectorToolBar->removeAction( qAction );
Expand All @@ -7375,6 +7390,11 @@ int QgisApp::addDatabaseToolBarIcon( QAction * qAction )
return 0;
}

QAction*QgisApp::addDatabaseToolBarWidget( QWidget* widget )
{
return mDatabaseToolBar->addWidget( widget );
}

void QgisApp::removeDatabaseToolBarIcon( QAction *qAction )
{
mDatabaseToolBar->removeAction( qAction );
Expand All @@ -7386,6 +7406,11 @@ int QgisApp::addWebToolBarIcon( QAction * qAction )
return 0;
}

QAction*QgisApp::addWebToolBarWidget( QWidget* widget )
{
return mWebToolBar->addWidget( widget );
}

void QgisApp::removeWebToolBarIcon( QAction *qAction )
{
mWebToolBar->removeAction( qAction );
Expand Down
45 changes: 45 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -724,22 +724,67 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void removeAddLayerAction( QAction* action );
//! Add an icon to the plugin toolbar
int addPluginToolBarIcon( QAction * qAction );
/**
* Add a widget to the plugins toolbar.
* To remove this widget again, call {@link removeToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addPluginToolBarWidget( QWidget* widget );
//! Remove an icon from the plugin toolbar
void removePluginToolBarIcon( QAction *qAction );
//! Add an icon to the Raster toolbar
int addRasterToolBarIcon( QAction * qAction );
/**
* Add a widget to the raster toolbar.
* To remove this widget again, call {@link removeRasterToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addRasterToolBarWidget( QWidget* widget );
//! Remove an icon from the Raster toolbar
void removeRasterToolBarIcon( QAction *qAction );
//! Add an icon to the Vector toolbar
int addVectorToolBarIcon( QAction * qAction );
/**
* Add a widget to the vector toolbar.
* To remove this widget again, call {@link removeVectorToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addVectorToolBarWidget( QWidget* widget );
//! Remove an icon from the Vector toolbar
void removeVectorToolBarIcon( QAction *qAction );
//! Add an icon to the Database toolbar
int addDatabaseToolBarIcon( QAction * qAction );
/**
* Add a widget to the database toolbar.
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addDatabaseToolBarWidget( QWidget* widget );
//! Remove an icon from the Database toolbar
void removeDatabaseToolBarIcon( QAction *qAction );
//! Add an icon to the Web toolbar
int addWebToolBarIcon( QAction * qAction );
/**
* Add a widget to the web toolbar.
* To remove this widget again, call {@link removeWebToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addWebToolBarWidget( QWidget* widget );
//! Remove an icon from the Web toolbar
void removeWebToolBarIcon( QAction *qAction );
//! Save window state
Expand Down
25 changes: 25 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -203,6 +203,11 @@ int QgisAppInterface::addToolBarIcon( QAction * qAction )
return qgis->addPluginToolBarIcon( qAction );
}

QAction*QgisAppInterface::addToolBarWidget( QWidget* widget )
{
return qgis->addPluginToolBarWidget( widget );
}

void QgisAppInterface::removeToolBarIcon( QAction *qAction )
{
qgis->removePluginToolBarIcon( qAction );
Expand All @@ -213,6 +218,11 @@ int QgisAppInterface::addRasterToolBarIcon( QAction * qAction )
return qgis->addRasterToolBarIcon( qAction );
}

QAction*QgisAppInterface::addRasterToolBarWidget( QWidget* widget )
{
return qgis->addRasterToolBarWidget( widget );
}

void QgisAppInterface::removeRasterToolBarIcon( QAction *qAction )
{
qgis->removeRasterToolBarIcon( qAction );
Expand All @@ -223,6 +233,11 @@ int QgisAppInterface::addVectorToolBarIcon( QAction * qAction )
return qgis->addVectorToolBarIcon( qAction );
}

QAction*QgisAppInterface::addVectorToolBarWidget(QWidget* widget)
{
return qgis->addVectorToolBarWidget( widget );
}

void QgisAppInterface::removeVectorToolBarIcon( QAction *qAction )
{
qgis->removeVectorToolBarIcon( qAction );
Expand All @@ -233,6 +248,11 @@ int QgisAppInterface::addDatabaseToolBarIcon( QAction * qAction )
return qgis->addDatabaseToolBarIcon( qAction );
}

QAction*QgisAppInterface::addDatabaseToolBarWidget(QWidget* widget)
{
return qgis->addDatabaseToolBarWidget( widget );
}

void QgisAppInterface::removeDatabaseToolBarIcon( QAction *qAction )
{
qgis->removeDatabaseToolBarIcon( qAction );
Expand All @@ -243,6 +263,11 @@ int QgisAppInterface::addWebToolBarIcon( QAction * qAction )
return qgis->addWebToolBarIcon( qAction );
}

QAction*QgisAppInterface::addWebToolBarWidget(QWidget* widget)
{
return qgis->addWebToolBarWidget( widget );
}

void QgisAppInterface::removeWebToolBarIcon( QAction *qAction )
{
qgis->removeWebToolBarIcon( qAction );
Expand Down
45 changes: 45 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -80,22 +80,67 @@ class QgisAppInterface : public QgisInterface

//! Add an icon to the plugins toolbar
int addToolBarIcon( QAction *qAction );
/**
* Add a widget to the plugins toolbar.
* To remove this widget again, call {@link removeToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addToolBarWidget( QWidget* widget );
//! Remove an icon (action) from the plugin toolbar
void removeToolBarIcon( QAction *qAction );
//! Add an icon to the Raster toolbar
int addRasterToolBarIcon( QAction *qAction );
/**
* Add a widget to the raster toolbar.
* To remove this widget again, call {@link removeRasterToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addRasterToolBarWidget( QWidget* widget );
//! Remove an icon (action) from the Raster toolbar
void removeRasterToolBarIcon( QAction *qAction );
//! Add an icon to the Vector toolbar
int addVectorToolBarIcon( QAction *qAction );
/**
* Add a widget to the vector toolbar.
* To remove this widget again, call {@link removeVectorToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addVectorToolBarWidget( QWidget* widget );
//! Remove an icon (action) from the Vector toolbar
void removeVectorToolBarIcon( QAction *qAction );
//! Add an icon to the Database toolbar
int addDatabaseToolBarIcon( QAction *qAction );
/**
* Add a widget to the database toolbar.
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addDatabaseToolBarWidget( QWidget* widget );
//! Remove an icon (action) from the Database toolbar
void removeDatabaseToolBarIcon( QAction *qAction );
//! Add an icon to the Web toolbar
int addWebToolBarIcon( QAction *qAction );
/**
* Add a widget to the web toolbar.
* To remove this widget again, call {@link removeWebToolBarIcon}
* with the returned QAction.
*
* @param widget widget to add. The toolbar will take ownership of this widget
* @return the QAction you can use to remove this widget from the toolbar
*/
QAction* addWebToolBarWidget( QWidget* widget );
//! Remove an icon (action) from the Web toolbar
void removeWebToolBarIcon( QAction *qAction );

Expand Down

0 comments on commit d90f167

Please sign in to comment.