aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scxmleditor/common/magnifier.h
blob: c001c55514eb4861baef6a1fbc690cf194abbee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include <QGraphicsView>
#include <QPointer>

#include "ui_magnifier.h"

QT_FORWARD_DECLARE_CLASS(QMouseEvent)

namespace ScxmlEditor {

namespace PluginInterface { class GraphicsScene; }

namespace Common {

class GraphicsView;

class Magnifier : public QWidget
{
    Q_OBJECT

public:
    Magnifier(QWidget *parent = nullptr);

    void setCurrentView(GraphicsView *mainView);
    void setCurrentScene(PluginInterface::GraphicsScene *scene);
    void setTopLeft(const QPoint &topLeft);

signals:
    void clicked(double zoomLevel);

protected:
    void resizeEvent(QResizeEvent *e) override;
    void paintEvent(QPaintEvent *e) override;
    void showEvent(QShowEvent *e) override;
    void hideEvent(QHideEvent *e) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void moveEvent(QMoveEvent *e) override;
    void wheelEvent(QWheelEvent *e) override;

private:
    QPoint m_topLeft;
    QPointer<GraphicsView> m_mainView;
    QRadialGradient m_gradientBrush;
    Ui::Magnifier m_ui;
};

} // namespace Common
} // namespace ScxmlEditor