Commit e573c502 authored by Christoph Cullmann's avatar Christoph Cullmann

honor the 'load me per default if my app name is mentioned in the list'...

honor the 'load me per default if my app name is mentioned in the list' X-KTextEditor-Load-Default attribute
parent 654a1fa3
......@@ -49,8 +49,6 @@ KatePluginListItem::KatePluginListItem(bool checked, KatePluginInfo *info)
, mInfo(info)
{
setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
// skip plugins that will be loaded always!
setDisabled(info->alwaysLoad);
}
KatePluginListView::KatePluginListView(QWidget *parent)
......@@ -83,9 +81,6 @@ KateConfigPluginPage::KateConfigPluginPage(QWidget *parent, KateConfigDialog *di
KatePluginList &pluginList(KateApp::self()->pluginManager()->pluginList());
for (KatePluginList::iterator it = pluginList.begin(); it != pluginList.end(); ++it) {
if (it->alwaysLoad) {
continue;
}
QTreeWidgetItem *item = new KatePluginListItem(it->load, &(*it));
item->setText(0, it->service->name());
item->setText(1, it->service->comment());
......
......@@ -54,28 +54,16 @@ void KatePluginManager::setupPluginList()
{
KService::List traderList = KServiceTypeTrader::self()->query(QStringLiteral("KTextEditor/Plugin"));
KatePluginList alwaysLoad;
KatePluginList others;
m_pluginList.clear ();
foreach(const KService::Ptr & ptr, traderList) {
KatePluginInfo info;
info.service = ptr;
info.alwaysLoad = false;
info.defaultLoad = info.service->property(QStringLiteral("X-KTextEditor-Load-Default")).toStringList().contains(QStringLiteral("kate"));
info.load = false;
info.plugin = 0L;
if (info.alwaysLoad) {
alwaysLoad.push_back(info);
} else {
others.push_back(info);
}
info.plugin = nullptr;
m_pluginList.push_back(info);
}
/**
* prefer always load plugins in handling
*/
m_pluginList = alwaysLoad;
m_pluginList << others;
/**
* construct fast lookup map
*/
......@@ -96,17 +84,17 @@ void KatePluginManager::loadConfig(KConfig *config)
if (config) {
KConfigGroup cg = KConfigGroup(config, QStringLiteral("Kate Plugins"));
// disable all plugin if no config...
// disable all plugin if no config, beside the ones marked as default load
for (int i = 0; i < m_pluginList.size(); ++i) {
m_pluginList[i].load = cg.readEntry(m_pluginList[i].service->library(), false);
m_pluginList[i].load = cg.readEntry(m_pluginList[i].service->library(), m_pluginList[i].defaultLoad);
}
}
/**
* load plugins, some are always enforced to load!
* load plugins
*/
for (KatePluginList::iterator it = m_pluginList.begin(); it != m_pluginList.end(); ++it) {
if (it->load || it->alwaysLoad) {
if (it->load) {
loadPlugin(&(*it));
// restore config
......
......@@ -36,7 +36,7 @@ class KatePluginInfo
{
public:
bool load;
bool alwaysLoad;
bool defaultLoad;
KService::Ptr service;
KTextEditor::Plugin *plugin;
QString saveName() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment