From d26cff520f53c0e2eb68a762df5f7c728db568bc Mon Sep 17 00:00:00 2001 From: Amir Pakdel Date: Tue, 12 May 2015 12:25:43 -0400 Subject: [PATCH 1/3] Bug #244 Supporting cmd:// URLs --- src/gui/DatabaseWidget.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 369c69037..6303d094e 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "autotype/AutoType.h" #include "core/Config.h" @@ -452,9 +453,21 @@ void DatabaseWidget::openUrl() void DatabaseWidget::openUrlForEntry(Entry* entry) { - if (!entry->url().isEmpty()) { - QDesktopServices::openUrl(entry->url()); + QString UrlString = entry->url(); + if (UrlString.isEmpty()) + return; + + UrlString.replace("{TITLE}", entry->title(), Qt::CaseInsensitive); + UrlString.replace("{USERNAME}", entry->username(), Qt::CaseInsensitive); + UrlString.replace("{PASSWORD}", entry->password(), Qt::CaseInsensitive); + + if (UrlString.startsWith("cmd://") && UrlString.length()>6){ + QProcess::startDetached(UrlString.right(UrlString.length()-6)); + return; } + + QDesktopServices::openUrl(UrlString); + } void DatabaseWidget::createGroup() From 0458dad6dc606149ca20ddc127bbfdcdfd4422e4 Mon Sep 17 00:00:00 2001 From: Amir Pakdel Date: Wed, 13 May 2015 14:34:48 -0400 Subject: [PATCH 2/3] Code cleanups --- src/gui/DatabaseWidget.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 6303d094e..0b5e1545d 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -453,21 +453,16 @@ void DatabaseWidget::openUrl() void DatabaseWidget::openUrlForEntry(Entry* entry) { - QString UrlString = entry->url(); + QString UrlString = entry->resolvePlaceholders(entry->url()); if (UrlString.isEmpty()) return; - UrlString.replace("{TITLE}", entry->title(), Qt::CaseInsensitive); - UrlString.replace("{USERNAME}", entry->username(), Qt::CaseInsensitive); - UrlString.replace("{PASSWORD}", entry->password(), Qt::CaseInsensitive); - if (UrlString.startsWith("cmd://") && UrlString.length()>6){ - QProcess::startDetached(UrlString.right(UrlString.length()-6)); - return; + QProcess::startDetached(UrlString.mid(6)); + } else { + QDesktopServices::openUrl(UrlString); } - QDesktopServices::openUrl(UrlString); - } void DatabaseWidget::createGroup() From bcc3108c3d660e54fd14eb527ea4fd090ebf1564 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Mon, 13 Jul 2015 22:36:20 +0200 Subject: [PATCH 3/3] Coding style cleanup. --- src/gui/DatabaseWidget.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 0b5e1545d..112739efb 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -453,14 +453,16 @@ void DatabaseWidget::openUrl() void DatabaseWidget::openUrlForEntry(Entry* entry) { - QString UrlString = entry->resolvePlaceholders(entry->url()); - if (UrlString.isEmpty()) + QString urlString = entry->resolvePlaceholders(entry->url()); + if (urlString.isEmpty()) { return; + } - if (UrlString.startsWith("cmd://") && UrlString.length()>6){ - QProcess::startDetached(UrlString.mid(6)); - } else { - QDesktopServices::openUrl(UrlString); + if (urlString.startsWith("cmd://") && (urlString.length() > 6)) { + QProcess::startDetached(urlString.mid(6)); + } + else { + QDesktopServices::openUrl(urlString); } }