diff --git a/src/plugins/fossil/CMakeLists.txt b/src/plugins/fossil/CMakeLists.txt index e2d6d39c253..fe0527a4222 100644 --- a/src/plugins/fossil/CMakeLists.txt +++ b/src/plugins/fossil/CMakeLists.txt @@ -14,7 +14,7 @@ add_qtc_plugin(Fossil fossileditor.cpp fossileditor.h fossilplugin.cpp fossilplugin.h fossilsettings.cpp fossilsettings.h - pullorpushdialog.cpp pullorpushdialog.h pullorpushdialog.ui + pullorpushdialog.cpp pullorpushdialog.h revertdialog.ui revisioninfo.h wizard/fossiljsextension.cpp wizard/fossiljsextension.h diff --git a/src/plugins/fossil/fossil.qbs b/src/plugins/fossil/fossil.qbs index bc59be722ef..b757e54dc9f 100644 --- a/src/plugins/fossil/fossil.qbs +++ b/src/plugins/fossil/fossil.qbs @@ -20,7 +20,7 @@ QtcPlugin { "fossilcommitwidget.cpp", "fossilcommitwidget.h", "fossileditor.cpp", "fossileditor.h", "annotationhighlighter.cpp", "annotationhighlighter.h", - "pullorpushdialog.cpp", "pullorpushdialog.h", "pullorpushdialog.ui", + "pullorpushdialog.cpp", "pullorpushdialog.h", "branchinfo.h", "configuredialog.cpp", "configuredialog.h", "revisioninfo.h", diff --git a/src/plugins/fossil/pullorpushdialog.cpp b/src/plugins/fossil/pullorpushdialog.cpp index 7a93f411a56..56b4813b979 100644 --- a/src/plugins/fossil/pullorpushdialog.cpp +++ b/src/plugins/fossil/pullorpushdialog.cpp @@ -2,86 +2,112 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "pullorpushdialog.h" -#include "ui_pullorpushdialog.h" #include "constants.h" +#include +#include #include +#include +#include +#include +#include + namespace Fossil { namespace Internal { -PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent) : QDialog(parent), - m_mode(mode), - m_ui(new Ui::PullOrPushDialog) +PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent) + : QDialog(parent) { - m_ui->setupUi(this); - m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::File); - m_ui->localPathChooser->setPromptDialogFilter(tr(Constants::FOSSIL_FILE_FILTER)); + setWindowTitle(mode == PullMode ? tr("Pull Source") : tr("Push Destination")); + resize(600, 0); - switch (m_mode) { - case PullMode: - this->setWindowTitle(tr("Pull Source")); - break; - case PushMode: - this->setWindowTitle(tr("Push Destination")); - break; - } + 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); + m_localPathChooser->setExpectedKind(Utils::PathChooser::File); + m_localPathChooser->setPromptDialogFilter(tr(Constants::FOSSIL_FILE_FILTER)); + + m_urlButton = new QRadioButton(tr("Specify URL:")); + m_urlButton->setToolTip(tr("For example: https://[user[:pass]@]host[:port]/[path]")); + + m_urlLineEdit = new QLineEdit; + m_urlLineEdit->setEnabled(false); + m_urlLineEdit->setToolTip(m_urlButton->toolTip()); + + m_rememberCheckBox = new QCheckBox(tr("Remember specified location as default")); + m_rememberCheckBox->setEnabled(false); + + m_privateCheckBox = new QCheckBox(tr("Include private branches")); + m_privateCheckBox->setToolTip(tr("Allow transfer of private branches.")); + + auto buttonBox = new QDialogButtonBox; + buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + using namespace Utils::Layouting; + Column { + Group { + title(tr("Remote Location")), + Form { + m_defaultButton, br, + m_localButton, m_localPathChooser, br, + m_urlButton, m_urlLineEdit, br, + }, + }, + Group { + title(tr("Options")), + Column { m_rememberCheckBox, m_privateCheckBox, }, + }, + buttonBox, + }.attachTo(this); // select URL text in line edit when clicking the radio button - m_ui->localButton->setFocusProxy(m_ui->localPathChooser); - m_ui->urlButton->setFocusProxy(m_ui->urlLineEdit); - connect(m_ui->urlButton, &QRadioButton::clicked, m_ui->urlLineEdit, &QLineEdit::selectAll); - - this->adjustSize(); -} - -PullOrPushDialog::~PullOrPushDialog() -{ - delete m_ui; + m_localButton->setFocusProxy(m_localPathChooser); + m_urlButton->setFocusProxy(m_urlLineEdit); + connect(m_urlButton, &QRadioButton::clicked, m_urlLineEdit, &QLineEdit::selectAll); + connect(m_urlButton, &QRadioButton::toggled, m_urlLineEdit, &QLineEdit::setEnabled); + connect(m_localButton, &QRadioButton::toggled, m_localPathChooser, + &Utils::PathChooser::setEnabled); + connect(m_urlButton, &QRadioButton::toggled, m_rememberCheckBox, &QCheckBox::setEnabled); + connect(m_localButton, &QRadioButton::toggled, m_rememberCheckBox, &QCheckBox::setEnabled); } QString PullOrPushDialog::remoteLocation() 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::isPrivateOptionEnabled() const { - return m_ui->privateCheckBox->isChecked(); + return m_privateCheckBox->isChecked(); } void PullOrPushDialog::setDefaultRemoteLocation(const QString &url) { - m_ui->urlLineEdit->setText(url); + m_urlLineEdit->setText(url); } void PullOrPushDialog::setLocalBaseDirectory(const QString &dir) { - m_ui->localPathChooser->setBaseDirectory(Utils::FilePath::fromString(dir)); -} - -void PullOrPushDialog::changeEvent(QEvent *e) -{ - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - m_ui->retranslateUi(this); - break; - default: - break; - } + m_localPathChooser->setBaseDirectory(Utils::FilePath::fromString(dir)); } } // namespace Internal diff --git a/src/plugins/fossil/pullorpushdialog.h b/src/plugins/fossil/pullorpushdialog.h index f578b00cf17..1d921733b69 100644 --- a/src/plugins/fossil/pullorpushdialog.h +++ b/src/plugins/fossil/pullorpushdialog.h @@ -5,11 +5,17 @@ #include +QT_BEGIN_NAMESPACE +class QCheckBox; +class QLineEdit; +class QRadioButton; +QT_END_NAMESPACE + +namespace Utils { class PathChooser; } + namespace Fossil { namespace Internal { -namespace Ui { class PullOrPushDialog; } - class PullOrPushDialog : public QDialog { Q_OBJECT @@ -21,7 +27,6 @@ public: }; explicit PullOrPushDialog(Mode mode, QWidget *parent = nullptr); - ~PullOrPushDialog() final; // Common parameters and options QString remoteLocation() const; @@ -32,12 +37,14 @@ public: // Pull-specific options // Push-specific options -protected: - void changeEvent(QEvent *e) final; - private: - Mode m_mode; - Ui::PullOrPushDialog *m_ui; + QRadioButton *m_defaultButton; + QRadioButton *m_localButton; + Utils::PathChooser *m_localPathChooser; + QRadioButton *m_urlButton; + QLineEdit *m_urlLineEdit; + QCheckBox *m_rememberCheckBox; + QCheckBox *m_privateCheckBox; }; } // namespace Internal diff --git a/src/plugins/fossil/pullorpushdialog.ui b/src/plugins/fossil/pullorpushdialog.ui deleted file mode 100644 index eec47059a67..00000000000 --- a/src/plugins/fossil/pullorpushdialog.ui +++ /dev/null @@ -1,235 +0,0 @@ - - - Fossil::Internal::PullOrPushDialog - - - - 0 - 0 - 477 - 268 - - - - Dialog - - - - - - Remote 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 - - - - - - - Allow transfer of private branches. - - - Include private branches - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Qt::Vertical - - - - 20 - 4 - - - - - - - - - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 - - editingFinished() - browsingFinished() - -
-
- - - - buttonBox - accepted() - Fossil::Internal::PullOrPushDialog - accept() - - - 257 - 177 - - - 157 - 274 - - - - - buttonBox - rejected() - Fossil::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 - - - - -