mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 02:14:45 +08:00
fix: #13 custom drop area widgets
- adds public function to set widgets - some cleanup changes
This commit is contained in:
parent
180ed31fc4
commit
e04b5c7900
AdvancedDockingSystem
AdvancedDockingSystemDemo/src
@ -112,6 +112,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
QList<SectionContent::RefPtr> contents() const;
|
QList<SectionContent::RefPtr> contents() const;
|
||||||
|
|
||||||
|
QPointer<DropOverlay> dropOverlay() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
// Internal Stuff Begins Here
|
// Internal Stuff Begins Here
|
||||||
|
@ -16,7 +16,7 @@ class DropOverlayCross;
|
|||||||
* DropOverlay paints a translucent rectangle over another widget. The geometry
|
* DropOverlay paints a translucent rectangle over another widget. The geometry
|
||||||
* of the rectangle is based on the mouse location.
|
* of the rectangle is based on the mouse location.
|
||||||
*/
|
*/
|
||||||
class DropOverlay : public QFrame
|
class ADS_EXPORT_API DropOverlay : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class DropOverlayCross;
|
friend class DropOverlayCross;
|
||||||
@ -28,6 +28,8 @@ public:
|
|||||||
void setAllowedAreas(DropAreas areas);
|
void setAllowedAreas(DropAreas areas);
|
||||||
DropAreas allowedAreas() const;
|
DropAreas allowedAreas() const;
|
||||||
|
|
||||||
|
void setAreaWidgets(const QHash<DropArea, QWidget*>& widgets);
|
||||||
|
|
||||||
DropArea cursorLocation() const;
|
DropArea cursorLocation() const;
|
||||||
|
|
||||||
DropArea showDropOverlay(QWidget* target);
|
DropArea showDropOverlay(QWidget* target);
|
||||||
@ -51,7 +53,11 @@ private:
|
|||||||
DropArea _lastLocation;
|
DropArea _lastLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
// DropOverlayCross shows a cross with 5 different drop area possibilities.
|
/*!
|
||||||
|
* DropOverlayCross shows a cross with 5 different drop area possibilities.
|
||||||
|
* I could have handled everything inside DropOverlay, but because of some
|
||||||
|
* styling issues it's better to have a separate class for the cross.
|
||||||
|
*/
|
||||||
class DropOverlayCross : public QWidget
|
class DropOverlayCross : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -434,6 +434,11 @@ QList<SectionContent::RefPtr> ContainerWidget::contents() const
|
|||||||
return sl;
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointer<DropOverlay> ContainerWidget::dropOverlay() const
|
||||||
|
{
|
||||||
|
return _dropOverlay;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// PRIVATE API BEGINS HERE
|
// PRIVATE API BEGINS HERE
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
@ -40,7 +40,7 @@ DropOverlay::DropOverlay(QWidget* parent) :
|
|||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
setLayout(l);
|
setLayout(l);
|
||||||
|
|
||||||
// Cross widget.
|
// Cross with default drop area widgets.
|
||||||
QHash<DropArea, QWidget*> areaWidgets;
|
QHash<DropArea, QWidget*> areaWidgets;
|
||||||
areaWidgets.insert(ADS_NS::TopDropArea, createDropWidget(":/img/split-top.png"));
|
areaWidgets.insert(ADS_NS::TopDropArea, createDropWidget(":/img/split-top.png"));
|
||||||
areaWidgets.insert(ADS_NS::RightDropArea, createDropWidget(":/img/split-right.png"));
|
areaWidgets.insert(ADS_NS::RightDropArea, createDropWidget(":/img/split-right.png"));
|
||||||
@ -64,8 +64,6 @@ void DropOverlay::setAllowedAreas(DropAreas areas)
|
|||||||
_allowedAreas = areas;
|
_allowedAreas = areas;
|
||||||
|
|
||||||
_cross->reset();
|
_cross->reset();
|
||||||
// _cross->move(pos());
|
|
||||||
// _cross->resize(size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DropAreas DropOverlay::allowedAreas() const
|
DropAreas DropOverlay::allowedAreas() const
|
||||||
@ -73,6 +71,11 @@ DropAreas DropOverlay::allowedAreas() const
|
|||||||
return _allowedAreas;
|
return _allowedAreas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DropOverlay::setAreaWidgets(const QHash<DropArea, QWidget*>& widgets)
|
||||||
|
{
|
||||||
|
_cross->setAreaWidgets(widgets);
|
||||||
|
}
|
||||||
|
|
||||||
DropArea DropOverlay::cursorLocation() const
|
DropArea DropOverlay::cursorLocation() const
|
||||||
{
|
{
|
||||||
return _cross->cursorLocation();
|
return _cross->cursorLocation();
|
||||||
@ -243,7 +246,7 @@ DropOverlayCross::DropOverlayCross(DropOverlay* overlay) :
|
|||||||
_widgets()
|
_widgets()
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||||
setWindowTitle("DropSplitAreas");
|
setWindowTitle("DropOverlayCross");
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
_grid = new QGridLayout();
|
_grid = new QGridLayout();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
|
||||||
#include "ads/SectionWidget.h"
|
#include "ads/SectionWidget.h"
|
||||||
|
#include "ads/DropOverlay.h"
|
||||||
|
|
||||||
#include "dialogs/SectionContentListWidget.h"
|
#include "dialogs/SectionContentListWidget.h"
|
||||||
|
|
||||||
@ -102,6 +103,18 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
#endif
|
#endif
|
||||||
setCentralWidget(_container);
|
setCentralWidget(_container);
|
||||||
|
|
||||||
|
// Optional: Use custom drop area widgets.
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
QHash<ADS_NS::DropArea, QWidget*> areaWidgets;
|
||||||
|
areaWidgets.insert(ADS_NS::TopDropArea, new QPushButton("TOP"));
|
||||||
|
areaWidgets.insert(ADS_NS::RightDropArea, new QPushButton("RIGHT"));
|
||||||
|
areaWidgets.insert(ADS_NS::BottomDropArea, new QPushButton("BOTTOM"));
|
||||||
|
areaWidgets.insert(ADS_NS::LeftDropArea, new QPushButton("LEFT"));
|
||||||
|
areaWidgets.insert(ADS_NS::CenterDropArea, new QPushButton("CENTER"));
|
||||||
|
_container->dropOverlay()->setAreaWidgets(areaWidgets);
|
||||||
|
}
|
||||||
|
|
||||||
// ADS - Adding some contents.
|
// ADS - Adding some contents.
|
||||||
// Test #1: Use high-level public API
|
// Test #1: Use high-level public API
|
||||||
if (true)
|
if (true)
|
||||||
|
Loading…
Reference in New Issue
Block a user