Skip to content

Commit 598a66f

Browse files
author
mhugent
committed
Consider themes for all composer items and change icon themes in composer together with application. Fixes bug #1438
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9731 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 037b039 commit 598a66f

File tree

5 files changed

+84
-44
lines changed

5 files changed

+84
-44
lines changed

src/app/composer/qgscomposer.cpp

+23-34
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,16 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
7878
// mActionAddImage
7979
// mActionSelectMoveItem
8080

81-
QAction* moveItemContentAction = new QAction( QIcon( QPixmap( myIconPath + "mActionMoveItemContent.png" ) ),
82-
tr( "Move Content" ), 0 );
83-
moveItemContentAction->setToolTip( tr( "Move item content" ) );
84-
moveItemContentAction->setCheckable( true );
85-
connect( moveItemContentAction, SIGNAL( triggered() ), this, SLOT( moveItemContent() ) );
86-
toolBar->addAction( moveItemContentAction );
87-
//toolBar->addAction(QIcon(QPixmap(myIconPath+"mActionMoveItemContent.png")), tr("Move Item content"), this, SLOT(moveItemContent()));
88-
89-
QAction* groupItemsAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionGroupItems.png" ) ),
90-
tr( "&Group" ), this, SLOT( groupItems() ) );
91-
groupItemsAction->setToolTip( tr( "Group items" ) );
92-
QAction* ungroupItemsAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionUngroupItems.png" ) ),
93-
tr( "&Ungroup" ), this, SLOT( ungroupItems() ) );
94-
ungroupItemsAction->setToolTip( tr( "Ungroup items" ) );
95-
QAction* raiseItemsAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionRaiseItems.png" ) ),
96-
tr( "Raise" ), this, SLOT( raiseSelectedItems() ) );
97-
raiseItemsAction->setToolTip( tr( "Raise selected items" ) );
98-
QAction* lowerItemsAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionLowerItems.png" ) ),
99-
tr( "Lower" ), this, SLOT( lowerSelectedItems() ) );
100-
lowerItemsAction->setToolTip( tr( "Lower selected items" ) );
101-
QAction* moveItemsToTopAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToTop.png" ) ),
102-
tr( "Bring to Front" ), this, SLOT( moveSelectedItemsToTop() ) );
103-
moveItemsToTopAction->setToolTip( tr( "Move selected items to top" ) );
104-
QAction* moveItemsToBottomAction = toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToBottom.png" ) ),
105-
tr( "Send to Back" ), this, SLOT( moveSelectedItemsToBottom() ) );
106-
moveItemsToBottomAction->setToolTip( tr( "Move selected items to bottom" ) );
81+
mActionMoveItemContent->setToolTip( tr( "Move item content" ) );
82+
mActionGroupItems->setToolTip( tr( "Group items" ) );
83+
mActionUngroupItems->setToolTip( tr( "Ungroup items" ) );
84+
mActionRaiseItems->setToolTip( tr( "Raise selected items" ) );
85+
mActionLowerItems->setToolTip( tr( "Lower selected items" ) );
86+
mActionMoveItemsToTop->setToolTip( tr( "Move selected items to top" ) );
87+
mActionMoveItemsToBottom->setToolTip( tr( "Move selected items to bottom" ) );
10788

10889
QActionGroup* toggleActionGroup = new QActionGroup( this );
109-
toggleActionGroup->addAction( moveItemContentAction );
90+
toggleActionGroup->addAction( mActionMoveItemContent);
11091
toggleActionGroup->addAction( mActionAddNewMap );
11192
toggleActionGroup->addAction( mActionAddNewLabel );
11293
toggleActionGroup->addAction( mActionAddNewLegend );
@@ -124,6 +105,7 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
124105
mActionSelectMoveItem->setCheckable( true );
125106
mActionAddNewScalebar->setCheckable( true );
126107
mActionAddImage->setCheckable( true );
108+
mActionMoveItemContent->setCheckable( true );
127109

