Permalink
Browse files

Fix opening of project files on macOS

Per #665
  • Loading branch information...
tresf committed Jan 8, 2017
1 parent c9c1ba7 commit 50e80013021e7fa5ba222ccc4083b883a33532a6
Showing with 39 additions and 1 deletion.
  1. +9 −0 include/EventApp.h
  2. +30 −1 src/core/main.cpp
View
@@ -0,0 +1,9 @@
#include <QApplication>
class EventApp : public QApplication
{
public:
EventApp(int& argc, char * * argv);
bool event(QEvent *event);
};
View
@@ -38,6 +38,7 @@
#include <QMessageBox>
#include <QPushButton>
#include <QTextStream>
#include <QFileOpenEvent>
#ifdef LMMS_BUILD_WIN32
#include <windows.h>
@@ -74,6 +75,7 @@
#include "DataFile.h"
#include "Song.h"
#include "SetupDialog.h"
#include "EventApp.h"
static inline QString baseName( const QString & file )
{
@@ -261,7 +263,7 @@ int main( int argc, char * * argv )
QCoreApplication * app = coreOnly ?
new QCoreApplication( argc, argv ) :
new QApplication( argc, argv ) ;
new EventApp( argc, argv ) ;
Mixer::qualitySettings qs( Mixer::qualitySettings::Mode_HighQuality );
ProjectRenderer::OutputSettings os( 44100, false, 160,
@@ -917,3 +919,30 @@ int main( int argc, char * * argv )
return ret;
}
EventApp::EventApp( int& argc, char * * argv ) : QApplication( argc, argv ) {}
// Responds to QApplication events such as QFileOpenEvent (MacOS)
bool EventApp::event( QEvent * event )
{
switch(event->type())
{
case QEvent::FileOpen:
{
QFileOpenEvent * fileEvent = static_cast<QFileOpenEvent *>( event );
if( event )
{
Engine::getSong()->loadProject( fileEvent->file() );
return true;
}
}
default:
return QApplication::event( event );
}
}

0 comments on commit 50e8001

Please sign in to comment.