- change: Git support is disabled in the distributed buildings.

This commit is contained in:
Roy Qu 2023-08-08 14:41:23 +08:00
parent dfbdf604fb
commit 3a8e434399
15 changed files with 159 additions and 66 deletions

View File

@ -18,6 +18,7 @@ Red Panda C++ Version 2.24
- fix: Can't parse full class name when handle inheritance. - fix: Can't parse full class name when handle inheritance.
- fix: Can't parse virtual inherit. - fix: Can't parse virtual inherit.
- fix: Filename in the gcc 13.1 error messages when building project is using wrong encoding. - fix: Filename in the gcc 13.1 error messages when building project is using wrong encoding.
- change: Git support is disabled in the distributed buildings.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -3,6 +3,9 @@ QT += core gui printsupport network svg xml widgets
CONFIG += c++17 CONFIG += c++17
CONFIG += nokey CONFIG += nokey
# uncomment the following line to enable vcs (git) support
# CONFIG += ENABLE_VCS
isEmpty(APP_NAME) { isEmpty(APP_NAME) {
APP_NAME = RedPandaCPP APP_NAME = RedPandaCPP
} }
@ -140,25 +143,12 @@ SOURCES += \
settingsdialog/projectoutputwidget.cpp \ settingsdialog/projectoutputwidget.cpp \
settingsdialog/projectprecompilewidget.cpp \ settingsdialog/projectprecompilewidget.cpp \
settingsdialog/toolsgeneralwidget.cpp \ settingsdialog/toolsgeneralwidget.cpp \
settingsdialog/toolsgitwidget.cpp \
shortcutmanager.cpp \ shortcutmanager.cpp \
symbolusagemanager.cpp \ symbolusagemanager.cpp \
syntaxermanager.cpp \ syntaxermanager.cpp \
thememanager.cpp \ thememanager.cpp \
todoparser.cpp \ todoparser.cpp \
toolsmanager.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/gituserconfigdialog.cpp \
vcs/gitutils.cpp \
visithistorymanager.cpp \ visithistorymanager.cpp \
widgets/aboutdialog.cpp \ widgets/aboutdialog.cpp \
widgets/bookmarkmodel.cpp \ widgets/bookmarkmodel.cpp \
@ -276,25 +266,12 @@ HEADERS += \
settingsdialog/projectoutputwidget.h \ settingsdialog/projectoutputwidget.h \
settingsdialog/projectprecompilewidget.h \ settingsdialog/projectprecompilewidget.h \
settingsdialog/toolsgeneralwidget.h \ settingsdialog/toolsgeneralwidget.h \
settingsdialog/toolsgitwidget.h \
shortcutmanager.h \ shortcutmanager.h \
symbolusagemanager.h \ symbolusagemanager.h \
syntaxermanager.h \ syntaxermanager.h \
thememanager.h \ thememanager.h \
todoparser.h \ todoparser.h \
toolsmanager.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/gituserconfigdialog.h \
vcs/gitutils.h \
visithistorymanager.h \ visithistorymanager.h \
widgets/aboutdialog.h \ widgets/aboutdialog.h \
widgets/bookmarkmodel.h \ widgets/bookmarkmodel.h \
@ -384,16 +361,6 @@ FORMS += \
settingsdialog/projectoutputwidget.ui \ settingsdialog/projectoutputwidget.ui \
settingsdialog/projectprecompilewidget.ui \ settingsdialog/projectprecompilewidget.ui \
settingsdialog/toolsgeneralwidget.ui \ 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 \
vcs/gituserconfigdialog.ui \
widgets/aboutdialog.ui \ widgets/aboutdialog.ui \
widgets/choosethemedialog.ui \ widgets/choosethemedialog.ui \
widgets/cpudialog.ui \ widgets/cpudialog.ui \
@ -423,6 +390,53 @@ FORMS += \
widgets/searchinfiledialog.ui \ widgets/searchinfiledialog.ui \
widgets/signalmessagedialog.ui widgets/signalmessagedialog.ui
ENABLE_VCS {
DEFINES += ENABLE_VCS
SOURCES += \
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/gituserconfigdialog.cpp \
vcs/gitutils.cpp \
settingsdialog/toolsgitwidget.cpp
HEADERS += \
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/gituserconfigdialog.h \
vcs/gitutils.h \
settingsdialog/toolsgitwidget.h
FORMS += \
vcs/gitbranchdialog.ui \
vcs/gitfetchdialog.ui \
vcs/gitlogdialog.ui \
vcs/gitmergedialog.ui \
vcs/gitpulldialog.ui \
vcs/gitpushdialog.ui \
vcs/gitremotedialog.ui \
vcs/gitresetdialog.ui \
vcs/gituserconfigdialog.ui \
settingsdialog/toolsgitwidget.ui
}
win32: { win32: {
FORMS += \ FORMS += \
settingsdialog/projectversioninfowidget.ui \ settingsdialog/projectversioninfowidget.ui \

View File

@ -16,33 +16,45 @@
*/ */
#include "customfileiconprovider.h" #include "customfileiconprovider.h"
#include "iconsmanager.h" #include "iconsmanager.h"
#ifdef ENABLE_VCS
#include "vcs/gitrepository.h" #include "vcs/gitrepository.h"
#endif
CustomFileIconProvider::CustomFileIconProvider() CustomFileIconProvider::CustomFileIconProvider()
{ {
//provider delete it in the destructor //provider delete it in the destructor
#ifdef ENABLE_VCS
mVCSRepository = new GitRepository(""); mVCSRepository = new GitRepository("");
#endif
} }
CustomFileIconProvider::~CustomFileIconProvider() CustomFileIconProvider::~CustomFileIconProvider()
{ {
#ifdef ENABLE_VCS
delete mVCSRepository; delete mVCSRepository;
#endif
} }
void CustomFileIconProvider::setRootFolder(const QString &folder) void CustomFileIconProvider::setRootFolder(const QString &folder)
{ {
#ifdef ENABLE_VCS
mVCSRepository->setFolder(folder); mVCSRepository->setFolder(folder);
#endif
} }
void CustomFileIconProvider::update() void CustomFileIconProvider::update()
{ {
#ifdef ENABLE_VCS
mVCSRepository->update(); mVCSRepository->update();
#endif
} }
#ifdef ENABLE_VCS
GitRepository *CustomFileIconProvider::VCSRepository() const GitRepository *CustomFileIconProvider::VCSRepository() const
{ {
return mVCSRepository; return mVCSRepository;
} }
#endif
QIcon CustomFileIconProvider::icon(IconType type) const QIcon CustomFileIconProvider::icon(IconType type) const
{ {
@ -59,6 +71,7 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
{ {
QIcon icon; QIcon icon;
if (info.isDir()) { if (info.isDir()) {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_CONFLICT);
@ -69,10 +82,12 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER_VCS_NOCHANGE);
} else } else
#endif
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FOLDER);
} else if (!info.exists()) { } else if (!info.exists()) {
icon = pIconsManager->getIcon(IconsManager::ACTION_MISC_CROSS); icon = pIconsManager->getIcon(IconsManager::ACTION_MISC_CROSS);
} else if (isHFile(info.fileName())) { } else if (isHFile(info.fileName())) {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_CONFLICT);
@ -83,8 +98,10 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE_VCS_NOCHANGE);
} else } else
#endif
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_HFILE);
} else if (isCppFile(info.fileName())) { } else if (isCppFile(info.fileName())) {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE_VCS_CONFLICT);
@ -95,8 +112,10 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE_VCS_NOCHANGE);
} else } else
#endif
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CPPFILE);
} else if (isCFile(info.fileName())) { } else if (isCFile(info.fileName())) {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE_VCS_CONFLICT);
@ -107,8 +126,10 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE_VCS_NOCHANGE);
} else } else
#endif
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_CFILE);
} else if (info.suffix()=="dev") { } else if (info.suffix()=="dev") {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE_VCS_CONFLICT);
@ -119,8 +140,10 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE_VCS_NOCHANGE);
} else } else
#endif
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_PROJECTFILE);
} else { } else {
#ifdef ENABLE_VCS
if (mVCSRepository->isFileInRepository(info)) { if (mVCSRepository->isFileInRepository(info)) {
if (mVCSRepository->isFileConflicting(info)) if (mVCSRepository->isFileConflicting(info))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_CONFLICT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_CONFLICT);
@ -130,7 +153,9 @@ QIcon CustomFileIconProvider::icon(const QFileInfo &info) const
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_CHANGED); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_CHANGED);
else else
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_NOCHANGE); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_FILE_VCS_NOCHANGE);
} //use default system icon }
#endif
//use default system icon
} }
if (!icon.isNull()) if (!icon.isNull())
return icon; return icon;

