Skip to content
Permalink
Browse files

Remove snapping settings from status bar

  • Loading branch information
m-kuhn committed Oct 26, 2016
1 parent 42b9bff commit 322edff6e490357b75e705ec0a0db4fc27f26f69
Showing with 117 additions and 167 deletions.
  1. +5 −21 src/app/qgisapp.cpp
  2. +0 −5 src/app/qgsoptions.cpp
  3. +25 −43 src/app/qgssnappingwidget.cpp
  4. +0 −1 src/app/qgssnappingwidget.h
  5. +87 −97 src/ui/qgsoptionsbase.ui
@@ -2069,16 +2069,11 @@ void QgisApp::createToolBars()
<< mLabelToolBar;


// snapping widget as tool bar
QString simpleSnappingWidgetMode = QSettings().value( QStringLiteral( "/qgis/simpleSnappingWidgetMode" ), "toolbar" ).toString();
if ( simpleSnappingWidgetMode != QLatin1String( "statusbar" ) )
{
mSnappingWidget = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, mSnappingToolBar );
mSnappingWidget->setObjectName( QStringLiteral( "mSnappingWidget" ) );
//mSnappingWidget->setFont( myFont );
connect( mSnappingWidget, SIGNAL( snappingConfigChanged() ), QgsProject::instance(), SIGNAL( snappingConfigChanged() ) );
mSnappingToolBar->addWidget( mSnappingWidget );
}
mSnappingWidget = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, mSnappingToolBar );
mSnappingWidget->setObjectName( QStringLiteral( "mSnappingWidget" ) );
//mSnappingWidget->setFont( myFont );
connect( mSnappingWidget, SIGNAL( snappingConfigChanged() ), QgsProject::instance(), SIGNAL( snappingConfigChanged() ) );
mSnappingToolBar->addWidget( mSnappingWidget );

QList<QAction*> toolbarMenuActions;
// Set action names so that they can be used in customization
@@ -2427,17 +2422,6 @@ void QgisApp::createStatusBar()
mRotationLabel->setToolTip( tr( "Current clockwise map rotation in degrees" ) );
statusBar()->addPermanentWidget( mRotationLabel, 0 );

// snapping widget
QString simpleSnappingWidgetMode = QSettings().value( QStringLiteral( "/qgis/simpleSnappingWidgetMode" ), "toolbar" ).toString();
if ( simpleSnappingWidgetMode == QLatin1String( "statusbar" ) )
{
mSnappingWidget = new QgsSnappingWidget( QgsProject::instance(), mMapCanvas, statusBar() );
mSnappingWidget->setObjectName( QStringLiteral( "mSnappingWidget" ) );
mSnappingWidget->setFont( myFont );
connect( mSnappingWidget, SIGNAL( snappingConfigChanged() ), QgsProject::instance(), SIGNAL( snappingConfigChanged() ) );
statusBar()->addPermanentWidget( mSnappingWidget, 0 );
}

mRotationEdit = new QgsDoubleSpinBox( statusBar() );
mRotationEdit->setObjectName( QStringLiteral( "mRotationEdit" ) );
mRotationEdit->setClearValue( 0.0 );
@@ -915,10 +915,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mSnappingMainDialogComboBox->addItem( tr( "dialog" ), "dialog" );
mSnappingMainDialogComboBox->addItem( tr( "dock" ), "dock" );
mSnappingMainDialogComboBox->setCurrentIndex( mSnappingMainDialogComboBox->findData( mSettings->value( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), "dialog" ).toString() ) );
mSnappingSimplePanelComboBox->clear();
mSnappingSimplePanelComboBox->addItem( tr( "tool bar" ), "toolbar" );
mSnappingSimplePanelComboBox->addItem( tr( "status bar" ), "statusbar" );
mSnappingSimplePanelComboBox->setCurrentIndex( mSnappingSimplePanelComboBox->findData( mSettings->value( QStringLiteral( "/qgis/simpleSnappingWidgetMode" ), "toolbar" ).toString() ) );

mOffsetJoinStyleComboBox->addItem( tr( "Round" ), 0 );
mOffsetJoinStyleComboBox->addItem( tr( "Mitre" ), 1 );
@@ -1191,7 +1187,6 @@ void QgsOptions::saveOptions()
cmbScanZipInBrowser->currentData().toString() );
mSettings->setValue( QStringLiteral( "/qgis/ignoreShapeEncoding" ), cbxIgnoreShapeEncoding->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/mainSnappingWidgetMode" ), mSnappingMainDialogComboBox->currentData() );
mSettings->setValue( QStringLiteral( "/qgis/simpleSnappingWidgetMode" ), mSnappingSimplePanelComboBox->currentData() );

mSettings->setValue( QStringLiteral( "/qgis/addPostgisDC" ), cbxAddPostgisDC->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/addOracleDC" ), cbxAddOracleDC->isChecked() );
@@ -22,7 +22,6 @@
#include <QHeaderView>
#include <QMenu>
#include <QSettings>
#include <QStatusBar>
#include <QToolBar>
#include <QToolButton>

@@ -59,17 +58,8 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
}
else
{
QStatusBar *sb = qobject_cast<QStatusBar*>( parent );
if ( sb )
{
mDisplayMode = StatusBar;
setObjectName( QStringLiteral( "SnappingOptionStatusBar" ) );
}
else
{
mDisplayMode = Widget;
setObjectName( QStringLiteral( "SnappingOptionDialog" ) );
}
mDisplayMode = Widget;
setObjectName( QStringLiteral( "SnappingOptionDialog" ) );
}

// enable button
@@ -162,7 +152,7 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
}
else
{
// mode = widget or status bar
// mode = widget
QHBoxLayout* layout = new QHBoxLayout();

QToolButton* enabledButton = new QToolButton();
@@ -196,36 +186,28 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject* project, QgsMapCanvas* canvas,
layout->setAlignment( Qt::AlignRight );
layout->setSpacing( mDisplayMode == Widget ? 3 : 0 );

if ( mDisplayMode == Widget )
{
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->setSelectionMode( QAbstractItemView::NoSelection );

// item delegates
mLayerTreeView->setEditTriggers( QAbstractItemView::AllEditTriggers );
mLayerTreeView->setItemDelegate( new QgsSnappingLayerDelegate( mCanvas, this ) );

QGridLayout* topLayout = new QGridLayout();
topLayout->addLayout( layout, 0, 0, Qt::AlignLeft | Qt::AlignTop );
topLayout->addWidget( mLayerTreeView, 1, 0 );
setLayout( topLayout );
}
else
{
// mode = status bar
setLayout( layout );
}
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->setSelectionMode( QAbstractItemView::NoSelection );

// item delegates
mLayerTreeView->setEditTriggers( QAbstractItemView::AllEditTriggers );
mLayerTreeView->setItemDelegate( new QgsSnappingLayerDelegate( mCanvas, this ) );

QGridLayout* topLayout = new QGridLayout();
topLayout->addLayout( layout, 0, 0, Qt::AlignLeft | Qt::AlignTop );
topLayout->addWidget( mLayerTreeView, 1, 0 );
setLayout( topLayout );
}

// connect settings changed and map units changed to properly update the widget
@@ -97,7 +97,6 @@ class APP_EXPORT QgsSnappingWidget : public QWidget
enum DisplayMode
{
ToolBar,
StatusBar,
Widget
};
DisplayMode mDisplayMode;

0 comments on commit 322edff

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