From 9cb36f803f9b104d5ef563dd1ead74be8eec5c2d Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Tue, 25 Aug 2020 19:21:25 -0400 Subject: [PATCH] UI: Disable scene rename shortcut key while renaming While editing a scene name, the Qt shortcut key for the renameScene action remained active. If the user pressed the shortcut key while actively editing a scene name, the widget would retrigger the action, causing the name edit to fail and discard the current changes to the scene name. The scene name would be reset to its previous saved value and reselected as if the user had pressed the shortcut key for the first time. This commit removes the QAction associated with the shortcut key from the scenes dock widget when editing starts and adds the action back to the widget once editing is done. Fixes #3044. --- UI/window-basic-main.cpp | 7 +++++-- UI/window-basic-main.hpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 788721215..fa594e543 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -302,12 +302,12 @@ OBSBasic::OBSBasic(QWidget *parent) connect(diskFullTimer, SIGNAL(timeout()), this, SLOT(CheckDiskSpaceRemaining())); - QAction *renameScene = new QAction(ui->scenesDock); + renameScene = new QAction(ui->scenesDock); renameScene->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(renameScene, SIGNAL(triggered()), this, SLOT(EditSceneName())); ui->scenesDock->addAction(renameScene); - QAction *renameSource = new QAction(ui->sourcesDock); + renameSource = new QAction(ui->sourcesDock); renameSource->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(renameSource, SIGNAL(triggered()), this, SLOT(EditSceneItemName())); @@ -4390,6 +4390,7 @@ void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current, void OBSBasic::EditSceneName() { + ui->scenesDock->removeAction(renameScene); QListWidgetItem *item = ui->scenes->currentItem(); Qt::ItemFlags flags = item->flags(); @@ -5424,6 +5425,8 @@ void OBSBasic::SceneNameEdited(QWidget *editor, obs_source_t *source = obs_scene_get_source(scene); RenameListItem(this, ui->scenes, source, text); + ui->scenesDock->addAction(renameScene); + if (api) api->on_event(OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 0296e512d..8e960c675 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -282,6 +282,8 @@ private: QPointer deinterlaceMenu; QPointer perSceneTransitionMenu; QPointer shortcutFilter; + QPointer renameScene; + QPointer renameSource; QPointer programWidget; QPointer programLayout;