mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-11 00:04:27 -04:00
Use QUndoStack generated actions for undo/redo
Benefits include correct icon text describing actual action which will be undone/redone, automatic disabling/enabling of action
This commit is contained in:
parent
53e24f1951
commit
2bba805d41
@ -526,9 +526,6 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
|
||||
mGeneralDock->show();
|
||||
mItemsDock->show();
|
||||
|
||||
mActionUndo->setEnabled( false );
|
||||
mActionRedo->setEnabled( false );
|
||||
|
||||
tabifyDockWidget( mGeneralDock, mUndoDock );
|
||||
tabifyDockWidget( mItemDock, mUndoDock );
|
||||
tabifyDockWidget( mGeneralDock, mItemDock );
|
||||
@ -555,6 +552,18 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout )
|
||||
mLayout = layout;
|
||||
mView->setCurrentLayout( layout );
|
||||
|
||||
// add undo/redo actions which apply to the correct layout undo stack
|
||||
delete mUndoAction;
|
||||
delete mRedoAction;
|
||||
mUndoAction = layout->undoStack()->stack()->createUndoAction( this );
|
||||
mUndoAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionUndo.svg" ) ) );
|
||||
mRedoAction = layout->undoStack()->stack()->createRedoAction( this );
|
||||
mRedoAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionRedo.svg" ) ) );
|
||||
menuEdit->insertAction( menuEdit->actions().at( 0 ), mRedoAction );
|
||||
menuEdit->insertAction( mRedoAction, mUndoAction );
|
||||
mLayoutToolbar->addAction( mUndoAction );
|
||||
mLayoutToolbar->addAction( mRedoAction );
|
||||
|
||||
connect( mActionClearGuides, &QAction::triggered, &mLayout->guides(), [ = ]
|
||||
{
|
||||
mLayout->guides().clear();
|
||||
@ -568,10 +577,6 @@ void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout )
|
||||
mActionShowBoxes->setChecked( mLayout->context().boundingBoxesVisible() );
|
||||
mActionShowPage->setChecked( mLayout->context().pagesVisible() );
|
||||
|
||||
connect( mLayout->undoStack()->stack(), &QUndoStack::canUndoChanged, mActionUndo, &QAction::setEnabled );
|
||||
connect( mLayout->undoStack()->stack(), &QUndoStack::canRedoChanged, mActionRedo, &QAction::setEnabled );
|
||||
connect( mActionUndo, &QAction::triggered, mLayout->undoStack()->stack(), &QUndoStack::undo );
|
||||
connect( mActionRedo, &QAction::triggered, mLayout->undoStack()->stack(), &QUndoStack::redo );
|
||||
mUndoView->setStack( mLayout->undoStack()->stack() );
|
||||
|
||||
mSelectTool->setLayout( layout );
|
||||
|
@ -283,6 +283,9 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
|
||||
QgsDockWidget *mItemsDock = nullptr;
|
||||
QTreeView *mItemsTreeView = nullptr;
|
||||
|
||||
QAction *mUndoAction = nullptr;
|
||||
QAction *mRedoAction = nullptr;
|
||||
|
||||
struct PanelStatus
|
||||
{
|
||||
PanelStatus( bool visible = true, bool active = false )
|
||||
|
@ -62,8 +62,6 @@
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="mActionUndo"/>
|
||||
<addaction name="mActionRedo"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mToolsToolbar">
|
||||
<property name="windowTitle">
|
||||
@ -85,7 +83,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1083</width>
|
||||
<height>25</height>
|
||||
<height>42</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="mLayoutMenu">
|
||||
@ -156,8 +154,6 @@
|
||||
<property name="title">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
<addaction name="mActionUndo"/>
|
||||
<addaction name="mActionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="mActionDeleteSelection"/>
|
||||
<addaction name="separator"/>
|
||||
@ -500,37 +496,6 @@
|
||||
<string>Layout Properties…</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionUndo">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/images/themes/default/mActionUndo.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Undo</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert last change</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionRedo">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mActionRedo.svg</normaloff>:/images/themes/default/mActionRedo.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Redo</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restore last change</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionShowBoxes">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
@ -1055,7 +1020,6 @@
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user