QtDesigner integration has been added

QtDesigner intergration has been added
This commit is contained in:
Arin Alexander 2017-04-07 21:01:51 +03:00
parent 0505801e3a
commit cd2e748a9b
25 changed files with 1662 additions and 37 deletions

View File

@ -1,6 +1,8 @@
CONFIG += build_translations
CONFIG += zint
CONFIG += qjsengine
CONFIG += dialogdesigner
greaterThan(QT_MAJOR_VERSION, 4) {
QT += uitools
}

View File

@ -0,0 +1,109 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** 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 General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include "shared_global_p.h"
#include <QtCore/QMap>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class QDesignerFormEditorInterface;
class QDesignerCustomWidgetInterface;
class QDesignerPluginManagerPrivate;
class QDESIGNER_SHARED_EXPORT QDesignerPluginManager: public QObject
{
Q_OBJECT
public:
explicit QDesignerPluginManager(QDesignerFormEditorInterface *core);
virtual ~QDesignerPluginManager();
QDesignerFormEditorInterface *core() const;
QObject *instance(const QString &plugin) const;
QStringList registeredPlugins() const;
QStringList findPlugins(const QString &path);
QStringList pluginPaths() const;
void setPluginPaths(const QStringList &plugin_paths);
QStringList disabledPlugins() const;
void setDisabledPlugins(const QStringList &disabled_plugins);
QStringList failedPlugins() const;
QString failureReason(const QString &pluginName) const;
QList<QObject*> instances() const;
QList<QDesignerCustomWidgetInterface*> registeredCustomWidgets() const;
bool registerNewPlugins();
public slots:
bool syncSettings();
void ensureInitialized();
private:
void updateRegisteredPlugins();
void registerPath(const QString &path);
void registerPlugin(const QString &plugin);
private:
static QStringList defaultPluginPaths();
QDesignerPluginManagerPrivate *m_d;
};
QT_END_NAMESPACE
#endif // PLUGINMANAGER_H

View File

@ -0,0 +1,126 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** 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 General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef QDESIGNER_INTEGRATION_H
#define QDESIGNER_INTEGRATION_H
#include "shared_global_p.h"
#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerResourceBrowserInterface;
class QVariant;
class QWidget;
namespace qdesigner_internal {
struct Selection;
class QDesignerIntegrationPrivate;
class QDESIGNER_SHARED_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
{
Q_OBJECT
public:
explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0);
virtual ~QDesignerIntegration();
static void requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document);
virtual QWidget *containerWindow(QWidget *widget) const;
// Load plugins into widget database and factory.
static void initializePlugins(QDesignerFormEditorInterface *formEditor);
void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
// Create a resource browser specific to integration. Language integration takes precedence
virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0);
signals:
void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
void helpRequested(const QString &manual, const QString &document);
public slots:
virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
// Additional signals of designer property editor
virtual void updatePropertyComment(const QString &name, const QString &value);
virtual void resetProperty(const QString &name);
virtual void addDynamicProperty(const QString &name, const QVariant &value);
virtual void removeDynamicProperty(const QString &name);
virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow);
virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow);
virtual void updateSelection();
virtual void updateGeometry();
virtual void activateWidget(QWidget *widget);
void updateCustomWidgetPlugins();
private slots:
void updatePropertyPrivate(const QString &name, const QVariant &value);
private:
void initialize();
void getSelection(Selection &s);
QObject *propertyEditorObject();
QDesignerIntegrationPrivate *m_d;
};
} // namespace qdesigner_internal
QT_END_NAMESPACE
#endif // QDESIGNER_INTEGRATION_H

View File

@ -0,0 +1,72 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** 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 General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef SHARED_GLOBAL_H
#define SHARED_GLOBAL_H
#include <QtCore/qglobal.h>
#ifdef QT_DESIGNER_STATIC
#define QDESIGNER_SHARED_EXTERN
#define QDESIGNER_SHARED_IMPORT
#else
#define QDESIGNER_SHARED_EXTERN Q_DECL_EXPORT
#define QDESIGNER_SHARED_IMPORT Q_DECL_IMPORT
#endif
#ifndef QT_NO_SHARED_EXPORT
# ifdef QDESIGNER_SHARED_LIBRARY
# define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_EXTERN
# else
# define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_IMPORT
# endif
#else
# define QDESIGNER_SHARED_EXPORT
#endif
#endif // SHARED_GLOBAL_H

View File

@ -0,0 +1,10 @@
This is a new Designer integration, started on 28.02.2008.
The reason for it is the introduction of layout caching
in Qt 4.4, which unearthed a lot of mainwindow-size related
bugs in Designer and all integrations.
The goal of it is to have a closed layout chain from
integration top level to form window.
Friedemann

View File

@ -0,0 +1,11 @@
INCLUDEPATH *= $$PWD $$PWD/..
SOURCES += $$PWD/widgethost.cpp \
$$PWD/sizehandlerect.cpp \
$$PWD/formresizer.cpp
HEADERS += $$PWD/widgethost.h \
$$PWD/sizehandlerect.h \
$$PWD/formresizer.h \
$$PWD/widgethostconstants.h \
$$PWD/../namespace_global.h

View File

