qmldesignerplugin.h 3.8 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
hjk's avatar
hjk committed
24
25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29
30
31
32

#ifndef QMLDESIGNERPLUGIN_H
#define QMLDESIGNERPLUGIN_H

33
#include <qmldesigner/designersettings.h>
hjk's avatar
hjk committed
34
#include <qmldesigner/components/pluginmanager/pluginmanager.h>
35
#include <qmldesignercorelib_global.h>
36

37
38
#include <extensionsystem/iplugin.h>

Marco Bubke's avatar
Marco Bubke committed
39
40
41
42
#include "documentmanager.h"
#include "viewmanager.h"
#include "shortcutmanager.h"

Lasse Holmstedt's avatar
Lasse Holmstedt committed
43
44
45
46
47
48
49
#include <QWeakPointer>
#include <QStringList>

QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE

50
namespace Core {
51
    class Context;
52
    class IContext;
53
    class IEditor;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
54
55
    class DesignMode;
    class EditorManager;
56
57
58
59
}

namespace QmlDesigner {

Marco Bubke's avatar
Marco Bubke committed
60
namespace Internal {
Lasse Holmstedt's avatar
Lasse Holmstedt committed
61
62
class DesignModeWidget;
class DesignModeContext;
Marco Bubke's avatar
Marco Bubke committed
63
}
Lasse Holmstedt's avatar
Lasse Holmstedt committed
64

65
class QMLDESIGNERCORE_EXPORT QmlDesignerPlugin : public ExtensionSystem::IPlugin
66
67
{
    Q_OBJECT
68
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlDesigner.json")
69
70

public:
Marco Bubke's avatar
Marco Bubke committed
71
72
    QmlDesignerPlugin();
    virtual ~QmlDesignerPlugin();
73
74

    //Plugin
hjk's avatar
hjk committed
75
    virtual bool initialize(const QStringList &arguments, QString *errorMessage = 0);
76
77
    virtual void extensionsInitialized();

Marco Bubke's avatar
Marco Bubke committed
78
79
80
81
82
83
84
    static QmlDesignerPlugin *instance();

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

    ViewManager &viewManager();
    const ViewManager &viewManager() const;
85

86
    DesignerSettings settings();
87
88
    void setSettings(const DesignerSettings &s);

Marco Bubke's avatar
Marco Bubke committed
89
90
    DesignDocument *currentDesignDocument() const;
    Internal::DesignModeWidget *mainWidget() const;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
91

Marco Bubke's avatar
Marco Bubke committed
92
private slots:
Lasse Holmstedt's avatar
Lasse Holmstedt committed
93
    void switchTextDesign();
Marco Bubke's avatar
Marco Bubke committed
94
95
96
    void onTextEditorsClosed(QList<Core::IEditor *> editors);
    void onCurrentEditorChanged(Core::IEditor *editor);
    void onCurrentModeChanged(Core::IMode *mode, Core::IMode *oldMode);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
97

Marco Bubke's avatar
Marco Bubke committed
98
private: // functions
Lasse Holmstedt's avatar
Lasse Holmstedt committed
99
    void createDesignModeWidget();
Marco Bubke's avatar
Marco Bubke committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    void showDesigner();
    void hideDesigner();
    void changeEditor();
    void jumpTextCursorToSelectedModelNode();
    void selectModelNodeUnderTextCursor();
    void activateAutoSynchronization();
    void deactivateAutoSynchronization();
    void resetModelSelection();

private: // variables
    ViewManager m_viewManager;
    DocumentManager m_documentManager;
    ShortCutManager m_shortCutManager;

    Internal::DesignModeWidget *m_mainWidget;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
115

hjk's avatar
hjk committed
116
    QmlDesigner::PluginManager m_pluginManager;
Marco Bubke's avatar
Marco Bubke committed
117
    static QmlDesignerPlugin *m_instance;
118
    DesignerSettings m_settings;
Marco Bubke's avatar
Marco Bubke committed
119
    Internal::DesignModeContext *m_context;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
120
    bool m_isActive;
121
122
123
124
125
};

} // namespace QmlDesigner

#endif // QMLDESIGNERPLUGIN_H