improve edit chain

This commit is contained in:
arm64v8a
2023-01-22 17:53:51 +09:00
parent 8fa966aba4
commit f0b8c4ec02
10 changed files with 59 additions and 9 deletions

View File

@@ -44,13 +44,30 @@ void EditChain::on_select_profile_clicked() {
});
}
void EditChain::AddProfileToListIfExist(int id) {
auto _ent = NekoRay::profileManager->GetProfile(id);
void EditChain::AddProfileToListIfExist(int profileId) {
auto _ent = NekoRay::profileManager->GetProfile(profileId);
if (_ent != nullptr && _ent->type != "chain") {
auto wI = new QListWidgetItem();
wI->setData(114514, profileId);
auto w = new ProxyItem(this, _ent, wI);
wI->setData(114514, id);
ui->listWidget->addItem(wI);
ui->listWidget->setItemWidget(wI, w);
// change button
connect(w->get_change_button(), &QPushButton::clicked, w, [=] {
get_edit_dialog()->hide();
GetMainWindow()->start_select_mode(w, [=](int newId) {
get_edit_dialog()->show();
ReplaceProfile(w, newId);
});
});
}
}
void EditChain::ReplaceProfile(ProxyItem *w, int profileId) {
auto _ent = NekoRay::profileManager->GetProfile(profileId);
if (_ent != nullptr && _ent->type != "chain") {
w->item->setData(114514, profileId);
w->ent = _ent;
w->refresh_data();
}
}