Skip to content

Commit eab40d0

Browse files
authoredNov 8, 2018
Merge pull request #8435 from elpaso/handle-bad-layers5
bad layers dialog new button labels and icon
2 parents ad1bba2 + ba4981a commit eab40d0

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed
 

‎src/app/qgsapplayertreeviewmenuprovider.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
199199

200200
menu->addSeparator();
201201

202-
// change data source is only supported for vectors and rasters
203-
if ( vlayer || rlayer )
204-
{
205-
206-
QAction *a = new QAction( tr( "Change data source…" ), menu );
207-
connect( a, &QAction::triggered, [ = ]
208-
{
209-
QgisApp::instance()->changeDataSource( layer );
210-
} );
211-
menu->addAction( a );
212-
}
213-
214202
if ( vlayer )
215203
{
216204
QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
@@ -251,6 +239,26 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
251239
}
252240
}
253241

242+
// change data source is only supported for vectors and rasters
243+
if ( vlayer || rlayer )
244+
{
245+
246+
QAction *a = new QAction( tr( "Change data source…" ), menu );
247+
// Disable when layer is editable
248+
if ( layer->isEditable() )
249+
{
250+
a->setEnabled( false );
251+
}
252+
else
253+
{
254+
connect( a, &QAction::triggered, [ = ]
255+
{
256+
QgisApp::instance()->changeDataSource( layer );
257+
} );
258+
}
259+
menu->addAction( a );
260+
}
261+
254262
menu->addSeparator();
255263

256264
if ( layer && layer->isSpatial() )

‎src/app/qgshandlebadlayers.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ void QgsHandleBadLayersHandler::handleBadLayers( const QList<QDomNode> &layers )
4242
QApplication::setOverrideCursor( Qt::ArrowCursor );
4343
QgsHandleBadLayers *dialog = new QgsHandleBadLayers( layers );
4444

45-
dialog->buttonBox->button( QDialogButtonBox::Ignore )->setToolTip( tr( "Import all bad layers unmodified (you can fix them later)." ) );
46-
dialog->buttonBox->button( QDialogButtonBox::Apply )->setToolTip( tr( "Apply fixes to bad layers (remaining bad layers will be removed from the project)." ) );
47-
dialog->buttonBox->button( QDialogButtonBox::Discard )->setToolTip( tr( "Remove all bad layers from the project" ) );
45+
dialog->buttonBox->button( QDialogButtonBox::Ignore )->setToolTip( tr( "Import all unavailable layers unmodified (you can fix them later)." ) );
46+
dialog->buttonBox->button( QDialogButtonBox::Ignore )->setText( tr( "Keep unavailable layers" ) );
47+
dialog->buttonBox->button( QDialogButtonBox::Discard )->setToolTip( tr( "Remove all unavailable layers from the project" ) );
48+
dialog->buttonBox->button( QDialogButtonBox::Discard )->setText( tr( "Remove unavailable layers" ) );
49+
dialog->buttonBox->button( QDialogButtonBox::Discard )->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteSelected.svg" ) );
4850

4951
if ( dialog->layerCount() < layers.size() )
5052
QgisApp::instance()->messageBar()->pushMessage(
51-
tr( "Handle bad layers" ),
52-
tr( "%1 of %2 bad layers were not fixable." )
53+
tr( "Handle unavailable layers" ),
54+
tr( "%1 of %2 unavailable layers were not fixable." )
5355
.arg( layers.size() - dialog->layerCount() )
5456
.arg( layers.size() ),
5557
Qgis::Warning, QgisApp::instance()->messageTimeout() );
@@ -74,10 +76,13 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
7476
mBrowseButton = new QPushButton( tr( "Browse" ) );
7577
buttonBox->addButton( mBrowseButton, QDialogButtonBox::ActionRole );
7678
mBrowseButton->setDisabled( true );
79+
mApplyButton = new QPushButton( tr( "Apply changes" ) );
80+
mApplyButton->setToolTip( tr( "Apply fixes to unavailable layers (remaining unavailable layers will be removed from the project)." ) );
81+
buttonBox->addButton( mApplyButton, QDialogButtonBox::ActionRole );
7782

7883
connect( mLayerList, &QTableWidget::itemSelectionChanged, this, &QgsHandleBadLayers::selectionChanged );
7984
connect( mBrowseButton, &QAbstractButton::clicked, this, &QgsHandleBadLayers::browseClicked );
80-
connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsHandleBadLayers::apply );
85+
connect( mApplyButton, &QAbstractButton::clicked, this, &QgsHandleBadLayers::apply );
8186
connect( buttonBox->button( QDialogButtonBox::Ignore ), &QPushButton::clicked, this, &QgsHandleBadLayers::reject );
8287
connect( buttonBox->button( QDialogButtonBox::Discard ), &QPushButton::clicked, this, &QgsHandleBadLayers::accept );
8388

@@ -349,7 +354,7 @@ void QgsHandleBadLayers::editAuthCfg()
349354
void QgsHandleBadLayers::apply()
350355
{
351356
QgsProject::instance()->layerTreeRegistryBridge()->setEnabled( true );
352-
357+
buttonBox->button( QDialogButtonBox::Ignore )->setEnabled( false );
353358
QList<QgsMapLayer *> toRemove;
354359
for ( const auto &l : QgsProject::instance()->mapLayers( ) )
355360
{

‎src/app/qgshandlebadlayers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class APP_EXPORT QgsHandleBadLayers
5757

5858
private:
5959
QPushButton *mBrowseButton = nullptr;
60+
QPushButton *mApplyButton = nullptr;
6061
const QList<QDomNode> &mLayers;
6162
QList<int> mRows;
6263
QString mVectorFileFilter;

‎src/app/qgslayertreeviewbadlayerindicator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ QString QgsLayerTreeViewBadLayerIndicatorProvider::iconName( QgsMapLayer *layer
5959
QString QgsLayerTreeViewBadLayerIndicatorProvider::tooltipText( QgsMapLayer *layer )
6060
{
6161
Q_UNUSED( layer );
62-
return tr( "<b>Bad layer!</b><br>Layer data source could not be found. Click to set a new data source" );
62+
return tr( "<b>Unavailable layer!</b><br>Layer data source could not be found. Click to set a new data source" );
6363
}
6464

6565
bool QgsLayerTreeViewBadLayerIndicatorProvider::acceptLayer( QgsMapLayer *layer )

‎src/core/qgsprojectbadlayerhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
void QgsProjectBadLayerHandler::handleBadLayers( const QList<QDomNode> &layers )
2424
{
25-
QgsApplication::messageLog()->logMessage( QObject::tr( "%1 bad layers found:" ).arg( layers.size() ) );
25+
QgsApplication::messageLog()->logMessage( QObject::tr( "%1 unavailable layers found:" ).arg( layers.size() ) );
2626
Q_FOREACH ( const QDomNode &layer, layers )
2727
{
2828
QgsApplication::messageLog()->logMessage( QObject::tr( " * %1" ).arg( dataSource( layer ) ) );

‎src/ui/qgshandlebadlayersbase.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>Handle Bad Layers</string>
14+
<string>Handle Unavailable Layers</string>
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>
@@ -27,7 +27,7 @@
2727
<enum>Qt::Horizontal</enum>
2828
</property>
2929
<property name="standardButtons">
30-
<set>QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ignore</set>
30+
<set>QDialogButtonBox::Discard|QDialogButtonBox::Ignore</set>
3131
</property>
3232
</widget>
3333
</item>
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.