Commit 9098449d authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Add config to handle single/double click


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent f01bc99d
......@@ -9,6 +9,7 @@
#include <KLocalizedString>
#include <KUrlRequester>
#include <QCheckBox>
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QVBoxLayout>
......@@ -70,8 +71,30 @@ KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin
vbox = new QVBoxLayout;
group = new QGroupBox(i18nc("Groupbox title", "Git"), this);
m_cbGitStatusDiffNumStat = new QCheckBox(i18n("Show number of changed lines in git status"));
vbox->addWidget(m_cbGitStatusDiffNumStat);
auto hbox = new QHBoxLayout;
label = new QLabel(i18n("What happens when you <b>single click</b> an item in git status toolview"), this);
m_cmbSingleClick = new QComboBox(this);
m_cmbSingleClick->addItem(i18n("No Action"));
m_cmbSingleClick->addItem(i18n("Show Diff"));
m_cmbSingleClick->addItem(i18n("Open file"));
m_cmbSingleClick->addItem(i18n("Stage / Unstage"));
hbox->addWidget(label);
hbox->addWidget(m_cmbSingleClick);
vbox->addLayout(hbox);
hbox = new QHBoxLayout;
label = new QLabel(i18n("What happens when you <b>double click</b> an item in git status toolview"), this);
m_cmbDoubleClick = new QComboBox(this);
m_cmbDoubleClick->addItem(i18n("No Action"));
m_cmbDoubleClick->addItem(i18n("Show Diff"));
m_cmbDoubleClick->addItem(i18n("Open file"));
m_cmbDoubleClick->addItem(i18n("Stage / Unstage"));
hbox->addWidget(label);
hbox->addWidget(m_cmbDoubleClick);
vbox->addLayout(hbox);
vbox->addStretch(1);
group->setLayout(vbox);
layout->addWidget(group);
......@@ -88,6 +111,8 @@ KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin
connect(m_cbMultiProjectGoto, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cbGitStatusDiffNumStat, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cmbSingleClick, QOverload<int>::of(&QComboBox::activated), this, &KateProjectConfigPage::slotMyChanged);
connect(m_cmbDoubleClick, QOverload<int>::of(&QComboBox::activated), this, &KateProjectConfigPage::slotMyChanged);
reset();
}
......@@ -122,6 +147,8 @@ void KateProjectConfigPage::apply()
m_plugin->setMultiProject(m_cbMultiProjectCompletion->checkState() == Qt::Checked, m_cbMultiProjectGoto->checkState() == Qt::Checked);
m_plugin->setGitStatusShowNumStat(m_cbGitStatusDiffNumStat->isChecked());
m_plugin->setSingleClickAction((ClickAction)m_cmbSingleClick->currentIndex());
m_plugin->setDoubleClickAction((ClickAction)m_cmbDoubleClick->currentIndex());
}
void KateProjectConfigPage::reset()
......@@ -135,6 +162,8 @@ void KateProjectConfigPage::reset()
m_cbMultiProjectGoto->setCheckState(m_plugin->multiProjectGoto() ? Qt::Checked : Qt::Unchecked);
m_cbGitStatusDiffNumStat->setChecked(m_plugin->showGitStatusWithNumStat());
m_cmbSingleClick->setCurrentIndex(m_plugin->singleClickAcion());
m_cmbDoubleClick->setCurrentIndex(m_plugin->doubleClickAcion());
m_changed = false;
}
......
......@@ -12,6 +12,7 @@ class KateProjectPlugin;
class QWidget;
class QCheckBox;
class KUrlRequester;
class QComboBox;
class KateProjectConfigPage : public KTextEditor::ConfigPage
{
......@@ -45,6 +46,8 @@ private:
QCheckBox *m_cbMultiProjectCompletion;
QCheckBox *m_cbMultiProjectGoto;
QCheckBox *m_cbGitStatusDiffNumStat;
QComboBox *m_cmbSingleClick;
QComboBox *m_cmbDoubleClick;
KateProjectPlugin *m_plugin;
bool m_changed = false;
};
......
......@@ -353,6 +353,28 @@ bool KateProjectPlugin::showGitStatusWithNumStat()
return m_gitNumStat;
}
void KateProjectPlugin::setSingleClickAction(ClickAction cb)
{
m_singleClick = cb;
writeConfig();
}
ClickAction KateProjectPlugin::singleClickAcion()
{
return m_singleClick;
}
void KateProjectPlugin::setDoubleClickAction(ClickAction cb)
{
m_doubleClick = cb;
writeConfig();
}
ClickAction KateProjectPlugin::doubleClickAcion()
{
return m_doubleClick;
}
void KateProjectPlugin::setMultiProject(bool completion, bool gotoSymbol)
{
m_multiProjectCompletion = completion;
......@@ -376,6 +398,8 @@ void KateProjectPlugin::readConfig()
m_multiProjectGoto = config.readEntry("multiProjectCompletion", false);
m_gitNumStat = config.readEntry("gitStatusNumStat", true);
m_singleClick = (ClickAction)config.readEntry("gitStatusSingleClick", (int)ClickAction::ShowDiff);
m_doubleClick = (ClickAction)config.readEntry("gitStatusDoubleClick", (int)ClickAction::StageUnstage);
Q_EMIT configUpdated();
}
......@@ -406,6 +430,8 @@ void KateProjectPlugin::writeConfig()
config.writeEntry("multiProjectGoto", m_multiProjectGoto);
config.writeEntry("gitStatusNumStat", m_gitNumStat);
config.writeEntry("gitStatusSingleClick", (int)m_singleClick);
config.writeEntry("gitStatusDoubleClick", (int)m_doubleClick);
Q_EMIT configUpdated();
}
......
......@@ -21,6 +21,13 @@
#include "kateproject.h"
#include "kateprojectcompletion.h"
enum ClickAction {
NoAction = 0,
ShowDiff,
OpenFile,
StageUnstage,
};
class KateProjectPlugin : public KTextEditor::Plugin
{
Q_OBJECT
......@@ -105,6 +112,12 @@ public:
void setGitStatusShowNumStat(bool show);
bool showGitStatusWithNumStat();
void setSingleClickAction(ClickAction cb);
ClickAction singleClickAcion();
void setDoubleClickAction(ClickAction cb);
ClickAction doubleClickAcion();
Q_SIGNALS:
/**
* Signal that a new project got created.
......@@ -197,6 +210,8 @@ private:
// git features
bool m_gitNumStat = true;
ClickAction m_singleClick;
ClickAction m_doubleClick;
/**
* thread pool for our workers
......
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