@ -0,0 +1,198 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#include "formresizer.h"
#include "sizehandlerect.h"
#include "widgethostconstants.h"
#include <QDebug>
#include <QDesignerFormWindowInterface>
#include <QResizeEvent>
#include <QPalette>
#include <QLayout>
#include <QFrame>
#include <QResizeEvent>
enum { debugFormResizer = 0 };
using namespace SharedTools::Internal;
FormResizer::FormResizer(QWidget *parent) :
QWidget(parent),
m_frame(new QFrame),
m_formWindow(0)
{
// Make the resize grip of a mainwindow form find us as resizable window.
setWindowFlags(windowFlags() | Qt::SubWindow);
setBackgroundRole(QPalette::Base);
QVBoxLayout *handleLayout = new QVBoxLayout(this);
handleLayout->setMargin(SELECTION_MARGIN);
handleLayout->addWidget(m_frame);
m_frame->setFrameStyle(QFrame::Panel | QFrame::Raised);
QVBoxLayout *layout = new QVBoxLayout(m_frame);
layout->setMargin(0);
// handles
m_handles.reserve(SizeHandleRect::Left);
for (int i = SizeHandleRect::LeftTop; i <= SizeHandleRect::Left; ++i) {
SizeHandleRect *shr = new SizeHandleRect(this, static_cast<SizeHandleRect::Direction>(i), this);
connect(shr, SIGNAL(mouseButtonReleased(QRect,QRect)), this, SIGNAL(formWindowSizeChanged(QRect,QRect)));
m_handles.push_back(shr);
}
setState(SelectionHandleActive);
updateGeometry();
}
void FormResizer::updateGeometry()
{
const QRect &geom = m_frame->geometry();
if (debugFormResizer)
qDebug() << "FormResizer::updateGeometry() " << size() << " frame " << geom;
const int w = SELECTION_HANDLE_SIZE;
const int h = SELECTION_HANDLE_SIZE;
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it) {
SizeHandleRect *hndl = *it;;
switch (hndl->dir()) {
case SizeHandleRect::LeftTop:
hndl->move(geom.x() - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::Top:
hndl->move(geom.x() + geom.width() / 2 - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::RightTop:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::Right:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() + geom.height() / 2 - h / 2);
break;
case SizeHandleRect::RightBottom:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::Bottom:
hndl->move(geom.x() + geom.width() / 2 - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::LeftBottom:
hndl->move(geom.x() - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::Left:
hndl->move(geom.x() - w / 2, geom.y() + geom.height() / 2 - h / 2);
break;
default:
break;
}
}
}
void FormResizer::update()
{
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it) {
(*it)->update();
}
}
void FormResizer::setState(SelectionHandleState st)
{
if (debugFormResizer)
qDebug() << "FormResizer::setState " << st;
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it)
(*it)->setState(st);
}
void FormResizer::setFormWindow(QDesignerFormWindowInterface *fw)
{
if (debugFormResizer)
qDebug() << "FormResizer::setFormWindow " << fw;
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_frame->layout());
Q_ASSERT(layout);
if (layout->count())
delete layout->takeAt(0);
m_formWindow = fw;
if (m_formWindow)
layout->addWidget(m_formWindow);
mainContainerChanged();
connect(fw, SIGNAL(mainContainerChanged(QWidget*)), this, SLOT(mainContainerChanged()));
}
void FormResizer::resizeEvent(QResizeEvent *event)
{
if (debugFormResizer)
qDebug() << ">FormResizer::resizeEvent" << event->size();
updateGeometry();
QWidget::resizeEvent(event);
if (debugFormResizer)
qDebug() << "<FormResizer::resizeEvent";
}
QSize FormResizer::decorationSize() const
{
const int lineWidth = m_frame->lineWidth();
const QMargins frameMargins = m_frame->contentsMargins();
const int margin = 2* SELECTION_MARGIN;
QSize size = QSize( margin, margin );
size += QSize( qMax( frameMargins.left(), lineWidth ), qMax( frameMargins.top(), lineWidth ) );
size += QSize( qMax( frameMargins.right(), lineWidth ), qMax( frameMargins.bottom(), lineWidth ) );
return size;
}
QWidget *FormResizer::mainContainer()
{
if (m_formWindow)
return m_formWindow->mainContainer();
return 0;
}
void FormResizer::mainContainerChanged()
{
const QSize maxWidgetSize = QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
if (const QWidget *mc = mainContainer()) {
// Set Maximum size which is not handled via a hint (as opposed to minimum size)
const QSize maxWidgetSize = QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
const QSize formMaxSize = mc->maximumSize();
QSize newMaxSize = maxWidgetSize;
if (formMaxSize != maxWidgetSize)
newMaxSize = formMaxSize + decorationSize();
if (debugFormResizer)
qDebug() << "FormResizer::mainContainerChanged" << mc << " Size " << mc->size()<< newMaxSize;
setMaximumSize(newMaxSize);
resize(decorationSize() + mc->size());
} else {
setMaximumSize(maxWidgetSize);
}
}

View File

@ -0,0 +1,99 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef FORMRESIZER_H
#define FORMRESIZER_H
#include "namespace_global.h"
#include "widgethostconstants.h"
#include <QWidget>
#include <QVector>
QT_FORWARD_DECLARE_CLASS(QDesignerFormWindowInterface)
QT_FORWARD_DECLARE_CLASS(QFrame)
namespace SharedTools {
namespace Internal {
class SizeHandleRect;
/* A window to embed a form window interface as follows:
*
* Widget
* |
* +---+----+
* | |
* | |
* Handles QVBoxLayout [margin: SELECTION_MARGIN]
* |
* Frame [margin: lineWidth]
* |
* QVBoxLayout
* |
* QDesignerFormWindowInterface
*
* Can be embedded into a QScrollArea. */
class FormResizer : public QWidget
{
Q_OBJECT
public:
FormResizer(QWidget *parent = 0);
void updateGeometry();
void setState(SelectionHandleState st);
void update();
void setFormWindow(QDesignerFormWindowInterface *fw);
signals:
void formWindowSizeChanged(const QRect &oldGeo, const QRect &newGeo);
protected:
virtual void resizeEvent(QResizeEvent *event);
private slots:
void mainContainerChanged();
private:
QSize decorationSize() const;
QWidget *mainContainer();
QFrame *m_frame;
typedef QVector<SizeHandleRect*> Handles;
Handles m_handles;
QDesignerFormWindowInterface * m_formWindow;
};
}
} // namespace SharedTools
#endif // FORMRESIZER_H

View File

