Browse Source

Refactor paste actions of ModuleWidget and RackWidget.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
27ccb2f9a3
2 changed files with 20 additions and 16 deletions
  1. +8
    -5
      src/app/ModuleWidget.cpp
  2. +12
    -11
      src/app/RackWidget.cpp

+ 8
- 5
src/app/ModuleWidget.cpp View File

@@ -738,19 +738,22 @@ void ModuleWidget::pasteClipboardAction() {
json_object_del(moduleJ, "leftModuleId");
json_object_del(moduleJ, "rightModuleId");

// history::ModuleChange
history::ModuleChange* h = new history::ModuleChange;
h->name = "paste module preset";
h->moduleId = module->id;
h->oldModuleJ = toJson();
json_t* oldModuleJ = toJson();

try {
fromJson(moduleJ);
}
catch (Exception& e) {
WARN("%s", e.what());
json_decref(oldModuleJ);
return;
}

// history::ModuleChange
history::ModuleChange* h = new history::ModuleChange;
h->name = "paste module preset";
h->moduleId = module->id;
h->oldModuleJ = oldModuleJ;
h->newModuleJ = toJson();
APP->history->push(h);
}


+ 12
- 11
src/app/RackWidget.cpp View File

@@ -318,23 +318,24 @@ void RackWidget::pastePresetClipboardAction() {
json_object_del(moduleJ, "leftModuleId");
json_object_del(moduleJ, "rightModuleId");

ModuleWidget* mw;
try {
ModuleWidget* mw = moduleWidgetFromJson(moduleJ);
assert(mw);
assert(mw->module);

APP->engine->addModule(mw->module);
addModuleAtMouse(mw);

// history::ModuleAdd
history::ModuleAdd* h = new history::ModuleAdd;
h->setModule(mw);
APP->history->push(h);
mw = moduleWidgetFromJson(moduleJ);
}
catch (Exception& e) {
WARN("%s", e.what());
return;
}
assert(mw);
assert(mw->module);

APP->engine->addModule(mw->module);
addModuleAtMouse(mw);

// history::ModuleAdd
history::ModuleAdd* h = new history::ModuleAdd;
h->setModule(mw);
APP->history->push(h);
}

static void RackWidget_updateExpanders(RackWidget* that) {


Loading…
Cancel
Save