diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index 5c97278b8..983b64b2c 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -259,6 +259,7 @@ void SourceTreeItem::EnterEditMode() setFocusPolicy(Qt::StrongFocus); boxLayout->removeWidget(label); editor = new QLineEdit(label->text()); + editor->selectAll(); editor->installEventFilter(this); boxLayout->insertWidget(1, editor); setFocusProxy(editor); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 56b1c8a0a..b4f90ef81 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -258,6 +258,8 @@ OBSBasic::OBSBasic(QWidget *parent) ui->scenes->setAttribute(Qt::WA_MacShowFocusRect, false); ui->sources->setAttribute(Qt::WA_MacShowFocusRect, false); + ui->scenes->setItemDelegate(new SceneRenameDelegate(ui->scenes)); + auto displayResize = [this]() { struct obs_video_info ovi; @@ -7192,3 +7194,17 @@ bool OBSBasic::ReplayBufferActive() return false; return outputHandler->ReplayBufferActive(); } + +SceneRenameDelegate::SceneRenameDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + +void SceneRenameDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + QStyledItemDelegate::setEditorData(editor, index); + QLineEdit *lineEdit = qobject_cast(editor); + if (lineEdit) + lineEdit->selectAll(); +} diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 52a421250..85d71f21f 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -816,3 +817,12 @@ public: private: std::unique_ptr ui; }; + +class SceneRenameDelegate : public QStyledItemDelegate { + Q_OBJECT + +public: + SceneRenameDelegate(QObject *parent); + virtual void setEditorData(QWidget *editor, const QModelIndex &index) + const override; +};