summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2018-09-27 21:01:53 +0200
committerAndré Hartmann <aha_1980@gmx.de>2018-09-30 05:37:09 +0000
commit546956a302d7a91006460b55e699e1b832b02a3d (patch)
treeaac4d67aed94d93c7bd7364d0d731a495838d989 /src/plugins
parent017f4d7c4d6ec5b2f667ba5d0ad692e7f52ac182 (diff)
downloadqt-creator-546956a302d7a91006460b55e699e1b832b02a3d.tar.gz
Git: Allow creating a new repository from branch view
... when clicking "Add Branch" in a project that is not under git version control. The "Add Branch" serves no purpose here, so re-use it to call this (already existing) function. Done-with: Orgad Shaneh <orgad.shaneh@audiocodes.com> Change-Id: Ib23d2cbeec0598e0b6f00cbde265793cc25e6142 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/git/branchview.cpp8
-rw-r--r--src/plugins/git/gitplugin.cpp5
-rw-r--r--src/plugins/git/gitplugin.h1
3 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp
index 406304608d..4619a21e7e 100644
--- a/src/plugins/git/branchview.cpp
+++ b/src/plugins/git/branchview.cpp
@@ -67,7 +67,6 @@ BranchView::BranchView() :
m_model(new BranchModel(GitPlugin::client(), this))
{
m_addButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
- m_addButton->setToolTip(tr("Add Branch"));
m_addButton->setProperty("noArrow", true);
connect(m_addButton, &QToolButton::clicked, this, &BranchView::add);
@@ -126,10 +125,12 @@ void BranchView::refresh(const QString &repository, bool force)
m_repository = repository;
if (m_repository.isEmpty()) {
m_repositoryLabel->setText(tr("<No repository>"));
+ m_addButton->setToolTip(tr("Create Git Repository..."));
m_branchView->setEnabled(false);
} else {
m_repositoryLabel->setText(QDir::toNativeSeparators(m_repository));
m_repositoryLabel->setToolTip(GitPlugin::msgRepositoryLabel(m_repository));
+ m_addButton->setToolTip(tr("Add Branch..."));
m_branchView->setEnabled(true);
}
QString errorMessage;
@@ -252,6 +253,11 @@ QModelIndex BranchView::selectedIndex()
bool BranchView::add()
{
+ if (m_repository.isEmpty()) {
+ GitPlugin::instance()->initRepository();
+ return true;
+ }
+
QModelIndex trackedIndex = selectedIndex();
QString trackedBranch = m_model->fullName(trackedIndex);
if (trackedBranch.isEmpty()) {
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index cafcc55470..87aac67ef0 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -1319,6 +1319,11 @@ void GitPlugin::manageRemotes()
showNonModalDialog(currentState().topLevel(), m_remoteDialog);
}
+void GitPlugin::initRepository()
+{
+ createRepository();
+}
+
void GitPlugin::stashList()
{
showNonModalDialog(currentState().topLevel(), m_stashDialog);
diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h
index fde722bd4b..8722cc058d 100644
--- a/src/plugins/git/gitplugin.h
+++ b/src/plugins/git/gitplugin.h
@@ -93,6 +93,7 @@ public:
QObject *remoteCommand(const QStringList &options, const QString &workingDirectory,
const QStringList &args) override;
void manageRemotes();
+ void initRepository();
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;