Skip to content
Permalink
Browse files

Fixes #17845 tested on Linux KDE and Win 10

  • Loading branch information
elpaso committed Feb 9, 2018
1 parent fcb50a6 commit e435d79d6c4de64f1f45153db288f14495296cc2
Showing with 36 additions and 27 deletions.
  1. +20 −20 src/app/qgisapp.cpp
  2. +1 −1 src/app/qgisapp.h
  3. +12 −6 src/app/qgsrasterlayerproperties.cpp
  4. +3 −0 src/app/qgsrasterlayerproperties.h
@@ -12568,7 +12568,7 @@ void QgisApp::readProject( const QDomDocument &doc )
}
}

void QgisApp::showLayerProperties( QgsMapLayer *ml )
void QgisApp::showLayerProperties( QgsMapLayer *mapLayer )
{
/*
TODO: Consider reusing the property dialogs again.
@@ -12579,15 +12579,15 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
a separate copy of the dialog pointer needs to be stored with each layer.
*/

if ( !ml )
if ( !mapLayer )
return;

if ( !QgsProject::instance()->layerIsEmbedded( ml->id() ).isEmpty() )
if ( !QgsProject::instance()->layerIsEmbedded( mapLayer->id() ).isEmpty() )
{
return; //don't show properties of embedded layers
}

if ( ml->type() == QgsMapLayer::RasterLayer )
if ( mapLayer->type() == QgsMapLayer::RasterLayer )
{
#if 0 // See note above about reusing this
QgsRasterLayerProperties *rlp = nullptr;
@@ -12601,27 +12601,27 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
// handled by rendererChanged() connect( rlp, SIGNAL( refreshLegend( QString, bool ) ), mLayerTreeView, SLOT( refreshLayerSymbology( QString ) ) );
}
#else
QgsRasterLayerProperties *rlp = new QgsRasterLayerProperties( ml, mMapCanvas, this );
QgsRasterLayerProperties *rasterLayerPropertiesDialog = new QgsRasterLayerProperties( mapLayer, mMapCanvas, this );
#endif
// Cannot use exec here due to raster transparency map tool:
// in order to pass focus to the canvas, the dialog needs to
// be hidden and shown in non-modal mode.
rlp->setModal( true );
rlp->show();
rasterLayerPropertiesDialog->setModal( true );
rasterLayerPropertiesDialog->show();
// Delete (later, for safety) since dialog cannot be reused without
// updating code
connect( rlp, &QgsRasterLayerProperties::accepted, [ rlp ]
connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::accepted, [ rasterLayerPropertiesDialog ]
{
rlp->deleteLater();
rasterLayerPropertiesDialog->deleteLater();
} );
connect( rlp, &QgsRasterLayerProperties::rejected, [ rlp ]
connect( rasterLayerPropertiesDialog, &QgsRasterLayerProperties::rejected, [ rasterLayerPropertiesDialog ]
{
rlp->deleteLater();
rasterLayerPropertiesDialog->deleteLater();
} );
}
else if ( ml->type() == QgsMapLayer::VectorLayer ) // VECTOR
else if ( mapLayer->type() == QgsMapLayer::VectorLayer ) // VECTOR
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( ml );
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mapLayer );

#if 0 // See note above about reusing this
QgsVectorLayerProperties *vlp = nullptr;
@@ -12635,26 +12635,26 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
// handled by rendererChanged() connect( vlp, SIGNAL( refreshLegend( QString ) ), mLayerTreeView, SLOT( refreshLayerSymbology( QString ) ) );
}
#else
QgsVectorLayerProperties *vlp = new QgsVectorLayerProperties( vlayer, this );
QgsVectorLayerProperties *vectorLayerPropertiesDialog = new QgsVectorLayerProperties( vlayer, this );
#endif
Q_FOREACH ( QgsMapLayerConfigWidgetFactory *factory, mMapLayerPanelFactories )
{
vlp->addPropertiesPageFactory( factory );
vectorLayerPropertiesDialog->addPropertiesPageFactory( factory );
}

mMapStyleWidget->blockUpdates( true );
if ( vlp->exec() )
if ( vectorLayerPropertiesDialog->exec() )
{
activateDeactivateLayerRelatedActions( ml );
activateDeactivateLayerRelatedActions( mapLayer );
mMapStyleWidget->updateCurrentWidgetLayer();
}
mMapStyleWidget->blockUpdates( false );

delete vlp; // delete since dialog cannot be reused without updating code
delete vectorLayerPropertiesDialog; // delete since dialog cannot be reused without updating code
}
else if ( ml->type() == QgsMapLayer::PluginLayer )
else if ( mapLayer->type() == QgsMapLayer::PluginLayer )
{
QgsPluginLayer *pl = qobject_cast<QgsPluginLayer *>( ml );
QgsPluginLayer *pl = qobject_cast<QgsPluginLayer *>( mapLayer );
if ( !pl )
return;

@@ -603,7 +603,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsLocatorWidget *locatorWidget() { return mLocatorWidget; }

//! show layer properties
void showLayerProperties( QgsMapLayer *ml );
void showLayerProperties( QgsMapLayer *mapLayer );

//! returns pointer to map legend
QgsLayerTreeView *layerTreeView();
@@ -180,6 +180,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
{
mPixelSelectorTool = qgis::make_unique<QgsMapToolEmitPoint>( canvas );
connect( mPixelSelectorTool.get(), &QgsMapToolEmitPoint::canvasClicked, this, &QgsRasterLayerProperties::pixelSelected );
connect( mPixelSelectorTool.get(), &QgsMapToolEmitPoint::deactivated, this, &QgsRasterLayerProperties::restoreWindowModality );
}
else
{
@@ -1194,16 +1195,16 @@ void QgsRasterLayerProperties::pbnAddValuesFromDisplay_clicked()
{
//Need to work around the modality of the dialog but can not just hide() it.
// According to Qt5 docs, to change modality the dialog needs to be hidden
// and shown it again.
// and shown again.
hide();
setModal( false );
showMinimized();

// Transfer focus to the canvas to use the selector tool
mMapCanvas->window()->raise();
mMapCanvas->window()->activateWindow();
mMapCanvas->window()->setFocus();
mMapCanvas->setMapTool( mPixelSelectorTool.get() );

}
}

@@ -1636,10 +1637,6 @@ void QgsRasterLayerProperties::pixelSelected( const QgsPointXY &canvasPoint, con
return;
}

raise();
setModal( true );
activateWindow();

//Get the pixel values and add a new entry to the transparency table
if ( mMapCanvas && mPixelSelectorTool )
{
@@ -1872,6 +1869,15 @@ void QgsRasterLayerProperties::saveStyleAs_clicked()
QMessageBox::information( this, tr( "Saved Style" ), message );
}

void QgsRasterLayerProperties::restoreWindowModality()
{
hide();
setModal( true );
show();
raise();
activateWindow();
}

//
//
// Next four methods for saving and restoring QMD metadata
@@ -103,6 +103,9 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
void loadStyle_clicked();
//! Save a style when appriate button is pressed.
void saveStyleAs_clicked();
//! Restore dialog modality and focus, usually after a pixel clicked to pick transparency color
void restoreWindowModality();


//! Load a saved metadata file.
void loadMetadata();

0 comments on commit e435d79

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