From 9b5c58f92f129925b48449bba20bb6e9678d2e58 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Aug 2022 19:27:45 +0300 Subject: [PATCH] Allow SeparatePanel not to join all spaces. --- ui/widgets/separate_panel.cpp | 12 +++++++----- ui/widgets/separate_panel.h | 9 +++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ui/widgets/separate_panel.cpp b/ui/widgets/separate_panel.cpp index 4176ba3..063bb42 100644 --- a/ui/widgets/separate_panel.cpp +++ b/ui/widgets/separate_panel.cpp @@ -89,8 +89,8 @@ PanelShow::operator bool() const { } // namespace -SeparatePanel::SeparatePanel(QWidget *parent) -: RpWidget(parent) +SeparatePanel::SeparatePanel(SeparatePanelArgs &&args) +: RpWidget(args.parent) , _close(this, st::separatePanelClose) , _back(this, object_ptr(this, st::separatePanelBack)) , _body(this) @@ -98,7 +98,7 @@ SeparatePanel::SeparatePanel(QWidget *parent) setMouseTracking(true); setWindowIcon(QGuiApplication::windowIcon()); initControls(); - initLayout(); + initLayout(args); } void SeparatePanel::setTitle(rpl::producer title) { @@ -280,7 +280,7 @@ bool SeparatePanel::eventHook(QEvent *e) { return RpWidget::eventHook(e); } -void SeparatePanel::initLayout() { +void SeparatePanel::initLayout(const SeparatePanelArgs &args) { setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint) | Qt::WindowStaysOnTopHint | Qt::NoDropShadowWindowHint @@ -296,7 +296,9 @@ void SeparatePanel::initLayout() { Ui::ForceFullRepaint(this); }, lifetime()); - Ui::Platform::InitOnTopPanel(this); + if (args.onAllSpaces) { + Ui::Platform::InitOnTopPanel(this); + } } void SeparatePanel::createBorderImage() { diff --git a/ui/widgets/separate_panel.h b/ui/widgets/separate_panel.h index 311c02f..63cfbdd 100644 --- a/ui/widgets/separate_panel.h +++ b/ui/widgets/separate_panel.h @@ -29,9 +29,14 @@ class FlatLabel; template class FadeWrapScaled; +struct SeparatePanelArgs { + QWidget *parent = nullptr; + bool onAllSpaces = false; +}; + class SeparatePanel final : public RpWidget { public: - explicit SeparatePanel(QWidget *parent = nullptr); + explicit SeparatePanel(SeparatePanelArgs &&args = {}); void setTitle(rpl::producer title); void setTitleHeight(int height); @@ -73,7 +78,7 @@ protected: private: void initControls(); - void initLayout(); + void initLayout(const SeparatePanelArgs &args); void initGeometry(QSize size); void updateGeometry(QSize size); void showControls();