From 2bd2aaf2366d7767131cfc2695bac99f0f7eee34 Mon Sep 17 00:00:00 2001 From: jpue <94829332+jpue@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:31:46 +0100 Subject: [PATCH] webaccess: show page names of multi-page (solo-) frames --- variables.pri | 2 +- webaccess/res/virtualconsole.js | 3 +- webaccess/src/webaccess.cpp | 107 ++++++++++++++++++++++---------- 3 files changed, 76 insertions(+), 36 deletions(-) diff --git a/variables.pri b/variables.pri index a7c4378904..503894d292 100644 --- a/variables.pri +++ b/variables.pri @@ -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 diff --git a/webaccess/res/virtualconsole.js b/webaccess/res/virtualconsole.js index ea4b916f8f..0b5ad374bf 100644 --- a/webaccess/res/virtualconsole.js +++ b/webaccess/res/virtualconsole.js @@ -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"); diff --git a/webaccess/src/webaccess.cpp b/webaccess/src/webaccess.cpp index 03105b6095..8e8608f17b 100644 --- a/webaccess/src/webaccess.cpp +++ b/webaccess/src/webaccess.cpp @@ -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" @@ -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 = "
id()) + "\" " "style=\"left: " + QString::number(frame->x()) + @@ -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 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 += "
"; str += "id()) + ");\">\n"; str += "
id()) + "\" style=\"color:" + frame->foregroundColor().name() + "; width: "+ QString::number(hw) +"px \">"; - str += "
id()) + "Caption\">" +(caption) + "
\n"; + str += "
id()) + "Caption\">" + caption + "
\n"; str += "
\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 += "id()) +"\" " + - "style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75" )) + "; \" " + + str += "id()) + "\" " + + "style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75")) + "; \" " + "href=\"javascript:frameDisableStateChange(" + QString::number(frame->id()) + ");\">" + "\n"; @@ -1103,21 +1123,21 @@ QString WebAccess::getFrameHTML(VCFrame *frame) QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" + ""; - str += "
id()) + "\" style=\"width: "+QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >"+ - "
id()) + "Page\">" + - QString("Page: %1").arg(frame->currentPage() + 1) + "
\n"; + str += "
id()) + "\" style=\"width: " + QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >" + + "
id()) + "Page\">" + currentPageName + "
\n"; str += "id()) + "\" href=\"javascript:frameNextPage(" + QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" + "\n"; - str += "
\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 += "
\n"; } @@ -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 = "
id()) + "\" " "style=\"left: " + QString::number(frame->x()) + @@ -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 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 += "
"; str += "id()) + ");\">\n"; str += "
id()) + "\" style=\"color:" + frame->foregroundColor().name() + "; width: "+ QString::number(hw) +"px \">"; - str += "
id()) + "Caption\">" +(caption) + "
\n"; + str += "
id()) + "Caption\">" + caption + "
\n"; str += "
\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 += "id()) +"\" " + + str += "id()) + "\" " + "style=\" background-color: " + QString((frame->isDisabled() ? "#E0DFDF" : "#D7DE75")) + "; \" " + "href=\"javascript:frameDisableStateChange(" + QString::number(frame->id()) + ");\">" + "\n"; @@ -1193,9 +1232,8 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame) QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" + ""; - str += "
id()) + "\" style=\"width: "+QString::number(frame->isCollapsed() ? 60 : 100)+"px; \" >"+ - "
id()) + "Page\">" + - QString("Page: %1").arg(frame->currentPage() + 1) + "
\n"; + str += "
id()) + "\" style=\"width: " + QString::number(frame->isCollapsed() ? 60 : 100) + "px; \" >" + + "
id()) + "Page\">" + currentPageName + "
\n"; str += "id()) + "\" href=\"javascript:frameNextPage(" + QString::number(frame->id()) + ");\" style=\"display: " + QString(!frame->isCollapsed() ? "block" : "none") + "\">" + @@ -1205,9 +1243,10 @@ QString WebAccess::getSoloFrameHTML(VCSoloFrame *frame) str += "
\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 += "
\n"; }