Verified Commit ec1cb3ca authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Allow users to enable indexing by clicking button

Before there was the instruction to enable indexing by modifying
some config file without mentioning the format/where it is located.
Also the instruction did not seem to work, because the value is read
from ~/.config/katerc.

This will make it far easier to enable indexing. The setting
in the projectsplugin config works too, but that is not as discoverable.
parent 72517fc3
......@@ -153,6 +153,11 @@ public:
return m_projectIndex.data();
}
KateProjectPlugin *plugin()
{
return m_plugin;
}
/**
* Computes a suitable file name for the given suffix.
* If you e.g. want to store a "notes" file, you could pass "notes" and get
......
......@@ -10,6 +10,7 @@
#include <KLocalizedString>
#include <KMessageWidget>
#include <QAction>
#include <QVBoxLayout>
KateProjectInfoViewIndex::KateProjectInfoViewIndex(KateProjectPluginView *pluginView, KateProject *project, QWidget *parent)
......@@ -166,16 +167,25 @@ void KateProjectInfoViewIndex::enableWidgets(bool valid)
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->setMessageType(KMessageWidget::Warning);
m_messageWidget->setWordWrap(false);
// disabled or failed to create?
if (m_project->projectIndex()) {
m_messageWidget->setText(i18n("The index could not be created. Please install 'ctags'."));
} else {
m_messageWidget->setText(i18n("The index is not enabled. Please add '\"index\": true' to your .kateproject file."));
}
static_cast<QVBoxLayout *>(layout())->insertWidget(0, m_messageWidget);
} else {
m_messageWidget->animatedShow();
}
// disabled or failed to create?
if (!valid && m_project->projectIndex()) {
m_messageWidget->setText(i18n("The index could not be created. Please install 'ctags'."));
// Make sure we remove the action
const QList<QAction *> actions = m_messageWidget->actions();
if (actions.size() == 1) {
m_messageWidget->removeAction(actions.first());
}
} else if (!valid) {
m_messageWidget->setText(i18n("Indexing is not enabled"));
auto enableIndexing = new QAction(i18n("Enable indexing"), m_messageWidget);
connect(enableIndexing, &QAction::triggered, m_messageWidget, [this]() {
m_project->plugin()->setIndex(true, QUrl());
m_project->reload(true);
});
m_messageWidget->addAction(enableIndexing);
}
}
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