Fossil: Inline pullorpushdialog.ui

Change-Id: Idd279a2ed2cc2b14e573aae588a309ae808b008f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Alessandro Portale
2023-02-07 08:42:11 +01:00
parent 89880907f2
commit d14c561cf6
5 changed files with 89 additions and 291 deletions

View File

@@ -14,7 +14,7 @@ add_qtc_plugin(Fossil
fossileditor.cpp fossileditor.h fossileditor.cpp fossileditor.h
fossilplugin.cpp fossilplugin.h fossilplugin.cpp fossilplugin.h
fossilsettings.cpp fossilsettings.h fossilsettings.cpp fossilsettings.h
pullorpushdialog.cpp pullorpushdialog.h pullorpushdialog.ui pullorpushdialog.cpp pullorpushdialog.h
revertdialog.ui revertdialog.ui
revisioninfo.h revisioninfo.h
wizard/fossiljsextension.cpp wizard/fossiljsextension.h wizard/fossiljsextension.cpp wizard/fossiljsextension.h

View File

@@ -20,7 +20,7 @@ QtcPlugin {
"fossilcommitwidget.cpp", "fossilcommitwidget.h", "fossilcommitwidget.cpp", "fossilcommitwidget.h",
"fossileditor.cpp", "fossileditor.h", "fossileditor.cpp", "fossileditor.h",
"annotationhighlighter.cpp", "annotationhighlighter.h", "annotationhighlighter.cpp", "annotationhighlighter.h",
"pullorpushdialog.cpp", "pullorpushdialog.h", "pullorpushdialog.ui", "pullorpushdialog.cpp", "pullorpushdialog.h",
"branchinfo.h", "branchinfo.h",
"configuredialog.cpp", "configuredialog.h", "configuredialog.cpp", "configuredialog.h",
"revisioninfo.h", "revisioninfo.h",

View File

@@ -2,86 +2,112 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pullorpushdialog.h" #include "pullorpushdialog.h"
#include "ui_pullorpushdialog.h"
#include "constants.h" #include "constants.h"
#include <utils/layoutbuilder.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QRadioButton>
namespace Fossil { namespace Fossil {
namespace Internal { namespace Internal {
PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent) : QDialog(parent), PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent)
m_mode(mode), : QDialog(parent)
m_ui(new Ui::PullOrPushDialog)
{ {
m_ui->setupUi(this); setWindowTitle(mode == PullMode ? tr("Pull Source") : tr("Push Destination"));
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::File); resize(600, 0);
m_ui->localPathChooser->setPromptDialogFilter(tr(Constants::FOSSIL_FILE_FILTER));
switch (m_mode) { m_defaultButton = new QRadioButton(tr("Default location"));
case PullMode: m_defaultButton->setChecked(true);
this->setWindowTitle(tr("Pull Source"));
break; m_localButton = new QRadioButton(tr("Local filesystem:"));
case PushMode:
this->setWindowTitle(tr("Push Destination")); m_localPathChooser = new Utils::PathChooser;
break; 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 // select URL text in line edit when clicking the radio button
m_ui->localButton->setFocusProxy(m_ui->localPathChooser); m_localButton->setFocusProxy(m_localPathChooser);
m_ui->urlButton->setFocusProxy(m_ui->urlLineEdit); m_urlButton->setFocusProxy(m_urlLineEdit);
connect(m_ui->urlButton, &QRadioButton::clicked, m_ui->urlLineEdit, &QLineEdit::selectAll); connect(m_urlButton, &QRadioButton::clicked, m_urlLineEdit, &QLineEdit::selectAll);
connect(m_urlButton, &QRadioButton::toggled, m_urlLineEdit, &QLineEdit::setEnabled);
this->adjustSize(); connect(m_localButton, &QRadioButton::toggled, m_localPathChooser,
} &Utils::PathChooser::setEnabled);
connect(m_urlButton, &QRadioButton::toggled, m_rememberCheckBox, &QCheckBox::setEnabled);
PullOrPushDialog::~PullOrPushDialog() connect(m_localButton, &QRadioButton::toggled, m_rememberCheckBox, &QCheckBox::setEnabled);
{
delete m_ui;
} }
QString PullOrPushDialog::remoteLocation() const QString PullOrPushDialog::remoteLocation() const
{ {
if (m_ui->defaultButton->isChecked()) if (m_defaultButton->isChecked())
return QString(); return QString();
if (m_ui->localButton->isChecked()) if (m_localButton->isChecked())
return m_ui->localPathChooser->filePath().toString(); return m_localPathChooser->filePath().toString();
return m_ui->urlLineEdit->text(); return m_urlLineEdit->text();
} }
bool PullOrPushDialog::isRememberOptionEnabled() const bool PullOrPushDialog::isRememberOptionEnabled() const
{ {
if (m_ui->defaultButton->isChecked()) if (m_defaultButton->isChecked())
return false; return false;
return m_ui->rememberCheckBox->isChecked(); return m_rememberCheckBox->isChecked();
} }
bool PullOrPushDialog::isPrivateOptionEnabled() const bool PullOrPushDialog::isPrivateOptionEnabled() const
{ {
return m_ui->privateCheckBox->isChecked(); return m_privateCheckBox->isChecked();
} }
void PullOrPushDialog::setDefaultRemoteLocation(const QString &url) void PullOrPushDialog::setDefaultRemoteLocation(const QString &url)
{ {
m_ui->urlLineEdit->setText(url); m_urlLineEdit->setText(url);
} }
void PullOrPushDialog::setLocalBaseDirectory(const QString &dir) void PullOrPushDialog::setLocalBaseDirectory(const QString &dir)
{ {
m_ui->localPathChooser->setBaseDirectory(Utils::FilePath::fromString(dir)); m_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;
}
} }
} // namespace Internal } // namespace Internal

View File

@@ -5,11 +5,17 @@
#include <QDialog> #include <QDialog>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QLineEdit;
class QRadioButton;
QT_END_NAMESPACE
namespace Utils { class PathChooser; }
namespace Fossil { namespace Fossil {
namespace Internal { namespace Internal {
namespace Ui { class PullOrPushDialog; }
class PullOrPushDialog : public QDialog class PullOrPushDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@@ -21,7 +27,6 @@ public:
}; };
explicit PullOrPushDialog(Mode mode, QWidget *parent = nullptr); explicit PullOrPushDialog(Mode mode, QWidget *parent = nullptr);
~PullOrPushDialog() final;
// Common parameters and options // Common parameters and options
QString remoteLocation() const; QString remoteLocation() const;
@@ -32,12 +37,14 @@ public:
// Pull-specific options // Pull-specific options
// Push-specific options // Push-specific options
protected:
void changeEvent(QEvent *e) final;
private: private:
Mode m_mode; QRadioButton *m_defaultButton;
Ui::PullOrPushDialog *m_ui; QRadioButton *m_localButton;
Utils::PathChooser *m_localPathChooser;
QRadioButton *m_urlButton;
QLineEdit *m_urlLineEdit;
QCheckBox *m_rememberCheckBox;
QCheckBox *m_privateCheckBox;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -1,235 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Fossil::Internal::PullOrPushDialog</class>
<widget class="QDialog" name="Fossil::Internal::PullOrPushDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>268</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>Remote 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" native="true">
<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="privateCheckBox">
<property name="toolTip">
<string>Allow transfer of private branches.</string>
</property>
<property name="text">
<string>Include private branches</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>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Fossil::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>Fossil::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>