Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix hiding of the titlebar on Qt6

Dmitry Kazakov176bf59a7f32
diff --git a/libs/widgets/KoDockWidgetTitleBar.cpp b/libs/widgets/KoDockWidgetTitleBar.cpp
index ea836a73c7..e98e32aa85 100644
--- a/libs/widgets/KoDockWidgetTitleBar.cpp
+++ b/libs/widgets/KoDockWidgetTitleBar.cpp
@@ -249,12 +249,42 @@ void KoDockWidgetTitleBar::Private::updateButtonSizes()
void KoDockWidgetTitleBar::hideEvent(QHideEvent *event){
Q_UNUSED(event);
d->updateButtonSizes();
+
+ /**
+ * On Qt6 QDockWidget will read the size hint of the titlebar
+ * before it is actually made visible, so we should force
+ * it to recalcualate, when visibility (and hence size-hint)
+ * is changed
+ */
+ if (parentWidget() && parentWidget()->layout()) {
+ parentWidget()->layout()->update();
+ }
}
void KoDockWidgetTitleBar::showEvent(QShowEvent *event){
Q_UNUSED(event);
d->updateButtonSizes();
d->closeButton->setVisible(true);
+
+ /**
+ * On Qt6 QDockWidget will read the size hint of the titlebar
+ * before it is actually made visible, so we should force
+ * it to recalcualate, when visibility (and hence size-hint)
+ * is changed
+ */
+ if (parentWidget() && parentWidget()->layout()) {
+ parentWidget()->layout()->update();
+ }
+}
+
+QSize KoDockWidgetTitleBar::sizeHint() const
+{
+ /**
+ * On Qt6 QDockWidget reserves space for the titlebar
+ * purely on its size hint, ignoring its visiblity, so
+ * we should account for that in the size hint itself
+ */
+ return isVisible() ? QWidget::sizeHint() : QSize();
}
//have to include this because of Q_PRIVATE_SLOT
diff --git a/libs/widgets/KoDockWidgetTitleBar.h b/libs/widgets/KoDockWidgetTitleBar.h
index 154f02e89c..1b18ce1f31 100644
--- a/libs/widgets/KoDockWidgetTitleBar.h
+++ b/libs/widgets/KoDockWidgetTitleBar.h
@@ -33,6 +33,8 @@ protected:
void resizeEvent(QResizeEvent* event) override; ///< reimplemented from QWidget
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;
+ QSize sizeHint() const override;
+
private:
Q_PRIVATE_SLOT(d, void toggleFloating())
Q_PRIVATE_SLOT(d, void topLevelChanged(bool topLevel))