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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "genericlinuxdeviceconfigurationwizardpages.h"
#include "ui_genericlinuxdeviceconfigurationwizardsetuppage.h"
#include <projectexplorer/devicesupport/idevice.h>
namespace RemoteLinux {
namespace Internal {
class GenericLinuxDeviceConfigurationWizardSetupPagePrivate
{
public:
Ui::GenericLinuxDeviceConfigurationWizardSetupPage ui;
};
class GenericLinuxDeviceConfigurationWizardFinalPagePrivate
{
public:
QLabel infoLabel;
};
} // namespace Internal
using namespace QSsh;
using namespace Utils;
GenericLinuxDeviceConfigurationWizardSetupPage::GenericLinuxDeviceConfigurationWizardSetupPage(QWidget *parent) :
QWizardPage(parent), d(new Internal::GenericLinuxDeviceConfigurationWizardSetupPagePrivate)
{
d->ui.setupUi(this);
setTitle(tr("Connection"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
d->ui.privateKeyPathChooser->setExpectedKind(PathChooser::File);
d->ui.privateKeyPathChooser->setHistoryCompleter(QLatin1String("Ssh.KeyFile.History"));
d->ui.privateKeyPathChooser->setPromptDialogTitle(tr("Choose a Private Key File"));
connect(d->ui.nameLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
connect(d->ui.hostNameLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
connect(d->ui.userNameLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
connect(d->ui.privateKeyPathChooser, &PathChooser::validChanged,
this, &QWizardPage::completeChanged);
connect(d->ui.passwordButton, &QAbstractButton::toggled,
this, &GenericLinuxDeviceConfigurationWizardSetupPage::handleAuthTypeChanged);
}
GenericLinuxDeviceConfigurationWizardSetupPage::~GenericLinuxDeviceConfigurationWizardSetupPage()
{
delete d;
}
void GenericLinuxDeviceConfigurationWizardSetupPage::initializePage()
{
d->ui.nameLineEdit->setText(defaultConfigurationName());
d->ui.hostNameLineEdit->setText(defaultHostName());
d->ui.userNameLineEdit->setText(defaultUserName());
d->ui.passwordButton->setChecked(true);
d->ui.passwordLineEdit->setText(defaultPassWord());
d->ui.privateKeyPathChooser->setPath(ProjectExplorer::IDevice::defaultPrivateKeyFilePath());
handleAuthTypeChanged();
}
bool GenericLinuxDeviceConfigurationWizardSetupPage::isComplete() const
{
return !configurationName().isEmpty() && !hostName().isEmpty() && !userName().isEmpty()
&& (authenticationType() != SshConnectionParameters::AuthenticationTypePublicKey
|| d->ui.privateKeyPathChooser->isValid());
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::configurationName() const
{
return d->ui.nameLineEdit->text().trimmed();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::hostName() const
{
return d->ui.hostNameLineEdit->text().trimmed();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::userName() const
{
return d->ui.userNameLineEdit->text().trimmed();
}
SshConnectionParameters::AuthenticationType GenericLinuxDeviceConfigurationWizardSetupPage::authenticationType() const
{
return d->ui.passwordButton->isChecked()
? SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods
: SshConnectionParameters::AuthenticationTypePublicKey;
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::password() const
{
return d->ui.passwordLineEdit->text();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::privateKeyFilePath() const
{
return d->ui.privateKeyPathChooser->path();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultConfigurationName() const
{
return tr("Generic Linux Device");
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultHostName() const
{
return QString();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultUserName() const
{
return QString();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultPassWord() const
{
return QString();
}
void GenericLinuxDeviceConfigurationWizardSetupPage::handleAuthTypeChanged()
{
d->ui.passwordLineEdit->setEnabled(authenticationType() != SshConnectionParameters::AuthenticationTypePublicKey);
d->ui.privateKeyPathChooser->setEnabled(!d->ui.passwordLineEdit->isEnabled());
emit completeChanged();
}
GenericLinuxDeviceConfigurationWizardFinalPage::GenericLinuxDeviceConfigurationWizardFinalPage(QWidget *parent)
: QWizardPage(parent), d(new Internal::GenericLinuxDeviceConfigurationWizardFinalPagePrivate)
{
setTitle(tr("Summary"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
d->infoLabel.setWordWrap(true);
QVBoxLayout * const layout = new QVBoxLayout(this);
layout->addWidget(&d->infoLabel);
}
GenericLinuxDeviceConfigurationWizardFinalPage::~GenericLinuxDeviceConfigurationWizardFinalPage()
{
delete d;
}
void GenericLinuxDeviceConfigurationWizardFinalPage::initializePage()
{
d->infoLabel.setText(infoText());
}
QString GenericLinuxDeviceConfigurationWizardFinalPage::infoText() const
{
return tr("The new device configuration will now be created.\n"
"In addition, device connectivity will be tested.");
}
} // namespace RemoteLinux
|