Skip to content

Commit d90f167

Browse files
committedApr 28, 2013
Allow adding QToolButton's to the toolbars
* iface.addToolBarWidget() * iface.addRasterToolBarWidget() * iface.addVectorToolBarWidget() * iface.addDatabaseToolBarWidget() * iface.addWebToolBarWidget()
1 parent ddbfb2e commit d90f167

File tree

6 files changed

+242
-0
lines changed

6 files changed

+242
-0
lines changed
 

‎python/gui/qgisinterface.sip

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,29 @@ class QgisInterface : QObject
7171
//! Add an icon to the plugins toolbar
7272
virtual int addToolBarIcon( QAction *qAction ) = 0;
7373

74+
/**
75+
* Add a widget to the plugins toolbar.
76+
* To remove this widget again, call {@link removeToolBarIcon}
77+
* with the returned QAction.
78+
*
79+
* @param widget widget to add. The toolbar will take ownership of this widget
80+
* @return the QAction you can use to remove this widget from the toolbar
81+
*/
82+
virtual QAction* addToolBarWidget( QWidget* widget ) = 0;
83+
7484
//! Remove an action (icon) from the plugin toolbar
7585
virtual void removeToolBarIcon( QAction *qAction ) = 0;
7686

87+
/**
88+
* Add a widget to the raster toolbar.
89+
* To remove this widget again, call {@link removeRasterToolBarIcon}
90+
* with the returned QAction.
91+
*
92+
* @param widget widget to add. The toolbar will take ownership of this widget
93+
* @return the QAction you can use to remove this widget from the toolbar
94+
*/
95+
virtual QAction* addRasterToolBarWidget( QWidget* widget ) = 0;
96+
7797
//! Add an icon to the Raster toolbar
7898
//! @note added in 2.0
7999
virtual int addRasterToolBarIcon( QAction *qAction ) = 0;
@@ -84,8 +104,19 @@ class QgisInterface : QObject
84104

85105
//! Add an icon to the Vector toolbar
86106
//! @note added in 2.0
107+
87108
virtual int addVectorToolBarIcon( QAction *qAction ) = 0;
88109

110+
/**
111+
* Add a widget to the vector toolbar.
112+
* To remove this widget again, call {@link removeVectorToolBarIcon}
113+
* with the returned QAction.
114+
*
115+
* @param widget widget to add. The toolbar will take ownership of this widget
116+
* @return the QAction you can use to remove this widget from the toolbar
117+
*/
118+
virtual QAction* addVectorToolBarWidget( QWidget* widget ) = 0;
119+
89120
//! Remove an action (icon) from the Vector toolbar
90121
//! @note added in 2.0
91122
virtual void removeVectorToolBarIcon( QAction *qAction ) = 0;
@@ -94,6 +125,16 @@ class QgisInterface : QObject
94125
//! @note added in 2.0
95126
virtual int addDatabaseToolBarIcon( QAction *qAction ) = 0;
96127

128+
/**
129+
* Add a widget to the database toolbar.
130+
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
131+
* with the returned QAction.
132+
*
133+
* @param widget widget to add. The toolbar will take ownership of this widget
134+
* @return the QAction you can use to remove this widget from the toolbar
135+
*/
136+
virtual QAction* addDatabaseToolBarWidget( QWidget* widget ) = 0;
137+
97138
//! Remove an action (icon) from the Database toolbar
98139
//! @note added in 2.0
99140
virtual void removeDatabaseToolBarIcon( QAction *qAction ) = 0;
@@ -102,6 +143,16 @@ class QgisInterface : QObject
102143
//! @note added in 2.0
103144
virtual int addWebToolBarIcon( QAction *qAction ) = 0;
104145

146+
/**
147+
* Add a widget to the web toolbar.
148+
* To remove this widget again, call {@link removeWebToolBarIcon}
149+
* with the returned QAction.
150+
*
151+
* @param widget widget to add. The toolbar will take ownership of this widget
152+
* @return the QAction you can use to remove this widget from the toolbar
153+
*/
154+
virtual QAction* addWebToolBarWidget( QWidget* widget ) = 0;
155+
105156
//! Remove an action (icon) from the Web toolbar
106157
//! @note added in 2.0
107158
virtual void removeWebToolBarIcon( QAction *qAction ) = 0;

