Launcher: allow copying the raw command line
This commit is contained in:
parent
5ae818e526
commit
5312ed9071
3 changed files with 65 additions and 2 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
static bool static_enableDownloadDirUI = true;
|
static bool static_enableDownloadDirUI = true;
|
||||||
static QSettings::Format static_binaryFormat = QSettings::InvalidFormat;
|
static QSettings::Format static_binaryFormat = QSettings::InvalidFormat;
|
||||||
|
@ -175,6 +177,46 @@ QString LaunchConfig::htmlForCommandLine()
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString formatArgForClipboard(const LaunchConfig::Arg& a)
|
||||||
|
{
|
||||||
|
if (a.value.isEmpty()) {
|
||||||
|
return "--" + a.arg + " ";
|
||||||
|
} else if (a.arg == "prop") {
|
||||||
|
return "--" + a.arg + ":" + a.value + " ";
|
||||||
|
} else {
|
||||||
|
return "--" + a.arg + "=" + a.value + " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LaunchConfig::copyCommandLine()
|
||||||
|
{
|
||||||
|
QString r;
|
||||||
|
|
||||||
|
for (auto opt : flightgear::Options::sharedInstance()->extractOptions()) {
|
||||||
|
r += "--" + QString::fromStdString(opt) + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
collect();
|
||||||
|
const auto extraArgs = extraArgNames();
|
||||||
|
|
||||||
|
for (auto arg : valuesFromLauncher()) {
|
||||||
|
auto it = extraArgs.find(arg.arg.toStdString());
|
||||||
|
if (it != extraArgs.end()) {
|
||||||
|
continue; // skipped due to extra arg overriding
|
||||||
|
}
|
||||||
|
|
||||||
|
r += formatArgForClipboard(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto arg : valuesFromExtraArgs()) {
|
||||||
|
r += formatArgForClipboard(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
clipboard->setText(r);
|
||||||
|
}
|
||||||
|
|
||||||
bool LaunchConfig::saveConfigToINI()
|
bool LaunchConfig::saveConfigToINI()
|
||||||
{
|
{
|
||||||
// create settings using default type (INI) and path (inside FG_HOME),
|
// create settings using default type (INI) and path (inside FG_HOME),
|
||||||
|
@ -228,7 +270,7 @@ QVariant LaunchConfig::getValueForKey(QString group, QString key, QVariant defau
|
||||||
|
|
||||||
m_loadSaveSettings->beginGroup(group);
|
m_loadSaveSettings->beginGroup(group);
|
||||||
auto v = m_loadSaveSettings->value(key, defaultValue);
|
auto v = m_loadSaveSettings->value(key, defaultValue);
|
||||||
bool convertedOk = v.convert(defaultValue.type());
|
bool convertedOk = v.convert(static_cast<int>(defaultValue.type()));
|
||||||
if (!convertedOk) {
|
if (!convertedOk) {
|
||||||
qWarning() << "type forcing on loaded value failed:" << key << v << v.typeName() << defaultValue;
|
qWarning() << "type forcing on loaded value failed:" << key << v << v.typeName() << defaultValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE QString htmlForCommandLine();
|
Q_INVOKABLE QString htmlForCommandLine();
|
||||||
|
|
||||||
|
Q_INVOKABLE void copyCommandLine();
|
||||||
|
|
||||||
bool saveConfigToINI();
|
bool saveConfigToINI();
|
||||||
bool loadConfigFromINI();
|
bool loadConfigFromINI();
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,31 @@ import "."
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: buttonRow
|
||||||
|
spacing: Style.margin
|
||||||
|
height: childrenRect.height
|
||||||
|
anchors {
|
||||||
|
margins: Style.margin
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Copy to clipboard")
|
||||||
|
onClicked: {
|
||||||
|
_config.copyCommandLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flick
|
id: flick
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: scrollbar.right
|
right: scrollbar.right
|
||||||
top: parent.top
|
top: buttonRow.bottom
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
margins: Style.margin
|
margins: Style.margin
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue