diff options
author | hjk <hjk@qt.io> | 2022-09-06 13:02:22 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-09-07 11:12:09 +0000 |
commit | 702617dbba3034f2f45f7f23cf85303be77a77f4 (patch) | |
tree | c3b000e138c929ad67a4a05dfc3d85d1224fb35b | |
parent | fc61bd0f8576fc307bda8728f3a6efe3b9930b33 (diff) |
Bazaar: Inline pullorpushdialog.ui
Change-Id: Id7c90ac081dd63922c6289e5bc5233c588d982d6
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
-rw-r--r-- | src/plugins/bazaar/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/plugins/bazaar/bazaar.qbs | 1 | ||||
-rw-r--r-- | src/plugins/bazaar/pullorpushdialog.cpp | 147 | ||||
-rw-r--r-- | src/plugins/bazaar/pullorpushdialog.h | 29 | ||||
-rw-r--r-- | src/plugins/bazaar/pullorpushdialog.ui | 290 |
5 files changed, 129 insertions, 340 deletions
diff --git a/src/plugins/bazaar/CMakeLists.txt b/src/plugins/bazaar/CMakeLists.txt index ac4bcd4ffe..80bea018db 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 b7413b2e7c..85034d43bd 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 4dcfddff2e..2713474248 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 <utils/qtcassert.h> +#include <utils/layoutbuilder.h> -using namespace Bazaar::Internal; +#include <QApplication> +#include <QCheckBox> +#include <QDialogButtonBox> +#include <QLabel> +#include <QLineEdit> +#include <QRadioButton> -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(); -} -PullOrPushDialog::~PullOrPushDialog() -{ - delete m_ui; + 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() = 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 bae40616e9..a385ff00f9 100644 --- a/src/plugins/bazaar/pullorpushdialog.h +++ b/src/plugins/bazaar/pullorpushdialog.h @@ -5,10 +5,15 @@ #include <QDialog> -namespace Bazaar { -namespace Internal { +#include <utils/pathchooser.h> -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 8a2f6b7282..0000000000 --- a/src/plugins/bazaar/pullorpushdialog.ui +++ /dev/null @@ -1,290 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Bazaar::Internal::PullOrPushDialog</class> - <widget class="QDialog" name="Bazaar::Internal::PullOrPushDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>477</width> - <height>388</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Branch Location</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QRadioButton" name="defaultButton"> - <property name="text"> - <string>Default location</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="localButton"> - <property name="text"> - <string>Local filesystem:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="Utils::PathChooser" name="localPathChooser"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QRadioButton" name="urlButton"> - <property name="toolTip"> - <string>For example: 'https://[user[:pass]@]host[:port]/[path]'.</string> - </property> - <property name="text"> - <string>Specify URL:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="urlLineEdit"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="toolTip"> - <string>For example: 'https://[user[:pass]@]host[:port]/[path]'.</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Options</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="rememberCheckBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Remember specified location as default</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QCheckBox" name="overwriteCheckBox"> - <property name="toolTip"> - <string>Ignores differences between branches and overwrites -unconditionally.</string> - </property> - <property name="text"> - <string>Overwrite</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="useExistingDirCheckBox"> - <property name="toolTip"> - <string>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.</string> - </property> - <property name="text"> - <string>Use existing directory</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QCheckBox" name="createPrefixCheckBox"> - <property name="toolTip"> - <string>Creates the path leading up to the branch if it does not already exist.</string> - </property> - <property name="text"> - <string>Create prefix</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Revision:</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="revisionLineEdit"/> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QCheckBox" name="localCheckBox"> - <property name="toolTip"> - <string>Performs a local pull in a bound branch. -Local pulls are not applied to the master branch.</string> - </property> - <property name="text"> - <string>Local</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>4</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - <slots> - <signal>editingFinished()</signal> - <signal>browsingFinished()</signal> - </slots> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>defaultButton</tabstop> - <tabstop>localButton</tabstop> - <tabstop>urlButton</tabstop> - <tabstop>urlLineEdit</tabstop> - <tabstop>rememberCheckBox</tabstop> - <tabstop>overwriteCheckBox</tabstop> - <tabstop>localCheckBox</tabstop> - <tabstop>useExistingDirCheckBox</tabstop> - <tabstop>createPrefixCheckBox</tabstop> - <tabstop>revisionLineEdit</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>Bazaar::Internal::PullOrPushDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>257</x> - <y>177</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>Bazaar::Internal::PullOrPushDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>325</x> - <y>177</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>urlButton</sender> - <signal>toggled(bool)</signal> - <receiver>urlLineEdit</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>80</x> - <y>121</y> - </hint> - <hint type="destinationlabel"> - <x>332</x> - <y>123</y> - </hint> - </hints> - </connection> - <connection> - <sender>localButton</sender> - <signal>toggled(bool)</signal> - <receiver>localPathChooser</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>112</x> - <y>81</y> - </hint> - <hint type="destinationlabel"> - <x>346</x> - <y>81</y> - </hint> - </hints> - </connection> - <connection> - <sender>urlButton</sender> - <signal>toggled(bool)</signal> - <receiver>rememberCheckBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>71</x> - <y>92</y> - </hint> - <hint type="destinationlabel"> - <x>163</x> - <y>153</y> - </hint> - </hints> - </connection> - <connection> - <sender>localButton</sender> - <signal>toggled(bool)</signal> - <receiver>rememberCheckBox</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>71</x> - <y>67</y> - </hint> - <hint type="destinationlabel"> - <x>163</x> - <y>153</y> - </hint> - </hints> - </connection> - </connections> -</ui> |