refactor: move file open event handling to standalone file

This commit is contained in:
2024-12-31 10:57:21 +08:00
parent c227c74e23
commit 101f111209
7 changed files with 63 additions and 23 deletions

View File

@ -7,6 +7,10 @@
#include "playlistmanager.h"
#include "settings.h"
#ifdef Q_OS_MACOS
#include "fileopeneventhandler.h"
#endif // Q_OS_MACOS
#include <QApplication>
#include <QCommandLineParser>
#include <QDir>
@ -55,6 +59,16 @@ int main(int argc, char *argv[])
MainWindow w;
w.show();
#ifdef Q_OS_MACOS
FileOpenEventHandler * fileOpenEventHandler = new FileOpenEventHandler(&a);
a.installEventFilter(fileOpenEventHandler);
a.connect(fileOpenEventHandler, &FileOpenEventHandler::fileOpen, [&w](const QUrl & url){
if (w.isHidden()) w.showNormal();
w.showUrls({url});
w.initWindowSize();
});
#endif // Q_OS_MACOS
QStringList urlStrList = parser.positionalArguments();
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);