Compare commits
3 Commits
ebc2387a14
...
a8aa5b5c30
| Author | SHA1 | Date | |
|---|---|---|---|
| a8aa5b5c30 | |||
|
|
a10bbb4e8d | ||
|
|
033e48044c |
@@ -229,15 +229,22 @@ void MainWindow::adjustWindowSizeBySceneRect()
|
||||
// we can show the picture by increase the window size.
|
||||
QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ?
|
||||
sceneSizeWithMargins : screenSize;
|
||||
|
||||
// to avoid the window appearing maximized while not being actually maximized
|
||||
// which is common when viewing screenshots of the same screen size
|
||||
if (finalSize == screenSize) {
|
||||
showMaximized();
|
||||
} else {
|
||||
// We have a very reasonable sizeHint() value ;P
|
||||
this->resize(finalSize.expandedTo(this->sizeHint()));
|
||||
centerWindow();
|
||||
}
|
||||
|
||||
// We're sure the window can display the whole thing with 1:1 scale.
|
||||
// The old window size may cause fitInView call from resize() and the
|
||||
// above resize() call won't reset the scale back to 1:1, so we
|
||||
// just call resetScale() here to ensure the thing is no longer scaled.
|
||||
m_graphicsView->resetScale();
|
||||
centerWindow();
|
||||
} else {
|
||||
// toggle maximum
|
||||
showMaximized();
|
||||
@@ -346,11 +353,14 @@ void MainWindow::leaveEvent(QEvent *event)
|
||||
|
||||
void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton && !isMaximized()) {
|
||||
#if defined(Q_OS_WIN)
|
||||
const bool shouldAcceptDrag = !isMaximized() && !isFullScreen();
|
||||
#else
|
||||
const bool shouldAcceptDrag = !isFullScreen();
|
||||
#endif
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && shouldAcceptDrag) {
|
||||
m_clickedOnWindow = true;
|
||||
m_oldMousePos = event->pos();
|
||||
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
||||
// << m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -359,9 +369,9 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized() && !isFullScreen()) {
|
||||
if (!window()->windowHandle()->startSystemMove()) {
|
||||
move(event->globalPosition().toPoint() - m_oldMousePos);
|
||||
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow) {
|
||||
if (window()->windowHandle()->startSystemMove()) {
|
||||
m_clickedOnWindow = false;
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ private:
|
||||
ActionManager *m_am;
|
||||
PlaylistManager *m_pm;
|
||||
|
||||
QPoint m_oldMousePos;
|
||||
QPropertyAnimation *m_fadeOutAnimation;
|
||||
QPropertyAnimation *m_floatUpAnimation;
|
||||
QParallelAnimationGroup *m_exitAnimationGroup;
|
||||
|
||||
@@ -115,7 +115,6 @@ void TitleBar::mousePressEvent(QMouseEvent *event)
|
||||
}
|
||||
|
||||
m_dragPending = true;
|
||||
m_moveStartPos = event->pos();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -129,11 +128,18 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && m_dragPending
|
||||
&& !window()->isMaximized() && !window()->isFullScreen()) {
|
||||
#if defined(Q_OS_WIN)
|
||||
const bool shouldAcceptDrag = !window()->isMaximized() && !window()->isFullScreen();
|
||||
#else
|
||||
const bool shouldAcceptDrag = !window()->isFullScreen();
|
||||
#endif
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && m_dragPending && shouldAcceptDrag) {
|
||||
|
||||
if (QWindow *wh = window()->windowHandle()) {
|
||||
if (!wh->startSystemMove())
|
||||
window()->move(event->globalPosition().toPoint() - m_moveStartPos);
|
||||
if (wh->startSystemMove()) {
|
||||
m_dragPending = false;
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ private:
|
||||
bool m_closeHovered = false;
|
||||
bool m_closePressed = false;
|
||||
bool m_dragPending = false;
|
||||
QPoint m_moveStartPos;
|
||||
};
|
||||
|
||||
#endif // TITLEBAR_H
|
||||
|
||||
Reference in New Issue
Block a user