@@ -24,6 +24,7 @@ struct PatchManager { | |||||
void saveTemplateDialog(); | void saveTemplateDialog(); | ||||
bool load(std::string path); | bool load(std::string path); | ||||
void loadDialog(); | void loadDialog(); | ||||
void loadPathDialog(std::string path); | |||||
/** If `lastPath` is defined, ask the user to reload it */ | /** If `lastPath` is defined, ask the user to reload it */ | ||||
void revertDialog(); | void revertDialog(); | ||||
/** Disconnects all cables */ | /** Disconnects all cables */ | ||||
@@ -156,17 +156,16 @@ void Scene::onHoverKey(const event::HoverKey &e) { | |||||
} | } | ||||
void Scene::onPathDrop(const event::PathDrop &e) { | void Scene::onPathDrop(const event::PathDrop &e) { | ||||
OpaqueWidget::onPathDrop(e); | |||||
if (e.isConsumed()) | |||||
return; | |||||
if (e.paths.size() >= 1) { | if (e.paths.size() >= 1) { | ||||
const std::string &path = e.paths[0]; | const std::string &path = e.paths[0]; | ||||
if (string::filenameExtension(string::filename(path)) == "vcv") { | if (string::filenameExtension(string::filename(path)) == "vcv") { | ||||
APP->patch->load(path); | |||||
APP->patch->loadPathDialog(path); | |||||
e.consume(this); | e.consume(this); | ||||
return; | |||||
} | } | ||||
} | } | ||||
OpaqueWidget::onPathDrop(e); | |||||
} | } | ||||
@@ -218,6 +218,15 @@ void PatchManager::loadDialog() { | |||||
APP->history->setSaved(); | APP->history->setSaved(); | ||||
} | } | ||||
void PatchManager::loadPathDialog(std::string path) { | |||||
if (!promptClear("The current patch is unsaved. Clear it and open the new patch?")) | |||||
return; | |||||
load(path); | |||||
this->path = path; | |||||
APP->history->setSaved(); | |||||
} | |||||
void PatchManager::revertDialog() { | void PatchManager::revertDialog() { | ||||
if (path.empty()) | if (path.empty()) | ||||
return; | return; | ||||