add dialog to set git user infos
This commit is contained in:
parent
3df0c98031
commit
2084990491
|
@ -101,6 +101,7 @@ SOURCES += \
|
|||
vcs/gitremotedialog.cpp \
|
||||
vcs/gitrepository.cpp \
|
||||
vcs/gitresetdialog.cpp \
|
||||
vcs/gituserconfigdialog.cpp \
|
||||
vcs/gitutils.cpp \
|
||||
widgets/aboutdialog.cpp \
|
||||
widgets/bookmarkmodel.cpp \
|
||||
|
@ -243,6 +244,7 @@ HEADERS += \
|
|||
vcs/gitremotedialog.h \
|
||||
vcs/gitrepository.h \
|
||||
vcs/gitresetdialog.h \
|
||||
vcs/gituserconfigdialog.h \
|
||||
vcs/gitutils.h \
|
||||
widgets/aboutdialog.h \
|
||||
widgets/bookmarkmodel.h \
|
||||
|
@ -347,6 +349,7 @@ FORMS += \
|
|||
vcs/gitpushdialog.ui \
|
||||
vcs/gitremotedialog.ui \
|
||||
vcs/gitresetdialog.ui \
|
||||
vcs/gituserconfigdialog.ui \
|
||||
widgets/aboutdialog.ui \
|
||||
widgets/choosethemedialog.ui \
|
||||
widgets/cpudialog.ui \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@
|
|||
#include "vcs/gitmergedialog.h"
|
||||
#include "vcs/gitlogdialog.h"
|
||||
#include "vcs/gitremotedialog.h"
|
||||
#include "vcs/gituserconfigdialog.h"
|
||||
#include "widgets/infomessagebox.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
@ -768,7 +769,8 @@ void MainWindow::onFileSaved(const QString &path, bool inProject)
|
|||
if (!inProject) {
|
||||
if ( (isCFile(path) || isHFile(path))
|
||||
&& !mFileSystemModelIconProvider.VCSRepository()->isFileInRepository(path)) {
|
||||
mFileSystemModelIconProvider.VCSRepository()->add(extractRelativePath(mFileSystemModelIconProvider.VCSRepository()->folder(),path));
|
||||
QString output;
|
||||
mFileSystemModelIconProvider.VCSRepository()->add(extractRelativePath(mFileSystemModelIconProvider.VCSRepository()->folder(),path),output);
|
||||
}
|
||||
}
|
||||
// qDebug()<<"update icon provider";
|
||||
|
@ -5458,8 +5460,10 @@ void MainWindow::on_actionAdd_to_project_triggered()
|
|||
mProject->cppParser()->addFileToScan(filename);
|
||||
QString branch;
|
||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||
QString output;
|
||||
mProject->model()->iconProvider()->VCSRepository()->add(
|
||||
extractRelativePath(mProject->folder(),filename)
|
||||
extractRelativePath(mProject->folder(),filename),
|
||||
output
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5713,7 +5717,8 @@ void MainWindow::newProjectUnitFile()
|
|||
editor->activate();
|
||||
QString branch;
|
||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||
mProject->model()->iconProvider()->VCSRepository()->add(newFileName);
|
||||
QString output;
|
||||
mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output);
|
||||
mProject->model()->beginUpdate();
|
||||
mProject->model()->endUpdate();
|
||||
}
|
||||
|
@ -6719,10 +6724,11 @@ void MainWindow::on_actionGit_Create_Repository_triggered()
|
|||
} else if (ui->projectView->isVisible() && mProject) {
|
||||
GitManager vcsManager;
|
||||
vcsManager.createRepository(mProject->folder());
|
||||
vcsManager.add(mProject->folder(), extractFileName(mProject->filename()));
|
||||
vcsManager.add(mProject->folder(), extractFileName(mProject->options().icon));
|
||||
QString output;
|
||||
vcsManager.add(mProject->folder(), extractFileName(mProject->filename()), output);
|
||||
vcsManager.add(mProject->folder(), extractFileName(mProject->options().icon), output);
|
||||
foreach (PProjectUnit pUnit, mProject->units()) {
|
||||
vcsManager.add(mProject->folder(),extractRelativePath(mProject->folder(),pUnit->fileName()));
|
||||
vcsManager.add(mProject->folder(),extractRelativePath(mProject->folder(),pUnit->fileName()),output);
|
||||
}
|
||||
//update project view
|
||||
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode(), true);
|
||||
|
@ -6747,9 +6753,10 @@ void MainWindow::on_actionGit_Add_Files_triggered()
|
|||
if (ui->treeFiles->isVisible()) {
|
||||
GitManager vcsManager;
|
||||
QModelIndexList indices = ui->treeFiles->selectionModel()->selectedRows();
|
||||
QString output;
|
||||
foreach (const QModelIndex index,indices) {
|
||||
QFileInfo info = mFileSystemModel.fileInfo(index);
|
||||
vcsManager.add(info.absolutePath(),info.fileName());
|
||||
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
||||
}
|
||||
//update icons in files view
|
||||
mFileSystemModelIconProvider.update();
|
||||
|
@ -6766,7 +6773,8 @@ void MainWindow::on_actionGit_Add_Files_triggered()
|
|||
if (folderNode->unitIndex>=0) {
|
||||
PProjectUnit unit = mProject->units()[folderNode->unitIndex];
|
||||
QFileInfo info(unit->fileName());
|
||||
vcsManager.add(info.absolutePath(),info.fileName());
|
||||
QString output;
|
||||
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6811,8 +6819,19 @@ void MainWindow::on_actionGit_Commit_triggered()
|
|||
);
|
||||
return;
|
||||
}
|
||||
vcsManager.commit(folder,message,true);
|
||||
|
||||
QString output;
|
||||
QString userName = vcsManager.getUserName(folder);
|
||||
QString userEmail = vcsManager.getUserEmail(folder);
|
||||
if (userName.isEmpty() || userEmail.isEmpty()) {
|
||||
GitUserConfigDialog dialog(folder);
|
||||
if (dialog.exec()!=QDialog::Accepted) {
|
||||
QMessageBox::critical(this,
|
||||
tr("Can't Commit"),
|
||||
tr("Git needs user info to commit."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (vcsManager.commit(folder,message,true,output)) {
|
||||
//update project view
|
||||
if (mProject) {
|
||||
mProject->model()->beginUpdate();
|
||||
|
@ -6822,6 +6841,11 @@ void MainWindow::on_actionGit_Commit_triggered()
|
|||
mFileSystemModelIconProvider.update();
|
||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
InfoMessageBox infoBox;
|
||||
infoBox.showMessage(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionGit_Restore_triggered()
|
||||
|
@ -6835,7 +6859,8 @@ void MainWindow::on_actionGit_Restore_triggered()
|
|||
if (folder.isEmpty())
|
||||
return;
|
||||
GitManager vcsManager;
|
||||
vcsManager.restore(folder,"");
|
||||
QString output;
|
||||
if (vcsManager.restore(folder,"",output)) {
|
||||
|
||||
//update project view
|
||||
if (mProject) {
|
||||
|
@ -6846,6 +6871,11 @@ void MainWindow::on_actionGit_Restore_triggered()
|
|||
mFileSystemModelIconProvider.update();
|
||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
InfoMessageBox infoBox;
|
||||
infoBox.showMessage(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionWebsite_triggered()
|
||||
|
|
|
@ -29,7 +29,8 @@ void GitManager::createRepository(const QString &folder)
|
|||
|
||||
QDir dir(folder);
|
||||
stringsToFile(contents,dir.filePath(".gitignore"));
|
||||
add(folder,".gitignore");
|
||||
QString output;
|
||||
add(folder,".gitignore",output);
|
||||
}
|
||||
|
||||
bool GitManager::hasRepository(const QString &folder, QString& currentBranch)
|
||||
|
@ -93,32 +94,36 @@ bool GitManager::isFileChanged(const QFileInfo &fileInfo)
|
|||
return output.trimmed() == fileInfo.fileName();
|
||||
}
|
||||
|
||||
void GitManager::add(const QString &folder, const QString &path)
|
||||
bool GitManager::add(const QString &folder, const QString &path, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("add");
|
||||
args.append(path);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
void GitManager::remove(const QString &folder, const QString &path)
|
||||
bool GitManager::remove(const QString &folder, const QString &path, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("rm");
|
||||
args.append(path);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
void GitManager::rename(const QString &folder, const QString &oldName, const QString &newName)
|
||||
bool GitManager::rename(const QString &folder, const QString &oldName,
|
||||
const QString &newName, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("mv");
|
||||
args.append(oldName);
|
||||
args.append(newName);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
void GitManager::restore(const QString &folder, const QString &path)
|
||||
bool GitManager::restore(const QString &folder, const QString &path, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("restore");
|
||||
|
@ -126,7 +131,8 @@ void GitManager::restore(const QString &folder, const QString &path)
|
|||
args.append(".");
|
||||
else
|
||||
args.append(path);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
int GitManager::logCounts(const QString &folder, const QString &branch)
|
||||
|
@ -236,7 +242,7 @@ bool GitManager::removeRemote(const QString &folder, const QString &remoteName,
|
|||
args.append(remoteName);
|
||||
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::renameRemote(const QString &folder, const QString &oldName, const QString &newName, QString &output)
|
||||
|
@ -248,7 +254,7 @@ bool GitManager::renameRemote(const QString &folder, const QString &oldName, con
|
|||
args.append(newName);
|
||||
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::addRemote(const QString &folder, const QString &name, const QString &url, QString &output)
|
||||
|
@ -260,7 +266,7 @@ bool GitManager::addRemote(const QString &folder, const QString &name, const QSt
|
|||
args.append(url);
|
||||
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::setRemoteURL(const QString &folder, const QString &name, const QString &newURL, QString &output)
|
||||
|
@ -272,7 +278,7 @@ bool GitManager::setRemoteURL(const QString &folder, const QString &name, const
|
|||
args.append(newURL);
|
||||
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
QString GitManager::getRemoteURL(const QString &folder, const QString &name)
|
||||
|
@ -313,7 +319,7 @@ bool GitManager::setBranchUpstream(
|
|||
args.append(QString("--set-upstream-to=%1/%2").arg(remoteName,branch));
|
||||
args.append(branch);
|
||||
output = runGit(folder,args).trimmed();
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::fetch(const QString &folder, QString &output)
|
||||
|
@ -321,7 +327,7 @@ bool GitManager::fetch(const QString &folder, QString &output)
|
|||
QStringList args;
|
||||
args.append("fetch");
|
||||
output = runGit(folder,args).trimmed();
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::pull(const QString &folder, QString &output)
|
||||
|
@ -329,7 +335,7 @@ bool GitManager::pull(const QString &folder, QString &output)
|
|||
QStringList args;
|
||||
args.append("pull");
|
||||
output = runGit(folder,args).trimmed();
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::push(const QString &folder, QString &output)
|
||||
|
@ -337,7 +343,7 @@ bool GitManager::push(const QString &folder, QString &output)
|
|||
QStringList args;
|
||||
args.append("push");
|
||||
output = runGit(folder,args).trimmed();
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::push(const QString &folder, const QString &remoteName, const QString &branch, QString &output)
|
||||
|
@ -348,7 +354,58 @@ bool GitManager::push(const QString &folder, const QString &remoteName, const QS
|
|||
args.append(remoteName);
|
||||
args.append(branch);
|
||||
output = runGit(folder,args).trimmed();
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::removeConfig(const QString &folder, const QString &name, QString &output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("config");
|
||||
args.append("--unset-all");
|
||||
args.append(name);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::setConfig(const QString &folder, const QString &name, const QString &value, QString &output)
|
||||
{
|
||||
removeConfig(folder,name,output);
|
||||
QStringList args;
|
||||
args.append("config");
|
||||
args.append("--add");
|
||||
args.append(name);
|
||||
args.append(value);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::setUserName(const QString &folder, const QString &userName, QString &output)
|
||||
{
|
||||
return setConfig(folder,"user.name",userName,output);
|
||||
}
|
||||
|
||||
bool GitManager::setUserEmail(const QString &folder, const QString &userEmail, QString &output)
|
||||
{
|
||||
return setConfig(folder,"user.email",userEmail,output);
|
||||
}
|
||||
|
||||
QString GitManager::getConfig(const QString& folder, const QString &name)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("config");
|
||||
args.append("--get");
|
||||
args.append(name);
|
||||
return runGit(folder,args).trimmed();
|
||||
}
|
||||
|
||||
QString GitManager::getUserName(const QString& folder)
|
||||
{
|
||||
return getConfig(folder, "user.name");
|
||||
}
|
||||
|
||||
QString GitManager::getUserEmail(const QString& folder)
|
||||
{
|
||||
return getConfig(folder, "user.email");
|
||||
}
|
||||
|
||||
QStringList GitManager::listBranches(const QString &folder, int ¤t)
|
||||
|
@ -393,7 +450,7 @@ bool GitManager::switchToBranch(const QString &folder, const QString &branch,
|
|||
args.append("--no-track");
|
||||
args.append(branch);
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::merge(const QString &folder, const QString &commit, bool squash,
|
||||
|
@ -418,7 +475,7 @@ bool GitManager::merge(const QString &folder, const QString &commit, bool squash
|
|||
}
|
||||
args.append(commit);
|
||||
output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::continueMerge(const QString &folder)
|
||||
|
@ -427,7 +484,7 @@ bool GitManager::continueMerge(const QString &folder)
|
|||
args.append("merge");
|
||||
args.append("--continue");
|
||||
QString output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
return isSuccess(output);
|
||||
|
||||
}
|
||||
|
||||
|
@ -439,15 +496,30 @@ void GitManager::abortMerge(const QString &folder)
|
|||
runGit(folder,args);
|
||||
}
|
||||
|
||||
void GitManager::clone(const QString &folder, const QString &url)
|
||||
bool GitManager::isSuccess(const QString &output)
|
||||
{
|
||||
QStringList lst = textToLines(output);
|
||||
if (!lst.isEmpty()) {
|
||||
foreach (const QString& s, lst) {
|
||||
QString last= s.trimmed();
|
||||
if (last.startsWith("error:") || last.startsWith("fatal:"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GitManager::clone(const QString &folder, const QString &url, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("clone");
|
||||
args.append(url);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
void GitManager::commit(const QString &folder, const QString &message, bool autoStage)
|
||||
bool GitManager::commit(const QString &folder, const QString &message, bool autoStage, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("commit");
|
||||
|
@ -455,19 +527,21 @@ void GitManager::commit(const QString &folder, const QString &message, bool auto
|
|||
args.append("-a");
|
||||
args.append("-m");
|
||||
args.append(message);
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
void GitManager::revert(const QString &folder)
|
||||
bool GitManager::revert(const QString &folder, QString& output)
|
||||
{
|
||||
QStringList args;
|
||||
args.append("revert");
|
||||
runGit(folder,args);
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::reset(const QString &folder, const QString &commit,
|
||||
GitResetStrategy strategy,
|
||||
QString& ouput)
|
||||
QString& output)
|
||||
{
|
||||
//todo reset type
|
||||
QStringList args;
|
||||
|
@ -490,8 +564,8 @@ bool GitManager::reset(const QString &folder, const QString &commit,
|
|||
break;
|
||||
}
|
||||
args.append(commit);
|
||||
QString output = runGit(folder,args);
|
||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||
output = runGit(folder,args);
|
||||
return isSuccess(output);
|
||||
}
|
||||
|
||||
bool GitManager::isValid()
|
||||
|
@ -512,10 +586,16 @@ QString GitManager::runGit(const QString& workingFolder, const QStringList &args
|
|||
args.join("\" \"")));
|
||||
// qDebug()<<"---------";
|
||||
// qDebug()<<args;
|
||||
QProcessEnvironment env;
|
||||
env.insert("PATH",pSettings->dirs().appDir());
|
||||
env.insert("GIT_ASKPASS",includeTrailingPathDelimiter(pSettings->dirs().appDir())+"redpanda-win-git-askpass.exe");
|
||||
QString output = runAndGetOutput(
|
||||
fileInfo.absoluteFilePath(),
|
||||
workingFolder,
|
||||
args);
|
||||
args,
|
||||
"",
|
||||
false,
|
||||
env);
|
||||
output = escapeUTF8String(output.toUtf8());
|
||||
// qDebug()<<output;
|
||||
emit gitCmdFinished(output);
|
||||
|
|
|
@ -28,10 +28,10 @@ public:
|
|||
bool isFileStaged(const QFileInfo& fileInfo);
|
||||
bool isFileChanged(const QFileInfo& fileInfo);
|
||||
|
||||
void add(const QString& folder, const QString& path);
|
||||
void remove(const QString& folder, const QString& path);
|
||||
void rename(const QString& folder, const QString& oldName, const QString& newName);
|
||||
void restore(const QString& folder, const QString& path);
|
||||
bool add(const QString& folder, const QString& path, QString& output);
|
||||
bool remove(const QString& folder, const QString& path, QString& output);
|
||||
bool rename(const QString& folder, const QString& oldName, const QString& newName, QString& output);
|
||||
bool restore(const QString& folder, const QString& path, QString& output);
|
||||
|
||||
int logCounts(const QString& folder, const QString& branch=QString());
|
||||
QList<PGitCommitInfo> log(const QString& folder, int start, int count, const QString& branch=QString());
|
||||
|
@ -65,6 +65,15 @@ public:
|
|||
const QString& branch,
|
||||
QString& output);
|
||||
|
||||
bool removeConfig(const QString& folder, const QString &name, QString& output);
|
||||
bool setConfig(const QString& folder, const QString &name, const QString &value, QString& output);
|
||||
bool setUserName(const QString& folder, const QString& userName, QString& output);
|
||||
bool setUserEmail(const QString& folder, const QString& userEmail, QString& output);
|
||||
|
||||
QString getConfig(const QString& folder, const QString& name);
|
||||
QString getUserName(const QString& folder);
|
||||
QString getUserEmail(const QString& folder);
|
||||
|
||||
|
||||
QStringList listBranches(const QString& folder, int& current);
|
||||
bool switchToBranch(const QString& folder, const QString& branch, bool create,
|
||||
|
@ -78,9 +87,10 @@ public:
|
|||
bool continueMerge(const QString& folder);
|
||||
void abortMerge(const QString& folder);
|
||||
|
||||
void clone(const QString& folder, const QString& url);
|
||||
void commit(const QString& folder, const QString& message, bool autoStage);
|
||||
void revert(const QString& folder);
|
||||
bool isSuccess(const QString& output);
|
||||
bool clone(const QString& folder, const QString& url, QString& output);
|
||||
bool commit(const QString& folder, const QString& message, bool autoStage, QString& output);
|
||||
bool revert(const QString& folder, QString& output);
|
||||
bool reset(const QString& folder, const QString& commit, GitResetStrategy strategy, QString& output);
|
||||
|
||||
bool isValid();
|
||||
|
|
|
@ -30,24 +30,24 @@ bool GitRepository::hasRepository(QString& currentBranch)
|
|||
return mInRepository;
|
||||
}
|
||||
|
||||
void GitRepository::add(const QString &path)
|
||||
bool GitRepository::add(const QString &path, QString& output)
|
||||
{
|
||||
mManager->add(mFolder,path);
|
||||
return mManager->add(mFolder,path, output);
|
||||
}
|
||||
|
||||
void GitRepository::remove(const QString &path)
|
||||
bool GitRepository::remove(const QString &path, QString& output)
|
||||
{
|
||||
mManager->remove(mFolder,path);
|
||||
return mManager->remove(mFolder,path, output);
|
||||
}
|
||||
|
||||
void GitRepository::rename(const QString &oldName, const QString &newName)
|
||||
bool GitRepository::rename(const QString &oldName, const QString &newName, QString& output)
|
||||
{
|
||||
mManager->rename(mFolder, oldName, newName);
|
||||
return mManager->rename(mFolder, oldName, newName,output);
|
||||
}
|
||||
|
||||
void GitRepository::restore(const QString &path)
|
||||
bool GitRepository::restore(const QString &path, QString& output)
|
||||
{
|
||||
mManager->restore(mFolder, path);
|
||||
return mManager->restore(mFolder, path, output);
|
||||
}
|
||||
|
||||
QSet<QString> GitRepository::listFiles(bool refresh)
|
||||
|
@ -57,19 +57,19 @@ QSet<QString> GitRepository::listFiles(bool refresh)
|
|||
return mFilesInRepositories;
|
||||
}
|
||||
|
||||
void GitRepository::clone(const QString &url)
|
||||
bool GitRepository::clone(const QString &url, QString& output)
|
||||
{
|
||||
mManager->clone(mFolder,url);
|
||||
return mManager->clone(mFolder,url, output);
|
||||
}
|
||||
|
||||
void GitRepository::commit(const QString &message, bool autoStage)
|
||||
bool GitRepository::commit(const QString &message, QString& output, bool autoStage)
|
||||
{
|
||||
mManager->commit(mRealFolder, message, autoStage);
|
||||
return mManager->commit(mRealFolder, message, autoStage, output);
|
||||
}
|
||||
|
||||
void GitRepository::revert()
|
||||
bool GitRepository::revert(QString& output)
|
||||
{
|
||||
mManager->revert(mRealFolder);
|
||||
return mManager->revert(mRealFolder, output);
|
||||
}
|
||||
|
||||
void GitRepository::setFolder(const QString &newFolder)
|
||||
|
|
|
@ -54,15 +54,15 @@ public:
|
|||
return !mConflicts.isEmpty();
|
||||
}
|
||||
|
||||
void add(const QString& path);
|
||||
void remove(const QString& path);
|
||||
void rename(const QString& oldName, const QString& newName);
|
||||
void restore(const QString& path);
|
||||
bool add(const QString& path, QString& output);
|
||||
bool remove(const QString& path, QString& output);
|
||||
bool rename(const QString& oldName, const QString& newName, QString& output);
|
||||
bool restore(const QString& path, QString& output);
|
||||
QSet<QString> listFiles(bool refresh);
|
||||
|
||||
void clone(const QString& url);
|
||||
void commit(const QString& message, bool autoStage=true);
|
||||
void revert();
|
||||
bool clone(const QString& url, QString& output);
|
||||
bool commit(const QString& message, QString& output, bool autoStage=true);
|
||||
bool revert(QString& output);
|
||||
|
||||
|
||||
void setFolder(const QString &newFolder);
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#include "gituserconfigdialog.h"
|
||||
#include "ui_gituserconfigdialog.h"
|
||||
#include "gitmanager.h"
|
||||
#include "../widgets/infomessagebox.h"
|
||||
|
||||
GitUserConfigDialog::GitUserConfigDialog(const QString& folder, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::GitUserConfigDialog),
|
||||
mFolder(folder)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
GitManager manager;
|
||||
ui->txtUserName->setText(manager.getUserName(folder));
|
||||
ui->txtUserEmail->setText(manager.getUserEmail(folder));
|
||||
checkInfo();
|
||||
}
|
||||
|
||||
GitUserConfigDialog::~GitUserConfigDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void GitUserConfigDialog::checkInfo()
|
||||
{
|
||||
ui->btnOk->setEnabled(!ui->txtUserEmail->text().isEmpty()
|
||||
&& !ui->txtUserName->text().isEmpty());
|
||||
}
|
||||
|
||||
void GitUserConfigDialog::on_btnOk_clicked()
|
||||
{
|
||||
GitManager manager;
|
||||
QString output;
|
||||
if (!manager.setUserName(mFolder, ui->txtUserName->text(),output)) {
|
||||
InfoMessageBox infoBox;
|
||||
infoBox.showMessage(output);
|
||||
reject();
|
||||
}
|
||||
if (!manager.setUserEmail(mFolder, ui->txtUserEmail->text(),output)) {
|
||||
InfoMessageBox infoBox;
|
||||
infoBox.showMessage(output);
|
||||
reject();
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
void GitUserConfigDialog::on_btnCancel_clicked()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void GitUserConfigDialog::closeEvent(QCloseEvent * /*event*/)
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
|
||||
void GitUserConfigDialog::on_txtUserName_textChanged(const QString &/*arg1*/)
|
||||
{
|
||||
checkInfo();
|
||||
}
|
||||
|
||||
|
||||
void GitUserConfigDialog::on_txtUserEmail_textChanged(const QString &/*arg1*/)
|
||||
{
|
||||
checkInfo();
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef GITUSERCONFIGDIALOG_H
|
||||
#define GITUSERCONFIGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class GitUserConfigDialog;
|
||||
}
|
||||
|
||||
class GitUserConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GitUserConfigDialog(const QString& folder, QWidget *parent = nullptr);
|
||||
~GitUserConfigDialog();
|
||||
|
||||
private:
|
||||
Ui::GitUserConfigDialog *ui;
|
||||
QString mFolder;
|
||||
|
||||
private:
|
||||
void checkInfo();
|
||||
private slots:
|
||||
void on_btnOk_clicked();
|
||||
void on_btnCancel_clicked();
|
||||
void on_txtUserName_textChanged(const QString &arg1);
|
||||
void on_txtUserEmail_textChanged(const QString &arg1);
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // GITUSERCONFIGDIALOG_H
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GitUserConfigDialog</class>
|
||||
<widget class="QDialog" name="GitUserConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>429</width>
|
||||
<height>299</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Fill User Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="txtUserEmail"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>User Email:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" rowspan="2">
|
||||
<widget class="QLineEdit" name="txtUserName"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>User Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Git needs the following info to commit:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue