|
32 | 32 | #include "qgslogger.h"
|
33 | 33 | #include "qgsmessagelog.h"
|
34 | 34 | #include "qgsmessagebar.h"
|
| 35 | +#include "qgsmessagebaritem.h" |
35 | 36 | #include "qgsruntimeprofiler.h"
|
36 | 37 |
|
37 | 38 | #ifdef WITH_BINDINGS
|
@@ -509,7 +510,40 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString )
|
509 | 510 | QString baseName = QFileInfo( myFullPath ).baseName();
|
510 | 511 | if ( mySettings.value( QStringLiteral( "Plugins/watchDog/%1" ).arg( baseName ) ).isValid() )
|
511 | 512 | {
|
512 |
| - mQgisInterface->messageBar()->pushWarning( QObject::tr( "Plugin %1" ).arg( baseName ), QObject::tr( "The plugin will be disabled because it crashed QGIS during last startup. Please report an issue and re-enable the plugin when the problem has been solved." ) ); |
| 513 | + QToolButton *btnEnablePlugin = new QToolButton(); |
| 514 | + btnEnablePlugin ->setText( QObject::tr( "Enable Plugin" ) ); |
| 515 | + btnEnablePlugin ->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); |
| 516 | + |
| 517 | + QToolButton *btnIgnore = new QToolButton(); |
| 518 | + btnIgnore->setText( QObject::tr( "Ignore" ) ); |
| 519 | + btnIgnore->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); |
| 520 | + |
| 521 | + QgsMessageBarItem *watchdogMsg = new QgsMessageBarItem( |
| 522 | + QObject::tr( "Plugin %1" ).arg( baseName ), |
| 523 | + QObject::tr( "This plugin is disabled because it previously crashed QGIS." ), |
| 524 | + btnEnablePlugin, |
| 525 | + Qgis::Warning, |
| 526 | + 0, |
| 527 | + mQgisInterface->messageBar() ); |
| 528 | + watchdogMsg->layout()->addWidget( btnIgnore ); |
| 529 | + |
| 530 | + QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() |
| 531 | + { |
| 532 | + QgsSettings settings; |
| 533 | + settings.setValue( "/Plugins/" + baseName, true ); |
| 534 | + loadCppPlugin( myFullPath ); |
| 535 | + settings.remove( QStringLiteral( "/Plugins/watchDog/%1" ).arg( baseName ) ); |
| 536 | + mQgisInterface->messageBar()->popWidget( watchdogMsg ); |
| 537 | + } ); |
| 538 | + QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() |
| 539 | + { |
| 540 | + QgsSettings settings; |
| 541 | + settings.setValue( "/Plugins/" + baseName, false ); |
| 542 | + settings.remove( "/Plugins/watchDog/" + baseName ); |
| 543 | + mQgisInterface->messageBar()->popWidget( watchdogMsg ); |
| 544 | + } ); |
| 545 | + |
| 546 | + mQgisInterface->messageBar()->pushItem( watchdogMsg ); |
513 | 547 | mySettings.setValue( "/Plugins/" + baseName, false );
|
514 | 548 | }
|
515 | 549 | if ( mySettings.value( "/Plugins/" + baseName ).toBool() )
|
@@ -565,7 +599,46 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString &pluginDirString )
|
565 | 599 |
|
566 | 600 | if ( mySettings.value( "/PythonPlugins/watchDog/" + packageName ).isValid() )
|
567 | 601 | {
|
568 |
| - mQgisInterface->messageBar()->pushWarning( QObject::tr( "Plugin %1" ).arg( packageName ), QObject::tr( "The plugin will be disabled because it crashed QGIS during last startup. Please report an issue and re-enable the plugin when the problem has been solved." ) ); |
| 602 | + QToolButton *btnEnablePlugin = new QToolButton(); |
| 603 | + btnEnablePlugin->setText( QObject::tr( "Enable Plugin" ) ); |
| 604 | + btnEnablePlugin->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); |
| 605 | + |
| 606 | + QToolButton *btnIgnore = new QToolButton(); |
| 607 | + btnIgnore->setText( QObject::tr( "Ignore" ) ); |
| 608 | + btnIgnore->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); |
| 609 | + |
| 610 | + QgsMessageBarItem *watchdogMsg = new QgsMessageBarItem( |
| 611 | + QObject::tr( "Plugin %1" ).arg( packageName ), |
| 612 | + QObject::tr( "This plugin is disabled because it previously crashed QGIS." ), |
| 613 | + btnEnablePlugin, |
| 614 | + Qgis::Warning, |
| 615 | + 0, |
| 616 | + mQgisInterface->messageBar() ); |
| 617 | + watchdogMsg->layout()->addWidget( btnIgnore ); |
| 618 | + |
| 619 | + QObject::connect( btnEnablePlugin, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() |
| 620 | + { |
| 621 | + QgsSettings settings; |
| 622 | + settings.setValue( "/PythonPlugins/" + packageName, true ); |
| 623 | + if ( checkPythonPlugin( packageName ) ) |
| 624 | + { |
| 625 | + loadPythonPlugin( packageName ); |
| 626 | + } |
| 627 | + settings.remove( "/PythonPlugins/watchDog/" + packageName ); |
| 628 | + |
| 629 | + mQgisInterface->messageBar()->popWidget( watchdogMsg ); |
| 630 | + } ); |
| 631 | + |
| 632 | + QObject::connect( btnIgnore, &QToolButton::clicked, mQgisInterface->messageBar(), [ = ]() |
| 633 | + { |
| 634 | + QgsSettings settings; |
| 635 | + settings.setValue( "/PythonPlugins/" + packageName, false ); |
| 636 | + settings.remove( "/PythonPlugins/watchDog/" + packageName ); |
| 637 | + mQgisInterface->messageBar()->popWidget( watchdogMsg ); |
| 638 | + } ); |
| 639 | + |
| 640 | + mQgisInterface->messageBar()->pushItem( watchdogMsg ); |
| 641 | + |
569 | 642 | mySettings.setValue( "/PythonPlugins/" + packageName, false );
|
570 | 643 | }
|
571 | 644 | // check if the plugin was active on last session
|
|
0 commit comments