Commit 34b21064 authored by Michael Abrahams's avatar Michael Abrahams

Fix some keyboard shortcuts

When adding actions, setDefaultShortcut() should always come before
actionManager()->addAction, since the latter tries to read the shortcut
and register it globally.

Closes T904
parent 55b094b5
......@@ -649,8 +649,8 @@ void KisViewManager::createActions()
d->saveIncrementalBackup->setEnabled(false);
KisAction *tabletDebugger = new KisAction(i18n("Toggle Tablet Debugger"), this);
actionManager()->addAction("tablet_debugger", tabletDebugger );
tabletDebugger->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
actionManager()->addAction("tablet_debugger", tabletDebugger );
connect(tabletDebugger, SIGNAL(triggered()), this, SLOT(toggleTabletLogger()));
d->createTemplate = new KisAction( i18n( "&Create Template From Image..." ), this);
......@@ -670,26 +670,26 @@ void KisViewManager::createActions()
connect(d->openResourcesDirectory, SIGNAL(triggered()), SLOT(openResourcesDirectory()));
d->rotateCanvasRight = new KisAction(i18n("Rotate Canvas Right"), this);
d->rotateCanvasRight->setDefaultShortcut(QKeySequence("Ctrl+]"));
actionManager()->addAction("rotate_canvas_right", d->rotateCanvasRight);
d->rotateCanvasRight->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->rotateCanvasRight->setDefaultShortcut(QKeySequence("Ctrl+]"));
d->rotateCanvasLeft = new KisAction(i18n("Rotate Canvas Left"), this);
d->rotateCanvasLeft->setDefaultShortcut(QKeySequence("Ctrl+["));
actionManager()->addAction("rotate_canvas_left", d->rotateCanvasLeft);
d->rotateCanvasLeft->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->rotateCanvasLeft->setDefaultShortcut(QKeySequence("Ctrl+["));
d->wrapAroundAction = new KisAction(i18n("Wrap Around Mode"), this);
d->wrapAroundAction->setCheckable(true);
d->wrapAroundAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
actionManager()->addAction("wrap_around_mode", d->wrapAroundAction);
d->wrapAroundAction->setDefaultShortcut(QKeySequence(Qt::Key_W));
actionManager()->addAction("wrap_around_mode", d->wrapAroundAction);
d->levelOfDetailAction = new KisAction(i18n("Fast Preview Mode (LOD)"), this);
d->levelOfDetailAction->setCheckable(true);
d->levelOfDetailAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->levelOfDetailAction->setDefaultShortcut(QKeySequence("Shift+L"));
actionManager()->addAction("level_of_detail_mode", d->levelOfDetailAction);
d->levelOfDetailAction->setShortcut(QKeySequence("Shift+L"));
KisAction *tAction = new KisAction(i18n("Show Status Bar"), this);
tAction->setCheckable(true);
......@@ -740,8 +740,8 @@ void KisViewManager::createActions()
d->zoomTo100pct = new KisAction(i18n("Reset zoom"), this);
d->zoomTo100pct->setActivationFlags(KisAction::ACTIVE_IMAGE);
actionManager()->addAction("zoom_to_100pct", d->zoomTo100pct);
d->zoomTo100pct->setDefaultShortcut( QKeySequence( Qt::CTRL + Qt::Key_0 ) );
actionManager()->addAction("zoom_to_100pct", d->zoomTo100pct);
d->zoomIn = actionManager()->createStandardAction(KStandardAction::ZoomIn, 0, "");
d->zoomOut = actionManager()->createStandardAction(KStandardAction::ZoomOut, 0, "");
......
......@@ -58,6 +58,7 @@ void KisGridManager::setup(KisActionManager* actionManager)
m_toggleSnapToGrid->setCheckable(true);
m_toggleSnapToGrid->setActivationFlags(KisAction::ACTIVE_NODE);
m_toggleSnapToGrid->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Semicolon));
// XXX: Why is this disabled?
//actionManager->addAction("view_snap_to_grid", m_toggleSnapToGrid);
connect(m_toggleSnapToGrid, SIGNAL(triggered()), this, SLOT(toggleSnapToGrid()));
}
......
......@@ -292,14 +292,14 @@ void KisLayerManager::setup(KisActionManager* actionManager)
{
m_imageFlatten = new KisAction(i18n("&Flatten image"), this);
m_imageFlatten->setActivationFlags(KisAction::ACTIVE_LAYER);
actionManager->addAction("flatten_image", m_imageFlatten);
m_imageFlatten->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E));
actionManager->addAction("flatten_image", m_imageFlatten);
connect(m_imageFlatten, SIGNAL(triggered()), this, SLOT(flattenImage()));
m_imageMergeLayer = new KisAction(i18n("&Merge with Layer Below"), this);
m_imageMergeLayer->setActivationFlags(KisAction::ACTIVE_LAYER);
actionManager->addAction("merge_layer", m_imageMergeLayer);
m_imageMergeLayer->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
actionManager->addAction("merge_layer", m_imageMergeLayer);
connect(m_imageMergeLayer, SIGNAL(triggered()), this, SLOT(mergeLayer()));
m_flattenLayer = new KisAction(i18n("&Flatten Layer"), this);
......@@ -309,8 +309,8 @@ void KisLayerManager::setup(KisActionManager* actionManager)
KisAction * action = new KisAction(i18n("Rename current layer"), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
actionManager->addAction("RenameCurrentLayer", action);
action->setDefaultShortcut(QKeySequence(Qt::Key_F2));
actionManager->addAction("RenameCurrentLayer", action);
connect(action, SIGNAL(triggered()), this, SLOT(layerProperties()));
m_rasterizeLayer = new KisAction(i18n("Rasterize Layer"), this);
......
......@@ -313,41 +313,41 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
action = new QWidgetAction(this);
action->setText(i18n("Next Favourite Preset"));
view->actionCollection()->addAction("next_favorite_preset", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_Comma));
view->actionCollection()->addAction("next_favorite_preset", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotNextFavoritePreset()));
action = new QWidgetAction(this);
action->setText(i18n("Previous Favourite Preset"));
view->actionCollection()->addAction("previous_favorite_preset", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_Period));
view->actionCollection()->addAction("previous_favorite_preset", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotPreviousFavoritePreset()));
action = new QWidgetAction(this);
action->setText(i18n("Switch to Previous Preset"));
view->actionCollection()->addAction("previous_preset", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_Slash));
view->actionCollection()->addAction("previous_preset", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotSwitchToPreviousPreset()));
if (!cfg.toolOptionsInDocker()) {
action = new QWidgetAction(this);
action->setText(i18n("Show Tool Options"));
view->actionCollection()->addAction("show_tool_options", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_Backslash));
view->actionCollection()->addAction("show_tool_options", action);
connect(action, SIGNAL(triggered()), m_toolOptionsPopupButton, SLOT(showPopupWidget()));
}
action = new QWidgetAction(this);
action->setText(i18n("Show Brush Editor"));
view->actionCollection()->addAction("show_brush_editor", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_F5));
view->actionCollection()->addAction("show_brush_editor", action);
connect(action, SIGNAL(triggered()), m_brushEditorPopupButton, SLOT(showPopupWidget()));
action = new QWidgetAction(this);
action->setText(i18n("Show Brush Presets"));
view->actionCollection()->addAction("show_brush_presets", action);
view->actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::Key_F6));
view->actionCollection()->addAction("show_brush_presets", action);
connect(action, SIGNAL(triggered()), m_presetSelectorPopupButton, SLOT(showPopupWidget()));
QWidget* mirrorActions = new QWidget(this);
......@@ -359,8 +359,8 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
action = new QWidgetAction(this);
action->setText(i18n("Mirror"));
view->actionCollection()->addAction("mirror_actions", action);
action->setDefaultWidget(mirrorActions);
view->actionCollection()->addAction("mirror_actions", action);
action = new QWidgetAction(this);
action->setText(i18n("Workspaces"));
......
......@@ -135,8 +135,8 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
connect(cutSharp, SIGNAL(triggered()), this, SLOT(cutSharp()));
m_pasteNew = new KisAction(i18n("Paste into &New Image"), this);
actionManager->addAction("paste_new", m_pasteNew);
m_pasteNew->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_N));
actionManager->addAction("paste_new", m_pasteNew);
connect(m_pasteNew, SIGNAL(triggered()), this, SLOT(pasteNew()));
m_pasteAt = new KisAction(i18n("Paste at cursor"), this);
......@@ -145,30 +145,30 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
m_copyMerged = new KisAction(i18n("Copy merged"), this);
m_copyMerged->setActivationFlags(KisAction::PIXELS_SELECTED);
actionManager->addAction("copy_merged", m_copyMerged);
m_copyMerged->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
actionManager->addAction("copy_merged", m_copyMerged);
connect(m_copyMerged, SIGNAL(triggered()), this, SLOT(copyMerged()));
m_selectAll = new KisAction(KisIconUtils::loadIcon("select-all"), i18n("Select &All"), this);
actionManager->addAction("select_all", m_selectAll);
m_selectAll->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
actionManager->addAction("select_all", m_selectAll);
connect(m_selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
m_deselect = new KisAction(KisIconUtils::loadIcon("select-clear"), i18n("Deselect"), this);
m_deselect->setActivationFlags(KisAction::PIXELS_SELECTED | KisAction::SHAPES_SELECTED);
actionManager->addAction("deselect", m_deselect);
m_deselect->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A));
actionManager->addAction("deselect", m_deselect);
connect(m_deselect, SIGNAL(triggered()), this, SLOT(deselect()));
m_clear = new KisAction(KisIconUtils::loadIcon("select-clear"), i18n("Clear"), this);
m_clear->setActivationFlags(KisAction::ACTIVE_IMAGE);
actionManager->addAction("clear", m_clear);
m_clear->setDefaultShortcut(QKeySequence((Qt::Key_Delete)));
actionManager->addAction("clear", m_clear);
connect(m_clear, SIGNAL(triggered()), SLOT(clear()));
m_reselect = new KisAction(i18n("&Reselect"), this);
actionManager->addAction("reselect", m_reselect);
m_reselect->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
actionManager->addAction("reselect", m_reselect);
connect(m_reselect, SIGNAL(triggered()), this, SLOT(reselect()));
m_invert = new KisAction(i18n("&Invert Selection"), this);
......@@ -177,36 +177,36 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
m_invert->setOperationID("invertselection");
m_invert->setToolTip("foo");
actionManager->addAction("invert", m_invert);
m_invert->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
actionManager->addAction("invert", m_invert);
actionManager->registerOperation(new KisInvertSelectionOperaton);
m_copyToNewLayer = new KisAction(i18n("Copy Selection to New Layer"), this);
m_copyToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED);
actionManager->addAction("copy_selection_to_new_layer", m_copyToNewLayer);
m_copyToNewLayer->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_J));
actionManager->addAction("copy_selection_to_new_layer", m_copyToNewLayer);
connect(m_copyToNewLayer, SIGNAL(triggered()), this, SLOT(copySelectionToNewLayer()));
m_cutToNewLayer = new KisAction(i18n("Cut Selection to New Layer"), this);
m_cutToNewLayer->setActivationFlags(KisAction::PIXELS_SELECTED);
m_cutToNewLayer->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
actionManager->addAction("cut_selection_to_new_layer", m_cutToNewLayer);
m_cutToNewLayer->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_J));
actionManager->addAction("cut_selection_to_new_layer", m_cutToNewLayer);
connect(m_cutToNewLayer, SIGNAL(triggered()), this, SLOT(cutToNewLayer()));
m_fillForegroundColor = new KisAction(i18n("Fill with Foreground Color"), this);
m_fillForegroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE);
m_fillForegroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
actionManager->addAction("fill_selection_foreground_color", m_fillForegroundColor);
m_fillForegroundColor->setDefaultShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Backspace));
actionManager->addAction("fill_selection_foreground_color", m_fillForegroundColor);
connect(m_fillForegroundColor, SIGNAL(triggered()), this, SLOT(fillForegroundColor()));
m_fillBackgroundColor = new KisAction(i18n("Fill with Background Color"), this);
m_fillBackgroundColor->setActivationFlags(KisAction::ACTIVE_DEVICE);
m_fillBackgroundColor->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
actionManager->addAction("fill_selection_background_color", m_fillBackgroundColor);
m_fillBackgroundColor->setDefaultShortcut(QKeySequence(Qt::Key_Backspace));
actionManager->addAction("fill_selection_background_color", m_fillBackgroundColor);
connect(m_fillBackgroundColor, SIGNAL(triggered()), this, SLOT(fillBackgroundColor()));
m_fillPattern = new KisAction(i18n("Fill with Pattern"), this);
......@@ -218,15 +218,15 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
m_fillForegroundColorOpacity = new KisAction(i18n("Fill with Foreground Color (Opacity)"), this);
m_fillForegroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE);
m_fillForegroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
actionManager->addAction("fill_selection_foreground_color_opacity", m_fillForegroundColorOpacity);
m_fillForegroundColorOpacity->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Backspace));
actionManager->addAction("fill_selection_foreground_color_opacity", m_fillForegroundColorOpacity);
connect(m_fillForegroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillForegroundColorOpacity()));
m_fillBackgroundColorOpacity = new KisAction(i18n("Fill with Background Color (Opacity)"), this);
m_fillBackgroundColorOpacity->setActivationFlags(KisAction::ACTIVE_DEVICE);
m_fillBackgroundColorOpacity->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
actionManager->addAction("fill_selection_background_color_opacity", m_fillBackgroundColorOpacity);
m_fillBackgroundColorOpacity->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_Backspace));
actionManager->addAction("fill_selection_background_color_opacity", m_fillBackgroundColorOpacity);
connect(m_fillBackgroundColorOpacity, SIGNAL(triggered()), this, SLOT(fillBackgroundColorOpacity()));
m_fillPatternOpacity = new KisAction(i18n("Fill with Pattern (Opacity)"), this);
......@@ -244,8 +244,8 @@ void KisSelectionManager::setup(KisActionManager* actionManager)
m_toggleDisplaySelection->setCheckable(true);
m_toggleDisplaySelection->setActivationFlags(KisAction::ACTIVE_NODE);
actionManager->addAction("toggle_display_selection", m_toggleDisplaySelection);
m_toggleDisplaySelection->setDefaultShortcut(QKeySequence(Qt::CTRL + Qt::Key_H));
actionManager->addAction("toggle_display_selection", m_toggleDisplaySelection);
connect(m_toggleDisplaySelection, SIGNAL(triggered()), this, SLOT(toggleDisplaySelection()));
m_toggleDisplaySelection->setChecked(true);
......
......@@ -72,6 +72,8 @@
#include "kis_tool_utils.h"
#include <kis_paintop.h>
#include <kis_paintop_preset.h>
#include <kis_action_manager.h>
#include <kis_action.h>
KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)
: KisTool(canvas, cursor),
......@@ -101,25 +103,25 @@ KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)
m_standardBrushSizes.push_back(maxSize);
}
KisCanvas2 * kiscanvas = dynamic_cast<KisCanvas2*>(canvas);
KisActionManager *actionManager = kiscanvas->viewManager()->actionManager();
KActionCollection *collection = this->canvas()->canvasController()->actionCollection();
if (!collection->action("increase_brush_size")) {
QAction *increaseBrushSize = new QAction(i18n("Increase Brush Size"), collection);
// XXX: Perhaps a better place for these?
if (!actionManager->actionByName("increase_brush_size")) {
KisAction *increaseBrushSize = new KisAction(i18n("Increase Brush Size"));
increaseBrushSize->setShortcut(Qt::Key_BracketRight);
collection->addAction("increase_brush_size", increaseBrushSize);
actionManager->addAction("increase_brush_size", increaseBrushSize);
}
if (!collection->action("decrease_brush_size")) {
QAction *decreaseBrushSize = new QAction(i18n("Decrease Brush Size"), collection);
if (!actionManager->actionByName("decrease_brush_size")) {
KisAction *decreaseBrushSize = new KisAction(i18n("Decrease Brush Size"));
decreaseBrushSize->setShortcut(Qt::Key_BracketLeft);
collection->addAction("decrease_brush_size", decreaseBrushSize);
actionManager->addAction("decrease_brush_size", decreaseBrushSize);
}
addAction("increase_brush_size", dynamic_cast<QAction *>(collection->action("increase_brush_size")));
addAction("decrease_brush_size", dynamic_cast<QAction *>(collection->action("decrease_brush_size")));
addAction("increase_brush_size", dynamic_cast<QAction *>(actionManager->actionByName("increase_brush_size")));
addAction("decrease_brush_size", dynamic_cast<QAction *>(actionManager->actionByName("decrease_brush_size")));
KisCanvas2 * kiscanvas = dynamic_cast<KisCanvas2*>(canvas);
if (kiscanvas && kiscanvas->viewManager()) {
connect(this, SIGNAL(sigPaintingFinished()), kiscanvas->viewManager()->resourceProvider(), SLOT(slotPainting()));
}
......
......@@ -31,6 +31,7 @@ class QKeySequence;
/**
* A factory for KoToolBase objects.
*
* The baseclass for all tool plugins. Each plugin that ships a KoToolBase should also
* ship a factory. That factory will extend this class and set variable data like
* a toolTip and icon in the constructor of that extending class.
......@@ -149,6 +150,8 @@ public:
* Return the default keyboard shortcut for activation of this tool (if
* the shape this tool belongs to is active).
*
* See KoToolManager for use.
*
* @return the shortcut
*/
QKeySequence shortcut() const;
......
......@@ -140,8 +140,8 @@ KoPathTool::KoPathTool(KoCanvasBase *canvas)
connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve()));
m_actionAddPoint = new QAction(koIcon("pathpoint-insert"), i18n("Insert point"), this);
addAction("pathpoint-insert", m_actionAddPoint);
m_actionAddPoint->setShortcut(Qt::Key_Insert);
addAction("pathpoint-insert", m_actionAddPoint);
connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints()));
m_actionRemovePoint = new QAction(koIcon("pathpoint-remove"), i18n("Remove point"), this);
......
......@@ -35,16 +35,16 @@ EmfViewer::EmfViewer( QSize &size )
QMenu *fileMenu = menuBar()->addMenu( "&File" );
// The "Open" action
m_fileOpenAction->setShortcut( Qt::CTRL + Qt::Key_O );
m_fileOpenAction = fileMenu->addAction( "&Open", this,
SLOT( slotOpenFile() ) );
m_fileOpenAction->setShortcut( Qt::CTRL + Qt::Key_O );
fileMenu->addSeparator();
// The "Quit" action
m_fileQuitAction->setShortcut( Qt::CTRL + Qt::Key_Q );
m_fileQuitAction = fileMenu->addAction( "&Quit", qApp,
SLOT( closeAllWindows() ) );
m_fileQuitAction->setShortcut( Qt::CTRL + Qt::Key_Q );
// Set a suitably large size.
resize( m_size + QSize( 50, 50 ) );
......
......@@ -213,24 +213,24 @@ void DefaultTool::setupActions()
{
QAction * actionBringToFront = new QAction(koIcon("object-order-front-calligra"),
i18n("Bring to &Front"), this);
addAction("object_order_front", actionBringToFront);
actionBringToFront->setShortcut(QKeySequence("Ctrl+Shift+]"));
addAction("object_order_front", actionBringToFront);
connect(actionBringToFront, SIGNAL(triggered()), this, SLOT(selectionBringToFront()));
QAction * actionRaise = new QAction(koIcon("object-order-raise-calligra"), i18n("&Raise"), this);
addAction("object_order_raise", actionRaise);
actionRaise->setShortcut(QKeySequence("Ctrl+]"));
addAction("object_order_raise", actionRaise);
connect(actionRaise, SIGNAL(triggered()), this, SLOT(selectionMoveUp()));
QAction * actionLower = new QAction(koIcon("object-order-lower-calligra"), i18n("&Lower"), this);
addAction("object_order_lower", actionLower);
actionLower->setShortcut(QKeySequence("Ctrl+["));
addAction("object_order_lower", actionLower);
connect(actionLower, SIGNAL(triggered()), this, SLOT(selectionMoveDown()));
QAction * actionSendToBack = new QAction(koIcon("object-order-back-calligra"),
i18n("Send to &Back"), this);
addAction("object_order_back", actionSendToBack);
actionSendToBack->setShortcut(QKeySequence("Ctrl+Shift+["));
addAction("object_order_back", actionSendToBack);
connect(actionSendToBack, SIGNAL(triggered()), this, SLOT(selectionSendToBack()));
QAction * actionAlignLeft = new QAction(koIcon("object-align-horizontal-left-calligra"),
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment