{"action":"created","comment":{"url":"https://api.github.com/repos/LMMS/lmms/pulls/comments/51652442","id":51652442,"diff_hunk":"@@ -1269,13 +1309,77 @@ void MainWindow::updateConfig( QAction * _who )\n \n void MainWindow::onToggleMetronome()\n {\n-\tMixer * mixer = Engine::mixer();\n+\tMixer * mixer = getMixer();\n \n \tmixer->setMetronomeActive( m_metronomeToggle->isChecked() );\n }\n \n \n \n+void MainWindow::exportMIDI()\n+{\n+\tSong * song = getSong();\n+\tif ( !song )\n+\t{\n+\t\treturn;\n+\t}\n+\n+\tif ( song->isEmpty() )\n+\t{\n+\t\tQMessageBox::information( gui->mainWindow(),\n+\t\t\t\ttr( \"Empty project\" ),\n+\t\t\t\ttr( \"This project is empty so exporting makes \"\n+\t\t\t\t\t\"no sense. Please put some items into \"\n+\t\t\t\t\t\"Song Editor first!\" ) );\n+\t\treturn;\n+\t}\n+\n+\tFileDialog efd( gui->mainWindow() );\n+\n+\tefd.setFileMode( FileDialog::AnyFile );\n+\n+\tQStringList types;\n+\ttypes << tr(\"MIDI File (*.mid)\");\n+\tefd.setNameFilters( types );\n+\tQString base_filename;\n+\t// TODO Rename. Not a real member. Only for simpler refactoring!\n+\tQString const & m_fileName = song->projectFileName();\n+\n+\tif( !m_fileName.isEmpty() )\n+\t{\n+\t\tefd.setDirectory( QFileInfo( m_fileName ).absolutePath() );\n+\t\tbase_filename = QFileInfo( m_fileName ).completeBaseName();\n+\t}\n+\telse\n+\t{\n+\t\tefd.setDirectory( ConfigManager::inst()->userProjectsDir() );\n+\t\tbase_filename = tr( \"untitled\" );\n+\t}\n+\tefd.selectFile( base_filename + \".mid\" );\n+\tefd.setWindowTitle( tr( \"Select file for project-export...\" ) );\n+\n+\tefd.setAcceptMode( FileDialog::AcceptSave );\n+\n+\tif( efd.exec() == QDialog::Accepted && !efd.selectedFiles().isEmpty() && !efd.selectedFiles()[0].isEmpty() )\n+\t{\n+\t\tconst QString suffix = \".mid\";\n+\n+\t\tQString export_filename = efd.selectedFiles()[0];\n+\t\tif (!export_filename.endsWith(suffix)) export_filename += suffix;\n+\n+\t\t// NOTE start midi export\n+\n+\t\t// instantiate midi export plugin\n+\t\tTrackContainer::TrackList tracks;\n+\t\ttracks += song->tracks();\n+\t\ttracks += getBBTrackContainer()->tracks();\n+\n+\t\tsong->exportProjectMidi(tracks, song->getTempo(), export_filename);","path":"src/gui/MainWindow.cpp","position":344,"original_position":344,"commit_id":"96d88623ba52c25f5da1e59db3814eb50e4fff69","original_commit_id":"96d88623ba52c25f5da1e59db3814eb50e4fff69","user":{"login":"Wallacoloo","id":1210751,"avatar_url":"https://avatars.githubusercontent.com/u/1210751?v=3","gravatar_id":"","url":"https://api.github.com/users/Wallacoloo","html_url":"https://github.com/Wallacoloo","followers_url":"https://api.github.com/users/Wallacoloo/followers","following_url":"https://api.github.com/users/Wallacoloo/following{/other_user}","gists_url":"https://api.github.com/users/Wallacoloo/gists{/gist_id}","starred_url":"https://api.github.com/users/Wallacoloo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wallacoloo/subscriptions","organizations_url":"https://api.github.com/users/Wallacoloo/orgs","repos_url":"https://api.github.com/users/Wallacoloo/repos","events_url":"https://api.github.com/users/Wallacoloo/events{/privacy}","received_events_url":"https://api.github.com/users/Wallacoloo/received_events","type":"User","site_admin":false},"body":":+1: Great way to remove the gui calls from `core/Song.cpp`, imo.","created_at":"2016-02-02T23:10:36Z","updated_at":"2016-02-02T23:10:36Z","html_url":"https://github.com/LMMS/lmms/pull/2536#discussion_r51652442","pull_request_url":"https://api.github.com/repos/LMMS/lmms/pulls/2536","_links":{"self":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/comments/51652442"},"html":{"href":"https://github.com/LMMS/lmms/pull/2536#discussion_r51652442"},"pull_request":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/2536"}}},"pull_request":{"url":"https://api.github.com/repos/LMMS/lmms/pulls/2536","id":57776944,"html_url":"https://github.com/LMMS/lmms/pull/2536","diff_url":"https://github.com/LMMS/lmms/pull/2536.diff","patch_url":"https://github.com/LMMS/lmms/pull/2536.patch","issue_url":"https://api.github.com/repos/LMMS/lmms/issues/2536","number":2536,"state":"open","locked":false,"title":"Separation of core code and GUI: Getting rid of the static calls into the Engine class","user":{"login":"michaelgregorius","id":9293269,"avatar_url":"https://avatars.githubusercontent.com/u/9293269?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelgregorius","html_url":"https://github.com/michaelgregorius","followers_url":"https://api.github.com/users/michaelgregorius/followers","following_url":"https://api.github.com/users/michaelgregorius/following{/other_user}","gists_url":"https://api.github.com/users/michaelgregorius/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelgregorius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelgregorius/subscriptions","organizations_url":"https://api.github.com/users/michaelgregorius/orgs","repos_url":"https://api.github.com/users/michaelgregorius/repos","events_url":"https://api.github.com/users/michaelgregorius/events{/privacy}","received_events_url":"https://api.github.com/users/michaelgregorius/received_events","type":"User","site_admin":false},"body":"As a means to separate the core classes from the GUI I have started to get rid of the static calls into the `Engine` class. To do so the following steps have been taken so far:\r\n* A new class/interface `EngineClient` has been introduced. Classes that need information from the `Engine` inherit from this class. `EngineClient` provides access to the `Engine` and provides convenience methods to access `Song`, `BBTrackContainer` and `ProjectJournal` (more might be added later if needed).\r\n* So far the classes `PianoRoll`, `AutomationEditor` and `Plugin` inherit from `EngineClient`.\r\n* The constructors of the GUI classes `PianoRoll` and `AutomationEditor` have been adjusted to take a pointer to the `Engine` as a parameter. Both classes now retrieve the information via the `EngineClient` interface, i.e. they contain no more calls to `Engine::getSong`, etc.\r\n* The factory method `lmms_plugin_main` for the plugins has been extended to also take a pointer to the `Engine`. The constructors of all plugins have been adjusted as well. This way all plugins should now be able to access the `Engine` using `EngineClient::getEngine` instead of calling `Engine::getSong`, `Engine::getMixer`, etc.\r\n\r\nPlease provide feedback whether I should continue with this path and whether there is a chance for these changes to be integrated. Thanks!","created_at":"2016-01-31T19:07:27Z","updated_at":"2016-02-02T23:10:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"793736f1d17b814515721e994f791395216416a2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LMMS/lmms/pulls/2536/commits","review_comments_url":"https://api.github.com/repos/LMMS/lmms/pulls/2536/comments","review_comment_url":"https://api.github.com/repos/LMMS/lmms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LMMS/lmms/issues/2536/comments","statuses_url":"https://api.github.com/repos/LMMS/lmms/statuses/96d88623ba52c25f5da1e59db3814eb50e4fff69","head":{"label":"michaelgregorius:untangling-dependencies","ref":"untangling-dependencies","sha":"96d88623ba52c25f5da1e59db3814eb50e4fff69","user":{"login":"michaelgregorius","id":9293269,"avatar_url":"https://avatars.githubusercontent.com/u/9293269?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelgregorius","html_url":"https://github.com/michaelgregorius","followers_url":"https://api.github.com/users/michaelgregorius/followers","following_url":"https://api.github.com/users/michaelgregorius/following{/other_user}","gists_url":"https://api.github.com/users/michaelgregorius/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelgregorius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelgregorius/subscriptions","organizations_url":"https://api.github.com/users/michaelgregorius/orgs","repos_url":"https://api.github.com/users/michaelgregorius/repos","events_url":"https://api.github.com/users/michaelgregorius/events{/privacy}","received_events_url":"https://api.github.com/users/michaelgregorius/received_events","type":"User","site_admin":false},"repo":{"id":34210428,"name":"lmms","full_name":"michaelgregorius/lmms","owner":{"login":"michaelgregorius","id":9293269,"avatar_url":"https://avatars.githubusercontent.com/u/9293269?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelgregorius","html_url":"https://github.com/michaelgregorius","followers_url":"https://api.github.com/users/michaelgregorius/followers","following_url":"https://api.github.com/users/michaelgregorius/following{/other_user}","gists_url":"https://api.github.com/users/michaelgregorius/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelgregorius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelgregorius/subscriptions","organizations_url":"https://api.github.com/users/michaelgregorius/orgs","repos_url":"https://api.github.com/users/michaelgregorius/repos","events_url":"https://api.github.com/users/michaelgregorius/events{/privacy}","received_events_url":"https://api.github.com/users/michaelgregorius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michaelgregorius/lmms","description":"cross-platform music production software","fork":true,"url":"https://api.github.com/repos/michaelgregorius/lmms","forks_url":"https://api.github.com/repos/michaelgregorius/lmms/forks","keys_url":"https://api.github.com/repos/michaelgregorius/lmms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michaelgregorius/lmms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michaelgregorius/lmms/teams","hooks_url":"https://api.github.com/repos/michaelgregorius/lmms/hooks","issue_events_url":"https://api.github.com/repos/michaelgregorius/lmms/issues/events{/number}","events_url":"https://api.github.com/repos/michaelgregorius/lmms/events","assignees_url":"https://api.github.com/repos/michaelgregorius/lmms/assignees{/user}","branches_url":"https://api.github.com/repos/michaelgregorius/lmms/branches{/branch}","tags_url":"https://api.github.com/repos/michaelgregorius/lmms/tags","blobs_url":"https://api.github.com/repos/michaelgregorius/lmms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michaelgregorius/lmms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michaelgregorius/lmms/git/refs{/sha}","trees_url":"https://api.github.com/repos/michaelgregorius/lmms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michaelgregorius/lmms/statuses/{sha}","languages_url":"https://api.github.com/repos/michaelgregorius/lmms/languages","stargazers_url":"https://api.github.com/repos/michaelgregorius/lmms/stargazers","contributors_url":"https://api.github.com/repos/michaelgregorius/lmms/contributors","subscribers_url":"https://api.github.com/repos/michaelgregorius/lmms/subscribers","subscription_url":"https://api.github.com/repos/michaelgregorius/lmms/subscription","commits_url":"https://api.github.com/repos/michaelgregorius/lmms/commits{/sha}","git_commits_url":"https://api.github.com/repos/michaelgregorius/lmms/git/commits{/sha}","comments_url":"https://api.github.com/repos/michaelgregorius/lmms/comments{/number}","issue_comment_url":"https://api.github.com/repos/michaelgregorius/lmms/issues/comments{/number}","contents_url":"https://api.github.com/repos/michaelgregorius/lmms/contents/{+path}","compare_url":"https://api.github.com/repos/michaelgregorius/lmms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michaelgregorius/lmms/merges","archive_url":"https://api.github.com/repos/michaelgregorius/lmms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michaelgregorius/lmms/downloads","issues_url":"https://api.github.com/repos/michaelgregorius/lmms/issues{/number}","pulls_url":"https://api.github.com/repos/michaelgregorius/lmms/pulls{/number}","milestones_url":"https://api.github.com/repos/michaelgregorius/lmms/milestones{/number}","notifications_url":"https://api.github.com/repos/michaelgregorius/lmms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michaelgregorius/lmms/labels{/name}","releases_url":"https://api.github.com/repos/michaelgregorius/lmms/releases{/id}","deployments_url":"https://api.github.com/repos/michaelgregorius/lmms/deployments","created_at":"2015-04-19T14:44:30Z","updated_at":"2016-01-31T10:35:17Z","pushed_at":"2016-02-02T17:29:18Z","git_url":"git://github.com/michaelgregorius/lmms.git","ssh_url":"git@github.com:michaelgregorius/lmms.git","clone_url":"https://github.com/michaelgregorius/lmms.git","svn_url":"https://github.com/michaelgregorius/lmms","homepage":"http://lmms.io/","size":63014,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"LMMS:master","ref":"master","sha":"87e46d2ed117d8c5fbba51f357e4e3fb5f653774","user":{"login":"LMMS","id":6363159,"avatar_url":"https://avatars.githubusercontent.com/u/6363159?v=3","gravatar_id":"","url":"https://api.github.com/users/LMMS","html_url":"https://github.com/LMMS","followers_url":"https://api.github.com/users/LMMS/followers","following_url":"https://api.github.com/users/LMMS/following{/other_user}","gists_url":"https://api.github.com/users/LMMS/gists{/gist_id}","starred_url":"https://api.github.com/users/LMMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LMMS/subscriptions","organizations_url":"https://api.github.com/users/LMMS/orgs","repos_url":"https://api.github.com/users/LMMS/repos","events_url":"https://api.github.com/users/LMMS/events{/privacy}","received_events_url":"https://api.github.com/users/LMMS/received_events","type":"Organization","site_admin":false},"repo":{"id":15778896,"name":"lmms","full_name":"LMMS/lmms","owner":{"login":"LMMS","id":6363159,"avatar_url":"https://avatars.githubusercontent.com/u/6363159?v=3","gravatar_id":"","url":"https://api.github.com/users/LMMS","html_url":"https://github.com/LMMS","followers_url":"https://api.github.com/users/LMMS/followers","following_url":"https://api.github.com/users/LMMS/following{/other_user}","gists_url":"https://api.github.com/users/LMMS/gists{/gist_id}","starred_url":"https://api.github.com/users/LMMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LMMS/subscriptions","organizations_url":"https://api.github.com/users/LMMS/orgs","repos_url":"https://api.github.com/users/LMMS/repos","events_url":"https://api.github.com/users/LMMS/events{/privacy}","received_events_url":"https://api.github.com/users/LMMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LMMS/lmms","description":"cross-platform music production software","fork":false,"url":"https://api.github.com/repos/LMMS/lmms","forks_url":"https://api.github.com/repos/LMMS/lmms/forks","keys_url":"https://api.github.com/repos/LMMS/lmms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LMMS/lmms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LMMS/lmms/teams","hooks_url":"https://api.github.com/repos/LMMS/lmms/hooks","issue_events_url":"https://api.github.com/repos/LMMS/lmms/issues/events{/number}","events_url":"https://api.github.com/repos/LMMS/lmms/events","assignees_url":"https://api.github.com/repos/LMMS/lmms/assignees{/user}","branches_url":"https://api.github.com/repos/LMMS/lmms/branches{/branch}","tags_url":"https://api.github.com/repos/LMMS/lmms/tags","blobs_url":"https://api.github.com/repos/LMMS/lmms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LMMS/lmms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LMMS/lmms/git/refs{/sha}","trees_url":"https://api.github.com/repos/LMMS/lmms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LMMS/lmms/statuses/{sha}","languages_url":"https://api.github.com/repos/LMMS/lmms/languages","stargazers_url":"https://api.github.com/repos/LMMS/lmms/stargazers","contributors_url":"https://api.github.com/repos/LMMS/lmms/contributors","subscribers_url":"https://api.github.com/repos/LMMS/lmms/subscribers","subscription_url":"https://api.github.com/repos/LMMS/lmms/subscription","commits_url":"https://api.github.com/repos/LMMS/lmms/commits{/sha}","git_commits_url":"https://api.github.com/repos/LMMS/lmms/git/commits{/sha}","comments_url":"https://api.github.com/repos/LMMS/lmms/comments{/number}","issue_comment_url":"https://api.github.com/repos/LMMS/lmms/issues/comments{/number}","contents_url":"https://api.github.com/repos/LMMS/lmms/contents/{+path}","compare_url":"https://api.github.com/repos/LMMS/lmms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LMMS/lmms/merges","archive_url":"https://api.github.com/repos/LMMS/lmms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LMMS/lmms/downloads","issues_url":"https://api.github.com/repos/LMMS/lmms/issues{/number}","pulls_url":"https://api.github.com/repos/LMMS/lmms/pulls{/number}","milestones_url":"https://api.github.com/repos/LMMS/lmms/milestones{/number}","notifications_url":"https://api.github.com/repos/LMMS/lmms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LMMS/lmms/labels{/name}","releases_url":"https://api.github.com/repos/LMMS/lmms/releases{/id}","deployments_url":"https://api.github.com/repos/LMMS/lmms/deployments","created_at":"2014-01-09T20:43:43Z","updated_at":"2016-02-01T11:33:20Z","pushed_at":"2016-02-02T17:29:18Z","git_url":"git://github.com/LMMS/lmms.git","ssh_url":"git@github.com:LMMS/lmms.git","clone_url":"https://github.com/LMMS/lmms.git","svn_url":"https://github.com/LMMS/lmms","homepage":"http://lmms.io/","size":73161,"stargazers_count":674,"watchers_count":674,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":179,"mirror_url":null,"open_issues_count":452,"forks":179,"open_issues":452,"watchers":674,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/2536"},"html":{"href":"https://github.com/LMMS/lmms/pull/2536"},"issue":{"href":"https://api.github.com/repos/LMMS/lmms/issues/2536"},"comments":{"href":"https://api.github.com/repos/LMMS/lmms/issues/2536/comments"},"review_comments":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/2536/comments"},"review_comment":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LMMS/lmms/pulls/2536/commits"},"statuses":{"href":"https://api.github.com/repos/LMMS/lmms/statuses/96d88623ba52c25f5da1e59db3814eb50e4fff69"}}}}