@ -0,0 +1,188 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#include "sizehandlerect.h"
#include "widgethostconstants.h"
#include <QDesignerFormWindowInterface>
#include <QMouseEvent>
#include <QPainter>
#include <QFrame>
#include <QDebug>
enum { debugSizeHandle = 0 };
using namespace SharedTools::Internal;
SizeHandleRect::SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable) :
QWidget(parent),
m_dir(d),
m_resizable(resizable),
m_state(SelectionHandleOff)
{
setBackgroundRole(QPalette::Text);
setAutoFillBackground(true);
setFixedSize(SELECTION_HANDLE_SIZE, SELECTION_HANDLE_SIZE);
setMouseTracking(false);
updateCursor();
}
void SizeHandleRect::updateCursor()
{
switch (m_dir) {
case Right:
case RightTop:
setCursor(Qt::SizeHorCursor);
return;
case RightBottom:
setCursor(Qt::SizeFDiagCursor);
return;
case LeftBottom:
case Bottom:
setCursor(Qt::SizeVerCursor);
return;
default:
break;
}
setCursor(Qt::ArrowCursor);
}
void SizeHandleRect::paintEvent(QPaintEvent *)
{
switch (m_state) {
case SelectionHandleOff:
break;
case SelectionHandleInactive: {
QPainter p(this);
p.setPen(Qt::red);
p.drawRect(0, 0, width() - 1, height() - 1);
}
break;
case SelectionHandleActive: {
QPainter p(this);
p.setPen(Qt::blue);
p.drawRect(0, 0, width() - 1, height() - 1);
}
break;
}
}
void SizeHandleRect::mousePressEvent(QMouseEvent *e)
{
e->accept();
if (e->button() != Qt::LeftButton)
return;
m_startSize = m_curSize = m_resizable->size();
m_startPos = m_curPos = m_resizable->mapFromGlobal(e->globalPos());
if (debugSizeHandle)
qDebug() << "SizeHandleRect::mousePressEvent" << m_startSize << m_startPos << m_curPos;
}
void SizeHandleRect::mouseMoveEvent(QMouseEvent *e)
{
if (!(e->buttons() & Qt::LeftButton))
return;
// Try resize with delta against start position.
// We don't take little deltas in consecutive move events as this
// causes the handle and the mouse cursor to become out of sync
// once a min/maxSize limit is hit. When the cursor reenters the valid
// areas, it will now snap to it.
m_curPos = m_resizable->mapFromGlobal(e->globalPos());
QSize delta = QSize(m_curPos.x() - m_startPos.x(), m_curPos.y() - m_startPos.y());
switch (m_dir) {
case Right:
case RightTop: // Only width
delta.setHeight(0);
break;
case RightBottom: // All dimensions
break;
case LeftBottom:
case Bottom: // Only height
delta.setWidth(0);
break;
default:
delta = QSize(0, 0);
break;
}
if (delta != QSize(0, 0))
tryResize(delta);
}
void SizeHandleRect::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() != Qt::LeftButton)
return;
e->accept();
if (m_startSize != m_curSize) {
const QRect startRect = QRect(0, 0, m_startPos.x(), m_startPos.y());
const QRect newRect = QRect(0, 0, m_curPos.x(), m_curPos.y());
if (debugSizeHandle)
qDebug() << "SizeHandleRect::mouseReleaseEvent" << startRect << newRect;
emit mouseButtonReleased(startRect, newRect);
}
}
void SizeHandleRect::tryResize(const QSize &delta)
{
// Try resize with delta against start position
QSize newSize = m_startSize + delta;
newSize = newSize.expandedTo(m_resizable->minimumSizeHint());
newSize = newSize.expandedTo(m_resizable->minimumSize());
newSize = newSize.boundedTo(m_resizable->maximumSize());
if (newSize == m_resizable->size())
return;
if (debugSizeHandle)
qDebug() << "SizeHandleRect::tryResize by (" << m_startSize << '+' << delta << ')' << newSize;
m_resizable->resize(newSize);
m_curSize = m_resizable->size();
}
void SizeHandleRect::setState(SelectionHandleState st)
{
if (st == m_state)
return;
switch (st) {
case SelectionHandleOff:
hide();
break;
case SelectionHandleInactive:
case SelectionHandleActive:
show();
raise();
break;
}
m_state = st;
}

View File

@ -0,0 +1,82 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef SIZEHANDLERECT_H
#define SIZEHANDLERECT_H
#include "namespace_global.h"
#include "widgethostconstants.h"
#include <QWidget>
#include <QPoint>
namespace SharedTools {
namespace Internal {
class SizeHandleRect : public QWidget
{
Q_OBJECT
public:
enum Direction { LeftTop, Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left };
SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable);
Direction dir() const { return m_dir; }
void updateCursor();
void setState(SelectionHandleState st);
signals:
void mouseButtonReleased(const QRect &, const QRect &);
protected:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
private:
void tryResize(const QSize &delta);
private:
const Direction m_dir;
QPoint m_startPos;
QPoint m_curPos;
QSize m_startSize;
QSize m_curSize;
QWidget *m_resizable;
SelectionHandleState m_state;
};
}
} // namespace SharedTools
#endif // SIZEHANDLERECT_H

View File

@ -0,0 +1,111 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#include "widgethost.h"
#include "formresizer.h"
#include "widgethostconstants.h"
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowCursorInterface>
#include <QPalette>
#include <QLayout>
#include <QFrame>
#include <QResizeEvent>
#include <QDebug>
using namespace SharedTools;
// ---------- WidgetHost
WidgetHost::WidgetHost(QWidget *parent, QDesignerFormWindowInterface *formWindow) :
QScrollArea(parent),
m_formWindow(0),
m_formResizer(new Internal::FormResizer)
{
setWidget(m_formResizer);
// Re-set flag (gets cleared by QScrollArea): Make the resize grip of a mainwindow form find the resizer as resizable window.
m_formResizer->setWindowFlags(m_formResizer->windowFlags() | Qt::SubWindow);
setFormWindow(formWindow);
}
WidgetHost::~WidgetHost()
{
if (m_formWindow)
delete m_formWindow;
}
void WidgetHost::setFormWindow(QDesignerFormWindowInterface *fw)
{
m_formWindow = fw;
if (!fw)
return;
m_formResizer->setFormWindow(fw);
setBackgroundRole(QPalette::Base);
m_formWindow->setAutoFillBackground(true);
m_formWindow->setBackgroundRole(QPalette::Background);
connect(m_formResizer, SIGNAL(formWindowSizeChanged(QRect, QRect)),
this, SLOT(fwSizeWasChanged(QRect, QRect)));
connect(m_formWindow, SIGNAL(destroyed(QObject*)), this, SLOT(formWindowDeleted(QObject*)));
}
QSize WidgetHost::formWindowSize() const
{
if (!m_formWindow || !m_formWindow->mainContainer())
return QSize();
return m_formWindow->mainContainer()->size();
}
void WidgetHost::fwSizeWasChanged(const QRect &, const QRect &)
{
// newGeo is the mouse coordinates, thus moving the Right will actually emit wrong height
emit formWindowSizeChanged(formWindowSize().width(), formWindowSize().height());
}
void WidgetHost::formWindowDeleted(QObject *object)
{
if (object == m_formWindow) m_formWindow = 0;
}
void WidgetHost::updateFormWindowSelectionHandles(bool active)
{
Internal::SelectionHandleState state = Internal::SelectionHandleOff;
const QDesignerFormWindowCursorInterface *cursor = m_formWindow->cursor();
if (cursor->isWidgetSelected(m_formWindow->mainContainer()))
state = active ? Internal::SelectionHandleActive : Internal::SelectionHandleInactive;
m_formResizer->setState(state);
}
QWidget *WidgetHost::integrationContainer() const
{
return m_formResizer;
}

