summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/componentcore/zoomaction.h
blob: d211a19e7cfc2a454805a160050df356f4bab6c6 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once

#include <qmldesignercomponents_global.h>

#include <QPointer>
#include <QWidgetAction>

#include <array>

QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE

namespace QmlDesigner {

class QMLDESIGNERCOMPONENTS_EXPORT ZoomAction : public QWidgetAction
{
    Q_OBJECT

signals:
    void zoomLevelChanged(double zoom);

public:
    ZoomAction(QObject *parent);

    static std::array<double, 27> zoomLevels();
    static int indexOf(double zoom);

    void setZoomFactor(double zoom);
    double setNextZoomFactor(double zoom);
    double setPreviousZoomFactor(double zoom);

    int currentIndex() const;

protected:
    QWidget *createWidget(QWidget *parent) override;

private:
    void emitZoomLevelChanged(int index);

    static std::array<double, 27> m_zooms;
    QPointer<QComboBox> m_combo;
    int m_index = -1;
};

} // namespace QmlDesigner