From bd718392594b63f5d687b83db3e6652242f04fd5 Mon Sep 17 00:00:00 2001 From: Anthony Torres Date: Sun, 7 Apr 2019 03:34:21 -0400 Subject: [PATCH 1/2] UI: Add text autoselect on scene rename --- UI/window-basic-main.cpp | 16 ++++++++++++++++ UI/window-basic-main.hpp | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 11d92cf34..e41972331 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; @@ -7178,3 +7180,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; +}; From fdae1bbc0f83f4335963637cb830faf8f674b3a8 Mon Sep 17 00:00:00 2001 From: Anthony Torres Date: Sun, 7 Apr 2019 03:36:04 -0400 Subject: [PATCH 2/2] UI: Add text autoselect for source rename --- UI/source-tree.cpp | 1 + 1 file changed, 1 insertion(+) 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);