2023-09-28 Fred Gleason <fredg@paravelsystems.com>

* Added a 'RDJsonEscape(const QString &str)' function in
	'lib/rdweb.cpp' and 'lib/rdweb.h'.
	* Added a '--dump-panel-updates' switch to rdpanel(1).
	* Added a rdpanel(1) man page.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-09-28 15:51:08 -04:00
parent 4e48d86522
commit 5118c36219
14 changed files with 302 additions and 7 deletions

View File

@@ -23,9 +23,12 @@
#include <rdbutton_panel.h>
#include <rdbutton_dialog.h>
RDButtonPanel::RDButtonPanel(RDAirPlayConf::PanelType type,QWidget *parent)
RDButtonPanel::RDButtonPanel(RDAirPlayConf::PanelType type,int number,
QWidget *parent)
: RDWidget(parent)
{
panel_number=number;
for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
panel_button[i][j]=
@@ -76,6 +79,24 @@ QSizePolicy RDButtonPanel::sizePolicy() const
}
int RDButtonPanel::number() const
{
return panel_number;
}
QString RDButtonPanel::title() const
{
return panel_title;
}
void RDButtonPanel::setTitle(const QString &str)
{
panel_title=str;
}
RDPanelButton *RDButtonPanel::panelButton(int row,int col) const
{
return panel_button[row][col];
@@ -209,3 +230,41 @@ void RDButtonPanel::clear()
}
}
}
QString RDButtonPanel::json(int padding,bool final) const
{
QString ret;
//
// Get Button Count
//
int count=0;
for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(!panel_button[i][j]->isEmpty()) {
count++;
}
}
}
ret+=RDJsonPadding(padding)+"\"panel\": {\r\n";
ret+=RDJsonField("number",panel_number,4+padding);
ret+=RDJsonField("title",panel_title,4+padding,count==0);
for(int i=0;i<PANEL_MAX_BUTTON_ROWS;i++) {
for(int j=0;j<PANEL_MAX_BUTTON_COLUMNS;j++) {
if(!panel_button[i][j]->isEmpty()) {
count--;
ret+=panel_button[i][j]->json(4+padding,count==0);
}
}
}
ret+=RDJsonPadding(padding)+"}";
if(!final) {
ret+=",";
}
ret+="\r\n";
return ret;
}