128110
#ifdef Q_WS_MAC
129111
QMenu *appMenu = menuBar()->addMenu( tr( "QGIS" ) );
@@ -257,6 +239,13 @@ void QgsComposer::setupTheme()
257239
mActionAddNewLegend->setIcon( QgisApp::getThemeIcon( "/mActionAddLegend.png" ) );
258240
mActionAddNewScalebar->setIcon( QgisApp::getThemeIcon( "/mActionScaleBar.png" ) );
259241
mActionSelectMoveItem->setIcon( QgisApp::getThemeIcon( "/mActionSelectPan.png" ) );
242+
mActionMoveItemContent->setIcon( QgisApp::getThemeIcon("/mActionMoveItemContent.png"));
243+
mActionGroupItems->setIcon( QgisApp::getThemeIcon("/mActionGroupItems.png"));
244+
mActionUngroupItems->setIcon( QgisApp::getThemeIcon("/mActionUngroupItems.png"));
245+
mActionRaiseItems->setIcon( QgisApp::getThemeIcon("/mActionRaiseItems.png"));
246+
mActionLowerItems->setIcon( QgisApp::getThemeIcon("/mActionLowerItems.png"));
247+
mActionMoveItemsToTop->setIcon( QgisApp::getThemeIcon("/mActionMoveItemsToTop.png"));
248+
mActionMoveItemsToBottom->setIcon( QgisApp::getThemeIcon("/mActionMoveItemsToBottom.png"));
260249
}
261250

262251
void QgsComposer::connectSlots()
@@ -740,55 +729,55 @@ void QgsComposer::on_mActionAddImage_activated( void )
740729
}
741730
}
742731

743-
void QgsComposer::moveItemContent()
732+
void QgsComposer::on_mActionMoveItemContent_activated(void)
744733
{
745734
if ( mView )
746735
{
747736
mView->setCurrentTool( QgsComposerView::MoveItemContent );
748737
}
749738
}
750739

751-
void QgsComposer::groupItems( void )
740+
void QgsComposer::on_mActionGroupItems_activated( void )
752741
{
753742
if ( mView )
754743
{
755744
mView->groupItems();
756745
}
757746
}
758747

759-
void QgsComposer::ungroupItems( void )
748+
void QgsComposer::on_mActionUngroupItems_activated( void )
760749
{
761750
if ( mView )
762751
{
763752
mView->ungroupItems();
764753
}
765754
}
766755

767-
void QgsComposer::raiseSelectedItems()
756+
void QgsComposer::on_mActionRaiseItems_activated( void )
768757
{
769758
if ( mComposition )
770759
{
771760
mComposition->raiseSelectedItems();
772761
}
773762
}
774763

775-
void QgsComposer::lowerSelectedItems()
764+
void QgsComposer::on_mActionLowerItems_activated(void)
776765
{
777766
if ( mComposition )
778767
{
779768
mComposition->lowerSelectedItems();
780769
}
781770
}
782771

783-
void QgsComposer::moveSelectedItemsToTop()
772+
void QgsComposer::on_mActionMoveItemsToTop_activated(void)
784773
{
785774
if ( mComposition )
786775
{
787776
mComposition->moveSelectedItemsToTop();
788777
}
789778
}
790779

