- change UI layout to make it looks like the default style of Windows image browser. - update icons to material design icon for better looks. add lost icons for those new added button at the bottom bar. - restore window style to normal. remove borderless style. - delete X button at the right-top corner. disable feature that drag window to move, because all functions provided by native window are restored. - move prev next image button to the center of bottom bar. - move navigator view to the right-bottom corner so that it will not overlay on the shown image. - remove all animation effect, including alpha transition, fade out when exiting and etc. - delete function that double click windows to exit. now double clicking windows will do nothing. change default value of double click behavior to do nothing. - change default value of stay on top to false because stay on top is not the default behavior of Windows image browser.
87 lines
2.0 KiB
C++
87 lines
2.0 KiB
C++
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include "navigatorview.h"
|
|
|
|
#include "graphicsview.h"
|
|
#include "opacityhelper.h"
|
|
|
|
#include <QMouseEvent>
|
|
#include <QDebug>
|
|
|
|
NavigatorView::NavigatorView(QWidget *parent)
|
|
: QGraphicsView (parent)
|
|
, m_viewportRegion(this->rect())
|
|
, m_opacityHelper(new OpacityHelper(this))
|
|
{
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setStyleSheet("background-color: rgba(0, 0, 0, 120);"
|
|
"border-style: none;");
|
|
}
|
|
|
|
// doesn't take or manage its ownership
|
|
void NavigatorView::setMainView(GraphicsView *mainView)
|
|
{
|
|
m_mainView = mainView;
|
|
}
|
|
|
|
void NavigatorView::setOpacity(qreal opacity, bool animated)
|
|
{
|
|
m_opacityHelper->setOpacity(opacity, animated);
|
|
}
|
|
|
|
void NavigatorView::updateMainViewportRegion()
|
|
{
|
|
if (m_mainView != nullptr) {
|
|
m_viewportRegion = mapFromScene(m_mainView->mapToScene(m_mainView->rect()));
|
|
update();
|
|
}
|
|
}
|
|
|
|
void NavigatorView::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
m_mouseDown = true;
|
|
|
|
if (m_mainView) {
|
|
m_mainView->centerOn(mapToScene(event->pos()));
|
|
update();
|
|
}
|
|
|
|
event->accept();
|
|
}
|
|
|
|
void NavigatorView::mouseMoveEvent(QMouseEvent *event)
|
|
{
|
|
if (m_mouseDown && m_mainView) {
|
|
m_mainView->centerOn(mapToScene(event->pos()));
|
|
update();
|
|
event->accept();
|
|
} else {
|
|
event->ignore();
|
|
}
|
|
}
|
|
|
|
void NavigatorView::mouseReleaseEvent(QMouseEvent *event)
|
|
{
|
|
m_mouseDown = false;
|
|
|
|
event->accept();
|
|
}
|
|
|
|
void NavigatorView::wheelEvent(QWheelEvent *event)
|
|
{
|
|
event->ignore();
|
|
return QGraphicsView::wheelEvent(event);
|
|
}
|
|
|
|
void NavigatorView::paintEvent(QPaintEvent *event)
|
|
{
|
|
QGraphicsView::paintEvent(event);
|
|
|
|
QPainter painter(viewport());
|
|
painter.setPen(QPen(Qt::gray, 2));
|
|
painter.drawRect(m_viewportRegion.boundingRect());
|
|
}
|