Workflows: Move editor toolbar actions to the context menu

Undo, Redo, Save, Save As, Duplicate as Editable and Fit are now in the
graph background context menu; keyboard shortcuts are unchanged. The task
palette is placed to the right of the graph.
This commit is contained in:
Kristian Bendiksen committed 2026-10-21 11:19:35 +02:00
1 parent f9030a3e1f
commit 6e2fbde65f
4 files changed
+37 -43

No files matched your search

@@ -41,7 +41,6 @@
#include <QLabel>
#include <QMenu>
#include <QSplitter>
#include <QToolBar>
#include <QVBoxLayout>
#include <map>
@@ -73,10 +72,6 @@ RiuWorkflowEditorWidget::RiuWorkflowEditorWidget( QWidget* parent )
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 2 );
m_toolBar = new QToolBar( this );
m_toolBar->setIconSize( QSize( 16, 16 ) );
m_toolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
auto addAction = [this]( const QString& text, const QString& icon, const QKeySequence& shortcut, auto slot )
{
auto* action = new QAction( icon.isEmpty() ? QIcon() : QIcon( icon ), text, this );
@@ -84,44 +79,40 @@ RiuWorkflowEditorWidget::RiuWorkflowEditorWidget( QWidget* parent )
{
action->setShortcut( shortcut );
action->setShortcutContext( Qt::WidgetWithChildrenShortcut );
action->setToolTip( QString( "%1 (%2)" ).arg( text, shortcut.toString( QKeySequence::NativeText ) ) );
this->addAction( action );
}
connect( action, &QAction::triggered, this, slot );
m_toolBar->addAction( action );
return action;
};
m_saveAction = addAction( "Save",
m_saveAction = addAction( "Save",
":/Save.svg",
QKeySequence::Save,
[this]()
{
if ( m_workflow ) RicWorkflowFeatureTools::saveWorkflow( m_workflow );
} );
m_saveAsAction = addAction( "Save As...",
m_saveAsAction = addAction( "Save As...",
":/SaveAs.svg",
QKeySequence(),
[this]()
{
if ( m_workflow ) RicWorkflowFeatureTools::saveWorkflowAs( m_workflow );
} );
m_toolBar->addSeparator();
m_undoAction = addAction( "Undo",
m_undoAction = addAction( "Undo",
":/undo.png",
QKeySequence::Undo,
[this]()
{
if ( m_workflow && m_workflow->canUndo() && !m_workflow->isLocked() ) m_workflow->undo();
} );
m_redoAction = addAction( "Redo",
m_redoAction = addAction( "Redo",
":/redo.png",
QKeySequence( Qt::CTRL | Qt::Key_Y ),
[this]()
{
if ( m_workflow && m_workflow->canRedo() && !m_workflow->isLocked() ) m_workflow->redo();
} );
m_toolBar->addSeparator();
m_duplicateAction = addAction( "Duplicate as Editable",
":/Copy.svg",
QKeySequence(),
@@ -130,16 +121,15 @@ RiuWorkflowEditorWidget::RiuWorkflowEditorWidget( QWidget* parent )
if ( m_workflow ) RicWorkflowFeatureTools::duplicateAsEditable( m_workflow );
} );
m_fitAction = addAction( "Fit", "", QKeySequence(), [this]() { m_graphView->fitGraph(); } );
layout->addWidget( m_toolBar );
m_splitter = new QSplitter( Qt::Horizontal, this );
m_palette = new RiuWorkflowTaskPalette( m_splitter );
m_graphView = new RiuWorkflowGraphView( m_splitter );
m_splitter->addWidget( m_palette );
m_splitter->addWidget( m_graphView );
m_splitter->setStretchFactor( 0, 0 );
m_splitter->setStretchFactor( 1, 1 );
m_splitter->setSizes( { 220, 800 } );
m_splitter->addWidget( m_palette );
m_splitter->setStretchFactor( 0, 1 );
m_splitter->setStretchFactor( 1, 0 );
m_splitter->setSizes( { 800, 220 } );
layout->addWidget( m_splitter, 1 );
m_statusLabel = new QLabel( this );
@@ -464,10 +454,15 @@ void RiuWorkflowEditorWidget::showContextMenu( const RiuWorkflowGraphView::ItemR
{
appendAddTaskMenu( &menu, scenePos );
menu.addSeparator();
menu.addAction( m_undoAction );
menu.addAction( m_redoAction );
menu.addSeparator();
menu.addAction( m_saveAction );
menu.addAction( m_saveAsAction );
}
menu.addAction( m_duplicateAction );
menu.addSeparator();
menu.addAction( m_fitAction );
if ( editable ) menu.addAction( m_saveAction );
if ( !m_workflow->isEditable() ) menu.addAction( m_duplicateAction );
}
if ( !menu.isEmpty() ) menu.exec( globalPos );
@@ -31,7 +31,6 @@ class QAction;
class QLabel;
class QMenu;
class QSplitter;
class QToolBar;
class RimWorkflow;
class RimWorkflowJob;
struct RimWorkflowDefinition;
@@ -39,7 +38,7 @@ class RiuWorkflowTaskPalette;
class RiuWorkflowValidationRunner;
//==================================================================================================
/// The workflow dock: a toolbar, the task palette, the graph and a status line. Edits go through
/// The workflow dock: the graph, the task palette and a status line. Edits go through
/// RimWorkflow::applyEdit(); the workflow then calls RiuMainWindow::workflowDefinitionChanged(),
/// which refreshes this widget.
//==================================================================================================
@@ -89,18 +88,16 @@ private:
private:
caf::PdmPointer<RimWorkflow> m_workflow;
caf::PdmPointer<RimWorkflowJob> m_job;
QToolBar* m_toolBar;
QAction* m_saveAction;
QAction* m_saveAsAction;
QAction* m_undoAction;
QAction* m_redoAction;
QAction* m_duplicateAction;
QAction* m_fitAction;
QSplitter* m_splitter;
RiuWorkflowTaskPalette* m_palette;
RiuWorkflowGraphView* m_graphView;
QLabel* m_statusLabel;
RiuWorkflowValidationRunner* m_validationRunner;
QString m_message;
QAction* m_saveAction;
QAction* m_saveAsAction;
QAction* m_undoAction;
QAction* m_redoAction;
QAction* m_duplicateAction;
QAction* m_fitAction;
QSplitter* m_splitter;
RiuWorkflowTaskPalette* m_palette;
RiuWorkflowGraphView* m_graphView;
QLabel* m_statusLabel;
RiuWorkflowValidationRunner* m_validationRunner;
QString m_message;
};
+3 -2
View File
@@ -85,8 +85,9 @@ tree. Select a workflow job, provide its inputs, and click **Run**.
## 4. Create and edit workflows
Selecting a workflow opens the workflow editor in a tab next to the 3D views.
It shows a palette of all installed tasks, the workflow graph, and a status
line with validation results.
It shows the workflow graph, a palette of all installed tasks on the right,
and a status line with validation results. Right-click the graph background
for Undo, Redo, Save, Save As, and Duplicate as Editable.
- **New workflow:** right-click **Workflows** and choose **New Workflow**.
- **Copy a workflow:** choose **Duplicate as Editable** on any workflow,
+6 -5
View File
@@ -147,10 +147,10 @@ tooltip while dragging.
Selecting a `RimWorkflow` (or one of its jobs) shows `RiuWorkflowEditorWidget`
in a central dock tab:
- a toolbar with Save, Save As, Undo, Redo, Duplicate as Editable, and Fit;
- the task palette (`RiuWorkflowTaskPalette`): a filter field above a tree
grouped by id prefix. Drag a task onto the graph, or double-click it;
- the graph (`RiuWorkflowGraphView`);
- the task palette (`RiuWorkflowTaskPalette`) to the right of the graph: a
filter field above a tree grouped by id prefix. Drag a task onto the
graph, or double-click it;
- a status line for load errors, read-only reasons, validation results and
unsaved changes.
@@ -166,7 +166,8 @@ In an editable workflow:
- Unwired optional inputs are drawn as hollow ports.
- Right-click a task for Rename (F2), Set as Result Task, Optional Inputs ▸
and Delete (Del). Right-click a connection for Delete Connection.
Right-click the background for Add Task ▸, Fit and Save.
Right-click the background for Add Task ▸, Undo, Redo, Save, Save As,
Duplicate as Editable and Fit. There is no toolbar.
- Ctrl+Z/Ctrl+Y undo and redo; Ctrl+S saves.
Selecting a task shows its `RimWorkflowTaskInput` from the displayed job in
@@ -343,7 +344,7 @@ ApplicationLibCode/Commands/WorkflowCommands/
└── RicWorkflowLocationUi.{h,cpp} # name + folder dialog
ApplicationLibCode/UserInterface/
├── RiuWorkflowEditorWidget.{h,cpp} # the dock: toolbar, palette, graph, status
├── RiuWorkflowEditorWidget.{h,cpp} # the dock: graph, palette, status
├── RiuWorkflowGraphView.{h,cpp} # QGraphicsView with editing
├── RiuWorkflowGraphLayout.{h,cpp} # pure layout (QtCore only)
├── RiuWorkflowTaskPalette.{h,cpp}