diff --git a/CMakeLists.txt b/CMakeLists.txt index 38fe3a1..8d84bfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8) project(gitklient) set(PROJECT_VERSION_MAJOR 0) -set(PROJECT_VERSION_MINOR 2) -set(PROJECT_VERSION_PATCH 1) +set(PROJECT_VERSION_MINOR 3) +set(PROJECT_VERSION_PATCH 0) add_definitions(-DGK_VERSION="${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") find_package(ECM 5.18 REQUIRED NO_MODULE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eac8a41..50832c2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,6 +92,7 @@ ki18n_wrap_ui( dialogs/fetchdialog.ui dialogs/switchbranchdialog.ui dialogs/initdialog.ui + dialogs/notedialog.ui ) include(git/CMakeLists.txt) diff --git a/src/actions/branchactions.cpp b/src/actions/branchactions.cpp index c625f0b..cd79168 100644 --- a/src/actions/branchactions.cpp +++ b/src/actions/branchactions.cpp @@ -11,6 +11,7 @@ #include "dialogs/fetchdialog.h" #include "dialogs/filestreedialog.h" #include "dialogs/mergedialog.h" +#include "dialogs/notedialog.h" #include "dialogs/runnerdialog.h" #include "diffwindow.h" #include "git/commands/commandmerge.h" @@ -28,6 +29,7 @@ BranchActions::BranchActions(Git::Manager *git, QWidget *parent) : AbstractActio _actionMerge = addActionDisabled(i18n("Merge..."), this, &BranchActions::merge); _actionDiff = addActionDisabled(i18n("Diff"), this, &BranchActions::diff); _actionRemove = addActionDisabled(i18n("Remove..."), this, &BranchActions::remove); + _actionNote = addActionDisabled(i18n("Note..."), this, &BranchActions::note); } const QString &BranchActions::branchName() const @@ -45,6 +47,7 @@ void BranchActions::setBranchName(const QString &newBranchName) setActionEnabled(_actionMerge, true); setActionEnabled(_actionDiff, true); setActionEnabled(_actionRemove, true); + setActionEnabled(_actionNote, true); } const QString &BranchActions::otherBranch() const @@ -126,3 +129,9 @@ void BranchActions::merge() runner.exec(); } } + +void BranchActions::note() +{ + NoteDialog d{_git, _branchName, _parent}; + d.exec(); +} diff --git a/src/actions/branchactions.h b/src/actions/branchactions.h index 0fc9995..f2e7667 100644 --- a/src/actions/branchactions.h +++ b/src/actions/branchactions.h @@ -19,6 +19,7 @@ class BranchActions : public AbstractActions DEFINE_ACTION(actionMerge) DEFINE_ACTION(actionCreate) DEFINE_ACTION(actionRemove) + DEFINE_ACTION(actionNote) public: explicit BranchActions(Git::Manager *git, QWidget *parent = nullptr); @@ -37,6 +38,7 @@ private slots: void diff(); void remove(); void merge(); + void note(); }; #endif // BRANCHACTIONS_H diff --git a/src/dialogs/notedialog.cpp b/src/dialogs/notedialog.cpp new file mode 100644 index 0000000..bc66cf6 --- /dev/null +++ b/src/dialogs/notedialog.cpp @@ -0,0 +1,17 @@ +#include "notedialog.h" + +#include "git/gitmanager.h" + +NoteDialog::NoteDialog(Git::Manager *git, const QString &branchName, QWidget *parent) : + AppDialog(git, parent), _branchName{branchName} +{ + setupUi(this); + + textEdit->setText(git->readNote(branchName)); +} + +void NoteDialog::on_buttonBox_accepted() +{ + _git->saveNote(_branchName, textEdit->toPlainText()); + close(); +} diff --git a/src/dialogs/notedialog.h b/src/dialogs/notedialog.h new file mode 100644 index 0000000..89fe75c --- /dev/null +++ b/src/dialogs/notedialog.h @@ -0,0 +1,20 @@ +#ifndef NOTEDIALOG_H +#define NOTEDIALOG_H + +#include "ui_notedialog.h" + +#include "core/appdialog.h" + +class NoteDialog : public AppDialog, private Ui::NoteDialog +{ + Q_OBJECT + QString _branchName; + +public: + explicit NoteDialog(Git::Manager *git, const QString &branchName, QWidget *parent = nullptr); + +private slots: + void on_buttonBox_accepted(); +}; + +#endif // NOTEDIALOG_H diff --git a/src/dialogs/notedialog.ui b/src/dialogs/notedialog.ui new file mode 100644 index 0000000..8a00ec9 --- /dev/null +++ b/src/dialogs/notedialog.ui @@ -0,0 +1,54 @@ + + + NoteDialog + + + + 0 + 0 + 400 + 300 + + + + Note + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + rejected() + NoteDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/git/gitmanager.cpp b/src/git/gitmanager.cpp index b675114..c2f06e0 100644 --- a/src/git/gitmanager.cpp +++ b/src/git/gitmanager.cpp @@ -364,6 +364,16 @@ void Manager::setLoadFlags(const LoadFlags &newLoadFlags) _loadFlags = newLoadFlags; } +QString Manager::readNote(const QString &branchName) const +{ + return runGit({"notes", "show", branchName}); +} + +void Manager::saveNote(const QString &branchName, const QString ¬e) const +{ + runGit({"notes", "add", branchName, "-f", "--message=" + note}); +} + Manager::Manager() : QObject() , _remotesModel{new RemotesModel(this)} diff --git a/src/git/gitmanager.h b/src/git/gitmanager.h index a87760a..92f57af 100644 --- a/src/git/gitmanager.h +++ b/src/git/gitmanager.h @@ -158,6 +158,10 @@ class Manager : public QObject const LoadFlags &loadFlags() const; void setLoadFlags(const LoadFlags &newLoadFlags); + + QString readNote(const QString &branchName) const; + void saveNote(const QString &branchName, const QString ¬e) const; + signals: void pathChanged();