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.
|
// we can show the picture by increase the window size.
|
||||||
QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ?
|
QSize finalSize = (screenSize.expandedTo(sceneSizeWithMargins) == screenSize) ?
|
||||||
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
|
// We have a very reasonable sizeHint() value ;P
|
||||||
this->resize(finalSize.expandedTo(this->sizeHint()));
|
this->resize(finalSize.expandedTo(this->sizeHint()));
|
||||||
|
centerWindow();
|
||||||
|
}
|
||||||
|
|
||||||
// We're sure the window can display the whole thing with 1:1 scale.
|
// 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
|
// 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
|
// 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.
|
// just call resetScale() here to ensure the thing is no longer scaled.
|
||||||
m_graphicsView->resetScale();
|
m_graphicsView->resetScale();
|
||||||
centerWindow();
|
|
||||||
} else {
|
} else {
|
||||||
// toggle maximum
|
// toggle maximum
|
||||||
showMaximized();
|
showMaximized();
|
||||||
@@ -346,11 +353,14 @@ void MainWindow::leaveEvent(QEvent *event)
|
|||||||
|
|
||||||
void MainWindow::mousePressEvent(QMouseEvent *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_clickedOnWindow = true;
|
||||||
m_oldMousePos = event->pos();
|
|
||||||
// qDebug() << m_oldMousePos << m_graphicsView->transform().m11()
|
|
||||||
// << m_graphicsView->transform().m22() << m_graphicsView->matrix().m12();
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,9 +369,9 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized() && !isFullScreen()) {
|
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow) {
|
||||||
if (!window()->windowHandle()->startSystemMove()) {
|
if (window()->windowHandle()->startSystemMove()) {
|
||||||
move(event->globalPosition().toPoint() - m_oldMousePos);
|
m_clickedOnWindow = false;
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ private:
|
|||||||
ActionManager *m_am;
|
ActionManager *m_am;
|
||||||
PlaylistManager *m_pm;
|
PlaylistManager *m_pm;
|
||||||
|
|
||||||
QPoint m_oldMousePos;
|
|
||||||
QPropertyAnimation *m_fadeOutAnimation;
|
QPropertyAnimation *m_fadeOutAnimation;
|
||||||
QPropertyAnimation *m_floatUpAnimation;
|
QPropertyAnimation *m_floatUpAnimation;
|
||||||
QParallelAnimationGroup *m_exitAnimationGroup;
|
QParallelAnimationGroup *m_exitAnimationGroup;
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ void TitleBar::mousePressEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_dragPending = true;
|
m_dragPending = true;
|
||||||
m_moveStartPos = event->pos();
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,11 +128,18 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->buttons() & Qt::LeftButton && m_dragPending
|
#if defined(Q_OS_WIN)
|
||||||
&& !window()->isMaximized() && !window()->isFullScreen()) {
|
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 (QWindow *wh = window()->windowHandle()) {
|
||||||
if (!wh->startSystemMove())
|
if (wh->startSystemMove()) {
|
||||||
window()->move(event->globalPosition().toPoint() - m_moveStartPos);
|
m_dragPending = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ private:
|
|||||||
bool m_closeHovered = false;
|
bool m_closeHovered = false;
|
||||||
bool m_closePressed = false;
|
bool m_closePressed = false;
|
||||||
bool m_dragPending = false;
|
bool m_dragPending = false;
|
||||||
QPoint m_moveStartPos;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TITLEBAR_H
|
#endif // TITLEBAR_H
|
||||||
|
|||||||
Reference in New Issue
Block a user