UI: Add rename scene/source shortcut
This creates a hidden QAction in sceneDocks and sourceDocks so we can assign a shortcut to perform the renaming action.
This commit is contained in:
parent
11b84a5d85
commit
6c17c10e77
@ -244,6 +244,11 @@ void SourceTreeItem::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SourceTreeItem::IsEditing()
|
||||||
|
{
|
||||||
|
return editor != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void SourceTreeItem::EnterEditMode()
|
void SourceTreeItem::EnterEditMode()
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
@ -1279,10 +1284,14 @@ void SourceTree::Edit(int row)
|
|||||||
if (row < 0 || row >= stm->items.count())
|
if (row < 0 || row >= stm->items.count())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QWidget *widget = indexWidget(stm->createIndex(row, 0));
|
QModelIndex index = stm->createIndex(row, 0);
|
||||||
|
QWidget *widget = indexWidget(index);
|
||||||
SourceTreeItem *itemWidget = reinterpret_cast<SourceTreeItem *>(widget);
|
SourceTreeItem *itemWidget = reinterpret_cast<SourceTreeItem *>(widget);
|
||||||
|
if (itemWidget->IsEditing())
|
||||||
|
return;
|
||||||
|
|
||||||
itemWidget->EnterEditMode();
|
itemWidget->EnterEditMode();
|
||||||
edit(stm->createIndex(row, 0));
|
edit(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourceTree::MultipleBaseSelected() const
|
bool SourceTree::MultipleBaseSelected() const
|
||||||
|
@ -47,6 +47,7 @@ class SourceTreeItem : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SourceTreeItem(SourceTree *tree, OBSSceneItem sceneitem);
|
explicit SourceTreeItem(SourceTree *tree, OBSSceneItem sceneitem);
|
||||||
|
bool IsEditing();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSpacerItem *spacer = nullptr;
|
QSpacerItem *spacer = nullptr;
|
||||||
|
@ -241,12 +241,29 @@ OBSBasic::OBSBasic(QWidget *parent)
|
|||||||
ui->statusbar, SLOT(UpdateCPUUsage()));
|
ui->statusbar, SLOT(UpdateCPUUsage()));
|
||||||
cpuUsageTimer->start(3000);
|
cpuUsageTimer->start(3000);
|
||||||
|
|
||||||
|
QAction *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->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect(renameSource, SIGNAL(triggered()), this,
|
||||||
|
SLOT(EditSceneItemName()));
|
||||||
|
ui->sourcesDock->addAction(renameSource);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
renameScene->setShortcut({Qt::Key_Return});
|
||||||
|
renameSource->setShortcut({Qt::Key_Return});
|
||||||
|
|
||||||
ui->actionRemoveSource->setShortcuts({Qt::Key_Backspace});
|
ui->actionRemoveSource->setShortcuts({Qt::Key_Backspace});
|
||||||
ui->actionRemoveScene->setShortcuts({Qt::Key_Backspace});
|
ui->actionRemoveScene->setShortcuts({Qt::Key_Backspace});
|
||||||
|
|
||||||
ui->action_Settings->setMenuRole(QAction::PreferencesRole);
|
ui->action_Settings->setMenuRole(QAction::PreferencesRole);
|
||||||
ui->actionE_xit->setMenuRole(QAction::QuitRole);
|
ui->actionE_xit->setMenuRole(QAction::QuitRole);
|
||||||
|
#else
|
||||||
|
renameScene->setShortcut({Qt::Key_F2});
|
||||||
|
renameSource->setShortcut({Qt::Key_F2});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto addNudge = [this](const QKeySequence &seq, const char *s)
|
auto addNudge = [this](const QKeySequence &seq, const char *s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user