Skip to content

Commit

Permalink
Show all url schemas in entry view
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Mar 22, 2018
1 parent e92d5e8 commit bb705e8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/core/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ QString Entry::webUrl() const
QString Entry::displayUrl() const
{
QString url = maskPasswordPlaceholders(m_attributes->value(EntryAttributes::URLKey));
url = resolveMultiplePlaceholders(url);
return resolveUrl(url);
return resolveMultiplePlaceholders(url);
}

QString Entry::username() const
Expand Down
25 changes: 11 additions & 14 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,23 +629,19 @@ void DatabaseWidget::openUrl()

void DatabaseWidget::openUrlForEntry(Entry* entry)
{
QString urlString = entry->resolveMultiplePlaceholders(entry->url());
if (urlString.isEmpty()) {
return;
}

if (urlString.startsWith("cmd://")) {
if (entry->url().startsWith("cmd://")) {
QString cmdString = entry->resolveMultiplePlaceholders(entry->url());
// check if decision to execute command was stored
if (entry->attributes()->hasKey(EntryAttributes::RememberCmdExecAttr)) {
if (entry->attributes()->value(EntryAttributes::RememberCmdExecAttr) == "1") {
QProcess::startDetached(urlString.mid(6));
QProcess::startDetached(cmdString.mid(6));
}
return;
}

// otherwise ask user
if (urlString.length() > 6) {
QString cmdTruncated = urlString.mid(6);
if (cmdString.length() > 6) {
QString cmdTruncated = cmdString.mid(6);
if (cmdTruncated.length() > 400)
cmdTruncated = cmdTruncated.left(400) + " […]";
QMessageBox msgbox(QMessageBox::Icon::Question,
Expand All @@ -668,18 +664,19 @@ void DatabaseWidget::openUrlForEntry(Entry* entry)

int result = msgbox.exec();
if (result == QMessageBox::Yes) {
QProcess::startDetached(urlString.mid(6));
QProcess::startDetached(cmdString.mid(6));
}

if (remember) {
entry->attributes()->set(EntryAttributes::RememberCmdExecAttr,
result == QMessageBox::Yes ? "1" : "0");
}
}
}
else {
QUrl url = QUrl::fromUserInput(urlString);
QDesktopServices::openUrl(url);
} else {
QString urlString = entry->webUrl();
if (!urlString.isEmpty()) {
QDesktopServices::openUrl(urlString);
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/gui/DetailsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,15 @@ void DetailsWidget::updateEntryGeneralTab()
m_ui->entryPasswordLabel->setToolTip({});
}

m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl());
const QString url = m_currentEntry->webUrl();
if (!url.isEmpty()) {
// URL is well formed and can be opened in a browser
// create a new display url that masks password placeholders
// the actual link will use the password
m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl());
m_ui->entryUrlLabel->setUrl(url);
m_ui->entryUrlLabel->setCursor(Qt::PointingHandCursor);
} else {
// Fallback to the raw url string
m_ui->entryUrlLabel->setRawText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->url()));
m_ui->entryUrlLabel->setUrl({});
m_ui->entryUrlLabel->setCursor(Qt::ArrowCursor);
}

const TimeInfo entryTime = m_currentEntry->timeInfo();
Expand Down
3 changes: 3 additions & 0 deletions src/gui/DetailsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item row="0" column="2">
Expand Down

0 comments on commit bb705e8

Please sign in to comment.