‎src/app/qgisapp.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7342,6 +7342,11 @@ int QgisApp::addPluginToolBarIcon( QAction * qAction )
73427342
return 0;
73437343
}
73447344

7345+
QAction*QgisApp::addPluginToolBarWidget( QWidget* widget )
7346+
{
7347+
return mPluginToolBar->addWidget( widget );
7348+
}
7349+
73457350
void QgisApp::removePluginToolBarIcon( QAction *qAction )
73467351
{
73477352
mPluginToolBar->removeAction( qAction );
@@ -7353,6 +7358,11 @@ int QgisApp::addRasterToolBarIcon( QAction * qAction )
73537358
return 0;
73547359
}
73557360

7361+
QAction*QgisApp::addRasterToolBarWidget( QWidget* widget )
7362+
{
7363+
return mRasterToolBar->addWidget( widget );
7364+
}
7365+
73567366
void QgisApp::removeRasterToolBarIcon( QAction *qAction )
73577367
{
73587368
mRasterToolBar->removeAction( qAction );
@@ -7364,6 +7374,11 @@ int QgisApp::addVectorToolBarIcon( QAction * qAction )
73647374
return 0;
73657375
}
73667376

7377+
QAction*QgisApp::addVectorToolBarWidget( QWidget* widget )
7378+
{
7379+
return mVectorToolBar->addWidget( widget );
7380+
}
7381+
73677382
void QgisApp::removeVectorToolBarIcon( QAction *qAction )
73687383
{
73697384
mVectorToolBar->removeAction( qAction );
@@ -7375,6 +7390,11 @@ int QgisApp::addDatabaseToolBarIcon( QAction * qAction )
73757390
return 0;
73767391
}
73777392

7393+
QAction*QgisApp::addDatabaseToolBarWidget( QWidget* widget )
7394+
{
7395+
return mDatabaseToolBar->addWidget( widget );
7396+
}
7397+
73787398
void QgisApp::removeDatabaseToolBarIcon( QAction *qAction )
73797399
{
73807400
mDatabaseToolBar->removeAction( qAction );
@@ -7386,6 +7406,11 @@ int QgisApp::addWebToolBarIcon( QAction * qAction )
73867406
return 0;
73877407
}
73887408

7409+
QAction*QgisApp::addWebToolBarWidget( QWidget* widget )
7410+
{
7411+
return mWebToolBar->addWidget( widget );
7412+
}
7413+
73897414
void QgisApp::removeWebToolBarIcon( QAction *qAction )
73907415
{
73917416
mWebToolBar->removeAction( qAction );

‎src/app/qgisapp.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,22 +724,67 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
724724
void removeAddLayerAction( QAction* action );
725725
//! Add an icon to the plugin toolbar
726726
int addPluginToolBarIcon( QAction * qAction );
727+
/**
728+
* Add a widget to the plugins toolbar.
729+
* To remove this widget again, call {@link removeToolBarIcon}
730+
* with the returned QAction.
731+
*
732+
* @param widget widget to add. The toolbar will take ownership of this widget
733+
* @return the QAction you can use to remove this widget from the toolbar
734+
*/
735+
QAction* addPluginToolBarWidget( QWidget* widget );
727736
//! Remove an icon from the plugin toolbar
728737
void removePluginToolBarIcon( QAction *qAction );
729738
//! Add an icon to the Raster toolbar
730739
int addRasterToolBarIcon( QAction * qAction );
740+
/**
741+
* Add a widget to the raster toolbar.
742+
* To remove this widget again, call {@link removeRasterToolBarIcon}
743+
* with the returned QAction.
744+
*
745+
* @param widget widget to add. The toolbar will take ownership of this widget
746+
* @return the QAction you can use to remove this widget from the toolbar
747+
*/
748+
QAction* addRasterToolBarWidget( QWidget* widget );
731749
//! Remove an icon from the Raster toolbar
732750
void removeRasterToolBarIcon( QAction *qAction );
733751
//! Add an icon to the Vector toolbar
734752
int addVectorToolBarIcon( QAction * qAction );
753+
/**
754+
* Add a widget to the vector toolbar.
755+
* To remove this widget again, call {@link removeVectorToolBarIcon}
756+
* with the returned QAction.
757+
*
758+
* @param widget widget to add. The toolbar will take ownership of this widget
759+
* @return the QAction you can use to remove this widget from the toolbar
760+
*/
761+
QAction* addVectorToolBarWidget( QWidget* widget );
735762
//! Remove an icon from the Vector toolbar
736763
void removeVectorToolBarIcon( QAction *qAction );
737764
//! Add an icon to the Database toolbar
738765
int addDatabaseToolBarIcon( QAction * qAction );
766+
/**
767+
* Add a widget to the database toolbar.
768+
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
769+
* with the returned QAction.
770+
*
771+
* @param widget widget to add. The toolbar will take ownership of this widget
772+
* @return the QAction you can use to remove this widget from the toolbar
773+
*/
774+
QAction* addDatabaseToolBarWidget( QWidget* widget );
739775
//! Remove an icon from the Database toolbar
740776
void removeDatabaseToolBarIcon( QAction *qAction );
741777
//! Add an icon to the Web toolbar
742778
int addWebToolBarIcon( QAction * qAction );
779+
/**
780+
* Add a widget to the web toolbar.
781+
* To remove this widget again, call {@link removeWebToolBarIcon}
782+
* with the returned QAction.
783+
*
784+
* @param widget widget to add. The toolbar will take ownership of this widget
785+
* @return the QAction you can use to remove this widget from the toolbar
786+
*/
787+
QAction* addWebToolBarWidget( QWidget* widget );
743788
//! Remove an icon from the Web toolbar
744789
void removeWebToolBarIcon( QAction *qAction );
745790
//! Save window state

‎src/app/qgisappinterface.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ int QgisAppInterface::addToolBarIcon( QAction * qAction )
203203
return qgis->addPluginToolBarIcon( qAction );
204204
}
205205

206+
QAction*QgisAppInterface::addToolBarWidget( QWidget* widget )
207+
{
208+
return qgis->addPluginToolBarWidget( widget );
209+
}
210+
206211
void QgisAppInterface::removeToolBarIcon( QAction *qAction )
207212
{
208213
qgis->removePluginToolBarIcon( qAction );
@@ -213,6 +218,11 @@ int QgisAppInterface::addRasterToolBarIcon( QAction * qAction )
213218
return qgis->addRasterToolBarIcon( qAction );
214219
}
215220

221+
QAction*QgisAppInterface::addRasterToolBarWidget( QWidget* widget )
222+
{
223+
return qgis->addRasterToolBarWidget( widget );
224+
}
225+
216226
void QgisAppInterface::removeRasterToolBarIcon( QAction *qAction )
217227
{
218228
qgis->removeRasterToolBarIcon( qAction );
@@ -223,6 +233,11 @@ int QgisAppInterface::addVectorToolBarIcon( QAction * qAction )
223233
return qgis->addVectorToolBarIcon( qAction );
224234
}
225235

236+
QAction*QgisAppInterface::addVectorToolBarWidget(QWidget* widget)
237+
{
238+
return qgis->addVectorToolBarWidget( widget );
239+
}
240+
226241
void QgisAppInterface::removeVectorToolBarIcon( QAction *qAction )
227242
{
228243
qgis->removeVectorToolBarIcon( qAction );
@@ -233,6 +248,11 @@ int QgisAppInterface::addDatabaseToolBarIcon( QAction * qAction )
233248
return qgis->addDatabaseToolBarIcon( qAction );
234249
}
235250

