Showing with 568 additions and 1,836 deletions.
  1. +3 −0 images/images.qrc
  2. BIN {src/plugins/copyright_label → images/themes/default/plugins}/copyright_label.png
  3. BIN {src/plugins/north_arrow → images/themes/default/plugins}/north_arrow.png
  4. BIN {src/plugins/scale_bar → images/themes/default/plugins}/scale_bar.png
  5. 0 resources/context_help/{QgsCopyrightLabelPluginGui-de_DE → QgsDecorationCopyrightDialog-de_DE}
  6. 0 resources/context_help/{QgsCopyrightLabelPluginGui-en_US → QgsDecorationCopyrightDialog-en_US}
  7. 0 resources/context_help/{QgsCopyrightLabelPluginGui-es_ES → QgsDecorationCopyrightDialog-es_ES}
  8. 0 resources/context_help/{QgsCopyrightLabelPluginGui-fr_FR → QgsDecorationCopyrightDialog-fr_FR}
  9. 0 resources/context_help/{QgsCopyrightLabelPluginGui-it_IT → QgsDecorationCopyrightDialog-it_IT}
  10. 0 resources/context_help/{QgsCopyrightLabelPluginGui-ja_JP → QgsDecorationCopyrightDialog-ja_JP}
  11. 0 resources/context_help/{QgsCopyrightLabelPluginGui-pl_PL → QgsDecorationCopyrightDialog-pl_PL}
  12. 0 resources/context_help/{QgsCopyrightLabelPluginGui-pt_BR → QgsDecorationCopyrightDialog-pt_BR}
  13. 0 resources/context_help/{QgsCopyrightLabelPluginGui-ru_RU → QgsDecorationCopyrightDialog-ru_RU}
  14. 0 resources/context_help/{QgsCopyrightLabelPluginGui-sk_SK → QgsDecorationCopyrightDialog-sk_SK}
  15. 0 resources/context_help/{QgsCopyrightLabelPluginGui-sv_SE → QgsDecorationCopyrightDialog-sv_SE}
  16. 0 resources/context_help/{QgsNorthArrowPluginGui-de_DE → QgsDecorationNorthArrowDialog-de_DE}
  17. 0 resources/context_help/{QgsNorthArrowPluginGui-en_US → QgsDecorationNorthArrowDialog-en_US}
  18. 0 resources/context_help/{QgsNorthArrowPluginGui-fr_FR → QgsDecorationNorthArrowDialog-fr_FR}
  19. 0 resources/context_help/{QgsNorthArrowPluginGui-it_IT → QgsDecorationNorthArrowDialog-it_IT}
  20. 0 resources/context_help/{QgsNorthArrowPluginGui-ja_JP → QgsDecorationNorthArrowDialog-ja_JP}
  21. 0 resources/context_help/{QgsNorthArrowPluginGui-pt_BR → QgsDecorationNorthArrowDialog-pt_BR}
  22. 0 resources/context_help/{QgsScaleBarPluginGui-de_DE → QgsDecorationScaleBarDialog-de_DE}
  23. 0 resources/context_help/{QgsScaleBarPluginGui-en_US → QgsDecorationScaleBarDialog-en_US}
  24. 0 resources/context_help/{QgsScaleBarPluginGui-es_ES → QgsDecorationScaleBarDialog-es_ES}
  25. 0 resources/context_help/{QgsScaleBarPluginGui-fr_FR → QgsDecorationScaleBarDialog-fr_FR}
  26. 0 resources/context_help/{QgsScaleBarPluginGui-it_IT → QgsDecorationScaleBarDialog-it_IT}
  27. 0 resources/context_help/{QgsScaleBarPluginGui-ja_JP → QgsDecorationScaleBarDialog-ja_JP}
  28. 0 resources/context_help/{QgsScaleBarPluginGui-pl_PL → QgsDecorationScaleBarDialog-pl_PL}
  29. 0 resources/context_help/{QgsScaleBarPluginGui-pt_BR → QgsDecorationScaleBarDialog-pt_BR}
  30. +12 −0 src/app/CMakeLists.txt
  31. +25 −0 src/app/qgisapp.cpp
  32. +9 −0 src/app/qgisapp.h
  33. +152 −0 src/app/qgsdecorationcopyright.cpp
  34. +15 −45 src/{plugins/copyright_label/plugin.h → app/qgsdecorationcopyright.h}
  35. +34 −43 src/{plugins/copyright_label/plugingui.cpp → app/qgsdecorationcopyrightdialog.cpp}
  36. +13 −26 src/{plugins/copyright_label/plugingui.h → app/qgsdecorationcopyrightdialog.h}
  37. +29 −188 src/{plugins/north_arrow/plugin.cpp → app/qgsdecorationnortharrow.cpp}
  38. +21 −44 src/{plugins/north_arrow/plugin.h → app/qgsdecorationnortharrow.h}
  39. +36 −51 src/{plugins/north_arrow/plugingui.cpp → app/qgsdecorationnortharrowdialog.cpp}
  40. +10 −28 src/{plugins/north_arrow/plugingui.h → app/qgsdecorationnortharrowdialog.h}
  41. +33 −232 src/{plugins/scale_bar/plugin.cpp → app/qgsdecorationscalebar.cpp}
  42. +13 −51 src/{plugins/scale_bar/plugin.h → app/qgsdecorationscalebar.h}
  43. +92 −0 src/app/qgsdecorationscalebardialog.cpp
  44. +9 −27 src/{plugins/scale_bar/plugingui.h → app/qgsdecorationscalebardialog.h}
  45. +0 −3 src/plugins/CMakeLists.txt
  46. +0 −45 src/plugins/copyright_label/CMakeLists.txt
  47. +0 −15 src/plugins/copyright_label/README
  48. +0 −143 src/plugins/copyright_label/copyright.svg
  49. +0 −5 src/plugins/copyright_label/copyright_plugin.qrc
  50. +0 −329 src/plugins/copyright_label/plugin.cpp
  51. +0 −48 src/plugins/north_arrow/CMakeLists.txt
  52. +0 −15 src/plugins/north_arrow/README
  53. BIN src/plugins/north_arrow/images/logo.jpg
  54. BIN src/plugins/north_arrow/images/logo.xcf
  55. +0 −197 src/plugins/north_arrow/north_arrow.svg
  56. +0 −5 src/plugins/north_arrow/northarrow_plugin.qrc
  57. +0 −48 src/plugins/scale_bar/CMakeLists.txt
  58. +0 −97 src/plugins/scale_bar/plugingui.cpp
  59. +0 −124 src/plugins/scale_bar/scale_bar.svg
  60. +0 −5 src/plugins/scale_bar/scalebar_plugin.qrc
  61. +1 −0 src/ui/CMakeLists.txt
  62. +46 −1 src/ui/qgisapp.ui
  63. +5 −7 src/{plugins/copyright_label/pluginguibase.ui → ui/qgsdecorationcopyrightdialog.ui}
  64. +6 −8 src/{plugins/north_arrow/pluginguibase.ui → ui/qgsdecorationnortharrowdialog.ui}
  65. +4 −6 src/{plugins/scale_bar/pluginguibase.ui → ui/qgsdecorationscalebardialog.ui}
3 changes: 3 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
<file>north_arrows/default.png</file>
<file>themes/default/locked.png</file>
<file>themes/default/unlocked.png</file>
<file>themes/default/plugins/copyright_label.png</file>
<file>themes/default/plugins/north_arrow.png</file>
<file>themes/default/plugins/scale_bar.png</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
File renamed without changes
File renamed without changes
12 changes: 12 additions & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ SET(QGIS_APP_SRCS
qgscustomprojectiondialog.cpp
qgsdbfilterproxymodel.cpp
qgsdbtablemodel.cpp
qgsdecorationcopyright.cpp
qgsdecorationcopyrightdialog.cpp
qgsdecorationnortharrow.cpp
qgsdecorationnortharrowdialog.cpp
qgsdecorationscalebar.cpp
qgsdecorationscalebardialog.cpp
qgsembedlayerdialog.cpp
qgsformannotationdialog.cpp
qgsdelattrdialog.cpp
Expand Down Expand Up @@ -153,6 +159,12 @@ SET (QGIS_APP_MOC_HDRS
qgscustomization.h
qgscustomprojectiondialog.h
qgsdbtablemodel.h
qgsdecorationcopyright.h
qgsdecorationcopyrightdialog.h
qgsdecorationnortharrow.h
qgsdecorationnortharrowdialog.h
qgsdecorationscalebar.h
qgsdecorationscalebardialog.h
qgsdelattrdialog.h
qgsdisplayangle.h
qgsembedlayerdialog.h
Expand Down
25 changes: 25 additions & 0 deletions src/app/qgisapp.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
#include "qgscustomization.h"
#include "qgscustomprojectiondialog.h"
#include "qgsdatasourceuri.h"
#include "qgsdecorationcopyright.h"
#include "qgsdecorationnortharrow.h"
#include "qgsdecorationscalebar.h"
#include "qgsembedlayerdialog.h"
#include "qgsencodingfiledialog.h"
#include "qgsexception.h"
Expand Down Expand Up @@ -437,6 +440,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
initLegend();
createOverview();
createMapTips();
createDecorations();
readSettings();
updateRecentProjectPaths();
activateDeactivateLayerRelatedActions( NULL );
Expand Down Expand Up @@ -1470,6 +1474,9 @@ void QgisApp::setTheme( QString theThemeName )
mActionMoveLabel->setIcon( getThemeIcon( "/mActionMoveLabel.png" ) );
mActionRotateLabel->setIcon( getThemeIcon( "/mActionRotateLabel.png" ) );
mActionChangeLabelProperties->setIcon( getThemeIcon( "/mActionChangeLabelProperties.png" ) );
mActionDecorationCopyright->setIcon( getThemeIcon( "/plugins/copyright_label.png" ) );
mActionDecorationNorthArrow->setIcon( getThemeIcon( "/plugins/north_arrow.png" ) );
mActionDecorationScaleBar->setIcon( getThemeIcon( "/plugins/scale_bar.png" ) );

//change themes of all composers
QSet<QgsComposer*>::iterator composerIt = mPrintComposers.begin();
Expand Down Expand Up @@ -1803,6 +1810,24 @@ void QgisApp::createMapTips()
mpMaptip = new QgsMapTip();
}

void QgisApp::createDecorations()
{
mDecorationCopyright = new QgsDecorationCopyright( this );
connect( mActionDecorationCopyright, SIGNAL( triggered() ), mDecorationCopyright, SLOT( run() ) );
connect( mMapCanvas, SIGNAL( renderComplete( QPainter * ) ), mDecorationCopyright, SLOT( renderLabel( QPainter * ) ) );
connect( this, SIGNAL( projectRead() ), mDecorationCopyright, SLOT( projectRead() ) );

mDecorationNorthArrow = new QgsDecorationNorthArrow( this );
connect( mActionDecorationNorthArrow, SIGNAL( triggered() ), mDecorationNorthArrow, SLOT( run() ) );
connect( mMapCanvas, SIGNAL( renderComplete( QPainter * ) ), mDecorationNorthArrow, SLOT( renderNorthArrow( QPainter * ) ) );
connect( this, SIGNAL( projectRead() ), mDecorationNorthArrow, SLOT( projectRead() ) );

mDecorationScaleBar = new QgsDecorationScaleBar( this );
connect( mActionDecorationScaleBar, SIGNAL( triggered() ), mDecorationScaleBar, SLOT( run() ) );
connect( mMapCanvas, SIGNAL( renderComplete( QPainter * ) ), mDecorationScaleBar, SLOT( renderScaleBar( QPainter * ) ) );
connect( this, SIGNAL( projectRead() ), mDecorationScaleBar, SLOT( projectRead() ) );
}

// Update file menu with the current list of recently accessed projects
void QgisApp::updateRecentProjectPaths()
{
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class QgsBrowserDockWidget;
class QgsSnappingDialog;
class QgsGPSInformationWidget;

class QgsDecorationCopyright;
class QgsDecorationNorthArrow;
class QgsDecorationScaleBar;

#include <QMainWindow>
#include <QToolBar>
#include <QAbstractSocket>
Expand Down Expand Up @@ -864,6 +868,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
bool createDB();
void createMapTips();
void updateCRSStatusBar();
void createDecorations();

// actions for menus and toolbars -----------------

Expand Down Expand Up @@ -1051,6 +1056,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! Persistent tile scale slider
QgsTileScaleWidget * mpTileScaleWidget;

QgsDecorationCopyright* mDecorationCopyright;
QgsDecorationNorthArrow* mDecorationNorthArrow;
QgsDecorationScaleBar* mDecorationScaleBar;

int mLastComposerId;

#ifdef Q_OS_WIN
Expand Down
152 changes: 152 additions & 0 deletions src/app/qgsdecorationcopyright.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/***************************************************************************
plugin.cpp
Import tool for various worldmap analysis output files
Functions:
-------------------
begin : Jan 21, 2004
copyright : (C) 2004 by Tim Sutton
email : tim@linfiniti.com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

// includes

#include "qgsdecorationcopyright.h"
#include "qgsdecorationcopyrightdialog.h"

#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsproject.h"
#include "qgisapp.h"

#include <QPainter>
#include <QMenu>
#include <QDate>
#include <QTextDocument>
#include <QMatrix>
#include <QFile>

//non qt includes
#include <cmath>


QgsDecorationCopyright::QgsDecorationCopyright( QObject* parent )
: QObject(parent)
{
mPlacementLabels << tr( "Bottom Left" ) << tr( "Top Left" )
<< tr( "Top Right" ) << tr( "Bottom Right" );

// initialise default values in the gui
projectRead();
}

QgsDecorationCopyright::~QgsDecorationCopyright()
{}

void QgsDecorationCopyright::projectRead()
{
QDate now;
QString defString;

now = QDate::currentDate();
defString = "&copy; QGIS " + now.toString( "yyyy" );

// there is no font setting in the UI, so just use the Qt/QGIS default font (what mQFont gets when created)
// mQFont.setFamily( QgsProject::instance()->readEntry( "CopyrightLabel", "/FontName", "Sans Serif" ) );
// mQFont.setPointSize( QgsProject::instance()->readNumEntry( "CopyrightLabel", "/FontSize", 9 ) );
QgsProject* prj = QgsProject::instance();
mLabelQString = prj->readEntry( "CopyrightLabel", "/Label", defString );
mPlacementIndex = prj->readNumEntry( "CopyrightLabel", "/Placement", 3 );
mEnable = prj->readBoolEntry( "CopyrightLabel", "/Enabled", true );
mLabelQColor.setNamedColor( prj->readEntry( "CopyrightLabel", "/Color", "#000000" ) ); // default color is black
}

// Slot called when the buffer menu item is activated
void QgsDecorationCopyright::run()
{
QgsDecorationCopyrightDialog dlg( *this, QgisApp::instance() );

if (dlg.exec())
{
saveToProject();
QgisApp::instance()->mapCanvas()->refresh();
}
}


void QgsDecorationCopyright::renderLabel( QPainter * theQPainter )
{
//Large IF statement to enable/disable copyright label
if ( mEnable )
{
// need width/height of paint device
int myHeight = theQPainter->device()->height();
int myWidth = theQPainter->device()->width();

QTextDocument text;
text.setDefaultFont( mQFont );
// To set the text color in a QTextDocument we use a CSS style
QString style = "<style type=\"text/css\"> p {color: " +
mLabelQColor.name() + "}</style>";
text.setHtml( style + "<p>" + mLabelQString + "</p>" );
QSizeF size = text.size();

float myXOffset( 0 ), myYOffset( 0 );
//Determine placement of label from form combo box
switch ( mPlacementIndex )
{
case 0: // Bottom Left
//Define bottom left hand corner start point
myYOffset = myHeight - ( size.height() + 5 );
myXOffset = 5;
break;
case 1: // Top left
//Define top left hand corner start point
myYOffset = 0;;
myXOffset = 5;
break;
case 2: // Top Right
//Define top right hand corner start point
myYOffset = 0;
myXOffset = myWidth - ( size.width() + 5 );
break;
case 3: // Bottom Right
//Define bottom right hand corner start point
myYOffset = myHeight - ( size.height() + 5 );
myXOffset = myWidth - ( size.width() + 5 );
break;
default:
QgsDebugMsg( QString( "Unknown placement index of %1" ).arg( mPlacementIndex ) );
}

//Paint label to canvas
QMatrix worldMatrix = theQPainter->worldMatrix();
theQPainter->translate( myXOffset, myYOffset );
text.drawContents( theQPainter );
// Put things back how they were
theQPainter->setWorldMatrix( worldMatrix );
}
}

void QgsDecorationCopyright::saveToProject()
{
//save state to the project file.....
QgsProject* prj = QgsProject::instance();
prj->writeEntry( "CopyrightLabel", "/FontName", mQFont.family() );
prj->writeEntry( "CopyrightLabel", "/FontSize", mQFont.pointSize() );
prj->writeEntry( "CopyrightLabel", "/Label", mLabelQString );
prj->writeEntry( "CopyrightLabel", "/Color", mLabelQColor.name() );
prj->writeEntry( "CopyrightLabel", "/Placement", mPlacementIndex );
prj->writeEntry( "CopyrightLabel", "/Enabled", mEnable );
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,35 @@
***************************************************************************/
#ifndef QGSCOPYRIGHTLABELPLUGIN
#define QGSCOPYRIGHTLABELPLUGIN
#include "../qgisplugin.h"

#include <QColor>
#include <QFont>
#include <QObject>
class QAction;
class QPainter;

class QgisInterface;
class QgsDecorationCopyrightDialog;

/**
* \class Plugin
* \brief OpenModeller plugin for QGIS
*
*/
class QgsCopyrightLabelPlugin: public QObject, public QgisPlugin
class QgsDecorationCopyright : public QObject
{
Q_OBJECT public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param qI Pointer to the QgisInterface object.
*/
QgsCopyrightLabelPlugin( QgisInterface * );
Q_OBJECT
public:

//! Constructor
QgsDecorationCopyright( QObject* parent = NULL );
//! Destructor
virtual ~ QgsCopyrightLabelPlugin();
void writeEntry( QString theScope, QString theProperty, QVariant theValue );
virtual ~QgsDecorationCopyright();

public slots:
//! init the gui
void initGui();
//!set values on the gui when a project is read or the gui first loaded
//! set values on the gui when a project is read or the gui first loaded
void projectRead();
//! save values to the project
void saveToProject();

//! Show the dialog box
void run();
//! render the copyright label
void renderLabel( QPainter * );
//! Refresh the map display using the mapcanvas exported via the plugin interface
void refreshCanvas();
//! unload the plugin
void unload();
//! show the help document
void help();
//! change the copyright font
void setFont( QFont );
//! change the copyright text
void setLabel( QString );
//! change the copyright font color
void setColor( QColor );
//! set copyright label placement
void setPlacement( int );
//! set copyright label enabled
void setEnable( bool );
//! update the plugins theme when the app tells us its theme is changed
void setCurrentTheme( QString theThemeName );



private:
//! This is the font that will be used for the copyright label
Expand All @@ -87,11 +61,7 @@ class QgsCopyrightLabelPlugin: public QObject, public QgisPlugin
//! Copyright label enabled
bool mEnable;

int pluginType;
//! Pointer to the QGIS interface object
QgisInterface *qGisInterface;
//! Pointer to the QAction object used in the menu and toolbar
QAction *myQActionPointer;
friend class QgsDecorationCopyrightDialog;
};

#endif
Loading