2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 Hugues Delorme
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2016-01-15 14:57:40 +01:00
|
|
|
|
2011-02-28 13:40:06 +01:00
|
|
|
#include "pullorpushdialog.h"
|
|
|
|
|
|
2012-01-12 11:32:45 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2022-09-06 13:02:22 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2022-09-06 13:02:22 +02:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QRadioButton>
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2022-09-06 13:02:22 +02:00
|
|
|
namespace Bazaar::Internal {
|
|
|
|
|
|
|
|
|
|
PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent)
|
|
|
|
|
: QDialog(parent), m_mode(mode)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
2022-09-06 13:02:22 +02:00
|
|
|
resize(477, 388);
|
|
|
|
|
|
|
|
|
|
setWindowTitle(tr("Dialog"));
|
|
|
|
|
|
|
|
|
|
m_defaultButton = new QRadioButton(tr("Default location"));
|
|
|
|
|
m_defaultButton->setChecked(true);
|
|
|
|
|
|
|
|
|
|
m_localButton = new QRadioButton(tr("Local filesystem:"));
|
|
|
|
|
|
|
|
|
|
m_localPathChooser = new Utils::PathChooser;
|
|
|
|
|
m_localPathChooser->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
auto urlButton = new QRadioButton(tr("Specify URL:"));
|
|
|
|
|
urlButton->setToolTip(tr("For example: 'https://[user[:pass]@]host[:port]/[path]'."));
|
|
|
|
|
|
|
|
|
|
m_urlLineEdit = new QLineEdit;
|
|
|
|
|
m_urlLineEdit->setEnabled(false);
|
|
|
|
|
m_urlLineEdit->setToolTip(tr("For example: 'https://[user[:pass]@]host[:port]/[path]'."));
|
|
|
|
|
|
|
|
|
|
m_rememberCheckBox = new QCheckBox(tr("Remember specified location as default"));
|
|
|
|
|
m_rememberCheckBox->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
m_overwriteCheckBox = new QCheckBox(tr("Overwrite"));
|
|
|
|
|
m_overwriteCheckBox->setToolTip(tr("Ignores differences between branches and overwrites\n"
|
|
|
|
|
"unconditionally."));
|
|
|
|
|
|
|
|
|
|
m_useExistingDirCheckBox = new QCheckBox(tr("Use existing directory"));
|
|
|
|
|
m_useExistingDirCheckBox->setToolTip(tr("By default, push will fail if the target directory "
|
|
|
|
|
"exists, but does not already have a control directory.\n"
|
|
|
|
|
"This flag will allow push to proceed."));
|
|
|
|
|
|
|
|
|
|
m_createPrefixCheckBox = new QCheckBox(tr("Create prefix"));
|
|
|
|
|
m_createPrefixCheckBox->setToolTip(tr("Creates the path leading up to the branch "
|
|
|
|
|
"if it does not already exist."));
|
|
|
|
|
|
|
|
|
|
m_revisionLineEdit = new QLineEdit;
|
|
|
|
|
|
|
|
|
|
m_localCheckBox = new QCheckBox(tr("Local"));
|
|
|
|
|
m_localCheckBox->setToolTip(tr("Performs a local pull in a bound branch.\n"
|
|
|
|
|
"Local pulls are not applied to the master branch."));
|
|
|
|
|
|
|
|
|
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
|
|
|
|
|
m_localPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
2011-02-28 15:05:40 +01:00
|
|
|
if (m_mode == PullMode) {
|
2022-09-06 13:02:22 +02:00
|
|
|
setWindowTitle(tr("Pull Source"));
|
|
|
|
|
m_useExistingDirCheckBox->setVisible(false);
|
|
|
|
|
m_createPrefixCheckBox->setVisible(false);
|
2011-02-28 15:05:40 +01:00
|
|
|
} else {
|
2022-09-06 13:02:22 +02:00
|
|
|
setWindowTitle(tr("Push Destination"));
|
|
|
|
|
m_localCheckBox->setVisible(false);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-09-06 13:02:22 +02:00
|
|
|
using namespace Utils::Layouting;
|
|
|
|
|
Column {
|
|
|
|
|
Group {
|
|
|
|
|
title(tr("Branch Location")),
|
|
|
|
|
Form {
|
|
|
|
|
m_defaultButton, br,
|
|
|
|
|
m_localButton, m_localPathChooser, br,
|
|
|
|
|
urlButton, m_urlLineEdit, br,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Group {
|
|
|
|
|
title(tr("Options")),
|
|
|
|
|
Column {
|
|
|
|
|
m_rememberCheckBox,
|
|
|
|
|
m_overwriteCheckBox,
|
|
|
|
|
m_localCheckBox,
|
|
|
|
|
m_useExistingDirCheckBox,
|
|
|
|
|
m_createPrefixCheckBox,
|
|
|
|
|
Row { tr("Revision:"), m_revisionLineEdit },
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
buttonBox,
|
|
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
setFixedHeight(sizeHint().height());
|
|
|
|
|
setSizeGripEnabled(true);
|
|
|
|
|
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
connect(urlButton, &QRadioButton::toggled, m_urlLineEdit, &QWidget::setEnabled);
|
|
|
|
|
connect(m_localButton, &QAbstractButton::toggled, m_localPathChooser, &QWidget::setEnabled);
|
|
|
|
|
connect(urlButton, &QRadioButton::toggled, m_rememberCheckBox, &QWidget::setEnabled);
|
|
|
|
|
connect(m_localButton, &QRadioButton::toggled, m_rememberCheckBox, &QWidget::setEnabled);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-09-06 13:02:22 +02:00
|
|
|
PullOrPushDialog::~PullOrPushDialog() = default;
|
|
|
|
|
|
2011-02-28 13:40:06 +01:00
|
|
|
QString PullOrPushDialog::branchLocation() const
|
|
|
|
|
{
|
2022-09-06 13:02:22 +02:00
|
|
|
if (m_defaultButton->isChecked())
|
2011-02-28 13:40:06 +01:00
|
|
|
return QString();
|
2022-09-06 13:02:22 +02:00
|
|
|
if (m_localButton->isChecked())
|
|
|
|
|
return m_localPathChooser->filePath().toString();
|
|
|
|
|
return m_urlLineEdit->text();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PullOrPushDialog::isRememberOptionEnabled() const
|
|
|
|
|
{
|
2022-09-06 13:02:22 +02:00
|
|
|
if (m_defaultButton->isChecked())
|
2011-02-28 13:40:06 +01:00
|
|
|
return false;
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_rememberCheckBox->isChecked();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PullOrPushDialog::isOverwriteOptionEnabled() const
|
|
|
|
|
{
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_overwriteCheckBox->isChecked();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString PullOrPushDialog::revision() const
|
|
|
|
|
{
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_revisionLineEdit->text().simplified();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PullOrPushDialog::isLocalOptionEnabled() const
|
|
|
|
|
{
|
2012-01-12 11:32:45 +01:00
|
|
|
QTC_ASSERT(m_mode == PullMode, return false);
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_localCheckBox->isChecked();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PullOrPushDialog::isUseExistingDirectoryOptionEnabled() const
|
|
|
|
|
{
|
2012-01-12 11:32:45 +01:00
|
|
|
QTC_ASSERT(m_mode == PushMode, return false);
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_useExistingDirCheckBox->isChecked();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PullOrPushDialog::isCreatePrefixOptionEnabled() const
|
|
|
|
|
{
|
2012-01-12 11:32:45 +01:00
|
|
|
QTC_ASSERT(m_mode == PushMode, return false);
|
2022-09-06 13:02:22 +02:00
|
|
|
return m_createPrefixCheckBox->isChecked();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-09-06 13:02:22 +02:00
|
|
|
|
|
|
|
|
} // Bazaar::Internal
|