Remove a bunch of asQWidget() calls
This commit is contained in:
27
src/View.cpp
27
src/View.cpp
@@ -14,6 +14,9 @@
|
||||
|
||||
#include "controllers/FloatingWindow.h"
|
||||
#include "controllers/Frame.h"
|
||||
#include "controllers/Stack.h"
|
||||
#include "controllers/TitleBar.h"
|
||||
#include "controllers/TabBar.h"
|
||||
|
||||
#include <QWidget> // TODOv2 remove
|
||||
|
||||
@@ -194,6 +197,30 @@ Controllers::Frame *View::asFrameController() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Controllers::TitleBar *View::asTitleBarController() const
|
||||
{
|
||||
if (m_controller && m_controller->is(Type::TitleBar))
|
||||
return qobject_cast<Controllers::TitleBar *>(m_controller);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Controllers::TabBar *View::asTabBarController() const
|
||||
{
|
||||
if (m_controller && m_controller->is(Type::TabBar))
|
||||
return qobject_cast<Controllers::TabBar *>(m_controller);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Controllers::Stack *View::asStackController() const
|
||||
{
|
||||
if (m_controller && m_controller->is(Type::Stack))
|
||||
return qobject_cast<Controllers::Stack *>(m_controller);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool View::equals(const View *other) const
|
||||
{
|
||||
return other && handle() == other->handle();
|
||||
|
||||
@@ -37,6 +37,9 @@ class Controller;
|
||||
namespace Controllers {
|
||||
class FloatingWindow;
|
||||
class Frame;
|
||||
class Stack;
|
||||
class TabBar;
|
||||
class TitleBar;
|
||||
}
|
||||
|
||||
using HANDLE = const void *;
|
||||
@@ -149,6 +152,8 @@ public:
|
||||
virtual QWindow *windowHandle() const = 0;
|
||||
virtual void setFixedWidth(int) = 0;
|
||||
virtual void setFixedHeight(int) = 0;
|
||||
virtual void grabMouse() = 0;
|
||||
virtual void releaseMouse() = 0;
|
||||
|
||||
// TODOv2: Check if these two should be in the controller or on view
|
||||
virtual void onLayoutRequest()
|
||||
@@ -231,6 +236,9 @@ public:
|
||||
/// Mostly to save the call sites from having too many casts
|
||||
Controllers::FloatingWindow *asFloatingWindowController() const;
|
||||
Controllers::Frame *asFrameController() const;
|
||||
Controllers::TitleBar *asTitleBarController() const;
|
||||
Controllers::TabBar *asTabBarController() const;
|
||||
Controllers::Stack *asStackController() const;
|
||||
|
||||
protected:
|
||||
virtual void free_impl();
|
||||
|
||||
@@ -97,7 +97,7 @@ MainWindow *actualParent(MainWindow *candidate)
|
||||
|
||||
FloatingWindow::FloatingWindow(QRect suggestedGeometry, MainWindow *parent)
|
||||
: Controller(Type::FloatingWindow, Config::self().frameworkWidgetFactory()->createFloatingWindow(this, actualParent(parent), windowFlagsToUse()))
|
||||
, Draggable(view()->asQWidget(), KDDockWidgets::usesNativeDraggingAndResizing()) // FloatingWindow is only draggable when using a native title bar. Otherwise the KDDockWidgets::TitleBar is the draggable
|
||||
, Draggable(view(), KDDockWidgets::usesNativeDraggingAndResizing()) // FloatingWindow is only draggable when using a native title bar. Otherwise the KDDockWidgets::TitleBar is the draggable
|
||||
, m_dropArea(new DropArea(view()->asQWidget()))
|
||||
, m_titleBar(new Controllers::TitleBar(this))
|
||||
{
|
||||
|
||||
@@ -31,12 +31,12 @@ using namespace KDDockWidgets::Controllers;
|
||||
|
||||
Stack::Stack(Frame *frame, TabWidgetOptions options)
|
||||
: Controller(Type::Frame, Config::self().frameworkWidgetFactory()->createTabWidget(this, frame))
|
||||
, Draggable(view()->asQWidget(), Config::self().flags() & (Config::Flag_HideTitleBarWhenTabsVisible | Config::Flag_AlwaysShowTabs))
|
||||
, Draggable(view(), Config::self().flags() & (Config::Flag_HideTitleBarWhenTabsVisible | Config::Flag_AlwaysShowTabs))
|
||||
, m_tabBar(new TabBar(this))
|
||||
, m_frame(frame)
|
||||
, m_options(options)
|
||||
{
|
||||
qobject_cast<Views::Stack_qtwidgets *>(view()->asQWidget())->init();
|
||||
view()->init();
|
||||
}
|
||||
|
||||
Stack::~Stack()
|
||||
|
||||
@@ -22,8 +22,8 @@ using namespace KDDockWidgets;
|
||||
using namespace KDDockWidgets::Controllers;
|
||||
|
||||
Controllers::TabBar::TabBar(Stack *tabWidget)
|
||||
: Controller(Type::TabBar, new Views::TabBar_qtwidgets(this, tabWidget->asWidget())) // TODO: Config::self().frameworkWidgetFactory()->createTabBar(this)
|
||||
, Draggable(view()->asQWidget())
|
||||
: Controller(Type::TabBar, new Views::TabBar_qtwidgets(this, tabWidget->view()->asQWidget())) // TODO: Config::self().frameworkWidgetFactory()->createTabBar(this)
|
||||
, Draggable(view())
|
||||
, m_tabWidget(tabWidget)
|
||||
{
|
||||
}
|
||||
@@ -186,3 +186,10 @@ QRect Controllers::TabBar::rectForTab(int index) const
|
||||
auto view = static_cast<Views::TabBar_qtwidgets *>(this->view()); // TODO
|
||||
return view->rectForTab(index);
|
||||
}
|
||||
|
||||
|
||||
DockWidget *Controllers::TabBar::currentDockWidget() const
|
||||
{
|
||||
auto view = static_cast<Views::TabBar_qtwidgets *>(this->view()); // TODO
|
||||
return view->currentDockWidget();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ class Frame;
|
||||
|
||||
class DOCKS_EXPORT TabBar : public Controller, public Draggable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabBar(Stack *tabWidget = nullptr);
|
||||
virtual ~TabBar() override;
|
||||
@@ -39,6 +40,9 @@ public:
|
||||
///@overload
|
||||
DockWidget *dockWidgetAt(QPoint localPos) const;
|
||||
|
||||
/// @brief Returns the current dock widget
|
||||
DockWidget *currentDockWidget() const;
|
||||
|
||||
// Draggable
|
||||
bool dragCanStart(QPoint pressPos, QPoint pos) const override;
|
||||
std::unique_ptr<WindowBeingDragged> makeWindow() override;
|
||||
|
||||
@@ -34,7 +34,7 @@ using namespace KDDockWidgets::Controllers;
|
||||
|
||||
TitleBar::TitleBar(Frame *parent)
|
||||
: Controller(Type::TitleBar, Config::self().frameworkWidgetFactory()->createTitleBar(this, parent))
|
||||
, Draggable(view()->asQWidget()) // TODO
|
||||
, Draggable(view())
|
||||
, m_frame(parent)
|
||||
, m_floatingWindow(nullptr)
|
||||
, m_supportsAutoHide(Config::self().flags() & Config::Flag_AutoHideSupport)
|
||||
@@ -47,7 +47,7 @@ TitleBar::TitleBar(Frame *parent)
|
||||
|
||||
TitleBar::TitleBar(FloatingWindow *parent)
|
||||
: Controller(Type::TitleBar, Config::self().frameworkWidgetFactory()->createTitleBar(this, parent))
|
||||
, Draggable(view()->asQWidget()) // TODO
|
||||
, Draggable(view())
|
||||
, m_frame(nullptr)
|
||||
, m_floatingWindow(parent)
|
||||
, m_supportsAutoHide(Config::self().flags() & Config::Flag_AutoHideSupport)
|
||||
@@ -60,7 +60,7 @@ TitleBar::TitleBar(FloatingWindow *parent)
|
||||
|
||||
void TitleBar::init()
|
||||
{
|
||||
qobject_cast<Views::TitleBar_qtwidgets *>(view()->asQWidget())->init(); // TODO
|
||||
view()->init();
|
||||
view()->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
|
||||
|
||||
connect(this, &TitleBar::isFocusedChanged, this, [this] {
|
||||
|
||||
@@ -53,9 +53,10 @@ public:
|
||||
|
||||
~FallbackMouseGrabber() override;
|
||||
|
||||
void grabMouse(QWidgetOrQuick *target)
|
||||
void grabMouse(View *target)
|
||||
{
|
||||
m_target = target;
|
||||
m_guard = target->asQObject();
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
@@ -76,17 +77,18 @@ public:
|
||||
#endif
|
||||
|
||||
m_target = nullptr;
|
||||
m_guard.clear();
|
||||
qApp->removeEventFilter(this);
|
||||
}
|
||||
|
||||
bool eventFilter(QObject *, QEvent *ev) override
|
||||
{
|
||||
if (m_reentrancyGuard || !m_target)
|
||||
if (m_reentrancyGuard || !m_guard)
|
||||
return false;
|
||||
|
||||
if (QMouseEvent *me = mouseEvent(ev)) {
|
||||
m_reentrancyGuard = true;
|
||||
qApp->sendEvent(m_target, me);
|
||||
qApp->sendEvent(m_target->asQObject(), me);
|
||||
m_reentrancyGuard = false;
|
||||
return true;
|
||||
}
|
||||
@@ -95,7 +97,8 @@ public:
|
||||
}
|
||||
|
||||
bool m_reentrancyGuard = false;
|
||||
QPointer<QWidgetOrQuick> m_target;
|
||||
View *m_target = nullptr;
|
||||
QPointer<QObject> m_guard;
|
||||
};
|
||||
|
||||
FallbackMouseGrabber::~FallbackMouseGrabber()
|
||||
@@ -193,13 +196,13 @@ void StateNone::onEntry()
|
||||
bool StateNone::handleMouseButtonPress(Draggable *draggable, QPoint globalPos, QPoint pos)
|
||||
{
|
||||
qCDebug(state) << "StateNone::handleMouseButtonPress: draggable"
|
||||
<< draggable->asWidget() << "; globalPos" << globalPos;
|
||||
<< draggable << "; globalPos" << globalPos;
|
||||
|
||||
if (!draggable->isPositionDraggable(pos))
|
||||
return false;
|
||||
|
||||
q->m_draggable = draggable;
|
||||
q->m_draggableGuard = draggable->asWidget();
|
||||
q->m_draggableGuard = draggable->asView()->asQObject();
|
||||
q->m_pressPos = globalPos;
|
||||
q->m_offset = draggable->mapToWindow(pos);
|
||||
Q_EMIT q->mousePressed();
|
||||
@@ -313,7 +316,7 @@ void StateDragging::onEntry()
|
||||
Q_UNUSED(needsUndocking);
|
||||
#endif
|
||||
|
||||
qCDebug(state) << "StateDragging entered. m_draggable=" << q->m_draggable->asWidget()
|
||||
qCDebug(state) << "StateDragging entered. m_draggable=" << q->m_draggable
|
||||
<< "; m_windowBeingDragged=" << q->m_windowBeingDragged->floatingWindow();
|
||||
|
||||
auto fw = q->m_windowBeingDragged->floatingWindow();
|
||||
@@ -327,7 +330,7 @@ void StateDragging::onEntry()
|
||||
}
|
||||
} else {
|
||||
// Shouldn't happen
|
||||
qWarning() << Q_FUNC_INFO << "No window being dragged for " << q->m_draggable->asWidget();
|
||||
qWarning() << Q_FUNC_INFO << "No window being dragged for " << q->m_draggable;
|
||||
Q_EMIT q->dragCanceled();
|
||||
}
|
||||
|
||||
@@ -433,11 +436,11 @@ StateInternalMDIDragging::~StateInternalMDIDragging()
|
||||
void StateInternalMDIDragging::onEntry()
|
||||
{
|
||||
qCDebug(state) << "StateInternalMDIDragging entered. draggable="
|
||||
<< q->m_draggable->asWidget();
|
||||
<< q->m_draggable;
|
||||
|
||||
// Raise the dock widget being dragged
|
||||
if (auto tb = qobject_cast<Views::TitleBar_qtwidgets *>(q->m_draggable->asWidget())) { // TODO
|
||||
if (Controllers::Frame *f = tb->titleBar()->frame())
|
||||
if (auto tb = q->m_draggable->asView()->asTitleBarController()) {
|
||||
if (Controllers::Frame *f = tb->frame())
|
||||
f->view()->raise();
|
||||
}
|
||||
|
||||
@@ -453,9 +456,9 @@ bool StateInternalMDIDragging::handleMouseButtonRelease(QPoint)
|
||||
bool StateInternalMDIDragging::handleMouseMove(QPoint globalPos)
|
||||
{
|
||||
// for MDI we only support dragging via the title bar, other cases don't make sense conceptually
|
||||
auto tb = qobject_cast<Controllers::TitleBar *>(q->m_draggable->asWidget()); // TODO
|
||||
auto tb = q->m_draggable->asView()->asTitleBarController();
|
||||
if (!tb) {
|
||||
qWarning() << Q_FUNC_INFO << "expected a title bar, not" << q->m_draggable->asWidget();
|
||||
qWarning() << Q_FUNC_INFO << "expected a title bar, not" << q->m_draggable;
|
||||
Q_EMIT q->dragCanceled();
|
||||
return false;
|
||||
}
|
||||
@@ -630,13 +633,13 @@ DragController *DragController::instance()
|
||||
void DragController::registerDraggable(Draggable *drg)
|
||||
{
|
||||
m_draggables << drg;
|
||||
drg->asWidget()->installEventFilter(this);
|
||||
drg->asView()->asQObject()->installEventFilter(this);
|
||||
}
|
||||
|
||||
void DragController::unregisterDraggable(Draggable *drg)
|
||||
{
|
||||
m_draggables.removeOne(drg);
|
||||
drg->asWidget()->removeEventFilter(this);
|
||||
drg->asView()->asQObject()->removeEventFilter(this);
|
||||
}
|
||||
|
||||
bool DragController::isDragging() const
|
||||
@@ -659,7 +662,7 @@ bool DragController::isIdle() const
|
||||
return activeState() == m_stateNone;
|
||||
}
|
||||
|
||||
void DragController::grabMouseFor(QWidgetOrQuick *target)
|
||||
void DragController::grabMouseFor(View *target)
|
||||
{
|
||||
if (isWayland())
|
||||
return; // No grabbing supported on wayland
|
||||
@@ -671,7 +674,7 @@ void DragController::grabMouseFor(QWidgetOrQuick *target)
|
||||
}
|
||||
}
|
||||
|
||||
void DragController::releaseMouse(QWidgetOrQuick *target)
|
||||
void DragController::releaseMouse(View *target)
|
||||
{
|
||||
if (isWayland())
|
||||
return; // No grabbing supported on wayland
|
||||
@@ -975,7 +978,7 @@ DropArea *DragController::dropAreaUnderCursor() const
|
||||
Draggable *DragController::draggableForQObject(QObject *o) const
|
||||
{
|
||||
for (auto draggable : m_draggables)
|
||||
if (draggable->asWidget() == o) {
|
||||
if (draggable->asView()->asQObject() == o) {
|
||||
return draggable;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ public:
|
||||
bool isInClientDrag() const;
|
||||
bool isIdle() const;
|
||||
|
||||
void grabMouseFor(QWidgetOrQuick *);
|
||||
void releaseMouse(QWidgetOrQuick *);
|
||||
void grabMouseFor(View *);
|
||||
void releaseMouse(View *);
|
||||
|
||||
Controllers::FloatingWindow *floatingWindowBeingDragged() const;
|
||||
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
|
||||
Draggable::List m_draggables;
|
||||
Draggable *m_draggable = nullptr;
|
||||
QPointer<WidgetType> m_draggableGuard; // Just so we know if the draggable was destroyed for some reason
|
||||
QPointer<QObject> m_draggableGuard; // Just so we know if the draggable was destroyed for some reason
|
||||
std::unique_ptr<WindowBeingDragged> m_windowBeingDragged;
|
||||
DropArea *m_currentDropArea = nullptr;
|
||||
bool m_nonClientDrag = false;
|
||||
|
||||
@@ -21,35 +21,35 @@ using namespace KDDockWidgets;
|
||||
class Draggable::Private
|
||||
{
|
||||
public:
|
||||
explicit Private(QWidgetOrQuick *_thisWidget, bool _enabled)
|
||||
: thisWidget(_thisWidget)
|
||||
explicit Private(View *_thisView, bool _enabled)
|
||||
: thisView(_thisView)
|
||||
, enabled(_enabled)
|
||||
{
|
||||
Q_ASSERT(thisWidget);
|
||||
Q_ASSERT(thisView);
|
||||
}
|
||||
|
||||
QPointer<WidgetResizeHandler> widgetResizeHandler;
|
||||
QWidgetOrQuick *const thisWidget;
|
||||
View *const thisView;
|
||||
const bool enabled;
|
||||
};
|
||||
|
||||
Draggable::Draggable(QWidgetOrQuick *thisWidget, bool enabled)
|
||||
: d(new Private(thisWidget, enabled))
|
||||
Draggable::Draggable(View *thisView, bool enabled)
|
||||
: d(new Private(thisView, enabled))
|
||||
{
|
||||
if (thisWidget && d->enabled)
|
||||
if (thisView && d->enabled)
|
||||
DragController::instance()->registerDraggable(this);
|
||||
}
|
||||
|
||||
Draggable::~Draggable()
|
||||
{
|
||||
if (d->thisWidget && d->enabled)
|
||||
if (d->thisView && d->enabled)
|
||||
DragController::instance()->unregisterDraggable(this);
|
||||
delete d;
|
||||
}
|
||||
|
||||
QWidgetOrQuick *Draggable::asWidget() const
|
||||
View *Draggable::asView() const
|
||||
{
|
||||
return d->thisWidget;
|
||||
return d->thisView;
|
||||
}
|
||||
|
||||
bool Draggable::dragCanStart(QPoint pressPos, QPoint globalPos) const
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class View;
|
||||
|
||||
namespace Controllers {
|
||||
class FloatingWindow;
|
||||
class DockWidget;
|
||||
@@ -41,9 +43,9 @@ class DOCKS_EXPORT Draggable
|
||||
public:
|
||||
typedef QVector<Draggable *> List;
|
||||
|
||||
explicit Draggable(QWidget *thisObject, bool enabled = true);
|
||||
explicit Draggable(View *thisView, bool enabled = true);
|
||||
virtual ~Draggable();
|
||||
QWidget *asWidget() const;
|
||||
View *asView() const;
|
||||
|
||||
/**
|
||||
* If this draggable is already a window, do nothing.
|
||||
|
||||
@@ -40,12 +40,11 @@ static Draggable *bestDraggable(Draggable *draggable)
|
||||
// When de detach a title bar it will get hidden and we only the title bar of the FloatingWindow is visible
|
||||
/// Apparently that causes problems with grabbing the mouse, so instead use a visible draggable.
|
||||
// grabbing mouse on an hidden window works usually, it's some edge case on Windows with MFC.
|
||||
if (auto tbView = qobject_cast<Views::TitleBar_qtwidgets *>(draggable->asWidget())) {
|
||||
auto titleBar = tbView->titleBar();
|
||||
if (auto titleBar = draggable->asView()->asTitleBarController()) {
|
||||
if (titleBar->isVisible())
|
||||
return draggable;
|
||||
|
||||
auto fw = tbView->window()->asFloatingWindowController();
|
||||
auto fw = titleBar->window()->asFloatingWindowController();
|
||||
if (!fw) // defensive, doesn't happen
|
||||
return draggable;
|
||||
|
||||
@@ -65,7 +64,8 @@ static Draggable *bestDraggable(Draggable *draggable)
|
||||
WindowBeingDragged::WindowBeingDragged(Controllers::FloatingWindow *fw, Draggable *draggable)
|
||||
: m_floatingWindow(fw)
|
||||
, m_draggable(bestDraggable(draggable))
|
||||
, m_draggableWidget(m_draggable ? m_draggable->asWidget() : nullptr)
|
||||
, m_draggableWidget(m_draggable ? m_draggable->asView() : nullptr)
|
||||
, m_guard(m_draggableWidget ? m_draggableWidget->asQObject() : nullptr)
|
||||
{
|
||||
init();
|
||||
|
||||
@@ -79,7 +79,8 @@ WindowBeingDragged::WindowBeingDragged(Controllers::FloatingWindow *fw, Draggabl
|
||||
|
||||
WindowBeingDragged::WindowBeingDragged(Draggable *draggable)
|
||||
: m_draggable(draggable)
|
||||
, m_draggableWidget(m_draggable->asWidget())
|
||||
, m_draggableWidget(m_draggable->asView())
|
||||
, m_guard(m_draggableWidget ? m_draggableWidget->asQObject() : nullptr)
|
||||
{
|
||||
if (!isWayland()) {
|
||||
qWarning() << Q_FUNC_INFO << "Wrong ctor called."; // Doesn't happen
|
||||
@@ -120,7 +121,7 @@ void WindowBeingDragged::init()
|
||||
|
||||
void WindowBeingDragged::grabMouse(bool grab)
|
||||
{
|
||||
if (!m_draggableWidget)
|
||||
if (!m_guard)
|
||||
return;
|
||||
|
||||
qCDebug(hovering) << "WindowBeingDragged: grab " << m_floatingWindow << grab << m_draggableWidget;
|
||||
@@ -168,7 +169,7 @@ bool WindowBeingDragged::contains(LayoutWidget *layoutWidget) const
|
||||
if (m_floatingWindow)
|
||||
return m_floatingWindow->layoutWidget() == layoutWidget;
|
||||
|
||||
if (auto fw = Views::ViewWrapper_qtwidgets(m_draggableWidget->window()).asFloatingWindowController()) {
|
||||
if (auto fw = m_draggableWidget->window()->asFloatingWindowController()) {
|
||||
// We're not dragging via the floating window itself, but via the tab bar. Still might represent floating window though.
|
||||
return fw->layoutWidget() == layoutWidget && fw->hasSingleFrame();
|
||||
}
|
||||
@@ -199,8 +200,7 @@ WindowBeingDraggedWayland::WindowBeingDraggedWayland(Draggable *draggable)
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto tbView = qobject_cast<Views::TitleBar_qtwidgets *>(draggable->asWidget())) {
|
||||
auto tb = tbView->titleBar();
|
||||
if (auto tb = draggable->asView()->asTitleBarController()) {
|
||||
if (auto fw = tb->floatingWindow()) {
|
||||
// case #1: we're dragging the whole floating window by its titlebar
|
||||
m_floatingWindow = fw;
|
||||
@@ -209,19 +209,18 @@ WindowBeingDraggedWayland::WindowBeingDraggedWayland(Draggable *draggable)
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "Shouldn't happen. TitleBar of what ?";
|
||||
}
|
||||
} else if (auto fw = Views::ViewWrapper_qtwidgets(draggable->asWidget()).asFloatingWindowController()) {
|
||||
} else if (auto fw = draggable->asView()->asFloatingWindowController()) {
|
||||
// case #2: the floating window itself is the draggable, happens on platforms that support
|
||||
// native dragging. Not the case for Wayland. But adding this case for completeness.
|
||||
m_floatingWindow = fw;
|
||||
#ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
} else if (auto tbw = qobject_cast<Views::TabBar_qtwidgets *>(draggable->asWidget())) {
|
||||
m_dockWidget = tbw->currentDockWidget();
|
||||
} else if (auto tw = qobject_cast<Views::Stack_qtwidgets *>(draggable->asWidget())) {
|
||||
m_frame = tw->stack()->frame();
|
||||
} else if (auto tabBar = draggable->asView()->asTabBarController()) {
|
||||
m_dockWidget = tabBar->currentDockWidget();
|
||||
} else if (auto stack = draggable->asView()->asStackController()) {
|
||||
m_frame = stack->frame();
|
||||
#endif
|
||||
} else {
|
||||
qWarning() << "Unknown draggable" << draggable->asWidget()
|
||||
<< "please fix";
|
||||
qWarning() << "Unknown draggable" << draggable << "please fix";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "kddockwidgets/docks_export.h"
|
||||
#include "controllers/FloatingWindow.h"
|
||||
#include "View.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -85,7 +86,8 @@ protected:
|
||||
Q_DISABLE_COPY(WindowBeingDragged)
|
||||
QPointer<Controllers::FloatingWindow> m_floatingWindow;
|
||||
Draggable *const m_draggable;
|
||||
QPointer<QWidget> m_draggableWidget; // Just to have a QPointer on it
|
||||
View *m_draggableWidget;
|
||||
QPointer<QObject> m_guard;
|
||||
};
|
||||
|
||||
struct WindowBeingDraggedWayland : public WindowBeingDragged
|
||||
|
||||
@@ -223,3 +223,13 @@ HANDLE ViewWrapper_qtwidgets::handle() const
|
||||
{
|
||||
return reinterpret_cast<HANDLE>(m_widget);
|
||||
}
|
||||
|
||||
void ViewWrapper_qtwidgets::grabMouse()
|
||||
{
|
||||
m_widget->grabMouse();
|
||||
}
|
||||
|
||||
void ViewWrapper_qtwidgets::releaseMouse()
|
||||
{
|
||||
m_widget->releaseMouse();
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
std::unique_ptr<ViewWrapper> window() const override;
|
||||
std::unique_ptr<ViewWrapper> parentView() const override;
|
||||
HANDLE handle() const override;
|
||||
void grabMouse() override;
|
||||
void releaseMouse() override;
|
||||
|
||||
private:
|
||||
QWidget *const m_widget;
|
||||
|
||||
@@ -337,6 +337,16 @@ public:
|
||||
QWidget::setObjectName(name);
|
||||
}
|
||||
|
||||
void grabMouse() override
|
||||
{
|
||||
QWidget::grabMouse();
|
||||
}
|
||||
|
||||
void releaseMouse() override
|
||||
{
|
||||
QWidget::releaseMouse();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e) override
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ static QPoint dragPointForWidget(Controllers::Frame *frame, int index)
|
||||
return frame->titleBar()->mapToGlobal(QPoint(5, 5));
|
||||
} else {
|
||||
QRect rect = frame->tabWidget()->tabBar()->rectForTab(index);
|
||||
return frame->tabWidget()->tabBar()->asWidget()->mapToGlobal(rect.center());
|
||||
return frame->tabWidget()->tabBar()->view()->mapToGlobal(rect.center());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4847,8 +4847,8 @@ void TestDocks::tst_titleBarFocusedWhenTabsChange()
|
||||
|
||||
auto tabBar2 = tb2->tabBar();
|
||||
const QRect rect0 = tabBar2->rectForTab(0);
|
||||
const QPoint globalPos = tabBar2->asWidget()->mapToGlobal(rect0.topLeft()) + QPoint(5, 5);
|
||||
Tests::clickOn(globalPos, tabBar2->asWidget());
|
||||
const QPoint globalPos = tabBar2->view()->mapToGlobal(rect0.topLeft()) + QPoint(5, 5);
|
||||
Tests::clickOn(globalPos, tabBar2->view()->asQWidget());
|
||||
|
||||
QVERIFY(!titleBar1->isFocused());
|
||||
QVERIFY(dock2->titleBar()->isFocused());
|
||||
@@ -4860,7 +4860,7 @@ void TestDocks::tst_titleBarFocusedWhenTabsChange()
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
// TODO: Not yet ready for QtQuick. The TitleBar.qml is clicked, but we check the C++ TitleBar for focus
|
||||
Tests::clickOn(globalPos, tabBar2->asWidget());
|
||||
Tests::clickOn(globalPos, tabBar2->view()->asQWidget());
|
||||
QVERIFY(!dock1->titleBar()->isFocused());
|
||||
QVERIFY(dock2->titleBar()->isFocused());
|
||||
#endif
|
||||
@@ -6621,7 +6621,7 @@ void TestDocks::tst_doubleClickTabToDetach()
|
||||
auto frame = dock1->dptr()->frame();
|
||||
QCOMPARE(frame->currentIndex(), 1);
|
||||
|
||||
auto tb = frame->tabWidget()->asWidget();
|
||||
auto tb = frame->tabWidget()->view()->asQWidget();
|
||||
|
||||
// TODO
|
||||
Tests::doubleClickOn(tb->mapToGlobal(QPoint(20, 20)), frame->view()->asQWidget()->window()->windowHandle());
|
||||
@@ -7173,7 +7173,7 @@ void TestDocks::tst_dragBySingleTab()
|
||||
Controllers::TabBar *tabBar = frame1->tabWidget()->tabBar();
|
||||
QVERIFY(tabBar);
|
||||
SetExpectedWarning sew("No window being dragged for"); // because dragging by tab does nothing in this case
|
||||
drag(tabBar->asWidget(), globalPressPos, QPoint(0, 0));
|
||||
drag(tabBar->view()->asQWidget(), globalPressPos, QPoint(0, 0));
|
||||
|
||||
delete dock1;
|
||||
Testing::waitForDeleted(frame1);
|
||||
@@ -7215,7 +7215,7 @@ void TestDocks::tst_dragByTabBar()
|
||||
dock2->addDockWidgetAsTab(dock3);
|
||||
#if defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
if (documentMode)
|
||||
static_cast<QTabWidget *>(dock2->dptr()->frame()->tabWidget()->asWidget())
|
||||
static_cast<QTabWidget *>(dock2->dptr()->frame()->tabWidget()->view()->asQWidget())
|
||||
->setDocumentMode(true);
|
||||
#else
|
||||
Q_UNUSED(documentMode);
|
||||
@@ -7267,7 +7267,7 @@ void TestDocks::tst_dock2FloatingWidgetsTabbed()
|
||||
QPoint globalPressPos = dragPointForWidget(frame2.data(), 0);
|
||||
Controllers::TabBar *tabBar = frame2->tabWidget()->tabBar();
|
||||
QVERIFY(tabBar);
|
||||
drag(tabBar->asWidget(), globalPressPos, frame2->view()->windowGeometry().bottomRight() + QPoint(10, 10));
|
||||
drag(tabBar->view()->asQWidget(), globalPressPos, frame2->view()->windowGeometry().bottomRight() + QPoint(10, 10));
|
||||
|
||||
QVERIFY(frame2->dockWidgetCount() == 1);
|
||||
QVERIFY(dock1->floatingWindow());
|
||||
@@ -7287,7 +7287,7 @@ void TestDocks::tst_dock2FloatingWidgetsTabbed()
|
||||
tabBar = frame2->tabWidget()->tabBar();
|
||||
|
||||
finalPoint = dock2->window()->geometry().center() + QPoint(7, 7);
|
||||
drag(tabBar->asWidget(), globalPressPos, finalPoint);
|
||||
drag(tabBar->view()->asQWidget(), globalPressPos, finalPoint);
|
||||
QCOMPARE(frame2->dockWidgetCount(), 2);
|
||||
|
||||
// 2.6 Drag the tabbed group over a 3rd floating window
|
||||
|
||||
@@ -362,7 +362,7 @@ inline WidgetType *draggableFor(WidgetType *w)
|
||||
: nullptr;
|
||||
|
||||
if ((KDDockWidgets::Config::self().flags() & KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible) && frame && frame->hasTabsVisible()) {
|
||||
draggable = frame->tabWidget()->asWidget();
|
||||
draggable = frame->tabWidget()->view()->asQWidget();
|
||||
} else {
|
||||
draggable = fw->titleBar()->view()->asQWidget();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user