[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/krita-animation-pentikainen] krita/plugins/extensions/dockers/animation: Recover keyboard
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2015-11-04 18:29:54
Message-ID: E1Zu2ok-00015B-HQ () scm ! kde ! org
[Download RAW message or body]
Git commit 9bb39dc1f46df4ad1a41f6aced620d58f9b4cc11 by Dmitry Kazakov.
Committed on 04/11/2015 at 18:28.
Pushed by dkazakov into branch 'krita-animation-pentikainen'.
Recover keyboard focus decoration on the timeline
Now you ca easily select frames with the keyboard even when pressing Ctrl key!
M +24 -4 krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.cpp
M +3 -0 krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.h
http://commits.kde.org/calligra/9bb39dc1f46df4ad1a41f6aced620d58f9b4cc11
diff --git a/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.cpp \
b/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.cpp index \
9949a2b..b7e7f82 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.cpp
+++ b/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.cpp
@@ -20,6 +20,7 @@
#include <QPen>
#include <QPainter>
+#include <QApplication>
#include "timeline_frames_model.h"
#include "timeline_color_scheme.h"
@@ -83,14 +84,32 @@ void TimelineFramesItemDelegate::drawBackground(QPainter \
*painter, const QModelI painter->fillRect(rc, color);
}
+void TimelineFramesItemDelegate::drawFocus(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QRect &rect) const
+{
+ // copied form Qt 4.8!
+
+ if ((option.state & QStyle::State_HasFocus) == 0 || !rect.isValid())
+ return;
+ QStyleOptionFocusRect o;
+ o.QStyleOption::operator=(option);
+ o.rect = rect;
+ o.state |= QStyle::State_KeyboardFocusChange;
+ o.state |= QStyle::State_Item;
+ QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
+ ? QPalette::Normal : QPalette::Disabled;
+ o.backgroundColor = option.palette.color(cg, (option.state & \
QStyle::State_Selected) + ? \
QPalette::Highlight : QPalette::Window); + const QWidget *widget = \
qobject_cast<QWidget*>(parent()); + QStyle *style = widget ? widget->style() : \
QApplication::style(); + style->drawPrimitive(QStyle::PE_FrameFocusRect, &o, \
painter, widget); +}
+
void TimelineFramesItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
- //QStyleOptionViewItem op2 = option;
- //op2.showDecorationSelected = false;
- //QItemDelegate::paint(painter, op2, index);
-
drawBackground(painter, index, option.rect);
if (option.showDecorationSelected &&
@@ -109,6 +128,7 @@ void TimelineFramesItemDelegate::paint(QPainter *painter,
painter->setOpacity(oldOpacity);
}
+ drawFocus(painter, option, option.rect);
bool active = index.data(TimelineFramesModel::ActiveFrameRole).toBool();
bool layerIsCurrent = index.data(TimelineFramesModel::ActiveLayerRole).toBool();
diff --git a/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.h \
b/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.h index \
16865f5..7f88be8 100644
--- a/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.h
+++ b/krita/plugins/extensions/dockers/animation/timeline_frames_item_delegate.h
@@ -30,6 +30,9 @@ public:
static void paintActiveFrameSelector(QPainter *painter, const QRect &rc, bool \
isCurrentFrame);
static void drawBackground(QPainter *painter, const QModelIndex &index, const \
QRect &rc); + void drawFocus(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QRect &rect) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const \
QModelIndex &index) const; };
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic