From 459187f8edd3a99b1dcb088a28e1ba112d350eff Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sat, 22 Oct 2022 16:17:16 +0800 Subject: [PATCH] Select sendFileRadioButton when dropping a file:// scheme url --- urlhandler/kdeconnect-handler.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/urlhandler/kdeconnect-handler.cpp b/urlhandler/kdeconnect-handler.cpp index a308cb300..55f57b894 100644 --- a/urlhandler/kdeconnect-handler.cpp +++ b/urlhandler/kdeconnect-handler.cpp @@ -113,8 +113,13 @@ int main(int argc, char **argv) } }); - QObject::connect(urlRequester, &KUrlRequester::textChanged, [urlRequester, &uidialog](const QString &newUrl) { - bool isLocalFileUrl = QFileInfo(newUrl).exists() && QFileInfo(newUrl).isFile(); // we don't support sending directories yet! + QObject::connect(urlRequester, &KUrlRequester::textChanged, [&urlRequester, &uidialog]() { + QUrl fileUrl(urlRequester->url()); + bool isLocalFileUrl = false; + if (fileUrl.isLocalFile()) { + QFileInfo fileInfo(fileUrl.toLocalFile()); + isLocalFileUrl = fileInfo.exists() && fileInfo.isFile(); // we don't support sending directories yet! + } uidialog.sendFileRadioButton->setChecked(isLocalFileUrl); uidialog.sendUrlRadioButton->setChecked(!isLocalFileUrl); });