View File

@ -28,12 +28,16 @@ public:
void setRootFolder(const QString& folder); void setRootFolder(const QString& folder);
void update(); void update();
private: private:
#ifdef ENABLE_VCS
GitRepository* mVCSRepository; GitRepository* mVCSRepository;
#endif
// QFileIconProvider interface // QFileIconProvider interface
public: public:
QIcon icon(IconType type) const override; QIcon icon(IconType type) const override;
QIcon icon(const QFileInfo &info) const override; QIcon icon(const QFileInfo &info) const override;
#ifdef ENABLE_VCS
GitRepository *VCSRepository() const; GitRepository *VCSRepository() const;
#endif
}; };
#endif // CUSTOMFILEICONPROVIDER_H #endif // CUSTOMFILEICONPROVIDER_H

View File

@ -365,7 +365,9 @@ int main(int argc, char *argv[])
pSettings->editor().save(); pSettings->editor().save();
//auto detect git in path //auto detect git in path
#ifdef ENABLE_VCS
pSettings->vcs().detectGitInPath(); pSettings->vcs().detectGitInPath();
#endif
} }
//Color scheme settings must be loaded after translation //Color scheme settings must be loaded after translation
ColorManager colorManager; ColorManager colorManager;

View File

@ -40,6 +40,7 @@
#include "iconsmanager.h" #include "iconsmanager.h"
#include "widgets/newclassdialog.h" #include "widgets/newclassdialog.h"
#include "widgets/newheaderdialog.h" #include "widgets/newheaderdialog.h"
#ifdef ENABLE_VCS
#include "vcs/gitmanager.h" #include "vcs/gitmanager.h"
#include "vcs/gitrepository.h" #include "vcs/gitrepository.h"
#include "vcs/gitbranchdialog.h" #include "vcs/gitbranchdialog.h"
@ -47,6 +48,7 @@
#include "vcs/gitlogdialog.h" #include "vcs/gitlogdialog.h"
#include "vcs/gitremotedialog.h" #include "vcs/gitremotedialog.h"
#include "vcs/gituserconfigdialog.h" #include "vcs/gituserconfigdialog.h"
#endif
#include "widgets/infomessagebox.h" #include "widgets/infomessagebox.h"
#include "widgets/newtemplatedialog.h" #include "widgets/newtemplatedialog.h"
#include "visithistorymanager.h" #include "visithistorymanager.h"
@ -444,9 +446,10 @@ MainWindow::MainWindow(QWidget *parent)
this, &MainWindow::on_EditorTabsRight_tabCloseRequested); this, &MainWindow::on_EditorTabsRight_tabCloseRequested);
//git menu //git menu
#ifdef ENABLE_VCS
connect(ui->menuGit, &QMenu::aboutToShow, connect(ui->menuGit, &QMenu::aboutToShow,
this, &MainWindow::updateVCSActions); this, &MainWindow::updateVCSActions);
#endif
initToolButtons(); initToolButtons();
buildContextMenus(); buildContextMenus();
updateAppTitle(); updateAppTitle();
@ -959,9 +962,11 @@ void MainWindow::applySettings()
// for (int i=0;i<ui->cbFilesPath->count();i++) { // for (int i=0;i<ui->cbFilesPath->count();i++) {
// ui->cbFilesPath->setItemIcon(i,pIconsManager->getIcon(IconsManager::FILESYSTEM_GIT)); // ui->cbFilesPath->setItemIcon(i,pIconsManager->getIcon(IconsManager::FILESYSTEM_GIT));
// } // }
#ifdef ENABLE_VCS
ui->menuGit->menuAction()->setVisible(pSettings->vcs().gitOk()); ui->menuGit->menuAction()->setVisible(pSettings->vcs().gitOk());
#else
ui->menuGit->menuAction()->setVisible(false);
#endif
stretchExplorerPanel(!ui->tabExplorer->isShrinked()); stretchExplorerPanel(!ui->tabExplorer->isShrinked());
stretchMessagesPanel(!ui->tabMessages->isShrinked()); stretchMessagesPanel(!ui->tabMessages->isShrinked());
} }
@ -1060,6 +1065,7 @@ void MainWindow::updateDPI(int oldDPI, int /*newDPI*/)
void MainWindow::onFileSaved(const QString &path, bool inProject) void MainWindow::onFileSaved(const QString &path, bool inProject)
{ {
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk()) { if (pSettings->vcs().gitOk()) {
QString branch; QString branch;
if (inProject && mProject && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) { if (inProject && mProject && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
@ -1080,6 +1086,7 @@ void MainWindow::onFileSaved(const QString &path, bool inProject)
ui->treeFiles->update(index); ui->treeFiles->update(index);
} }
} }
#endif
//updateForEncodingInfo(); //updateForEncodingInfo();
} }
@ -3684,12 +3691,14 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
onRoot = true; onRoot = true;
} }
} }
GitManager vcsManager;
QString branch;
bool hasRepository = vcsManager.hasRepository(mProject->folder(),branch);
QMenu menu(this); QMenu menu(this);
#ifdef ENABLE_VCS
QMenu vcsMenu(this); QMenu vcsMenu(this);
QString branch;
GitManager vcsManager;
bool hasRepository = vcsManager.hasRepository(mProject->folder(),branch);
#endif
updateProjectActions(); updateProjectActions();
menu.addAction(ui->actionProject_New_File); menu.addAction(ui->actionProject_New_File);
menu.addAction(ui->actionNew_Class); menu.addAction(ui->actionNew_Class);
@ -3702,6 +3711,7 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
menu.addAction(mProject_Rename_Unit); menu.addAction(mProject_Rename_Unit);
} }
menu.addSeparator(); menu.addSeparator();
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk()) { if (pSettings->vcs().gitOk()) {
if (hasRepository) { if (hasRepository) {
menu.addMenu(&vcsMenu); menu.addMenu(&vcsMenu);
@ -3711,6 +3721,7 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
} }
menu.addSeparator(); menu.addSeparator();
} }
#endif
if (onFolder && mProject->modelType()==ProjectModelType::Custom) { if (onFolder && mProject->modelType()==ProjectModelType::Custom) {
menu.addAction(mProject_Add_Folder); menu.addAction(mProject_Add_Folder);
if (!onRoot) { if (!onRoot) {
@ -3733,6 +3744,7 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
menu.addSeparator(); menu.addSeparator();
menu.addAction(ui->actionClose_Project); menu.addAction(ui->actionClose_Project);
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk() && hasRepository) { if (pSettings->vcs().gitOk() && hasRepository) {
mProject->model()->iconProvider()->update(); mProject->model()->iconProvider()->update();
vcsMenu.setTitle(tr("Version Control")); vcsMenu.setTitle(tr("Version Control"));
@ -3771,7 +3783,8 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
vcsMenu.addAction(ui->actionGit_Commit); vcsMenu.addAction(ui->actionGit_Commit);
vcsMenu.addAction(ui->actionGit_Restore); vcsMenu.addAction(ui->actionGit_Restore);
bool canBranch = !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles() bool canBranch = false;
canBranch = !mProject->model()->iconProvider()->VCSRepository()->hasChangedFiles()
&& !mProject->model()->iconProvider()->VCSRepository()->hasStagedFiles(); && !mProject->model()->iconProvider()->VCSRepository()->hasStagedFiles();
ui->actionGit_Branch->setEnabled(canBranch); ui->actionGit_Branch->setEnabled(canBranch);
ui->actionGit_Merge->setEnabled(canBranch); ui->actionGit_Merge->setEnabled(canBranch);
@ -3785,6 +3798,7 @@ void MainWindow::onProjectViewContextMenu(const QPoint &pos)
// ui->actionGit_Reset->setEnabled(true); // ui->actionGit_Reset->setEnabled(true);
// ui->actionGit_Revert->setEnabled(true); // ui->actionGit_Revert->setEnabled(true);
} }
#endif
menu.exec(ui->projectView->mapToGlobal(pos)); menu.exec(ui->projectView->mapToGlobal(pos));
} }
@ -3849,11 +3863,13 @@ void MainWindow::onFileEncodingContextMenu(const QPoint &pos)
void MainWindow::onFilesViewContextMenu(const QPoint &pos) void MainWindow::onFilesViewContextMenu(const QPoint &pos)
{ {
QMenu menu(this);
#ifdef ENABLE_VCS
GitManager vcsManager; GitManager vcsManager;
QString branch; QString branch;
bool hasRepository = vcsManager.hasRepository(pSettings->environment().currentFolder(),branch); bool hasRepository = vcsManager.hasRepository(pSettings->environment().currentFolder(),branch);
QMenu menu(this);
QMenu vcsMenu(this); QMenu vcsMenu(this);
#endif
menu.addAction(ui->actionOpen_Folder); menu.addAction(ui->actionOpen_Folder);
menu.addSeparator(); menu.addSeparator();
menu.addAction(mFilesView_CreateFolder); menu.addAction(mFilesView_CreateFolder);
@ -3861,6 +3877,7 @@ void MainWindow::onFilesViewContextMenu(const QPoint &pos)
menu.addAction(mFilesView_RemoveFile); menu.addAction(mFilesView_RemoveFile);
menu.addAction(mFilesView_Rename); menu.addAction(mFilesView_Rename);
menu.addSeparator(); menu.addSeparator();
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk()) { if (pSettings->vcs().gitOk()) {
if (hasRepository) { if (hasRepository) {
menu.addMenu(&vcsMenu); menu.addMenu(&vcsMenu);
@ -3870,6 +3887,7 @@ void MainWindow::onFilesViewContextMenu(const QPoint &pos)
} }
menu.addSeparator(); menu.addSeparator();
} }
#endif
menu.addAction(mFilesView_Open); menu.addAction(mFilesView_Open);
menu.addAction(mFilesView_OpenWithExternal); menu.addAction(mFilesView_OpenWithExternal);
menu.addSeparator(); menu.addSeparator();
@ -3886,6 +3904,7 @@ void MainWindow::onFilesViewContextMenu(const QPoint &pos)
mFilesView_Rename->setEnabled(!path.isEmpty()); mFilesView_Rename->setEnabled(!path.isEmpty());
mFilesView_RemoveFile->setEnabled(!path.isEmpty() || !ui->treeFiles->selectionModel()->selectedRows().isEmpty()); mFilesView_RemoveFile->setEnabled(!path.isEmpty() || !ui->treeFiles->selectionModel()->selectedRows().isEmpty());
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk() && hasRepository) { if (pSettings->vcs().gitOk() && hasRepository) {
mFileSystemModelIconProvider.update(); mFileSystemModelIconProvider.update();
vcsMenu.setTitle(tr("Version Control")); vcsMenu.setTitle(tr("Version Control"));
@ -3927,6 +3946,7 @@ void MainWindow::onFilesViewContextMenu(const QPoint &pos)
// ui->actionGit_Reset->setEnabled(true); // ui->actionGit_Reset->setEnabled(true);
// ui->actionGit_Revert->setEnabled(true); // ui->actionGit_Revert->setEnabled(true);
} }
#endif
menu.exec(ui->treeFiles->mapToGlobal(pos)); menu.exec(ui->treeFiles->mapToGlobal(pos));
} }
@ -7045,6 +7065,7 @@ void MainWindow::on_actionAdd_to_project_triggered()
foreach (const QString& filename, dialog.selectedFiles()) { foreach (const QString& filename, dialog.selectedFiles()) {
PProjectUnit newUnit = mProject->addUnit(filename,folderNode); PProjectUnit newUnit = mProject->addUnit(filename,folderNode);
mProject->cppParser()->addProjectFile(filename,true); mProject->cppParser()->addProjectFile(filename,true);
#ifdef ENABLE_VCS
QString branch; QString branch;
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) { if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
QString output; QString output;
@ -7053,6 +7074,7 @@ void MainWindow::on_actionAdd_to_project_triggered()
output output
); );
} }
#endif
if (newUnit) { if (newUnit) {
QModelIndex index = mProject->model()->getNodeIndex(newUnit->node().get()); QModelIndex index = mProject->model()->getNodeIndex(newUnit->node().get());
index = mProjectProxyModel->mapFromSource(index); index = mProjectProxyModel->mapFromSource(index);
@ -7418,11 +7440,13 @@ void MainWindow::newProjectUnitFile(const QString& suffix)
if (editor) if (editor)
editor->activate(); editor->activate();
QString branch; QString branch;
#ifdef ENABLE_VCS
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) { if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
QString output; QString output;
mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output); mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output);
mProject->model()->refreshIcon(newFileName); mProject->model()->refreshIcon(newFileName);
} }
#endif
updateProjectView(); updateProjectView();
} }
@ -7761,6 +7785,7 @@ void MainWindow::setDockMessagesToArea(const Qt::DockWidgetArea &area)
} }
} }
#ifdef ENABLE_VCS
void MainWindow::updateVCSActions() void MainWindow::updateVCSActions()
{ {
bool hasRepository = false; bool hasRepository = false;
@ -7795,6 +7820,7 @@ void MainWindow::updateVCSActions()
ui->actionGit_Restore->setEnabled(hasRepository && shouldEnable); ui->actionGit_Restore->setEnabled(hasRepository && shouldEnable);
ui->actionGit_Revert->setEnabled(hasRepository && shouldEnable); ui->actionGit_Revert->setEnabled(hasRepository && shouldEnable);
} }
#endif
void MainWindow::invalidateProjectProxyModel() void MainWindow::invalidateProjectProxyModel()
{ {
@ -8958,7 +8984,7 @@ void MainWindow::on_actionNew_Class_triggered()
pSettings->ui().setNewHeaderDialogHeight(dialog.height()); pSettings->ui().setNewHeaderDialogHeight(dialog.height());
} }
#ifdef ENABLE_VCS
void MainWindow::on_actionGit_Create_Repository_triggered() void MainWindow::on_actionGit_Create_Repository_triggered()
{ {
if (ui->treeFiles->isVisible()) { if (ui->treeFiles->isVisible()) {
@ -9131,15 +9157,6 @@ void MainWindow::on_actionGit_Restore_triggered()
} }
void MainWindow::on_actionWebsite_triggered()
{
if (pSettings->environment().language()=="zh_CN") {
QDesktopServices::openUrl(QUrl("https://royqh1979.gitee.io/redpandacpp/"));
} else {
QDesktopServices::openUrl(QUrl("https://sourceforge.net/projects/redpanda-cpp/"));
}
}
void MainWindow::on_actionGit_Branch_triggered() void MainWindow::on_actionGit_Branch_triggered()
{ {
@ -9162,7 +9179,6 @@ void MainWindow::on_actionGit_Branch_triggered()
} }
} }
void MainWindow::on_actionGit_Merge_triggered() void MainWindow::on_actionGit_Merge_triggered()
{ {
QString folder; QString folder;
@ -9311,6 +9327,16 @@ void MainWindow::on_actionGit_Push_triggered()
} }
} }
#endif
void MainWindow::on_actionWebsite_triggered()
{
if (pSettings->environment().language()=="zh_CN") {
QDesktopServices::openUrl(QUrl("https://royqh1979.gitee.io/redpandacpp/"));
} else {
QDesktopServices::openUrl(QUrl("https://sourceforge.net/projects/redpanda-cpp/"));
}
}
void MainWindow::on_actionFilesView_Hide_Non_Support_Files_toggled(bool /* arg1 */) void MainWindow::on_actionFilesView_Hide_Non_Support_Files_toggled(bool /* arg1 */)
{ {

View File

@ -338,7 +338,9 @@ private slots:
void onProjectViewNodeRenamed(); void onProjectViewNodeRenamed();
void setDockExplorerToArea(const Qt::DockWidgetArea &area); void setDockExplorerToArea(const Qt::DockWidgetArea &area);
void setDockMessagesToArea(const Qt::DockWidgetArea &area); void setDockMessagesToArea(const Qt::DockWidgetArea &area);
#ifdef ENABLE_VCS
void updateVCSActions(); void updateVCSActions();
#endif
void invalidateProjectProxyModel(); void invalidateProjectProxyModel();
void onEditorRenamed(const QString &oldFilename, const QString &newFilename, bool firstSave); void onEditorRenamed(const QString &oldFilename, const QString &newFilename, bool firstSave);
void onAutoSaveTimeout(); void onAutoSaveTimeout();
@ -702,6 +704,7 @@ private slots:
void on_actionNew_Header_triggered(); void on_actionNew_Header_triggered();
#ifdef ENABLE_VCS
void on_actionGit_Create_Repository_triggered(); void on_actionGit_Create_Repository_triggered();
void on_actionGit_Add_Files_triggered(); void on_actionGit_Add_Files_triggered();
@ -710,8 +713,6 @@ private slots:
void on_actionGit_Restore_triggered(); void on_actionGit_Restore_triggered();
void on_actionWebsite_triggered();
void on_actionGit_Branch_triggered(); void on_actionGit_Branch_triggered();
void on_actionGit_Merge_triggered(); void on_actionGit_Merge_triggered();
@ -725,6 +726,8 @@ private slots:
void on_actionGit_Pull_triggered(); void on_actionGit_Pull_triggered();
void on_actionGit_Push_triggered(); void on_actionGit_Push_triggered();
#endif
void on_actionWebsite_triggered();
void on_actionFilesView_Hide_Non_Support_Files_toggled(bool arg1); void on_actionFilesView_Hide_Non_Support_Files_toggled(bool arg1);

View File

@ -2627,11 +2627,13 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const
if (!p) if (!p)
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
#ifdef ENABLE_VCS
if (p == mProject->rootNode().get()) { if (p == mProject->rootNode().get()) {
QString branch; QString branch;
if (mIconProvider->VCSRepository()->hasRepository(branch)) if (mIconProvider->VCSRepository()->hasRepository(branch))
return QString("%1 [%2]").arg(p->text,branch); return QString("%1 [%2]").arg(p->text,branch);
} }
#endif
return p->text; return p->text;
} else if (role==Qt::EditRole) { } else if (role==Qt::EditRole) {
return p->text; return p->text;
@ -2643,9 +2645,11 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const
icon = mIconProvider->icon(unit->fileName()); icon = mIconProvider->icon(unit->fileName());
} else { } else {
if (p == mProject->rootNode().get()) { if (p == mProject->rootNode().get()) {
#ifdef ENABLE_VCS
QString branch; QString branch;
if (mIconProvider->VCSRepository()->hasRepository(branch)) if (mIconProvider->VCSRepository()->hasRepository(branch))
icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_GIT); icon = pIconsManager->getIcon(IconsManager::FILESYSTEM_GIT);
#endif
} else { } else {
switch(p->folderNodeType) { switch(p->folderNodeType) {
case ProjectModelNodeType::DUMMY_HEADERS_FOLDER: case ProjectModelNodeType::DUMMY_HEADERS_FOLDER:

View File

@ -48,7 +48,9 @@ Settings::Settings(const QString &filename):
mCodeCompletion(this), mCodeCompletion(this),
mCodeFormatter(this), mCodeFormatter(this),
mUI(this), mUI(this),
#ifdef ENABLE_VCS
mVCS(this), mVCS(this),
#endif
mLanguages(this) mLanguages(this)
{ {
//load(); //load();
@ -112,7 +114,9 @@ void Settings::load()
mCodeFormatter.load(); mCodeFormatter.load();
mUI.load(); mUI.load();
mDirs.load(); mDirs.load();
#ifdef ENABLE_VCS
mVCS.load(); mVCS.load();
#endif
mLanguages.load(); mLanguages.load();
} }
@ -172,10 +176,12 @@ Settings::UI &Settings::ui()
return mUI; return mUI;
} }
#ifdef ENABLE_VCS
Settings::VCS &Settings::vcs() Settings::VCS &Settings::vcs()
{ {
return mVCS; return mVCS;
} }
#endif
Settings::Debugger& Settings::debugger() Settings::Debugger& Settings::debugger()
{ {
@ -5935,6 +5941,7 @@ void Settings::UI::doLoad()
mNewHeaderDialogHeight = intValue("new_header_dialog_height", 300*qApp->desktop()->height()/1080); mNewHeaderDialogHeight = intValue("new_header_dialog_height", 300*qApp->desktop()->height()/1080);
} }
#ifdef ENABLE_VCS
Settings::VCS::VCS(Settings *settings):_Base(settings,SETTING_VCS), Settings::VCS::VCS(Settings *settings):_Base(settings,SETTING_VCS),
mGitOk(false) mGitOk(false)
{ {
@ -6010,6 +6017,7 @@ void Settings::VCS::detectGitInPath()
} }
} }
#endif
Settings::Languages::Languages(Settings *settings): Settings::Languages::Languages(Settings *settings):
_Base(settings,SETTING_LANGUAGES) _Base(settings,SETTING_LANGUAGES)

View File

@ -962,7 +962,7 @@ public:
void doSave() override; void doSave() override;
void doLoad() override; void doLoad() override;
}; };
#ifdef ENABLE_VCS
class VCS: public _Base { class VCS: public _Base {
public: public:
explicit VCS(Settings *settings); explicit VCS(Settings *settings);
@ -979,6 +979,7 @@ public:
void doSave() override; void doSave() override;
void doLoad() override; void doLoad() override;
}; };
#endif
class Languages: public _Base { class Languages: public _Base {
public: public:
@ -1565,7 +1566,9 @@ public:
CodeCompletion &codeCompletion(); CodeCompletion &codeCompletion();
CodeFormatter &codeFormatter(); CodeFormatter &codeFormatter();
UI &ui(); UI &ui();
#ifdef ENABLE_VCS
VCS &vcs(); VCS &vcs();
#endif
Languages &languages(); Languages &languages();
QString filename() const; QString filename() const;
@ -1581,7 +1584,9 @@ private:
CodeCompletion mCodeCompletion; CodeCompletion mCodeCompletion;
CodeFormatter mCodeFormatter; CodeFormatter mCodeFormatter;
UI mUI; UI mUI;
#ifdef ENABLE_VCS
VCS mVCS; VCS mVCS;
#endif
Languages mLanguages; Languages mLanguages;
}; };