251+
QAction*QgisAppInterface::addDatabaseToolBarWidget(QWidget* widget)
252+
{
253+
return qgis->addDatabaseToolBarWidget( widget );
254+
}
255+
236256
void QgisAppInterface::removeDatabaseToolBarIcon( QAction *qAction )
237257
{
238258
qgis->removeDatabaseToolBarIcon( qAction );
@@ -243,6 +263,11 @@ int QgisAppInterface::addWebToolBarIcon( QAction * qAction )
243263
return qgis->addWebToolBarIcon( qAction );
244264
}
245265

266+
QAction*QgisAppInterface::addWebToolBarWidget(QWidget* widget)
267+
{
268+
return qgis->addWebToolBarWidget( widget );
269+
}
270+
246271
void QgisAppInterface::removeWebToolBarIcon( QAction *qAction )
247272
{
248273
qgis->removeWebToolBarIcon( qAction );

‎src/app/qgisappinterface.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,67 @@ class QgisAppInterface : public QgisInterface
8080

8181
//! Add an icon to the plugins toolbar
8282
int addToolBarIcon( QAction *qAction );
83+
/**
84+
* Add a widget to the plugins toolbar.
85+
* To remove this widget again, call {@link removeToolBarIcon}
86+
* with the returned QAction.
87+
*
88+
* @param widget widget to add. The toolbar will take ownership of this widget
89+
* @return the QAction you can use to remove this widget from the toolbar
90+
*/
91+
QAction* addToolBarWidget( QWidget* widget );
8392
//! Remove an icon (action) from the plugin toolbar
8493
void removeToolBarIcon( QAction *qAction );
8594
//! Add an icon to the Raster toolbar
8695
int addRasterToolBarIcon( QAction *qAction );
96+
/**
97+
* Add a widget to the raster toolbar.
98+
* To remove this widget again, call {@link removeRasterToolBarIcon}
99+
* with the returned QAction.
100+
*
101+
* @param widget widget to add. The toolbar will take ownership of this widget
102+
* @return the QAction you can use to remove this widget from the toolbar
103+
*/
104+
QAction* addRasterToolBarWidget( QWidget* widget );
87105
//! Remove an icon (action) from the Raster toolbar
88106
void removeRasterToolBarIcon( QAction *qAction );
89107
//! Add an icon to the Vector toolbar
90108
int addVectorToolBarIcon( QAction *qAction );
109+
/**
110+
* Add a widget to the vector toolbar.
111+
* To remove this widget again, call {@link removeVectorToolBarIcon}
112+
* with the returned QAction.
113+
*
114+
* @param widget widget to add. The toolbar will take ownership of this widget
115+
* @return the QAction you can use to remove this widget from the toolbar
116+
*/
117+
QAction* addVectorToolBarWidget( QWidget* widget );
91118
//! Remove an icon (action) from the Vector toolbar
92119
void removeVectorToolBarIcon( QAction *qAction );
93120
//! Add an icon to the Database toolbar
94121
int addDatabaseToolBarIcon( QAction *qAction );
122+
/**
123+
* Add a widget to the database toolbar.
124+
* To remove this widget again, call {@link removeDatabaseToolBarIcon}
125+
* with the returned QAction.
126+
*
127+
* @param widget widget to add. The toolbar will take ownership of this widget
128+
* @return the QAction you can use to remove this widget from the toolbar
129+
*/
130+
QAction* addDatabaseToolBarWidget( QWidget* widget );
95131
//! Remove an icon (action) from the Database toolbar
96132
void removeDatabaseToolBarIcon( QAction *qAction );
97133
//! Add an icon to the Web toolbar
98134
int addWebToolBarIcon( QAction *qAction );
135+
/**
136+
* Add a widget to the web toolbar.
137+
* To remove this widget again, call {@link removeWebToolBarIcon}
138+
* with the returned QAction.
139+
*
140+
* @param widget widget to add. The toolbar will take ownership of this widget
141+
* @return the QAction you can use to remove this widget from the toolbar
142+
*/
143+
QAction* addWebToolBarWidget( QWidget* widget );
99144
//! Remove an icon (action) from the Web toolbar
100145
void removeWebToolBarIcon( QAction *qAction );
101146

0 commit comments

Comments
 (0)
Please sign in to comment.