diff --git a/src/plugins/bazaar/CMakeLists.txt b/src/plugins/bazaar/CMakeLists.txt index ac4bcd4ffe3..80bea018dbf 100644 --- a/src/plugins/bazaar/CMakeLists.txt +++ b/src/plugins/bazaar/CMakeLists.txt @@ -11,7 +11,7 @@ add_qtc_plugin(Bazaar branchinfo.cpp branchinfo.h commiteditor.cpp commiteditor.h constants.h - pullorpushdialog.cpp pullorpushdialog.h pullorpushdialog.ui + pullorpushdialog.cpp pullorpushdialog.h revertdialog.ui uncommitdialog.ui ) diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs index b7413b2e7c2..85034d43bdf 100644 --- a/src/plugins/bazaar/bazaar.qbs +++ b/src/plugins/bazaar/bazaar.qbs @@ -31,7 +31,6 @@ QtcPlugin { "constants.h", "pullorpushdialog.cpp", "pullorpushdialog.h", - "pullorpushdialog.ui", "revertdialog.ui", "uncommitdialog.ui", ] diff --git a/src/plugins/bazaar/pullorpushdialog.cpp b/src/plugins/bazaar/pullorpushdialog.cpp index 4dcfddff2e5..2713474248f 100644 --- a/src/plugins/bazaar/pullorpushdialog.cpp +++ b/src/plugins/bazaar/pullorpushdialog.cpp @@ -2,86 +2,155 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "pullorpushdialog.h" -#include "ui_pullorpushdialog.h" #include +#include -using namespace Bazaar::Internal; +#include +#include +#include +#include +#include +#include -PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent) : QDialog(parent), - m_mode(mode), - m_ui(new Ui::PullOrPushDialog) +namespace Bazaar::Internal { + +PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent) + : QDialog(parent), m_mode(mode) { - m_ui->setupUi(this); - m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::Directory); + 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); if (m_mode == PullMode) { - this->setWindowTitle(tr("Pull Source")); - m_ui->useExistingDirCheckBox->setVisible(false); - m_ui->createPrefixCheckBox->setVisible(false); + setWindowTitle(tr("Pull Source")); + m_useExistingDirCheckBox->setVisible(false); + m_createPrefixCheckBox->setVisible(false); } else { - this->setWindowTitle(tr("Push Destination")); - m_ui->localCheckBox->setVisible(false); + setWindowTitle(tr("Push Destination")); + m_localCheckBox->setVisible(false); } - this->adjustSize(); + + 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); } -PullOrPushDialog::~PullOrPushDialog() -{ - delete m_ui; -} +PullOrPushDialog::~PullOrPushDialog() = default; QString PullOrPushDialog::branchLocation() const { - if (m_ui->defaultButton->isChecked()) + if (m_defaultButton->isChecked()) return QString(); - if (m_ui->localButton->isChecked()) - return m_ui->localPathChooser->filePath().toString(); - return m_ui->urlLineEdit->text(); + if (m_localButton->isChecked()) + return m_localPathChooser->filePath().toString(); + return m_urlLineEdit->text(); } bool PullOrPushDialog::isRememberOptionEnabled() const { - if (m_ui->defaultButton->isChecked()) + if (m_defaultButton->isChecked()) return false; - return m_ui->rememberCheckBox->isChecked(); + return m_rememberCheckBox->isChecked(); } bool PullOrPushDialog::isOverwriteOptionEnabled() const { - return m_ui->overwriteCheckBox->isChecked(); + return m_overwriteCheckBox->isChecked(); } QString PullOrPushDialog::revision() const { - return m_ui->revisionLineEdit->text().simplified(); + return m_revisionLineEdit->text().simplified(); } bool PullOrPushDialog::isLocalOptionEnabled() const { QTC_ASSERT(m_mode == PullMode, return false); - return m_ui->localCheckBox->isChecked(); + return m_localCheckBox->isChecked(); } bool PullOrPushDialog::isUseExistingDirectoryOptionEnabled() const { QTC_ASSERT(m_mode == PushMode, return false); - return m_ui->useExistingDirCheckBox->isChecked(); + return m_useExistingDirCheckBox->isChecked(); } bool PullOrPushDialog::isCreatePrefixOptionEnabled() const { QTC_ASSERT(m_mode == PushMode, return false); - return m_ui->createPrefixCheckBox->isChecked(); + return m_createPrefixCheckBox->isChecked(); } -void PullOrPushDialog::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - m_ui->retranslateUi(this); - break; - default: - break; - } -} + +} // Bazaar::Internal diff --git a/src/plugins/bazaar/pullorpushdialog.h b/src/plugins/bazaar/pullorpushdialog.h index bae40616e9d..a385ff00f94 100644 --- a/src/plugins/bazaar/pullorpushdialog.h +++ b/src/plugins/bazaar/pullorpushdialog.h @@ -5,10 +5,15 @@ #include -namespace Bazaar { -namespace Internal { +#include -namespace Ui { class PullOrPushDialog; } +QT_BEGIN_NAMESPACE +class QCheckBox; +class QLineEdit; +class QRadioButton; +QT_END_NAMESPACE + +namespace Bazaar::Internal { class PullOrPushDialog : public QDialog { @@ -36,13 +41,19 @@ public: bool isUseExistingDirectoryOptionEnabled() const; bool isCreatePrefixOptionEnabled() const; -protected: - void changeEvent(QEvent *e) override; - private: Mode m_mode; - Ui::PullOrPushDialog *m_ui; + + QRadioButton *m_defaultButton; + QRadioButton *m_localButton; + Utils::PathChooser *m_localPathChooser; + QLineEdit *m_urlLineEdit; + QCheckBox *m_rememberCheckBox; + QCheckBox *m_overwriteCheckBox; + QCheckBox *m_useExistingDirCheckBox; + QCheckBox *m_createPrefixCheckBox; + QLineEdit *m_revisionLineEdit; + QCheckBox *m_localCheckBox; }; -} // namespace Internal -} // namespace Bazaar +} // Bazaar::Internal diff --git a/src/plugins/bazaar/pullorpushdialog.ui b/src/plugins/bazaar/pullorpushdialog.ui deleted file mode 100644 index 8a2f6b7282f..00000000000 --- a/src/plugins/bazaar/pullorpushdialog.ui +++ /dev/null @@ -1,290 +0,0 @@ - - - Bazaar::Internal::PullOrPushDialog - - - - 0 - 0 - 477 - 388 - - - - Dialog - - - - - - Branch Location - - - - - - Default location - - - true - - - - - - - Local filesystem: - - - - - - - false - - - - - - - For example: 'https://[user[:pass]@]host[:port]/[path]'. - - - Specify URL: - - - - - - - false - - - For example: 'https://[user[:pass]@]host[:port]/[path]'. - - - - - - - - - - Options - - - - - - false - - - Remember specified location as default - - - - - - - Ignores differences between branches and overwrites -unconditionally. - - - Overwrite - - - - - - - By default, push will fail if the target directory exists, but does not already have a control directory. -This flag will allow push to proceed. - - - Use existing directory - - - - - - - Creates the path leading up to the branch if it does not already exist. - - - Create prefix - - - - - - - Revision: - - - - - - - - - - Performs a local pull in a bound branch. -Local pulls are not applied to the master branch. - - - Local - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Qt::Vertical - - - - 20 - 4 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - defaultButton - localButton - urlButton - urlLineEdit - rememberCheckBox - overwriteCheckBox - localCheckBox - useExistingDirCheckBox - createPrefixCheckBox - revisionLineEdit - - - - - buttonBox - accepted() - Bazaar::Internal::PullOrPushDialog - accept() - - - 257 - 177 - - - 157 - 274 - - - - - buttonBox - rejected() - Bazaar::Internal::PullOrPushDialog - reject() - - - 325 - 177 - - - 286 - 274 - - - - - urlButton - toggled(bool) - urlLineEdit - setEnabled(bool) - - - 80 - 121 - - - 332 - 123 - - - - - localButton - toggled(bool) - localPathChooser - setEnabled(bool) - - - 112 - 81 - - - 346 - 81 - - - - - urlButton - toggled(bool) - rememberCheckBox - setEnabled(bool) - - - 71 - 92 - - - 163 - 153 - - - - - localButton - toggled(bool) - rememberCheckBox - setEnabled(bool) - - - 71 - 67 - - - 163 - 153 - - - - -