mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Fixed reception of escape key press events
This commit is contained in:
parent
f3c5d51380
commit
fe10b570d3
@ -40,6 +40,7 @@ struct FloatingDragPreviewPrivate
|
|||||||
qreal WindowOpacity;
|
qreal WindowOpacity;
|
||||||
bool Hidden = false;
|
bool Hidden = false;
|
||||||
QPixmap ContentPreviewPixmap;
|
QPixmap ContentPreviewPixmap;
|
||||||
|
bool Canceled = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,6 +60,7 @@ struct FloatingDragPreviewPrivate
|
|||||||
*/
|
*/
|
||||||
void cancelDragging()
|
void cancelDragging()
|
||||||
{
|
{
|
||||||
|
Canceled = true;
|
||||||
emit _this->draggingCanceled();
|
emit _this->draggingCanceled();
|
||||||
DockManager->containerOverlay()->hideOverlay();
|
DockManager->containerOverlay()->hideOverlay();
|
||||||
DockManager->dockAreaOverlay()->hideOverlay();
|
DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
@ -85,11 +87,6 @@ void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (DockContainer == ContainerWidget)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
||||||
if (ContainerWidget->rect().contains(MappedPos))
|
if (ContainerWidget->rect().contains(MappedPos))
|
||||||
{
|
{
|
||||||
@ -207,10 +204,9 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
|
|||||||
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||||
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||||
|
|
||||||
// The focused object will receive key press events and therefore we
|
// The only safe way to receive escape key presses is to install an event
|
||||||
// install the event filter on it to receive escape key press for drag
|
// filter for the application object
|
||||||
// canceling
|
qApp->installEventFilter(this);
|
||||||
qApp->focusObject()->installEventFilter(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -377,7 +373,7 @@ void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
|
|||||||
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
|
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(watched);
|
Q_UNUSED(watched);
|
||||||
if (event->type() == QEvent::KeyPress)
|
if (!d->Canceled && event->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
QKeyEvent* e = static_cast<QKeyEvent*>(event);
|
QKeyEvent* e = static_cast<QKeyEvent*>(event);
|
||||||
if (e->key() == Qt::Key_Escape)
|
if (e->key() == Qt::Key_Escape)
|
||||||
|
Loading…
Reference in New Issue
Block a user