View File

@ -0,0 +1,80 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef WIDGETHOST_H
#define WIDGETHOST_H
#include "namespace_global.h"
#include <QScrollArea>
QT_FORWARD_DECLARE_CLASS(QDesignerFormWindowInterface)
namespace SharedTools {
namespace Internal {
class FormResizer;
}
/* A scroll area that embeds a Designer form window */
class WidgetHost : public QScrollArea
{
Q_OBJECT
public:
WidgetHost(QWidget *parent = 0, QDesignerFormWindowInterface *formWindow = 0);
virtual ~WidgetHost();
// Show handles if active and main container is selected.
void updateFormWindowSelectionHandles(bool active);
inline QDesignerFormWindowInterface *formWindow() const { return m_formWindow; }
QWidget *integrationContainer() const;
protected:
void setFormWindow(QDesignerFormWindowInterface *fw);
signals:
void formWindowSizeChanged(int, int);
private slots:
void fwSizeWasChanged(const QRect &, const QRect &);
void formWindowDeleted(QObject* object);
private:
QSize formWindowSize() const;
QDesignerFormWindowInterface *m_formWindow;
Internal::FormResizer *m_formResizer;
QSize m_oldFakeWidgetSize;
};
} // namespace SharedTools
#endif // WIDGETHOST_H

View File

@ -0,0 +1,41 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef WIDGETHOST_CONSTANTS_H
#define WIDGETHOST_CONSTANTS_H
namespace SharedTools {
namespace Internal {
enum { SELECTION_HANDLE_SIZE = 6, SELECTION_MARGIN = 10 };
enum SelectionHandleState { SelectionHandleOff, SelectionHandleInactive, SelectionHandleActive };
}
}
#endif // WIDGETHOST_CONSTANTS_H

View File

@ -0,0 +1,48 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (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 qt-sales@nokia.com.
**
**************************************************************************/
#ifndef NAMESPACE_GLOBAL_H
#define NAMESPACE_GLOBAL_H
#include <QtCore/qglobal.h>
#if QT_VERSION < 0x040400
# define QT_ADD_NAMESPACE(name) ::name
# define QT_USE_NAMESPACE
# define QT_BEGIN_NAMESPACE
# define QT_END_NAMESPACE
# define QT_BEGIN_INCLUDE_NAMESPACE
# define QT_END_INCLUDE_NAMESPACE
# define QT_BEGIN_MOC_NAMESPACE
# define QT_END_MOC_NAMESPACE
# define QT_FORWARD_DECLARE_CLASS(name) class name;
# define QT_MANGLE_NAMESPACE(name) name
#endif
#endif // NAMESPACE_GLOBAL_H

View File

@ -0,0 +1,17 @@
include(../../common.pri)
include($$PWD/3rdparty/qtcreator/designerintegrationv2/designerintegration.pri)
INCLUDEPATH *= $$PWD/3rdparty/designer
greaterThan(QT_MAJOR_VERSION, 4) {
contains(QT,uitools){
DEFINES += HAVE_QTDESIGNER_INTEGRATION
}
}
lessThan(QT_MAJOR_VERSION, 5){
contains(CONFIG,uitools){
DEFINES += HAVE_QTDESIGNER_INTEGRATION
}
}
QT += designer designercomponents-private
SOURCES += $$PWD/lrdialogdesigner.cpp
HEADERS += $$PWD/lrdialogdesigner.h

View File

@ -0,0 +1,171 @@
#include "lrdialogdesigner.h"
#include <QPluginLoader>
#include <QDesignerComponents>
#include <QDesignerIntegration>
#include <abstractobjectinspector.h>
#include <QDesignerFormEditorInterface>
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowManagerInterface>
#include <QDesignerFormEditorPluginInterface>
#include <QDesignerWidgetBoxInterface>
#include <QDesignerActionEditorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QDesignerObjectInspectorInterface>
#include <QDesignerFormEditorInterface>
#include "pluginmanager_p.h"
//#include <QExtensionManager>
#include "widgethost.h"
namespace LimeReport{
DialogDesigner::DialogDesigner(QObject *parent) : QObject(parent)
{
QDesignerComponents::initializeResources();
m_formEditor = QDesignerComponents::createFormEditor(this);
QDesignerComponents::initializePlugins(m_formEditor);
QDesignerComponents::createTaskMenu(m_formEditor, this);
foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() )
{
if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) )
{
// initialize plugin if needed
if ( !fep->isInitialized() )
fep->initialize( m_formEditor );
// set action chackable
// fep->action()->setCheckable( true );
// // add action mode to group
// aModes->addAction( fep->action() );
}
}
m_widgetBox = QDesignerComponents::createWidgetBox(m_formEditor, 0);
m_widgetBox->setWindowTitle(tr("Widget Box"));
m_widgetBox->setObjectName(QLatin1String("WidgetBox"));
m_formEditor->setWidgetBox(m_widgetBox);
m_formEditor->setTopLevel(m_widgetBox);
m_designerToolWindows.append(m_widgetBox);
connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0);
m_objectInspector->setWindowTitle(tr("Object Inspector"));
m_objectInspector->setObjectName(QLatin1String("ObjectInspector"));
m_formEditor->setObjectInspector(m_objectInspector);
m_designerToolWindows.append(m_objectInspector);
connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0);
m_propertyEditor->setWindowTitle(tr("Property Editor"));
m_propertyEditor->setObjectName(QLatin1String("PropertyEditor"));
m_formEditor->setPropertyEditor(m_propertyEditor);
m_designerToolWindows.append(m_propertyEditor);
connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0);
m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor"));
m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor"));
m_designerToolWindows.append(m_signalSlotEditor);
connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0);
m_resourcesEditor->setWindowTitle(tr("Resource Editor"));
m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor"));
m_designerToolWindows.append(m_resourcesEditor);
connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0);
m_actionEditor->setWindowTitle(tr("Action Editor"));
m_actionEditor->setObjectName("ActionEditor");
m_formEditor->setActionEditor(m_actionEditor);
m_designerToolWindows.append(m_actionEditor);
connect(m_formEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) );
m_designerIntegration = new QDesignerIntegration(m_formEditor,this);
m_formEditor->setIntegration(m_designerIntegration);
}
DialogDesigner::~DialogDesigner()
{
for (int i = 0; i<m_designerToolWindows.size();++i){
if (m_designerToolWindows[i])
delete m_designerToolWindows[i];
}
delete m_designerIntegration;
delete m_formEditor;
}
QWidget *DialogDesigner::createFormEditor(const QString &content)
{
QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
wnd->setContents(content);
m_formEditor->formWindowManager()->setActiveFormWindow(wnd);
m_formEditor->objectInspector()->setFormWindow(wnd);
wnd->editWidgets();
SharedTools::WidgetHost *placeholder = new SharedTools::WidgetHost(0,wnd);
placeholder->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
placeholder->setFocusProxy( wnd );
return placeholder;
}
void DialogDesigner::setActiveEditor(QWidget *widget)
{
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget);
if (wh){
m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow());
}
}
QWidget* DialogDesigner::widgetBox() const
{
return m_widgetBox;
}
QWidget* DialogDesigner::actionEditor() const
{
return m_actionEditor;
}
QWidget* DialogDesigner::propertyEditor() const
{
return m_propertyEditor;
}
QWidget* DialogDesigner::objectInspector() const
{
return m_objectInspector;
}
QWidget *DialogDesigner::signalSlotEditor() const
{
return m_signalSlotEditor;
}
QWidget *DialogDesigner::resourcesEditor() const
{
return m_resourcesEditor;
}
void DialogDesigner::objectDestroyed(QObject *object)
{
for ( int i = 0; i<m_designerToolWindows.size();++i){
m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
}
}
}

