Skip to content
Permalink
Browse files

Address snapping config UX problems

  • Loading branch information
m-kuhn committed Oct 25, 2016
1 parent f8bae67 commit a43f8a361655e8ade14f5052fa2b30c240a24966
Showing with 24 additions and 5 deletions.
  1. +1 −2 src/app/qgisapp.cpp
  2. +20 −3 src/app/qgssnappingwidget.cpp
  3. +2 −0 src/app/qgssnappingwidget.h
  4. +1 −0 src/core/qgsproject.cpp
@@ -823,9 +823,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
QDialog* dialog = new QDialog( this );
dialog->setWindowTitle( tr( "Project snapping settings" ) );
QVBoxLayout* layout = new QVBoxLayout( dialog );
QDialogButtonBox* button = new QDialogButtonBox( QDialogButtonBox::Close );
layout->addWidget( mSnappingDialogWidget );
layout->addWidget( button );
layout->setMargin( 0 );
mSnappingDialogContainer = dialog;
}
endProfile();
@@ -201,12 +201,15 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
mLayerTreeView = new QTreeView();
QgsSnappingLayerTreeModel* model = new QgsSnappingLayerTreeModel( mProject, this );
model->setLayerTreeModel( new QgsLayerTreeModel( QgsProject::instance()->layerTreeRoot(), model ) );

connect( model, &QgsSnappingLayerTreeModel::rowsInserted, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );
connect( model, &QgsSnappingLayerTreeModel::modelReset, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );
connect( model, &QgsSnappingLayerTreeModel::rowsRemoved, this, &QgsSnappingWidget::onSnappingTreeLayersChanged );

// model->setFlags( 0 );
mLayerTreeView->setModel( model );
mLayerTreeView->resizeColumnToContents( 0 );
mLayerTreeView->header()->show();
mLayerTreeView->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
mLayerTreeView->header()->setSectionResizeMode( QHeaderView::Interactive );
mLayerTreeView->setSelectionMode( QAbstractItemView::NoSelection );

// item delegates
@@ -230,9 +233,17 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
connect( project, &QgsProject::topologicalEditingChanged, this, &QgsSnappingWidget::projectTopologicalEditingChanged );
connect( mCanvas, SIGNAL( mapUnitsChanged() ), this, SLOT( updateToleranceDecimals() ) );


// Slightly modify the config so the settings changed code doesn't early exit
mConfig = project->snappingConfig();
mConfig.setEnabled( !mConfig.enabled() );
projectSnapSettingsChanged();

// modeChanged determines if widget are visible or not based on mode
modeChanged();
updateToleranceDecimals();

restoreGeometry( QSettings().value( "/Windows/SnappingWidget/geometry" ).toByteArray() );
}

QgsSnappingWidget::~QgsSnappingWidget()
@@ -252,7 +263,7 @@ void QgsSnappingWidget::projectSnapSettingsChanged()

mEnabledAction->setChecked( config.enabled() );

if ( config.mode() == QgsSnappingConfig::AllLayers && mModeButton->defaultAction() != mActiveLayerAction )
if ( config.mode() == QgsSnappingConfig::AllLayers && mModeButton->defaultAction() != mAllLayersAction )
{
mModeButton->setDefaultAction( mAllLayersAction );
modeChanged();
@@ -351,6 +362,12 @@ void QgsSnappingWidget::enableIntersectionSnapping( bool enabled )
mProject->setSnappingConfig( mConfig );
}

void QgsSnappingWidget::onSnappingTreeLayersChanged()
{
mLayerTreeView->resizeColumnToContents( 0 );
QTimer::singleShot( 0, mLayerTreeView, &QTreeView::expandAll );
}

void QgsSnappingWidget::modeButtonTriggered( QAction* action )
{
if ( action != mModeButton->defaultAction() )
@@ -91,6 +91,8 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
//! number of decimals of the tolerance spin box depends on map units
void updateToleranceDecimals();

void onSnappingTreeLayersChanged();

private:
enum DisplayMode
{
@@ -451,6 +451,7 @@ void QgsProject::clear()
mEmbeddedLayers.clear();
mRelationManager->clear();
mSnappingConfig.reset();
emit snappingConfigChanged();

mMapThemeCollection.reset( new QgsMapThemeCollection() );
emit mapThemeCollectionChanged();

0 comments on commit a43f8a3

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