mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-26 08:26:50 +00:00
Handle example editors better - don't treat example name as filename
This commit is contained in:
@@ -76,6 +76,8 @@ EditorWrapper::EditorWrapper(PythonShell *parent) : QFrame(parent), m_PyShell(pa
|
||||
layout()->setSpacing(0);
|
||||
layout()->setMargin(0);
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_Title = tr("Untitled Script");
|
||||
}
|
||||
|
||||
EditorWrapper::~EditorWrapper()
|
||||
@@ -86,6 +88,16 @@ EditorWrapper::~EditorWrapper()
|
||||
void EditorWrapper::setFilename(QString filename)
|
||||
{
|
||||
m_Filename = filename;
|
||||
if(!m_Filename.isEmpty())
|
||||
m_Title.clear();
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void EditorWrapper::setTitle(QString title)
|
||||
{
|
||||
if(!m_Filename.isEmpty())
|
||||
return;
|
||||
m_Title = title;
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
@@ -107,9 +119,9 @@ void EditorWrapper::updateTitle()
|
||||
if(m_Filename.isEmpty())
|
||||
{
|
||||
if(isModified())
|
||||
setWindowTitle(lit("Untitled Script *"));
|
||||
setWindowTitle(m_Title + lit(" *"));
|
||||
else
|
||||
setWindowTitle(lit("Untitled Script"));
|
||||
setWindowTitle(m_Title);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1583,19 +1595,21 @@ void PythonShell::on_projectExplorer_itemActivated(RDTreeWidgetItem *item, int c
|
||||
}
|
||||
else if(item->parent() == m_Examples)
|
||||
{
|
||||
QString filename = tr("Example: ") + item->text(0);
|
||||
QString title = tr("Example: ") + item->text(0);
|
||||
QString text = item->data(0, Qt::UserRole).toString();
|
||||
|
||||
for(EditorWrapper *edit : m_Editors)
|
||||
{
|
||||
if(edit->filename() == filename)
|
||||
if(edit->filename() == title || edit->title() == title)
|
||||
{
|
||||
ToolWindowManager::raiseToolWindow(edit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CreateNewScriptEditor(filename, text);
|
||||
CreateNewScriptEditor("", text);
|
||||
|
||||
m_Editors.back()->setTitle(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -59,6 +59,7 @@ class EditorWrapper : public QFrame
|
||||
RDLabel *m_Warning;
|
||||
|
||||
QString m_Filename;
|
||||
QString m_Title;
|
||||
bool m_Modified = false;
|
||||
|
||||
bool m_UIExt = false;
|
||||
@@ -74,6 +75,9 @@ public:
|
||||
QString filename() { return m_Filename; }
|
||||
void setFilename(QString filename);
|
||||
|
||||
QString title() { return m_Title; }
|
||||
void setTitle(QString title);
|
||||
|
||||
void setWarning(QString text);
|
||||
|
||||
bool isModified() { return m_Modified; }
|
||||
|
||||
Reference in New Issue
Block a user