Skip to content
Permalink
Browse files

[ui] add an horizontal mode for tile scale panel

  • Loading branch information
nirvn committed Aug 22, 2018
1 parent 560164d commit 1531c52802f182619e051cadd8f46d9701f8978a
Showing with 10 additions and 2 deletions.
  1. +9 −2 src/providers/wms/qgstilescalewidget.cpp
  2. +1 −0 src/providers/wms/qgstilescalewidget.h
@@ -35,8 +35,8 @@ QgsTileScaleWidget::QgsTileScaleWidget( QgsMapCanvas *mapCanvas, QWidget *parent
, mMapCanvas( mapCanvas )
{
setupUi( this );
connect( mSlider, &QSlider::valueChanged, this, &QgsTileScaleWidget::mSlider_valueChanged );

connect( mSlider, &QSlider::valueChanged, this, &QgsTileScaleWidget::mSlider_valueChanged );
connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, &QgsTileScaleWidget::scaleChanged );

layerChanged( mMapCanvas->currentLayer() );
@@ -110,6 +110,11 @@ void QgsTileScaleWidget::mSlider_valueChanged( int value )
mMapCanvas->zoomByFactor( mResolutions.at( mSlider->value() ) / mMapCanvas->mapUnitsPerPixel() );
}

void QgsTileScaleWidget::locationChanged( Qt::DockWidgetArea area )
{
mSlider->setOrientation( area == Qt::TopDockWidgetArea || area == Qt::BottomDockWidgetArea ? Qt::Horizontal : Qt::Vertical );
}

void QgsTileScaleWidget::showTileScale( QMainWindow *mainWindow )
{
QgsDockWidget *dock = mainWindow->findChild<QgsDockWidget *>( QStringLiteral( "theTileScaleDock" ) );
@@ -144,7 +149,9 @@ void QgsTileScaleWidget::showTileScale( QMainWindow *mainWindow )
//create the dock widget
dock = new QgsDockWidget( tr( "Tile Scale" ), mainWindow );
dock->setObjectName( QStringLiteral( "theTileScaleDock" ) );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

connect( dock, &QDockWidget::dockLocationChanged, tws, &QgsTileScaleWidget::locationChanged );

mainWindow->addDockWidget( Qt::RightDockWidgetArea, dock );

// add to the Panel submenu
@@ -36,6 +36,7 @@ class QgsTileScaleWidget : public QWidget, private Ui::QgsTileScaleWidget
void scaleChanged( double );
void mSlider_valueChanged( int );
void scaleEnabled( bool );
void locationChanged( Qt::DockWidgetArea area );

private:
QgsTileScaleWidget( QgsMapCanvas *mapCanvas, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );

0 comments on commit 1531c52

Please sign in to comment.
You can’t perform that action at this time.