diff --git a/qrenderdoc/Windows/MainWindow.ui b/qrenderdoc/Windows/MainWindow.ui
index bd0e91479..e8c7ef361 100644
--- a/qrenderdoc/Windows/MainWindow.ui
+++ b/qrenderdoc/Windows/MainWindow.ui
@@ -250,7 +250,7 @@
- P&ython Shell
+ P&ython Scripting
diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp
index 7cfe919ac..57d8b1e01 100644
--- a/qrenderdoc/Windows/PythonShell.cpp
+++ b/qrenderdoc/Windows/PythonShell.cpp
@@ -934,6 +934,10 @@ PythonShell::PythonShell(ICaptureContext &ctx, QWidget *parent)
ui->scriptOutput->setFont(Formatter::FixedFont());
ui->helpText->setFont(Formatter::FixedFont());
+ ui->outputGroup->setWindowTitle(tr("Output"));
+ ui->helpGroup->setWindowTitle(tr("Help"));
+ ui->replGroup->setWindowTitle(tr("Interactive REPL"));
+
ui->lineInput->setAcceptTabCharacters(true);
scriptEditor = new ScintillaEdit(this);
@@ -968,6 +972,15 @@ PythonShell::PythonShell(ICaptureContext &ctx, QWidget *parent)
scriptEditor->colourise(0, -1);
+ QObject::connect(ui->interactiveOutput, &RDTextEdit::keyPress, [this](QKeyEvent *e) {
+ // ignore keypresses that aren't typing, but for up/down redirect that to the line input to get history
+ if((e->text().isEmpty() || !e->text()[0].isPrint()) && e->key() != Qt::Key_Up &&
+ e->key() != Qt::Key_Down)
+ return;
+ ui->lineInput->setFocus(Qt::OtherFocusReason);
+ QApplication::postEvent(ui->lineInput, new QKeyEvent(*e));
+ });
+
QObject::connect(scriptEditor, &ScintillaEdit::modified,
[this](int type, int, int, int, const QByteArray &, int, int, int) {
if(type & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT | SC_MOD_BEFOREINSERT |
@@ -1003,11 +1016,37 @@ PythonShell::PythonShell(ICaptureContext &ctx, QWidget *parent)
}
});
- ui->scriptSplitter->insertWidget(0, scriptEditor);
- int w = ui->scriptSplitter->rect().width();
- ui->scriptSplitter->setSizes({w * 2 / 3, w / 3});
+ scriptEditor->setWindowTitle(tr("Script Editor"));
- ui->tabWidget->setCurrentIndex(0);
+ ui->docking->addToolWindow(scriptEditor, ToolWindowManager::EmptySpace);
+ ui->docking->setToolWindowProperties(
+ scriptEditor, ToolWindowManager::HideCloseButton | ToolWindowManager::DisallowFloatWindow);
+
+ ui->docking->addToolWindow(
+ ui->replGroup, ToolWindowManager::AreaReference(ToolWindowManager::BottomOf,
+ ui->docking->areaOf(scriptEditor), 0.3f));
+ ui->docking->setToolWindowProperties(
+ ui->replGroup, ToolWindowManager::HideCloseButton | ToolWindowManager::DisallowFloatWindow);
+
+ ui->docking->addToolWindow(ui->outputGroup,
+ ToolWindowManager::AreaReference(ToolWindowManager::AddTo,
+ ui->docking->areaOf(ui->replGroup)));
+ ui->docking->setToolWindowProperties(
+ ui->outputGroup, ToolWindowManager::HideCloseButton | ToolWindowManager::DisallowFloatWindow);
+
+ ui->docking->addToolWindow(ui->helpGroup,
+ ToolWindowManager::AreaReference(ToolWindowManager::AddTo,
+ ui->docking->areaOf(ui->replGroup)));
+ ui->docking->setToolWindowProperties(
+ ui->helpGroup, ToolWindowManager::HideCloseButton | ToolWindowManager::DisallowFloatWindow);
+
+ ToolWindowManager::raiseToolWindow(ui->replGroup);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setSpacing(3);
+ layout->setContentsMargins(3, 3, 3, 3);
+ layout->addWidget(ui->toolbar);
+ layout->addWidget(ui->docking);
interactiveContext = NULL;
@@ -1029,6 +1068,20 @@ PythonShell::~PythonShell()
delete ui;
}
+QVariant PythonShell::persistData()
+{
+ QVariantMap state = ui->docking->saveState();
+
+ return state;
+}
+
+void PythonShell::setPersistData(const QVariant &persistData)
+{
+ QVariantMap state = persistData.toMap();
+
+ ui->docking->restoreState(state);
+}
+
PythonContext *PythonShell::GetScriptContext()
{
return scriptContext;
@@ -1065,7 +1118,7 @@ void PythonShell::runScript(bool debugging)
ANALYTIC_SET(UIFeatures.PythonInterop, true);
- ui->outputHelpTabs->setCurrentIndex(0);
+ ToolWindowManager::raiseToolWindow(ui->outputGroup);
ui->scriptOutput->clear();
diff --git a/qrenderdoc/Windows/PythonShell.h b/qrenderdoc/Windows/PythonShell.h
index 4797bcefb..15b159be6 100644
--- a/qrenderdoc/Windows/PythonShell.h
+++ b/qrenderdoc/Windows/PythonShell.h
@@ -42,6 +42,8 @@ class PythonShell : public QFrame, public IPythonShell
{
Q_OBJECT
+ Q_PROPERTY(QVariant persistData READ persistData WRITE setPersistData DESIGNABLE false SCRIPTABLE false)
+
public:
explicit PythonShell(ICaptureContext &ctx, QWidget *parent = 0);
@@ -57,6 +59,10 @@ public:
rdcstr GetScriptText() override;
void RunScript() override { runScript(false); }
void DebugScript() override { runScript(true); }
+
+ QVariant persistData();
+ void setPersistData(const QVariant &persistData);
+
private slots:
// automatic slots
void on_execute_clicked();
diff --git a/qrenderdoc/Windows/PythonShell.ui b/qrenderdoc/Windows/PythonShell.ui
index e9debe0ab..7ead69759 100644
--- a/qrenderdoc/Windows/PythonShell.ui
+++ b/qrenderdoc/Windows/PythonShell.ui
@@ -6,391 +6,375 @@
0
0
- 544
- 346
+ 705
+ 448
- Interactive Python Shell
+ Python Scripting
-
-
- 0
+
+
+
+ 10
+ 90
+ 361
+ 291
+
-
- 3
-
-
- 3
-
-
- 3
-
-
- 3
-
- -
-
-
- 1
-
-
-
- Interactive Shell
-
-
-
- 4
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 2
-
-
-
-
-
- Qt::ScrollBarAlwaysOn
-
-
- true
-
-
- Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
- -
-
-
- 6
-
-
-
-
-
- -
-
-
- Execute
-
-
-
- -
-
-
- Clear
-
-
-
-
-
-
+
+
+ 4
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+ -
+
+
+ Qt::ScrollBarAlwaysOn
+
+
+ true
+
+
+ Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
+
-
-
- Run Scripts
-
-
-
- 4
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 2
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 28
-
-
-
- QFrame::Panel
-
-
- QFrame::Raised
-
-
-
- 2
-
-
- 6
-
-
- 2
-
-
- 6
-
-
- 2
-
-
-
-
-
- Create a new blank script
-
-
- New
-
-
-
- :/page_white_edit.png:/page_white_edit.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Open an existing python script
-
-
- Open
-
-
-
- :/folder_page_white.png:/folder_page_white.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Save the current script to disk
-
-
- Save As
-
-
-
- :/save.png:/save.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- -
-
-
- Begin running the script in python
-
-
- Run
-
-
-
- :/arrow_right.png:/arrow_right.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Begin running the script in python
-
-
- Debug
-
-
-
- :/wrench.png:/wrench.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Stop execution of the current script
-
-
- Abort
-
-
-
- :/del.png:/del.png
-
-
- Qt::ToolButtonTextBesideIcon
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
- false
-
-
-
- 0
-
-
-
- Output
-
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 2
-
-
-
-
-
- Qt::ScrollBarAlwaysOn
-
-
- true
-
-
- Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
-
-
-
-
- Help
-
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 2
-
-
- 4
-
- -
-
-
- Search
-
-
-
- -
-
-
- -
-
-
- Qt::ScrollBarAlwaysOn
-
-
- true
-
-
- Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
-
-
-
-
-
-
+
+ -
+
+
+ 6
+
+
-
+
+
+ -
+
+
+ Execute
+
+
+
+ -
+
+
+ Clear/Reset
+
+
+
+
+
+
+
+
+
+
+ 410
+ 50
+ 111
+ 81
+
+
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 4
+
+ -
+
+
+ Search
+
-
-
-
+
+ -
+
+
+ -
+
+
+ Qt::ScrollBarAlwaysOn
+
+
+ true
+
+
+ Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
+
+
+
+
+
+
+
+
+ 10
+ 10
+ 432
+ 28
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 28
+
+
+
+ QFrame::Panel
+
+
+ QFrame::Raised
+
+
+
+ 2
+
+
+ 6
+
+
+ 2
+
+
+ 6
+
+
+ 2
+
+ -
+
+
+ Create a new blank script
+
+
+ New
+
+
+
+ :/page_white_edit.png:/page_white_edit.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Open an existing python script
+
+
+ Open
+
+
+
+ :/folder_page_white.png:/folder_page_white.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Save the current script to disk
+
+
+ Save As
+
+
+
+ :/save.png:/save.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ -
+
+
+ Begin running the script in python
+
+
+ Run
+
+
+
+ :/arrow_right.png:/arrow_right.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Begin running the script in python
+
+
+ Debug
+
+
+
+ :/wrench.png:/wrench.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Stop execution of the current script
+
+
+ Abort
+
+
+
+ :/del.png:/del.png
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+
+ 390
+ 210
+ 276
+ 212
+
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 4
+
+ -
+
+
+ Qt::ScrollBarAlwaysOn
+
+
+ true
+
+
+ Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
+
+
+
+
+
+
+
+
+ 220
+ 40
+ 351
+ 301
+
+
+
+
+ ToolWindowManager
+ QWidget
+ 3rdparty/toolwindowmanager/ToolWindowManager.h
+
RDLineEdit
QLineEdit