From 49d1bcbd3993182276e3b492b19b67e52eb596b9 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 28 Jun 2019 01:30:31 +0200 Subject: [PATCH] Restore dock widget from settings, fixed frameless widget restore https://discordapp.com/channels/539048679160676382/539486309882789888/593835010566521033 --- src/blackgui/dockwidget.cpp | 18 ++++++++++++++---- src/blackgui/dockwidget.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index afbb700a5..20d009a76 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -280,6 +280,15 @@ namespace BlackGui this->setFrameless(!frameless); } + void CDockWidget::toggleFramelessDeferred(int delayMs) + { + QPointer myself(this); + QTimer::singleShot(delayMs, this, [ = ] + { + if (myself) { myself->toggleFrameless(); } + }); + } + void CDockWidget::windowAlwaysOnTop() { if (this->isFloating()) @@ -317,16 +326,17 @@ namespace BlackGui { this->toggleFloating(); } - if (s.isFramless() != this->isFrameless()) - { - this->toggleFrameless(); - } const QByteArray geo(s.getGeometry()); if (!geo.isEmpty()) { const bool ok = this->restoreGeometry(geo); if (ok) { this->rememberFloatingSizeAndPosition(); } } + if (s.isFramless() != this->isFrameless()) + { + // not working if directly called + this->toggleFramelessDeferred(); + } this->setMargins(); return true; } diff --git a/src/blackgui/dockwidget.h b/src/blackgui/dockwidget.h index ab69f5c52..f3ac94dd1 100644 --- a/src/blackgui/dockwidget.h +++ b/src/blackgui/dockwidget.h @@ -108,6 +108,9 @@ namespace BlackGui //! Toggle frameless mode void toggleFrameless(); + //! Toggle frameless deferred + void toggleFramelessDeferred(int delayMs = 1000); + //! Window always on top void windowAlwaysOnTop();