mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 12:03:55 -07:00
Better handler.
Took 6 minutes
This commit is contained in:
parent
20e5b52bae
commit
5eac9acc58
2 changed files with 9 additions and 12 deletions
|
|
@ -40,22 +40,19 @@ public:
|
||||||
if (event->type() == QEvent::FileOpen) {
|
if (event->type() == QEvent::FileOpen) {
|
||||||
auto *fileEvent = static_cast<QFileOpenEvent *>(event);
|
auto *fileEvent = static_cast<QFileOpenEvent *>(event);
|
||||||
|
|
||||||
qWarning() << "[MAC][FileOpenEvent] raw url:" << fileEvent->url()
|
const QUrl url = fileEvent->url();
|
||||||
<< "toString:" << fileEvent->url().toString() << "schemePrefix:" << m_prefixes;
|
|
||||||
|
|
||||||
const QString url = fileEvent->url().toString();
|
for (auto prefix : m_prefixes) {
|
||||||
|
if (url.scheme() == prefix) {
|
||||||
qWarning() << "[MAC][FileOpenEvent] extracted url:" << url;
|
emit urlReceived(url.toString());
|
||||||
|
|
||||||
for (auto m_prefix : m_prefixes) {
|
|
||||||
if (url.startsWith(m_prefix)) {
|
|
||||||
qWarning() << "[MAC][FileOpenEvent] MATCH prefix → emitting urlReceived";
|
|
||||||
emit urlReceived(url);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qWarning() << "[MAC][FileOpenEvent] ignored (wrong scheme)";
|
if (url.isLocalFile()) {
|
||||||
|
emit urlReceived(url.toLocalFile());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::eventFilter(watched, event);
|
return QObject::eventFilter(watched, event);
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ int main(int argc, char *argv[])
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
UrlSchemeEventFilter cockatriceFilter(QStringList{QStringLiteral("cockatrice://"), QStringLiteral("file://")});
|
UrlSchemeEventFilter cockatriceFilter(QStringList{QStringLiteral("cockatrice")});
|
||||||
|
|
||||||
QStringList pendingMacUrls;
|
QStringList pendingMacUrls;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue