qmldesignerplugin.h 3.09 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
12 13 14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16 17
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
18 19 20 21 22
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
con's avatar
con committed
23
**
hjk's avatar
hjk committed
24
****************************************************************************/
25

hjk's avatar
hjk committed
26
#pragma once
27

28
#include <qmldesigner/designersettings.h>
29
#include <qmldesignercorelib_global.h>
30

31 32
#include <extensionsystem/iplugin.h>

Marco Bubke's avatar
Marco Bubke committed
33 34 35
#include "documentmanager.h"
#include "viewmanager.h"
#include "shortcutmanager.h"
36
#include <designeractionmanager.h>
Marco Bubke's avatar
Marco Bubke committed
37

Lasse Holmstedt's avatar
Lasse Holmstedt committed
38 39 40 41 42 43
#include <QStringList>

QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE

44 45 46 47 48 49
namespace Core {
    class IEditor;
}

namespace QmlDesigner {

50
class QmlDesignerPluginPrivate;
51

52
namespace Internal { class DesignModeWidget; }
Lasse Holmstedt's avatar
Lasse Holmstedt committed
53

54
class QMLDESIGNERCORE_EXPORT QmlDesignerPlugin : public ExtensionSystem::IPlugin
55 56
{
    Q_OBJECT
57
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlDesigner.json")
58 59

public:
Marco Bubke's avatar
Marco Bubke committed
60 61
    QmlDesignerPlugin();
    virtual ~QmlDesignerPlugin();
62 63

    //Plugin
Tim Jenssen's avatar
Tim Jenssen committed
64 65
    bool initialize(const QStringList &arguments, QString *errorMessage = 0) override;
    void extensionsInitialized() override;
66

Marco Bubke's avatar
Marco Bubke committed
67 68 69 70 71 72 73
    static QmlDesignerPlugin *instance();

    DocumentManager &documentManager();
    const DocumentManager &documentManager() const;

    ViewManager &viewManager();
    const ViewManager &viewManager() const;
74

75 76 77
    DesignerActionManager &designerActionManager();
    const DesignerActionManager &designerActionManager() const;

78
    DesignerSettings settings();
79 80
    void setSettings(const DesignerSettings &s);

Marco Bubke's avatar
Marco Bubke committed
81 82
    DesignDocument *currentDesignDocument() const;
    Internal::DesignModeWidget *mainWidget() const;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
83

84 85
    void switchToTextModeDeferred();

Marco Bubke's avatar
Marco Bubke committed
86
private: // functions
Lasse Holmstedt's avatar
Lasse Holmstedt committed
87
    void createDesignModeWidget();
Marco Bubke's avatar
Marco Bubke committed
88 89 90 91 92 93 94 95
    void showDesigner();
    void hideDesigner();
    void changeEditor();
    void jumpTextCursorToSelectedModelNode();
    void selectModelNodeUnderTextCursor();
    void activateAutoSynchronization();
    void deactivateAutoSynchronization();
    void resetModelSelection();
96
    RewriterView *rewriterView() const;
97
    Model *currentModel() const;
Marco Bubke's avatar
Marco Bubke committed
98 99

private: // variables
100
    QmlDesignerPluginPrivate *d = nullptr;
Marco Bubke's avatar
Marco Bubke committed
101
    static QmlDesignerPlugin *m_instance;
102

103 104 105
};

} // namespace QmlDesigner