2015-12-09 19:21:38 +08:00
|
|
|
#ifndef FLOATINGWIDGET_H
|
|
|
|
#define FLOATINGWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2017-02-08 06:51:29 +08:00
|
|
|
#include <QFrame>
|
2016-02-15 19:27:23 +08:00
|
|
|
class QBoxLayout;
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2016-02-02 22:01:48 +08:00
|
|
|
#include "ads/API.h"
|
|
|
|
#include "ads/SectionContent.h"
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
ADS_NAMESPACE_BEGIN
|
2017-01-31 05:44:27 +08:00
|
|
|
class MainContainerWidget;
|
2015-12-09 19:21:38 +08:00
|
|
|
class SectionTitleWidget;
|
|
|
|
class SectionContentWidget;
|
2016-02-12 15:00:31 +08:00
|
|
|
class InternalContentData;
|
2017-01-17 14:57:24 +08:00
|
|
|
class SectionWidget;
|
2017-02-08 06:51:29 +08:00
|
|
|
class CContainerWidget;
|
|
|
|
class FloatingWidget;
|
|
|
|
|
|
|
|
class CFloatingTitleWidget : public QFrame
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
QPoint m_DragStartPosition;
|
2017-02-09 06:03:13 +08:00
|
|
|
QPoint m_DragStartMousePosition;
|
2017-02-08 06:51:29 +08:00
|
|
|
FloatingWidget* floatingWidget() const;
|
|
|
|
MainContainerWidget* mainContainerWidget() const;
|
2017-02-09 06:03:13 +08:00
|
|
|
void moveFloatingWidget(QMouseEvent* ev);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onMaximizeButtonClicked();
|
2017-02-08 06:51:29 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void mousePressEvent(QMouseEvent* ev);
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
|
|
|
virtual void mouseMoveEvent(QMouseEvent* ev);
|
|
|
|
|
|
|
|
public:
|
|
|
|
CFloatingTitleWidget(SectionContent::Flags Flags, FloatingWidget* Parent);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void closeButtonClicked();
|
|
|
|
};
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
|
|
|
|
// FloatingWidget holds and displays SectionContent as a floating window.
|
|
|
|
// It can be resized, moved and dropped back into a SectionWidget.
|
|
|
|
class FloatingWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2017-01-31 05:44:27 +08:00
|
|
|
friend class MainContainerWidget;
|
2017-02-09 06:03:13 +08:00
|
|
|
friend class CFloatingTitleWidget;
|
2016-02-15 18:13:58 +08:00
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
public:
|
2017-01-31 05:44:27 +08:00
|
|
|
FloatingWidget(MainContainerWidget* container, SectionContent::RefPtr sc, SectionTitleWidget* titleWidget, SectionContentWidget* contentWidget, QWidget* parent = NULL);
|
2017-01-17 14:57:24 +08:00
|
|
|
FloatingWidget(SectionWidget* sectionWidget);
|
|
|
|
virtual ~FloatingWidget();
|
2016-02-02 20:49:10 +08:00
|
|
|
|
|
|
|
SectionContent::RefPtr content() const { return _content; }
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2017-01-31 05:44:27 +08:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
unsigned int zOrderIndex() const;
|
|
|
|
|
2017-02-08 06:51:29 +08:00
|
|
|
CContainerWidget* containerWidget() const {return m_ContainerWidget;}
|
|
|
|
MainContainerWidget* mainContainerWidget() const {return m_MainContainerWidget;}
|
|
|
|
|
2016-02-15 17:28:42 +08:00
|
|
|
public://private:
|
|
|
|
bool takeContent(InternalContentData& data);
|
2015-12-09 19:21:38 +08:00
|
|
|
|
2017-02-12 05:05:23 +08:00
|
|
|
void startFloating(const QPoint& Pos);
|
|
|
|
|
2017-01-31 05:44:27 +08:00
|
|
|
protected:
|
|
|
|
virtual void changeEvent(QEvent *event) override;
|
2017-02-09 06:03:13 +08:00
|
|
|
virtual void moveEvent(QMoveEvent *event) override;
|
|
|
|
virtual bool event(QEvent *e);
|
2017-02-11 04:23:14 +08:00
|
|
|
void titleMouseReleaseEvent();
|
|
|
|
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
2017-02-09 06:03:13 +08:00
|
|
|
void updateDropOverlays(const QPoint& GlobalPos);
|
2017-01-31 05:44:27 +08:00
|
|
|
|
2016-04-11 13:15:42 +08:00
|
|
|
private slots:
|
|
|
|
void onCloseButtonClicked();
|
|
|
|
|
2015-12-09 19:21:38 +08:00
|
|
|
private:
|
2017-02-13 02:59:29 +08:00
|
|
|
void setDraggingActive(bool Active);
|
|
|
|
|
2017-02-08 06:51:29 +08:00
|
|
|
MainContainerWidget* m_MainContainerWidget;
|
2015-12-09 19:21:38 +08:00
|
|
|
SectionContent::RefPtr _content;
|
|
|
|
SectionTitleWidget* _titleWidget;
|
|
|
|
SectionContentWidget* _contentWidget;
|
2017-02-08 06:51:29 +08:00
|
|
|
CContainerWidget* m_ContainerWidget;
|
2017-02-11 04:23:14 +08:00
|
|
|
CContainerWidget* m_DropContainer;
|
2017-02-09 06:03:13 +08:00
|
|
|
bool m_DraggingActive = false;
|
2017-02-12 05:05:23 +08:00
|
|
|
bool m_NonCLientDraggingActive = false;
|
2017-01-31 05:44:27 +08:00
|
|
|
unsigned int m_zOrderIndex = 0;
|
2017-02-12 05:05:23 +08:00
|
|
|
QPoint m_DragStartPosition;
|
|
|
|
QPoint m_DragStartMousePosition;
|
2017-01-31 05:44:27 +08:00
|
|
|
static unsigned int zOrderCounter;
|
2015-12-09 19:21:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ADS_NAMESPACE_END
|
2016-02-12 14:15:10 +08:00
|
|
|
#endif
|