51
51
#endif
52
52
53
53
54
- // QSettings group constans
55
- const QString reposGroup = " /Qgis/plugin-repos" ;
56
- const QString settingsGroup = " /Qgis/plugin-installer" ;
57
- const QString seenPluginGroup = " /Qgis/plugin-seen" ;
58
-
59
-
60
54
QgsPluginManager::QgsPluginManager ( QWidget * parent, Qt::WFlags fl )
61
55
: QgsOptionsDialogBase( " PluginManager" , parent, fl )
62
56
{
@@ -70,7 +64,14 @@ QgsPluginManager::QgsPluginManager( QWidget * parent, Qt::WFlags fl )
70
64
// and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
71
65
initOptionsBase ( true );
72
66
73
- // init models
67
+ // Don't let QgsOptionsDialogBase to narrow the vertical tab list widget
68
+ mOptListWidget ->setMaximumWidth ( 16777215 );
69
+
70
+ // Restiore UI state for widgets not handled by QgsOptionsDialogBase
71
+ QSettings settings;
72
+ mPluginsDetailsSplitter ->restoreState ( settings.value ( QString ( " /Windows/PluginManager/secondSplitterState" ) ).toByteArray () );
73
+
74
+ // Init models
74
75
mModelPlugins = new QStandardItemModel ( 0 , 1 );
75
76
mModelProxy = new QgsPluginSortFilterProxyModel ( this );
76
77
mModelProxy ->setSourceModel ( mModelPlugins );
@@ -112,6 +113,9 @@ QgsPluginManager::~QgsPluginManager()
112
113
{
113
114
delete mModelProxy ;
114
115
delete mModelPlugins ;
116
+
117
+ QSettings settings;
118
+ settings.setValue ( QString ( " /Windows/PluginManager/secondSplitterState" ), mPluginsDetailsSplitter ->saveState () );
115
119
}
116
120
117
121
@@ -157,6 +161,10 @@ void QgsPluginManager::setPythonUtils( QgsPythonUtils* pythonUtils )
157
161
connect ( actionSortByVote, SIGNAL ( triggered ( ) ), mModelProxy , SLOT ( sortPluginsByVote ( ) ) );
158
162
connect ( actionSortByStatus, SIGNAL ( triggered ( ) ), mModelProxy , SLOT ( sortPluginsByStatus ( ) ) );
159
163
164
+ // get the QSettings group from the installer
165
+ QString settingsGroup;
166
+ QgsPythonRunner::eval ( " pyplugin_installer.instance().exportSettingsGroup()" , settingsGroup );
167
+
160
168
// Initialize list of allowed checking intervals
161
169
mCheckingOnStartIntervals << 0 << 1 << 3 << 7 << 14 << 30 ;
162
170
@@ -470,8 +478,9 @@ void QgsPluginManager::reloadModelData()
470
478
mypDetailItem->setFont ( font );
471
479
}
472
480
473
- // set checkable if the plugin is loadable.
474
- mypDetailItem->setCheckable ( it->value ( " installed" ) == " true" && it->value ( " error" ).isEmpty () );
481
+ // Set checkable if the plugin is installed and not disabled due to incompatibility.
482
+ // Broken plugins are checkable to to allow disabling them
483
+ mypDetailItem->setCheckable ( it->value ( " installed" ) == " true" && it->value ( " error" ) != " incompatible" );
475
484
476
485
// Set ckeckState depending on the plugin is loaded or not.
477
486
// Initially mark all unchecked, then overwrite state of loaded ones with checked.
@@ -501,10 +510,10 @@ void QgsPluginManager::reloadModelData()
501
510
if ( mPythonUtils && mPythonUtils ->isEnabled () )
502
511
{
503
512
// TODO: implement better sort method instead of these dummy -Z statuses
504
- mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Reinstallable plugins " , " category: plugins that are installed and available" ) , " installedZ" ) );
505
- if ( hasUpgradeablePlugins () ) mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Upgradeable plugins " , " category: plugins that are installed and there is newer version available" ), " upgradeableZ" ) );
513
+ mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Reinstallable" , " category: plugins that are installed and available" ) , " installedZ" ) );
514
+ if ( hasUpgradeablePlugins () ) mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Upgradeable" , " category: plugins that are installed and there is a newer version available" ), " upgradeableZ" ) );
506
515
mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Only locally available" , " category: plugins that are only locally available" ), " orphanZ" ) );
507
- if ( hasNewerPlugins () ) mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Newer locally " , " category: plugins installed and availabie; installed version is newer " ), " newerZ" ) );
516
+ if ( hasNewerPlugins () ) mModelPlugins ->appendRow ( createSpacerItem ( tr ( " Downgradeable " , " category: plugins that are installed and there is an OLDER version available " ), " newerZ" ) );
508
517
}
509
518
510
519
updateTabTitle ();
@@ -530,7 +539,6 @@ void QgsPluginManager::pluginItemChanged( QStandardItem * item )
530
539
}
531
540
else if ( ! item->checkState () )
532
541
{
533
- // don't test if isPluginLoaded, to allow disable also plugins taht weren't successfully loaded
534
542
QgsDebugMsg ( " Unloading plugin: " + id );
535
543
unloadPlugin ( id );
536
544
}
@@ -579,7 +587,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
579
587
{
580
588
errorMsg = QString ( " <b>%1</b><br/>%2" ).arg ( tr ( " This plugin is broken" ) ).arg ( metadata->value ( " error_details" ) );
581
589
}
582
- html += QString ( " <table bgcolor=\" #EEEE00 \" cellspacing=\" 2\" cellpadding=\" 6\" width=\" 100%\" >"
590
+ html += QString ( " <table bgcolor=\" #FFFF88 \" cellspacing=\" 2\" cellpadding=\" 6\" width=\" 100%\" >"
583
591
" <tr><td width=\" 100%\" style=\" color:#CC0000\" >%1</td></tr>"
584
592
" </table>" ).arg ( errorMsg );
585
593
}
@@ -625,7 +633,23 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
625
633
html += QString ( " <img src=\" %1\" style=\" float:right;\" >" ).arg ( metadata->value ( " icon" ) );
626
634
}
627
635
628
- html += QString ( " <h3>%2</h3>" ).arg ( metadata->value ( " description" ) );
636
+ html += QString ( " <h3>%2</h3><br/>" ).arg ( metadata->value ( " description" ) );
637
+
638
+ if ( ! metadata->value ( " average_vote" ).isEmpty () )
639
+ {
640
+ // draw stars
641
+ int stars = qRound ( metadata->value ( " average_vote" ).toFloat () );
642
+ for ( int i = 0 ; i < stars; i++ )
643
+ {
644
+ html += " <img src=\" :/images/themes/default/mIconNew.png\" >" ;
645
+ }
646
+ html += tr ( " <br/>%1 rating vote(s)<br/>" ).arg ( metadata->value ( " rating_votes" ) );
647
+ }
648
+ if ( ! metadata->value ( " downloads" ).isEmpty () )
649
+ {
650
+ html += tr ( " %1 downloads<br/>" ).arg ( metadata->value ( " downloads" ) );
651
+ html += " <br/>" ;
652
+ }
629
653
630
654
if ( ! metadata->value ( " category" ).isEmpty () )
631
655
{
@@ -661,21 +685,6 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
661
685
html += " <br/>" ;
662
686
}
663
687
664
- if ( ! metadata->value ( " average_vote" ).isEmpty () )
665
- {
666
- // draw stars
667
- int stars = qRound ( metadata->value ( " average_vote" ).toFloat () );
668
- for ( int i = 0 ; i < stars; i++ )
669
- {
670
- html += " <img src=\" :/images/themes/default/mIconNew.png\" >" ;
671
- }
672
- html += tr ( " <br/>%1 rating vote(s)<br/>" ).arg ( metadata->value ( " rating_votes" ) );
673
- }
674
- if ( ! metadata->value ( " downloads" ).isEmpty () )
675
- {
676
- html += tr ( " %1 downloads<br/>" ).arg ( metadata->value ( " downloads" ) );
677
- }
678
-
679
688
html += " <br/>" ;
680
689
681
690
if ( ! metadata->value ( " version_installed" ).isEmpty () )
@@ -721,7 +730,7 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
721
730
722
731
// Enable/disable buttons
723
732
buttonInstall->setEnabled ( metadata->value ( " pythonic" ).toUpper () == " TRUE" && metadata->value ( " status" ) != " orphan" );
724
- buttonUninstall->setEnabled ( metadata->value ( " pythonic" ).toUpper () == " TRUE" && metadata->value ( " status " ) != " readonly " && metadata->value ( " status" ) != " not installed" && metadata->value ( " status" ) != " new" );
733
+ buttonUninstall->setEnabled ( metadata->value ( " pythonic" ).toUpper () == " TRUE" && metadata->value ( " readonly " ) != " true " && metadata->value ( " status" ) != " not installed" && metadata->value ( " status" ) != " new" );
725
734
buttonUninstall->setHidden ( metadata->value ( " status" ) == " not installed" || metadata->value ( " status" ) == " new" );
726
735
727
736
// Store the id of the currently displayed plugin
@@ -852,6 +861,9 @@ void QgsPluginManager::reject()
852
861
{
853
862
if ( mPythonUtils && mPythonUtils ->isEnabled () )
854
863
{
864
+ // get the QSettings group from the installer
865
+ QString settingsGroup;
866
+ QgsPythonRunner::eval ( " pyplugin_installer.instance().exportSettingsGroup()" , settingsGroup );
855
867
QSettings settings;
856
868
settings.setValue ( settingsGroup + " /checkOnStart" , QVariant ( ckbCheckUpdates->isChecked () ) );
857
869
settings.setValue ( settingsGroup + " /checkOnStartInterval" , QVariant ( mCheckingOnStartIntervals .value ( comboInterval->currentIndex () ) ) );
@@ -1116,6 +1128,8 @@ void QgsPluginManager::on_buttonDeleteRep_clicked( )
1116
1128
1117
1129
void QgsPluginManager::on_ckbExperimental_toggled ( bool state )
1118
1130
{
1131
+ QString settingsGroup;
1132
+ QgsPythonRunner::eval ( " pyplugin_installer.instance().exportSettingsGroup()" , settingsGroup );
1119
1133
QSettings settings;
1120
1134
settings.setValue ( settingsGroup + " /allowExperimental" , QVariant ( state ) );
1121
1135
QgsPythonRunner::run ( " pyplugin_installer.installer_data.plugins.rebuild()" );
@@ -1132,27 +1146,25 @@ bool QgsPluginManager::isPluginLoaded( QString key )
1132
1146
QMap<QString, QString>* plugin = pluginMetadata ( key );
1133
1147
if ( plugin->isEmpty () )
1134
1148
{
1149
+ // No such plugin in the metadata registry
1135
1150
return false ;
1136
1151
}
1137
1152
1138
- QString library = key;
1139
1153
if ( plugin->value ( " pythonic" ) != " true" )
1140
1154
{
1141
- // trim "cpp:" prefix from cpp plugin id
1155
+ // For C++ plugins, just check in the QgsPluginRegistry. If the plugin is broken, it was disabled quietly.
1156
+ // Trim "cpp:" prefix from cpp plugin id
1142
1157
key = key.mid ( 4 );
1143
- library = plugin->value ( " library" );
1158
+ QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance ();
1159
+ return pRegistry->isLoaded ( key );
1144
1160
}
1145
-
1146
- QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance ();
1147
- if ( pRegistry->isLoaded ( key ) )
1161
+ else
1148
1162
{
1149
- // TODO: this check shouldn't be necessary, plugin base names must be unique
1150
- if ( pRegistry->library ( key ) == library )
1151
- {
1152
- return true ;
1153
- }
1163
+ // For Python plugins, check in QSettings if enabled rather than checking in QgsPluginRegistry if loaded.
1164
+ // This will allow to turn off the plugin if broken.
1165
+ QSettings mySettings;
1166
+ return ( plugin->value ( " installed" ) == " true" && mySettings.value ( " /PythonPlugins/" + key, QVariant ( false ) ).toBool () );
1154
1167
}
1155
- return false ;
1156
1168
}
1157
1169
1158
1170
0 commit comments