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