Commit 17a84524 authored by Michael Abrahams's avatar Michael Abrahams

Replace most calls to setActivationFlags() with static data

The new function actionRegistry->getActionProperty exposes the .action
data in a more user-friendly way.
parent 877d96bd
<?xml version="1.0" encoding="UTF-8"?>
<ActionCollection version="2" name="Krita">
<Actions category="General">
<text>Krita</text>
<Action name="open_resources_directory">
......@@ -286,7 +285,7 @@
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="make_brush_color_lighter">
......@@ -375,7 +374,7 @@
<activationFlags>10000</activationFlags>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="hmirror_action">
......@@ -399,7 +398,7 @@
<activationFlags>10000</activationFlags>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="brushslider3">
......@@ -2463,7 +2462,7 @@
<statusTip></statusTip>
</Action>
<Action name="remove_layer">
<icon></icon>
<icon>deletelayer</icon>
<text>&amp;Remove Layer</text>
<whatsThis></whatsThis>
<toolTip>Remove Layer</toolTip>
......@@ -2502,7 +2501,7 @@
<statusTip></statusTip>
</Action>
<Action name="layer_properties">
<icon></icon>
<icon>properties</icon>
<text>&amp;Properties...</text>
<whatsThis></whatsThis>
<toolTip>Properties</toolTip>
......@@ -2537,7 +2536,7 @@
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
</Actions>
......
......@@ -474,7 +474,7 @@
<activationConditions>0</activationConditions>
<shortcut>Tab</shortcut>
<defaultShortcut>Tab</defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="fullscreen">
......@@ -500,7 +500,7 @@
<activationConditions>0</activationConditions>
<shortcut>W</shortcut>
<defaultShortcut>W</defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="level_of_detail_mode">
......@@ -602,7 +602,7 @@
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="view_show_guides">
......@@ -615,7 +615,7 @@
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable>false</isCheckable>
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="showStatusBar">
......@@ -650,6 +650,7 @@
<whatsThis></whatsThis>
<toolTip>Snap To Grid</toolTip>
<iconText>Snap To Grid</iconText>
<activationFlags>1000</activationFlags>
<shortcut>Ctrl+Shift+;</shortcut>
<defaultShortcut>Ctrl+Shift+;</defaultShortcut>
<isCheckable>true</isCheckable>
......@@ -1754,7 +1755,7 @@
</Action>
<Action name="gmic">
<icon></icon>
<text>Apply G'Mic Action...</text>
<text>G'MIC</text>
<whatsThis></whatsThis>
<toolTip>Apply G'Mic Action</toolTip>
<iconText>Apply G'Mic Action</iconText>
......@@ -1880,6 +1881,17 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="settings_active_author">
<icon>im-user</icon>
<text>Active Author Profile</text>
<whatsThis></whatsThis>
<toolTip>Active Author Profile</toolTip>
<iconText>Active Author Profile</iconText>
<shortcut></shortcut>
<defaultShortcut></defaultShortcut>
<isCheckable></isCheckable>
<statusTip></statusTip>
</Action>
<Action name="options_configure_keybinding">
<icon>configure-shortcuts</icon>
<text>Configure S&amp;hortcuts...</text>
......
......@@ -82,27 +82,20 @@ BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QVariantList &)
if (parent->inherits("KisViewManager")) {
m_view = (KisViewManager*) parent;
KisAction* action = 0;
// Open and play action
action = new KisAction(KisIconUtils::loadIcon("media-playback-start"), i18n("Open and play..."), this);
addAction("Macro_Open_Play", action);
KisAction* action = createAction("Macro_Open_Play");
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenPlay()));
// Open and edit action
action = new KisAction(KisIconUtils::loadIcon("document-edit"), i18n("Open and edit..."), this);
addAction("Macro_Open_Edit", action);
action = createAction("Macro_Open_Edit");
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenEdit()));
// Start recording action
m_startRecordingMacroAction = new KisAction(KisIconUtils::loadIcon("media-record"), i18n("Start recording macro"), this);
m_startRecordingMacroAction->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("Recording_Start_Recording_Macro", m_startRecordingMacroAction);
m_startRecordingMacroAction = createAction("Recording_Start_Recording_Macro");
connect(m_startRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStartRecordingMacro()));
// Save recorded action
m_stopRecordingMacroAction = new KisAction(KisIconUtils::loadIcon("media-playback-stop"), i18n("Stop recording actions"), this);
m_stopRecordingMacroAction->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("Recording_Stop_Recording_Macro", m_stopRecordingMacroAction);
m_stopRecordingMacroAction = createAction("Recording_Stop_Recording_Macro");
connect(m_stopRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStopRecordingMacro()));
m_stopRecordingMacroAction->setEnabled(false);
}
......
......@@ -34,9 +34,7 @@ K_PLUGIN_FACTORY_WITH_JSON(ClonesArrayFactory, "kritaclonesarray.json", register
ClonesArray::ClonesArray(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("Clones &Array..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
addAction("clones_array", action);
KisAction *action = createAction("clones_array");
connect(action, SIGNAL(triggered()), this, SLOT(slotCreateClonesArray()));
}
......
......@@ -46,16 +46,10 @@ K_PLUGIN_FACTORY_WITH_JSON(ColorRangeFactory, "kritacolorrange.json", registerPl
ColorRange::ColorRange(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction* action = new KisAction(i18n("Select from Color Range..."), this);
action->setActivationFlags(KisAction::ACTIVE_DEVICE);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
addAction("colorrange", action);
KisAction* action = createAction("colorrange");
connect(action, SIGNAL(triggered()), this, SLOT(slotActivated()));
action = new KisAction(i18n("Select Opaque"), this);
action->setActivationFlags(KisAction::ACTIVE_DEVICE);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
addAction("selectopaque", action);
action = createAction("selectopaque");
connect(action, SIGNAL(triggered()), this, SLOT(selectOpaque()));
}
......
......@@ -56,12 +56,9 @@ ColorSpaceConversion::ColorSpaceConversion(QObject *parent, const QVariantList &
: KisViewPlugin(parent)
{
KisAction *action = m_view->actionManager()->createAction("imagecolorspaceconversion");
action->setActivationFlags(KisAction::ACTIVE_NODE);
connect(action, SIGNAL(triggered()), this, SLOT(slotImageColorSpaceConversion()));
action = m_view->actionManager()->createAction("layercolorspaceconversion");
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
connect(action, SIGNAL(triggered()), this, SLOT(slotLayerColorSpaceConversion()));
}
......
......@@ -85,11 +85,8 @@ KisGmicPlugin::KisGmicPlugin(QObject *parent, const QVariantList &)
m_onCanvasPreviewRequestCounter(0),
m_filteringIsRunning(false)
{
KisAction *action = new KisAction(i18n("G'MIC"), this);
action->setActivationFlags(KisAction::ACTIVE_DEVICE);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
KisAction *action = createAction("gmic");
connect(action, SIGNAL(triggered()), this, SLOT(slotShowGmicDialog()));
addAction("gmic", action);
KoResourcePaths::addResourceType("gmic_definitions", "data", "krita/gmic/");
m_blacklistPath = KoResourcePaths::findResource("gmic_definitions", STANDARD_GMIC_DEFINITION + ".blacklist");
......
......@@ -38,9 +38,7 @@ K_PLUGIN_FACTORY_WITH_JSON(HistogramFactory, "kritahistogram.json", registerPlug
Histogram::Histogram(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction* action = new KisAction(i18n("&Histogram..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
addAction("histogram", action);
KisAction* action = createAction("histogram");
connect(action, SIGNAL(triggered()), this, SLOT(slotActivated()));
}
......
......@@ -49,22 +49,15 @@ ImageSize::ImageSize(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = createAction("imagesize");
action->setActivationFlags(KisAction::ACTIVE_NODE);
connect(action, SIGNAL(triggered()), this, SLOT(slotImageSize()));
action = createAction("canvassize");
action->setActivationFlags(KisAction::ACTIVE_NODE);
connect(action, SIGNAL(triggered()), this, SLOT(slotCanvasSize()));
action = createAction("layersize");
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
connect(action, SIGNAL(triggered()), this, SLOT(slotLayerSize()));
action = createAction("selectionscale");
action->setActivationFlags(KisAction::PIXELS_SELECTED);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
Q_CHECK_PTR(action);
connect(action, SIGNAL(triggered()), this, SLOT(slotSelectionScale()));
}
......
......@@ -54,7 +54,6 @@ Imagesplit::Imagesplit(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = createAction("imagesplit");
action->setActivationFlags(KisAction::ACTIVE_NODE);
connect(action, SIGNAL(triggered()), this, SLOT(slotImagesplit()));
}
......
......@@ -55,9 +55,7 @@ K_PLUGIN_FACTORY_WITH_JSON(LayerSplitFactory, "kritalayersplit.json", registerPl
LayerSplit::LayerSplit(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("Split Layer..."), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("layersplit", action);
KisAction *action = createAction("layersplit");
connect(action, SIGNAL(triggered()), this, SLOT(slotLayerSplit()));
}
......
......@@ -50,8 +50,6 @@ metadataeditorPlugin::metadataeditorPlugin(QObject *parent, const QVariantList &
: KisViewPlugin(parent)
{
KisAction *action = createAction("EditLayerMetaData");
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
connect(action, SIGNAL(triggered()), this, SLOT(slotEditLayerMetaData()));
}
......
......@@ -39,40 +39,30 @@ ModifySelection::ModifySelection(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction* action = createAction("growselection");
action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
action->setOperationID("growselection");
addUIFactory(new KisOperationUIWidgetFactory<WdgGrowSelection>("growselection"));
addOperation(new GrowSelectionOperation);
action = createAction("shrinkselection");
action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
action->setOperationID("shrinkselection");
addUIFactory(new KisOperationUIWidgetFactory<WdgShrinkSelection>("shrinkselection"));
addOperation(new ShrinkSelectionOperation);
action = createAction("borderselection");
action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
action->setOperationID("borderselection");
addUIFactory(new KisOperationUIWidgetFactory<WdgBorderSelection>("borderselection"));
addOperation(new BorderSelectionOperation);
action = createAction("featherselection");
action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
action->setOperationID("featherselection");
addUIFactory(new KisOperationUIWidgetFactory<WdgFeatherSelection>("featherselection"));
addOperation(new FeatherSelectionOperation);
action = createAction("smoothselection");
action->setActivationFlags(KisAction::PIXEL_SELECTION_WITH_PIXELS);
action->setActivationConditions(KisAction::SELECTION_EDITABLE);
action->setOperationID("smoothselection");
addOperation(new SmoothSelectionOperation);
......
......@@ -45,12 +45,9 @@ OffsetImage::OffsetImage(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = createAction("offsetimage");
action->setActivationFlags(KisAction::ACTIVE_NODE);
connect(action, SIGNAL(triggered()), this, SLOT(slotOffsetImage()));
action = createAction("offsetlayer");
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
connect(action, SIGNAL(triggered()), this, SLOT(slotOffsetLayer()));
}
......
......@@ -44,58 +44,34 @@ RotateImage::RotateImage(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("&Rotate Image..."), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("rotateimage", action);
KisAction *action = createAction("rotateimage");
connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage()));
action = new KisAction(KisIconUtils::loadIcon("object-rotate-right"), i18nc("rotate image 90 degrees to the right", "Rotate Image 90° to the Right"), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("rotateImageCW90", action);
action = createAction("rotateImageCW90");
connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage90()));
action = new KisAction(i18nc("rotate image 180 degrees to the right", "Rotate Image 180°"), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("rotateImage180", action);
action = createAction("rotateImage180");
connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage180()));
action = new KisAction(KisIconUtils::loadIcon("object-rotate-left"), i18nc("rotate image 90 degrees to the left", "Rotate Image 90° to the Right"), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("rotateImageCCW90", action);
action = createAction("rotateImageCCW90");
connect(action, SIGNAL(triggered()), this, SLOT(slotRotateImage270()));
action = new KisAction(KisIconUtils::loadIcon("symmetry-horizontal"), i18n("Mirror Image Horizontally"), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("mirrorImageHorizontal", action);
action = createAction("mirrorImageHorizontal");
connect(action, SIGNAL(triggered()), this, SLOT(slotMirrorImageHorizontal()));
action = new KisAction(KisIconUtils::loadIcon("symmetry-vertical"), i18n("Mirror Image Vertically"), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("mirrorImageVertical", action);
action = createAction("mirrorImageVertical");
connect(action, SIGNAL(triggered()), this, SLOT(slotMirrorImageVertical()));
action = new KisAction(i18n("&Rotate Layer..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
addAction("rotatelayer", action);
action = createAction("rotatelayer");
connect(action, SIGNAL(triggered()), this, SLOT(slotRotateLayer()));
action = new KisAction(i18nc("rotate the layer 180 degrees", "Rotate Layer 180°"), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
addAction("rotateLayer180", action);
action = createAction("rotateLayer180");
connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotate180()));
action = new KisAction(KisIconUtils::loadIcon("object-rotate-right"), i18nc("rotate the layer 90 degrees to the right", "Rotate Layer 90° to the Right"), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
addAction("rotateLayerCW90", action);
action = createAction("rotateLayerCW90");
connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateRight90()));
action = new KisAction(KisIconUtils::loadIcon("object-rotate-left"), i18nc("rotate the layer 90 degrees to the left", "Rotate Layer 90° to the Left"), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
addAction("rotateLayerCCW90", action);
action = createAction("rotateLayerCCW90");
connect(action, SIGNAL(triggered()), m_view->nodeManager(), SLOT(rotateLeft90()));
}
......
......@@ -48,9 +48,7 @@ K_PLUGIN_FACTORY_WITH_JSON(KisSeparateChannelsPluginFactory, "kritaseparatechann
KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("Separate Image..."), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("separate", action);
KisAction *action = createAction("separate");
connect(action, SIGNAL(triggered(bool)), SLOT(slotSeparate()));
}
......
......@@ -36,15 +36,10 @@ K_PLUGIN_FACTORY_WITH_JSON(ShearImageFactory, "kritashearimage.json", registerPl
ShearImage::ShearImage(QObject *parent, const QVariantList &)
: KisViewPlugin(parent)
{
KisAction *action = new KisAction(i18n("&Shear Image..."), this);
action->setActivationFlags(KisAction::ACTIVE_NODE);
addAction("shearimage", action);
KisAction *action = createAction("shearimage");
connect(action, SIGNAL(triggered()), this, SLOT(slotShearImage()));
action = new KisAction(i18n("&Shear Layer..."), this);
action->setActivationFlags(KisAction::ACTIVE_LAYER);
action->setActivationConditions(KisAction::ACTIVE_NODE_EDITABLE);
addAction("shearlayer", action);
action = createAction("shearlayer");
connect(action, SIGNAL(triggered()), this, SLOT(slotShearLayer()));
}
......
......@@ -2095,17 +2095,13 @@ void KisMainWindow::createActions()
d->redo->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->exportPdf = actionManager->createAction("file_export_pdf");
d->exportPdf->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->exportPdf->setIcon(KisIconUtils::loadIcon("application-pdf"));
connect(d->exportPdf, SIGNAL(triggered()), this, SLOT(exportToPdf()));
#ifdef HAVE_OPENGL
d->exportAnimation = actionManager->createAction("file_export_animation");
d->exportAnimation->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->exportAnimation, SIGNAL(triggered()), this, SLOT(exportAnimation()));
#endif
d->closeAll = actionManager->createAction("file_close_all");
d->closeAll->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->closeAll, SIGNAL(triggered()), this, SLOT(slotFileCloseAll()));
// d->reloadFile = actionManager->createAction("file_reload_file");
......@@ -2116,13 +2112,11 @@ void KisMainWindow::createActions()
connect(d->importFile, SIGNAL(triggered(bool)), this, SLOT(slotImportFile()));
d->exportFile = actionManager->createAction("file_export_file");
d->exportFile->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->exportFile, SIGNAL(triggered(bool)), this, SLOT(slotExportFile()));
/* The following entry opens the document information dialog. Since the action is named so it
intends to show data this entry should not have a trailing ellipses (...). */
d->showDocumentInfo = actionManager->createAction("file_documentinfo");
d->showDocumentInfo->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->showDocumentInfo, SIGNAL(triggered(bool)), this, SLOT(slotDocumentInfo()));
......@@ -2146,26 +2140,21 @@ void KisMainWindow::createActions()
actionCollection()->addAction("window", d->windowMenu);
d->mdiCascade = actionManager->createAction("windows_cascade");
d->mdiCascade->setActivationFlags(KisAction::MULTIPLE_IMAGES);
connect(d->mdiCascade, SIGNAL(triggered()), d->mdiArea, SLOT(cascadeSubWindows()));
d->mdiTile = actionManager->createAction("windows_tile");
d->mdiTile->setActivationFlags(KisAction::MULTIPLE_IMAGES);
connect(d->mdiTile, SIGNAL(triggered()), d->mdiArea, SLOT(tileSubWindows()));
d->mdiNextWindow = actionManager->createAction("windows_next");
d->mdiNextWindow->setActivationFlags(KisAction::MULTIPLE_IMAGES);
connect(d->mdiNextWindow, SIGNAL(triggered()), d->mdiArea, SLOT(activateNextSubWindow()));
d->mdiPreviousWindow = actionManager->createAction("windows_previous");
d->mdiPreviousWindow->setActivationFlags(KisAction::MULTIPLE_IMAGES);
connect(d->mdiPreviousWindow, SIGNAL(triggered()), d->mdiArea, SLOT(activatePreviousSubWindow()));
d->newWindow = actionManager->createAction("view_newwindow");
connect(d->newWindow, SIGNAL(triggered(bool)), this, SLOT(newWindow()));
d->close = actionManager->createAction("file_close");
d->close->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->close, SIGNAL(triggered()), SLOT(closeCurrentWindow()));
actionManager->createStandardAction(KStandardAction::Preferences, this, SLOT(slotPreferences()));
......
......@@ -634,11 +634,9 @@ KisUndoAdapter * KisViewManager::undoAdapter()
void KisViewManager::createActions()
{
d->saveIncremental = actionManager()->createAction("save_incremental_version");
d->saveIncremental->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->saveIncremental, SIGNAL(triggered()), this, SLOT(slotSaveIncremental()));
d->saveIncrementalBackup = actionManager()->createAction("save_incremental_backup");
d->saveIncrementalBackup->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->saveIncrementalBackup, SIGNAL(triggered()), this, SLOT(slotSaveIncrementalBackup()));
connect(mainWindow(), SIGNAL(documentSaved()), this, SLOT(slotDocumentSaved()));
......@@ -650,39 +648,24 @@ void KisViewManager::createActions()
connect(tabletDebugger, SIGNAL(triggered()), this, SLOT(toggleTabletLogger()));
d->createTemplate = actionManager()->createAction("create_template");
d->createTemplate->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->createTemplate, SIGNAL(triggered()), this, SLOT(slotCreateTemplate()));
d->createCopy = actionManager()->createAction("create_copy");
d->createCopy->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(d->createCopy, SIGNAL(triggered()), this, SLOT(slotCreateCopy()));
d->openResourcesDirectory = actionManager()->createAction("open_resources_directory");
connect(d->openResourcesDirectory, SIGNAL(triggered()), SLOT(openResourcesDirectory()));
d->rotateCanvasRight = actionManager()->createAction("rotate_canvas_right");
d->rotateCanvasRight->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->rotateCanvasLeft = actionManager()->createAction("rotate_canvas_left");
d->rotateCanvasLeft->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->wrapAroundAction = actionManager()->createAction("wrap_around_mode");
d->wrapAroundAction->setCheckable(true);
d->wrapAroundAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->rotateCanvasRight = actionManager()->createAction("rotate_canvas_right");
d->rotateCanvasLeft = actionManager()->createAction("rotate_canvas_left");
d->wrapAroundAction = actionManager()->createAction("wrap_around_mode");
d->levelOfDetailAction = actionManager()->createAction("level_of_detail_mode");
d->levelOfDetailAction->setCheckable(true);
d->levelOfDetailAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
KisAction *tAction = actionManager()->createAction("showStatusBar");
tAction->setCheckable(true);
tAction->setChecked(true);
tAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool)));
tAction = actionManager()->createAction("view_show_just_the_canvas");
tAction->setActivationFlags(KisAction::NONE);
tAction->setCheckable(true);
tAction->setChecked(false);
connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showJustTheCanvas(bool)));
......@@ -690,26 +673,18 @@ void KisViewManager::createActions()
KisAction *a = dynamic_cast<KisAction*>(actionCollection()->action("format_italic"));
if (a) {
a->setDefaultShortcut(QKeySequence());
a->setActivationConditions(KisAction::SELECTION_EDITABLE);
}
a = actionManager()->createAction("edit_blacklist_cleanup");
connect(a, SIGNAL(triggered()), this, SLOT(slotBlacklistCleanup()));
d->showRulersAction = actionManager()->createAction("view_ruler");
d->showRulersAction->setCheckable(true);
d->showRulersAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
KisConfig cfg;
d->showRulersAction = actionManager()->createAction("view_ruler");
d->showRulersAction->setChecked(cfg.showRulers());
d->showGuidesAction = actionManager()->createAction("view_show_guides");
d->showGuidesAction->setCheckable(true);
d->showGuidesAction->setCheckable(false);
d->showGuidesAction->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->zoomTo100pct = actionManager()->createAction("zoom_to_100pct");
d->zoomTo100pct->setActivationFlags(KisAction::ACTIVE_IMAGE);
d->zoomIn = actionManager()->createStandardAction(KStandardAction::ZoomIn, 0, "");
d->zoomOut = actionManager()->createStandardAction(KStandardAction::ZoomOut, 0, "");
......
......@@ -49,10 +49,8 @@ KisGridManager::~KisGridManager()
void KisGridManager::setup(KisActionManager* actionManager)
{
m_toggleGrid = actionManager->createAction("view_grid");
m_toggleGrid->setActivationFlags(KisAction::ACTIVE_NODE);
m_toggleSnapToGrid = actionManager->createAction("view_snap_to_grid");
m_toggleSnapToGrid->setActivationFlags(KisAction::ACTIVE_NODE);
connect(m_toggleSnapToGrid, SIGNAL(triggered()), this, SLOT(toggleSnapToGrid()));
}
......
......@@ -19,7 +19,6 @@
#include "kis_action.h"
#include "kis_action_manager.h"
#include "kis_action_registry.h"
#include <QEvent>
class Q_DECL_HIDDEN KisAction::Private {
......
......@@ -45,6 +45,11 @@ class KRITAUI_EXPORT KisAction : public QWidgetAction
{
Q_OBJECT
public:
/**
* If you re-order these, you must change the associated values in
* krita.action and kritamenu.action!
*/
enum ActivationFlag {
NONE = 0x0000, ///< Always activate
ACTIVE_IMAGE = 0x0001, ///< Activate if there is at least one image
......
......@@ -31,7 +31,6 @@
#include "operations/kis_operation.h"
#include "kis_layer.h"
#include "KisDocument.h"
#include "kis_action_registry.h"
#include "QFile"
#include <QDomDocument>
......@@ -164,10 +163,16 @@ KisAction *KisActionManager::createAction(const QString &name)
// will add them to the KisActionRegistry for the time being so we can get
// properly categorized shortcuts.
a = new KisAction();
KisActionRegistry::instance()->propertizeAction(name, a);
KisActionRegistry::instance()->addAction(name, a);
// TODO: Add other static data (activationFlags, etc.) using getActionXml();
auto actionRegistry = KisActionRegistry::instance();
// Add extra properties
actionRegistry->propertizeAction(name, a);
actionRegistry->addAction(name, a);
bool ok; // We will skip this check
int activationFlags = actionRegistry->getActionProperty(name, "activationFlags").toInt(&ok, 2);
int activationConditions = actionRegistry->getActionProperty(name, "activationConditions").toInt(&ok, 2);
a->setActivationFlags((KisAction::ActivationFlags) activationFlags);
a->setActivationConditions((KisAction::ActivationConditions) activationConditions);
addAction(name, a);
......
......@@ -27,6 +27,7 @@
#include "KisView.h"
#include "kstandardaction.h"