Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds attributes for controlling the window created via dialog() #2956

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
[codespell]
skip = .git,*.pdf,*.svg,go.sum,*.css,.codespellrc,translations
skip = .git,*.pdf,*.svg,go.sum,*.css,.codespellrc,translations,./plugins/itemfakevim/fakevim/*
check-hidden = true
# ignore translations, names, Some&annotations, etc
ignore-regex = (Comment|GenericName)\[.*|\bSimon Ser\b|DoubleClick|{0xf.*, (true|false),.*|\b\S+&(amp;)?\S+\b|.*codespell-ignore.*
ignore-regex = (Comment|GenericName)\[.*|\bSimon Ser\b|DoubleClick|{0xf.*, (true|false),.*|\b\S+&(amp;)?\S+\b|.*codespell-ignore.*|\bonTop\b|readLine\(\)=INE
# ignore-words-list =
4 changes: 4 additions & 0 deletions docs/scripting-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ 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 windows to get input focus)
- '.onTop' - set to true for the dialog to stay above other windows
- '.noParent' - set to true to avoid attaching the dialog to the main window
- '.popupWindow', '.sheetWindow', '.toolWindow', '.foreignWindow' - set/unset the type of dialog window (see `Qt::WindowFlags <https://doc.qt.io/qt-6/qt.html#WindowType-enum>`__ for details)

:returns: Value or values from accepted dialog or ``undefined`` if dialog
was canceled.
Expand Down
14 changes: 14 additions & 0 deletions src/scriptable/scriptableproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,20 @@ int ScriptableProxy::inputDialog(const NamedValueList &values)
createAndSetWidget<QLabel>("text", value.value, &dialog);
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 if (value.name == ".noParent")
dialog.setParent(value.value.toBool() ? nullptr : m_wnd);
else if (value.name == ".popupWindow")
dialog.setWindowFlag(Qt::Popup, value.value.toBool());
else if (value.name == ".toolWindow")
dialog.setWindowFlag(Qt::Tool, value.value.toBool());
else if (value.name == ".sheetWindow")
dialog.setWindowFlag(Qt::Sheet, value.value.toBool());
else if (value.name == ".foreignWindow")
dialog.setWindowFlag(Qt::ForeignWindow, value.value.toBool());
else
widgets.append( createWidget(value.name, value.value, &inputDialog) );
}
Expand Down
19 changes: 19 additions & 0 deletions src/tests/tests_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,25 @@ 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,
'.noParent', true,
'.popupWindow', true,
'.toolWindow', true,
'.sheetWindow', false,
'.foreignWindow', true,
'.noParent', true,
'text', 'DEFAULT',
)
)";
runMultiple(
[&]() { RUN(WITH_TIMEOUT + script2, "DEFAULT\n"); },
[&]() { RUN(Args() << "keys" << "focus::QLineEdit in :QDialog" << "ENTER", ""); }
);
}

void Tests::commandDialogCloseOnDisconnect()
Expand Down
Loading