实现HTTP服务架构

This commit is contained in:
lixiaoyuan
2025-08-31 14:38:53 +08:00
parent 4af4e670d2
commit e0b64a20c4
46 changed files with 1436 additions and 545 deletions

View File

@@ -27,10 +27,10 @@ int MaskMain::initUI()
PvApp::label(p, PV_ID_MAIN, 0, 0, 1920, 1080, "", "background-color: rgb(1, 32, 54)");
PvApp::image(p, 0, 0, 0, 1920, 90, "bkgHead.png");
ui.datetime = PvApp::label(p, PV_ID_MAIN, 10, 30, 420, 30, GetDateTimeWeekday(), qss::label(20));
ui.datetime = PvApp::label(p, PV_ID_MAIN, 10, 30, 420, 30, GetDateTimeWeekday(), QSS::label(20));
pvSetAlignment(p, ui.datetime, AlignCenter);
int idStationTitle = PvApp::label(p, 0, 620, 0, 660, 90, "能源站监控与运行管理系统", qss::label(48));
int idStationTitle = PvApp::label(p, 0, 620, 0, 660, 90, "能源站监控与运行管理系统", QSS::label(48));
pvSetAlignment(p, idStationTitle, AlignCenter);
// 初始化子页面
@@ -81,7 +81,7 @@ int MaskMain::initUI()
std::string& title = vecMenuItems[i];
EPvCode statusTmp = PvApp::getPvCode(title);
int x = x0 + (w+margin)*i;
int id = PvApp::button(p, 0, x, y, w, h, title, (statusTmp == pvcode_) ? qss::BTN_ACTIVE : qss::BTN);
int id = PvApp::button(p, 0, x, y, w, h, title, (statusTmp == pvcode_) ? QSS::BTN_ACTIVE : QSS::BTN);
mapMenuInfo_[id] = std::make_pair(title, statusTmp);
}
}

View File

@@ -160,38 +160,38 @@ int PvApp::widget(PARAM* p, int parent, int x, int y, int w, int h)
return id;
}
int PvApp::label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
static const std::string style = "QLabel { border: none; background-color: transparent; } QLabel:disabled { color: gray;}";
int id = PvApp::pvid(p);
pvQLabel(p, id, parent);
pvSetGeometry(p, id, x, y, w, h);
if (!text.empty()) { pvSetText(p, id, text.c_str()); }
pvSetStyleSheet(p, id, qss.empty() ? style.c_str() : qss.c_str());
pvSetStyleSheet(p, id, QSS.empty() ? style.c_str() : QSS.c_str());
return id;
}
int PvApp::labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
int id = PvApp::label(p, parent, x, y, w, h, text, qss);
int id = PvApp::label(p, parent, x, y, w, h, text, QSS);
pvSetAlignment(p, id, AlignCenter);
return id;
}
int PvApp::labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
int id = PvApp::label(p, parent, x, y, w, h, text, qss);
int id = PvApp::label(p, parent, x, y, w, h, text, QSS);
pvSetAlignment(p, id, AlignCenter);
return id;
}
int PvApp::button(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::button(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
int id = PvApp::pvid(p);
pvQPushButton(p, id, parent);
pvSetGeometry(p, id, x, y, w, h);
if (!text.empty()) { pvSetText(p, id, text.c_str()); }
pvSetStyleSheet(p, id, qss.empty() ? qss::button().c_str() : qss.c_str());
pvSetStyleSheet(p, id, QSS.empty() ? QSS::button().c_str() : QSS.c_str());
return id;
}
@@ -208,7 +208,7 @@ int PvApp::combox(PARAM* p, int parent, int x, int y, int w, int h, const std::v
int id = PvApp::pvid(p);
pvQComboBox(p, id, parent, 0, 0);
pvSetGeometry(p, id, x, y, w, h);
pvSetStyleSheet(p, id, qss::COMBOX_14.c_str());
pvSetStyleSheet(p, id, QSS::COMBOX_14.c_str());
for (int i=0; i<vecItems.size(); ++i)
{
pvInsertItem(p, id, i, NULL, vecItems[i].c_str());
@@ -218,17 +218,17 @@ int PvApp::combox(PARAM* p, int parent, int x, int y, int w, int h, const std::v
return id;
}
int PvApp::textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
int id = PvApp::pvid(p);
pvQLineEdit(p, id, parent);
pvSetGeometry(p, id, x, y, w, h);
pvSetStyleSheet(p, id, qss::LINEEDIT.c_str());
pvSetStyleSheet(p, id, QSS::LINEEDIT.c_str());
if (!text.empty()) { pvSetText(p, id, text.c_str()); }
return id;
}
int PvApp::multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss)
int PvApp::multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS)
{
static std::string style =
"QTextEdit { background-color: rgb(12, 39, 58); border: 1px solid rgb(18, 251, 255); border-radius: 3px; color:white; font: bold 14px;}"
@@ -270,13 +270,13 @@ int PvApp::timeEdit(PARAM* p, int parent, int x, int y, int w, int h)
int PvApp::lineLabel(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val)
{
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, qss::label(14));
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, QSS::label(14));
return PvApp::label(p, pid, w, 0, rect.w-w, rect.h, val);
}
int PvApp::lineTextedit(PARAM* p, int parent, PvRect& rect, int w, std::string key, std::string val)
{
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, qss::label(14));
int pid = PvApp::label(p, parent, rect.x, rect.y, rect.w, rect.h, key, QSS::label(14));
return PvApp::textedit(p, pid, w, 0, rect.w-w, rect.h, val);
}

