Fix Tidal authentication on macOS

This commit is contained in:
Jonas Kvinge 2021-04-11 18:33:35 +02:00
parent 201ac47943
commit 7d3ceb7d8c
3 changed files with 27 additions and 7 deletions

View File

@ -78,7 +78,7 @@ const char *CommandlineOptions::kHelpText =
const char *CommandlineOptions::kVersionText = "Strawberry %1";
CommandlineOptions::CommandlineOptions(int argc, char* *argv)
CommandlineOptions::CommandlineOptions(int argc, char **argv)
: argc_(argc),
argv_(argv),
url_list_action_(UrlList_None),

View File

@ -148,8 +148,11 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
}
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
Q_UNUSED(aNotification);
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
key_tap_ = [ [SPMediaKeyTap alloc] initWithDelegate:self];
if ([SPMediaKeyTap usesGlobalMediaKeyTap]) {
if ([key_tap_ startWatchingMediaKeys]) {
@ -187,6 +190,13 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
}
- (void)handleURLEvent:(NSAppleEventDescriptor*)theEvent withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
NSString *url = [[theEvent paramDescriptorForKeyword:keyDirectObject] stringValue];
application_handler_->LoadUrl(QString::fromNSString(url));
}
- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event {
#pragma unused(keyTap)
[self handleMediaEvent:event];

View File

@ -2391,13 +2391,23 @@ void MainWindow::Activate() {
bool MainWindow::LoadUrl(const QString &url) {
if (!QFile::exists(url)) return false;
if (QFile::exists(url)) {
MimeData *mimedata = new MimeData;
mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
AddToPlaylist(mimedata);
return true;
}
#ifdef HAVE_TIDAL
else if (url.startsWith("tidal://login")) {
emit AuthorizationUrlReceived(QUrl(url));
return true;
}
#endif
else {
qLog(Error) << "Can't open" << url;
}
MimeData *mimedata = new MimeData;
mimedata->setUrls(QList<QUrl>() << QUrl::fromLocalFile(url));
AddToPlaylist(mimedata);
return true;
return false;
}