initial work
- settings for git execute path - a git manager
This commit is contained in:
parent
cc43ac245a
commit
18d5a6c1ab
|
@ -84,11 +84,13 @@ 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 \
|
||||||
thememanager.cpp \
|
thememanager.cpp \
|
||||||
todoparser.cpp \
|
todoparser.cpp \
|
||||||
toolsmanager.cpp \
|
toolsmanager.cpp \
|
||||||
|
vcs/gitmanager.cpp \
|
||||||
widgets/aboutdialog.cpp \
|
widgets/aboutdialog.cpp \
|
||||||
widgets/bookmarkmodel.cpp \
|
widgets/bookmarkmodel.cpp \
|
||||||
widgets/classbrowser.cpp \
|
widgets/classbrowser.cpp \
|
||||||
|
@ -210,11 +212,13 @@ 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 \
|
||||||
thememanager.h \
|
thememanager.h \
|
||||||
todoparser.h \
|
todoparser.h \
|
||||||
toolsmanager.h \
|
toolsmanager.h \
|
||||||
|
vcs/gitmanager.h \
|
||||||
widgets/aboutdialog.h \
|
widgets/aboutdialog.h \
|
||||||
widgets/bookmarkmodel.h \
|
widgets/bookmarkmodel.h \
|
||||||
widgets/classbrowser.h \
|
widgets/classbrowser.h \
|
||||||
|
@ -306,6 +310,7 @@ FORMS += \
|
||||||
settingsdialog/projectoutputwidget.ui \
|
settingsdialog/projectoutputwidget.ui \
|
||||||
settingsdialog/projectprecompilewidget.ui \
|
settingsdialog/projectprecompilewidget.ui \
|
||||||
settingsdialog/toolsgeneralwidget.ui \
|
settingsdialog/toolsgeneralwidget.ui \
|
||||||
|
settingsdialog/toolsgitwidget.ui \
|
||||||
widgets/aboutdialog.ui \
|
widgets/aboutdialog.ui \
|
||||||
widgets/cpudialog.ui \
|
widgets/cpudialog.ui \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
|
@ -420,7 +425,7 @@ theme_files.files += $$files(themes/*.png, false)
|
||||||
colorscheme_files.files += $$files(colorschemes/*.scheme, false)
|
colorscheme_files.files += $$files(colorschemes/*.scheme, false)
|
||||||
colorscheme_files.prefix = /colorschemes
|
colorscheme_files.prefix = /colorschemes
|
||||||
|
|
||||||
RESOURCES += qmake_qm_files
|
#RESOURCES += qmake_qm_files
|
||||||
RESOURCES += iconsets_files
|
#RESOURCES += iconsets_files
|
||||||
RESOURCES += theme_files
|
#RESOURCES += theme_files
|
||||||
RESOURCES += colorscheme_files
|
#RESOURCES += colorscheme_files
|
||||||
|
|
|
@ -46,7 +46,8 @@ Settings::Settings(const QString &filename):
|
||||||
mCodeCompletion(this),
|
mCodeCompletion(this),
|
||||||
mCodeFormatter(this),
|
mCodeFormatter(this),
|
||||||
mHistory(this),
|
mHistory(this),
|
||||||
mUI(this)
|
mUI(this),
|
||||||
|
mVCS(this)
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
@ -106,6 +107,8 @@ void Settings::load()
|
||||||
mCodeFormatter.load();
|
mCodeFormatter.load();
|
||||||
mUI.load();
|
mUI.load();
|
||||||
mDirs.load();
|
mDirs.load();
|
||||||
|
mVCS.load();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::Dirs &Settings::dirs()
|
Settings::Dirs &Settings::dirs()
|
||||||
|
@ -153,6 +156,11 @@ Settings::UI &Settings::ui()
|
||||||
return mUI;
|
return mUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::VCS &Settings::vcs()
|
||||||
|
{
|
||||||
|
return mVCS;
|
||||||
|
}
|
||||||
|
|
||||||
Settings::History& Settings::history()
|
Settings::History& Settings::history()
|
||||||
{
|
{
|
||||||
return mHistory;
|
return mHistory;
|
||||||
|
@ -5074,3 +5082,28 @@ void Settings::UI::doLoad()
|
||||||
mNewHeaderDialogWidth = intValue("new_header_dialog_width", 642*qApp->desktop()->width()/1920);
|
mNewHeaderDialogWidth = intValue("new_header_dialog_width", 642*qApp->desktop()->width()/1920);
|
||||||
mNewHeaderDialogHeight = intValue("new_header_dialog_height", 300*qApp->desktop()->height()/1080);
|
mNewHeaderDialogHeight = intValue("new_header_dialog_height", 300*qApp->desktop()->height()/1080);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::VCS::VCS(Settings *settings):_Base(settings,SETTING_VCS)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::VCS::doSave()
|
||||||
|
{
|
||||||
|
saveValue("git_path",mGitPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::VCS::doLoad()
|
||||||
|
{
|
||||||
|
mGitPath = stringValue("git_path", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Settings::VCS::gitPath() const
|
||||||
|
{
|
||||||
|
return mGitPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::VCS::setGitPath(const QString &newGitPath)
|
||||||
|
{
|
||||||
|
mGitPath = newGitPath;
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#define SETTING_DEBUGGER "Debugger"
|
#define SETTING_DEBUGGER "Debugger"
|
||||||
#define SETTING_HISTORY "History"
|
#define SETTING_HISTORY "History"
|
||||||
#define SETTING_UI "UI"
|
#define SETTING_UI "UI"
|
||||||
|
#define SETTING_VCS "VCS"
|
||||||
#define SETTING_CODE_COMPLETION "CodeCompletion"
|
#define SETTING_CODE_COMPLETION "CodeCompletion"
|
||||||
#define SETTING_CODE_FORMATTER "CodeFormatter"
|
#define SETTING_CODE_FORMATTER "CodeFormatter"
|
||||||
#define SETTING_COMPILTER_SETS "CompilerSets"
|
#define SETTING_COMPILTER_SETS "CompilerSets"
|
||||||
|
@ -881,6 +882,18 @@ public:
|
||||||
void doLoad() override;
|
void doLoad() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VCS: public _Base {
|
||||||
|
public:
|
||||||
|
explicit VCS(Settings *settings);
|
||||||
|
const QString &gitPath() const;
|
||||||
|
void setGitPath(const QString &newGitPath);
|
||||||
|
private:
|
||||||
|
QString mGitPath;
|
||||||
|
protected:
|
||||||
|
void doSave() override;
|
||||||
|
void doLoad() override;
|
||||||
|
};
|
||||||
|
|
||||||
class UI: public _Base {
|
class UI: public _Base {
|
||||||
public:
|
public:
|
||||||
explicit UI(Settings *settings);
|
explicit UI(Settings *settings);
|
||||||
|
@ -1325,6 +1338,7 @@ public:
|
||||||
CodeCompletion &codeCompletion();
|
CodeCompletion &codeCompletion();
|
||||||
CodeFormatter &codeFormatter();
|
CodeFormatter &codeFormatter();
|
||||||
UI &ui();
|
UI &ui();
|
||||||
|
VCS &vcs();
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1340,6 +1354,7 @@ private:
|
||||||
CodeFormatter mCodeFormatter;
|
CodeFormatter mCodeFormatter;
|
||||||
History mHistory;
|
History mHistory;
|
||||||
UI mUI;
|
UI mUI;
|
||||||
|
VCS mVCS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "projectmakefilewidget.h"
|
#include "projectmakefilewidget.h"
|
||||||
#include "projectdllhostwidget.h"
|
#include "projectdllhostwidget.h"
|
||||||
#include "toolsgeneralwidget.h"
|
#include "toolsgeneralwidget.h"
|
||||||
|
#include "toolsgitwidget.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "environmentfileassociationwidget.h"
|
#include "environmentfileassociationwidget.h"
|
||||||
#include "projectversioninfowidget.h"
|
#include "projectversioninfowidget.h"
|
||||||
|
@ -219,6 +220,10 @@ PSettingsDialog SettingsDialog::optionDialog()
|
||||||
widget = new ToolsGeneralWidget(tr("General"),tr("Tools"));
|
widget = new ToolsGeneralWidget(tr("General"),tr("Tools"));
|
||||||
dialog->addWidget(widget);
|
dialog->addWidget(widget);
|
||||||
|
|
||||||
|
widget = new ToolsGitWidget(tr("Git"),tr("Tools"));
|
||||||
|
dialog->addWidget(widget);
|
||||||
|
|
||||||
|
|
||||||
dialog->selectFirstWidget();
|
dialog->selectFirstWidget();
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include "toolsgitwidget.h"
|
||||||
|
#include "ui_toolsgitwidget.h"
|
||||||
|
#include "../iconsmanager.h"
|
||||||
|
#include "../settings.h"
|
||||||
|
#include "../systemconsts.h"
|
||||||
|
#include "../utils.h"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
ToolsGitWidget::ToolsGitWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||||
|
SettingsWidget(name,group,parent),
|
||||||
|
ui(new Ui::ToolsGitWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->lblGitInfo->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolsGitWidget::~ToolsGitWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGitWidget::doLoad()
|
||||||
|
{
|
||||||
|
ui->txtGitPath->setText(pSettings->vcs().gitPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGitWidget::doSave()
|
||||||
|
{
|
||||||
|
pSettings->vcs().setGitPath(ui->txtGitPath->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGitWidget::updateIcons(const QSize &size)
|
||||||
|
{
|
||||||
|
pIconsManager->setIcon(ui->btnBrowseGit,IconsManager::ACTION_FILE_OPEN_FOLDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsGitWidget::on_btnBrowseGit_clicked()
|
||||||
|
{
|
||||||
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr("Git Executable"),
|
||||||
|
QString(),
|
||||||
|
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
||||||
|
if (!filename.isEmpty() && fileExists(filename)) {
|
||||||
|
ui->txtGitPath->setText(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ToolsGitWidget::on_btnTestGit_clicked()
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo(ui->txtGitPath->text());
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
|
ui->lblGitInfo->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ui->lblGitInfo->setVisible(true);
|
||||||
|
ui->lblGitInfo->setText("");
|
||||||
|
QStringList args;
|
||||||
|
args.append("--version");
|
||||||
|
QString output = runAndGetOutput(
|
||||||
|
fileInfo.fileName(),
|
||||||
|
fileInfo.absolutePath(),
|
||||||
|
args);
|
||||||
|
ui->lblGitInfo->setText(output);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef TOOLSGITWIDGET_H
|
||||||
|
#define TOOLSGITWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "settingswidget.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ToolsGitWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ToolsGitWidget : public SettingsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ToolsGitWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
||||||
|
~ToolsGitWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ToolsGitWidget *ui;
|
||||||
|
|
||||||
|
// SettingsWidget interface
|
||||||
|
protected:
|
||||||
|
void doLoad() override;
|
||||||
|
void doSave() override;
|
||||||
|
void updateIcons(const QSize &size) override;
|
||||||
|
private slots:
|
||||||
|
void on_btnBrowseGit_clicked();
|
||||||
|
void on_btnTestGit_clicked();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOOLSGITWIDGET_H
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ToolsGitWidget</class>
|
||||||
|
<widget class="QWidget" name="ToolsGitWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>555</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QPushButton" name="btnTestGit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Test</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="btnBrowseGit">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Browse</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="txtGitPath"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" 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="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Path to Git Executable:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="4">
|
||||||
|
<widget class="QLabel" name="lblGitInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../icons.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "gitmanager.h"
|
||||||
|
|
||||||
|
GitManager::GitManager(QObject *parent) : QObject(parent),
|
||||||
|
mGitPathValid(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::gitPathValid() const
|
||||||
|
{
|
||||||
|
return mGitPathValid;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef GITMANAGER_H
|
||||||
|
#define GITMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class GitManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit GitManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
bool gitPathValid() const;
|
||||||
|
bool createRepository(const QString& folder);
|
||||||
|
bool hasRepository(const QString& folder);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
private:
|
||||||
|
void validate();
|
||||||
|
private:
|
||||||
|
QString mGitPath;
|
||||||
|
bool mGitPathValid;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GITMANAGER_H
|
Loading…
Reference in New Issue