Browse Source

Add PatchManager::loadPathDialog() for dragging a file to the Rack window.

tags/v1.1.2
Andrew Belt 5 years ago
parent
commit
e6e7f33256
3 changed files with 14 additions and 5 deletions
  1. +1
    -0
      include/patch.hpp
  2. +4
    -5
      src/app/Scene.cpp
  3. +9
    -0
      src/patch.cpp

+ 1
- 0
include/patch.hpp View File

@@ -24,6 +24,7 @@ struct PatchManager {
void saveTemplateDialog();
bool load(std::string path);
void loadDialog();
void loadPathDialog(std::string path);
/** If `lastPath` is defined, ask the user to reload it */
void revertDialog();
/** Disconnects all cables */


+ 4
- 5
src/app/Scene.cpp View File

@@ -156,17 +156,16 @@ void Scene::onHoverKey(const event::HoverKey &e) {
}

void Scene::onPathDrop(const event::PathDrop &e) {
OpaqueWidget::onPathDrop(e);
if (e.isConsumed())
return;

if (e.paths.size() >= 1) {
const std::string &path = e.paths[0];
if (string::filenameExtension(string::filename(path)) == "vcv") {
APP->patch->load(path);
APP->patch->loadPathDialog(path);
e.consume(this);
return;
}
}

OpaqueWidget::onPathDrop(e);
}




+ 9
- 0
src/patch.cpp View File

@@ -218,6 +218,15 @@ void PatchManager::loadDialog() {
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() {
if (path.empty())
return;


Loading…
Cancel
Save