Skip to content

Commit

Permalink
Fix opening of project files on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jan 8, 2017
1 parent c9c1ba7 commit 50e8001
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
9 changes: 9 additions & 0 deletions include/EventApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <QApplication>

class EventApp : public QApplication
{
public:
EventApp(int& argc, char * * argv);
bool event(QEvent *event);
};

31 changes: 30 additions & 1 deletion src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <QMessageBox>
#include <QPushButton>
#include <QTextStream>
#include <QFileOpenEvent>

#ifdef LMMS_BUILD_WIN32
#include <windows.h>
Expand Down Expand Up @@ -74,6 +75,7 @@
#include "DataFile.h"
#include "Song.h"
#include "SetupDialog.h"
#include "EventApp.h"

static inline QString baseName( const QString & file )
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.