View File

@ -0,0 +1,48 @@
#ifndef DIALOGDESIGNER_H
#define DIALOGDESIGNER_H
#include <QObject>
#include <QVector>
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerIntegrationInterface;
class QDesignerWidgetBoxInterface;
class QDesignerActionEditorInterface;
class QDesignerPropertyEditorInterface;
class QDesignerObjectInspectorInterface;
class QDesignerFormWindowManagerInterface;
namespace LimeReport{
class DialogDesigner : public QObject
{
Q_OBJECT
public:
explicit DialogDesigner(QObject *parent = 0);
~DialogDesigner();
QWidget* createFormEditor(const QString& content);
void setActiveEditor(QWidget* widget);
QWidget* widgetBox() const;
QWidget* actionEditor() const;
QWidget* propertyEditor() const;
QWidget* objectInspector() const;
QWidget* signalSlotEditor() const;
QWidget* resourcesEditor() const;
private slots:
void objectDestroyed(QObject* object);
private:
QDesignerFormEditorInterface* m_formEditor;
QDesignerIntegrationInterface* m_designerIntegration;
QDesignerWidgetBoxInterface* m_widgetBox;
QDesignerActionEditorInterface* m_actionEditor;
QDesignerPropertyEditorInterface* m_propertyEditor;
QDesignerObjectInspectorInterface* m_objectInspector;
QWidget* m_signalSlotEditor;
QWidget* m_resourcesEditor;
QVector<QWidget*> m_designerToolWindows;
};
} // namespace LimeReport
#endif // DIALOGDESIGNER_H

View File

@ -1,5 +1,9 @@
include(../common.pri)
contains(CONFIG,dialogdesigner){
include($$REPORT_PATH/dialogdesigner/dialogdesigner.pri)
}
DEFINES += INSPECT_BASEDESIGN
INCLUDEPATH += \
@ -19,6 +23,15 @@ SOURCES += \
$$REPORT_PATH/bands/lrgroupbands.cpp \
$$REPORT_PATH/bands/lrsubdetailband.cpp \
$$REPORT_PATH/bands/lrtearoffband.cpp \
$$REPORT_PATH/databrowser/lrdatabrowser.cpp \
$$REPORT_PATH/databrowser/lrsqleditdialog.cpp \
$$REPORT_PATH/databrowser/lrconnectiondialog.cpp \
$$REPORT_PATH/databrowser/lrvariabledialog.cpp \
$$REPORT_PATH/databrowser/lrdatabrowsertree.cpp \
$$REPORT_PATH/serializators/lrxmlqrectserializator.cpp \
$$REPORT_PATH/serializators/lrxmlbasetypesserializators.cpp \
$$REPORT_PATH/serializators/lrxmlreader.cpp \
$$REPORT_PATH/serializators/lrxmlwriter.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrstringpropitem.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrrectproptem.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrintpropitem.cpp \
@ -44,16 +57,8 @@ SOURCES += \
$$REPORT_PATH/objectinspector/lrobjectitemmodel.cpp \
$$REPORT_PATH/objectinspector/lrobjectpropitem.cpp \
$$REPORT_PATH/objectinspector/lrpropertydelegate.cpp \
$$REPORT_PATH/objectsbrowser/lrobjectbrowser.cpp \
$$REPORT_PATH/databrowser/lrdatabrowser.cpp \
$$REPORT_PATH/databrowser/lrsqleditdialog.cpp \
$$REPORT_PATH/databrowser/lrconnectiondialog.cpp \
$$REPORT_PATH/databrowser/lrvariabledialog.cpp \
$$REPORT_PATH/databrowser/lrdatabrowsertree.cpp \
$$REPORT_PATH/serializators/lrxmlqrectserializator.cpp \
$$REPORT_PATH/serializators/lrxmlbasetypesserializators.cpp \
$$REPORT_PATH/serializators/lrxmlreader.cpp \
$$REPORT_PATH/serializators/lrxmlwriter.cpp \
$$REPORT_PATH/objectsbrowser/lrobjectbrowser.cpp \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \
$$REPORT_PATH/items/lrsubitemparentpropitem.cpp \
$$REPORT_PATH/items/lralignpropitem.cpp \
$$REPORT_PATH/items/lrhorizontallayout.cpp \
@ -88,8 +93,8 @@ SOURCES += \
$$REPORT_PATH/lrgroupfunctions.cpp \
$$REPORT_PATH/lrsimplecrypt.cpp \
$$REPORT_PATH/lraboutdialog.cpp \
$$REPORT_PATH/lrsettingdialog.cpp \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp
$$REPORT_PATH/lrsettingdialog.cpp
contains(CONFIG, zint){
SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp
@ -145,6 +150,7 @@ HEADERS += \
$$REPORT_PATH/objectinspector/lrobjectpropitem.h \
$$REPORT_PATH/objectinspector/lrpropertydelegate.h \
$$REPORT_PATH/objectsbrowser/lrobjectbrowser.h \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h \
$$REPORT_PATH/items/editors/lritemeditorwidget.h \
$$REPORT_PATH/items/editors/lrfonteditorwidget.h \
$$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.h \
@ -187,8 +193,8 @@ HEADERS += \
$$REPORT_PATH/lraboutdialog.h \
$$REPORT_PATH/lrcallbackdatasourceintf.h \
$$REPORT_PATH/lrsettingdialog.h \
$$REPORT_PATH/lrpreviewreportwidget_p.h \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h
$$REPORT_PATH/lrpreviewreportwidget_p.h
contains(CONFIG,zint){
HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h

View File

@ -33,6 +33,7 @@
#include "lrreportengine_p.h"
#include "lrbasedesignintf.h"
#include "lrsettingdialog.h"
#include "dialogdesigner/lrdialogdesigner.h"
#include <QDebug>
#include <QObject>
@ -46,10 +47,8 @@
namespace LimeReport {
// ReportDesignIntf
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) :
QWidget(parent), m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false)
QWidget(parent), m_dialogDesigner(new DialogDesigner(this)), m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false)
{
m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South);
@ -73,7 +72,6 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
connect(m_report,SIGNAL(cleared()),this,SIGNAL(cleared()));
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));
//m_instance=this;
m_scriptEditor->setPlainText(report->scriptContext()->initScript());
m_zoomer = new GraphicsViewZoomer(activeView());
#ifdef Q_OS_WIN
@ -81,6 +79,39 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
#endif
}
DialogDesigner *ReportDesignWidget::dialogDesigner() const
{
return m_dialogDesigner;
}
QWidget *ReportDesignWidget::toolWindow(ReportDesignWidget::ToolWindowType windowType)
{
switch (windowType) {
case WidgetBox:
return dialogDesigner()->widgetBox();
case PropertyEditor:
return dialogDesigner()->propertyEditor();
case ObjectInspector:
return dialogDesigner()->objectInspector();
case ActionEditor:
return dialogDesigner()->actionEditor();
case ResourceEditor:
return dialogDesigner()->resourcesEditor();
case SignalSlotEditor:
return dialogDesigner()->signalSlotEditor();
default:
return 0;
}
}
ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType()
{
QString tabType = m_tabWidget->tabWhatsThis(m_tabWidget->currentIndex());
if ( tabType.compare("dialog") == 0) return Dialog;
if ( tabType.compare("script") == 0) return Script;
return Page;
}
bool ReportDesignWidget::useMagnet() const
{
return m_useMagnet;
@ -139,6 +170,7 @@ void ReportDesignWidget::loadState(QSettings* settings)
void ReportDesignWidget::createTabs(){
int pageIndex = -1;
for (int i = 0; i<m_report->pageCount();++i){
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
@ -152,11 +184,22 @@ void ReportDesignWidget::createTabs(){
view->centerOn(0,0);
view->scale(0.5,0.5);
connectPage(m_report->pageAt(i));
m_tabWidget->addTab(view,QIcon(),tr("Page")+QString::number(i+1));
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page");
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
QWidget* dialogEditor;
foreach(DialogDescriber::Ptr dialogDesc, m_report->scriptContext()->dialogDescribers()){
dialogEditor = m_dialogDesigner->createFormEditor(dialogDesc->description());
pageIndex = m_tabWidget->addTab(dialogEditor,QIcon(),dialogDesc->name());
m_tabWidget->setTabWhatsThis(pageIndex,"dialog");
}
#endif
m_scriptEditor = new QTextEdit(this);
m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
m_tabWidget->setTabWhatsThis(pageIndex,"script");
m_tabWidget->setCurrentIndex(0);
}
ReportDesignWidget::~ReportDesignWidget()
@ -189,7 +232,6 @@ void ReportDesignWidget::connectPage(PageDesignIntf *page)
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
//activeView()->centerOn(0,0);
emit activePageChanged();
}
@ -605,6 +647,9 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
}
m_zoomer->setView(view);
}
if (activeTabType() == Dialog){
m_dialogDesigner->setActiveEditor(m_tabWidget->widget(index));
}
emit activePageChanged();
}

View File

