From ef3b942fece049f191196a0d724f34e196055ef3 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 4 Oct 2019 21:34:20 +0800 Subject: [PATCH] ui tweak and minor bug fixes --- bottombuttongroup.cpp | 4 +++- bottombuttongroup.h | 1 + graphicsview.cpp | 2 ++ mainwindow.cpp | 10 +++++++++- navigatorview.cpp | 4 +++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bottombuttongroup.cpp b/bottombuttongroup.cpp index 49e6584..c57f7e3 100644 --- a/bottombuttongroup.cpp +++ b/bottombuttongroup.cpp @@ -36,7 +36,9 @@ BottomButtonGroup::BottomButtonGroup(QWidget *parent) addButton(newBtn("zoom-original", [this]() { emit resetToOriginalBtnClicked(); })); - addButton(newBtn("view-fullscreen", [](){qDebug()<< "TODO: view-fullscreen";})); + addButton(newBtn("view-fullscreen", [this]() { + emit toggleWindowMaximum(); + })); addButton(newBtn("zoom-in", [this]() { emit zoomInBtnClicked(); })); diff --git a/bottombuttongroup.h b/bottombuttongroup.h index e338f5c..1284959 100644 --- a/bottombuttongroup.h +++ b/bottombuttongroup.h @@ -14,6 +14,7 @@ public: signals: void resetToOriginalBtnClicked(); + void toggleWindowMaximum(); void zoomInBtnClicked(); void zoomOutBtnClicked(); void toggleCheckerboardBtnClicked(); diff --git a/graphicsview.cpp b/graphicsview.cpp index e88871b..b8c6629 100644 --- a/graphicsview.cpp +++ b/graphicsview.cpp @@ -193,6 +193,8 @@ void GraphicsView::resizeEvent(QResizeEvent *event) } else { fitInView(sceneRect(), Qt::KeepAspectRatio); } + } else { + emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle); } return QGraphicsView::resizeEvent(event); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 4c1f9b4..4a3e0c1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) : this->setCentralWidget(m_graphicsView); m_gv = new NavigatorView(this); - m_gv->setFixedSize(250, 160); + m_gv->setFixedSize(220, 160); m_gv->setScene(scene); m_gv->setMainView(m_graphicsView); m_gv->fitInView(m_gv->sceneRect(), Qt::KeepAspectRatio); @@ -79,6 +79,14 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_bottomButtonGroup, &BottomButtonGroup::resetToOriginalBtnClicked, this, [ = ](){ m_graphicsView->resetScale(); }); + connect(m_bottomButtonGroup, &BottomButtonGroup::toggleWindowMaximum, + this, [ = ](){ + if (isMaximized()) { + showNormal(); + } else { + showMaximized(); + } + }); connect(m_bottomButtonGroup, &BottomButtonGroup::zoomInBtnClicked, this, [ = ](){ m_graphicsView->zoomView(1.25); }); connect(m_bottomButtonGroup, &BottomButtonGroup::zoomOutBtnClicked, diff --git a/navigatorview.cpp b/navigatorview.cpp index fa8e51f..c02dee8 100644 --- a/navigatorview.cpp +++ b/navigatorview.cpp @@ -11,7 +11,7 @@ NavigatorView::NavigatorView(QWidget *parent) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setStyleSheet("background-color: rgba(0, 0, 0, 220);" + setStyleSheet("background-color: rgba(0, 0, 0, 120);" "border-radius: 3px;"); } @@ -34,6 +34,7 @@ void NavigatorView::mousePressEvent(QMouseEvent *event) if (m_mainView) { m_mainView->centerOn(mapToScene(event->pos())); + update(); } return QGraphicsView::mousePressEvent(event); @@ -43,6 +44,7 @@ void NavigatorView::mouseMoveEvent(QMouseEvent *event) { if (m_mouseDown && m_mainView) { m_mainView->centerOn(mapToScene(event->pos())); + update(); } return QGraphicsView::mouseMoveEvent(event);