Skip to content
Permalink
Browse files
Do for the copyright label what has just been done for the scale bar
and north arrow (deal better with translated placement words).

Also tidy up scale bar and north arrow code a little bit.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5446 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed May 13, 2006
1 parent 868f1cf commit be1c6732c50e1f5612d6c42bcf7a1f5f6980aa48
@@ -69,7 +69,10 @@ QgsCopyrightLabelPlugin::QgsCopyrightLabelPlugin(QgisApp * theQGisApp,
QgisPlugin(name_,description_,version_,type_),
qgisMainWindowPointer(theQGisApp),
qGisInterface(theQgisInterFace)
{}
{
mPlacementLabels << tr("Bottom Left") << tr("Top Left")
<< tr("Top Right") << tr("Bottom Right");
}

QgsCopyrightLabelPlugin::~QgsCopyrightLabelPlugin()
{}
@@ -110,7 +113,7 @@ void QgsCopyrightLabelPlugin::projectRead()
mQFont.setFamily(QgsProject::instance()->readEntry("CopyrightLabel","/FontName","Arial"));
mQFont.setPointSize(QgsProject::instance()->readNumEntry("CopyrightLabel","/FontSize",14));
mLabelQString = QgsProject::instance()->readEntry("CopyrightLabel","/Label","&copy; QGIS 2006");
mPlacement = QgsProject::instance()->readEntry("CopyrightLabel","/Placement","Bottom Right");
mPlacementIndex = QgsProject::instance()->readNumEntry("CopyrightLabel","/Placement",3);
mEnable = QgsProject::instance()->readBoolEntry("CopyrightLabel","/Enabled",true);
// todo - read & store state of font color
mLabelQColor = QColor(Qt::black);
@@ -133,10 +136,11 @@ void QgsCopyrightLabelPlugin::run()
connect(myPluginGui, SIGNAL(changeFont(QFont )), this, SLOT(setFont(QFont )));
connect(myPluginGui, SIGNAL(changeLabel(QString )), this, SLOT(setLabel(QString )));
connect(myPluginGui, SIGNAL(changeColor(QColor)), this, SLOT(setColor(QColor)));
connect(myPluginGui, SIGNAL(changePlacement(QString)), this, SLOT(setPlacement(QString)));
connect(myPluginGui, SIGNAL(changePlacement(int)), this, SLOT(setPlacement(int)));
connect(myPluginGui, SIGNAL(enableCopyrightLabel(bool)), this, SLOT(setEnable(bool)));
myPluginGui->setText(mLabelQString);
myPluginGui->setPlacement(mPlacement);
myPluginGui->setPlacementLabels(mPlacementLabels);
myPluginGui->setPlacement(mPlacementIndex);
myPluginGui->show();
}
//! Refresh the map display using the mapcanvas exported via the plugin interface
@@ -167,31 +171,31 @@ void QgsCopyrightLabelPlugin::renderLabel(QPainter * theQPainter)
int myYOffset = myHeight;
int myXOffset = myWidth;


//Determine placement of label from form combo box
if (mPlacement==tr("Bottom Left"))
{
//Define bottom left hand corner start point
myYOffset = myYOffset - (myQSimpleText.height()+5);
myXOffset = 5;
}
else if (mPlacement==tr("Top Left"))
{
//Define top left hand corner start point
myYOffset = 5;
myXOffset = 5;
}
else if (mPlacement==tr("Top Right"))
{
//Define top right hand corner start point
myYOffset = 5;
myXOffset = myXOffset - (myQSimpleText.widthUsed()+5);
}
else // defaulting to bottom right
switch (mPlacementIndex)
{
//Define bottom right hand corner start point
myYOffset = myYOffset - (myQSimpleText.height()+5);
myXOffset = myXOffset - (myQSimpleText.widthUsed()+5);
case 0: // Bottom Left
//Define bottom left hand corner start point
myYOffset = myYOffset - (myQSimpleText.height()+5);
myXOffset = 5;
break;
case 1: // Top left
//Define top left hand corner start point
myYOffset = 5;
myXOffset = 5;
break;
case 2: // Top Right
//Define top right hand corner start point
myYOffset = 5;
myXOffset = myXOffset - (myQSimpleText.widthUsed()+5);
break;
case 3: // Bottom Right
//Define bottom right hand corner start point
myYOffset = myYOffset - (myQSimpleText.height()+5);
myXOffset = myXOffset - (myQSimpleText.widthUsed()+5);
break;
default:
std::cerr << "Unknown placement index of " << mPlacementIndex << '\n';
}

//Paint label to canvas
@@ -243,10 +247,10 @@ void QgsCopyrightLabelPlugin::setColor(QColor theQColor)
}

//! set placement of copyright label
void QgsCopyrightLabelPlugin::setPlacement(QString theQString)
void QgsCopyrightLabelPlugin::setPlacement(int placementIndex)
{
mPlacement = theQString;
QgsProject::instance()->writeEntry("CopyrightLabel","/Placement", mPlacement);
mPlacementIndex = placementIndex;
QgsProject::instance()->writeEntry("CopyrightLabel","/Placement", mPlacementIndex);
refreshCanvas();
}

@@ -63,7 +63,7 @@ class QgsCopyrightLabelPlugin:public QObject, public QgisPlugin
//! change the copyright font colour
void setColor(QColor);
//! set copyright label placement
void setPlacement(QString);
void setPlacement(int);
//! set copyright label enabled
void setEnable(bool);

