Emit DockRegistry::windowChangedScreen()
We now have a signal we can connect to adapt sizes to logical dpi changes
This commit is contained in:
@@ -18,15 +18,18 @@
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Config.h"
|
||||
#include "DockRegistry_p.h"
|
||||
#include "DropAreaWithCentralFrame_p.h"
|
||||
#include "DropArea_p.h"
|
||||
#include "Frame_p.h"
|
||||
#include "FrameworkWidgetFactory.h"
|
||||
#include "Logging_p.h"
|
||||
#include "SideBar_p.h"
|
||||
#include "DropAreaWithCentralFrame_p.h"
|
||||
#include "FrameworkWidgetFactory.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
|
||||
// clazy:excludeall=ctor-missing-parent-argument,missing-qobject-macro
|
||||
|
||||
@@ -92,6 +95,10 @@ MainWindow::MainWindow(const QString &name, MainWindowOptions options,
|
||||
}
|
||||
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
create();
|
||||
connect(windowHandle(), &QWindow::screenChanged, DockRegistry::self(),
|
||||
[this] { Q_EMIT DockRegistry::self()->windowChangedScreen(windowHandle()); });
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
||||
@@ -206,7 +206,11 @@ public:
|
||||
SideBarLocation sideBarLocationForDockWidget(const DockWidgetBase *) const;
|
||||
|
||||
///@brief Overload that returns the SideBar itself
|
||||
SideBar* sideBarForDockWidget(const DockWidgetBase *) const;
|
||||
SideBar *sideBarForDockWidget(const DockWidgetBase *) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/// @brief emitted when a main window or a floating window change screen
|
||||
void windowChangedScreen(QWindow *);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
@@ -9,15 +9,17 @@
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "DockRegistry_p.h"
|
||||
#include "DropArea_p.h"
|
||||
#include "FloatingWindowWidget_p.h"
|
||||
#include "Logging_p.h"
|
||||
#include "Utils_p.h"
|
||||
#include "DropArea_p.h"
|
||||
#include "TitleBar_p.h"
|
||||
#include "Utils_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
@@ -56,7 +58,15 @@ void FloatingWindowWidget::paintEvent(QPaintEvent *ev)
|
||||
bool FloatingWindowWidget::event(QEvent *ev)
|
||||
{
|
||||
if (ev->type() == QEvent::WindowStateChange)
|
||||
Q_EMIT windowStateChanged(static_cast<QWindowStateChangeEvent*>(ev));
|
||||
Q_EMIT windowStateChanged(static_cast<QWindowStateChangeEvent *>(ev));
|
||||
|
||||
if (ev->type() == QEvent::Show && !m_screenChangedConnection) {
|
||||
// We connect after QEvent::Show, so we have a QWindow. Qt doesn't offer much API to
|
||||
// intercept screen events
|
||||
m_screenChangedConnection =
|
||||
connect(windowHandle(), &QWindow::screenChanged, DockRegistry::self(),
|
||||
[this] { Q_EMIT DockRegistry::self()->windowChangedScreen(windowHandle()); });
|
||||
}
|
||||
|
||||
return FloatingWindow::event(ev);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ protected:
|
||||
bool event(QEvent *ev) override;
|
||||
|
||||
QVBoxLayout *const m_vlayout;
|
||||
QMetaObject::Connection m_screenChangedConnection;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
Reference in New Issue
Block a user