791-
void QgsComposer::moveSelectedItemsToBottom()
780+
void QgsComposer::on_mActionMoveItemsToBottom(void)
792781
{
793782
if ( mComposition )
794783
{

src/app/composer/qgscomposer.h

+11-9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
5050
QgsComposer( QgisApp *qgis );
5151
~QgsComposer();
5252

53+
//! Set the pixmap / icons on the toolbar buttons
54+
void setupTheme();
55+
5356
//! Open and show, set defaults if first time
5457
void open();
5558

@@ -130,25 +133,25 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
130133
void on_mActionAddImage_activated( void );
131134

132135
//! Set tool to move item content
133-
void moveItemContent();
136+
void on_mActionMoveItemContent_activated(void);
134137

135138
//! Group selected items
136-
void groupItems( void );
139+
void on_mActionGroupItems_activated( void );
137140

138141
//! Ungroup selected item group
139-
void ungroupItems( void );
142+
void on_mActionUngroupItems_activated( void );
140143

141144
//! Move selected items one position up
142-
void raiseSelectedItems();
145+
void on_mActionRaiseItems_activated(void);
143146

144147
//!Move selected items one position down
145-
void lowerSelectedItems();
148+
void on_mActionLowerItems_activated(void);
146149

147150
//!Move selected items to top
148-
void moveSelectedItemsToTop();
151+
void on_mActionMoveItemsToTop_activated(void);
149152

150153
//!Move selected items to bottom
151-
void moveSelectedItemsToBottom();
154+
void on_mActionMoveItemsToBottom(void);
152155

153156
//! Save window state
154157
void saveWindowState();
@@ -196,8 +199,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
196199
void activate();
197200

198201
private:
199-
//! Set the pixmap / icons on the toolbar buttons
200-
void setupTheme();
202+
201203
/**Establishes the signal slot connection for the class*/
202204
void connectSlots();
203205

src/app/qgisapp.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ QgisApp *QgisApp::smInstance = 0;
304304
QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
305305
: QMainWindow( parent, fl ),
306306
mSplash( splash ),
307+
mComposer(0),
307308
mPythonConsole( NULL ),
308309
mPythonUtils( NULL )
309310
{
@@ -1480,6 +1481,11 @@ void QgisApp::setTheme( QString theThemeName )
14801481
mActionCustomProjection->setIcon( getThemeIcon( "/mActionCustomProjection.png" ) );
14811482
mActionAddWmsLayer->setIcon( getThemeIcon( "/mActionAddWmsLayer.png" ) );
14821483
mActionAddToOverview->setIcon( getThemeIcon( "/mActionInOverview.png" ) );
1484+
1485+
if(mComposer)
1486+
{
1487+
mComposer->setupTheme();
1488+
}
14831489
}
14841490

14851491
void QgisApp::setupConnections()

src/app/qgsoptions.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ void QgsOptions::themeChanged( const QString &newThemeName )
245245
QString newt = newThemeName;
246246
QgisApp::instance()->setTheme( newt );
247247
}
248+
248249
QString QgsOptions::theme()
249250
{
250251
// returns the current theme (as selected in the cmbTheme combo box)

src/ui/qgscomposerbase.ui

+43-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<rect>
66
<x>0</x>
77
<y>0</y>
8-
<width>800</width>
8+
<width>710</width>
99
<height>609</height>
1010
</rect>
1111
</property>
@@ -244,6 +244,13 @@
244244
<addaction name="mActionAddNewLegend" />
245245
<addaction name="mActionAddNewScalebar" />
246246
<addaction name="mActionSelectMoveItem" />
247+
<addaction name="mActionMoveItemContent" />
248+
<addaction name="mActionGroupItems" />
249+
<addaction name="mActionUngroupItems" />
250+
<addaction name="mActionRaiseItems" />
251+
<addaction name="mActionLowerItems" />
252+
<addaction name="mActionMoveItemsToTop" />
253+
<addaction name="mActionMoveItemsToBottom" />
247254
</widget>
248255
<action name="mActionPrint" >
249256
<property name="icon" >
@@ -367,6 +374,41 @@
367374
<string>Add Image</string>
368375
</property>
369376
</action>
377+
<action name="mActionMoveItemContent" >
378+
<property name="text" >
379+
<string>moveItemContent</string>
380+
</property>
381+
</action>
382+
<action name="mActionGroupItems" >
383+
<property name="text" >
384+
<string>Group Items</string>
385+
</property>
386+
</action>
387+
<action name="mActionUngroupItems" >
388+
<property name="text" >
389+
<string>Ungroup</string>
390+
</property>
391+
</action>
392+
<action name="mActionRaiseItems" >
393+
<property name="text" >
394+
<string>Raise</string>
395+
</property>
396+
</action>
397+
<action name="mActionLowerItems" >
398+
<property name="text" >
399+
<string>Lower</string>
400+
</property>
401+
</action>
402+
<action name="mActionMoveItemsToTop" >
403+
<property name="text" >
404+
<string>Bring to front</string>
405+
</property>
406+
</action>
407+
<action name="mActionMoveItemsToBottom" >
408+
<property name="text" >
409+
<string>Send to back</string>
410+
</property>
411+
</action>
370412
</widget>
371413
<tabstops>
372414
<tabstop>mOptionsTabWidget</tabstop>

0 commit comments

Comments
 (0)