Allow SeparatePanel not to join all spaces.

This commit is contained in:
John Preston 2022-08-04 19:27:45 +03:00
parent dcb4a33eef
commit 9b5c58f92f
2 changed files with 14 additions and 7 deletions

View file

@ -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<Ui::IconButton>(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<QString> 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() {

View file

@ -29,9 +29,14 @@ class FlatLabel;
template <typename Widget>
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<QString> 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();