Allow scrolling hand dragging for non interactive scenes.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-07-21 12:27:58 +03:00
parent 9f6bb49a22
commit 185e228853
4 changed files with 25 additions and 3 deletions

View file

@ -1116,7 +1116,8 @@ QList<QGraphicsScene *> MainWindowsNoGUI::CreateScenes(const QList<QGraphicsItem
QList<QGraphicsScene *> scenes;
for (int i=0; i<papers.size(); ++i)
{
QGraphicsScene *scene = new VMainGraphicsScene();
auto *scene = new VMainGraphicsScene();
scene->SetNonInteractive(true);
scene->setBackgroundBrush(QBrush(QColor(Qt::gray), Qt::SolidPattern));
scene->addItem(shadows.at(i));
scene->addItem(papers.at(i));

View file

@ -113,6 +113,18 @@ void VMainGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsScene::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
bool VMainGraphicsScene::IsNonInteractive() const
{
return m_nonInteractive;
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::SetNonInteractive(bool nonInteractive)
{
m_nonInteractive = nonInteractive;
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::InitOrigins()
{

View file

@ -63,6 +63,10 @@ public:
QRectF VisibleItemsBoundingRect() const;
void InitOrigins();
void SetOriginsVisible(bool visible);
bool IsNonInteractive() const;
void SetNonInteractive(bool nonInteractive);
public slots:
void ChoosedItem(quint32 id, const SceneObject &type);
void SelectedItem(bool selected, quint32 object, quint32 tool);
@ -145,6 +149,7 @@ signals:
void LanguageChanged();
private:
Q_DISABLE_COPY(VMainGraphicsScene)
/** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar;
@ -155,6 +160,9 @@ private:
QTransform _transform;
QPointF scenePos;
QVector<QGraphicsItem *> origins;
/** @brief m_nonInteractive all item on scene in non interactive. */
bool m_nonInteractive{false};
};
//---------------------------------------------------------------------------------------------------------------------

View file

@ -568,9 +568,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
}
case Qt::MiddleButton:
{
auto scene = qobject_cast<VMainGraphicsScene*>(this->scene());
const QList<QGraphicsItem *> list = items(event->pos());
if (list.size() == 0)
{// Only when the user clicks on the scene background
if (list.isEmpty() || (scene && scene->IsNonInteractive()))
{// Only when the user clicks on the scene background or non interactive scene
m_ptStartPos = event->pos();
m_oldCursor = viewport()->cursor();
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);