Changeset View
Changeset View
Standalone View
Standalone View
krita/ui/kis_selection_manager.cc
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | |||||
119 | } | 119 | } | ||
120 | 120 | | |||
121 | void KisSelectionManager::setup(KisActionManager* actionManager) | 121 | void KisSelectionManager::setup(KisActionManager* actionManager) | ||
122 | { | 122 | { | ||
123 | m_cut = actionManager->createStandardAction(KStandardAction::Cut, this, SLOT(cut())); | 123 | m_cut = actionManager->createStandardAction(KStandardAction::Cut, this, SLOT(cut())); | ||
124 | m_copy = actionManager->createStandardAction(KStandardAction::Copy, this, SLOT(copy())); | 124 | m_copy = actionManager->createStandardAction(KStandardAction::Copy, this, SLOT(copy())); | ||
125 | m_paste = actionManager->createStandardAction(KStandardAction::Paste, this, SLOT(paste())); | 125 | m_paste = actionManager->createStandardAction(KStandardAction::Paste, this, SLOT(paste())); | ||
126 | 126 | | |||
127 | KisAction *copySharp = new KisAction(i18n("Copy (sharp)"), this); | 127 | KisAction *action = actionManager->createAction("copy_sharp"); | ||
128 | copySharp->setActivationFlags(KisAction::PIXELS_SELECTED); | 128 | action->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
129 | actionManager->addAction("copy_sharp", copySharp); | 129 | connect(action, SIGNAL(triggered()), this, SLOT(copySharp())); | ||
130 | connect(copySharp, SIGNAL(triggered()), this, SLOT(copySharp())); | 130 | | ||
131 | 131 | action = actionManager->createAction("cut_sharp"); | |||
132 | KisAction *cutSharp = new KisAction(i18n("Cut (sharp)"), this); | 132 | action->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
133 | cutSharp->setActivationFlags(KisAction::PIXELS_SELECTED); | 133 | connect(action, SIGNAL(triggered()), this, SLOT(cutSharp())); | ||
134 | actionManager->addAction("cut_sharp", cutSharp); | 134 | | ||
135 | connect(cutSharp, SIGNAL(triggered()), this, SLOT(cutSharp())); | 135 | m_pasteNew = actionManager->createAction("paste_new"); | ||
136 | | ||||
137 | m_pasteNew = new KisAction(i18n("Paste into &New Image"), this); | | |||
138 | m_pasteNew->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_N)); | | |||
139 | actionManager->addAction("paste_new", m_pasteNew); | | |||
140 | connect(m_pasteNew, SIGNAL(triggered()), this, SLOT(pasteNew())); | 136 | connect(m_pasteNew, SIGNAL(triggered()), this, SLOT(pasteNew())); | ||
141 | 137 | | |||
142 | m_pasteAt = new KisAction(i18n("Paste at cursor"), this); | 138 | m_pasteAt = actionManager->createAction("paste_at"); | ||
143 | actionManager->addAction("paste_at", m_pasteAt); | | |||
144 | connect(m_pasteAt, SIGNAL(triggered()), this, SLOT(pasteAt())); | 139 | connect(m_pasteAt, SIGNAL(triggered()), this, SLOT(pasteAt())); | ||
145 | 140 | | |||
146 | m_copyMerged = new KisAction(i18n("Copy merged"), this); | 141 | m_copyMerged = actionManager->createAction("copy_merged"); | ||
147 | m_copyMerged->setActivationFlags(KisAction::PIXELS_SELECTED); | 142 | m_copyMerged->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
148 | m_copyMerged->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C)); | | |||
149 | actionManager->addAction("copy_merged", m_copyMerged); | | |||
150 | connect(m_copyMerged, SIGNAL(triggered()), this, SLOT(copyMerged())); | 143 | connect(m_copyMerged, SIGNAL(triggered()), this, SLOT(copyMerged())); | ||
151 | 144 | | |||
152 | m_selectAll = new KisAction(KisIconUtils::loadIcon("select-all"), i18n("Select &All"), this); | 145 | m_selectAll = actionManager->createAction("select_all"); | ||
153 | m_selectAll->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); | | |||
154 | actionManager->addAction("select_all", m_selectAll); | | |||
155 | connect(m_selectAll, SIGNAL(triggered()), this, SLOT(selectAll())); | 146 | connect(m_selectAll, SIGNAL(triggered()), this, SLOT(selectAll())); | ||
156 | 147 | | |||
157 | m_deselect = new KisAction(KisIconUtils::loadIcon("select-clear"), i18n("Deselect"), this); | 148 | m_deselect = actionManager->createAction("deselect"); | ||
158 | m_deselect->setActivationFlags(KisAction::PIXELS_SELECTED | KisAction::SHAPES_SELECTED); | 149 | m_deselect->setActivationFlags(KisAction::PIXELS_SELECTED | KisAction::SHAPES_SELECTED); | ||
159 | m_deselect->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A)); | | |||
160 | actionManager->addAction("deselect", m_deselect); | | |||
161 | connect(m_deselect, SIGNAL(triggered()), this, SLOT(deselect())); | 150 | connect(m_deselect, SIGNAL(triggered()), this, SLOT(deselect())); | ||
162 | 151 | | |||
163 | m_clear = new KisAction(KisIconUtils::loadIcon("select-clear"), i18n("Clear"), this); | 152 | m_clear = actionManager->createAction("clear"); | ||
164 | m_clear->setActivationFlags(KisAction::ACTIVE_IMAGE); | 153 | m_clear->setActivationFlags(KisAction::ACTIVE_IMAGE); | ||
165 | m_clear->setDefaultShortcut(QKeySequence((Qt::Key_Delete))); | | |||
166 | actionManager->addAction("clear", m_clear); | | |||
167 | connect(m_clear, SIGNAL(triggered()), SLOT(clear())); | 154 | connect(m_clear, SIGNAL(triggered()), SLOT(clear())); | ||
168 | 155 | | |||
169 | m_reselect = new KisAction(i18n("&Reselect"), this); | 156 | m_reselect = actionManager->createAction("reselect"); | ||
170 | m_reselect->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D)); | | |||
171 | actionManager->addAction("reselect", m_reselect); | | |||
172 | connect(m_reselect, SIGNAL(triggered()), this, SLOT(reselect())); | 157 | connect(m_reselect, SIGNAL(triggered()), this, SLOT(reselect())); | ||
173 | 158 | | |||
174 | m_invert = new KisAction(i18n("&Invert Selection"), this); | 159 | m_invert = actionManager->createAction("invert"); | ||
175 | m_invert->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | 160 | m_invert->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | ||
176 | m_invert->setActivationConditions(KisAction::SELECTION_EDITABLE); | 161 | m_invert->setActivationConditions(KisAction::SELECTION_EDITABLE); | ||
177 | m_invert->setOperationID("invertselection"); | 162 | m_invert->setOperationID("invertselection"); | ||
178 | m_invert->setToolTip("foo"); | | |||
179 | | ||||
180 | m_invert->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I)); | | |||
181 | actionManager->addAction("invert", m_invert); | | |||
182 | 163 | | |||
183 | actionManager->registerOperation(new KisInvertSelectionOperaton); | 164 | actionManager->registerOperation(new KisInvertSelectionOperaton); | ||
184 | 165 | | |||
185 | m_copyToNewLayer = new KisAction(i18n("Copy Selection to New Layer"), this); | 166 | m_copyToNewLayer = actionManager->createAction("copy_selection_to_new_layer"); | ||
186 | m_copyToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED); | 167 | m_copyToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
187 | m_copyToNewLayer->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_J)); | | |||
188 | actionManager->addAction("copy_selection_to_new_layer", m_copyToNewLayer); | | |||
189 | connect(m_copyToNewLayer, SIGNAL(triggered()), this, SLOT(copySelectionToNewLayer())); | 168 | connect(m_copyToNewLayer, SIGNAL(triggered()), this, SLOT(copySelectionToNewLayer())); | ||
190 | 169 | | |||
191 | m_cutToNewLayer = new KisAction(i18n("Cut Selection to New Layer"), this); | 170 | m_cutToNewLayer = actionManager->createAction("cut_selection_to_new_layer"); | ||
192 | m_cutToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED); | 171 | m_cutToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
193 | m_cutToNewLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 172 | m_cutToNewLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
194 | m_cutToNewLayer->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_J)); | | |||
195 | actionManager->addAction("cut_selection_to_new_layer", m_cutToNewLayer); | | |||
196 | connect(m_cutToNewLayer, SIGNAL(triggered()), this, SLOT(cutToNewLayer())); | 173 | connect(m_cutToNewLayer, SIGNAL(triggered()), this, SLOT(cutToNewLayer())); | ||
197 | 174 | | |||
198 | m_fillForegroundColor = new KisAction(i18n("Fill with Foreground Color"), this); | 175 | m_fillForegroundColor = actionManager->createAction("fill_selection_foreground_color"); | ||
199 | m_fillForegroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE); | 176 | m_fillForegroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
200 | m_fillForegroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 177 | m_fillForegroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
201 | m_fillForegroundColor->setDefaultShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Backspace)); | | |||
202 | actionManager->addAction("fill_selection_foreground_color", m_fillForegroundColor); | | |||
203 | connect(m_fillForegroundColor, SIGNAL(triggered()), this, SLOT(fillForegroundColor())); | 178 | connect(m_fillForegroundColor, SIGNAL(triggered()), this, SLOT(fillForegroundColor())); | ||
204 | 179 | | |||
205 | m_fillBackgroundColor = new KisAction(i18n("Fill with Background Color"), this); | 180 | m_fillBackgroundColor = actionManager->createAction("fill_selection_background_color"); | ||
206 | m_fillBackgroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE); | 181 | m_fillBackgroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
207 | m_fillBackgroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 182 | m_fillBackgroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
208 | m_fillBackgroundColor->setDefaultShortcut(QKeySequence(Qt::Key_Backspace)); | | |||
209 | actionManager->addAction("fill_selection_background_color", m_fillBackgroundColor); | | |||
210 | connect(m_fillBackgroundColor, SIGNAL(triggered()), this, SLOT(fillBackgroundColor())); | 183 | connect(m_fillBackgroundColor, SIGNAL(triggered()), this, SLOT(fillBackgroundColor())); | ||
211 | 184 | | |||
212 | m_fillPattern = new KisAction(i18n("Fill with Pattern"), this); | 185 | m_fillPattern = actionManager->createAction("fill_selection_pattern"); | ||
213 | m_fillPattern->setActivationFlags(KisAction::ACTIVE_DEVICE); | 186 | m_fillPattern->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
214 | m_fillPattern->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 187 | m_fillPattern->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
215 | actionManager->addAction("fill_selection_pattern", m_fillPattern); | | |||
216 | connect(m_fillPattern, SIGNAL(triggered()), this, SLOT(fillPattern())); | 188 | connect(m_fillPattern, SIGNAL(triggered()), this, SLOT(fillPattern())); | ||
217 | 189 | | |||
218 | m_fillForegroundColorOpacity = new KisAction(i18n("Fill with Foreground Color (Opacity)"), this); | 190 | m_fillForegroundColorOpacity = actionManager->createAction("fill_selection_foreground_color_opacity"); | ||
219 | m_fillForegroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | 191 | m_fillForegroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
220 | m_fillForegroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 192 | m_fillForegroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
221 | m_fillForegroundColorOpacity->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Backspace)); | | |||
222 | actionManager->addAction("fill_selection_foreground_color_opacity", m_fillForegroundColorOpacity); | | |||
223 | connect(m_fillForegroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillForegroundColorOpacity())); | 193 | connect(m_fillForegroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillForegroundColorOpacity())); | ||
224 | 194 | | |||
225 | m_fillBackgroundColorOpacity = new KisAction(i18n("Fill with Background Color (Opacity)"), this); | 195 | m_fillBackgroundColorOpacity = actionManager->createAction("fill_selection_background_color_opacity"); | ||
226 | m_fillBackgroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | 196 | m_fillBackgroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
227 | m_fillBackgroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 197 | m_fillBackgroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
228 | m_fillBackgroundColorOpacity->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_Backspace)); | | |||
229 | actionManager->addAction("fill_selection_background_color_opacity", m_fillBackgroundColorOpacity); | | |||
230 | connect(m_fillBackgroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillBackgroundColorOpacity())); | 198 | connect(m_fillBackgroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillBackgroundColorOpacity())); | ||
231 | 199 | | |||
232 | m_fillPatternOpacity = new KisAction(i18n("Fill with Pattern (Opacity)"), this); | 200 | m_fillPatternOpacity = actionManager->createAction("fill_selection_pattern_opacity"); | ||
233 | m_fillPatternOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | 201 | m_fillPatternOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE); | ||
234 | m_fillPatternOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | 202 | m_fillPatternOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE); | ||
235 | actionManager->addAction("fill_selection_pattern_opacity", m_fillPatternOpacity); | | |||
236 | connect(m_fillPatternOpacity, SIGNAL(triggered()), this, SLOT(fillPatternOpacity())); | 203 | connect(m_fillPatternOpacity, SIGNAL(triggered()), this, SLOT(fillPatternOpacity())); | ||
237 | 204 | | |||
238 | m_strokeShapes = new KisAction(i18nc("@action:inmenu", "Stro&ke selected shapes"), this); | 205 | m_strokeShapes = actionManager->createAction("stroke_shapes"); | ||
239 | m_strokeShapes->setActivationFlags(KisAction::SHAPES_SELECTED); | 206 | m_strokeShapes->setActivationFlags(KisAction::SHAPES_SELECTED); | ||
240 | actionManager->addAction("stroke_shapes", m_strokeShapes); | | |||
241 | connect(m_strokeShapes, SIGNAL(triggered()), this, SLOT(paintSelectedShapes())); | 207 | connect(m_strokeShapes, SIGNAL(triggered()), this, SLOT(paintSelectedShapes())); | ||
242 | 208 | | |||
243 | m_toggleDisplaySelection = new KisAction(i18n("Display Selection"), this); | 209 | m_toggleDisplaySelection = actionManager->createAction("toggle_display_selection"); | ||
244 | m_toggleDisplaySelection->setCheckable(true); | 210 | m_toggleDisplaySelection->setCheckable(true); | ||
245 | m_toggleDisplaySelection->setActivationFlags(KisAction::ACTIVE_NODE); | 211 | m_toggleDisplaySelection->setActivationFlags(KisAction::ACTIVE_NODE); | ||
246 | | ||||
247 | m_toggleDisplaySelection->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); | | |||
248 | actionManager->addAction("toggle_display_selection", m_toggleDisplaySelection); | | |||
249 | connect(m_toggleDisplaySelection, SIGNAL(triggered()), this, SLOT(toggleDisplaySelection())); | 212 | connect(m_toggleDisplaySelection, SIGNAL(triggered()), this, SLOT(toggleDisplaySelection())); | ||
250 | 213 | | |||
251 | m_toggleDisplaySelection->setChecked(true); | 214 | m_toggleDisplaySelection->setChecked(true); | ||
252 | 215 | | |||
253 | m_imageResizeToSelection = new KisAction(i18n("Trim to Selection"), this); | 216 | m_imageResizeToSelection = actionManager->createAction("resizeimagetoselection"); | ||
254 | m_imageResizeToSelection->setActivationFlags(KisAction::PIXELS_SELECTED); | 217 | m_imageResizeToSelection->setActivationFlags(KisAction::PIXELS_SELECTED); | ||
255 | actionManager->addAction("resizeimagetoselection", m_imageResizeToSelection); | | |||
256 | connect(m_imageResizeToSelection, SIGNAL(triggered()), this, SLOT(imageResizeToSelection())); | 218 | connect(m_imageResizeToSelection, SIGNAL(triggered()), this, SLOT(imageResizeToSelection())); | ||
257 | 219 | | |||
258 | KisAction *action = new KisAction(i18nc("@action:inmenu", "&Convert to Vector Selection"), this); | 220 | action = actionManager->createAction("convert_to_vector_selection"); | ||
259 | action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | 221 | action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | ||
260 | actionManager->addAction("convert_to_vector_selection", action); | | |||
261 | connect(action, SIGNAL(triggered()), SLOT(convertToVectorSelection())); | 222 | connect(action, SIGNAL(triggered()), SLOT(convertToVectorSelection())); | ||
262 | 223 | | |||
263 | action = new KisAction(i18nc("@action:inmenu", "Convert &Shapes to Vector Selection"), this); | 224 | action = actionManager->createAction("convert_shapes_to_vector_selection"); | ||
264 | action->setActivationFlags(KisAction::SHAPES_SELECTED); | 225 | action->setActivationFlags(KisAction::SHAPES_SELECTED); | ||
265 | actionManager->addAction("convert_shapes_to_vector_selection", action); | | |||
266 | connect(action, SIGNAL(triggered()), SLOT(convertShapesToVectorSelection())); | 226 | connect(action, SIGNAL(triggered()), SLOT(convertShapesToVectorSelection())); | ||
267 | 227 | | |||
268 | action = new KisAction(i18nc("@action:inmenu", "&Convert to Shape"), this); | 228 | action = actionManager->createAction("convert_selection_to_shape"); | ||
269 | action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | 229 | action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS); | ||
270 | actionManager->addAction("convert_selection_to_shape", action); | | |||
271 | connect(action, SIGNAL(triggered()), SLOT(convertToShape())); | 230 | connect(action, SIGNAL(triggered()), SLOT(convertToShape())); | ||
272 | 231 | | |||
273 | m_toggleSelectionOverlayMode = new KisAction(i18nc("@action:inmenu", "&Toggle Selection Display Mode"), this); | 232 | m_toggleSelectionOverlayMode = actionManager->createAction("toggle-selection-overlay-mode"); | ||
274 | actionManager->addAction("toggle-selection-overlay-mode", m_toggleSelectionOverlayMode); | | |||
275 | connect(m_toggleSelectionOverlayMode, SIGNAL(triggered()), SLOT(slotToggleSelectionDecoration())); | 233 | connect(m_toggleSelectionOverlayMode, SIGNAL(triggered()), SLOT(slotToggleSelectionDecoration())); | ||
276 | 234 | | |||
277 | QClipboard *cb = QApplication::clipboard(); | 235 | QClipboard *cb = QApplication::clipboard(); | ||
278 | connect(cb, SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); | 236 | connect(cb, SIGNAL(dataChanged()), SLOT(clipboardDataChanged())); | ||
279 | 237 | | |||
280 | } | 238 | } | ||
281 | 239 | | |||
282 | 240 | | |||
▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines |