2010-01-07 12:14:35 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-02-26 11:08:17 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef DESIGNMODE_H
|
|
|
|
|
#define DESIGNMODE_H
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/imode.h>
|
|
|
|
|
#include <coreplugin/icorelistener.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
|
|
|
|
|
#include <QWeakPointer>
|
2010-02-26 11:08:17 +01:00
|
|
|
#include <QPair>
|
|
|
|
|
#include <QStringList>
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-16 15:13:57 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
2010-01-07 12:14:35 +01:00
|
|
|
class QAction;
|
2010-02-26 11:08:17 +01:00
|
|
|
class QStackedWidget;
|
2010-02-16 15:13:57 +01:00
|
|
|
QT_END_NAMESPACE
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
namespace Core {
|
|
|
|
|
class EditorManager;
|
2010-01-07 12:14:35 +01:00
|
|
|
class DesignMode;
|
2010-02-26 11:08:17 +01:00
|
|
|
|
|
|
|
|
namespace Internal {
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
class DesignModeCoreListener : public Core::ICoreListener
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
DesignModeCoreListener(DesignMode* mode);
|
|
|
|
|
bool coreAboutToClose();
|
|
|
|
|
private:
|
|
|
|
|
DesignMode *m_mode;
|
|
|
|
|
};
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A global mode for Design pane - used by Bauhaus (QML Designer) and
|
|
|
|
|
* Qt Designer. Other plugins can register themselves by registerDesignWidget()
|
|
|
|
|
* and giving a list of mimetypes that the editor understands, as well as an instance
|
|
|
|
|
* to the main editor widget itself.
|
|
|
|
|
*/
|
|
|
|
|
class CORE_EXPORT DesignMode : public Core::IMode
|
2010-01-07 12:14:35 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-02-26 11:08:17 +01:00
|
|
|
DesignMode(EditorManager *editorManager);
|
2010-01-07 12:14:35 +01:00
|
|
|
~DesignMode();
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
void registerDesignWidget(QWidget *widget, const QStringList &mimeTypes,
|
|
|
|
|
bool preferDesignMode = false);
|
|
|
|
|
void unregisterDesignWidget(QWidget *widget);
|
2010-03-16 16:51:45 +01:00
|
|
|
|
|
|
|
|
QStringList registeredMimeTypes() const;
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
// IContext
|
|
|
|
|
QList<int> context() const;
|
|
|
|
|
QWidget *widget();
|
|
|
|
|
|
|
|
|
|
// IMode
|
2010-01-07 18:58:43 +01:00
|
|
|
QString displayName() const;
|
2010-01-07 12:14:35 +01:00
|
|
|
QIcon icon() const;
|
|
|
|
|
int priority() const;
|
2010-01-07 18:58:43 +01:00
|
|
|
QString id() const;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
signals:
|
|
|
|
|
void actionsUpdated(Core::IEditor *editor);
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
private slots:
|
|
|
|
|
void currentEditorChanged(Core::IEditor *editor);
|
|
|
|
|
void updateActions();
|
|
|
|
|
|
|
|
|
|
private:
|
2010-02-26 11:08:17 +01:00
|
|
|
Internal::DesignModeCoreListener *m_coreListener;
|
2010-01-07 12:14:35 +01:00
|
|
|
QWeakPointer<Core::IEditor> m_currentEditor;
|
|
|
|
|
bool m_isActive;
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
struct DesignEditorInfo {
|
|
|
|
|
int widgetIndex;
|
|
|
|
|
QStringList mimeTypes;
|
|
|
|
|
bool preferredMode;
|
|
|
|
|
QWidget *widget;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QList<DesignEditorInfo*> m_editors;
|
|
|
|
|
|
|
|
|
|
EditorManager *m_editorManager;
|
|
|
|
|
QStackedWidget *m_stackWidget;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
friend class Internal::DesignModeCoreListener;
|
2010-01-07 12:14:35 +01:00
|
|
|
};
|
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
|
|
|
|
|
} // namespace Core
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
#endif // DESIGNMODE_H
|