@ -48,6 +48,7 @@ namespace LimeReport {
class ReportEnginePrivate;
class DataBrowser;
class ReportDesignWindow;
class DialogDesigner;
class ReportDesignWidget : public QWidget
{
@ -55,8 +56,20 @@ class ReportDesignWidget : public QWidget
Q_PROPERTY(QObject* datasourcesManager READ dataManager())
friend class ReportDesignWindow;
public:
enum ToolWindowType{
WidgetBox = 1,
ObjectInspector = 2,
ActionEditor = 3,
SignalSlotEditor = 4,
PropertyEditor = 5,
ResourceEditor = 6
};
enum EditorTabType{
Page,
Dialog,
Script
};
~ReportDesignWidget();
// static ReportDesignWidget* instance(){return m_instance;}
void createStartPage();
void clear();
DataSourceManager* dataManager();
@ -76,7 +89,6 @@ public:
QList<QGraphicsItem *> selectedItems();
QStringList datasourcesNames();
void scale( qreal sx, qreal sy);
// void setDatabrowser(DataBrowser* databrowser);
ReportEnginePrivate* report(){return m_report;}
QString reportFileName();
bool isNeedToSave();
@ -88,7 +100,9 @@ public:
bool useGrid(){ return m_useGrid;}
bool useMagnet() const;
void setUseMagnet(bool useMagnet);
DialogDesigner *dialogDesigner() const;
QWidget* toolWindow(ToolWindowType windowType);
EditorTabType activeTabType();
public slots:
void saveToFile(const QString&);
bool save();
@ -155,6 +169,7 @@ private:
ReportEnginePrivate* m_report;
QGraphicsView *m_view;
QTextEdit* m_scriptEditor;
DialogDesigner* m_dialogDesigner;
QMainWindow *m_mainWindow;
QTabWidget* m_tabWidget;
GraphicsViewZoomer* m_zoomer;
@ -163,7 +178,6 @@ private:
int m_horizontalGridStep;
bool m_useGrid;
bool m_useMagnet;
// static ReportDesignWidget* m_instance;
};
}

View File

