Commit 147bd26d authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Restore config for quickopen

parent ca0543cc
......@@ -17,8 +17,10 @@
#include <KAboutData>
#include <KActionCollection>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KSharedConfig>
#include <QBoxLayout>
#include <QCoreApplication>
......@@ -251,6 +253,15 @@ KateQuickOpen::KateQuickOpen(KateMainWindow *mainWindow)
m_filterMode = m_inputLine->filterMode();
}
KateQuickOpen::~KateQuickOpen()
{
KSharedConfig::Ptr cfg = KSharedConfig::openConfig();
KConfigGroup cg(cfg, "General");
cg.writeEntry("Quickopen Filter Mode", static_cast<int>(m_filterMode));
cg.writeEntry("Quickopen List Mode", m_base_model->listMode() == KateQuickOpenModelList::CurrentProject);
}
bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event)
{
// catch key presses + shortcut overrides to allow to have ESC as application wide shortcut, too, see bug 409856
......
......@@ -29,6 +29,8 @@ class KateQuickOpen : public QMenu
Q_OBJECT
public:
KateQuickOpen(KateMainWindow *mainWindow);
~KateQuickOpen();
/**
* update state
* will fill model with current open documents, project documents, ...
......@@ -56,7 +58,7 @@ private:
KateMainWindow *m_mainWindow;
QTreeView *m_listView;
QuickOpenLineEdit *m_inputLine;
QuickOpenStyleDelegate* m_styleDelegate;
QuickOpenStyleDelegate *m_styleDelegate;
FilterModes m_filterMode;
/**
......
......@@ -9,7 +9,9 @@
#include <QContextMenuEvent>
#include <QMenu>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
QuickOpenLineEdit::QuickOpenLineEdit(QWidget *parent)
: QLineEdit(parent)
......@@ -26,43 +28,58 @@ void QuickOpenLineEdit::contextMenuEvent(QContextMenuEvent *event)
void QuickOpenLineEdit::setupMenu()
{
KSharedConfig::Ptr cfg = KSharedConfig::openConfig();
KConfigGroup cg(cfg, "General");
const int cfgFilterMode = cg.readEntry("Quickopen Filter Mode", (FilterMode::FilterByName | FilterMode::FilterByPath));
const bool cfgListMode = cg.readEntry("Quickopen List Mode", true);
menu->addSeparator();
auto act = menu->addAction(i18n("Filter By Path"));
act->setCheckable(true);
connect(act, &QAction::toggled, this, [this](bool checked) {
auto act1 = menu->addAction(i18n("Filter By Path"));
act1->setCheckable(true);
connect(act1, &QAction::toggled, this, [this](bool checked) {
m_mode.setFlag(FilterMode::FilterByPath, checked);
emit filterModeChanged(m_mode);
});
act->setChecked(true);
act = menu->addAction(i18n("Filter By Name"));
act->setCheckable(true);
connect(act, &QAction::toggled, this, [this](bool checked) {
auto act2 = menu->addAction(i18n("Filter By Name"));
act2->setCheckable(true);
connect(act2, &QAction::toggled, this, [this](bool checked) {
m_mode.setFlag(FilterMode::FilterByName, checked);
emit filterModeChanged(m_mode);
});
act->setChecked(true);
if (cfgFilterMode == FilterMode::FilterByName) {
act1->setChecked(true);
} else if (cfgFilterMode == FilterMode::FilterByPath) {
act2->setChecked(true);
} else {
act1->setChecked(true);
act2->setChecked(true);
}
menu->addSeparator();
QActionGroup *actGp = new QActionGroup(this);
actGp->setExclusionPolicy(QActionGroup::ExclusionPolicy::Exclusive);
act = menu->addAction(i18n("All Projects"));
auto act = menu->addAction(i18n("All Projects"));
act->setCheckable(true);
connect(act, &QAction::toggled, this, [this](bool checked) {
if (checked)
emit listModeChanged(KateQuickOpenModelList::AllProjects);
});
act->setChecked(!cfgListMode);
actGp->addAction(act);
act = menu->addAction(i18n("Current Project"));
act->setCheckable(true);
connect(act, &QAction::toggled, this, [this](bool checked) {
if (checked)
emit listModeChanged(KateQuickOpenModelList::CurrentProject);
});
act->setCheckable(true);
act->setChecked(cfgListMode);
actGp->addAction(act);
}
......@@ -25,7 +25,7 @@ class QuickOpenLineEdit : public QLineEdit
public:
explicit QuickOpenLineEdit(QWidget *parent);
FilterModes filterMode()
FilterModes filterMode() const
{
return m_mode;
}
......
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