@@ -76,8 +76,9 @@ class QgsCopyrightLabelPlugin:public QObject, public QgisPlugin
QString mLabelQString;
//! This is the colour for the copyright label
QColor mLabelQColor;
//! Placement of the copyright label
QString mPlacement;
//! Placement of the copyright label - index and translated label names
int mPlacementIndex;
QStringList mPlacementLabels;
//! Copyright label enabled
bool mEnable;

@@ -44,7 +44,7 @@ void QgsCopyrightLabelPluginGui::on_pbnOK_clicked()
emit changeFont(txtCopyrightText->currentFont());
emit changeLabel(txtCopyrightText->text());
emit changeColor(txtCopyrightText->color());
emit changePlacement(cboPlacement->currentText());
emit changePlacement(cboPlacement->currentIndex());
emit enableCopyrightLabel(cboxEnabled->isChecked());

done(1);
@@ -68,7 +68,13 @@ void QgsCopyrightLabelPluginGui::setText(QString theTextQString)
txtCopyrightText->setPlainText(theTextQString);
}

void QgsCopyrightLabelPluginGui::setPlacement(QString thePlacementQString)
void QgsCopyrightLabelPluginGui::setPlacementLabels(QStringList& labels)
{
cboPlacement->setCurrentText(tr(thePlacementQString));
cboPlacement->clear();
cboPlacement->addItems(labels);
}

void QgsCopyrightLabelPluginGui::setPlacement(int placementIndex)
{
cboPlacement->setCurrentIndex(placementIndex);
}
@@ -27,7 +27,8 @@ Q_OBJECT;
QgsCopyrightLabelPluginGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsCopyrightLabelPluginGui();
void setText(QString);
void setPlacement(QString);
void setPlacementLabels(QStringList&);
void setPlacement(int);

public slots:
void on_pbnOK_clicked();
@@ -44,7 +45,7 @@ public slots:
void changeFont(QFont);
void changeLabel(QString);
void changeColor(QColor);
void changePlacement(QString);
void changePlacement(int);
void enableCopyrightLabel(bool);

};
@@ -74,13 +74,12 @@ QgsNorthArrowPlugin::QgsNorthArrowPlugin(QgisApp * theQGisApp,
QgisIface * theQgisInterFace):
QgisPlugin(name_,description_,version_,type_),
qgisMainWindowPointer(theQGisApp),
qGisInterface(theQgisInterFace),
mPlacementIndex(1)
qGisInterface(theQgisInterFace)
{
mRotationInt=0;
mAutomatic=true;
mPlacementLabels << tr("Bottom Left") << tr("Top Left") << tr("Top Right") << tr("Bottom Right");
mPlacementIndex = 0;
mPlacementLabels << tr("Bottom Left") << tr("Top Left")
<< tr("Top Right") << tr("Bottom Right");
}

QgsNorthArrowPlugin::~QgsNorthArrowPlugin()
@@ -161,16 +161,6 @@ void QgsNorthArrowPluginGui::rotatePixmap(int theRotationInt)
}
}

// Called when the widget needs to be updated.
//
/*
void QgsNorthArrowPluginGui::paintEvent( QPaintEvent * thePaintEvent)
{
std::cerr<<__FILE__<<__LINE__<<'\n';
rotatePixmap(sliderRotation->value());
std::cerr<<__FILE__<<__LINE__<<'\n';
}
*/
//
// Called when the widget has been resized.
//
@@ -77,11 +77,13 @@ QgsScaleBarPlugin::QgsScaleBarPlugin(QgisApp * theQGisApp,
qgisMainWindowPointer(theQGisApp),
qGisInterface(theQgisInterFace)
{
mPlacementLabels << tr("Top Left") << tr("Bottom Left") << tr("Top Right") << tr("Bottom Right");
mStyleLabels << tr("Tick Down") << tr("Tick Up") << tr("Bar") << tr("Box");
mPlacementLabels << tr("Bottom Left") << tr("Top Left")
<< tr("Top Right") << tr("Bottom Right");
mPlacementIndex = 1;
mStyleLabels << tr("Tick Down") << tr("Tick Up")
<< tr("Bar") << tr("Box");

mPreferredSize = 30;
mPlacementIndex = 0;
mStyleIndex = 0;
mEnabled = true;
mSnapping = true;
@@ -129,7 +131,7 @@ void QgsScaleBarPlugin::projectRead()

mPreferredSize = QgsProject::instance()->readNumEntry("ScaleBar","/PreferredSize",30);
mStyleIndex = QgsProject::instance()->readNumEntry("ScaleBar","/Style",0);
mPlacementIndex = QgsProject::instance()->readNumEntry("ScaleBar","/Placement",0);
mPlacementIndex = QgsProject::instance()->readNumEntry("ScaleBar","/Placement",2);
mEnabled = QgsProject::instance()->readBoolEntry("ScaleBar","/Enabled",true);
mSnapping = QgsProject::instance()->readBoolEntry("ScaleBar","/Snapping",true);
int myRedInt = QgsProject::instance()->readNumEntry("ScaleBar","/ColorRedPart",0);
@@ -301,13 +303,13 @@ void QgsScaleBarPlugin::renderScaleBar(QPainter * theQPainter)
int myOriginY=myMargin;
switch (mPlacementIndex)
{
case 0: // Top Left
case 0: // Bottom Left
myOriginX=myMargin;
myOriginY=myMargin;
myOriginY=myCanvasHeight - myMargin;
break;
case 1: // Bottom Left
case 1: // Top Left
myOriginX=myMargin;
myOriginY=myCanvasHeight - myMargin;
myOriginY=myMargin;
break;
case 2: // Top Right
myOriginX=myCanvasWidth - ((int) myTotalScaleBarWidth) - myMargin;

0 comments on commit be1c673

Please sign in to comment.