Cmdline option to open a file in write mode (#2216)

* Added an option to directly enable write mode via -w/--writemode to the command line option parser
This commit is contained in:
tobigrimm 2020-05-28 13:33:19 +02:00 committed by GitHub
parent 433f056ec5
commit cd6fc26ed1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -50,7 +50,13 @@ Options
.. option:: -i <file>
Run script file
Run script file
.. option:: -w, --writemode
Open a file in write mode, instead of the default read-only mode.
When used together with -A/--analysis <level>, it will open a file directly
in write mode without any further dialog or confirmation.
.. option:: --pythonhome <PYTHONHOME>

View File

@ -241,7 +241,7 @@ bool CutterApplication::loadTranslations()
return true;
}
const auto &allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
QLocale::AnyCountry);
QLocale::AnyCountry);
bool cutterTrLoaded = false;
@ -325,6 +325,11 @@ bool CutterApplication::parseCommandLineOptions()
QObject::tr("file"));
cmd_parser.addOption(scriptOption);
QCommandLineOption writeModeOption({"w", "writemode"},
QObject::tr("Open file in write mode"));
cmd_parser.addOption(writeModeOption);
QCommandLineOption pythonHomeOption("pythonhome",
QObject::tr("PYTHONHOME to use for embedded python interpreter"),
"PYTHONHOME");
@ -407,6 +412,8 @@ bool CutterApplication::parseCommandLineOptions()
break;
}
opts.fileOpenOptions.script = cmd_parser.value(scriptOption);
opts.fileOpenOptions.writeEnabled = cmd_parser.isSet(writeModeOption);
}
if (cmd_parser.isSet(pythonHomeOption)) {

View File

@ -165,6 +165,9 @@ void InitialOptionsDialog::loadOptions(const InitialOptions &options)
ui->entry_loadOffset->setText(RAddressString(options.binLoadAddr));
}
ui->writeCheckBox->setChecked(options.writeEnabled);
// TODO: all other options should also be applied to the ui
}