View File

@@ -136,21 +136,21 @@ public:
static int widget(PARAM* p, int parent, int x, int y, int w, int h);
static int label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int label(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int labelCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int labelAlignCenter(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int button(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int button(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int image(PARAM* p, int parent, int x, int y, int w, int h, const char* filename);
static int combox(PARAM* p, int parent, int x, int y, int w, int h, const std::vector<std::string>& vecItems, int index=0);
static int textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int textedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string qss = "");
static int multiTextedit(PARAM* p, int parent, int x, int y, int w, int h, std::string text, std::string QSS = "");
static int radioButton(PARAM* p, int parent, int x, int y, int w, int h, std::string text);

View File

@@ -249,8 +249,8 @@ PvChartCurve::PvChartCurve(PARAM* p, int parent, int x, int y, int w, int h) : P
void PvChartCurve::setBackground(PARAM* p, int r, int g, int b)
{
qpwSetCanvasBackground(p, plotId_, r, g, b);
std::string qss = "border: none; border-radius: 0px; background-color: " + PvColor(r, g, b).rgb() + ";";
pvSetStyleSheet(p, pvid_, qss.c_str());
std::string QSS = "border: none; border-radius: 0px; background-color: " + PvColor(r, g, b).rgb() + ";";
pvSetStyleSheet(p, pvid_, QSS.c_str());
}
void PvChartCurve::setLabelYLeft(std::string title, float min, float max, float step)

View File

@@ -17,24 +17,24 @@ PvPopWidget::PvPopWidget(PARAM* p, int width, int height, std::string name)
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);
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);
{
int w = 100, h = 40, offset = 50;
int x = (width- w*2 - offset) *0.5;
int y = height - h - 40;
ui.btnOK = PvApp::button(p, ui.widget, x, y, w, h, "确定", qss::BTN_CONFIRM);
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(); }
});
ui.btnCancel = PvApp::button(p, ui.widget, x+w+offset, y, w, h, "取消", qss::BTN_CANCEL);
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);
});
}
ui.msg = PvApp::label(p, ui.widget, 50, height-110, width-100, 24, "", qss::label(14, "red"));
ui.msg = PvApp::label(p, ui.widget, 50, height-110, width-100, 24, "", QSS::label(14, "red"));
}
std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string type, std::string key, std::string title, int x, int y, bool editable/* = true*/)
@@ -42,7 +42,7 @@ std::shared_ptr<PvPopWidget::ParamLine> PvPopWidget::addParamLine(std::string ty
auto line = std::make_shared<ParamLine>(type, key);
mapLines[key] = line;
PvApp::label(p, ui.widget, x, y, lineKeyWidth, lineHeight, title, qss::label(15));
PvApp::label(p, ui.widget, x, y, lineKeyWidth, lineHeight, title, QSS::label(15));
if (type == "textedit")
{
line->widget = PvApp::textedit(p, ui.widget, x+lineKeyWidth, y, lineValWidth, lineHeight, "");

View File

@@ -6,7 +6,7 @@ std::string BUTTON()
return "";
}
namespace qss
namespace QSS
{
std::string label(int fontSize, std::string color, std::string bkgcolor, std::string border)
{
@@ -44,11 +44,11 @@ namespace qss
return ss.str();
}
const std::string LABEL_BKG_1 = qss::label(14, "", "rgb(5, 47, 77)", "none; border-radius:5px");
const std::string LABEL_BKG_1 = QSS::label(14, "", "rgb(5, 47, 77)", "none; border-radius:5px");
const std::string LABEL_BKG_2 = qss::label(14, "", "rgb(8, 54, 91)", "none; border-radius:5px");
const std::string LABEL_BKG_2 = QSS::label(14, "", "rgb(8, 54, 91)", "none; border-radius:5px");
const std::string LABEL_BOX = qss::label(16, "", "rgba(200,200,200,20)", "none; border-radius:2px")
const std::string LABEL_BOX = QSS::label(16, "", "rgba(200,200,200,20)", "none; border-radius:2px")
+ "QLabel:hover {border: 1px solid rgb(1, 183, 209);}";
const std::string QSS_BOX_ACTIVE =
@@ -56,10 +56,10 @@ namespace qss
"QLabel:hover {border: 1px solid rgb(1, 183, 209);}"
"QLabel:disabled { color:rgb(150,150,150);}";
const std::string LABEL_TITLE = qss::label(16, "rgb(99, 196, 216)", "", "none; padding-top: 0px;");
const std::string LABEL_TITLE = QSS::label(16, "rgb(99, 196, 216)", "", "none; padding-top: 0px;");
const std::string LABEL_KEY = qss::label(13, "rgb(180,180,180)", "", "");
const std::string LABEL_VAL = qss::label(14, "", "", "");
const std::string LABEL_KEY = QSS::label(13, "rgb(180,180,180)", "", "");
const std::string LABEL_VAL = QSS::label(14, "", "", "");
const std::string BTN =
"QPushButton { background-color:rgb(4, 96, 142);border-radius:10px;border:0px solid rgb(10,120,215);color:white;font:bold 18px;}"
@@ -133,16 +133,16 @@ namespace qss
///////////////////////////////////////////////////////////////////////////////////////////////////
/// === 表格
const std::string QSS_TABLE =
qss::label(15, "", "rgb(7, 46, 74)", "1px solid rgb(28, 121, 122)");
QSS::label(15, "", "rgb(7, 46, 74)", "1px solid rgb(28, 121, 122)");
// 表头标签
const std::string QSS_TABLE_HEAD =
qss::label(14, "", "rgb(18, 93, 113)", "1px solid rgb(120, 120, 120); border-style:inset solid");
QSS::label(14, "", "rgb(18, 93, 113)", "1px solid rgb(120, 120, 120); border-style:inset solid");
//"background-color: rgb(18, 93, 113); color:rgb(255, 255, 255); font:bold 16px;"
//"border-width:1 1 1 1px; border-style:inset solid; border-color:rgb(120, 120, 120);";
// 单元格
const std::string QSS_TABLE_CELL = qss::label(14, "", "", "none; padding-left: 10px");
const std::string QSS_TABLE_CELL = QSS::label(14, "", "", "none; padding-left: 10px");
const std::string QSS_TABLE_BTN_VIEW =
"QPushButton { background-color: rgb(7, 46, 74); color:white; border-radius:2px; border:none; font:bold 14px;}"

View File

@@ -1,7 +1,7 @@
#pragma once
#include <string>
namespace qss
namespace QSS
{
std::string label(int fontSize = 14, std::string color = "", std::string bkgcolor = "", std::string border = "");
@@ -23,8 +23,6 @@ namespace qss
extern const std::string LINEEDIT;
extern const std::string QSS_BOX_ACTIVE;
extern const std::string LABEL_TITLE;

View File

@@ -20,7 +20,7 @@ PvTable::PvTable(PARAM* p, int parent, int x, int y, int w, int irow, Options& o
pvid = PvApp::widget(p, parent, x, y, w, h+1);
// 表格的背景色和边框样式
PvApp::label(p, pvid, 0, 0, w, h+1, "", qss::QSS_TABLE);
PvApp::label(p, pvid, 0, 0, w, h+1, "", QSS::QSS_TABLE);
vecHeads.resize(0);
vecRows.resize(nrow);
@@ -30,8 +30,8 @@ PvTable::PvTable(PARAM* p, int parent, int x, int y, int w, int irow, Options& o
for (int row = 0; row < nrow; row++)
{
int y = row * option.row_height + (option.show_header ? option.head_height : 0);
string qss = (row % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1;
int widgetRow = PvApp::label(p, pvid, 1, y, rect.w-2, option.row_height, "", qss);
string QSS = (row % 2 != 0) ? QSS::QSS_TABLE_ROW_0 : QSS::QSS_TABLE_ROW_1;
int widgetRow = PvApp::label(p, pvid, 1, y, rect.w-2, option.row_height, "", QSS);
pvHide(p, widgetRow);
vecRows[row].widget = widgetRow;
}
@@ -48,13 +48,13 @@ void PvTable::addHead(string id, string text, int width, vector<pair<string, str
// 创建表头的标签
if (option.show_header)
{
vecHeads[col].pvid = PvApp::label(p, pvid, posCol, 0, width, option.head_height, text, qss::QSS_TABLE_HEAD);
vecHeads[col].pvid = PvApp::label(p, pvid, posCol, 0, width, option.head_height, text, QSS::QSS_TABLE_HEAD);
}
// 创建列的单元格
for (int row = 0; row < nrow; ++row)
{
int cellId = PvApp::label(p, vecRows[row].widget, posCol, 0, width, option.row_height, "", qss::QSS_TABLE_CELL);
int cellId = PvApp::label(p, vecRows[row].widget, posCol, 0, width, option.row_height, "", QSS::QSS_TABLE_CELL);
vecRows[row].vecCells.push_back(cellId);
PvApp::bind(p, MOUSE_OVER_EVENT, cellId, [=](string s) { highlight(row, (s == "1")); });
}
@@ -97,11 +97,11 @@ void PvTable::setRowVisible(int irow, bool v)
void PvTable::highlight(int irow, bool v)
{
string qss = ((irow % 2 != 0) ? qss::QSS_TABLE_ROW_0 : qss::QSS_TABLE_ROW_1);
string QSS = ((irow % 2 != 0) ? QSS::QSS_TABLE_ROW_0 : QSS::QSS_TABLE_ROW_1);
if (vecRows.size() > 0 && irow <= vecRows.size())
{
if (v) { qss = "background-color:rgba(14,45,60,200);border:1px solid rgba(255,0,0,100);"; }
pvSetStyleSheet(p, vecRows[irow].widget, qss.c_str());
if (v) { QSS = "background-color:rgba(14,45,60,200);border:1px solid rgba(255,0,0,100);"; }
pvSetStyleSheet(p, vecRows[irow].widget, QSS.c_str());
}
}
@@ -110,11 +110,11 @@ void PvTable::addOperate(vector<string> vecOpt)
// 创建表头的标签
if (option.show_header)
{
PvApp::label(p, pvid, posCol, 0, rect.w - posCol, option.head_height, "操作", qss::QSS_TABLE_HEAD);
PvApp::label(p, pvid, posCol, 0, rect.w - posCol, option.head_height, "操作", QSS::QSS_TABLE_HEAD);
}
for (int row = 0; row < nrow; ++row)
{
int cellWidget = PvApp::label(p, vecRows[row].widget, posCol, 0, rect.w - posCol, option.row_height, "", qss::QSS_TABLE_CELL);
int cellWidget = PvApp::label(p, vecRows[row].widget, posCol, 0, rect.w - posCol, option.row_height, "", QSS::QSS_TABLE_CELL);
vecOper.push_back({ cellWidget, vector<int>() });
auto& vec_opt_btn_ = vecOper.back().second;
int x = 5, w = 60;
@@ -122,7 +122,7 @@ void PvTable::addOperate(vector<string> vecOpt)
{
auto& title = vecOpt[i];
w = 20 + 15 * title.size() / 3;
int btn = PvApp::button(p, cellWidget, x, 4, w, 24, title, qss::button(14, "", "", "none; border-radius: 0px"));
int btn = PvApp::button(p, cellWidget, x, 4, w, 24, title, QSS::button(14, "", "", "none; border-radius: 0px"));
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
if (callbackOper) { callbackOper(row, 0, title); }
});
@@ -239,7 +239,7 @@ PvPagination::PvPagination(PARAM* p, int parent, int x, int y, int n)
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](string) { this->activePage(i, true); });
}
btnNext = PvApp::button(p, pvid, 32, 0, 30, 30, ">", STYLE_NORMAL);
labelInfo = PvApp::label(p, pvid, 2*32, 0, 80, 30, " 共0页", qss::label(14, "rgb(27, 220, 224)"));
labelInfo = PvApp::label(p, pvid, 2*32, 0, 80, 30, " 共0页", QSS::label(14, "rgb(27, 220, 224)"));
pvSetEnabled(p, btnPrev, 0);
pvSetEnabled(p, btnNext, 0);

View File

@@ -4,9 +4,9 @@
static int CreatePanel(PARAM* p, int parentId, int x, int y, int w, int h, std::string title)
{
int id = PvApp::label(p, parentId, x, y, w, h, "", qss::LABEL_BKG_2);
PvApp::label(p, id, 10, 10, w, 20, title, qss::STYLE_TITLE_ICON);
PvApp::label(p, id, 20, 30, w, 2, "", qss::QSS_UNDERLINE);
int id = PvApp::label(p, parentId, x, y, w, h, "", QSS::LABEL_BKG_2);
PvApp::label(p, id, 10, 10, w, 20, title, QSS::STYLE_TITLE_ICON);
PvApp::label(p, id, 20, 30, w, 2, "", QSS::QSS_UNDERLINE);
return id;
}

View File

@@ -19,9 +19,9 @@ void TestPage(PARAM* p)
static int CreatePanel(PARAM* p, int parent, int x, int y, int w, int h, std::string title)
{
int panelId = PvApp::label(p, parent, x, y, w, h, "", qss::LABEL_BKG_1);
int titleId = PvApp::label(p, panelId, 10, 8, w, 22, title, qss::STYLE_TITLE_ICON);
PvApp::label(p, panelId, 20, 28, w, 2, "", qss::QSS_UNDERLINE);
int panelId = PvApp::label(p, parent, x, y, w, h, "", QSS::LABEL_BKG_1);
int titleId = PvApp::label(p, panelId, 10, 8, w, 22, title, QSS::STYLE_TITLE_ICON);
PvApp::label(p, panelId, 20, 28, w, 2, "", QSS::QSS_UNDERLINE);
return panelId;
}
@@ -35,7 +35,7 @@ static int CreatePanel1(PARAM* p, int parent, int x, int y, int w, int h, std::s
static int CreateCard1(PARAM* p, int parentId, int x, int y, int w, int h, std::string title, std::string val)
{
int id = PvApp::label(p, parentId, x, y, w, h, "", qss::LABEL_BKG_1);
int id = PvApp::label(p, parentId, x, y, w, h, "", QSS::LABEL_BKG_1);
int idTitle = PvApp::label(p, id, 0, h*0.5, w, h*0.5, title, "background:transparent; font: bold 28px;");
int idVal = PvApp::label(p, id, 0, 0, w, h*0.5, val, "background:transparent; font: bold 28px; color:rgb(77,215,240);");
pvSetAlignment(p, idTitle, AlignCenter);
@@ -45,7 +45,7 @@ static int CreateCard1(PARAM* p, int parentId, int x, int y, int w, int h, std::
static int CreateCard2(PARAM* p, int parent, int x, int y, int w, int h, std::string title, std::string val)
{
int id = PvApp::label(p, parent, x, y, w, h, "", qss::LABEL_BKG_1);
int id = PvApp::label(p, parent, x, y, w, h, "", QSS::LABEL_BKG_1);
int idTitle = PvApp::label(p, id, 0, 0, w, h*0.5, title);
int idVal = PvApp::label(p, id, 0, h*0.5, w, h*0.5, val, "background:transparent; font: bold 16px; color:rgb(77,215,240);");
@@ -59,15 +59,15 @@ static int CreateBox(PARAM* p, int parent, int x, int y, int w, int h, std::stri
int id = PvApp::label(p, parent, x, y, w, h, "", "border-radius:0px; background-color: rgb(7, 45, 66); border: 1px solid rgb(27, 88, 105);");
{
int len = 10;
std::string qss = "background-color: transparent; border: 1px solid rgb(0, 218, 216);";
PvApp::label(p, id, 0, 0, len, len, "", qss + "border-width: 2px 0 0 2px");
PvApp::label(p, id, w-len, 0, len, len, "", qss + "border-width: 2px 2px 0 0");
PvApp::label(p, id, w-len, h-len, len, len, "", qss + "border-width: 0 2px 2px 0");
PvApp::label(p, id, 0, h-len, len, len, "", qss + "border-width: 0 0 2px 2px");
std::string QSS = "background-color: transparent; border: 1px solid rgb(0, 218, 216);";
PvApp::label(p, id, 0, 0, len, len, "", QSS + "border-width: 2px 0 0 2px");
PvApp::label(p, id, w-len, 0, len, len, "", QSS + "border-width: 2px 2px 0 0");
PvApp::label(p, id, w-len, h-len, len, len, "", QSS + "border-width: 0 2px 2px 0");
PvApp::label(p, id, 0, h-len, len, len, "", QSS + "border-width: 0 0 2px 2px");
}
// "border:none; background-color: transparent; font: bold 14px; padding-bottom: 0px;"
int titleId = PvApp::label(p, id, 0, 0, w, h*0.5-2, k);
int valId = PvApp::label(p, id, 0, h*0.5+2, w, h*0.5-2, val, qss::label(16, "rgb(77, 215, 240)"));
int valId = PvApp::label(p, id, 0, h*0.5+2, w, h*0.5-2, val, QSS::label(16, "rgb(77, 215, 240)"));
pvSetAlignment(p, titleId, AlignHCenter | AlignBottom);
pvSetAlignment(p, valId, AlignHCenter | AlignTop);
return valId;
@@ -276,7 +276,7 @@ int MaskPageHome::initUI(EPvCode pvcode)
// 中间区域
{
int panel = PvApp::label(p, 0, x = 10+500+10, y, w = 880, h1+h2+h3+20, "", qss::LABEL_BKG_1);
int panel = PvApp::label(p, 0, x = 10+500+10, y, w = 880, h1+h2+h3+20, "", QSS::LABEL_BKG_1);
////// 饼图
//int left = PvApp::widget(p, panel, 100, 100, 100, 100);
@@ -298,7 +298,7 @@ int MaskPageHome::initUI(EPvCode pvcode)
auto popStation = new PopStation(p);
popStation->show(0);
int btn = PvApp::button(p, panel, 10, 20, 100, 30, "场站一", qss::BTN);
int btn = PvApp::button(p, panel, 10, 20, 100, 30, "场站一", QSS::BTN);
PvApp::bind(p, PvEvent::BUTTON_EVENT, btn, [=](std::string) {
popStation->setStatus("场站一");
pvShow(p, popStation->widget);

View File

@@ -8,8 +8,8 @@
static int CreateParamLabel(PARAM* p, int parent, int x, int y, std::string k, std::string v)
{
PvApp::label(p, parent, x, y, 70, 30, k, qss::LABEL_KEY);
return PvApp::label(p, parent, x += 70, y, 120, 30, v, qss::LABEL_VAL);
PvApp::label(p, parent, x, y, 70, 30, k, QSS::LABEL_KEY);
return PvApp::label(p, parent, x += 70, y, 120, 30, v, QSS::LABEL_VAL);
}
class CardDevice : PvObject
@@ -22,24 +22,24 @@ public:
CardDevice(PARAM* p, int parent, int x, int y) : PvObject(p)
{
card_ = PvApp::label(p, parent, x, y, 400, 250, "", qss::QSS_CARD_DEVICE);
card_ = PvApp::label(p, parent, x, y, 400, 250, "", QSS::QSS_CARD_DEVICE);
PvApp::label(p, card_, 10, 10, 60, 60, "", "border:none; background-color: rgb(39, 158, 145);");
ui.name = PvApp::label(p, card_, 80, 10, 100, 20, "");
ui.code = PvApp::label(p, card_, 80, 30, 100, 20, "");
ui.type = PvApp::label(p, card_, 80, 50, 100, 20, "", qss::label(14, "rgb(8, 161, 249)"));
ui.type = PvApp::label(p, card_, 80, 50, 100, 20, "", QSS::label(14, "rgb(8, 161, 249)"));
int x1 = 190;
ui.online = PvApp::labelAlignCenter(p, card_, x1, 10, 70, 30, "在线", qss::LABEL_VAL);
ui.running = PvApp::labelAlignCenter(p, card_, x1 += 70, 10, 70, 30, "空闲", qss::LABEL_VAL);
ui.err = PvApp::labelAlignCenter(p, card_, x1 += 70, 10, 70, 30, "正常", qss::LABEL_VAL);
ui.online = PvApp::labelAlignCenter(p, card_, x1, 10, 70, 30, "在线", QSS::LABEL_VAL);
ui.running = PvApp::labelAlignCenter(p, card_, x1 += 70, 10, 70, 30, "空闲", QSS::LABEL_VAL);
ui.err = PvApp::labelAlignCenter(p, card_, x1 += 70, 10, 70, 30, "正常", QSS::LABEL_VAL);
PvApp::labelAlignCenter(p, card_, x1 = 190, 40, 70, 30, "在线状态", qss::LABEL_KEY);
PvApp::labelAlignCenter(p, card_, x1 += 70, 40, 70, 30, "工作状态", qss::LABEL_KEY);
PvApp::labelAlignCenter(p, card_, x1 += 70, 40, 70, 30, "故障状态", qss::LABEL_KEY);
PvApp::labelAlignCenter(p, card_, x1 = 190, 40, 70, 30, "在线状态", QSS::LABEL_KEY);
PvApp::labelAlignCenter(p, card_, x1 += 70, 40, 70, 30, "工作状态", QSS::LABEL_KEY);
PvApp::labelAlignCenter(p, card_, x1 += 70, 40, 70, 30, "故障状态", QSS::LABEL_KEY);
PvApp::label(p, card_, 10, 80, 80, 30, "运行分析:", qss::LABEL_KEY);
PvApp::label(p, card_, 10, 80, 80, 30, "运行分析:", QSS::LABEL_KEY);
PvApp::button(p, card_, 80, 83, 60, 24, "查看");
// 默认创建 10 个参数标签:
@@ -50,8 +50,8 @@ public:
int row = i/2;
int col = i%2;
int h = 25;
vecParamLabel[i].first = PvApp::label(p, card_, 10 + 200*col, 115 + h*row, 70, h, "参数"+std::to_string(i) + ":", qss::LABEL_KEY);
vecParamLabel[i].second = PvApp::label(p, card_, 10 + 200*col + 70, 115 + h*row, 120, h, "---", qss::LABEL_VAL);
vecParamLabel[i].first = PvApp::label(p, card_, 10 + 200*col, 115 + h*row, 70, h, "参数"+std::to_string(i) + ":", QSS::LABEL_KEY);
vecParamLabel[i].second = PvApp::label(p, card_, 10 + 200*col + 70, 115 + h*row, 120, h, "---", QSS::LABEL_VAL);
}
}
@@ -166,7 +166,7 @@ int MaskPageRunning::initUI(EPvCode pvcode)
pvHide(p, security.workspace);
{
std::string style = qss::label(20, "white; padding: 0px 0px 0px 10px;", "rgb(8, 54, 91)", "none; border-radius: 5px;");
std::string style = QSS::label(20, "white; padding: 0px 0px 0px 10px;", "rgb(8, 54, 91)", "none; border-radius: 5px;");
for (int i = 0; i<12; ++i)
{
int w = 320, h = 240;
@@ -174,20 +174,20 @@ int MaskPageRunning::initUI(EPvCode pvcode)
int cardId = PvApp::label(p, security.workspace, x, y, w, h, "监控点 " + std::to_string(i+1), style);
pvSetAlignment(p, cardId, AlignLeft | AlignTop);
PvApp::label(p, cardId, 10, 40, w-20, h-50, "", qss::label(14, "", "", "8px solid black; border-radius: 0px;"));
PvApp::label(p, cardId, 10, 40, w-20, h-50, "", QSS::label(14, "", "", "8px solid black; border-radius: 0px;"));
PvApp::image(p, cardId, (w-77)*0.5, 40+(h-40-77)*0.5, 77, 77, "play1.png");
}
}
{
int w = 320, h = 50;
int pid = PvApp::label(p, security.workspace, 1320, 10, w, 200, "环境温度信息", qss::label(20, "", "", "none;"));
int pid = PvApp::label(p, security.workspace, 1320, 10, w, 200, "环境温度信息", QSS::label(20, "", "", "none;"));
pvSetAlignment(p, pid, AlignLeft | AlignTop);
PvApp::label(p, pid, 0, 30, w, 5, "", qss::QSS_UNDERLINE);
PvApp::label(p, pid, 0, 30, w, 5, "", QSS::QSS_UNDERLINE);
int x = 0, y = 50;
PvApp::label(p, pid, x, y, w, h, "", qss::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*2, "", qss::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
PvApp::label(p, pid, x, y, w, h, "", QSS::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*2, "", QSS::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
{
w = w/3;
PvApp::labelCenter(p, pid, x, y, w, h, "点位");
@@ -200,13 +200,13 @@ int MaskPageRunning::initUI(EPvCode pvcode)
}
{
int w = 320, h = 50;
int pid = PvApp::label(p, security.workspace, 1320, 200, w, 500, "消防信息", qss::label(20, "", "", "none;"));
int pid = PvApp::label(p, security.workspace, 1320, 200, w, 500, "消防信息", QSS::label(20, "", "", "none;"));
pvSetAlignment(p, pid, AlignLeft | AlignTop);
PvApp::label(p, pid, 0, 30, w, 5, "", qss::QSS_UNDERLINE);
PvApp::label(p, pid, 0, 30, w, 5, "", QSS::QSS_UNDERLINE);
int x = 0, y = 50;
PvApp::label(p, pid, x, y, w, h, "", qss::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*9, "", qss::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
PvApp::label(p, pid, x, y, w, h, "", QSS::label(14, "", "rgb(16, 105, 125)", "none; border-radius: 5px 5px 0px 0px;"));
PvApp::label(p, pid, x, y, w, h*9, "", QSS::label(14, "", "", "1px solid rgb(12, 255, 251); border-radius: 5px;"));
{
w = w/2;
PvApp::labelCenter(p, pid, x, y, w, h, "点位");
@@ -246,8 +246,8 @@ void MaskPageRunning::initModule(Module& module, std::string name, int x, int y,
module.name = name;
int deviceNum = activeStation->getDeviceNumByGroup(name);
int pid = module.widget = PvApp::label(p, 0, x, y, w, h, "", qss::LABEL_BOX);
PvApp::label(p, module.widget, 10, 20, w, 30, module.name, qss::LABEL_TITLE);
int pid = module.widget = PvApp::label(p, 0, x, y, w, h, "", QSS::LABEL_BOX);
PvApp::label(p, module.widget, 10, 20, w, 30, module.name, QSS::LABEL_TITLE);
pvSetAlignment(p, module.widget, AlignTop | AlignLeft);
module.labelPower = PvApp::lineLabel(p, pid, PvRect(10, 80, 180, 30), 70, "总功率:", "60 W");
module.labelNum = PvApp::lineLabel(p, pid, PvRect(10, 110, 180, 30), 70, "设备数量:", std::to_string(deviceNum).c_str());
@@ -268,13 +268,13 @@ void MaskPageRunning::activeBoxPanel(Module* module)
{
if (activeBox)
{
pvSetStyleSheet(p, activeBox->widget, qss::LABEL_BOX.c_str());
pvSetStyleSheet(p, activeBox->widget, QSS::LABEL_BOX.c_str());
pvHide(p, activeBox->workspace);
}
activeBox = module;
if (activeBox)
{
pvSetStyleSheet(p, activeBox->widget, qss::QSS_BOX_ACTIVE.c_str());
pvSetStyleSheet(p, activeBox->widget, QSS::QSS_BOX_ACTIVE.c_str());
pvShow(p, activeBox->workspace);
}

View File

@@ -4,9 +4,9 @@
static int CreatePanel(PARAM* p, int parentId, int x, int y, int w, int h, std::string title)
{
int id = PvApp::label(p, parentId, x, y, w, h, "", qss::LABEL_BKG_2);
PvApp::label(p, id, 10, 10, w, 20, title, qss::STYLE_TITLE_ICON);
PvApp::label(p, id, 20, 30, w, 2, "", qss::QSS_UNDERLINE);
int id = PvApp::label(p, parentId, x, y, w, h, "", QSS::LABEL_BKG_2);
PvApp::label(p, id, 10, 10, w, 20, title, QSS::STYLE_TITLE_ICON);
PvApp::label(p, id, 20, 30, w, 2, "", QSS::QSS_UNDERLINE);
return id;
}
@@ -52,7 +52,7 @@ static VecStatDef statDef = {
int MaskPageStat::initUI(EPvCode pvcode)
{
PvApp::label(p, PV_ID_MAIN, 10, 100, 1900, 850, "", qss::LABEL_BKG_1);
PvApp::label(p, PV_ID_MAIN, 10, 100, 1900, 850, "", QSS::LABEL_BKG_1);
if (pvcode == EPvCode::MASK_STAT) { pvcode = EPvCode::MASK_STAT_STORAGE; }
std::string curModuleName;
@@ -63,7 +63,7 @@ int MaskPageStat::initUI(EPvCode pvcode)
std::string moduleName = statDef[i].first;
// 创建按钮
bool isActive = (PvApp::getPvCode(moduleName) == pvcode);
int pageBtn = PvApp::button(p, PV_ID_MAIN, 10+(i*190), 110, 180, 40, moduleName, isActive ? qss::QSS_BTN_MGR_ACTIVE : qss::QSS_BTN_MGR);
int pageBtn = PvApp::button(p, PV_ID_MAIN, 10+(i*190), 110, 180, 40, moduleName, isActive ? QSS::QSS_BTN_MGR_ACTIVE : QSS::QSS_BTN_MGR);
mapSubpage_[pageBtn] = moduleName;
if (isActive)
{

View File

@@ -79,7 +79,7 @@ MaskPageSysmgr::MaskPageSysmgr(PARAM* p) : PvMask(p)
int MaskPageSysmgr::initUI(EPvCode pvcode)
{
PvApp::label(p, PV_ID_MAIN, 10, 150, 1900, 790, "", qss::LABEL_BKG_1);
PvApp::label(p, PV_ID_MAIN, 10, 150, 1900, 790, "", QSS::LABEL_BKG_1);
if (pvcode == EPvCode::MASK_SYSMGR) { pvcode = EPvCode::MASK_MGR_USER; }
@@ -88,7 +88,7 @@ int MaskPageSysmgr::initUI(EPvCode pvcode)
{
std::string& title = vecPageNames[i];
bool isActive = (PvApp::getPvCode(title) == pvcode);
int idPageBtn = PvApp::button(p, PV_ID_MAIN, 10+(i*110), 100, 100, 40, title, isActive ? qss::QSS_BTN_MGR_ACTIVE : qss::QSS_BTN_MGR);
int idPageBtn = PvApp::button(p, PV_ID_MAIN, 10+(i*110), 100, 100, 40, title, isActive ? QSS::QSS_BTN_MGR_ACTIVE : QSS::QSS_BTN_MGR);
mapSubpage_[idPageBtn] = title;
}

View File

@@ -438,12 +438,12 @@ std::string PagePolicy::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& f
// === PageSyslog ===
PageSyslog::PageSyslog(PARAM* p, EPvCode pvcode) : PageTable(p)
{
table->addHead(DMSystemLog::LOG_ID, "日志编号", 160, {});
table->addHead(DMSystemLog::TYPE, "日志类型", 160, {});
table->addHead(DMSystemLog::USER_ACCOUNT, "用户", 160, {});
table->addHead(DMSystemLog::CONTENT, "日志详情", 800, {});
table->addHead(DMSystemLog::STATUS, "状态", 160, {});
table->addHead(DMSystemLog::CREATE_TIME, "记录时间", 200, {});
table->addHead(DMLogSystem::LOG_ID, "日志编号", 160, {});
table->addHead(DMLogSystem::TYPE, "日志类型", 160, {});
table->addHead(DMLogSystem::USER_ACCOUNT, "用户", 160, {});
table->addHead(DMLogSystem::CONTENT, "日志详情", 800, {});
table->addHead(DMLogSystem::STATUS, "状态", 160, {});
table->addHead(DMLogSystem::CREATE_TIME, "记录时间", 200, {});
table->addOperate({"查看"});
}
void PageSyslog::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)
@@ -477,12 +477,12 @@ std::string PageSyslog::onPopConfirm(std::shared_ptr<PvPopWidget> pop, Fields& f
// === PageAlertlog ===
PageAlertlog::PageAlertlog(PARAM* p, EPvCode pvcode) : PageTable(p)
{
table->addHead(DMAlertLog::LOG_ID, "日志编号", 160, {});
table->addHead(DMAlertLog::TYPE, "日志类型", 160, {});
table->addHead(DMAlertLog::DEVICE_ID, "设备ID", 160, {});
table->addHead(DMAlertLog::CONTENT, "日志详情", 800, {});
table->addHead(DMAlertLog::STATUS, "状态", 160, {});
table->addHead(DMAlertLog::CREATE_TIME, "记录时间", 200, {});
table->addHead(DMLogAlert::LOG_ID, "日志编号", 160, {});
table->addHead(DMLogAlert::TYPE, "日志类型", 160, {});
table->addHead(DMLogAlert::DEVICE_ID, "设备ID", 160, {});
table->addHead(DMLogAlert::CONTENT, "日志详情", 800, {});
table->addHead(DMLogAlert::STATUS, "状态", 160, {});
table->addHead(DMLogAlert::CREATE_TIME, "记录时间", 200, {});
table->addOperate({"查看"});
}
void PageAlertlog::onQueryTable(PageInfo& pageInfo, std::vector<Fields>& result)

View File

@@ -103,7 +103,7 @@ PanelPolicyPeak::PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, i
}
if (row == 0 || col == 0)
{
std::string qssLabel = (row==0) ? qss::label(14, "", "rgb(19, 93, 114)") : "";
std::string qssLabel = (row==0) ? QSS::label(14, "", "rgb(19, 93, 114)") : "";
int label = PvApp::label(p, pvid, x+w*col, y+h*row, w, h, text, qssLabel);
pvSetAlignment(p, label, AlignCenter);
}
@@ -127,7 +127,7 @@ PanelPolicyPeak::PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, i
ui.radioPolicy1 = PvApp::radioButton(p, labelPolicy, 80, 0, 80, H, "一充一放");
ui.radioPolicy2 = PvApp::radioButton(p, labelPolicy, 170, 0, 80, H, "两充两放");
ui.label1 = PvApp::label(p, pvid, 10, y+=30, 610, 90, "第一次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
ui.label1 = PvApp::label(p, pvid, 10, y+=30, 610, 90, "第一次充放电过程", QSS::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
int y0 = 70;
@@ -152,7 +152,7 @@ PanelPolicyPeak::PanelPolicyPeak(PARAM* p, int parent, int ix, int iy, int iw, i
ui.arrt1LabelPowerOut = PvApp::textedit(p, labelPowerOut, y0 += 70, 0, 80, H, "");
}
ui.label2 = PvApp::label(p, pvid, 630, y, 610, 90, "第二次充放电过程", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
ui.label2 = PvApp::label(p, pvid, 630, y, 610, 90, "第二次充放电过程", QSS::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label2, AlignLeft | AlignTop);
{
int y0 = 70;
@@ -394,14 +394,14 @@ PanelPolicyRequire::PanelPolicyRequire(PARAM* p, int parent, int ix, int iy, int
int y = 10;
const int H = 24;
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 80, "响应削峰指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 80, "响应削峰指令", QSS::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
ui.dischargeSoc = PvApp::lineTextedit(p, ui.label1, PvRect(10, 40, 270, H), 100, "电池SOC阈值", "");
ui.dischargePower = PvApp::lineTextedit(p, ui.label1, PvRect(300, 40, 270, H), 70, "放电功率", "");
}
ui.label2 = PvApp::label(p, pvid, 10, y += 90, 600, 90, "响应填谷指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
ui.label2 = PvApp::label(p, pvid, 10, y += 90, 600, 90, "响应填谷指令", QSS::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label2, AlignLeft | AlignTop);
{
ui.chargeSoc = PvApp::lineTextedit(p, ui.label2, PvRect(10, 40, 270, H), 100, "电池SOC阈值", "");
@@ -458,7 +458,7 @@ PanelPolicySelf::PanelPolicySelf(PARAM* p, int parent, int ix, int iy, int iw, i
int y = 10;
const int H = 24;
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 120, "响应削峰指令", qss::label(14, "", "", "1px solid rgb(49, 130, 141)"));
ui.label1 = PvApp::label(p, pvid, 10, y, 600, 120, "响应削峰指令", QSS::label(14, "", "", "1px solid rgb(49, 130, 141)"));
pvSetAlignment(p, ui.label1, AlignLeft | AlignTop);
{
ui.usedSoc = PvApp::lineTextedit(p, ui.label1, PvRect(10, 40, 270, H), 100, "自用电量比值", "");

View File

@@ -30,7 +30,7 @@ int pvMain(PARAM* p)
// 管理客户端的连接信息
PvUser pvuser;
PvApp::setPvUser(p, &pvuser);
XLOGD() << "Browser client connect: s= " << int(p->s) << ", user=" << int(&pvuser);
XLOGD() << "Browser client connect: s= " << int(p->s) << ", user=" << (&pvuser);
// 客户端断开时回调
pvSetCleanup(p, onPvThreadCleanup, p);