diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 155b41ab..c54c486e 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -92,9 +92,13 @@ SOURCES += \ todoparser.cpp \ toolsmanager.cpp \ vcs/gitbranchdialog.cpp \ + vcs/gitfetchdialog.cpp \ vcs/gitlogdialog.cpp \ vcs/gitmanager.cpp \ vcs/gitmergedialog.cpp \ + vcs/gitpulldialog.cpp \ + vcs/gitpushdialog.cpp \ + vcs/gitremotedialog.cpp \ vcs/gitrepository.cpp \ vcs/gitresetdialog.cpp \ vcs/gitutils.cpp \ @@ -229,9 +233,13 @@ HEADERS += \ todoparser.h \ toolsmanager.h \ vcs/gitbranchdialog.h \ + vcs/gitfetchdialog.h \ vcs/gitlogdialog.h \ vcs/gitmanager.h \ vcs/gitmergedialog.h \ + vcs/gitpulldialog.h \ + vcs/gitpushdialog.h \ + vcs/gitremotedialog.h \ vcs/gitrepository.h \ vcs/gitresetdialog.h \ vcs/gitutils.h \ @@ -330,8 +338,12 @@ FORMS += \ settingsdialog/toolsgeneralwidget.ui \ settingsdialog/toolsgitwidget.ui \ vcs/gitbranchdialog.ui \ + vcs/gitfetchdialog.ui \ vcs/gitlogdialog.ui \ vcs/gitmergedialog.ui \ + vcs/gitpulldialog.ui \ + vcs/gitpushdialog.ui \ + vcs/gitremotedialog.ui \ vcs/gitresetdialog.ui \ widgets/aboutdialog.ui \ widgets/cpudialog.ui \ diff --git a/RedPandaIDE/vcs/gitfetchdialog.cpp b/RedPandaIDE/vcs/gitfetchdialog.cpp new file mode 100644 index 00000000..cb3992ec --- /dev/null +++ b/RedPandaIDE/vcs/gitfetchdialog.cpp @@ -0,0 +1,14 @@ +#include "gitfetchdialog.h" +#include "ui_gitfetchdialog.h" + +GitFetchDialog::GitFetchDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::GitFetchDialog) +{ + ui->setupUi(this); +} + +GitFetchDialog::~GitFetchDialog() +{ + delete ui; +} diff --git a/RedPandaIDE/vcs/gitfetchdialog.h b/RedPandaIDE/vcs/gitfetchdialog.h new file mode 100644 index 00000000..6b075e22 --- /dev/null +++ b/RedPandaIDE/vcs/gitfetchdialog.h @@ -0,0 +1,22 @@ +#ifndef GITFETCHDIALOG_H +#define GITFETCHDIALOG_H + +#include + +namespace Ui { +class GitFetchDialog; +} + +class GitFetchDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GitFetchDialog(QWidget *parent = nullptr); + ~GitFetchDialog(); + +private: + Ui::GitFetchDialog *ui; +}; + +#endif // GITFETCHDIALOG_H diff --git a/RedPandaIDE/vcs/gitfetchdialog.ui b/RedPandaIDE/vcs/gitfetchdialog.ui new file mode 100644 index 00000000..b0141148 --- /dev/null +++ b/RedPandaIDE/vcs/gitfetchdialog.ui @@ -0,0 +1,18 @@ + + GitFetchDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + diff --git a/RedPandaIDE/vcs/gitmanager.cpp b/RedPandaIDE/vcs/gitmanager.cpp index faf16c18..8d98006e 100644 --- a/RedPandaIDE/vcs/gitmanager.cpp +++ b/RedPandaIDE/vcs/gitmanager.cpp @@ -218,6 +218,69 @@ QStringList GitManager::listConflicts(const QString &folder) return textToLines(runGit(folder,args)); } +QStringList GitManager::listRemotes(const QString &folder) +{ + QStringList args; + args.append("remote"); + return textToLines(runGit(folder,args)); +} + +bool GitManager::removeRemote(const QString &folder, const QString &remoteName, QString& output) +{ + QStringList args; + args.append("remote"); + args.append("remove"); + args.append(remoteName); + + output = runGit(folder,args); + return !output.startsWith("error") && !output.startsWith("fatal"); +} + +bool GitManager::renameRemote(const QString &folder, const QString &oldName, const QString &newName, QString &output) +{ + QStringList args; + args.append("remote"); + args.append("rename"); + args.append(oldName); + args.append(newName); + + output = runGit(folder,args); + return !output.startsWith("error") && !output.startsWith("fatal"); +} + +bool GitManager::addRemote(const QString &folder, const QString &name, const QString &url, QString &output) +{ + QStringList args; + args.append("remote"); + args.append("add"); + args.append(name); + args.append(url); + + output = runGit(folder,args); + return !output.startsWith("error") && !output.startsWith("fatal"); +} + +bool GitManager::setRemoteURL(const QString &folder, const QString &name, const QString &newURL, QString &output) +{ + QStringList args; + args.append("remote"); + args.append("set-url"); + args.append(name); + args.append(newURL); + + output = runGit(folder,args); + return !output.startsWith("error") && !output.startsWith("fatal"); +} + +QString GitManager::getRemoteURL(const QString &folder, const QString &name) +{ + QStringList args; + args.append("remote"); + args.append("get-url"); + args.append(name); + return runGit(folder,args); +} + QStringList GitManager::listBranches(const QString &folder, int ¤t) { QStringList args; diff --git a/RedPandaIDE/vcs/gitmanager.h b/RedPandaIDE/vcs/gitmanager.h index 882cedbc..d836e5a3 100644 --- a/RedPandaIDE/vcs/gitmanager.h +++ b/RedPandaIDE/vcs/gitmanager.h @@ -40,6 +40,16 @@ public: QStringList listStagedFiles(const QString& folder); QStringList listChangedFiles(const QString& folder); QStringList listConflicts(const QString& folder); + QStringList listRemotes(const QString& folder); + + bool removeRemote(const QString& folder, const QString& remoteName, QString& output); + bool renameRemote(const QString& folder, const QString& oldName, + const QString& newName, QString& output); + bool addRemote(const QString& folder, const QString& name, + const QString& url, QString& output); + bool setRemoteURL(const QString& folder, const QString& name, + const QString& newURL, QString& output); + QString getRemoteURL(const QString& folder, const QString& name); QStringList listBranches(const QString& folder, int& current); bool switchToBranch(const QString& folder, const QString& branch, bool create, diff --git a/RedPandaIDE/vcs/gitpulldialog.cpp b/RedPandaIDE/vcs/gitpulldialog.cpp new file mode 100644 index 00000000..1b064ab7 --- /dev/null +++ b/RedPandaIDE/vcs/gitpulldialog.cpp @@ -0,0 +1,14 @@ +#include "gitpulldialog.h" +#include "ui_gitpulldialog.h" + +GitPullDialog::GitPullDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::GitPullDialog) +{ + ui->setupUi(this); +} + +GitPullDialog::~GitPullDialog() +{ + delete ui; +} diff --git a/RedPandaIDE/vcs/gitpulldialog.h b/RedPandaIDE/vcs/gitpulldialog.h new file mode 100644 index 00000000..b0bad375 --- /dev/null +++ b/RedPandaIDE/vcs/gitpulldialog.h @@ -0,0 +1,22 @@ +#ifndef GITPULLDIALOG_H +#define GITPULLDIALOG_H + +#include + +namespace Ui { +class GitPullDialog; +} + +class GitPullDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GitPullDialog(QWidget *parent = nullptr); + ~GitPullDialog(); + +private: + Ui::GitPullDialog *ui; +}; + +#endif // GITPULLDIALOG_H diff --git a/RedPandaIDE/vcs/gitpulldialog.ui b/RedPandaIDE/vcs/gitpulldialog.ui new file mode 100644 index 00000000..842d30de --- /dev/null +++ b/RedPandaIDE/vcs/gitpulldialog.ui @@ -0,0 +1,18 @@ + + GitPullDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + diff --git a/RedPandaIDE/vcs/gitpushdialog.cpp b/RedPandaIDE/vcs/gitpushdialog.cpp new file mode 100644 index 00000000..b639d581 --- /dev/null +++ b/RedPandaIDE/vcs/gitpushdialog.cpp @@ -0,0 +1,14 @@ +#include "gitpushdialog.h" +#include "ui_gitpushdialog.h" + +GitPushDialog::GitPushDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::GitPushDialog) +{ + ui->setupUi(this); +} + +GitPushDialog::~GitPushDialog() +{ + delete ui; +} diff --git a/RedPandaIDE/vcs/gitpushdialog.h b/RedPandaIDE/vcs/gitpushdialog.h new file mode 100644 index 00000000..dc3e17d3 --- /dev/null +++ b/RedPandaIDE/vcs/gitpushdialog.h @@ -0,0 +1,22 @@ +#ifndef GITPUSHDIALOG_H +#define GITPUSHDIALOG_H + +#include + +namespace Ui { +class GitPushDialog; +} + +class GitPushDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GitPushDialog(QWidget *parent = nullptr); + ~GitPushDialog(); + +private: + Ui::GitPushDialog *ui; +}; + +#endif // GITPUSHDIALOG_H diff --git a/RedPandaIDE/vcs/gitpushdialog.ui b/RedPandaIDE/vcs/gitpushdialog.ui new file mode 100644 index 00000000..3ed38777 --- /dev/null +++ b/RedPandaIDE/vcs/gitpushdialog.ui @@ -0,0 +1,18 @@ + + GitPushDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + diff --git a/RedPandaIDE/vcs/gitremotedialog.cpp b/RedPandaIDE/vcs/gitremotedialog.cpp new file mode 100644 index 00000000..0e4635a6 --- /dev/null +++ b/RedPandaIDE/vcs/gitremotedialog.cpp @@ -0,0 +1,86 @@ +#include "gitremotedialog.h" +#include "ui_gitremotedialog.h" +#include "gitmanager.h" +#include "../iconsmanager.h" +#include "../widgets/infomessagebox.h" + +GitRemoteDialog::GitRemoteDialog(const QString& folder, QWidget *parent) : + QDialog(parent), + ui(new Ui::GitRemoteDialog), + mFolder(folder) +{ + ui->setupUi(this); + GitManager manager; + ui->lstRemotes->addItems(manager.listRemotes(folder)); + connect(pIconsManager, &IconsManager::actionIconsUpdated, + this, &GitRemoteDialog::updateIcons); + ui->btnRemove->setEnabled(false); + ui->pnlProcess->setVisible(false); + ui->grpDetail->setEnabled(false); + connect(ui->lstRemotes->selectionModel(), + &QItemSelectionModel::selectionChanged, + this, + &GitRemoteDialog::onRemotesSelectionChanged); +} + +GitRemoteDialog::~GitRemoteDialog() +{ + delete ui; +} + +void GitRemoteDialog::updateIcons() +{ + ui->btnAdd->setIcon(pIconsManager->getIcon(IconsManager::ACTION_MISC_ADD)); + ui->btnRemove->setIcon(pIconsManager->getIcon(IconsManager::ACTION_MISC_REMOVE)); +} + +void GitRemoteDialog::onRemotesSelectionChanged() +{ + bool enabled=(ui->lstRemotes->selectedItems().count()>0); + ui->btnRemove->setEnabled(enabled); + ui->pnlProcess->setVisible(enabled); + ui->grpDetail->setEnabled(enabled); + if (enabled) { + QString remoteName = ui->lstRemotes->selectedItems()[0]->text(); + GitManager manager; + QString remoteURL = manager.getRemoteURL(mFolder,remoteName); + ui->txtName->setText(remoteName); + ui->txtURL->setText(remoteURL); + ui->btnProcess->setText(tr("Update")); + } +} + +void GitRemoteDialog::on_btnAdd_clicked() +{ + ui->grpDetail->setEnabled(true); + ui->pnlProcess->setVisible(true); + ui->btnProcess->setText(tr("Add")); + ui->btnRemove->setEnabled(false); +} + + +void GitRemoteDialog::on_btnRemove_clicked() +{ + if (ui->lstRemotes->selectedItems().count()>0) { + QString remoteName = ui->lstRemotes->selectedItems()[0]->text(); + GitManager manager; + QString output; + if (!manager.removeRemote(mFolder,remoteName,output)) { + InfoMessageBox infoBox; + infoBox.showMessage(output); + } else { + refresh(); + } + } +} + +void GitRemoteDialog::refresh() +{ + ui->lstRemotes->clear(); + GitManager manager; + ui->lstRemotes->addItems(manager.listRemotes(mFolder)); + ui->btnRemove->setEnabled(false); + ui->pnlProcess->setVisible(false); + ui->grpDetail->setEnabled(false); +} + diff --git a/RedPandaIDE/vcs/gitremotedialog.h b/RedPandaIDE/vcs/gitremotedialog.h new file mode 100644 index 00000000..b2dc0880 --- /dev/null +++ b/RedPandaIDE/vcs/gitremotedialog.h @@ -0,0 +1,30 @@ +#ifndef GITREMOTEDIALOG_H +#define GITREMOTEDIALOG_H + +#include + +namespace Ui { +class GitRemoteDialog; +} + +class GitRemoteDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GitRemoteDialog(const QString& folder, QWidget *parent = nullptr); + ~GitRemoteDialog(); + +private slots: + void updateIcons(); + void onRemotesSelectionChanged(); + void on_btnAdd_clicked(); + + void on_btnRemove_clicked(); + void refresh(); +private: + Ui::GitRemoteDialog *ui; + QString mFolder; +}; + +#endif // GITREMOTEDIALOG_H diff --git a/RedPandaIDE/vcs/gitremotedialog.ui b/RedPandaIDE/vcs/gitremotedialog.ui new file mode 100644 index 00000000..48ecbce9 --- /dev/null +++ b/RedPandaIDE/vcs/gitremotedialog.ui @@ -0,0 +1,279 @@ + + + GitRemoteDialog + + + + 0 + 0 + 906 + 502 + + + + Git Remote + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + + 1 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Add Remote + + + Add + + + + :/icons/images/newlook24/002-add.png:/icons/images/newlook24/002-add.png + + + + + + + Remove Remote + + + Remove + + + + :/icons/images/newlook24/008-close.png:/icons/images/newlook24/008-close.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SelectRows + + + + + + + + + 3 + 0 + + + + Detail + + + + + + + + + Name + + + + + + + URL + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 781 + 20 + + + + + + + + Close + + + + + + + + + + + + +