View File

@ -51,7 +51,9 @@
#include "projectmakefilewidget.h" #include "projectmakefilewidget.h"
#include "projectdllhostwidget.h" #include "projectdllhostwidget.h"
#include "toolsgeneralwidget.h" #include "toolsgeneralwidget.h"
#ifdef ENABLE_VCS
#include "toolsgitwidget.h" #include "toolsgitwidget.h"
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include "environmentfileassociationwidget.h" #include "environmentfileassociationwidget.h"
#include "projectversioninfowidget.h" #include "projectversioninfowidget.h"
@ -233,9 +235,10 @@ PSettingsDialog SettingsDialog::optionDialog()
widget = new ToolsGeneralWidget(tr("General"),tr("Tools")); widget = new ToolsGeneralWidget(tr("General"),tr("Tools"));
dialog->addWidget(widget); dialog->addWidget(widget);
#ifdef ENABLE_VCS
widget = new ToolsGitWidget(tr("Git"),tr("Tools")); widget = new ToolsGitWidget(tr("Git"),tr("Tools"));
dialog->addWidget(widget); dialog->addWidget(widget);
#endif
dialog->selectFirstWidget(); dialog->selectFirstWidget();

View File

@ -1,4 +1,6 @@
#ifdef ENABLE_VCS
#include "gitmanager.h" #include "gitmanager.h"
#endif
#include "../utils.h" #include "../utils.h"
#include "../settings.h" #include "../settings.h"

View File

@ -15,8 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "customfilesystemmodel.h" #include "customfilesystemmodel.h"
#include "../vcs/gitmanager.h"
#include "../vcs/gitrepository.h"
CustomFileSystemModel::CustomFileSystemModel(QObject *parent) : QFileSystemModel(parent) CustomFileSystemModel::CustomFileSystemModel(QObject *parent) : QFileSystemModel(parent)
{ {

View File

@ -20,8 +20,6 @@
#include <QFileSystemModel> #include <QFileSystemModel>
#include <QTimer> #include <QTimer>
class GitRepository;
class GitManager;
class CustomFileSystemModel : public QFileSystemModel class CustomFileSystemModel : public QFileSystemModel
{ {
Q_OBJECT Q_OBJECT