mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Properly implemented support for canceling non-opaque undocking on Linux
This commit is contained in:
parent
e085a29484
commit
056f04d408
@ -384,8 +384,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
|
||||
// uncomment the follwing line if you want to use non opaque undocking and splitter
|
||||
// moevements
|
||||
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
||||
CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, true);
|
||||
// CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
||||
|
||||
// Now create the dock manager and its content
|
||||
d->DockManager = new CDockManager(this);
|
||||
|
@ -206,6 +206,13 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
|
||||
|
||||
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// In Windows this widget directly receives the escape key press events
|
||||
// in Linux we need to install an event filter for the given Content
|
||||
// widget to receive the escape key press
|
||||
Content->installEventFilter(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -372,6 +379,23 @@ void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent* e = static_cast<QKeyEvent*>(event);
|
||||
if (e->key() == Qt::Key_Escape)
|
||||
{
|
||||
d->Content->removeEventFilter(this);
|
||||
d->cancelDragging();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
@ -78,6 +78,12 @@ public:
|
||||
*/
|
||||
~CFloatingDragPreview();
|
||||
|
||||
/**
|
||||
* We filter the events of the assigned content widget to receive
|
||||
* escape key presses for canceling the drag operation
|
||||
*/
|
||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
|
||||
public: // implements IFloatingWidget -----------------------------------------
|
||||
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
|
Loading…
Reference in New Issue
Block a user