UI: resolve .url, .lnk shortcuts during drag-and-drop
On applies to Windows. Suggested here: https://ideas.obsproject.com/posts/1636
This commit is contained in:
parent
748cf32a43
commit
bf09a70a09
@ -5,6 +5,9 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QUrlQuery>
|
||||
#ifdef _WIN32
|
||||
#include <QSettings>
|
||||
#endif
|
||||
#include <string>
|
||||
|
||||
#include "window-basic-main.hpp"
|
||||
@ -58,6 +61,15 @@ static string GenerateSourceName(const char *base)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static QString ReadWindowsURLFile(const QString &file)
|
||||
{
|
||||
QSettings iniFile(file, QSettings::IniFormat);
|
||||
QVariant url = iniFile.value("InternetShortcut/URL");
|
||||
return url.toString();
|
||||
}
|
||||
#endif
|
||||
|
||||
void OBSBasic::AddDropURL(const char *url, QString &name, obs_data_t *settings,
|
||||
const obs_video_info &ovi)
|
||||
{
|
||||
@ -247,6 +259,23 @@ void OBSBasic::dropEvent(QDropEvent *event)
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (fileInfo.suffix().compare(
|
||||
"url", Qt::CaseInsensitive) == 0) {
|
||||
QString urlTarget = ReadWindowsURLFile(file);
|
||||
if (!urlTarget.isEmpty()) {
|
||||
ConfirmDropUrl(urlTarget);
|
||||
}
|
||||
continue;
|
||||
} else if (fileInfo.isShortcut()) {
|
||||
file = fileInfo.symLinkTarget();
|
||||
fileInfo = QFileInfo(file);
|
||||
if (!fileInfo.exists()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QString suffixQStr = fileInfo.suffix();
|
||||
QByteArray suffixArray = suffixQStr.toUtf8();
|
||||
const char *suffix = suffixArray.constData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user