diff options
author | Katja Marttila <katja.marttila@qt.io> | 2020-12-28 14:02:26 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-12-30 09:10:29 +0000 |
commit | c9eb521f4520d5624ad83ed3a54705169049ad1c (patch) | |
tree | d0a6add4976ad5c0db68f491390c88de647d807c | |
parent | ca664d6e9f7b53c5b61237da2fceb8248124ad40 (diff) |
Allow disabling undo in RegisterFileType operation during uninstall
Task-number: QTIFW-2089
Change-Id: I8cccd471718eaaa6dc167a852b8854dc424f994e
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r-- | doc/operations.qdoc | 3 | ||||
-rw-r--r-- | src/libs/installer/registerfiletypeoperation.cpp | 6 | ||||
-rw-r--r-- | tests/auto/installer/registerfiletypeoperation/tst_registerfiletypeoperation.cpp | 24 |
3 files changed, 31 insertions, 2 deletions
diff --git a/doc/operations.qdoc b/doc/operations.qdoc index fdfe1764d..1df1de39d 100644 --- a/doc/operations.qdoc +++ b/doc/operations.qdoc @@ -231,6 +231,9 @@ \c command. Optionally, you can specify \c description, \c contentType, and \c icon. This is currently only supported on Windows. + \note File type will be unregistered during uninstallation. If you want keep the + type registered, you can overwrite the \e UNDO by passing \e UNDOOPERATION + and \e "", to the end of the argument list. \row \li ConsumeOutput \li "ConsumeOutput" \c installerKeyName \c executablePath \c processArguments diff --git a/src/libs/installer/registerfiletypeoperation.cpp b/src/libs/installer/registerfiletypeoperation.cpp index 0a7c2eaa5..c1ee7a038 100644 --- a/src/libs/installer/registerfiletypeoperation.cpp +++ b/src/libs/installer/registerfiletypeoperation.cpp @@ -97,7 +97,7 @@ bool RegisterFileTypeOperation::performOperation() ensureOptionalArgumentsRead(); if (!checkArgumentCount(2, 5, QString::fromLatin1("<extension> <command> [description [contentType [icon]]]"))) return false; - QStringList args = arguments(); + QStringList args = parsePerformOperationArguments(); bool allUsers = false; PackageManagerCore *const core = packageManager(); @@ -153,8 +153,10 @@ bool RegisterFileTypeOperation::undoOperation() { #ifdef Q_OS_WIN ensureOptionalArgumentsRead(); - QStringList args = arguments(); + if (parseUndoOperationArguments().count() > 0) + return true; + QStringList args = arguments(); if (!checkArgumentCount(2, 5, tr("Register File Type: Invalid arguments"))) return false; diff --git a/tests/auto/installer/registerfiletypeoperation/tst_registerfiletypeoperation.cpp b/tests/auto/installer/registerfiletypeoperation/tst_registerfiletypeoperation.cpp index 4d14a2753..5a4377d7b 100644 --- a/tests/auto/installer/registerfiletypeoperation/tst_registerfiletypeoperation.cpp +++ b/tests/auto/installer/registerfiletypeoperation/tst_registerfiletypeoperation.cpp @@ -66,6 +66,14 @@ private: QCOMPARE(m_settings->value(m_shellAppkey).toString(), QString()); } + void clearSettings() + { + m_settings->setValue(m_defaultKey, QString()); + m_settings->setValue(m_openWithProgIdkey, QString()); + m_settings->setValue(m_shellKey, QString()); + m_settings->setValue(m_shellAppkey, QString()); + } + private slots: void initTestCase() { @@ -126,6 +134,22 @@ private slots: verifySettingsCleaned(); } + void testRegisterFileTypeNoUndo() + { + RegisterFileTypeOperation op(&m_core); + op.setArguments(QStringList() << m_fileType << m_command << "test filetype" << + "text/plain" << 0 << "ProgId="+m_progId << "UNDOOPERATION" << ""); + QVERIFY(op.testOperation()); + QVERIFY(op.performOperation()); + + verifySettings(); + QVERIFY(op.undoOperation()); + verifySettings(); + + //Clear so it does not pollute settings + clearSettings(); + } + void testPerformingFromCLI() { QString installDir = QInstaller::generateTemporaryFileName(); |