Select sendFileRadioButton when dropping a file:// scheme url

This commit is contained in:
Gary Wang 2022-10-22 16:17:16 +08:00 committed by Gary Wang
parent 4baae049eb
commit 459187f8ed

View file

@ -113,8 +113,13 @@ int main(int argc, char **argv)
} }
}); });
QObject::connect(urlRequester, &KUrlRequester::textChanged, [urlRequester, &uidialog](const QString &newUrl) { QObject::connect(urlRequester, &KUrlRequester::textChanged, [&urlRequester, &uidialog]() {
bool isLocalFileUrl = QFileInfo(newUrl).exists() && QFileInfo(newUrl).isFile(); // we don't support sending directories yet! 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.sendFileRadioButton->setChecked(isLocalFileUrl);
uidialog.sendUrlRadioButton->setChecked(!isLocalFileUrl); uidialog.sendUrlRadioButton->setChecked(!isLocalFileUrl);
}); });