Skip to content

Commit

Permalink
allow to add a QToolBar to QGisInterface (will allow subclassing)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Apr 24, 2014
1 parent d2b1c82 commit 26e94fe
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
Original file line number Diff line number Diff line change
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, 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 26e94fe

Please sign in to comment.