From 193481ce468deab888f9915da25d7789d1d2531d Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 3 Nov 2018 01:03:54 +0100 Subject: [PATCH] [handler] Embed URL into string Summary: E.g. Device to call +1234567 with Device to send /home/nico/foo to Device to open http://google.com on Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: apol, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D16623 --- urlhandler/dialog.ui | 7 ------- urlhandler/kdeconnect-handler.cpp | 17 +++++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/urlhandler/dialog.ui b/urlhandler/dialog.ui index e7708566d..832c312b5 100644 --- a/urlhandler/dialog.ui +++ b/urlhandler/dialog.ui @@ -20,13 +20,6 @@ - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - diff --git a/urlhandler/kdeconnect-handler.cpp b/urlhandler/kdeconnect-handler.cpp index 3d6f718a4..59b2524e0 100644 --- a/urlhandler/kdeconnect-handler.cpp +++ b/urlhandler/kdeconnect-handler.cpp @@ -85,21 +85,26 @@ int main(int argc, char** argv) proxyModel.setSourceModel(&model); QDialog dialog; - dialog.setWindowTitle(urlToShare.toDisplayString(QUrl::PreferLocalFile)); + Ui::Dialog uidialog; uidialog.setupUi(&dialog); uidialog.devicePicker->setModel(&proxyModel); + QString displayUrl; + if (urlToShare.scheme() == QLatin1String("tel")) { - uidialog.label->setText(i18n("Device to call this phone number with:")); - uidialog.urlLabel->setText(urlToShare.toDisplayString(QUrl::RemoveScheme)); + displayUrl = urlToShare.toDisplayString(QUrl::RemoveScheme); + uidialog.label->setText(i18n("Device to call %1 with:", displayUrl)); } else if (urlToShare.isLocalFile()) { - uidialog.label->setText(i18n("Device to send this file to:")); - uidialog.urlLabel->setText(urlToShare.toDisplayString(QUrl::PreferLocalFile)); + displayUrl = urlToShare.toDisplayString(QUrl::PreferLocalFile); + uidialog.label->setText(i18n("Device to send %1 to:", displayUrl)); } else { - uidialog.urlLabel->setText(urlToShare.toDisplayString()); + displayUrl = urlToShare.toDisplayString(QUrl::PreferLocalFile); + uidialog.label->setText(i18n("Device to open %1 on:", displayUrl)); } + dialog.setWindowTitle(displayUrl); + if (dialog.exec() == QDialog::Accepted) { QUrl url = urlToShare; const int currentDeviceIndex = uidialog.devicePicker->currentIndex();