mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
[UI] avoid "jumping around" if window was resized
* resizing in frameless is subject of QSizeGrip in the status bar * also make sure resize grip is always aligned to the right QSizePolicy::MinimumExpanding * the last point still still happens (resize button centered) for an unknown reason
This commit is contained in:
committed by
Mat Sutcliffe
parent
d8ec308a3b
commit
516a7063e5
@@ -213,8 +213,19 @@ namespace BlackGui
|
||||
bool CEnableForFramelessWindow::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_ASSERT(m_widget);
|
||||
if (m_windowMode == WindowFrameless && event->buttons() & Qt::LeftButton && !m_framelessDragPosition.isNull())
|
||||
if (m_windowMode == WindowFrameless && event->buttons() == Qt::LeftButton && !m_framelessDragPosition.isNull())
|
||||
{
|
||||
const QSize s = m_widget->size();
|
||||
const bool changedSize = (m_moveSize != s);
|
||||
|
||||
// avoid "jumping around" if window was resized
|
||||
// resizing in frameless is subject of QSizeGrip in the status bar
|
||||
if (changedSize)
|
||||
{
|
||||
m_moveSize = s;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_widget->move(event->globalPos() - m_framelessDragPosition);
|
||||
event->accept();
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QSize>
|
||||
#include <Qt>
|
||||
|
||||
class QEvent;
|
||||
@@ -88,6 +89,7 @@ namespace BlackGui
|
||||
|
||||
protected:
|
||||
QPoint m_framelessDragPosition; //!< position, if moving is handled with frameless window
|
||||
QSize m_moveSize; //!< size when moved (in frameless window)
|
||||
QPushButton *m_framelessCloseButton = nullptr; //!< close button
|
||||
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
||||
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace BlackGui
|
||||
m_ownedStatusBar = statusBar ? false : true;
|
||||
m_statusBar = statusBar ? statusBar : new QStatusBar();
|
||||
if (m_statusBar->objectName().isEmpty()) { m_statusBar->setObjectName("sb_ManagedStatusBar"); }
|
||||
if (m_ownedStatusBar) { m_statusBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);}
|
||||
// if (m_ownedStatusBar) { m_statusBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);}
|
||||
|
||||
m_statusBarIcon = new QLabel(m_statusBar);
|
||||
m_statusBarIcon->setObjectName(QString("lbl_StatusBarIcon").append(m_statusBar->objectName()));
|
||||
@@ -67,7 +67,7 @@ namespace BlackGui
|
||||
if (m_ownedStatusBar)
|
||||
{
|
||||
// self created status bar
|
||||
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(m_statusBar->sizePolicy().hasHeightForWidth());
|
||||
|
||||
Reference in New Issue
Block a user