Skip to content

Commit

Permalink
Show Ad-hoc command note from execution result
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Apr 9, 2024
1 parent dcdda57 commit 02ad035
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
23 changes: 13 additions & 10 deletions src/ahcformdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,13 @@ AHCFormDlg::AHCFormDlg(PsiCon *psi, const AHCommand &r, const Jid &receiver, XMP
node_ = r.node();
sessionId_ = r.sessionId();

_ui.lb_note->setText(r.note().text);
_ui.lb_note->setVisible(r.hasNote());

_ui.lb_instructions->setText(r.data().instructions());
_ui.lb_instructions->setVisible(!r.data().instructions().isEmpty());

// XData form
_xdata = new XDataWidget(_psi, this, _client, receiver);
_xdata->setForm(r.data());
//_xdata->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
_xdata->layout()->setSizeConstraint(QLayout::SetFixedSize);
_ui.scrollArea->setWidget(_xdata);
if (!r.hasData() && (r.hasNote() || !r.data().instructions().isEmpty()))
_ui.scrollArea->setVisible(false);

updateFromCommand(r);

_ui.busy->setVisible(!final);

Expand Down Expand Up @@ -129,6 +122,16 @@ AHCFormDlg::AHCFormDlg(PsiCon *psi, const AHCommand &r, const Jid &receiver, XMP
setParent(nullptr);
}

void AHCFormDlg::updateFromCommand(const AHCommand &r)
{
_ui.lb_note->setText(r.note().text);
_ui.lb_note->setVisible(r.hasNote());

_xdata->setForm(r.data());
if (!r.hasData() && (r.hasNote() || !r.data().instructions().isEmpty()))
_ui.scrollArea->setVisible(false);
}

void AHCFormDlg::doPrev()
{
_ui.busy->start();
Expand Down Expand Up @@ -178,7 +181,7 @@ void AHCFormDlg::commandExecuted()
_ui.busy->stop();
AHCExecuteTask *t = dynamic_cast<AHCExecuteTask *>(sender());
if (t && t->hasCommandPayload()) {
_xdata->setForm(t->resultCommand().data());
updateFromCommand(t->resultCommand());
} else {
close();
}
Expand Down
3 changes: 3 additions & 0 deletions src/ahcformdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ protected slots:
void doCancel();
void commandExecuted();

private:
void updateFromCommand(const AHCommand &r);

private:
Ui::AHCFormDlg _ui;
PsiCon *_psi;
Expand Down
40 changes: 15 additions & 25 deletions src/ahcformdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,17 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="lb_note">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
<item row="2" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::NoButton</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="lb_instructions">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<item row="2" column="0">
<widget class="BusyWidget" name="busy" native="true"/>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
Expand All @@ -43,17 +33,17 @@
</sizepolicy>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="BusyWidget" name="busy" native="true"/>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::NoButton</set>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="lb_note">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
Expand Down

0 comments on commit 02ad035

Please sign in to comment.