KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
Draggable.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#include "Draggable_p.h"
13#include "DragController_p.h"
14#include "FloatingWindow_p.h"
15#include "WidgetResizeHandler_p.h"
16#include "Utils_p.h"
17
18
19using namespace KDDockWidgets;
20
21class Draggable::Private
22{
23public:
24 explicit Private(QWidgetOrQuick *_thisWidget, bool _enabled)
25 : thisWidget(_thisWidget)
26 , enabled(_enabled)
27 {
28 Q_ASSERT(thisWidget);
29 }
30
31 QPointer<WidgetResizeHandler> widgetResizeHandler;
32 QWidgetOrQuick *const thisWidget;
33 const bool enabled;
34};
35
36Draggable::Draggable(QWidgetOrQuick *thisWidget, bool enabled)
37 : d(new Private(thisWidget, enabled))
38{
39 if (thisWidget && d->enabled)
40 DragController::instance()->registerDraggable(this);
41}
42
43Draggable::~Draggable()
44{
45 if (d->thisWidget && d->enabled)
46 DragController::instance()->unregisterDraggable(this);
47 delete d;
48}
49
50QWidgetOrQuick *Draggable::asWidget() const
51{
52 return d->thisWidget;
53}
54
55bool Draggable::dragCanStart(QPoint pressPos, QPoint globalPos) const
56{
57 return (globalPos - pressPos).manhattanLength() > KDDockWidgets::startDragDistance();
58}
59
60void Draggable::setWidgetResizeHandler(WidgetResizeHandler *w)
61{
62 Q_ASSERT(!d->widgetResizeHandler);
63 Q_ASSERT(w);
64 d->widgetResizeHandler = w;
65}

© 2019-2023 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated on Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8