Skip to content

Commit

Permalink
Merge pull request #1662 from jpue/master
Browse files Browse the repository at this point in the history
webaccess: show page names of multi-page (solo-) frames
  • Loading branch information
mcallegari authored Jan 12, 2025
2 parents 4b0aa7c + 2bd2aaf commit f5d2bc1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 36 deletions.
2 changes: 1 addition & 1 deletion variables.pri
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ macx:USERRGBSCRIPTDIR = $$USERDATADIR/RGBScripts
android:USERRGBSCRIPTDIR = $$USERDATADIR/rgbscripts
ios:USERRGBSCRIPTDIR = $$USERDATADIR/RGBScripts

# RGB Scripts
# Web Files
win32:WEBFILESDIR = Web
unix:!macx:WEBFILESDIR = $$DATADIR/web
macx:WEBFILESDIR = $$DATADIR/Web
Expand Down
3 changes: 2 additions & 1 deletion webaccess/res/virtualconsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ var framesTotalPages = new Array();
var framesCurrentPage = new Array();
var frameDisableState = new Array();
var frameCaption = new Array();
var framesPageNames = new Array();

function updateFrameLabel(id) {
var framePageObj = document.getElementById("fr" + id + "Page");
var newLabel = "Page " + (framesCurrentPage[id] + 1);
var newLabel = framesPageNames[id][framesCurrentPage[id]];
framePageObj.innerHTML = newLabel;

var frameCaptionObj = document.getElementById("fr" + id + "Caption");
Expand Down
107 changes: 73 additions & 34 deletions webaccess/src/webaccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "vcmatrix.h"
#include "vclabel.h"
#include "vcframe.h"
#include "vcframepageshortcut.h"
#include "vcclock.h"
#include "vcxypad.h"
#include "qlcfile.h"
Expand Down Expand Up @@ -1050,15 +1051,6 @@ QString WebAccess::getFrameHTML(VCFrame *frame)
int cw = 36;
// header width
int hw = w - pw - ew - cw;
// header caption
QString caption = "";
if (frame->multipageMode()) {
caption = QString(frame->caption()) != ""
? QString("%1 - Page: %2").arg(frame->caption()).arg(frame->currentPage() + 1)
: QString("Page: %1").arg(frame->currentPage() + 1);
} else {
caption = QString(frame->caption());
}

QString str = "<div class=\"vcframe\" id=\"fr" + QString::number(frame->id()) + "\" "
"style=\"left: " + QString::number(frame->x()) +
Expand All @@ -1071,20 +1063,48 @@ QString WebAccess::getFrameHTML(VCFrame *frame)

if (frame->isHeaderVisible())
{
// header caption
QString caption = QString(frame->caption());
QString currentPageName = "";

if (frame->multipageMode())
{
m_JScode += "framesPageNames[" + QString::number(frame->id()) + "] = new Array();\n";

const QList<VCFramePageShortcut*> shortcuts = frame->shortcuts();
int index = 0;
for (const VCFramePageShortcut* shortcut : shortcuts)
{
m_JScode += "framesPageNames[" + QString::number(frame->id()) + "][" + QString::number(index) + "] = \"" +
QString(shortcut->name()).replace("\\", "\\\\").replace("\"", "\\\"") + "\";\n";
index++;
}
currentPageName = QString(shortcuts[frame->currentPage()]->name());

if (caption != "")
caption += " - ";

if (currentPageName == "")
currentPageName = tr("Page: %1").arg(frame->currentPage() + 1);

caption += currentPageName;
}

str += "<div style=\"position: absolute; display: flex; align-items: center; justify-content: center; flex-direction: row; width: 100%;\">";
str += "<a class=\"vcframeButton\" href=\"javascript:frameToggleCollapse(" +
QString::number(frame->id()) + ");\"><img src=\"expand.png\" width=\"27\"></a>\n";

str += "<div class=\"vcframeHeader\" id=\"vcframeHeader" + QString::number(frame->id()) + "\" style=\"color:" +
frame->foregroundColor().name() + "; width: "+ QString::number(hw) +"px \">";
str += "<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Caption\">" +(caption) + "</div>\n";
str += "<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Caption\">" + caption + "</div>\n";
str += "</div>\n";

m_JScode += "frameCaption[" + QString::number(frame->id()) + "] = \"" + QString(frame->caption()) + "\";\n";
m_JScode += "frameCaption[" + QString::number(frame->id()) + "] = \"" +
QString(frame->caption()).replace("\\", "\\\\").replace("\"", "\\\"") + "\";\n";

if (frame->isEnableButtonVisible()) {
str += "<a class=\"vcframeButton\" id=\"frEnBtn"+ QString::number(frame->id()) +"\" " +
"style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75" )) + "; \" " +
str += "<a class=\"vcframeButton\" id=\"frEnBtn" + QString::number(frame->id()) + "\" " +
"style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75")) + "; \" " +
"href=\"javascript:frameDisableStateChange(" + QString::number(frame->id()) + ");\">" +
"<img src=\"check.png\" width=\"27\"></a>\n";

Expand All @@ -1103,21 +1123,21 @@ QString WebAccess::getFrameHTML(VCFrame *frame)
QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" +
"<img src=\"back.png\" width=\"27\"></a>";

str += "<div class=\"vcframePageLabel\" id=\"frPglbl" + QString::number(frame->id()) + "\" style=\"width: "+QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >"+
"<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Page\">" +
QString("Page: %1").arg(frame->currentPage() + 1) + "</div></div>\n";
str += "<div class=\"vcframePageLabel\" id=\"frPglbl" + QString::number(frame->id()) + "\" style=\"width: " + QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >" +
"<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Page\">" + currentPageName + "</div></div>\n";

