Introduce "Maximize/restore" title bar button support

As happens with other docking frameworks:
- Maximized/restore button only visible when window is floating
- floating button is never visible

Available by setting Flag_TitleBarHasMaximizeButton.
Added example too.

Fixes: #37
This commit is contained in:
Sergio Martins
2020-04-20 19:54:03 +01:00
parent ab0fc1e328
commit 6ee3cfbb2d
9 changed files with 81 additions and 6 deletions

View File

@@ -27,6 +27,7 @@
#include <QApplication>
#include <QPainter>
#include <QVBoxLayout>
#include <QWindowStateChangeEvent>
using namespace KDDockWidgets;
@@ -51,6 +52,14 @@ void FloatingWindowWidget::paintEvent(QPaintEvent *)
p.drawRect(rect().adjusted(0, 0, -1, -1));
}
bool FloatingWindowWidget::event(QEvent *ev)
{
if (ev->type() == QEvent::WindowStateChange)
Q_EMIT windowStateChanged(static_cast<QWindowStateChangeEvent*>(ev));
return FloatingWindow::event(ev);
}
void FloatingWindowWidget::init()
{
m_vlayout->setSpacing(0);