qstring multi-arg, connect/action context object, signal qualification

master
Zithia Satazaki 2022-03-28 17:13:33 -04:00
parent 22b06c465a
commit 95c0af06be
7 changed files with 11 additions and 11 deletions

View File

@ -182,7 +182,7 @@ void BeatPad::initUI(NodeUIScene* scene) {
auto c = f->second; auto c = f->second;
QString n; QString n;
if (auto smp = c->smp.lock(); smp) n = smp->name.section('/', -1, -1); if (auto smp = c->smp.lock(); smp) n = smp->name.section('/', -1, -1);
v.push_back({ f->first, qs("%1 %2").arg(Util::noteName(i)).arg(n) }); v.push_back({ f->first, qs("%1 %2").arg(Util::noteName(i), n) });
} }
} }
return v; return v;
@ -197,7 +197,7 @@ void BeatPad::initUI(NodeUIScene* scene) {
for (int16_t i = 0; i < 12; i++) { for (int16_t i = 0; i < 12; i++) {
int16_t n = oct*12+i; int16_t n = oct*12+i;
if (auto f = cfg.find(n); f != cfg.end()) mo->addAction(Util::noteName(n))->setDisabled(true); if (auto f = cfg.find(n); f != cfg.end()) mo->addAction(Util::noteName(n))->setDisabled(true);
else mo->addAction(Util::noteName(n), [=] { state->selectNote(n); }); else mo->addAction(Util::noteName(n), m, [=] { state->selectNote(n); });
} }
} }
}; };
@ -217,7 +217,7 @@ void BeatPad::initUI(NodeUIScene* scene) {
sampleSelector->setSample(smp); sampleSelector->setSample(smp);
gain->bind(state->cfg->gain); gain->bind(state->cfg->gain);
noteSelector->setEntry({n, qs("%1 %2").arg(Util::noteName(n)).arg(smp ? smp->name.section('/', -1, -1) : "")}, false); noteSelector->setEntry({n, qs("%1 %2").arg(Util::noteName(n), smp ? smp->name.section('/', -1, -1) : "")}, false);
}; };
state->setSample = [=](std::shared_ptr<Sample> smp) { state->setSample = [=](std::shared_ptr<Sample> smp) {
state->cfg->smp = smp; state->cfg->smp = smp;
@ -225,7 +225,7 @@ void BeatPad::initUI(NodeUIScene* scene) {
if (smp) cfg[n] = state->cfg; if (smp) cfg[n] = state->cfg;
else if (auto f = cfg.find(n); f != cfg.end()) cfg.erase(f); else if (auto f = cfg.find(n); f != cfg.end()) cfg.erase(f);
noteSelector->setEntry({n, qs("%1 %2").arg(Util::noteName(n)).arg(smp ? smp->name : "")}, false); noteSelector->setEntry({n, qs("%1 %2").arg(Util::noteName(n), smp ? smp->name : "")}, false);
}; };
//ol->updateGeometry(); //ol->updateGeometry();

View File

@ -128,7 +128,7 @@ void Capaxitor::onGadgetCreated() {
KnobGadget::autoCreate(l, adsr); KnobGadget::autoCreate(l, adsr);
QObject::connect(sampleSelector, &SampleSelectorGadget::sampleSelected, [=](auto smp) { this->smp = smp; }); QObject::connect(sampleSelector, &SampleSelectorGadget::sampleSelected, sampleSelector, [=](auto smp) { this->smp = smp; });
} }
void Capaxitor::onDoubleClick() { emit project->socket->openNodeUI(this); } void Capaxitor::onDoubleClick() { emit project->socket->openNodeUI(this); }

View File

@ -122,7 +122,7 @@ void SampleSelectorGadget::buildSubmenu(DirectoryNode* dir, QMenu* menu) {
wfp->setMinimumSize(192, 48); wfp->setMinimumSize(192, 48);
menu->addAction(wa); menu->addAction(wa);
if (s == smp) wa->setDisabled(true); if (s == smp) wa->setDisabled(true);
else connect(wa, &QWidgetAction::triggered, [this, s] { setSample(s); }); else connect(wa, &QWidgetAction::triggered, this, [this, s] { setSample(s); });
} }
} }
} }
@ -135,7 +135,7 @@ void SampleSelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) {
auto* m = new QMenu(); auto* m = new QMenu();
if (project->samples.empty()) m->addAction("(no samples in project)")->setDisabled(true); if (project->samples.empty()) m->addAction("(no samples in project)")->setDisabled(true);
else { else {
m->addAction("(no sample)", [this] { setSample(nullptr); }); m->addAction("(no sample)", this, [this] { setSample(nullptr); });
m->addSeparator(); m->addSeparator();
DirectoryNode root; DirectoryNode root;
for (auto s : project->samples) root.placeData(s->name, s->uuid); for (auto s : project->samples) root.placeData(s->name, s->uuid);

View File

@ -60,7 +60,7 @@ void SelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) {
for (auto e : v) { for (auto e : v) {
if (_entry.first == e.first) { if (_entry.first == e.first) {
m->addAction(e.second)->setDisabled(true); m->addAction(e.second)->setDisabled(true);
} else m->addAction(e.second, [this, e] { } else m->addAction(e.second, this, [this, e] {
setEntry(e); setEntry(e);
}); });
} }

View File

@ -47,6 +47,6 @@ namespace Xybrid::UI {
inline SelectorGadget* setEditFunc(const std::function<void(QMenu*)>& f) { fEditMenu = f; return this; } inline SelectorGadget* setEditFunc(const std::function<void(QMenu*)>& f) { fEditMenu = f; return this; }
signals: signals:
void onSelect(const Entry&); void onSelect(const Xybrid::UI::SelectorGadget::Entry&);
}; };
} }

View File

@ -152,7 +152,7 @@ void PatchboardScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* e) {
addItem(new NodeObject(n)); addItem(new NodeObject(n));
}, graph.get()); }, graph.get());
m->addAction("Import...", [this, p] { m->addAction("Import...", this, [this, p] {
if (auto fileName = FileOps::showOpenDialog(nullptr, "Import node...", Config::Directories::presets, FileOps::Filter::node); !fileName.isEmpty()) { if (auto fileName = FileOps::showOpenDialog(nullptr, "Import node...", Config::Directories::presets, FileOps::Filter::node); !fileName.isEmpty()) {
auto n = FileOps::loadNode(fileName, graph); auto n = FileOps::loadNode(fileName, graph);
if (!n) return; // right, that can return null if (!n) return; // right, that can return null

View File

@ -401,7 +401,7 @@ void PatternEditorView::headerContextMenu(QPoint pt) {
}); });
if (idx < hdr->count() - 1) { if (idx < hdr->count() - 1) {
menu->addAction("Delete Channel", this, [this, idx, p]() { menu->addAction("Delete Channel", this, [this, idx, p]() {
if (QMessageBox::warning(this, "Are you sure?", QString("Remove channel %1 from pattern %2?").arg(Util::numAndName(idx, p->channel(idx).name)).arg(Util::numAndName(p->index, p->name)), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return; if (QMessageBox::warning(this, "Are you sure?", QString("Remove channel %1 from pattern %2?").arg(Util::numAndName(idx, p->channel(idx).name), Util::numAndName(p->index, p->name)), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return;
(new PatternChannelDeleteCommand(p, idx))->commit(); (new PatternChannelDeleteCommand(p, idx))->commit();
}); });
menu->addAction("Rename Channel...", this, [this, idx, p]() { menu->addAction("Rename Channel...", this, [this, idx, p]() {