diff --git a/docs/source/user-docs/command-line.rst b/docs/source/user-docs/command-line.rst index f7421ed8..3be7e916 100644 --- a/docs/source/user-docs/command-line.rst +++ b/docs/source/user-docs/command-line.rst @@ -50,7 +50,13 @@ Options .. option:: -i - 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 , it will open a file directly + in write mode without any further dialog or confirmation. .. option:: --pythonhome diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index 150858c2..7e646e08 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -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)) { diff --git a/src/dialogs/InitialOptionsDialog.cpp b/src/dialogs/InitialOptionsDialog.cpp index a6031877..93ec2606 100644 --- a/src/dialogs/InitialOptionsDialog.cpp +++ b/src/dialogs/InitialOptionsDialog.cpp @@ -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 }