mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Fixed some issues with mouse double clicks, remove unused and supefluous code
This commit is contained in:
parent
72fc9cd79a
commit
635b96a2ae
@ -66,8 +66,6 @@ enum DropArea
|
||||
Q_DECLARE_FLAGS(DropAreas, DropArea)
|
||||
|
||||
void deleteEmptySplitter(MainContainerWidget* container);
|
||||
MainContainerWidget* findParentContainerWidget(QWidget* w);
|
||||
SectionWidget* findParentSectionWidget(QWidget* w);
|
||||
QSplitter* findParentSplitter(QWidget* w);
|
||||
QSplitter* findImmediateSplitter(QWidget* w);
|
||||
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
|
||||
void dumpLayout();
|
||||
|
||||
MainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
|
||||
|
||||
signals:
|
||||
/*!
|
||||
* Emits whenever the "isActiveTab" state of a SectionContent changes.
|
||||
|
@ -59,12 +59,6 @@ public:
|
||||
|
||||
SectionContent::RefPtr content() const { return _content; }
|
||||
|
||||
/**
|
||||
* Returns true, if this floating widget is dragged right now.
|
||||
* That means, left mouse button is down in the title widget
|
||||
*/
|
||||
bool isDraggingActive() const;
|
||||
|
||||
/**
|
||||
* Returns the current zOrderIndex
|
||||
*/
|
||||
@ -99,7 +93,6 @@ private:
|
||||
CContainerWidget* m_ContainerWidget;
|
||||
CContainerWidget* m_DropContainer;
|
||||
bool m_DraggingActive = false;
|
||||
bool m_NonCLientDraggingActive = false;
|
||||
unsigned int m_zOrderIndex = 0;
|
||||
QPoint m_DragStartPosition;
|
||||
QPoint m_DragStartMousePosition;
|
||||
|
@ -27,7 +27,6 @@ class SectionTitleWidget : public QFrame
|
||||
SectionContent::RefPtr m_Content;
|
||||
|
||||
// Drag & Drop (Floating)
|
||||
QPointer<FloatingWidget> m_FloatingWidget;
|
||||
QPoint m_DragStartMousePosition;
|
||||
QPoint m_DragStartGlobalMousePosition;
|
||||
QPoint m_DragStartPosition;
|
||||
@ -45,14 +44,6 @@ public:
|
||||
bool isActiveTab() const;
|
||||
void setActiveTab(bool active);
|
||||
|
||||
/**
|
||||
* Returns true, if this sections title widget is currently dragging
|
||||
* a floating widget
|
||||
*/
|
||||
bool isDraggingFloatingWidget() const;
|
||||
|
||||
virtual bool event(QEvent *e);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev);
|
||||
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
||||
|
@ -47,37 +47,6 @@ void deleteEmptySplitter(MainContainerWidget* container)
|
||||
while (doAgain);
|
||||
}
|
||||
|
||||
MainContainerWidget* findParentContainerWidget(QWidget* w)
|
||||
{
|
||||
MainContainerWidget* cw = 0;
|
||||
QWidget* next = w;
|
||||
do
|
||||
{
|
||||
if ((cw = dynamic_cast<MainContainerWidget*>(next)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
next = next->parentWidget();
|
||||
}
|
||||
while (next);
|
||||
return cw;
|
||||
}
|
||||
|
||||
SectionWidget* findParentSectionWidget(class QWidget* w)
|
||||
{
|
||||
SectionWidget* cw = 0;
|
||||
QWidget* next = w;
|
||||
do
|
||||
{
|
||||
if ((cw = dynamic_cast<SectionWidget*>(next)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
next = next->parentWidget();
|
||||
}
|
||||
while (next);
|
||||
return cw;
|
||||
}
|
||||
|
||||
QSplitter* findParentSplitter(class QWidget* w)
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ void CContainerWidget::dropIntoContainer(FloatingWidget* FloatingWidget, DropAre
|
||||
l->addWidget(sp);
|
||||
for (auto SectionWidget : SectionWidgets)
|
||||
{
|
||||
sp->insertWidget(0, SectionWidget);
|
||||
sp->addWidget(SectionWidget);
|
||||
}
|
||||
}
|
||||
else if ((FloatingMainSplitter->orientation() == orientation) &&
|
||||
|
@ -137,7 +137,7 @@ void CFloatingTitleWidget::onMaximizeButtonClicked()
|
||||
|
||||
|
||||
FloatingWidget::FloatingWidget(MainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent) :
|
||||
QWidget(parent, Qt::Window/*Qt::CustomizeWindowHint | Qt::Tool*/),
|
||||
QWidget(0),
|
||||
m_MainContainerWidget(container),
|
||||
_content(sc),
|
||||
_titleWidget(titleWidget),
|
||||
@ -208,24 +208,15 @@ void FloatingWidget::onCloseButtonClicked()
|
||||
m_MainContainerWidget->hideSectionContent(_content);
|
||||
}
|
||||
|
||||
bool FloatingWidget::isDraggingActive() const
|
||||
{
|
||||
return _titleWidget->isDraggingFloatingWidget();
|
||||
}
|
||||
|
||||
|
||||
void FloatingWidget::changeEvent(QEvent *event)
|
||||
{
|
||||
QWidget::changeEvent(event);
|
||||
if (event->type() != QEvent::ActivationChange)
|
||||
if (event->type() == QEvent::ActivationChange && isActiveWindow())
|
||||
{
|
||||
std::cout << "FloatingWidget::changeEvent QEvent::ActivationChange " << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isActiveWindow())
|
||||
{
|
||||
m_zOrderIndex = ++zOrderCounter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,9 +224,9 @@ void FloatingWidget::changeEvent(QEvent *event)
|
||||
void FloatingWidget::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
QWidget::moveEvent(event);
|
||||
if (m_DraggingActive)
|
||||
if (m_DraggingActive && qApp->mouseButtons().testFlag(Qt::LeftButton))
|
||||
{
|
||||
std::cout << "Dragging" << std::endl;
|
||||
//std::cout << "Dragging" << std::endl;
|
||||
updateDropOverlays(QCursor::pos());
|
||||
}
|
||||
}
|
||||
@ -270,12 +261,16 @@ bool FloatingWidget::event(QEvent *e)
|
||||
{
|
||||
std::cout << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type() << std::endl;
|
||||
setDraggingActive(true);
|
||||
m_NonCLientDraggingActive = true;
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::NonClientAreaMouseButtonDblClick)
|
||||
{
|
||||
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick" << std::endl;
|
||||
setDraggingActive(false);
|
||||
}
|
||||
else if ((e->type() == QEvent::NonClientAreaMouseButtonRelease) && m_DraggingActive)
|
||||
{
|
||||
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease" << e->type() << std::endl;
|
||||
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease" << std::endl;
|
||||
titleMouseReleaseEvent();
|
||||
}
|
||||
return QWidget::event(e);
|
||||
@ -318,7 +313,6 @@ void FloatingWidget::startFloating(const QPoint& Pos)
|
||||
void FloatingWidget::titleMouseReleaseEvent()
|
||||
{
|
||||
setDraggingActive(false);
|
||||
m_NonCLientDraggingActive = false;
|
||||
if (!m_DropContainer)
|
||||
{
|
||||
return;
|
||||
|
@ -33,13 +33,11 @@ QSplitter* MainContainerWidget::newSplitter(Qt::Orientation orientation, QWidget
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainContainerWidget::MainContainerWidget(QWidget *parent) :
|
||||
CContainerWidget(this, parent)
|
||||
{
|
||||
m_SectionDropOverlay = new DropOverlay(this, DropOverlay::ModeSectionOverlay);
|
||||
|
||||
m_ContainerDropOverlay = new DropOverlay(this, DropOverlay::ModeContainerOverlay);
|
||||
m_SectionDropOverlay = new DropOverlay(0, DropOverlay::ModeSectionOverlay);
|
||||
m_ContainerDropOverlay = new DropOverlay(0, DropOverlay::ModeContainerOverlay);
|
||||
m_ContainerDropOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
m_ContainerDropOverlay->setWindowFlags(m_ContainerDropOverlay->windowFlags() | Qt::WindowTransparentForInput);
|
||||
m_Containers.append(this);
|
||||
@ -817,7 +815,7 @@ bool MainContainerWidget::restoreFloatingWidgets(QDataStream& in, int version, Q
|
||||
fw->_contentWidget->setVisible(visible);
|
||||
}
|
||||
floatings.append(fw);
|
||||
data.titleWidget->m_FloatingWidget = fw; // $mfreiholz: Don't look at it :-< It's more than ugly...
|
||||
//data.titleWidget->m_FloatingWidget = fw; // $mfreiholz: Don't look at it :-< It's more than ugly...
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -13,11 +13,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef ADS_ANIMATIONS_ENABLED
|
||||
#include <QPropertyAnimation>
|
||||
#include <QParallelAnimationGroup>
|
||||
#endif
|
||||
|
||||
#include "ads/Internal.h"
|
||||
#include "ads/DropOverlay.h"
|
||||
#include "ads/SectionContent.h"
|
||||
@ -80,13 +75,47 @@ void SectionTitleWidget::mousePressEvent(QMouseEvent* ev)
|
||||
QFrame::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
CContainerWidget* findParentContainerWidget(QWidget* w)
|
||||
{
|
||||
CContainerWidget* cw = 0;
|
||||
QWidget* next = w;
|
||||
do
|
||||
{
|
||||
if ((cw = dynamic_cast<CContainerWidget*>(next)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
next = next->parentWidget();
|
||||
}
|
||||
while (next);
|
||||
return cw;
|
||||
}
|
||||
|
||||
SectionWidget* findParentSectionWidget(class QWidget* w)
|
||||
{
|
||||
SectionWidget* cw = 0;
|
||||
QWidget* next = w;
|
||||
do
|
||||
{
|
||||
if ((cw = dynamic_cast<SectionWidget*>(next)) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
next = next->parentWidget();
|
||||
}
|
||||
while (next);
|
||||
return cw;
|
||||
}
|
||||
|
||||
void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
SectionWidget* section = nullptr;
|
||||
MainContainerWidget* cw = findParentContainerWidget(this);
|
||||
CContainerWidget* cw = findParentContainerWidget(this);
|
||||
MainContainerWidget* mcw = cw->mainContainerWidget();
|
||||
std::cout << "SectionTitleWidget::mouseReleaseEvent" << std::endl;
|
||||
|
||||
m_FloatingWidget.clear();
|
||||
//m_FloatingWidget.clear();
|
||||
// End of tab moving, change order now
|
||||
if (m_TabMoving && (section = findParentSectionWidget(this)) != nullptr)
|
||||
{
|
||||
@ -111,8 +140,8 @@ void SectionTitleWidget::mouseReleaseEvent(QMouseEvent* ev)
|
||||
// Reset
|
||||
m_DragStartMousePosition = QPoint();
|
||||
m_TabMoving = false;
|
||||
cw->m_SectionDropOverlay->hideDropOverlay();
|
||||
cw->hideContainerOverlay();
|
||||
mcw->m_SectionDropOverlay->hideDropOverlay();
|
||||
mcw->hideContainerOverlay();
|
||||
QFrame::mouseReleaseEvent(ev);
|
||||
}
|
||||
|
||||
@ -125,7 +154,7 @@ void SectionTitleWidget::moveFloatingWidget(QMouseEvent* ev, MainContainerWidget
|
||||
m_FloatingWidget->move(moveToGlobalPos);*/
|
||||
|
||||
const QPoint moveToPos = ev->globalPos() - m_DragStartMousePosition;
|
||||
m_FloatingWidget->move(moveToPos);
|
||||
//m_FloatingWidget->move(moveToPos);
|
||||
}
|
||||
|
||||
|
||||
@ -202,11 +231,6 @@ void SectionTitleWidget::moveTab(QMouseEvent* ev)
|
||||
}
|
||||
|
||||
|
||||
bool SectionTitleWidget::isDraggingFloatingWidget() const
|
||||
{
|
||||
return !m_FloatingWidget.isNull();
|
||||
}
|
||||
|
||||
void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||
{
|
||||
std::cout << "SectionTitleWidget::mouseMoveEvent" << std::endl;
|
||||
@ -218,17 +242,9 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||
|
||||
// TODO make a member with the main container widget and assign it on
|
||||
// creation
|
||||
MainContainerWidget* MainContainerWidget = findParentContainerWidget(this);
|
||||
MainContainerWidget* MainContainerWidget = findParentContainerWidget(this)->mainContainerWidget();
|
||||
ev->accept();
|
||||
|
||||
// Move already existing FloatingWidget
|
||||
if (isDraggingFloatingWidget())
|
||||
{
|
||||
std::cout << "SectionTitleWidget isDraggingFloatingWidget()" << std::endl;
|
||||
//moveFloatingWidget(ev, MainContainerWidget);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SectionWidget* sectionwidget = findParentSectionWidget(this);
|
||||
if (!sectionwidget)
|
||||
@ -267,10 +283,4 @@ void SectionTitleWidget::mouseMoveEvent(QMouseEvent* ev)
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
bool SectionTitleWidget::event(QEvent *e)
|
||||
{
|
||||
return QFrame::event(e);
|
||||
}
|
||||
|
||||
ADS_NAMESPACE_END
|
||||
|
Loading…
Reference in New Issue
Block a user