From de1c90d2442f9107a7c8be75d114af7e73572e70 Mon Sep 17 00:00:00 2001 From: Nicolas Pardon Date: Sat, 2 Dec 2023 21:49:32 +0100 Subject: [PATCH] Add execute command from url field on AutoOpen, implementing feature #7424 --- src/gui/DatabaseWidget.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index b20f5a240..d9e1abfb0 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -2290,16 +2290,14 @@ void DatabaseWidget::processAutoOpen() { Q_ASSERT(m_db); + // check if AutoOpen group exists auto* autoopenGroup = m_db->rootGroup()->findGroupByPath("/AutoOpen"); if (!autoopenGroup) { return; } + // iterate over each entry in AutoOpen group for (const auto* entry : autoopenGroup->entries()) { - if (entry->url().isEmpty() || (entry->password().isEmpty() && entry->username().isEmpty())) { - continue; - } - // Support ifDevice advanced entry, a comma separated list of computer names // that control whether to perform AutoOpen on this entry or not. Can be // negated using '!' @@ -2327,7 +2325,17 @@ void DatabaseWidget::processAutoOpen() continue; } } + // if entry starts with 'cmd://' execute openUrlForEntry + // this will allow triggering any application/script on db open + if (entry->url().startsWith("cmd://")) { + auto current_entry = entry->clone(); + openUrlForEntry(current_entry); + continue; + } + if (entry->url().isEmpty() || (entry->password().isEmpty() && entry->username().isEmpty())) { + continue; + } openDatabaseFromEntry(entry); } }