Add undo, redo, cut, copy and paste actions to MainWindow which pass onto the editor widget

Sun, 09 Apr 2023 16:23:05 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 16:23:05 +0300
changeset 365
9d5cb5635c18
parent 364
39fbdee0c0c8
child 366
ea656dead697

Add undo, redo, cut, copy and paste actions to MainWindow which pass onto the editor widget

src/mainwindow.ui file | annotate | diff | comparison | revisions
--- a/src/mainwindow.ui	Sun Apr 09 16:01:57 2023 +0300
+++ b/src/mainwindow.ui	Sun Apr 09 16:23:05 2023 +0300
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>959</width>
+    <width>1333</width>
     <height>695</height>
    </rect>
   </property>
@@ -44,7 +44,7 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>959</width>
+     <width>1333</width>
      <height>38</height>
     </rect>
    </property>
@@ -78,7 +78,6 @@
     <addaction name="actionRenderStylePickScene"/>
     <addaction name="actionWireframe"/>
     <addaction name="separator"/>
-    <addaction name="actionAdjustGridToView"/>
     <addaction name="actionDrawAxes"/>
     <addaction name="separator"/>
     <addaction name="actionTileSubWindows"/>
@@ -88,6 +87,13 @@
     <property name="title">
      <string>Edit</string>
     </property>
+    <addaction name="actionUndo"/>
+    <addaction name="actionRedo"/>
+    <addaction name="separator"/>
+    <addaction name="actionCut"/>
+    <addaction name="actionCopy"/>
+    <addaction name="actionPaste"/>
+    <addaction name="separator"/>
     <addaction name="actionInvert"/>
     <addaction name="separator"/>
     <addaction name="actionGridFine"/>
@@ -263,7 +269,6 @@
    <addaction name="actionGridFine"/>
    <addaction name="actionGridMedium"/>
    <addaction name="actionGridCoarse"/>
-   <addaction name="actionAdjustGridToView"/>
   </widget>
   <widget class="QDockWidget" name="dockWidget">
    <property name="features">
@@ -313,6 +318,20 @@
     </layout>
    </widget>
   </widget>
+  <widget class="QToolBar" name="editToolbar">
+   <property name="windowTitle">
+    <string>toolBar_2</string>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actionCut"/>
+   <addaction name="actionCopy"/>
+   <addaction name="actionPaste"/>
+  </widget>
   <action name="actionQuit">
    <property name="icon">
     <iconset resource="../resources.qrc">
@@ -399,14 +418,6 @@
     <string>Pick scene colours</string>
    </property>
   </action>
-  <action name="actionAdjustGridToView">
-   <property name="text">
-    <string>Adjust grid to view</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+G</string>
-   </property>
-  </action>
   <action name="actionSave">
    <property name="icon">
     <iconset resource="../resources.qrc">
@@ -594,6 +605,22 @@
     <string>Ctrl+V</string>
    </property>
   </action>
+  <action name="actionUndo">
+   <property name="text">
+    <string>Undo</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Z</string>
+   </property>
+  </action>
+  <action name="actionRedo">
+   <property name="text">
+    <string>Redo</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Y</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>
@@ -639,5 +666,85 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionUndo</sender>
+   <signal>triggered()</signal>
+   <receiver>modelEdit</receiver>
+   <slot>undo()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>1041</x>
+     <y>163</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionRedo</sender>
+   <signal>triggered()</signal>
+   <receiver>modelEdit</receiver>
+   <slot>redo()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>1041</x>
+     <y>163</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionCut</sender>
+   <signal>triggered()</signal>
+   <receiver>modelEdit</receiver>
+   <slot>cut()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>1041</x>
+     <y>163</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionCopy</sender>
+   <signal>triggered()</signal>
+   <receiver>modelEdit</receiver>
+   <slot>copy()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>1041</x>
+     <y>163</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionPaste</sender>
+   <signal>triggered()</signal>
+   <receiver>modelEdit</receiver>
+   <slot>paste()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>1041</x>
+     <y>163</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
 </ui>

mercurial