Issue #189: Enable plugins by default

This commit is contained in:
Jakub Melka 2024-06-29 16:32:14 +02:00
parent dcac8c9572
commit 7e4a4d78e3
4 changed files with 18 additions and 3 deletions

View File

@ -84,7 +84,7 @@ public:
virtual QMenu* addToolMenu(QString name) override; virtual QMenu* addToolMenu(QString name) override;
virtual void setStatusBarMessage(QString message, int time) override; virtual void setStatusBarMessage(QString message, int time) override;
virtual void setDocument(const pdf::PDFModifiedDocument& document) override; virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
virtual void adjustToolbar(QToolBar* toolbar) override; virtual void adjustToolbar(QToolBar* toolbar) override final;
virtual pdf::PDFTextSelection getSelectedText() const override; virtual pdf::PDFTextSelection getSelectedText() const override;
protected: protected:

View File

@ -373,7 +373,8 @@ PDFProgramController::PDFProgramController(QObject* parent) :
m_actionComboBox(nullptr), m_actionComboBox(nullptr),
m_isBusy(false), m_isBusy(false),
m_isFactorySettingsBeingRestored(false), m_isFactorySettingsBeingRestored(false),
m_progress(nullptr) m_progress(nullptr),
m_loadAllPlugins(false)
{ {
connect(&m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &PDFProgramController::onFileChanged); connect(&m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &PDFProgramController::onFileChanged);
} }
@ -1616,6 +1617,7 @@ void PDFProgramController::readSettings(Settings settingsFlags)
{ {
// Load allowed plugins // Load allowed plugins
settings.beginGroup("Plugins"); settings.beginGroup("Plugins");
m_loadAllPlugins = !settings.contains("EnabledPlugins");
m_enabledPlugins = settings.value("EnabledPlugins").toStringList(); m_enabledPlugins = settings.value("EnabledPlugins").toStringList();
settings.endGroup(); settings.endGroup();
} }
@ -2190,12 +2192,18 @@ void PDFProgramController::loadPlugins()
m_plugins.back().pluginFile = availablePlugin; m_plugins.back().pluginFile = availablePlugin;
m_plugins.back().pluginFileWithPath = pluginFileName; m_plugins.back().pluginFileWithPath = pluginFileName;
if (!m_enabledPlugins.contains(m_plugins.back().name)) QString pluginName = m_plugins.back().name;
if (!m_enabledPlugins.contains(pluginName) && !m_loadAllPlugins)
{ {
loader.unload(); loader.unload();
continue; continue;
} }
if (m_loadAllPlugins)
{
m_enabledPlugins << pluginName;
}
pdf::PDFPlugin* plugin = qobject_cast<pdf::PDFPlugin*>(loader.instance()); pdf::PDFPlugin* plugin = qobject_cast<pdf::PDFPlugin*>(loader.instance());
if (plugin) if (plugin)
{ {
@ -2203,6 +2211,7 @@ void PDFProgramController::loadPlugins()
} }
} }
} }
m_loadAllPlugins = false;
auto comparator = [](const std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>& l, const std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>& r) auto comparator = [](const std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>& l, const std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>& r)
{ {

View File

@ -452,6 +452,7 @@ private:
pdf::PDFProgress* m_progress; pdf::PDFProgress* m_progress;
QStringList m_enabledPlugins; QStringList m_enabledPlugins;
bool m_loadAllPlugins;
pdf::PDFPluginInfos m_plugins; pdf::PDFPluginInfos m_plugins;
std::vector<std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>> m_loadedPlugins; std::vector<std::pair<pdf::PDFPluginInfo, pdf::PDFPlugin*>> m_loadedPlugins;
}; };

View File

@ -258,6 +258,11 @@ void PDFWidgetUtils::checkMenuAccessibility(QMenu* menu)
QString text = action->text(); QString text = action->text();
int i = text.indexOf(QChar('&')); int i = text.indexOf(QChar('&'));
if (text.isEmpty())
{
continue;
}
if (i == -1) if (i == -1)
{ {
actionsWithNoAmpersands << text; actionsWithNoAmpersands << text;