Skip to content

Commit

Permalink
Merge pull request #1317 from 3nids/addtoolbar
Browse files Browse the repository at this point in the history
allow to add a QToolBar to QGisInterface
  • Loading branch information
3nids committed Apr 28, 2014
2 parents 7581370 + 02e46e8 commit 483ba9e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -162,6 +162,10 @@ class QgisInterface : QObject
//! Add toolbar with specified name
virtual QToolBar *addToolBar( QString name ) = 0 /Factory/;

//! Add a toolbar
//! @note added in 2.3
virtual void addToolBar( QToolBar* toolbar /Transfer/, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;

/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

Expand Down
7 changes: 7 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -2135,6 +2135,13 @@ QToolBar *QgisApp::addToolBar( QString name )
return toolBar;
}

void QgisApp::addToolBar( QToolBar* toolBar , Qt::ToolBarArea area )
{
QMainWindow::addToolBar( area, toolBar );
// add to the Toolbar submenu
mToolbarMenu->addAction( toolBar->toggleViewAction() );
}

QgsLegend *QgisApp::legend()
{
Q_ASSERT( mMapLegend );
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -211,6 +211,14 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* parent class, it will also add it to the View menu list of toolbars.*/
QToolBar *addToolBar( QString name );

/** Add a toolbar to the main window. Overloaded from QMainWindow.
* After adding the toolbar to the ui (by delegating to the QMainWindow
* parent class, it will also add it to the View menu list of toolbars.
* @note added in 2.3
*/
void addToolBar( QToolBar* toolBar, Qt::ToolBarArea area = Qt::TopToolBarArea );


/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
void addWindow( QAction *action );
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -285,6 +285,11 @@ QToolBar* QgisAppInterface::addToolBar( QString name )
return qgis->addToolBar( name );
}

void QgisAppInterface::addToolBar( QToolBar *toolbar, Qt::ToolBarArea area )
{
return qgis->addToolBar( toolbar, area );
}

void QgisAppInterface::openURL( QString url, bool useQgisDocDirectory )
{
qgis->openURL( url, useQgisDocDirectory );
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -146,6 +146,10 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! Add toolbar with specified name
QToolBar* addToolBar( QString name );

//! Add a toolbar
//! @note added in 2.3
void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea );

/** Open a url in the users browser. By default the QGIS doc directory is used
* as the base for the URL. To open a URL that is not relative to the installed
* QGIS documentation, set useQgisDocDirectory to false.
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -205,6 +205,10 @@ class GUI_EXPORT QgisInterface : public QObject
//! Add toolbar with specified name
virtual QToolBar *addToolBar( QString name ) = 0;

//! Add a toolbar
//! @note added in 2.3
virtual void addToolBar( QToolBar* toolbar, Qt::ToolBarArea area = Qt::TopToolBarArea ) = 0;

/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

Expand Down

0 comments on commit 483ba9e

Please sign in to comment.