[krita] krita: Add "Show in Timeline" action to the Layers Docker
Dmitry Kazakov
dimula73 at gmail.com
Wed Dec 16 17:28:10 UTC 2015
Git commit 474fabb8cdaeb6975a3547d6d320fae07d26e8e0 by Dmitry Kazakov.
Committed on 16/12/2015 at 17:27.
Pushed by dkazakov into branch 'master'.
Add "Show in Timeline" action to the Layers Docker
CC:kimageshop at kde.org
M +11 -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/krita/474fabb8cdaeb6975a3547d6d320fae07d26e8e0
diff --git a/krita/krita.action b/krita/krita.action
index 8ba5483..436b007 100644
--- a/krita/krita.action
+++ b/krita/krita.action
@@ -2392,6 +2392,17 @@
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
+ <Action name="show_in_timeline">
+ <icon></icon>
+ <text>Show in Timeline</text>
+ <whatsThis></whatsThis>
+ <toolTip></toolTip>
+ <iconText></iconText>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>true</isCheckable>
+ <statusTip></statusTip>
+ </Action>
</Actions>
<Actions category="Unknown">
diff --git a/krita/plugins/extensions/dockers/animation/timeline_docker.cpp b/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
index ce9f8f1..d32987a 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
+++ b/krita/plugins/extensions/dockers/animation/timeline_docker.cpp
@@ -126,9 +126,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 ec6a27a..6f4a70e 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()));
@@ -196,6 +204,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) {
@@ -388,9 +401,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);
}
@@ -647,11 +669,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 ¤t, 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 4e48858..71e3e26 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
+++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
@@ -562,8 +562,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