@ -73,6 +73,14 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par
createDataWindow();
createScriptWindow();
createObjectsBrowser();
#ifdef HAVE_QTDESIGNER_INTEGRATION
createDialogWidgetBox();
createDialogPropertyEditor();
createDialogObjectInspector();
createDialogActionEditor();
createDialogResourceEditor();
createDialogSignalSlotEditor();
#endif
m_instance=this;
m_statusBar=new QStatusBar(this);
m_lblReportName = new QLabel(report->reportFileName(),this);
@ -82,6 +90,8 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par
restoreSetting();
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors();
}
ReportDesignWindow::~ReportDesignWindow()
@ -475,7 +485,6 @@ void ReportDesignWindow::createObjectInspector()
m_objectInspector->setModel(m_propertyModel);
m_objectInspector->setAlternatingRowColors(true);
m_objectInspector->setRootIsDecorated(!m_propertyModel->subclassesAsLevel());
QDockWidget *objectDoc = new QDockWidget(this);
QWidget* w = new QWidget(objectDoc);
QVBoxLayout* l = new QVBoxLayout(w);
@ -485,6 +494,7 @@ void ReportDesignWindow::createObjectInspector()
objectDoc->setWindowTitle(tr("Object Inspector"));
objectDoc->setWidget(w);
objectDoc->setObjectName("objectInspector");
m_pageEditors.append(objectDoc);
addDockWidget(Qt::LeftDockWidgetArea,objectDoc);
}
@ -497,9 +507,73 @@ void ReportDesignWindow::createObjectsBrowser()
doc->setObjectName("structureDoc");
addDockWidget(Qt::RightDockWidgetArea,doc);
m_objectsBrowser->setMainWindow(this);
m_pageEditors.append(doc);
m_objectsBrowser->setReportEditor(m_reportDesignWidget);
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWindow::createDialogWidgetBox()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Widget Box"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::WidgetBox));
doc->setObjectName("WidgetBox");
addDockWidget(Qt::LeftDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogPropertyEditor()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Property Editor"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::PropertyEditor));
doc->setObjectName("PropertyEditor");
addDockWidget(Qt::RightDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogObjectInspector()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Object Inspector"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ObjectInspector));
doc->setObjectName("ObjectInspector");
addDockWidget(Qt::RightDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogActionEditor()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Action Editor"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ActionEditor));
doc->setObjectName("ActionEditor");
addDockWidget(Qt::BottomDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogResourceEditor()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Resource Editor"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ResourceEditor));
doc->setObjectName("ResourceEditor");
addDockWidget(Qt::BottomDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogSignalSlotEditor()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("SignalSlot Editor"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::SignalSlotEditor));
doc->setObjectName("SignalSlotEditor");
addDockWidget(Qt::BottomDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
#endif
void ReportDesignWindow::createDataWindow()
{
QDockWidget *dataDoc = new QDockWidget(this);
@ -510,6 +584,7 @@ void ReportDesignWindow::createDataWindow()
addDockWidget(Qt::LeftDockWidgetArea,dataDoc);
m_dataBrowser->setSettings(settings());
m_dataBrowser->setMainWindow(this);
m_pageEditors.append(dataDoc);
m_dataBrowser->setReportEditor(m_reportDesignWidget);
}
@ -522,6 +597,7 @@ void ReportDesignWindow::createScriptWindow()
dataDoc->setObjectName("scriptDoc");
addDockWidget(Qt::LeftDockWidgetArea,dataDoc);
m_scriptBrowser->setReportEditor(m_reportDesignWidget);
m_pageEditors.append(dataDoc);
#ifdef HAVE_UI_LOADER
m_scriptBrowser->updateDialogsTree();
#endif
@ -544,6 +620,8 @@ void ReportDesignWindow::startNewReport()
m_newPageFooter->setEnabled(true);
m_newReportHeader->setEnabled(true);
m_newReportFooter->setEnabled(true);
m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors();
}
void ReportDesignWindow::writePosition()
@ -557,7 +635,16 @@ void ReportDesignWindow::writePosition()
void ReportDesignWindow::writeState()
{
settings()->beginGroup("DesignerWindow");
settings()->setValue("State",saveState());
switch (m_editorTabType) {
case ReportDesignWidget::Page:
settings()->setValue("PageEditorsState", saveState());
settings()->setValue("DialogEditorsState", m_dialogEditorsState);
break;
default:
settings()->setValue("DialogEditorsState", saveState());
settings()->setValue("PageEditorsState", m_pageEditorsState);
break;
}
settings()->setValue("InspectorFirsColumnWidth",m_objectInspector->columnWidth(0));
settings()->endGroup();
settings()->beginGroup("RecentFiles");
@ -650,9 +737,15 @@ void ReportDesignWindow::restoreSetting()
resize(screenWidth*0.8, screenHeight*0.8);
move(x, y);
}
v = settings()->value("State");
v = settings()->value("PageEditorsState");
if (v.isValid()){
m_pageEditorsState = v.toByteArray();
restoreState(v.toByteArray());
m_editorTabType = ReportDesignWidget::Page;
}
v = settings()->value("DialogEditorsState");
if (v.isValid()){
m_dialogEditorsState = v.toByteArray();
}
v = settings()->value("InspectorFirsColumnWidth");
if (v.isValid()){
@ -954,6 +1047,8 @@ void ReportDesignWindow::slotLoadReport()
unsetCursor();
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
addRecentFile(fileName);
m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors();
}
}
@ -1120,11 +1215,48 @@ void ReportDesignWindow::updateAvaibleBands(){
}
}
void ReportDesignWindow::showDefaultEditors(){
foreach (QDockWidget* w, m_pageEditors) {
w->setVisible(m_editorTabType != ReportDesignWidget::Dialog);
}
foreach (QDockWidget* w, m_dialogEditors) {
w->setVisible(m_editorTabType == ReportDesignWidget::Dialog);
}
}
void ReportDesignWindow::slotActivePageChanged()
{
m_propertyModel->setObject(0);
updateRedoUndo();
updateAvaibleBands();
switch (m_editorTabType) {
case ReportDesignWidget::Dialog:
m_dialogEditorsState = saveState();
break;
default:
m_pageEditorsState = saveState();
break;
}
m_editorTabType = m_reportDesignWidget->activeTabType();
switch (m_editorTabType) {
case ReportDesignWidget::Dialog:
if (!m_dialogEditorsState.isEmpty())
restoreState(m_dialogEditorsState);
else
showDefaultEditors();
break;
default:
if (!m_pageEditors.isEmpty())
restoreState(m_pageEditorsState);
else
showDefaultEditors();
break;
}
}
void ReportDesignWindow::renderStarted()

View File

@ -126,6 +126,7 @@ protected:
void hideDockWidgets(Qt::DockWidgetArea area, bool value);
bool isDockAreaVisible(Qt::DockWidgetArea area);
private:
void initReportEditor(ReportEnginePrivate* report);
void createActions();
void createBandsButton();
void createMainMenu();
@ -134,9 +135,16 @@ private:
void createItemsActions();
void createObjectInspector();
void createObjectsBrowser();
void initReportEditor(ReportEnginePrivate* report);
void createDataWindow();
void createScriptWindow();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createDialogWidgetBox();
void createDialogPropertyEditor();
void createDialogObjectInspector();
void createDialogActionEditor();
void createDialogResourceEditor();
void createDialogSignalSlotEditor();
#endif
void updateRedoUndo();
void updateAvaibleBands();
void startNewReport();
@ -146,6 +154,7 @@ private:
void removeNotExistedRecentFiles();
void removeNotExistedRecentFilesFromMenu(const QString& fileName);
void addRecentFile(const QString& fileName);
void showDefaultEditors();
private:
static ReportDesignWindow* m_instance;
QStatusBar* m_statusBar;
@ -235,6 +244,12 @@ private:
QProgressDialog* m_progressDialog;
bool m_showProgressDialog;
QMap<QString,QDateTime> m_recentFiles;
QVector<QDockWidget*> m_pageEditors;
QVector<QDockWidget*> m_dialogEditors;
ReportDesignWidget::EditorTabType m_editorTabType;
QByteArray m_pageEditorsState;
QByteArray m_dialogEditorsState;
};
class ObjectNameValidator : public ValidatorIntf{

View File

@ -341,7 +341,7 @@ void registerChildObjects(ScriptEngineType* se, ScriptValueType* sv){
void ReportRender::initDialogs(){
if (m_scriptEngineContext){
ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine();
foreach(DialogDescriber::Ptr dialog, m_scriptEngineContext->dialogsDescriber()){
foreach(DialogDescriber::Ptr dialog, m_scriptEngineContext->dialogDescribers()){
ScriptValueType sv = se->newQObject(m_scriptEngineContext->getDialog(dialog->name()));
#ifdef USE_QJSENGINE
registerChildObjects(se,&sv);

View File

@ -144,21 +144,21 @@ public:
#endif
explicit ScriptEngineContext(QObject* parent=0):QObject(parent){}
#ifdef HAVE_UI_LOADER
void addDialog(const QString& name, const QByteArray &description);
void addDialog(const QString& name, const QByteArray &description);
bool previewDialog(const QString& dialogName);
bool containsDialog(const QString& dialogName);
const QVector<DialogDescriber::Ptr>& dialogsDescriber(){return m_dialogs;}
const QVector<DialogDescriber::Ptr>& dialogDescribers(){return m_dialogs;}
void deleteDialog(const QString& dialogName);
QDialog *getDialog(const QString &dialogName);
#endif
void clear();
void clear();
QString initScript() const;
void setInitScript(const QString& initScript);
void setInitScript(const QString& initScript);
protected:
QObject* createElement(const QString& collectionName,const QString& elementType);
int elementsCount(const QString& collectionName);
int elementsCount(const QString& collectionName);
QObject* elementAt(const QString& collectionName,int index);
void collectionLoadFinished(const QString &collectionName);
void collectionLoadFinished(const QString &collectionName);
#ifdef HAVE_UI_LOADER
QDialog *createDialog(DialogDescriber *cont);
QDialog *findDialog(const QString &dialogName);

View File

@ -117,7 +117,7 @@ void ScriptBrowser::updateDialogsTree()
{
ui->twDialogs->clear();
ScriptEngineContext* sc = reportEditor()->scriptContext();
foreach(DialogDescriber::Ptr dc, sc->dialogsDescriber()){
foreach(DialogDescriber::Ptr dc, sc->dialogDescribers()){
QTreeWidgetItem* dialogItem = new QTreeWidgetItem(ui->twDialogs,QStringList(dc->name()));
dialogItem->setIcon(0,QIcon(":/scriptbrowser/images/dialog"));
fillDialog(dialogItem,dc->description());