forked from qt-creator/qt-creator
Fix check if a key is supposed for deletion
Moved the function into timelineutils.h in order to be able to use it from other places as well. Change-Id: If5fa094abb6ae52d7922bc9bbcb96b482ece7ac0 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -70,11 +70,6 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static bool isDeleteKey(int key)
|
||||
{
|
||||
return (key == Qt::Key_Backspace) | (key == Qt::Key_Delete);
|
||||
}
|
||||
|
||||
QList<QmlTimelineKeyframeGroup> allTimelineFrames(const QmlTimeline &timeline)
|
||||
{
|
||||
QList<QmlTimelineKeyframeGroup> returnList;
|
||||
@@ -671,7 +666,7 @@ void TimelineGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDeleteKey(keyEvent->key()))
|
||||
if (TimelineUtils::isDeleteKey(keyEvent->key()))
|
||||
handleKeyframeDeletion();
|
||||
|
||||
QGraphicsScene::keyReleaseEvent(keyEvent);
|
||||
@@ -835,7 +830,7 @@ bool TimelineGraphicsScene::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::ShortcutOverride:
|
||||
if (isDeleteKey(static_cast<QKeyEvent *>(event)->key())) {
|
||||
if (TimelineUtils::isDeleteKey(static_cast<QKeyEvent *>(event)->key())) {
|
||||
QGraphicsScene::keyPressEvent(static_cast<QKeyEvent *>(event));
|
||||
event->accept();
|
||||
return true;
|
||||
|
@@ -39,6 +39,11 @@ namespace TimelineUtils {
|
||||
|
||||
enum class Side { Top, Right, Bottom, Left };
|
||||
|
||||
inline bool isDeleteKey(int key)
|
||||
{
|
||||
return (key == Qt::Key_Backspace) || (key == Qt::Key_Delete);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T clamp(const T &value, const T &lo, const T &hi)
|
||||
{
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "timelineplaceholder.h"
|
||||
#include "timelinepropertyitem.h"
|
||||
#include "timelinesectionitem.h"
|
||||
#include "timelineutils.h"
|
||||
|
||||
#include <designdocumentview.h>
|
||||
#include <exception.h>
|
||||
@@ -73,14 +74,6 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static int deleteKey()
|
||||
{
|
||||
if (Utils::HostOsInfo::isMacHost())
|
||||
return Qt::Key_Backspace;
|
||||
|
||||
return Qt::Key_Delete;
|
||||
}
|
||||
|
||||
TransitionEditorGraphicsScene::TransitionEditorGraphicsScene(TransitionEditorWidget *parent)
|
||||
: AbstractScrollGraphicsScene(parent)
|
||||
, m_parent(parent)
|
||||
@@ -459,7 +452,7 @@ bool TransitionEditorGraphicsScene::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::ShortcutOverride:
|
||||
if (static_cast<QKeyEvent *>(event)->key() == deleteKey()) {
|
||||
if (TimelineUtils::isDeleteKey(static_cast<QKeyEvent *>(event)->key())) {
|
||||
QGraphicsScene::keyPressEvent(static_cast<QKeyEvent *>(event));
|
||||
event->accept();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user