mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 16:05:21 +01:00
Misc advanced options improvements
This commit is contained in:
parent
6eb358ed75
commit
ce549cadb2
3 changed files with 66 additions and 21 deletions
|
@ -31,7 +31,7 @@ Window {
|
|||
|
||||
ColumnLayout {
|
||||
id: cl
|
||||
spacing: 20
|
||||
spacing: 10
|
||||
anchors.fill: parent
|
||||
|
||||
ScrollView {
|
||||
|
@ -69,6 +69,11 @@ Window {
|
|||
|
||||
TabButton {
|
||||
text: qsTr("General")
|
||||
onClicked: {
|
||||
if (chkSetUser.checked && !fieldUserPassword.length) {
|
||||
fieldUserPassword.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
TabButton {
|
||||
text: qsTr("Services")
|
||||
|
@ -101,6 +106,7 @@ Window {
|
|||
id: fieldHostname
|
||||
enabled: chkHostname.checked
|
||||
text: "raspberrypi"
|
||||
selectByMouse: true
|
||||
validator: RegularExpressionValidator { regularExpression: /[0-9A-Za-z][0-9A-Za-z-]{0,62}/ }
|
||||
}
|
||||
Text {
|
||||
|
@ -109,7 +115,6 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ImCheckBox {
|
||||
id: chkSetUser
|
||||
text: qsTr("Set username and password")
|
||||
|
@ -117,6 +122,9 @@ Window {
|
|||
if (!checked && chkSSH.checked && radioPasswordAuthentication.checked) {
|
||||
checked = true;
|
||||
}
|
||||
if (checked && !fieldUserPassword.length) {
|
||||
fieldUserPassword.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,6 +146,7 @@ Window {
|
|||
id: fieldUserName
|
||||
text: "pi"
|
||||
Layout.minimumWidth: 200
|
||||
selectByMouse: true
|
||||
property bool indicateError: false
|
||||
|
||||
onTextEdited: {
|
||||
|
@ -153,6 +162,7 @@ Window {
|
|||
id: fieldUserPassword
|
||||
echoMode: TextInput.Password
|
||||
Layout.minimumWidth: 200
|
||||
selectByMouse: true
|
||||
property bool alreadyCrypted: false
|
||||
property bool indicateError: false
|
||||
|
||||
|
@ -198,19 +208,13 @@ Window {
|
|||
TextField {
|
||||
id: fieldWifiSSID
|
||||
Layout.minimumWidth: 200
|
||||
selectByMouse: true
|
||||
property bool indicateError: false
|
||||
onTextEdited: {
|
||||
indicateError = false
|
||||
}
|
||||
}
|
||||
|
||||
ImCheckBox {
|
||||
id: chkWifiSSIDHidden
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr("Hidden SSID")
|
||||
checked: false
|
||||
}
|
||||
|
||||
Text {
|
||||
text: qsTr("Password:")
|
||||
color: parent.enabled ? (fieldWifiPassword.indicateError ? "red" : "black") : "grey"
|
||||
|
@ -218,6 +222,7 @@ Window {
|
|||
TextField {
|
||||
id: fieldWifiPassword
|
||||
Layout.minimumWidth: 200
|
||||
selectByMouse: true
|
||||
echoMode: chkShowPassword.checked ? TextInput.Normal : TextInput.Password
|
||||
property bool indicateError: false
|
||||
onTextEdited: {
|
||||
|
@ -225,11 +230,20 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
ImCheckBox {
|
||||
id: chkShowPassword
|
||||
RowLayout {
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr("Show password")
|
||||
checked: true
|
||||
|
||||
ImCheckBox {
|
||||
id: chkShowPassword
|
||||
text: qsTr("Show password")
|
||||
checked: true
|
||||
}
|
||||
ImCheckBox {
|
||||
id: chkWifiSSIDHidden
|
||||
Layout.columnSpan: 2
|
||||
text: qsTr("Hidden SSID")
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
|
@ -289,9 +303,6 @@ Window {
|
|||
}
|
||||
if (radioPasswordAuthentication.checked) {
|
||||
chkSetUser.checked = true
|
||||
if (!fieldUserPassword.length) {
|
||||
fieldUserPassword.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -339,6 +350,7 @@ Window {
|
|||
id: fieldPublicKey
|
||||
wrapMode: TextEdit.WrapAnywhere
|
||||
Layout.minimumWidth: 400
|
||||
selectByMouse: true
|
||||
}
|
||||
|
||||
ImButton {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <windows.h>
|
||||
#include <QWinTaskbarButton>
|
||||
#include <QWinTaskbarProgress>
|
||||
#include <QProcessEnvironment>
|
||||
#endif
|
||||
|
||||
#ifdef QT_NO_WIDGETS
|
||||
|
@ -790,16 +791,19 @@ QByteArray ImageWriter::getUsbSourceOSlist()
|
|||
#endif
|
||||
}
|
||||
|
||||
QString ImageWriter::_sshKeyDir()
|
||||
{
|
||||
return QDir::homePath()+"/.ssh";
|
||||
}
|
||||
|
||||
QString ImageWriter::_pubKeyFileName()
|
||||
{
|
||||
return QDir::homePath()+"/.ssh/id_rsa.pub";
|
||||
return _sshKeyDir()+"/id_rsa.pub";
|
||||
}
|
||||
|
||||
QString ImageWriter::_privKeyFileName()
|
||||
{
|
||||
QString fn = _pubKeyFileName();
|
||||
fn.chop(4);
|
||||
return fn;
|
||||
return _sshKeyDir()+"/id_rsa";
|
||||
}
|
||||
|
||||
QString ImageWriter::getDefaultPubKey()
|
||||
|
@ -821,18 +825,45 @@ bool ImageWriter::hasPubKey()
|
|||
return QFile::exists(_pubKeyFileName());
|
||||
}
|
||||
|
||||
QString ImageWriter::_sshKeyGen()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QString windir = QProcessEnvironment::systemEnvironment().value("windir");
|
||||
return QDir::fromNativeSeparators(windir+"\\SysNative\\OpenSSH\\ssh-keygen.exe");
|
||||
#else
|
||||
return "ssh-keygen";
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ImageWriter::hasSshKeyGen()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return QFile::exists(_sshKeyGen());
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImageWriter::generatePubKey()
|
||||
{
|
||||
if (!hasPubKey() && !QFile::exists(_privKeyFileName()))
|
||||
{
|
||||
QDir dir;
|
||||
QProcess proc;
|
||||
QString progName = _sshKeyGen();
|
||||
QStringList args;
|
||||
args << "-t" << "rsa" << "-f" << _privKeyFileName() << "-N" << "";
|
||||
QProcess::execute("ssh-keygen", args);
|
||||
|
||||
if (!dir.exists(_sshKeyDir()))
|
||||
{
|
||||
qDebug() << "Creating" << _sshKeyDir();
|
||||
dir.mkdir(_sshKeyDir());
|
||||
}
|
||||
|
||||
qDebug() << "Executing:" << progName << args;
|
||||
proc.start(progName, args);
|
||||
proc.waitForFinished();
|
||||
qDebug() << proc.readAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,8 @@ protected:
|
|||
void _parseCompressedFile();
|
||||
QString _pubKeyFileName();
|
||||
QString _privKeyFileName();
|
||||
QString _sshKeyDir();
|
||||
QString _sshKeyGen();
|
||||
};
|
||||
|
||||
#endif // IMAGEWRITER_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue