Skip to content

Commit

Permalink
Added web interface for cue list notes live editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Binary-Vanguard-12138 committed Feb 4, 2024
1 parent 09bd20f commit 37beeae
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ui/src/virtualconsole/vccuelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,18 @@ void VCCueList::slotItemChanged(QTreeWidgetItem *item, int column)

step.note = itemText;
ch->replaceStep(step, idx);

emit stepNoteChanged(idx, itemText);
}

void VCCueList::slotStepNoteChanged(int idx, QString note)
{
Chaser *ch = chaser();
if (ch == NULL)
return;
ChaserStep step = ch->steps().at(idx);
step.note = note;
ch->replaceStep(step, idx);
}

void VCCueList::slotFunctionRunning(quint32 fid)
Expand Down
5 changes: 5 additions & 0 deletions ui/src/virtualconsole/vccuelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public slots:
/** Skip to the previous cue */
void slotPreviousCue();

/** Update cue step note */
void slotStepNoteChanged(int idx, QString note);

signals:
/** progress percent value and text */
void progressStateChanged();
Expand Down Expand Up @@ -405,6 +408,8 @@ protected slots:
/** Signal to webaccess */
void stepChanged(int idx);

void stepNoteChanged(int idx, QString note);

private:
FunctionParent functionParent() const;

Expand Down
4 changes: 4 additions & 0 deletions webaccess/res/virtualconsole.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ form {
visibility: hidden;
}

input:focus-visible {
outline: none;
}

.vcbutton-wrapper {
position: absolute;
}
Expand Down
27 changes: 27 additions & 0 deletions webaccess/res/virtualconsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,33 @@ function setCueProgress(id, percent, text) {
progressValObj.innerHTML = text;
}

function changeCueNoteToEditMode(id, idx) {
var cueNoteSpanObj = document.getElementById("cueNoteSpan" + id + "_" + idx);
var cueNoteInputObj = document.getElementById("cueNoteInput" + id + "_" + idx);
cueNoteSpanObj.style.display = "none";
cueNoteInputObj.style.display = "block";
cueNoteInputObj.focus();
}

function changeCueNoteToTextMode(id, idx) {
var cueNoteSpanObj = document.getElementById("cueNoteSpan" + id + "_" + idx);
var cueNoteInputObj = document.getElementById("cueNoteInput" + id + "_" + idx);
cueNoteSpanObj.style.display = "block";
cueNoteInputObj.style.display = "none";
var newNote = cueNoteInputObj.value;
cueNoteSpanObj.innerHTML = newNote;
websocket.send(id + "|CUE_STEP_NOTE|" + idx + "|" + newNote);
}

function setCueStepNote(id, idx, note) {
var cueNoteSpanObj = document.getElementById("cueNoteSpan" + id + "_" + idx);
var cueNoteInputObj = document.getElementById("cueNoteInput" + id + "_" + idx);
cueNoteSpanObj.style.display = "block";
cueNoteInputObj.style.display = "none";
cueNoteSpanObj.innerHTML = note;
cueNoteInputObj.value = note;
}

function showSideFaderPanel(id, checked) {
var progressBarObj = document.getElementById("fadePanel" + id);
showPanel[id] = parseInt(checked, 10);
Expand Down
2 changes: 2 additions & 0 deletions webaccess/res/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ function connect() {
setFrameDisableState(msgParams[0], msgParams[2]);
} else if (msgParams[0] === "ALERT") {
alert(msgParams[1]);
} else if (msgParams[1] === "CUE_STEP_NOTE") {
setCueStepNote(msgParams[0], msgParams[2], msgParams[3]);
} else if (msgParams[1] === "CUE_PROGRESS") {
// CUE message is <ID>|CUE_PERCENT|<PERCENT>|<TEXT>
setCueProgress(msgParams[0], msgParams[2], msgParams[3]);
Expand Down
23 changes: 21 additions & 2 deletions webaccess/src/webaccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ void WebAccess::slotHandleWebSocketRequest(QHttpConnection *conn, QString data)
cue->slotNextCue();
else if (cmdList[1] == "STEP")
cue->playCueAtIndex(cmdList[2].toInt());
else if (cmdList[1] == "CUE_STEP_NOTE")
cue->slotStepNoteChanged(cmdList[2].toInt(), cmdList[3]);
else if (cmdList[1] == "CUE_SHOWPANEL")
cue->slotSideFaderButtonChecked(cmdList[2] == "1" ? false : true);
else if (cmdList[1] == "CUE_SIDECHANGE")
Expand Down Expand Up @@ -1360,6 +1362,17 @@ void WebAccess::slotCueIndexChanged(int idx)
sendWebSocketMessage(wsMessage.toUtf8());
}

void WebAccess::slotCueStepNoteChanged(int idx, QString note)
{
VCCueList *cue = qobject_cast<VCCueList *>(sender());
if (cue == NULL)
return;

QString wsMessage = QString("%1|CUE_STEP_NOTE|%2|%3").arg(cue->id()).arg(idx).arg(note);

sendWebSocketMessage(wsMessage.toUtf8());
}

void WebAccess::slotCueProgressStateChanged()
{
VCCueList *cue = qobject_cast<VCCueList *>(sender());
Expand Down Expand Up @@ -1549,7 +1562,7 @@ QString WebAccess::getCueListHTML(VCCueList *cue)
{
QString stepID = QString::number(cue->id()) + "_" + QString::number(i);
str += "<tr id=\"" + stepID + "\" "
"onclick=\"enableCue(" + QString::number(cue->id()) + ", " + QString::number(i) + ");\">\n";
"onclick=\"setCueIndex(" + QString::number(cue->id()) + ", " + QString::number(i) + ");\">\n";

ChaserStep *step = chaser->stepAt(i);
str += "<td>" + QString::number(i + 1) + "</td>";
Expand Down Expand Up @@ -1631,7 +1644,11 @@ QString WebAccess::getCueListHTML(VCCueList *cue)
str += "<td></td>";
}

str += "<td>" + step->note + "</td>\n";
str += "<td ondblclick=\"changeCueNoteToEditMode(" + QString::number(cue->id()) + ", " + QString::number(i) + ");\">" +
"<span id=\"cueNoteSpan" + stepID + "\" style=\"display: block;\">" + step->note + "</span>" +
"<input type=\"text\" id=\"cueNoteInput" + stepID + "\" value=\"" + step->note + "\" style=\"display: none; width: 60px;\" " +
"onfocusout=\"changeCueNoteToTextMode(" + QString::number(cue->id()) + ", " + QString::number(i) + ");\" />"
"</td>\n";
}
str += "</td>\n";
}
Expand Down Expand Up @@ -1715,6 +1732,8 @@ QString WebAccess::getCueListHTML(VCCueList *cue)

connect(cue, SIGNAL(stepChanged(int)),
this, SLOT(slotCueIndexChanged(int)));
connect(cue, SIGNAL(stepNoteChanged(int, QString)),
this, SLOT(slotCueStepNoteChanged(int, QString)));
connect(cue, SIGNAL(progressStateChanged()),
this, SLOT(slotCueProgressStateChanged()));
connect(cue, SIGNAL(sideFaderButtonChecked()),
Expand Down
1 change: 1 addition & 0 deletions webaccess/src/webaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected slots:
void slotSliderDisableStateChanged(bool disable);
void slotAudioTriggersToggled(bool toggle);
void slotCueIndexChanged(int idx);
void slotCueStepNoteChanged(int idx, QString note);
void slotCueProgressStateChanged();
void slotCueShowSideFaderPanel();
void slotCueSideFaderValueChanged();
Expand Down

0 comments on commit 37beeae

Please sign in to comment.