实现策略配置功能

This commit is contained in:
lixiaoyuan
2025-08-28 18:42:37 +08:00
parent 8f6c83147b
commit dda905cda0
47 changed files with 1311 additions and 863 deletions

View File

@@ -13,9 +13,9 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
int x = (1920-width) *0.5;
int y = (1080-height) *0.5;
ui.widget = PvApp::widget(p, pvid, x, y, width, height);
PvApp::label(p, ui.widget, 2, 2, width-4, height-4, "", "background-color: rgb(12,39,58); border: 1px solid rgb(31,145,156);");
PvApp::label(p, ui.widget, 0, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 0 5px 5px;");
PvApp::label(p, ui.widget, width-60, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 5px 5px 0;");
ui.bkg = PvApp::label(p, ui.widget, 2, 2, width-4, height-4, "", "background-color: rgb(12,39,58); border: 1px solid rgb(31,145,156);");
ui.bkgL = PvApp::label(p, ui.widget, 0, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 0 5px 5px;");
ui.bkgR = PvApp::label(p, ui.widget, width-60, 0, 60, height, "", "background-color: transparent; border: 0 solid rgb(42, 149, 245); border-width: 5px 5px 5px 0;");
ui.title = PvApp::label(p, ui.widget, 20, 10, width-20, 30, name, qss::label(20));
PvApp::label(p, ui.widget, 20, 40, width*0.5-20, 3, "", qss::QSS_UNDERLINE);
@@ -24,12 +24,12 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
int x = (width- w*2 - offset) *0.5;
int y = height - h - 40;
int btnOk = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnOk, [=](std::string) {
ui.btnOK = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnOK, [=](std::string) {
if (callbackConfirm) { callbackConfirm(); }
});
int btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
PvApp::bind(p, PvEvent::BUTTON_EVENT, btnCancel, [=](std::string) {
ui.btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
PvApp::bind(p, PvEvent::BUTTON_EVENT, ui.btnCancel, [=](std::string) {
this->show(false);
});
}
@@ -43,20 +43,21 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
mapLines[key] = line;
PvApp::label(p, ui.widget, x, y, lineKeyWidth, lineHeight, title, qss::label(15));
if (type == "lineEdit")
if (type == "textedit")
{
line->widget = PvApp::lineEdit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, "");
line->widget = PvApp::textedit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, "");
}
else if (type == "combox")
{
line->widget = PvApp::combox(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, {});
}
else if (type == "textEdit")
else if (type == "multiTextedit")
{
line->widget = PvApp::textEdit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight*4, "");
line->widget = PvApp::multiTextedit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight*4, "");
}
PvApp::bind(p, PvEvent::TEXT_EVENT, line->widget, [=](std::string text) {
line->val = text;
if (callbackTextEvent) callbackTextEvent(key, text);
});
if (!editable) { pvSetEnabled(p, line->widget, 0); }
return line;
@@ -64,12 +65,12 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
void PvPopWidget::addParamLineEdit(std::string key, std::string title, int x, int y, bool editable/*= true*/)
{
this->addParamLine("lineEdit", key, title, x, y, editable);
this->addParamLine("textedit", key, title, x, y, editable);
}
void PvPopWidget::addParamTextEdit(std::string key, std::string title, int x, int y, bool editable/* = true*/)
{
this->addParamLine("textEdit", key, title, x, y, editable);
this->addParamLine("multiTextedit", key, title, x, y, editable);
}
void PvPopWidget::addParamCombox(std::string key, std::string title, int x, int y, std::vector<std::string> items)
@@ -103,6 +104,8 @@ void PvPopWidget::setParamText(std::shared_ptr<ParamLine> line, std::string text
line->val = line->items[0];
pvSetCurrentItem(p, line->widget, 0);
}
// 【注意】combox 设置 item 不会触发 TEXT_EVENT
//if (callbackTextEvent) callbackTextEvent(line->key, line->val);
}
else
{
@@ -194,4 +197,20 @@ void PvPopWidget::setPrimaryKeys(std::vector<std::string> keys)
{
primaryKeys.set(k, "");
}
}
void PvPopWidget::resize(int width, int height)
{
int x = (1920-width) *0.5;
int y = (1080-height) *0.5;
pvSetGeometry(p, ui.widget, x, y, width, height);
pvSetGeometry(p, ui.bkg, 2, 2, width-4, height-4);
pvSetGeometry(p, ui.bkgL, 0, 0, 60, height);
pvSetGeometry(p, ui.bkgR, width-60, 0, 60, height);
int w = 100, h = 40, offset = 50;
x = (width- w*2 - offset) *0.5;
y = height - h - 40;
pvSetGeometry(p, ui.btnOK, x, y, w, h);
pvSetGeometry(p, ui.btnCancel, x+w+offset, y, w, h);
}