[calligra/krita-animation-pentikainen] krita: Add "Show in Timeline" action to the Layers Docker

Dmitry Kazakov dimula73 at gmail.com
Wed Dec 16 17:06:54 UTC 2015


Git commit a811a100a7aedbe1d8afa79df774836f1a2dc016 by Dmitry Kazakov.
Committed on 16/12/2015 at 17:06.
Pushed by dkazakov into branch 'krita-animation-pentikainen'.

Add "Show in Timeline" action to the Layers Docker

CC:kimageshop at kde.org

M  +1    -0    krita/krita.action
M  +10   -3    krita/plugins/extensions/dockers/animation/timeline_docker.cpp
M  +29   -4    krita/plugins/extensions/dockers/animation/timeline_frames_view.cpp
M  +5    -0    krita/plugins/extensions/dockers/animation/timeline_frames_view.h
M  +3    -1    krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp

http://commits.kde.org/calligra/a811a100a7aedbe1d8afa79df774836f1a2dc016

diff --git a/krita/krita.action b/krita/krita.action
index 559199e..7ccdd94 100644
--- a/krita/krita.action
+++ b/krita/krita.action
@@ -339,6 +339,7 @@
     <Action name="first_frame" icon="" text="First Frame" whatsThis="" toolTip="" iconText="" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
     <Action name="last_frame" icon="" text="Last Frame" whatsThis="" toolTip="" iconText="" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
     <Action name="lazy_frame" icon="" text="Auto Frame Mode" whatsThis="" toolTip="" iconText="" shortcut="" defaultShortcut="" isCheckable="true" statusTip=""/>
+    <Action name="show_in_timeline" icon="" text="Show in Timeline" whatsThis="" toolTip="" iconText="" shortcut="" defaultShortcut="" isCheckable="true" statusTip=""/>
     <Action name="" icon="show_tool_options" text="Show Tool Options" whatsThis="" toolTip="Show Tool Options" iconText="Show Tool Options" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
     <Action name="" icon="show_tool_options" text="Show Brush Editor" whatsThis="" toolTip="Show Brush Editor" iconText="Show Brush Editor" shortcut="i" defaultShortcut="" isCheckable="false" statusTip=""/>
     <Action name="" icon="show_tool_options" text="Show Brush Presets" whatsThis="" toolTip="Show Brush Presets" iconText="Show Brush Presets" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
diff --git a/krita/plugins/extensions/dockers/animation/timeline_docker.cpp b/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
index 20acfc2..25626a6 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
+++ b/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
@@ -123,9 +123,16 @@ void TimelineDocker::unsetCanvas()
 
 void TimelineDocker::setMainWindow(KisViewManager *view)
 {
-    Q_UNUSED(view);
-    //KisActionManager *actionManager = view->actionManager();
-    //actionManager->addAction("toggle_onion_skin", m_toggleOnionSkinAction);
+    KisActionManager *actionManager = view->actionManager();
+
+    QMap<QString, KisAction*> actions = m_d->view->globalActions();
+
+    QMap<QString, KisAction*>::iterator it = actions.begin();
+    QMap<QString, KisAction*>::iterator end = actions.end();
+
+    for (; it != end; ++it) {
+        actionManager->addAction(it.key(), it.value());
+    }
 }
 
 #include "timeline_docker.moc"
diff --git a/krita/plugins/extensions/dockers/animation/timeline_frames_view.cpp b/krita/plugins/extensions/dockers/animation/timeline_frames_view.cpp
index 3c54bc3..142ac34 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_frames_view.cpp
+++ b/krita/plugins/extensions/dockers/animation/timeline_frames_view.cpp
@@ -45,6 +45,7 @@
 
 #include "kis_animation_utils.h"
 #include "kis_custom_modifiers_catcher.h"
+#include "kis_action.h"
 
 typedef QPair<QRect, QModelIndex> QItemViewPaintPair;
 typedef QList<QItemViewPaintPair> QItemViewPaintPairs;
@@ -76,7 +77,7 @@ struct TimelineFramesView::Private
     QPoint startZoomPanDragPos;
 
     QToolButton *addLayersButton;
-    QAction *showHideLayerAction;
+    KisAction *showHideLayerAction;
     QMenu *layerEditingMenu;
     QMenu *existingLayersMenu;
 
@@ -84,6 +85,7 @@ struct TimelineFramesView::Private
     QMenu *frameEditingMenu;
 
     QMenu *multipleFrameEditingMenu;
+    QMap<QString, KisAction*> globalActions;
 
 
     KisDraggableToolButton *zoomDragButton;
@@ -158,8 +160,14 @@ TimelineFramesView::TimelineFramesView(QWidget *parent)
     m_d->layerEditingMenu->addAction("New Layer", this, SLOT(slotAddNewLayer()));
     m_d->existingLayersMenu = m_d->layerEditingMenu->addMenu("Add Existing Layer");
     m_d->layerEditingMenu->addSeparator();
