mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-26 08:01:32 +08:00
Added support for canceling non opaque docking with escape key, fixed state of non opaque docking when switching applications (if application becomes inactive)
This commit is contained in:
parent
8c1f065f3f
commit
ffd35cbce3
@ -201,8 +201,9 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
QScrollArea::mouseMoveEvent(ev);
|
QScrollArea::mouseMoveEvent(ev);
|
||||||
if (ev->buttons() != Qt::LeftButton)
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
{
|
{
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +277,12 @@ IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragSt
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FloatingWidget = new CFloatingOverlay(d->DockArea);
|
auto w = new CFloatingOverlay(d->DockArea);
|
||||||
|
connect(w, &CFloatingOverlay::draggingCanceled, [=]()
|
||||||
|
{
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
|
});
|
||||||
|
FloatingWidget = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
|
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
|
||||||
|
@ -151,7 +151,12 @@ struct DockWidgetTabPrivate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new CFloatingOverlay(Widget);
|
auto w = new CFloatingOverlay(Widget);
|
||||||
|
_this->connect(w, &CFloatingOverlay::draggingCanceled, [=]()
|
||||||
|
{
|
||||||
|
DragState = DraggingInactive;
|
||||||
|
});
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -246,6 +251,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
|
|||||||
IFloatingWidget* FloatingWidget = nullptr;
|
IFloatingWidget* FloatingWidget = nullptr;
|
||||||
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
|
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
|
||||||
(DraggingFloatingWidget != DraggingState);
|
(DraggingFloatingWidget != DraggingState);
|
||||||
|
|
||||||
// If section widget has multiple tabs, we take only one tab
|
// If section widget has multiple tabs, we take only one tab
|
||||||
// If it has only one single tab, we can move the complete
|
// If it has only one single tab, we can move the complete
|
||||||
// dock area into floating widget
|
// dock area into floating widget
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
@ -53,6 +54,17 @@ struct FloatingOverlayPrivate
|
|||||||
Hidden = Value;
|
Hidden = Value;
|
||||||
_this->update();
|
_this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel dragging and emit the draggingCanceled event
|
||||||
|
*/
|
||||||
|
void cancelDragging()
|
||||||
|
{
|
||||||
|
emit _this->draggingCanceled();
|
||||||
|
DockManager->containerOverlay()->hideOverlay();
|
||||||
|
DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
|
_this->close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// struct LedArrayPanelPrivate
|
// struct LedArrayPanelPrivate
|
||||||
|
|
||||||
@ -192,6 +204,9 @@ CFloatingOverlay::CFloatingOverlay(QWidget* Content, QWidget* parent) :
|
|||||||
d->ContentPreviewPixmap = QPixmap(Content->size());
|
d->ContentPreviewPixmap = QPixmap(Content->size());
|
||||||
Content->render(&d->ContentPreviewPixmap);
|
Content->render(&d->ContentPreviewPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||||
|
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,6 +350,30 @@ void CFloatingOverlay::paintEvent(QPaintEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingOverlay::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
Super::keyPressEvent(event);
|
||||||
|
if (event->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
|
d->cancelDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingOverlay::onApplicationStateChanged(Qt::ApplicationState state)
|
||||||
|
{
|
||||||
|
if (state != Qt::ApplicationActive)
|
||||||
|
{
|
||||||
|
disconnect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||||
|
this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||||
|
d->cancelDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ private:
|
|||||||
FloatingOverlayPrivate* d;
|
FloatingOverlayPrivate* d;
|
||||||
friend class FloatingOverlayPrivate;
|
friend class FloatingOverlayPrivate;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onApplicationStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Updates the drop overlays
|
* Updates the drop overlays
|
||||||
@ -43,6 +46,8 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual void paintEvent(QPaintEvent *e) override;
|
virtual void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The content is a DockArea or a DockWidget
|
* The content is a DockArea or a DockWidget
|
||||||
*/
|
*/
|
||||||
@ -84,6 +89,13 @@ public: // implements IFloatingWidget -----------------------------------------
|
|||||||
* of the assigned Content widget
|
* of the assigned Content widget
|
||||||
*/
|
*/
|
||||||
virtual void finishDragging() override;
|
virtual void finishDragging() override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* This signal is emitted, if dragging has been canceled by escape key
|
||||||
|
* or by active application switching via task manager
|
||||||
|
*/
|
||||||
|
void draggingCanceled();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user