26 mLayout =
new QGridLayout(
this );
27 mLayout->setContentsMargins( 0, 0, 0, 0 );
29 QLabel *minLbl =
new QLabel( tr(
"Minimum (exclusive)" ),
this );
30 minLbl->setWordWrap(
true );
31 minLbl->setAlignment( Qt::AlignTop );
32 minLbl->setToolTip( tr(
"Minimum scale, i.e. most \"zoomed out\". " 33 "This limit is exclusive, that means the layer will not be displayed on this scale." ) );
34 QLabel *maxLbl =
new QLabel( tr(
"Maximum (inclusive)" ),
this );
35 maxLbl->setWordWrap(
true );
36 maxLbl->setAlignment( Qt::AlignTop );
37 maxLbl->setToolTip( tr(
"Maximum scale, i.e. most \"zoomed in\". " 38 "This limit is inclusive, that means the layer will be displayed on this scale." ) );
41 mMinimumScaleIconLabel =
new QLabel(
this );
42 mMinimumScaleIconLabel->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomOut.svg" ) ).pixmap( QSize( iconSize, iconSize ) ) );
43 mMaximumScaleIconLabel =
new QLabel(
this );
44 mMaximumScaleIconLabel->setPixmap(
QgsApplication::getThemeIcon( QStringLiteral(
"/mActionZoomIn.svg" ) ).pixmap( QSize( iconSize, iconSize ) ) );
53 mMinimumScaleWidget->
setScale( 100000 );
54 mMaximumScaleWidget->
setScale( 1000 );
56 mLayout->addWidget( minLbl, 0, 0, 1, 2 );
57 mLayout->addWidget( mMinimumScaleIconLabel, 1, 0 );
58 mLayout->addWidget( mMinimumScaleWidget, 1, 1 );
59 mLayout->addWidget( maxLbl, 0, 2, 1, 2 );
60 mLayout->addWidget( mMaximumScaleIconLabel, 1, 2 );
61 mLayout->addWidget( mMaximumScaleWidget, 1, 3 );
63 mLayout->setColumnStretch( 0, 0 );
64 mLayout->setColumnStretch( 1, 3 );
65 mLayout->setColumnStretch( 2, 0 );
66 mLayout->setColumnStretch( 3, 3 );
77 QStringList scalesList;
79 scalesList.reserve( projectScales.size() );
80 for (
double scale : projectScales )
81 scalesList << QStringLiteral(
"1:%1" ).arg( scale );
95 mMinimumScaleWidget->
setScale( scale );
100 return mMinimumScaleWidget->
scale();
105 mMaximumScaleWidget->
setScale( scale );
110 return mMaximumScaleWidget->
scale();
119 void QgsScaleRangeWidget::emitRangeChanged()
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Map canvas is a class for displaying all GIS data types on a canvas.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
bool useProjectScales() const
Returns true if project mapScales() are enabled.
QVector< double > mapScales() const
Returns the list of custom project map scales.
static QgsProject * instance()
Returns the QgsProject singleton instance.