str += "<a class=\"vcframeButton\" id=\"frMpHdrNext" + QString::number(frame->id()) + "\" href=\"javascript:frameNextPage(" +
QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" +
"<img src=\"forward.png\" width=\"27\"></a>\n";


str += "</div>\n";

m_JScode += "framesCurrentPage[" + QString::number(frame->id()) + "] = " + QString::number(frame->currentPage()) + ";\n";
m_JScode += "framesTotalPages[" + QString::number(frame->id()) + "] = " + QString::number(frame->totalPagesNumber()) + ";\n\n";
m_JScode += "framesTotalPages[" + QString::number(frame->id()) + "] = " + QString::number(frame->totalPagesNumber()) + ";\n";

connect(frame, SIGNAL(pageChanged(int)), this, SLOT(slotFramePageChanged(int)));
}
m_JScode += "\n";
str += "</div>\n";
}

Expand All @@ -1140,15 +1160,6 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame)
int cw = 36;
// header width
int hw = w - pw - ew - cw;
// header caption
QString caption = "";
if (frame->multipageMode()) {
caption = QString(frame->caption()) != ""
? QString("%1 - Page: %2").arg(frame->caption()).arg(frame->currentPage() + 1)
: QString("Page: %1").arg(frame->currentPage() + 1);
} else {
caption = QString(frame->caption());
}

QString str = "<div class=\"vcframe\" id=\"fr" + QString::number(frame->id()) + "\" "
"style=\"left: " + QString::number(frame->x()) +
Expand All @@ -1161,19 +1172,47 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame)

if (frame->isHeaderVisible())
{
// header caption
QString caption = QString(frame->caption());
QString currentPageName = "";

if (frame->multipageMode())
{
m_JScode += "framesPageNames[" + QString::number(frame->id()) + "] = new Array();\n";

const QList<VCFramePageShortcut*> shortcuts = frame->shortcuts();
int index = 0;
for (const VCFramePageShortcut* shortcut : shortcuts)
{
m_JScode += "framesPageNames[" + QString::number(frame->id()) + "][" + QString::number(index) + "] = \"" +
QString(shortcut->name()).replace("\\", "\\\\").replace("\"", "\\\"") + "\";\n";
index++;
}
currentPageName = QString(shortcuts[frame->currentPage()]->name());

if (caption != "")
caption += " - ";

if (currentPageName == "")
currentPageName = tr("Page: %1").arg(frame->currentPage() + 1);

caption += currentPageName;
}

str += "<div style=\"position: absolute; display: flex; align-items: center; justify-content: center; flex-direction: row; width: 100%;\">";
str += "<a class=\"vcframeButton\" href=\"javascript:frameToggleCollapse(" +
QString::number(frame->id()) + ");\"><img src=\"expand.png\" width=\"27\"></a>\n";

str += "<div class=\"vcsoloframeHeader\" id=\"vcframeHeader" + QString::number(frame->id()) + "\" style=\"color:" +
frame->foregroundColor().name() + "; width: "+ QString::number(hw) +"px \">";
str += "<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Caption\">" +(caption) + "</div>\n";
str += "<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Caption\">" + caption + "</div>\n";
str += "</div>\n";

m_JScode += "frameCaption[" + QString::number(frame->id()) + "] = \"" + QString(frame->caption()) + "\";\n";
m_JScode += "frameCaption[" + QString::number(frame->id()) + "] = \"" +
QString(frame->caption()).replace("\\", "\\\\").replace("\"", "\\\"") + "\";\n";

if (frame->isEnableButtonVisible()) {
str += "<a class=\"vcframeButton\" id=\"frEnBtn"+ QString::number(frame->id()) +"\" " +
str += "<a class=\"vcframeButton\" id=\"frEnBtn" + QString::number(frame->id()) + "\" " +
"style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75")) + "; \" " +
"href=\"javascript:frameDisableStateChange(" + QString::number(frame->id()) + ");\">" +
"<img src=\"check.png\" width=\"27\"></a>\n";
Expand All @@ -1193,9 +1232,8 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame)
QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" +
"<img src=\"back.png\" width=\"27\"></a>";

str += "<div class=\"vcframePageLabel\" id=\"frPglbl" + QString::number(frame->id()) + "\" style=\"width: "+QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >"+
"<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Page\">" +
QString("Page: %1").arg(frame->currentPage() + 1) + "</div></div>\n";
str += "<div class=\"vcframePageLabel\" id=\"frPglbl" + QString::number(frame->id()) + "\" style=\"width: " + QString::number(frame->isCollapsed() ? 60 : 100) + "px; \" >" +
"<div class=\"vcFrameText\" id=\"fr" + QString::number(frame->id()) + "Page\">" + currentPageName + "</div></div>\n";

str += "<a class=\"vcframeButton\" id=\"frMpHdrNext" + QString::number(frame->id()) + "\" href=\"javascript:frameNextPage(" +
QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" +
Expand All @@ -1205,9 +1243,10 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame)
str += "</div>\n";

m_JScode += "framesCurrentPage[" + QString::number(frame->id()) + "] = " + QString::number(frame->currentPage()) + ";\n";
m_JScode += "framesTotalPages[" + QString::number(frame->id()) + "] = " + QString::number(frame->totalPagesNumber()) + ";\n\n";
m_JScode += "framesTotalPages[" + QString::number(frame->id()) + "] = " + QString::number(frame->totalPagesNumber()) + ";\n";
connect(frame, SIGNAL(pageChanged(int)), this, SLOT(slotFramePageChanged(int)));
}
m_JScode += "\n";
str += "</div>\n";
}

Expand Down

0 comments on commit f5d2bc1

Please sign in to comment.