1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright (c) 2018 Artur Shepilko
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pullorpushdialog.h"
#include "constants.h"
#include "fossiltr.h"
#include <utils/layoutbuilder.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QRadioButton>
namespace Fossil::Internal {
PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent)
: QDialog(parent)
{
setWindowTitle(mode == PullMode ? Tr::tr("Pull Source") : Tr::tr("Push Destination"));
resize(600, 0);
m_defaultButton = new QRadioButton(Tr::tr("Default location"));
m_defaultButton->setChecked(true);
m_localButton = new QRadioButton(Tr::tr("Local filesystem:"));
m_localPathChooser = new Utils::PathChooser;
m_localPathChooser->setEnabled(false);
m_localPathChooser->setExpectedKind(Utils::PathChooser::File);
m_localPathChooser->setPromptDialogFilter(Tr::tr(Constants::FOSSIL_FILE_FILTER));
m_urlButton = new QRadioButton(Tr::tr("Specify URL:"));
m_urlButton->setToolTip(Tr::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::tr("Remember specified location as default"));
m_rememberCheckBox->setEnabled(false);
m_privateCheckBox = new QCheckBox(Tr::tr("Include private branches"));
m_privateCheckBox->setToolTip(Tr::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 Layouting;
Column {
Group {
title(Tr::tr("Remote Location")),
Form {
m_defaultButton, br,
m_localButton, m_localPathChooser, br,
m_urlButton, m_urlLineEdit, br,
},
},
Group {
title(Tr::tr("Options")),
Column { m_rememberCheckBox, m_privateCheckBox, },
},
buttonBox,
}.attachTo(this);
// select URL text in line edit when clicking the radio button
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_defaultButton->isChecked())
return QString();
if (m_localButton->isChecked())
return m_localPathChooser->filePath().toString();
return m_urlLineEdit->text();
}
bool PullOrPushDialog::isRememberOptionEnabled() const
{
if (m_defaultButton->isChecked())
return false;
return m_rememberCheckBox->isChecked();
}
bool PullOrPushDialog::isPrivateOptionEnabled() const
{
return m_privateCheckBox->isChecked();
}
void PullOrPushDialog::setDefaultRemoteLocation(const QString &url)
{
m_urlLineEdit->setText(url);
}
void PullOrPushDialog::setLocalBaseDirectory(const Utils::FilePath &dir)
{
m_localPathChooser->setBaseDirectory(dir);
}
} // Fossil::Internal
|