Commit 28caa58e authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Add a menu entry to allow opening directories as project


Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <waqar.17a@gmail.com>
parent cf863735
......@@ -26,6 +26,7 @@
#include <QAction>
#include <QDialog>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QMenu>
......@@ -157,7 +158,9 @@ KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEdi
/**
* back + forward
*/
auto a = actionCollection()->addAction(KStandardAction::Back, QStringLiteral("projects_prev_project"), this, SLOT(slotProjectPrev()));
auto a = actionCollection()->addAction(QStringLiteral("projects_open_project"), this, SLOT(openDirectoryOrProject()));
a->setText(i18n("Open Folder..."));
a = actionCollection()->addAction(KStandardAction::Back, QStringLiteral("projects_prev_project"), this, SLOT(slotProjectPrev()));
actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Left));
a = actionCollection()->addAction(KStandardAction::Forward, QStringLiteral("projects_next_project"), this, SLOT(slotProjectNext()));
actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Right));
......@@ -638,4 +641,10 @@ void KateProjectPluginView::slotUpdateStatus(bool visible)
}
}
void KateProjectPluginView::openDirectoryOrProject()
{
const QString dir = QFileDialog::getExistingDirectory(nullptr, i18n("Choose a directory"), QDir::currentPath());
m_plugin->projectForDir(dir, true);
}
#include "kateprojectpluginview.moc"
......@@ -254,6 +254,11 @@ private Q_SLOTS:
*/
void slotUpdateStatus(bool visible);
/**
* Open a folder / project
*/
void openDirectoryOrProject();
private:
/**
* find current selected or under cursor word
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="kateprojectplugin" library="kateprojectplugin" version="9" translationDomain="kateproject">
<gui name="kateprojectplugin" library="kateprojectplugin" version="10" translationDomain="kateproject">
<MenuBar>
<Menu name="projects">
<text>&amp;Projects</text>
<Action name="projects_open_project"/>
<Action name="projects_prev_project"/>
<Action name="projects_next_project"/>
<Action name="projects_goto_index" />
......
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