ui tweak and minor bug fixes

This commit is contained in:
Gary Wang 2019-10-04 21:34:20 +08:00
parent e11ca3bba5
commit ef3b942fec
5 changed files with 18 additions and 3 deletions

View File

@ -36,7 +36,9 @@ BottomButtonGroup::BottomButtonGroup(QWidget *parent)
addButton(newBtn("zoom-original", [this]() { addButton(newBtn("zoom-original", [this]() {
emit resetToOriginalBtnClicked(); emit resetToOriginalBtnClicked();
})); }));
addButton(newBtn("view-fullscreen", [](){qDebug()<< "TODO: view-fullscreen";})); addButton(newBtn("view-fullscreen", [this]() {
emit toggleWindowMaximum();
}));
addButton(newBtn("zoom-in", [this]() { addButton(newBtn("zoom-in", [this]() {
emit zoomInBtnClicked(); emit zoomInBtnClicked();
})); }));

View File

@ -14,6 +14,7 @@ public:
signals: signals:
void resetToOriginalBtnClicked(); void resetToOriginalBtnClicked();
void toggleWindowMaximum();
void zoomInBtnClicked(); void zoomInBtnClicked();
void zoomOutBtnClicked(); void zoomOutBtnClicked();
void toggleCheckerboardBtnClicked(); void toggleCheckerboardBtnClicked();

View File

@ -193,6 +193,8 @@ void GraphicsView::resizeEvent(QResizeEvent *event)
} else { } else {
fitInView(sceneRect(), Qt::KeepAspectRatio); fitInView(sceneRect(), Qt::KeepAspectRatio);
} }
} else {
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
} }
return QGraphicsView::resizeEvent(event); return QGraphicsView::resizeEvent(event);
} }

View File

@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent) :
this->setCentralWidget(m_graphicsView); this->setCentralWidget(m_graphicsView);
m_gv = new NavigatorView(this); m_gv = new NavigatorView(this);
m_gv->setFixedSize(250, 160); m_gv->setFixedSize(220, 160);
m_gv->setScene(scene); m_gv->setScene(scene);
m_gv->setMainView(m_graphicsView); m_gv->setMainView(m_graphicsView);
m_gv->fitInView(m_gv->sceneRect(), Qt::KeepAspectRatio); m_gv->fitInView(m_gv->sceneRect(), Qt::KeepAspectRatio);
@ -79,6 +79,14 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_bottomButtonGroup, &BottomButtonGroup::resetToOriginalBtnClicked, connect(m_bottomButtonGroup, &BottomButtonGroup::resetToOriginalBtnClicked,
this, [ = ](){ m_graphicsView->resetScale(); }); this, [ = ](){ m_graphicsView->resetScale(); });
connect(m_bottomButtonGroup, &BottomButtonGroup::toggleWindowMaximum,
this, [ = ](){
if (isMaximized()) {
showNormal();
} else {
showMaximized();
}
});
connect(m_bottomButtonGroup, &BottomButtonGroup::zoomInBtnClicked, connect(m_bottomButtonGroup, &BottomButtonGroup::zoomInBtnClicked,
this, [ = ](){ m_graphicsView->zoomView(1.25); }); this, [ = ](){ m_graphicsView->zoomView(1.25); });
connect(m_bottomButtonGroup, &BottomButtonGroup::zoomOutBtnClicked, connect(m_bottomButtonGroup, &BottomButtonGroup::zoomOutBtnClicked,

View File

@ -11,7 +11,7 @@ NavigatorView::NavigatorView(QWidget *parent)
{ {
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setStyleSheet("background-color: rgba(0, 0, 0, 220);" setStyleSheet("background-color: rgba(0, 0, 0, 120);"
"border-radius: 3px;"); "border-radius: 3px;");
} }
@ -34,6 +34,7 @@ void NavigatorView::mousePressEvent(QMouseEvent *event)
if (m_mainView) { if (m_mainView) {
m_mainView->centerOn(mapToScene(event->pos())); m_mainView->centerOn(mapToScene(event->pos()));
update();
} }
return QGraphicsView::mousePressEvent(event); return QGraphicsView::mousePressEvent(event);
@ -43,6 +44,7 @@ void NavigatorView::mouseMoveEvent(QMouseEvent *event)
{ {
if (m_mouseDown && m_mainView) { if (m_mouseDown && m_mainView) {
m_mainView->centerOn(mapToScene(event->pos())); m_mainView->centerOn(mapToScene(event->pos()));
update();
} }
return QGraphicsView::mouseMoveEvent(event); return QGraphicsView::mouseMoveEvent(event);