@@ -6517,17 +6517,14 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
6517
6517
6518
6518
layerGeometryType.appendChild (type);
6519
6519
rootNode.appendChild (layerGeometryType);
6520
-
6521
6520
}
6522
6521
6523
6522
QString errorMsg;
6524
6523
if ( !selectionLayer->writeSymbology ( rootNode, doc, errorMsg ) )
6525
6524
{
6526
- QMessageBox::warning ( this ,
6527
- tr ( " Error" ),
6528
- tr ( " Cannot copy style: %1" )
6529
- .arg ( errorMsg ),
6530
- QMessageBox::Ok );
6525
+ messageBar ()->pushMessage ( errorMsg,
6526
+ tr ( " Cannot copy style: %1" ),
6527
+ QgsMessageBar::CRITICAL, messageTimeout () );
6531
6528
return ;
6532
6529
}
6533
6530
// Copies data in text form as well, so the XML can be pasted into a text editor
@@ -6544,26 +6541,21 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
6544
6541
6545
6542
void QgisApp::pasteStyle ( QgsMapLayer * destinationLayer )
6546
6543
{
6547
-
6548
6544
QgsMapLayer *selectionLayer = destinationLayer ? destinationLayer : activeLayer ();
6549
6545
if ( selectionLayer )
6550
6546
{
6551
-
6552
6547
if ( clipboard ()->hasFormat ( QGSCLIPBOARD_STYLE_MIME ) )
6553
6548
{
6554
6549
QDomDocument doc ( " qgis" );
6555
6550
QString errorMsg;
6556
6551
int errorLine, errorColumn;
6557
6552
if ( !doc.setContent ( clipboard ()->data ( QGSCLIPBOARD_STYLE_MIME ), false , &errorMsg, &errorLine, &errorColumn ) )
6558
6553
{
6559
- QMessageBox::information ( this ,
6560
- tr ( " Error" ),
6561
- tr ( " Cannot parse style: %1:%2:%3" )
6562
- .arg ( errorMsg )
6563
- .arg ( errorLine )
6564
- .arg ( errorColumn ),
6565
- QMessageBox::Ok );
6566
- return ;
6554
+
6555
+ messageBar ()->pushMessage ( errorMsg,
6556
+ tr ( " Cannot parse style: %1:%2:%3" ),
6557
+ QgsMessageBar::CRITICAL, messageTimeout () );
6558
+ return ;
6567
6559
}
6568
6560
6569
6561
QDomElement rootNode = doc.firstChildElement ( " qgis" );
@@ -6573,28 +6565,21 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
6573
6565
{
6574
6566
QgsVectorLayer *selectionVectorLayer = static_cast <QgsVectorLayer*>(selectionLayer);
6575
6567
int pasteLayerGeometryType = doc.elementsByTagName (" layerGeometryType" ).item (0 ).toElement ().text ().toInt ();
6576
-
6577
6568
if ( selectionVectorLayer->geometryType () != pasteLayerGeometryType )
6578
6569
{
6579
- QMessageBox::information ( this ,
6580
- tr ( " Error" ),
6581
- tr ( " Cannot paste style to layers that have a different geometry type" )
6582
- .arg ( errorMsg ),
6583
- QMessageBox::Ok );
6570
+ messageBar ()->pushMessage ( tr ( " Cannot paste style to layer with a different geometry type" ),
6571
+ tr ( " Your copied style does not match the layer you are pasting to" ),
6572
+ QgsMessageBar::INFO, messageTimeout () );
6584
6573
return ;
6585
6574
}
6586
6575
}
6587
6576
6588
-
6589
-
6590
6577
if ( !selectionLayer->readSymbology ( rootNode, errorMsg ) )
6591
6578
{
6592
- QMessageBox::information ( this ,
6593
- tr ( " Error" ),
6594
- tr ( " Cannot read style: %1" )
6595
- .arg ( errorMsg ),
6596
- QMessageBox::Ok );
6597
- return ;
6579
+ messageBar ()->pushMessage ( errorMsg,
6580
+ tr ( " Cannot read style: %1" ),
6581
+ QgsMessageBar::CRITICAL, messageTimeout () );
6582
+ return ;
6598
6583
}
6599
6584
6600
6585
mLayerTreeView ->refreshLayerSymbology ( selectionLayer->id () );
0 commit comments