qtquick: Window resizing works on Linux/mac now
This commit is contained in:
@@ -79,7 +79,7 @@ public:
|
||||
QPointer<FloatingWindow> m_floatingWindow;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
static Qt::WindowFlags windowFlagsToUse()
|
||||
{
|
||||
@@ -150,7 +150,10 @@ FloatingWindow::FloatingWindow(MainWindowBase *parent)
|
||||
if (Config::self().flags() & Config::Flag_KeepAboveIfNotUtilityWindow)
|
||||
setWindowFlag(Qt::WindowStaysOnTopHint, true);
|
||||
|
||||
maybeCreateResizeHandler();
|
||||
if (kddwUsesQtWidgets()) {
|
||||
// QtQuick will do it a bit later, once it has a QWindow
|
||||
maybeCreateResizeHandler();
|
||||
}
|
||||
|
||||
updateTitleBarVisibility();
|
||||
connect(m_dropArea, &MultiSplitter::visibleWidgetCountChanged, this, &FloatingWindow::onFrameCountChanged);
|
||||
@@ -205,7 +208,7 @@ void FloatingWindow::setupWindow()
|
||||
MARGINS margins = {0, 0, 0, 1}; // arbitrary, just needs to be > 0 it seems
|
||||
DwmExtendFrameIntoClientArea(HWND(winId()), &margins);
|
||||
}
|
||||
#endif
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
@@ -489,4 +492,3 @@ bool FloatingWindow::event(QEvent *ev)
|
||||
|
||||
return QWidgetAdapter::event(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,8 @@ Q_SIGNALS:
|
||||
void numFramesChanged();
|
||||
void windowStateChanged(QWindowStateChangeEvent *);
|
||||
protected:
|
||||
|
||||
void setupWindow();
|
||||
void maybeCreateResizeHandler();
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
|
||||
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||
@@ -144,7 +144,6 @@ protected:
|
||||
TitleBar *const m_titleBar;
|
||||
private:
|
||||
Q_DISABLE_COPY(FloatingWindow)
|
||||
void maybeCreateResizeHandler();
|
||||
void onFrameCountChanged(int count);
|
||||
void onVisibleFrameCountChanged(int count);
|
||||
bool m_disableSetVisible = false;
|
||||
|
||||
@@ -54,10 +54,11 @@ WidgetResizeHandler::~WidgetResizeHandler()
|
||||
|
||||
bool WidgetResizeHandler::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (s_disableAllHandlers || o != mTarget)
|
||||
if (s_disableAllHandlers || o != mTarget) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto widget = qobject_cast<QWidget*>(o);
|
||||
auto widget = qobject_cast<QWidgetOrQuick*>(o);
|
||||
if (!widget || !widget->isTopLevel()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,6 +177,8 @@ void FloatingWindowQuick::init()
|
||||
|
||||
QWidgetAdapter::setParent(m_quickWindow->contentItem());
|
||||
setupWindow();
|
||||
m_quickWindow->installEventFilter(this); // for window resizing
|
||||
maybeCreateResizeHandler();
|
||||
|
||||
m_visualItem = createItem(Config::self().qmlEngine(), QStringLiteral("qrc:/kddockwidgets/private/quick/qml/FloatingWindow.qml"));
|
||||
Q_ASSERT(m_visualItem);
|
||||
|
||||
@@ -559,9 +559,9 @@ void QWidgetAdapter::render(QPainter *)
|
||||
qWarning() << Q_FUNC_INFO << "Implement me";
|
||||
}
|
||||
|
||||
void QWidgetAdapter::setMouseTracking(bool)
|
||||
void QWidgetAdapter::setMouseTracking(bool enabled)
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "Implement me";
|
||||
m_mouseTrackingEnabled = enabled;
|
||||
}
|
||||
|
||||
bool QWidgetAdapter::event(QEvent *ev)
|
||||
@@ -572,6 +572,29 @@ bool QWidgetAdapter::event(QEvent *ev)
|
||||
return QQuickItem::event(ev);
|
||||
}
|
||||
|
||||
bool QWidgetAdapter::eventFilter(QObject *watched, QEvent *ev)
|
||||
{
|
||||
if (qobject_cast<QWindow*>(watched)) {
|
||||
if (m_mouseTrackingEnabled) {
|
||||
switch (ev->type()) {
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
ev->ignore();
|
||||
qApp->sendEvent(this, ev);
|
||||
//qDebug() << "Mouse event" << ev;
|
||||
if (ev->isAccepted())
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QQuickItem::eventFilter(watched, ev);
|
||||
}
|
||||
|
||||
void QWidgetAdapter::setWindowIsBeingDestroyed(bool is)
|
||||
{
|
||||
m_windowIsBeingDestroyed = is;
|
||||
|
||||
@@ -170,6 +170,7 @@ Q_SIGNALS:
|
||||
protected:
|
||||
void create();
|
||||
bool event(QEvent *) override;
|
||||
bool eventFilter(QObject *, QEvent *) override;
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
||||
void raiseAndActivate();
|
||||
virtual bool onResize(QSize newSize);
|
||||
@@ -186,6 +187,7 @@ private:
|
||||
int m_widgetAttributes = 0; // Qt::WidgetAttribute
|
||||
Qt::FocusPolicy m_focusPolicy = Qt::NoFocus;
|
||||
bool m_windowIsBeingDestroyed = false;
|
||||
bool m_mouseTrackingEnabled = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user