diff --git a/src/plugins/git/CMakeLists.txt b/src/plugins/git/CMakeLists.txt index 3aaee139c2d..6f23999babf 100644 --- a/src/plugins/git/CMakeLists.txt +++ b/src/plugins/git/CMakeLists.txt @@ -2,7 +2,7 @@ add_qtc_plugin(Git PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase SOURCES annotationhighlighter.cpp annotationhighlighter.h - branchadddialog.cpp branchadddialog.h branchadddialog.ui + branchadddialog.cpp branchadddialog.h branchcheckoutdialog.cpp branchcheckoutdialog.h branchcheckoutdialog.ui branchmodel.cpp branchmodel.h branchview.cpp branchview.h diff --git a/src/plugins/git/branchadddialog.cpp b/src/plugins/git/branchadddialog.cpp index ab7a3e11999..010ee9a8494 100644 --- a/src/plugins/git/branchadddialog.cpp +++ b/src/plugins/git/branchadddialog.cpp @@ -24,13 +24,19 @@ ****************************************************************************/ #include "branchadddialog.h" + #include "branchmodel.h" -#include "ui_branchadddialog.h" #include "gitplugin.h" #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -106,11 +112,22 @@ QWidget *BranchValidationDelegate::createEditor(QWidget *parent, } BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QWidget *parent) : - QDialog(parent), - m_ui(new Ui::BranchAddDialog) + QDialog(parent) { - m_ui->setupUi(this); - m_ui->trackingCheckBox->setVisible(false); + resize(590, 138); + + auto branchNameLabel = new QLabel(tr("Branch Name:")); + + m_branchNameEdit = new QLineEdit(this); + m_branchNameEdit->setValidator(new BranchNameValidator(localBranches, this)); + + m_checkoutCheckBox = new QCheckBox(tr("Checkout new branch")); + + m_trackingCheckBox = new QCheckBox(this); + m_trackingCheckBox->setVisible(false); + + m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + setCheckoutVisible(false); switch (type) { @@ -122,67 +139,75 @@ BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QW break; case BranchAddDialog::AddTag: setWindowTitle(tr("Add Tag")); - m_ui->branchNameLabel->setText(tr("Tag name:")); + branchNameLabel->setText(tr("Tag name:")); break; case BranchAddDialog::RenameTag: setWindowTitle(tr("Rename Tag")); - m_ui->branchNameLabel->setText(tr("Tag name:")); + branchNameLabel->setText(tr("Tag name:")); break; } - m_ui->branchNameEdit->setValidator(new BranchNameValidator(localBranches, this)); - connect(m_ui->branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus); + using namespace Utils::Layouting; + + Column { + Row { branchNameLabel, m_branchNameEdit }, + m_checkoutCheckBox, + m_trackingCheckBox, + st, + m_buttonBox + }.attachTo(this); + + connect(m_branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus); + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } -BranchAddDialog::~BranchAddDialog() -{ - delete m_ui; -} +BranchAddDialog::~BranchAddDialog() = default; void BranchAddDialog::setBranchName(const QString &n) { - m_ui->branchNameEdit->setText(n); - m_ui->branchNameEdit->selectAll(); + m_branchNameEdit->setText(n); + m_branchNameEdit->selectAll(); } QString BranchAddDialog::branchName() const { - return m_ui->branchNameEdit->text(); + return m_branchNameEdit->text(); } void BranchAddDialog::setTrackedBranchName(const QString &name, bool remote) { if (name.isEmpty()) { - m_ui->trackingCheckBox->setVisible(false); - m_ui->trackingCheckBox->setChecked(false); + m_trackingCheckBox->setVisible(false); + m_trackingCheckBox->setChecked(false); } else { - m_ui->trackingCheckBox->setText(remote ? tr("Track remote branch \"%1\"").arg(name) : - tr("Track local branch \"%1\"").arg(name)); - m_ui->trackingCheckBox->setVisible(true); - m_ui->trackingCheckBox->setChecked(remote); + m_trackingCheckBox->setText(remote ? tr("Track remote branch \"%1\"").arg(name) + : tr("Track local branch \"%1\"").arg(name)); + m_trackingCheckBox->setVisible(true); + m_trackingCheckBox->setChecked(remote); } } bool BranchAddDialog::track() const { - return m_ui->trackingCheckBox->isChecked(); + return m_trackingCheckBox->isChecked(); } void BranchAddDialog::setCheckoutVisible(bool visible) { - m_ui->checkoutCheckBox->setVisible(visible); - m_ui->checkoutCheckBox->setChecked(visible); + m_checkoutCheckBox->setVisible(visible); + m_checkoutCheckBox->setChecked(visible); } bool BranchAddDialog::checkout() const { - return m_ui->checkoutCheckBox->isChecked(); + return m_checkoutCheckBox->isChecked(); } /*! Updates the ok button enabled state of the dialog according to the validity of the branch name. */ void BranchAddDialog::updateButtonStatus() { - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_ui->branchNameEdit->hasAcceptableInput()); + m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_branchNameEdit->hasAcceptableInput()); } } // namespace Internal diff --git a/src/plugins/git/branchadddialog.h b/src/plugins/git/branchadddialog.h index fa2100bf2c4..3ee35659ff5 100644 --- a/src/plugins/git/branchadddialog.h +++ b/src/plugins/git/branchadddialog.h @@ -28,13 +28,17 @@ #include #include +QT_BEGIN_NAMESPACE +class QCheckBox; +class QDialogButtonBox; +class QLineEdit; +QT_BEGIN_NAMESPACE + namespace Git { namespace Internal { class BranchModel; -namespace Ui { class BranchAddDialog; } - class BranchValidationDelegate : public QItemDelegate { public: @@ -74,7 +78,10 @@ public: private: void updateButtonStatus(); - Ui::BranchAddDialog *m_ui; + QLineEdit *m_branchNameEdit; + QCheckBox *m_checkoutCheckBox; + QCheckBox *m_trackingCheckBox; + QDialogButtonBox *m_buttonBox; }; } // namespace Internal diff --git a/src/plugins/git/branchadddialog.ui b/src/plugins/git/branchadddialog.ui deleted file mode 100644 index 2650f3b5437..00000000000 --- a/src/plugins/git/branchadddialog.ui +++ /dev/null @@ -1,97 +0,0 @@ - - - Git::Internal::BranchAddDialog - - - - 0 - 0 - 590 - 138 - - - - - - - - - - Branch Name: - - - - - - - - - - Checkout new branch - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - buttonBox - accepted() - Git::Internal::BranchAddDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Git::Internal::BranchAddDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/git/git.qbs b/src/plugins/git/git.qbs index 971ee7ad2fb..076334e9145 100644 --- a/src/plugins/git/git.qbs +++ b/src/plugins/git/git.qbs @@ -18,7 +18,6 @@ QtcPlugin { "annotationhighlighter.h", "branchadddialog.cpp", "branchadddialog.h", - "branchadddialog.ui", "branchcheckoutdialog.cpp", "branchcheckoutdialog.h", "branchcheckoutdialog.ui",