Commit e96dd60f authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

use the new output in the git stuff

parent 7b358356
......@@ -6,6 +6,7 @@
#include "branchesdialog.h"
#include "branchesdialogmodel.h"
#include "git/gitutils.h"
#include "kateprojectpluginview.h"
#include <QCoreApplication>
#include <QKeyEvent>
......@@ -151,9 +152,10 @@ private:
QString m_filterString;
};
BranchesDialog::BranchesDialog(QWidget *parent, KTextEditor::MainWindow *mainWindow, QString projectPath)
BranchesDialog::BranchesDialog(QWidget *parent, KTextEditor::MainWindow *mainWindow, KateProjectPluginView *pluginView, QString projectPath)
: QMenu(parent)
, m_mainWindow(mainWindow)
, m_pluginView(pluginView)
, m_projectPath(projectPath)
{
QVBoxLayout *layout = new QVBoxLayout();
......@@ -331,12 +333,7 @@ void BranchesDialog::reselectFirst()
void BranchesDialog::sendMessage(const QString &message, bool warn)
{
KTextEditor::Message *msg = new KTextEditor::Message(message, warn ? KTextEditor::Message::Warning : KTextEditor::Message::Positive);
msg->setPosition(KTextEditor::Message::TopInView);
msg->setAutoHide(3000);
msg->setAutoHideMode(KTextEditor::Message::Immediate);
msg->setView(m_mainWindow->activeView());
m_mainWindow->activeView()->document()->postMessage(msg);
m_pluginView->sendMessage(message, warn);
}
void BranchesDialog::createNewBranch(const QString &branch, const QString &fromBranch)
......
......@@ -14,6 +14,7 @@ class BranchesDialogModel;
class QAction;
class BranchFilterModel;
class KActionCollection;
class KateProjectPluginView;
namespace KTextEditor
{
......@@ -24,7 +25,7 @@ class BranchesDialog : public QMenu
{
Q_OBJECT
public:
BranchesDialog(QWidget *parent, KTextEditor::MainWindow *mainWindow, QString projectPath);
BranchesDialog(QWidget *parent, KTextEditor::MainWindow *mainWindow, KateProjectPluginView *pluginView, QString projectPath);
void openDialog();
......@@ -52,6 +53,7 @@ private:
BranchesDialogModel *m_model;
BranchFilterModel *m_proxyModel;
KTextEditor::MainWindow *m_mainWindow;
KateProjectPluginView *m_pluginView;
QString m_projectPath;
QFutureWatcher<GitUtils::CheckoutResult> m_checkoutWatcher;
QString m_checkoutBranchName;
......
......@@ -124,25 +124,7 @@ void GitWidget::initGitExe()
void GitWidget::sendMessage(const QString &message, bool warn)
{
// use generic output view
// FIXME: proper attributes
// if finished => remove the other case below!
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("plainText"), message);
Q_EMIT m_pluginView->message(genericMessage);
// quickfix crash on startup
if (!m_mainWin->activeView()) {
return;
}
KTextEditor::Message *msg = new KTextEditor::Message(message, warn ? KTextEditor::Message::Warning : KTextEditor::Message::Positive);
msg->setPosition(KTextEditor::Message::TopInView);
msg->setAutoHide(warn ? 5000 : 3000);
msg->setAutoHideMode(KTextEditor::Message::Immediate);
msg->setView(m_mainWin->activeView());
m_mainWin->activeView()->document()->postMessage(msg);
m_pluginView->sendMessage(message, warn);
}
QProcess *GitWidget::gitprocess()
......@@ -431,7 +413,7 @@ void GitWidget::buildMenu()
}
});
m_gitMenu->addAction(i18n("Checkout Branch"), this, [this] {
BranchesDialog bd(this, m_mainWin, m_project->baseDir());
BranchesDialog bd(this, m_mainWin, m_pluginView, m_project->baseDir());
bd.openDialog();
});
......
......@@ -39,7 +39,6 @@ public:
bool eventFilter(QObject *o, QEvent *e) override;
void getStatus(bool untracked = true, bool submodules = false);
void sendMessage(const QString &message, bool warn);
QProcess *gitprocess();
KTextEditor::MainWindow *mainWindow();
......@@ -47,6 +46,9 @@ public:
std::vector<TempFileViewPair> *tempFilesVector();
void openTempFile(const QString &file, const QString &templatString);
// will just proxy the message to the plugin view
void sendMessage(const QString &message, bool warn);
private:
QToolButton *m_menuBtn;
QToolButton *m_commitBtn;
......
......@@ -638,4 +638,13 @@ void KateProjectPluginView::slotUpdateStatus(bool visible)
}
}
void KateProjectPluginView::sendMessage(const QString &plainText, bool warn)
{
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT message(genericMessage);
}
#include "kateprojectpluginview.moc"
......@@ -100,6 +100,13 @@ public:
return m_plugin;
}
/**
* Send out trivial plain text message, potential warnings
* @param message plain text message
* @param warn warning or not?
*/
void sendMessage(const QString &plainText, bool warn);
public Q_SLOTS:
/**
* Create views for given project.
......
......@@ -68,7 +68,7 @@ KateProjectView::KateProjectView(KateProjectPluginView *pluginView, KateProject
* Setup git checkout stuff
*/
m_branchBtn->setHidden(true);
m_branchesDialog = new BranchesDialog(this, mainWindow, m_project->baseDir());
m_branchesDialog = new BranchesDialog(this, mainWindow, m_pluginView, m_project->baseDir());
connect(m_branchBtn, &QPushButton::clicked, this, [this] {
m_branchesDialog->openDialog();
});
......
......@@ -6,6 +6,7 @@
#include "stashdialog.h"
#include "git/gitutils.h"
#include "gitwidget.h"
#include "kateprojectpluginview.h"
#include <QCoreApplication>
#include <QFileInfo>
......@@ -295,12 +296,8 @@ void StashDialog::reselectFirst()
void StashDialog::sendMessage(const QString &message, bool warn)
{
KTextEditor::Message *msg = new KTextEditor::Message(message, warn ? KTextEditor::Message::Warning : KTextEditor::Message::Positive);
msg->setPosition(KTextEditor::Message::TopInView);
msg->setAutoHide(3000);
msg->setAutoHideMode(KTextEditor::Message::Immediate);
msg->setView(m_mainWindow->activeView());
m_mainWindow->activeView()->document()->postMessage(msg);
// just proxy to git widget => proxy to plugin view
m_gitwidget->sendMessage(message, warn);
}
void StashDialog::stash(bool keepIndex, bool includeUntracked)
......
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