Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/scripting-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,8 @@ unlike in GUI, where row numbers start from 1 by default.
- '.style' - Qt style sheet for dialog
- '.height', '.width', '.x', '.y' - dialog geometry
- '.label' - dialog message (can contain basic HTML)
- '.modal' - set to true to make the dialog modal (to avoid other CopyQ windows to get input focus)
- '.onTop' - set to true for the dialog to stay above other windows

:returns: Value or values from accepted dialog or ``undefined`` if dialog
was canceled.
Expand Down
4 changes: 4 additions & 0 deletions src/scriptable/scriptableproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,10 @@ int ScriptableProxy::inputDialog(const NamedValueList &values)
createAndSetWidget<QLabel>("text", value.value, parent);
else if (value.name == ".defaultChoice")
inputDialog.defaultChoice = value.value.toString();
else if (value.name == ".modal")
dialog.setModal(value.value.toBool());
else if (value.name == ".onTop")
dialog.setWindowFlag(Qt::WindowStaysOnTopHint, value.value.toBool());
else
widgets.append( createWidget(value.name, value.value, &inputDialog) );
}
Expand Down
13 changes: 13 additions & 0 deletions src/tests/tests_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,19 @@ void Tests::commandDialog()
[&]() { RUN(WITH_TIMEOUT "dialog('.title', 'Remove Items', '.label', 'Remove all items?') === true", "true\n"); },
[&]() { RUN(Args() << "keys" << "focus::QPushButton in dialog_Remove Items:QDialog" << "ENTER", ""); }
);

RUN(Args() << "keys" << clipboardBrowserId, "");
const QByteArray script2 = R"(
dialog(
'.modal', true,
'.onTop', true,
'text', 'DEFAULT',
)
)";
runMultiple(
[&]() { RUN(WITH_TIMEOUT + script2, "DEFAULT\n"); },
[&]() { RUN(Args() << "keys" << "focus::QLineEdit in :QDialog" << "ENTER", ""); }
);
}

void Tests::commandDialogCloseOnDisconnect()
Expand Down
Loading