-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsdecorationscalebardialog.cpp
92 lines (74 loc) · 2.91 KB
/
qgsdecorationscalebardialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/***************************************************************************
* Copyright (C) 2003 by Tim Sutton *
* *
* This is a plugin generated from the QGIS plugin template *
* *
* 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. *
***************************************************************************/
#include "qgsdecorationscalebardialog.h"
#include "qgsdecorationscalebar.h"
#include "qgslogger.h"
#include "qgscontexthelp.h"
#include <QColorDialog>
#include <QSettings>
QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar& deco, int units, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );
QSettings settings;
restoreGeometry( settings.value( "/Windows/DecorationScaleBar/geometry" ).toByteArray() );
// set the map units in the spin box
switch ( units )
{
case 0:
spnSize->setSuffix( tr( " metres/km" ) );
break;
case 1:
spnSize->setSuffix( tr( " feet/miles" ) );
break;
case 2:
spnSize->setSuffix( tr( " degrees" ) );
break;
default:
QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( units ) );
}
spnSize->setValue( mDeco.mPreferredSize );
chkSnapping->setChecked( mDeco.mSnapping );
cboPlacement->clear();
cboPlacement->addItems( mDeco.mPlacementLabels );
cboPlacement->setCurrentIndex( mDeco.mPlacementIndex );
chkEnable->setChecked( mDeco.enabled() );
cboStyle->clear();
cboStyle->addItems( mDeco.mStyleLabels );
cboStyle->setCurrentIndex( mDeco.mStyleIndex );
pbnChangeColor->setColor( mDeco.mColor );
pbnChangeColor->setContext( "gui" );
pbnChangeColor->setColorDialogTitle( tr( "Select scalebar color" ) );
}
QgsDecorationScaleBarDialog::~QgsDecorationScaleBarDialog()
{
QSettings settings;
settings.setValue( "/Windows/DecorationScaleBar/geometry", saveGeometry() );
}
void QgsDecorationScaleBarDialog::on_buttonBox_helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
}
void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
{
mDeco.mPlacementIndex = cboPlacement->currentIndex();
mDeco.mPreferredSize = spnSize->value();
mDeco.mSnapping = chkSnapping->isChecked();
mDeco.setEnabled( chkEnable->isChecked() );
mDeco.mStyleIndex = cboStyle->currentIndex();
mDeco.mColor = pbnChangeColor->color();
accept();
}
void QgsDecorationScaleBarDialog::on_buttonBox_rejected()
{
reject();
}