Commit f7f93ebb authored by Krzysztof Stokop's avatar Krzysztof Stokop
Browse files

Revert "Project closing context menu"

This reverts commit 28b54bf0.
parent 28b54bf0
#include "kateprojectclosingcontextmenu.h"
#include <QApplication>
#include <QClipboard>
#include <QFileInfo>
#include <QIcon>
#include <QMenu>
#include <QMimeDatabase>
#include <QMimeType>
#include <QStandardPaths>
#include <KLocalizedString>
void KateProjectClosingContextMenu::exec(QList<KateProject*> projectList, const QPoint &pos, KateProjectPluginView *parent)
{
/**
* Create context menu
*/
QMenu menu;
/**
* fill menu
*/
QAction** actions = new QAction*[projectList.size()];
for(int i = 0; i<projectList.size(); i++)
actions[i] = menu.addAction(QIcon::fromTheme(QStringLiteral("window-close")), i18n(projectList[i]->name().toLocal8Bit().data()));
/**
* run menu and handle the triggered action
*/
if (QAction* const action = menu.exec(pos))
for(int i = 0; i<projectList.size(); i++)
if (action == actions[i])
parent->projectAboutToClose(projectList[i]);
}
#ifndef KATEPROJECTCLOSINGCONTEXTMENU_H
#define KATEPROJECTCLOSINGCONTEXTMENU_H
#include <QObject>
#include <QString>
#include "kateproject.h"
#include "kateprojectpluginview.h"
/**
* @todo write docs
*/
class KateProjectClosingContextMenu : public QObject
{
Q_OBJECT
public:
/**
* Creating project closing menu from Qlist<KateProject*>
*/
void exec(QList<KateProject*> projectList, const QPoint &pos, KateProjectPluginView *parent);
};
#endif // KATEPROJECTCLOSINGCONTEXTMENU_H
......@@ -9,7 +9,6 @@
#include "fileutil.h"
#include "gitwidget.h"
#include "kateprojectinfoviewindex.h"
#include "kateprojectclosingcontextmenu.h"
#include <ktexteditor/application.h>
#include <ktexteditor/codecompletioninterface.h>
......@@ -30,7 +29,6 @@
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QMenu>
#include <QContextMenuEvent>
#include <QTimer>
#include <QVBoxLayout>
......@@ -114,7 +112,7 @@ KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEdi
connect(m_projectsCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateProjectPluginView::slotCurrentChanged);
connect(m_reloadButton, &QToolButton::clicked, this, &KateProjectPluginView::slotProjectReload);
// connect(m_closeProjectButton, &QToolButton::clicked, this, &KateProjectPluginView::contextMenuEvent);
connect(m_closeProjectButton, &QToolButton::clicked, this, &KateProjectPluginView::slotProjectAboutToClose);
connect(m_plugin, &KateProjectPlugin::pluginViewProjectClosing, this, &KateProjectPluginView::slotProjectClose);
connect(m_gitStatusRefreshButton, &QToolButton::clicked, this, [this] {
......@@ -565,17 +563,13 @@ void KateProjectPluginView::slotProjectReload()
}
}
void KateProjectPluginView::contextMenuEvent(QContextMenuEvent* event)
void KateProjectPluginView::slotProjectAboutToClose()
{
KateProjectClosingContextMenu menu;
menu.exec(m_plugin->projects(), event->pos(), this);
event->accept();
}
void KateProjectPluginView::projectAboutToClose(KateProject *project)
{
m_plugin->closeProject(project);
if (QWidget *current = m_stackedProjectViews->currentWidget())
{
const auto project = static_cast<KateProjectView *>(current)->project();
m_plugin->closeProject(project);
}
}
void KateProjectPluginView::slotProjectClose(KateProject *project)
......
......@@ -99,11 +99,6 @@ public:
{
return m_plugin;
}
/**
* Getting project for others windows.
*/
void projectAboutToClose(KateProject *project);
public Q_SLOTS:
/**
......@@ -155,9 +150,11 @@ private Q_SLOTS:
void slotProjectReload();
/**
* Opening close menu
* Getting project for others windows
* and closing project documents.
*/
void contextMenuEvent(QContextMenuEvent* event);
void slotProjectAboutToClose();
/**
* Close current project.
*/
......
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