Skip to content

Commit 5ca2c32

Browse files
committedAug 21, 2011
Moved north arrow plugin to app
1 parent 2095872 commit 5ca2c32

18 files changed

+130
-586
lines changed
 

‎images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@
351351
<file>themes/default/locked.png</file>
352352
<file>themes/default/unlocked.png</file>
353353
<file>themes/default/plugins/copyright_label.png</file>
354+
<file>themes/default/plugins/north_arrow.png</file>
354355
</qresource>
355356
<qresource prefix="/images/tips">
356357
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>

‎src/app/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ SET(QGIS_APP_SRCS
2323
qgsdbtablemodel.cpp
2424
qgsdecorationcopyright.cpp
2525
qgsdecorationcopyrightdialog.cpp
26+
qgsdecorationnortharrow.cpp
27+
qgsdecorationnortharrowdialog.cpp
2628
qgsembedlayerdialog.cpp
2729
qgsformannotationdialog.cpp
2830
qgsdelattrdialog.cpp
@@ -157,6 +159,8 @@ SET (QGIS_APP_MOC_HDRS
157159
qgsdbtablemodel.h
158160
qgsdecorationcopyright.h
159161
qgsdecorationcopyrightdialog.h
162+
qgsdecorationnortharrow.h
163+
qgsdecorationnortharrowdialog.h
160164
qgsdelattrdialog.h
161165
qgsdisplayangle.h
162166
qgsembedlayerdialog.h

‎src/app/qgisapp.cpp

100755100644
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
#include "qgscustomprojectiondialog.h"
116116
#include "qgsdatasourceuri.h"
117117
#include "qgsdecorationcopyright.h"
118+
#include "qgsdecorationnortharrow.h"
118119
#include "qgsembedlayerdialog.h"
119120
#include "qgsencodingfiledialog.h"
120121
#include "qgsexception.h"
@@ -1473,6 +1474,7 @@ void QgisApp::setTheme( QString theThemeName )
14731474
mActionRotateLabel->setIcon( getThemeIcon( "/mActionRotateLabel.png" ) );
14741475
mActionChangeLabelProperties->setIcon( getThemeIcon( "/mActionChangeLabelProperties.png" ) );
14751476
mActionDecorationCopyright->setIcon( getThemeIcon( "/plugins/copyright_label.png" ) );
1477+
mActionDecorationNorthArrow->setIcon( getThemeIcon( "/plugins/north_arrow.png" ) );
14761478

14771479
//change themes of all composers
14781480
QSet<QgsComposer*>::iterator composerIt = mPrintComposers.begin();
@@ -1808,10 +1810,15 @@ void QgisApp::createMapTips()
18081810

18091811
void QgisApp::createDecorations()
18101812
{
1811-
mDecorationCopyright = new QgsDecorationCopyright(this);
1813+
mDecorationCopyright = new QgsDecorationCopyright( this );
18121814
connect( mActionDecorationCopyright, SIGNAL( triggered() ), mDecorationCopyright, SLOT( run() ) );
18131815
connect( mMapCanvas, SIGNAL( renderComplete( QPainter * ) ), mDecorationCopyright, SLOT( renderLabel( QPainter * ) ) );
18141816
connect( this, SIGNAL( projectRead() ), mDecorationCopyright, SLOT( projectRead() ) );
1817+
1818+
mDecorationNorthArrow = new QgsDecorationNorthArrow( this );
1819+
connect( mActionDecorationNorthArrow, SIGNAL( triggered() ), mDecorationNorthArrow, SLOT( run() ) );
1820+
connect( mMapCanvas, SIGNAL( renderComplete( QPainter * ) ), mDecorationNorthArrow, SLOT( renderNorthArrow( QPainter * ) ) );
1821+
connect( this, SIGNAL( projectRead() ), mDecorationNorthArrow, SLOT( projectRead() ) );
18151822
}
18161823

18171824
// Update file menu with the current list of recently accessed projects

‎src/app/qgisapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class QgsSnappingDialog;
7070
class QgsGPSInformationWidget;
7171

7272
class QgsDecorationCopyright;
73+
class QgsDecorationNorthArrow;
7374

7475
#include <QMainWindow>
7576
#include <QToolBar>
@@ -1055,6 +1056,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
10551056
QgsTileScaleWidget * mpTileScaleWidget;
10561057

10571058
QgsDecorationCopyright* mDecorationCopyright;
1059+
QgsDecorationNorthArrow* mDecorationNorthArrow;
10581060

10591061
int mLastComposerId;
10601062

‎src/plugins/north_arrow/plugin.cpp renamed to ‎src/app/qgsdecorationnortharrow.cpp

Lines changed: 29 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ email : tim@linfiniti.com
2020
***************************************************************************/
2121

2222
// includes
23+
#include "qgsdecorationnortharrow.h"
2324

24-
#include "qgisinterface.h"
25-
#include "qgisgui.h"
25+
#include "qgsdecorationnortharrowdialog.h"
26+
27+
#include "qgisapp.h"
2628
#include "qgscoordinatetransform.h"
2729
#include "qgsmaplayer.h"
28-
#include "plugin.h"
2930
#include "qgsproject.h"
3031
#include "qgslogger.h"
3132
#include "qgsmapcanvas.h"
3233
#include "qgsmaprenderer.h"
33-
#include "qgsapplication.h"
3434

3535
// qt includes
3636
#include <QPainter>
@@ -43,22 +43,14 @@ email : tim@linfiniti.com
4343
#include <cmath>
4444
#include <cassert>
4545

46-
//the gui subclass
47-
#include "plugingui.h"
4846

4947
#ifdef _MSC_VER
5048
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
5149
#endif
5250

53-
static const QString name_ = QObject::tr( "NorthArrow" );
54-
static const QString description_ = QObject::tr( "Displays a north arrow overlayed onto the map" );
55-
static const QString version_ = QObject::tr( "Version 0.1" );
56-
static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
57-
static const QString icon_ = ":/north_arrow.png";
58-
59-
const double QgsNorthArrowPlugin::PI = 3.14159265358979323846;
51+
const double QgsDecorationNorthArrow::PI = 3.14159265358979323846;
6052
// const double QgsNorthArrowPlugin::DEG2RAD = 0.0174532925199433;
61-
const double QgsNorthArrowPlugin::TOL = 1e-8;
53+
const double QgsDecorationNorthArrow::TOL = 1e-8;
6254

6355

6456
/**
@@ -67,47 +59,22 @@ const double QgsNorthArrowPlugin::TOL = 1e-8;
6759
* @param qgis Pointer to the QGIS main window
6860
* @param _qI Pointer to the QGIS interface object
6961
*/
70-
QgsNorthArrowPlugin::QgsNorthArrowPlugin( QgisInterface * theQgisInterFace ):
71-
QgisPlugin( name_, description_, version_, type_ ),
72-
qGisInterface( theQgisInterFace )
62+
QgsDecorationNorthArrow::QgsDecorationNorthArrow( QObject* parent )
63+
: QObject( parent )
7364
{
7465
mRotationInt = 0;
7566
mAutomatic = true;
7667
mPlacementLabels << tr( "Bottom Left" ) << tr( "Top Left" )
7768
<< tr( "Top Right" ) << tr( "Bottom Right" );
78-
}
7969

80-
QgsNorthArrowPlugin::~QgsNorthArrowPlugin()
81-
{
70+
projectRead();
8271
}
8372

84-
/*
85-
* Initialize the GUI interface for the plugin
86-
*/
87-
void QgsNorthArrowPlugin::initGui()
73+
QgsDecorationNorthArrow::~QgsDecorationNorthArrow()
8874
{
89-
// Create the action for tool
90-
myQActionPointer = new QAction( QIcon(), tr( "&North Arrow" ), this );
91-
setCurrentTheme( "" );
92-
myQActionPointer->setWhatsThis( tr( "Creates a north arrow that is displayed on the map canvas" ) );
93-
// Connect the action to the run
94-
connect( myQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
95-
//render the arrow each time the map is rendered
96-
connect( qGisInterface->mapCanvas(), SIGNAL( renderComplete( QPainter * ) ), this, SLOT( renderNorthArrow( QPainter * ) ) );
97-
//this resets this plugin up if a project is loaded
98-
connect( qGisInterface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
99-
// Add the icon to the toolbar & appropriate menu
100-
qGisInterface->addToolBarIcon( myQActionPointer );
101-
qGisInterface->addPluginToMenu( tr( "&Decorations" ), myQActionPointer );
102-
// this is called when the icon theme is changed
103-
connect( qGisInterface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
104-
105-
projectRead();
106-
refreshCanvas();
107-
10875
}
10976

110-
void QgsNorthArrowPlugin::projectRead()
77+
void QgsDecorationNorthArrow::projectRead()
11178
{
11279
//default text to start with - try to fetch it from qgsproject
11380

@@ -117,40 +84,27 @@ void QgsNorthArrowPlugin::projectRead()
11784
mAutomatic = QgsProject::instance()->readBoolEntry( "NorthArrow", "/Automatic", true );
11885
}
11986

120-
//method defined in interface
121-
void QgsNorthArrowPlugin::help()
87+
void QgsDecorationNorthArrow::saveToProject()
12288
{
123-
//implement me!
89+
QgsProject::instance()->writeEntry( "NorthArrow", "/Rotation", mRotationInt );
90+
QgsProject::instance()->writeEntry( "NorthArrow", "/Placement", mPlacementIndex );
91+
QgsProject::instance()->writeEntry( "NorthArrow", "/Enabled", mEnable );
92+
QgsProject::instance()->writeEntry( "NorthArrow", "/Automatic", mAutomatic );
12493
}
12594

12695
// Slot called when the buffer menu item is activated
127-
void QgsNorthArrowPlugin::run()
96+
void QgsDecorationNorthArrow::run()
12897
{
129-
QgsNorthArrowPluginGui *myPluginGui = new QgsNorthArrowPluginGui( qGisInterface->mainWindow(), QgisGui::ModalDialogFlags );
130-
myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
131-
//overides function by the same name created in .ui
132-
myPluginGui->setRotation( mRotationInt );
133-
myPluginGui->setPlacementLabels( mPlacementLabels );
134-
myPluginGui->setPlacement( mPlacementIndex );
135-
myPluginGui->setEnabled( mEnable );
136-
myPluginGui->setAutomatic( mAutomatic );
137-
138-
//listen for when the layer has been made so we can draw it
139-
connect( myPluginGui, SIGNAL( rotationChanged( int ) ), this, SLOT( rotationChanged( int ) ) );
140-
connect( myPluginGui, SIGNAL( changePlacement( int ) ), this, SLOT( setPlacement( int ) ) );
141-
connect( myPluginGui, SIGNAL( enableAutomatic( bool ) ), this, SLOT( setAutomatic( bool ) ) );
142-
connect( myPluginGui, SIGNAL( enableNorthArrow( bool ) ), this, SLOT( setEnabled( bool ) ) );
143-
connect( myPluginGui, SIGNAL( needToRefresh() ), this, SLOT( refreshCanvas() ) );
144-
myPluginGui->show();
145-
}
98+
QgsDecorationNorthArrowDialog dlg( *this, QgisApp::instance() );
14699

147-
//! Refresh the map display using the mapcanvas exported via the plugin interface
148-
void QgsNorthArrowPlugin::refreshCanvas()
149-
{
150-
qGisInterface->mapCanvas()->refresh();
100+
if ( dlg.exec() )
101+
{
102+
saveToProject();
103+
QgisApp::instance()->mapCanvas()->refresh();
104+
}
151105
}
152106

153-
void QgsNorthArrowPlugin::renderNorthArrow( QPainter * theQPainter )
107+
void QgsDecorationNorthArrow::renderNorthArrow( QPainter * theQPainter )
154108
{
155109

156110
//Large IF statement controlled by enable check box
@@ -245,57 +199,16 @@ void QgsNorthArrowPlugin::renderNorthArrow( QPainter * theQPainter )
245199
}
246200

247201
}
248-
// Unload the plugin by cleaning up the GUI
249-
void QgsNorthArrowPlugin::unload()
250-
{
251-
// remove the GUI
252-
qGisInterface->removePluginMenu( tr( "&Decorations" ), myQActionPointer );
253-
qGisInterface->removeToolBarIcon( myQActionPointer );
254-
// remove the northarrow from the canvas
255-
disconnect( qGisInterface->mapCanvas(), SIGNAL( renderComplete( QPainter * ) ),
256-
this, SLOT( renderNorthArrow( QPainter * ) ) );
257-
refreshCanvas();
258-
259-
delete myQActionPointer;
260-
}
261-
262-
263-
void QgsNorthArrowPlugin::rotationChanged( int theInt )
264-
{
265-
mRotationInt = theInt;
266-
QgsProject::instance()->writeEntry( "NorthArrow", "/Rotation", mRotationInt );
267-
}
268-
269-
//! set placement of north arrow
270-
void QgsNorthArrowPlugin::setPlacement( int placementIndex )
271-
{
272-
mPlacementIndex = placementIndex;
273-
QgsProject::instance()->writeEntry( "NorthArrow", "/Placement", mPlacementIndex );
274-
}
275-
276-
void QgsNorthArrowPlugin::setEnabled( bool theBool )
277-
{
278-
mEnable = theBool;
279-
QgsProject::instance()->writeEntry( "NorthArrow", "/Enabled", mEnable );
280-
}
281-
282-
void QgsNorthArrowPlugin::setAutomatic( bool theBool )
283-
{
284-
mAutomatic = theBool;
285-
QgsProject::instance()->writeEntry( "NorthArrow", "/Automatic", mAutomatic );
286-
if ( mAutomatic )
287-
calculateNorthDirection();
288-
}
289202

290-
bool QgsNorthArrowPlugin::calculateNorthDirection()
203+
bool QgsDecorationNorthArrow::calculateNorthDirection()
291204
{
292-
QgsMapCanvas& mapCanvas = *( qGisInterface->mapCanvas() );
205+
QgsMapCanvas* mapCanvas = QgisApp::instance()->mapCanvas();
293206

294207
bool goodDirn = false;
295208

296-
if ( mapCanvas.layerCount() > 0 )
209+
if ( mapCanvas->layerCount() > 0 )
297210
{
298-
QgsCoordinateReferenceSystem outputCRS = mapCanvas.mapRenderer()->destinationCrs();
211+
QgsCoordinateReferenceSystem outputCRS = mapCanvas->mapRenderer()->destinationCrs();
299212

300213
if ( outputCRS.isValid() && !outputCRS.geographicFlag() )
301214
{
@@ -306,7 +219,7 @@ bool QgsNorthArrowPlugin::calculateNorthDirection()
306219

307220
QgsCoordinateTransform transform( outputCRS, ourCRS );
308221

309-
QgsRectangle extent = mapCanvas.extent();
222+
QgsRectangle extent = mapCanvas->extent();
310223
QgsPoint p1( extent.center() );
311224
// A point a bit above p1. XXX assumes that y increases up!!
312225
// May need to involve the maptopixel transform if this proves
@@ -388,75 +301,3 @@ bool QgsNorthArrowPlugin::calculateNorthDirection()
388301
}
389302
return goodDirn;
390303
}
391-
392-
//! Set icons to the current theme
393-
void QgsNorthArrowPlugin::setCurrentTheme( QString theThemeName )
394-
{
395-
Q_UNUSED( theThemeName );
396-
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/north_arrow.png";
397-
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/north_arrow.png";
398-
QString myQrcPath = ":/north_arrow.png";
399-
if ( QFile::exists( myCurThemePath ) )
400-
{
401-
myQActionPointer->setIcon( QIcon( myCurThemePath ) );
402-
}
403-
else if ( QFile::exists( myDefThemePath ) )
404-
{
405-
myQActionPointer->setIcon( QIcon( myDefThemePath ) );
406-
}
407-
else if ( QFile::exists( myQrcPath ) )
408-
{
409-
myQActionPointer->setIcon( QIcon( myQrcPath ) );
410-
}
411-
else
412-
{
413-
myQActionPointer->setIcon( QIcon() );
414-
}
415-
}
416-
417-
/**
418-
* Required extern functions needed for every plugin
419-
* These functions can be called prior to creating an instance
420-
* of the plugin class
421-
*/
422-
// Class factory to return a new instance of the plugin class
423-
QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
424-
{
425-
return new QgsNorthArrowPlugin( theQgisInterfacePointer );
426-
}
427-
428-
// Return the name of the plugin - note that we do not user class members as
429-
// the class may not yet be insantiated when this method is called.
430-
QGISEXTERN QString name()
431-
{
432-
return name_;
433-
}
434-
435-
// Return the description
436-
QGISEXTERN QString description()
437-
{
438-
return description_;
439-
}
440-
441-
// Return the type (either UI or MapLayer plugin)
442-
QGISEXTERN int type()
443-
{
444-
return type_;
445-
}
446-
447-
// Return the version number for the plugin
448-
QGISEXTERN QString version()
449-
{
450-
return version_;
451-
}
452-
453-
QGISEXTERN QString icon()
454-
{
455-
return icon_;
456-
}
457-
458-
// Delete ourself
459-
QGISEXTERN void unload( QgisPlugin * thePluginPointer )
460-
{
461-
delete thePluginPointer;
462-
}

‎src/plugins/north_arrow/plugin.h renamed to ‎src/app/qgsdecorationnortharrow.h

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,60 +19,39 @@
1919
#ifndef QGSNORTHARROWPLUGIN
2020
#define QGSNORTHARROWPLUGIN
2121

22-
#include "../qgisplugin.h"
23-
2422
#include <QObject>
2523
#include <QStringList>
26-
class QgisInterface;
24+
2725
class QAction;
2826
class QToolBar;
2927
class QPainter;
30-
/**
31-
* \class Plugin
32-
* \brief North Arrow plugin for QGIS
33-
*
34-
*/
35-
class QgsNorthArrowPlugin: public QObject, public QgisPlugin
28+
29+
class QgsDecorationNorthArrow: public QObject
3630
{
37-
Q_OBJECT public:
38-
/**
39-
* Constructor for a plugin. The QgisInterface pointer is passed by
40-
* QGIS when it attempts to instantiate the plugin.
41-
* @param qI Pointer to the QgisInterface object.
42-
*/
43-
QgsNorthArrowPlugin( QgisInterface * );
31+
Q_OBJECT
32+
33+
public:
34+
//! Constructor
35+
QgsDecorationNorthArrow( QObject* parent = NULL );
4436
//! Destructor
45-
virtual ~QgsNorthArrowPlugin();
37+
virtual ~QgsDecorationNorthArrow();
38+
4639
public slots:
47-
//! init the gui
48-
virtual void initGui();
49-
//!set values on the gui when a project is read or the gui first loaded
40+
//! set values on the gui when a project is read or the gui first loaded
5041
void projectRead();
42+
//! save values to the project
43+
void saveToProject();
44+
5145
//! Show the dialog box
5246
void run();
53-
// draw some arbitary text to the screen
47+
//! draw some arbitary text to the screen
5448
void renderNorthArrow( QPainter * );
55-
//! Run when the user has set a new rotation
56-
void rotationChanged( int );
57-
//! Refresh the map display using the mapcanvas exported via the plugin interface
58-
void refreshCanvas();
59-
//! unload the plugin
60-
void unload();
61-
//! show the help document
62-
void help();
63-
//! set north arrow placement
64-
void setPlacement( int );
65-
//! enable or disable north arrow
66-
void setEnabled( bool );
67-
//! enable or disable the automatic setting of the arrow direction
68-
void setAutomatic( bool );
49+
6950
//! try to calculate the direction for the north arrow. Sets the
70-
// private class rotation variable. If unable to calculate the
71-
// direction, the function returns false and leaves the rotation
72-
// variable as is.
51+
//! private class rotation variable. If unable to calculate the
52+
//! direction, the function returns false and leaves the rotation
53+
//! variable as is.
7354
bool calculateNorthDirection();
74-
//! update the plugins theme when the app tells us its theme is changed
75-
void setCurrentTheme( QString theThemeName );
7655

7756
private:
7857

@@ -90,10 +69,8 @@ class QgsNorthArrowPlugin: public QObject, public QgisPlugin
9069
// The placement index and translated text
9170
int mPlacementIndex;
9271
QStringList mPlacementLabels;
93-
//! Pointer to the QGIS interface object
94-
QgisInterface *qGisInterface;
95-
//! Pointer to the QAction object used in the menu and toolbar
96-
QAction *myQActionPointer;
72+
73+
friend class QgsDecorationNorthArrowDialog;
9774
};
9875

9976
#endif

‎src/plugins/north_arrow/plugingui.cpp renamed to ‎src/app/qgsdecorationnortharrowdialog.cpp

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,92 +9,77 @@
99
* the Free Software Foundation; either version 2 of the License, or *
1010
* (at your option) any later version. *
1111
***************************************************************************/
12-
#include "plugingui.h"
13-
#include "qgsapplication.h"
12+
13+
#include "qgsdecorationnortharrowdialog.h"
14+
15+
#include "qgsdecorationnortharrow.h"
16+
17+
#include "qgslogger.h"
1418
#include "qgscontexthelp.h"
1519

1620
#include <QPainter>
1721
#include <cmath>
18-
#include "qgslogger.h"
1922

2023

21-
QgsNorthArrowPluginGui::QgsNorthArrowPluginGui( QWidget* parent, Qt::WFlags fl )
22-
: QDialog( parent, fl )
24+
QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent )
25+
: QDialog( parent ), mDeco( deco )
2326
{
2427
setupUi( this );
25-
}
26-
27-
QgsNorthArrowPluginGui::~QgsNorthArrowPluginGui()
28-
{
29-
}
30-
31-
void QgsNorthArrowPluginGui::on_buttonBox_accepted()
32-
{
33-
// Hide the dialog
34-
hide();
35-
//close the dialog
36-
emit rotationChanged( sliderRotation->value() );
37-
emit enableAutomatic( cboxAutomatic->isChecked() );
38-
emit changePlacement( cboPlacement->currentIndex() );
39-
emit enableNorthArrow( cboxShow->isChecked() );
40-
emit needToRefresh();
41-
42-
accept();
43-
}
4428

45-
void QgsNorthArrowPluginGui::on_buttonBox_rejected()
46-
{
47-
reject();
48-
}
49-
50-
void QgsNorthArrowPluginGui::setRotation( int theInt )
51-
{
52-
rotatePixmap( theInt );
53-
//sliderRotation->setValue(theInt);
29+
// rotation
30+
rotatePixmap( mDeco.mRotationInt );
5431
// signal/slot connection defined in 'designer' causes the slider to
5532
// be moved to reflect the change in the spinbox.
56-
spinAngle->setValue( theInt );
57-
}
33+
spinAngle->setValue( mDeco.mRotationInt );
5834

59-
void QgsNorthArrowPluginGui::setPlacementLabels( QStringList& labels )
60-
{
35+
// placement
6136
cboPlacement->clear();
62-
cboPlacement->addItems( labels );
37+
cboPlacement->addItems( mDeco.mPlacementLabels );
38+
cboPlacement->setCurrentIndex( mDeco.mPlacementIndex );
39+
40+
// enabled
41+
cboxShow->setChecked( mDeco.mEnable );
42+
43+
// automatic
44+
cboxAutomatic->setChecked( mDeco.mAutomatic );
6345
}
6446

65-
void QgsNorthArrowPluginGui::setPlacement( int placementIndex )
47+
QgsDecorationNorthArrowDialog::~QgsDecorationNorthArrowDialog()
6648
{
67-
cboPlacement->setCurrentIndex( placementIndex );
6849
}
6950

70-
void QgsNorthArrowPluginGui::setEnabled( bool theBool )
51+
void QgsDecorationNorthArrowDialog::on_buttonBox_helpRequested()
7152
{
72-
cboxShow->setChecked( theBool );
53+
QgsContextHelp::run( metaObject()->className() );
7354
}
7455

75-
void QgsNorthArrowPluginGui::setAutomatic( bool theBool )
56+
void QgsDecorationNorthArrowDialog::on_buttonBox_accepted()
7657
{
77-
cboxAutomatic->setChecked( theBool );
58+
mDeco.mRotationInt = sliderRotation->value();
59+
mDeco.mPlacementIndex = cboPlacement->currentIndex();
60+
mDeco.mEnable = cboxShow->isChecked();
61+
mDeco.mAutomatic = cboxAutomatic->isChecked();
62+
63+
accept();
7864
}
7965

80-
void QgsNorthArrowPluginGui::setAutomaticDisabled()
66+
void QgsDecorationNorthArrowDialog::on_buttonBox_rejected()
8167
{
82-
cboxAutomatic->setEnabled( false );
68+
reject();
8369
}
8470

8571

86-
//overides function by the same name created in .ui
87-
void QgsNorthArrowPluginGui::on_spinAngle_valueChanged( int theInt )
72+
void QgsDecorationNorthArrowDialog::on_spinAngle_valueChanged( int theInt )
8873
{
8974
Q_UNUSED( theInt );
9075
}
9176

92-
void QgsNorthArrowPluginGui::on_sliderRotation_valueChanged( int theInt )
77+
void QgsDecorationNorthArrowDialog::on_sliderRotation_valueChanged( int theInt )
9378
{
9479
rotatePixmap( theInt );
9580
}
9681

97-
void QgsNorthArrowPluginGui::rotatePixmap( int theRotationInt )
82+
void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
9883
{
9984
QPixmap myQPixmap;
10085
QString myFileNameQString = ":/images/north_arrows/default.png";
@@ -157,7 +142,7 @@ void QgsNorthArrowPluginGui::rotatePixmap( int theRotationInt )
157142
// Called when the widget has been resized.
158143
//
159144

160-
void QgsNorthArrowPluginGui::resizeEvent( QResizeEvent *theResizeEvent )
145+
void QgsDecorationNorthArrowDialog::resizeEvent( QResizeEvent *theResizeEvent )
161146
{
162147
Q_UNUSED( theResizeEvent );
163148
rotatePixmap( sliderRotation->value() );

‎src/plugins/north_arrow/plugingui.h renamed to ‎src/app/qgsdecorationnortharrowdialog.h

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,31 @@
1212
#ifndef QGSNORTHARROWPLUGINGUI_H
1313
#define QGSNORTHARROWPLUGINGUI_H
1414

15-
#include "ui_pluginguibase.h"
16-
#include "qgscontexthelp.h"
15+
#include "ui_qgsdecorationnortharrowdialog.h"
1716

18-
/**
19-
@author Tim Sutton
20-
*/
21-
class QgsNorthArrowPluginGui : public QDialog, private Ui::QgsNorthArrowPluginGuiBase
17+
class QgsDecorationNorthArrow;
18+
19+
class QgsDecorationNorthArrowDialog : public QDialog, private Ui::QgsDecorationNorthArrowDialog
2220
{
2321
Q_OBJECT
2422

2523
public:
26-
QgsNorthArrowPluginGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
27-
~QgsNorthArrowPluginGui();
24+
QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent = 0 );
25+
~QgsDecorationNorthArrowDialog();
2826

2927
private:
3028
void rotatePixmap( int theRotationInt );
31-
// void paintEvent( QPaintEvent * );//overloads qwidget
3229
void resizeEvent( QResizeEvent * ); //overloads qwidget
3330

34-
signals:
35-
//void drawRasterLayer(QString);
36-
//void drawVectorrLayer(QString,QString,QString);
37-
void rotationChanged( int );
38-
void changePlacement( int );
39-
// enable NorthArrow
40-
void enableNorthArrow( bool );
41-
void enableAutomatic( bool );
42-
void needToRefresh();
43-
44-
public slots:
45-
void setRotation( int );
46-
void setPlacementLabels( QStringList& );
47-
void setPlacement( int );
48-
void setEnabled( bool );
49-
void setAutomatic( bool );
50-
void setAutomaticDisabled();
51-
5231
private slots:
5332
void on_buttonBox_accepted();
5433
void on_buttonBox_rejected();
55-
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
34+
void on_buttonBox_helpRequested();
5635
void on_spinAngle_valueChanged( int theInt );
5736
void on_sliderRotation_valueChanged( int theInt );
37+
38+
protected:
39+
QgsDecorationNorthArrow& mDeco;
5840
};
5941

6042
#endif

‎src/plugins/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDI
55
ADD_SUBDIRECTORY(delimited_text)
66
ADD_SUBDIRECTORY(diagram_overlay)
77
ADD_SUBDIRECTORY(interpolation)
8-
ADD_SUBDIRECTORY(north_arrow)
98
ADD_SUBDIRECTORY(scale_bar)
109
ADD_SUBDIRECTORY(oracle_raster)
1110
ADD_SUBDIRECTORY(raster_terrain_analysis)

‎src/plugins/north_arrow/CMakeLists.txt

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎src/plugins/north_arrow/README

Lines changed: 0 additions & 15 deletions
This file was deleted.
-16 KB
Binary file not shown.
-449 KB
Binary file not shown.

‎src/plugins/north_arrow/north_arrow.svg

Lines changed: 0 additions & 197 deletions
This file was deleted.

‎src/plugins/north_arrow/northarrow_plugin.qrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎src/ui/qgisapp.ui

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<string>&amp;Decorations</string>
104104
</property>
105105
<addaction name="mActionDecorationCopyright"/>
106+
<addaction name="mActionDecorationNorthArrow"/>
106107
</widget>
107108
<addaction name="mActionPan"/>
108109
<addaction name="mActionZoomIn"/>
@@ -1502,6 +1503,18 @@
15021503
<string>Creates a copyright label that is displayed on the map canvas.</string>
15031504
</property>
15041505
</action>
1506+
<action name="mActionDecorationNorthArrow">
1507+
<property name="icon">
1508+
<iconset resource="../../images/images.qrc">
1509+
<normaloff>:/images/themes/default/plugins/north_arrow.png</normaloff>:/images/themes/default/plugins/north_arrow.png</iconset>
1510+
</property>
1511+
<property name="text">
1512+
<string>&amp;North Arrow</string>
1513+
</property>
1514+
<property name="whatsThis">
1515+
<string>&quot;Creates a north arrow that is displayed on the map canvas&quot;</string>
1516+
</property>
1517+
</action>
15051518
</widget>
15061519
<resources>
15071520
<include location="../../images/images.qrc"/>

‎src/plugins/north_arrow/pluginguibase.ui renamed to ‎src/ui/qgsdecorationnortharrowdialog.ui

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ui version="4.0">
3-
<class>QgsNorthArrowPluginGuiBase</class>
4-
<widget class="QDialog" name="QgsNorthArrowPluginGuiBase">
3+
<class>QgsDecorationNorthArrowDialog</class>
4+
<widget class="QDialog" name="QgsDecorationNorthArrowDialog">
55
<property name="geometry">
66
<rect>
77
<x>0</x>
@@ -11,7 +11,7 @@
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>North Arrow Plugin</string>
14+
<string>North Arrow Decoration</string>
1515
</property>
1616
<property name="windowIcon">
1717
<iconset>
@@ -35,7 +35,7 @@
3535
<string>Preview of north arrow</string>
3636
</property>
3737
<property name="frameShape">
38-
<enum>QFrame::Box</enum>
38+
<enum>QFrame::StyledPanel</enum>
3939
</property>
4040
<property name="scaledContents">
4141
<bool>false</bool>
@@ -44,7 +44,7 @@
4444
<set>Qt::AlignCenter</set>
4545
</property>
4646
</widget>
47-
<widget class="QWidget" name="">
47+
<widget class="QWidget" name="layoutWidget">
4848
<layout class="QGridLayout" name="gridLayout">
4949
<item row="0" column="0">
5050
<widget class="QLabel" name="textLabel6">
@@ -189,9 +189,7 @@
189189
<tabstop>cboxAutomatic</tabstop>
190190
<tabstop>buttonBox</tabstop>
191191
</tabstops>
192-
<resources>
193-
<include location="northarrow_plugin.qrc"/>
194-
</resources>
192+
<resources/>
195193
<connections>
196194
<connection>
197195
<sender>sliderRotation</sender>

0 commit comments

Comments
 (0)
Please sign in to comment.