浏览代码

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.
Ryan Foster 5 年之前
父节点
当前提交
9cb36f803f
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 5 2
      UI/window-basic-main.cpp
  2. 2 0
      UI/window-basic-main.hpp

+ 5 - 2
UI/window-basic-main.cpp

@@ -302,12 +302,12 @@ OBSBasic::OBSBasic(QWidget *parent)
 	connect(diskFullTimer, SIGNAL(timeout()), this,
 	connect(diskFullTimer, SIGNAL(timeout()), this,
 		SLOT(CheckDiskSpaceRemaining()));
 		SLOT(CheckDiskSpaceRemaining()));
 
 
-	QAction *renameScene = new QAction(ui->scenesDock);
+	renameScene = new QAction(ui->scenesDock);
 	renameScene->setShortcutContext(Qt::WidgetWithChildrenShortcut);
 	renameScene->setShortcutContext(Qt::WidgetWithChildrenShortcut);
 	connect(renameScene, SIGNAL(triggered()), this, SLOT(EditSceneName()));
 	connect(renameScene, SIGNAL(triggered()), this, SLOT(EditSceneName()));
 	ui->scenesDock->addAction(renameScene);
 	ui->scenesDock->addAction(renameScene);
 
 
-	QAction *renameSource = new QAction(ui->sourcesDock);
+	renameSource = new QAction(ui->sourcesDock);
 	renameSource->setShortcutContext(Qt::WidgetWithChildrenShortcut);
 	renameSource->setShortcutContext(Qt::WidgetWithChildrenShortcut);
 	connect(renameSource, SIGNAL(triggered()), this,
 	connect(renameSource, SIGNAL(triggered()), this,
 		SLOT(EditSceneItemName()));
 		SLOT(EditSceneItemName()));
@@ -4390,6 +4390,7 @@ void OBSBasic::on_scenes_currentItemChanged(QListWidgetItem *current,
 
 
 void OBSBasic::EditSceneName()
 void OBSBasic::EditSceneName()
 {
 {
+	ui->scenesDock->removeAction(renameScene);
 	QListWidgetItem *item = ui->scenes->currentItem();
 	QListWidgetItem *item = ui->scenes->currentItem();
 	Qt::ItemFlags flags = item->flags();
 	Qt::ItemFlags flags = item->flags();
 
 
@@ -5424,6 +5425,8 @@ void OBSBasic::SceneNameEdited(QWidget *editor,
 	obs_source_t *source = obs_scene_get_source(scene);
 	obs_source_t *source = obs_scene_get_source(scene);
 	RenameListItem(this, ui->scenes, source, text);
 	RenameListItem(this, ui->scenes, source, text);
 
 
+	ui->scenesDock->addAction(renameScene);
+
 	if (api)
 	if (api)
 		api->on_event(OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED);
 		api->on_event(OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED);
 
 

+ 2 - 0
UI/window-basic-main.hpp

@@ -282,6 +282,8 @@ private:
 	QPointer<QMenu> deinterlaceMenu;
 	QPointer<QMenu> deinterlaceMenu;
 	QPointer<QMenu> perSceneTransitionMenu;
 	QPointer<QMenu> perSceneTransitionMenu;
 	QPointer<QObject> shortcutFilter;
 	QPointer<QObject> shortcutFilter;
+	QPointer<QAction> renameScene;
+	QPointer<QAction> renameSource;
 
 
 	QPointer<QWidget> programWidget;
 	QPointer<QWidget> programWidget;
 	QPointer<QVBoxLayout> programLayout;
 	QPointer<QVBoxLayout> programLayout;