-    m_d->showHideLayerAction = m_d->layerEditingMenu->addAction(KisAnimationUtils::showLayerActionName, this, SLOT(slotHideLayerFromTimeline()));
+
+    m_d->showHideLayerAction = new KisAction(KisAnimationUtils::showLayerActionName, this);
+    m_d->showHideLayerAction->setActivationFlags(KisAction::ACTIVE_LAYER);
+    connect(m_d->showHideLayerAction, SIGNAL(triggered()), SLOT(slotHideLayerFromTimeline()));
     m_d->showHideLayerAction->setCheckable(true);
+    m_d->globalActions.insert("show_in_timeline", m_d->showHideLayerAction);
+    m_d->layerEditingMenu->addAction(m_d->showHideLayerAction);
+
     m_d->layerEditingMenu->addAction("Remove Layer", this, SLOT(slotRemoveLayer()));
 
     connect(m_d->existingLayersMenu, SIGNAL(aboutToShow()), SLOT(slotUpdateLayersMenu()));
@@ -195,6 +203,11 @@ TimelineFramesView::~TimelineFramesView()
 {
 }
 
+QMap<QString, KisAction*> TimelineFramesView::globalActions() const
+{
+    return m_d->globalActions;
+}
+
 void resizeToMinimalSize(QAbstractButton *w, int minimalSize) {
     QSize buttonSize = w->sizeHint();
     if (buttonSize.height() > minimalSize) {
@@ -387,9 +400,18 @@ void TimelineFramesView::slotHeaderDataChanged(Qt::Orientation orientation, int
         if (newFps != m_d->fps) {
             setFramesPerSecond(newFps);
         }
+    } else /* if (orientation == Qt::Vertical) */ {
+        updateShowInTimeline();
     }
 }
 
+void TimelineFramesView::rowsInserted(const QModelIndex& parent, int start, int end)
+{
+    QTableView::rowsInserted(parent, start, end);
+    updateShowInTimeline();
+}
+
+
 inline bool isIndexDragEnabled(QAbstractItemModel *model, const QModelIndex &index) {
     return (model->flags(index) & Qt::ItemIsDragEnabled);
 }
@@ -646,11 +668,14 @@ void TimelineFramesView::slotUpdateLayersMenu()
 
 void TimelineFramesView::slotLayerContextMenuRequested(const QPoint &globalPos)
 {
+    m_d->layerEditingMenu->exec(globalPos);
+}
+
+void TimelineFramesView::updateShowInTimeline()
+{
     const int row = m_d->model->activeLayerRow();
     const bool status = m_d->model->headerData(row, Qt::Vertical, TimelineFramesModel::LayerUsedInTimelineRole).toBool();
-
     m_d->showHideLayerAction->setChecked(status);
-    m_d->layerEditingMenu->exec(globalPos);
 }
 
 void TimelineFramesView::slotAddNewLayer()
diff --git a/krita/plugins/extensions/dockers/animation/timeline_frames_view.h b/krita/plugins/extensions/dockers/animation/timeline_frames_view.h
index 191a999..bf72086 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_frames_view.h
+++ b/krita/plugins/extensions/dockers/animation/timeline_frames_view.h
@@ -24,6 +24,7 @@
 
 #include "kritaanimationdocker_export.h"
 
+class KisAction;
 class TimelineWidget;
 
 
@@ -39,6 +40,7 @@ public:
     void updateGeometries();
 
     qreal zoom() const;
+    QMap<QString, KisAction*> globalActions() const;
 
 public Q_SLOTS:
     void setZoom(qreal zoom);
@@ -73,6 +75,8 @@ private:
     void setFramesPerSecond(int fps);
     void slotZoomButtonPressedImpl();
 
+    void updateShowInTimeline();
+
 protected:
     void currentChanged(const QModelIndex &current, const QModelIndex &previous);
     void startDrag(Qt::DropActions supportedActions);
@@ -83,6 +87,7 @@ protected:
     void mousePressEvent(QMouseEvent *event);
     void mouseMoveEvent(QMouseEvent *e);
     void mouseReleaseEvent(QMouseEvent *e);
+    void rowsInserted(const QModelIndex& parent, int start, int end);
 
 private:
     struct Private;
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
index c0d0b55..6cf7b13 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
+++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
@@ -524,8 +524,10 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
             addActionToMenu(&menu, "layer_style");
 
             menu.addSeparator();
-            menu.addAction(m_removeAction);
+            addActionToMenu(&menu, "show_in_timeline");
+            menu.addSeparator();
 
+            menu.addAction(m_removeAction);
             addActionToMenu(&menu, "duplicatelayer");
             addActionToMenu(&menu, "flatten_image");
             addActionToMenu(&menu, "flatten_layer");


More information about the kimageshop mailing list