diff --git a/docs/imgs/Screenshots/PythonUIProjectEditor.png b/docs/imgs/Screenshots/PythonUIProjectEditor.png index 852465930..001ca4bbc 100644 Binary files a/docs/imgs/Screenshots/PythonUIProjectEditor.png and b/docs/imgs/Screenshots/PythonUIProjectEditor.png differ diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 98f74fd4c..967f85ab8 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -514,6 +514,8 @@ void PythonShell::editorTab_Changed(int index) EditorWrapper *editor = curEditor(); ui->saveScript->setEnabled(editor && editor->filename() != QString()); + + enableButtons(ui->newScript->isEnabled()); } void PythonShell::openFileModified(const QString &path) @@ -1398,6 +1400,15 @@ void PythonShell::on_projectExplorer_itemActivated(RDTreeWidgetItem *item, int c if(filename.isEmpty()) return; + bool isExt = false; + RDTreeWidgetItem *parent = item; + while(parent) + { + if(parent == m_UIExtensions) + isExt = true; + parent = parent->parent(); + } + for(EditorWrapper *edit : m_Editors) { if(edit->filename() == filename) @@ -1428,6 +1439,11 @@ void PythonShell::on_projectExplorer_itemActivated(RDTreeWidgetItem *item, int c LoadScriptFromFilename(filename); + if(isExt) + m_Editors.back()->setUIExtension(true); + + editorTab_Changed(-1); + QString unsavedFile = interactiveContext->GetTempFilename(lit("script.py")); if(filename == unsavedFile) { @@ -1843,6 +1859,19 @@ void PythonShell::enableButtons(bool enable) ui->abortRun->setEnabled(!enable); ui->debugScript->setEnabled(enable); + EditorWrapper *editor = curEditor(); + + ui->runScript->setToolTip(QString()); + + if(editor) + { + if(editor->isUIExtension()) + { + ui->runScript->setEnabled(false); + ui->runScript->setToolTip(tr("UI Extension files can't be run")); + } + } + if(enable && !m_Ctx.Config().Python_DebugEnabled) { ui->debugScript->setEnabled(false); diff --git a/qrenderdoc/Windows/PythonShell.h b/qrenderdoc/Windows/PythonShell.h index 9f5d7b98d..349a1ae94 100644 --- a/qrenderdoc/Windows/PythonShell.h +++ b/qrenderdoc/Windows/PythonShell.h @@ -61,6 +61,8 @@ class EditorWrapper : public QFrame QString m_Filename; bool m_Modified = false; + bool m_UIExt = false; + void updateTitle(); public: @@ -77,6 +79,9 @@ public: bool isModified() { return m_Modified; } void markModified(bool modified); + bool isUIExtension() { return m_UIExt; } + void setUIExtension(bool uiext) { m_UIExt = uiext; } + public slots: bool checkAllowClose(); };