work save: git - merge
This commit is contained in:
parent
45bb056713
commit
7cc5cf4f45
|
@ -149,6 +149,7 @@ SOURCES += \
|
|||
widgets/filepropertiesdialog.cpp \
|
||||
widgets/functiontooltipwidget.cpp \
|
||||
widgets/headercompletionpopup.cpp \
|
||||
widgets/infomessagebox.cpp \
|
||||
widgets/issuestable.cpp \
|
||||
widgets/labelwithmenu.cpp \
|
||||
widgets/lightfusionstyle.cpp \
|
||||
|
@ -284,6 +285,7 @@ HEADERS += \
|
|||
widgets/filepropertiesdialog.h \
|
||||
widgets/functiontooltipwidget.h \
|
||||
widgets/headercompletionpopup.h \
|
||||
widgets/infomessagebox.h \
|
||||
widgets/issuestable.h \
|
||||
widgets/labelwithmenu.h \
|
||||
widgets/lightfusionstyle.h \
|
||||
|
@ -341,6 +343,7 @@ FORMS += \
|
|||
settingsdialog/settingsdialog.ui \
|
||||
widgets/custommakefileinfodialog.ui \
|
||||
widgets/filepropertiesdialog.ui \
|
||||
widgets/infomessagebox.ui \
|
||||
widgets/newclassdialog.ui \
|
||||
widgets/newheaderdialog.ui \
|
||||
widgets/newprojectdialog.ui \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,6 +42,7 @@
|
|||
#include "vcs/gitmanager.h"
|
||||
#include "vcs/gitrepository.h"
|
||||
#include "vcs/gitbranchdialog.h"
|
||||
#include "vcs/gitmergedialog.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QComboBox>
|
||||
|
@ -3077,10 +3078,14 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
|
|||
vcsMenu.addAction(ui->actionGit_Add_Files);
|
||||
}
|
||||
vcsMenu.addAction(ui->actionGit_Branch);
|
||||
vcsMenu.addAction(ui->actionGit_Merge);
|
||||
vcsMenu.addAction(ui->actionGit_Commit);
|
||||
vcsMenu.addAction(ui->actionGit_Restore);
|
||||
|
||||
ui->actionGit_Commit->setEnabled(true);
|
||||
bool canBranch = !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles()
|
||||
&& !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles();
|
||||
ui->actionGit_Merge->setEnabled(canBranch);
|
||||
ui->actionGit_Commit->setEnabled(canBranch);
|
||||
ui->actionGit_Branch->setEnabled(true);
|
||||
ui->actionGit_Restore->setEnabled(true);
|
||||
|
||||
|
@ -3188,11 +3193,15 @@ void MainWindow::onFilesViewContextMenu(const QPoint &pos)
|
|||
vcsMenu.addAction(ui->actionGit_Add_Files);
|
||||
}
|
||||
vcsMenu.addAction(ui->actionGit_Branch);
|
||||
vcsMenu.addAction(ui->actionGit_Merge);
|
||||
vcsMenu.addAction(ui->actionGit_Commit);
|
||||
vcsMenu.addAction(ui->actionGit_Restore);
|
||||
|
||||
bool canBranch = !mFileSystemModelIconProvider.VCSRepository()->hasChangedFiles()
|
||||
&& !mFileSystemModelIconProvider.VCSRepository()->hasChangedFiles();
|
||||
ui->actionGit_Branch->setEnabled(canBranch);
|
||||
ui->actionGit_Merge->setEnabled(canBranch);
|
||||
ui->actionGit_Commit->setEnabled(true);
|
||||
ui->actionGit_Branch->setEnabled(true);
|
||||
ui->actionGit_Restore->setEnabled(true);
|
||||
|
||||
// vcsMenu.addAction(ui->actionGit_Reset);
|
||||
|
@ -5675,20 +5684,26 @@ void MainWindow::updateVCSActions()
|
|||
{
|
||||
bool hasRepository = false;
|
||||
bool shouldEnable = false;
|
||||
bool canBranch = false;
|
||||
if (ui->projectView->isVisible() && mProject) {
|
||||
GitManager vcsManager;
|
||||
QString branch;
|
||||
hasRepository = vcsManager.hasRepository(mProject->folder(),branch);
|
||||
shouldEnable = true;
|
||||
canBranch = !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles()
|
||||
&& !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles();
|
||||
} else if (ui->treeFiles->isVisible()) {
|
||||
GitManager vcsManager;
|
||||
QString branch;
|
||||
hasRepository = vcsManager.hasRepository(pSettings->environment().currentFolder(),branch);
|
||||
shouldEnable = true;
|
||||
canBranch =!mFileSystemModelIconProvider.VCSRepository()->hasChangedFiles()
|
||||
&& !mFileSystemModelIconProvider.VCSRepository()->hasChangedFiles();
|
||||
}
|
||||
ui->actionGit_Create_Repository->setEnabled(!hasRepository && shouldEnable);
|
||||
ui->actionGit_Commit->setEnabled(hasRepository && shouldEnable);
|
||||
ui->actionGit_Branch->setEnabled(hasRepository && shouldEnable);
|
||||
ui->actionGit_Branch->setEnabled(hasRepository && shouldEnable && canBranch);
|
||||
ui->actionGit_Merge->setEnabled(hasRepository && shouldEnable && canBranch);
|
||||
ui->actionGit_Reset->setEnabled(hasRepository && shouldEnable);
|
||||
ui->actionGit_Restore->setEnabled(hasRepository && shouldEnable);
|
||||
ui->actionGit_Revert->setEnabled(hasRepository && shouldEnable);
|
||||
|
@ -6793,3 +6808,26 @@ void MainWindow::on_actionGit_Branch_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionGit_Merge_triggered()
|
||||
{
|
||||
QString folder;
|
||||
if (ui->treeFiles->isVisible()) {
|
||||
folder = pSettings->environment().currentFolder();
|
||||
} else if (ui->projectView->isVisible() && mProject) {
|
||||
folder = mProject->folder();
|
||||
}
|
||||
if (folder.isEmpty())
|
||||
return;
|
||||
GitMergeDialog dialog(folder);
|
||||
if (dialog.exec()==QDialog::Accepted) {
|
||||
//update project view
|
||||
if (mProject) {
|
||||
mProject->model()->beginUpdate();
|
||||
mProject->model()->endUpdate();
|
||||
}
|
||||
//update files view
|
||||
setFilesViewRoot(pSettings->environment().currentFolder());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -590,6 +590,8 @@ private slots:
|
|||
|
||||
void on_actionGit_Branch_triggered();
|
||||
|
||||
void on_actionGit_Merge_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
|
|
@ -1604,6 +1604,8 @@
|
|||
<addaction name="actionGit_Create_Repository"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionGit_Branch"/>
|
||||
<addaction name="actionGit_Merge"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionGit_Commit"/>
|
||||
<addaction name="actionGit_Restore"/>
|
||||
</widget>
|
||||
|
@ -2795,6 +2797,11 @@
|
|||
<string>Branch/Switch</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGit_Merge">
|
||||
<property name="text">
|
||||
<string>Merge</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "gitbranchdialog.h"
|
||||
#include "ui_gitbranchdialog.h"
|
||||
#include "gitmanager.h"
|
||||
#include "../widgets/infomessagebox.h"
|
||||
|
||||
GitBranchDialog::GitBranchDialog(const QString& folder, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
@ -47,6 +48,7 @@ void GitBranchDialog::on_btnOk_clicked()
|
|||
else
|
||||
text = ui->lstBranches->currentText();
|
||||
bool result = false;
|
||||
QString output;
|
||||
if (!text.isEmpty()) {
|
||||
result = mManager->switchToBranch(
|
||||
mFolder,
|
||||
|
@ -56,12 +58,17 @@ void GitBranchDialog::on_btnOk_clicked()
|
|||
ui->chkMerge->isChecked(),
|
||||
ui->rbForceTrack->isChecked(),
|
||||
ui->rbForceNoTrack->isChecked(),
|
||||
ui->chkForceCreation->isChecked());
|
||||
ui->chkForceCreation->isChecked(),
|
||||
output);
|
||||
}
|
||||
if (result)
|
||||
if (result) {
|
||||
accept();
|
||||
else
|
||||
} else if (!output.isEmpty()) {
|
||||
InfoMessageBox box;
|
||||
box.setMessage(output);
|
||||
box.exec();
|
||||
reject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,31 @@
|
|||
#include "gitmergedialog.h"
|
||||
#include "ui_gitmergedialog.h"
|
||||
#include "gitmanager.h"
|
||||
#include "../widgets/infomessagebox.h"
|
||||
|
||||
GitMergeDialog::GitMergeDialog(const QString& folder, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::GitMergeDialog),
|
||||
mFolder(folder)
|
||||
ui(new Ui::GitMergeDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
mManager = new GitManager();
|
||||
mCurrentBranchIndex=-1;
|
||||
QStringList branches =mManager->listBranches(mFolder,mCurrentBranchIndex);
|
||||
ui->cbBranch->addItems(branches);
|
||||
ui->cbBranch->setCurrentIndex(mCurrentBranchIndex);
|
||||
ui->btnOk->setEnabled(false);
|
||||
ui->rbBranch->setChecked(true);
|
||||
ui->txtMergeMessage->setPlainText(QObject::tr("<Auto Generated by Git>"));
|
||||
mFolder = mManager->rootFolder(folder);
|
||||
if (branches.isEmpty()) {
|
||||
QString currentBranch;
|
||||
if (mManager->hasRepository(folder,currentBranch)) {
|
||||
ui->cbBranch->addItem(currentBranch);
|
||||
ui->btnOk->setEnabled(false);
|
||||
}
|
||||
ui->grpOptions->setEnabled(false);
|
||||
ui->txtMergeMessage->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
GitMergeDialog::~GitMergeDialog()
|
||||
|
@ -16,3 +33,41 @@ GitMergeDialog::~GitMergeDialog()
|
|||
delete mManager;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void GitMergeDialog::on_btnCancel_clicked()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void GitMergeDialog::closeEvent(QCloseEvent */* event */)
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
|
||||
void GitMergeDialog::on_btnOk_clicked()
|
||||
{
|
||||
QString output;
|
||||
if (mManager->merge(mFolder,ui->cbBranch->currentText(),
|
||||
ui->chkSquash->isChecked(),
|
||||
ui->chkFastForwardOnly->isChecked(),
|
||||
ui->chkNoFastFoward->isChecked(),
|
||||
ui->chkNoCommit->isChecked(),
|
||||
output,
|
||||
ui->txtMergeMessage->toPlainText()
|
||||
)) {
|
||||
accept();
|
||||
} else {
|
||||
InfoMessageBox box;
|
||||
box.setMessage(output);
|
||||
box.exec();
|
||||
reject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GitMergeDialog::on_cbBranch_currentIndexChanged(int index)
|
||||
{
|
||||
ui->btnOk->setEnabled(mCurrentBranchIndex!=index);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,22 @@ public:
|
|||
explicit GitMergeDialog(const QString& folder, QWidget *parent = nullptr);
|
||||
~GitMergeDialog();
|
||||
|
||||
private slots:
|
||||
void on_btnCancel_clicked();
|
||||
|
||||
void on_btnOk_clicked();
|
||||
|
||||
void on_cbBranch_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::GitMergeDialog *ui;
|
||||
GitManager *mManager;
|
||||
QString mFolder;
|
||||
int mCurrentBranchIndex;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // GITMERGEDIALOG_H
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Merge</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
|
@ -133,7 +133,7 @@
|
|||
<item>
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -32,12 +32,18 @@ public:
|
|||
bool isFileStaged(const QString& filePath) {
|
||||
return mStagedFiles.contains(filePath);
|
||||
}
|
||||
bool hasStagedFiles() {
|
||||
return !mStagedFiles.isEmpty();
|
||||
}
|
||||
bool isFileChanged(const QFileInfo& fileInfo) {
|
||||
return isFileChanged(fileInfo.absoluteFilePath());
|
||||
}
|
||||
bool isFileChanged(const QString& filePath) {
|
||||
return mChangedFiles.contains(filePath);
|
||||
}
|
||||
bool hasChangedFiles() {
|
||||
return !mChangedFiles.isEmpty();
|
||||
}
|
||||
|
||||
void add(const QString& path);
|
||||
void remove(const QString& path);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#include "infomessagebox.h"
|
||||
#include "ui_infomessagebox.h"
|
||||
|
||||
InfoMessageBox::InfoMessageBox(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::InfoMessageBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
void InfoMessageBox::setMessage(const QString message)
|
||||
{
|
||||
ui->txtMessage->setText(message);
|
||||
}
|
||||
|
||||
InfoMessageBox::~InfoMessageBox()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void InfoMessageBox::on_btnOk_clicked()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef INFOMESSAGEBOX_H
|
||||
#define INFOMESSAGEBOX_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class InfoMessageBox;
|
||||
}
|
||||
|
||||
class InfoMessageBox : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InfoMessageBox(QWidget *parent = nullptr);
|
||||
void setMessage(const QString message);
|
||||
~InfoMessageBox();
|
||||
|
||||
private slots:
|
||||
void on_btnOk_clicked();
|
||||
|
||||
private:
|
||||
Ui::InfoMessageBox *ui;
|
||||
};
|
||||
|
||||
#endif // INFOMESSAGEBOX_H
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InfoMessageBox</class>
|
||||
<widget class="QDialog" name="InfoMessageBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>617</width>
|
||||
<height>459</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtMessage">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue