2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-08-12 15:43:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-08-12 15:43:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-08-12 15:43:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2010-08-12 15:43:13 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-08-12 15:43:13 +02:00
|
|
|
|
2010-07-06 11:05:43 +02:00
|
|
|
#include "contextpanewidget.h"
|
2012-08-23 15:53:58 +02:00
|
|
|
|
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QFontComboBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QGraphicsEffect>
|
|
|
|
|
#include <QAction>
|
2010-07-06 11:05:43 +02:00
|
|
|
#include "contextpanetextwidget.h"
|
2010-07-19 12:06:40 +02:00
|
|
|
#include "easingcontextpane.h"
|
2010-07-15 16:44:53 +02:00
|
|
|
#include "contextpanewidgetimage.h"
|
|
|
|
|
#include "contextpanewidgetrectangle.h"
|
2010-08-12 15:43:13 +02:00
|
|
|
#include "customcolordialog.h"
|
|
|
|
|
#include "colorbutton.h"
|
2010-07-06 11:05:43 +02:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
namespace QmlEditorWidgets {
|
2010-07-06 11:05:43 +02:00
|
|
|
|
2010-08-02 17:10:16 +02:00
|
|
|
/* XPM */
|
|
|
|
|
static const char * const line_xpm[] = {
|
2010-08-17 15:40:46 +02:00
|
|
|
"14 14 3 1",
|
2010-08-02 17:10:16 +02:00
|
|
|
" c None",
|
2010-08-03 12:48:00 +02:00
|
|
|
". c #0c0c0c",
|
2010-08-17 15:40:46 +02:00
|
|
|
"x c #1c1c1c",
|
|
|
|
|
"............. ",
|
|
|
|
|
". . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". x x . ",
|
|
|
|
|
". . ",
|
|
|
|
|
"............. ",
|
|
|
|
|
" "};
|
2010-08-02 17:10:16 +02:00
|
|
|
|
2010-08-03 12:48:00 +02:00
|
|
|
/* XPM */
|
2010-08-04 16:56:06 +10:00
|
|
|
static const char * pin_xpm[] = {
|
2010-08-03 12:48:00 +02:00
|
|
|
"12 9 7 1",
|
|
|
|
|
" c None",
|
|
|
|
|
". c #000000",
|
|
|
|
|
"+ c #515151",
|
|
|
|
|
"@ c #A8A8A8",
|
|
|
|
|
"# c #A9A9A9",
|
|
|
|
|
"$ c #999999",
|
|
|
|
|
"% c #696969",
|
|
|
|
|
" . ",
|
|
|
|
|
" ......+",
|
|
|
|
|
" .@@@@@.",
|
|
|
|
|
" .#####.",
|
|
|
|
|
"+.....$$$$$.",
|
|
|
|
|
" .%%%%%.",
|
|
|
|
|
" .......",
|
|
|
|
|
" ......+",
|
|
|
|
|
" . "};
|
2010-07-26 13:47:59 +02:00
|
|
|
|
|
|
|
|
DragWidget::DragWidget(QWidget *parent) : QFrame(parent)
|
2010-07-06 11:05:43 +02:00
|
|
|
{
|
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
setFrameShape(QFrame::StyledPanel);
|
|
|
|
|
setFrameShadow(QFrame::Sunken);
|
2010-08-13 17:17:50 +02:00
|
|
|
m_startPos = QPoint(-1, -1);
|
2010-07-22 13:35:38 +02:00
|
|
|
m_pos = QPoint(-1, -1);
|
2010-07-06 11:05:43 +02:00
|
|
|
|
2012-07-05 14:00:45 +02:00
|
|
|
// TODO: The following code should be enabled for OSX
|
|
|
|
|
// when QTBUG-23205 is fixed
|
2012-08-23 15:53:58 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
|
|
|
|
m_dropShadowEffect = new QGraphicsDropShadowEffect;
|
|
|
|
|
m_dropShadowEffect->setBlurRadius(6);
|
|
|
|
|
m_dropShadowEffect->setOffset(2, 2);
|
|
|
|
|
setGraphicsEffect(m_dropShadowEffect);
|
|
|
|
|
}
|
2010-07-26 13:47:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DragWidget::mousePressEvent(QMouseEvent * event)
|
|
|
|
|
{
|
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
2010-08-13 17:17:50 +02:00
|
|
|
m_startPos = event->globalPos() - parentWidget()->mapToGlobal((pos()));
|
2010-07-26 13:47:59 +02:00
|
|
|
m_opacityEffect = new QGraphicsOpacityEffect;
|
|
|
|
|
setGraphicsEffect(m_opacityEffect);
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
QFrame::mousePressEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DragWidget::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (event->button() == Qt::LeftButton) {
|
2010-08-13 17:17:50 +02:00
|
|
|
m_startPos = QPoint(-1, -1);
|
2012-07-05 14:00:45 +02:00
|
|
|
// TODO: The following code should be enabled for OSX
|
|
|
|
|
// when QTBUG-23205 is fixed
|
2012-08-23 15:53:58 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
|
|
|
|
m_dropShadowEffect = new QGraphicsDropShadowEffect;
|
|
|
|
|
m_dropShadowEffect->setBlurRadius(6);
|
|
|
|
|
m_dropShadowEffect->setOffset(2, 2);
|
|
|
|
|
setGraphicsEffect(m_dropShadowEffect);
|
|
|
|
|
}
|
2010-07-26 13:47:59 +02:00
|
|
|
}
|
|
|
|
|
QFrame::mouseReleaseEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 17:17:50 +02:00
|
|
|
static inline int limit(int a, int min, int max)
|
|
|
|
|
{
|
|
|
|
|
if (a < min)
|
|
|
|
|
return min;
|
|
|
|
|
if (a > max)
|
|
|
|
|
return max;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-26 13:47:59 +02:00
|
|
|
void DragWidget::mouseMoveEvent(QMouseEvent * event)
|
|
|
|
|
{
|
|
|
|
|
if (event->buttons() && Qt::LeftButton) {
|
2010-08-13 17:17:50 +02:00
|
|
|
if (m_startPos != QPoint(-1, -1)) {
|
|
|
|
|
QPoint newPos = parentWidget()->mapFromGlobal(event->globalPos() - m_startPos);
|
|
|
|
|
|
|
|
|
|
newPos.setX(limit(newPos.x(), 20, parentWidget()->width() - 20 - width()));
|
|
|
|
|
newPos.setY(limit(newPos.y(), 2, parentWidget()->height() - 20 - height()));
|
|
|
|
|
|
|
|
|
|
QPoint diff = pos() - newPos;
|
|
|
|
|
if (m_secondaryTarget)
|
|
|
|
|
m_secondaryTarget->move(m_secondaryTarget->pos() - diff);
|
|
|
|
|
move(newPos);
|
|
|
|
|
if (m_pos != newPos)
|
2010-08-03 12:48:00 +02:00
|
|
|
protectedMoved();
|
2010-08-13 17:17:50 +02:00
|
|
|
m_pos = newPos;
|
2010-07-26 13:47:59 +02:00
|
|
|
} else {
|
|
|
|
|
m_opacityEffect = new QGraphicsOpacityEffect;
|
|
|
|
|
setGraphicsEffect(m_opacityEffect);
|
|
|
|
|
}
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 12:48:00 +02:00
|
|
|
void DragWidget::protectedMoved()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-04 10:26:50 +01:00
|
|
|
void DragWidget::leaveEvent(QEvent *)
|
|
|
|
|
{
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isMacHost())
|
|
|
|
|
unsetCursor();
|
2010-11-04 10:26:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DragWidget::enterEvent(QEvent *)
|
|
|
|
|
{
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isMacHost())
|
|
|
|
|
setCursor(Qt::ArrowCursor);
|
2010-11-04 10:26:50 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-26 13:47:59 +02:00
|
|
|
ContextPaneWidget::ContextPaneWidget(QWidget *parent) : DragWidget(parent), m_currentWidget(0)
|
|
|
|
|
{
|
2010-07-06 11:05:43 +02:00
|
|
|
QGridLayout *layout = new QGridLayout(this);
|
2010-07-20 10:22:40 +02:00
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setContentsMargins(1, 1, 1, 1);
|
|
|
|
|
layout->setSpacing(0);
|
2010-08-03 12:48:00 +02:00
|
|
|
m_toolButton = new QToolButton(this);
|
|
|
|
|
m_toolButton->setAutoRaise(false);
|
|
|
|
|
|
2010-08-17 15:40:46 +02:00
|
|
|
m_toolButton->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
|
2010-08-03 12:48:00 +02:00
|
|
|
m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
|
m_toolButton->setFixedSize(16, 16);
|
|
|
|
|
|
2010-09-01 11:54:00 +02:00
|
|
|
m_toolButton->setToolTip(tr("Hides this toolbar."));
|
2010-08-03 12:48:00 +02:00
|
|
|
connect(m_toolButton, SIGNAL(clicked()), this, SLOT(onTogglePane()));
|
|
|
|
|
layout->addWidget(m_toolButton, 0, 0, 1, 1);
|
2010-07-06 11:05:43 +02:00
|
|
|
colorDialog();
|
|
|
|
|
|
|
|
|
|
QWidget *fontWidget = createFontWidget();
|
|
|
|
|
m_currentWidget = fontWidget;
|
2010-07-15 16:44:53 +02:00
|
|
|
QWidget *imageWidget = createImageWidget();
|
2010-07-30 14:30:19 +02:00
|
|
|
QWidget *borderImageWidget = createBorderImageWidget();
|
2010-07-15 16:44:53 +02:00
|
|
|
QWidget *rectangleWidget = createRectangleWidget();
|
2010-07-19 12:06:40 +02:00
|
|
|
QWidget *easingWidget = createEasingWidget();
|
2010-07-06 11:05:43 +02:00
|
|
|
layout->addWidget(fontWidget, 0, 1, 2, 1);
|
2010-07-19 12:06:40 +02:00
|
|
|
layout->addWidget(easingWidget, 0, 1, 2, 1);
|
2010-07-15 16:44:53 +02:00
|
|
|
layout->addWidget(imageWidget, 0, 1, 2, 1);
|
2010-07-30 14:30:19 +02:00
|
|
|
layout->addWidget(borderImageWidget, 0, 1, 2, 1);
|
2010-07-15 16:44:53 +02:00
|
|
|
layout->addWidget(rectangleWidget, 0, 1, 2, 1);
|
2010-07-19 12:06:40 +02:00
|
|
|
|
2010-07-06 11:05:43 +02:00
|
|
|
setAutoFillBackground(true);
|
|
|
|
|
setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
|
|
|
|
2010-09-01 11:54:00 +02:00
|
|
|
m_resetAction = new QAction(tr("Pin Toolbar"), this);
|
2010-08-02 17:10:16 +02:00
|
|
|
m_resetAction->setCheckable(true);
|
2010-08-03 12:48:00 +02:00
|
|
|
addAction(m_resetAction.data());
|
|
|
|
|
connect(m_resetAction.data(), SIGNAL(triggered(bool)), this, SLOT(onResetPosition(bool)));
|
2010-07-07 13:07:47 +02:00
|
|
|
|
2010-09-01 11:54:00 +02:00
|
|
|
m_disableAction = new QAction(tr("Show Always"), this);
|
2010-08-04 13:56:34 +02:00
|
|
|
addAction(m_disableAction.data());
|
|
|
|
|
m_disableAction->setCheckable(true);
|
|
|
|
|
connect(m_disableAction.data(), SIGNAL(toggled(bool)), this, SLOT(onDisable(bool)));
|
2010-08-03 12:48:00 +02:00
|
|
|
m_pinned = false;
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isMacHost())
|
|
|
|
|
setCursor(Qt::ArrowCursor);
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContextPaneWidget::~ContextPaneWidget()
|
|
|
|
|
{
|
|
|
|
|
//if the pane was never activated the widget is not in a widget tree
|
|
|
|
|
if (!m_bauhausColorDialog.isNull())
|
|
|
|
|
delete m_bauhausColorDialog.data();
|
2012-09-24 13:48:18 +02:00
|
|
|
m_bauhausColorDialog = 0;
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2, bool pinned)
|
2010-07-06 11:05:43 +02:00
|
|
|
{
|
|
|
|
|
//uncheck all color buttons
|
|
|
|
|
foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
|
|
|
|
|
colorButton->setChecked(false);
|
|
|
|
|
}
|
2010-07-22 13:35:38 +02:00
|
|
|
show();
|
|
|
|
|
update();
|
2010-07-06 11:05:43 +02:00
|
|
|
resize(sizeHint());
|
|
|
|
|
show();
|
2010-08-12 15:43:13 +02:00
|
|
|
rePosition(pos, alternative, alternative2, pinned);
|
2010-07-06 11:05:43 +02:00
|
|
|
raise();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative, const QPoint &alternative2, bool pinned)
|
2010-07-06 11:05:43 +02:00
|
|
|
{
|
2010-07-09 15:56:43 +02:00
|
|
|
if ((position.x() + width()) < parentWidget()->width())
|
2010-07-06 11:05:43 +02:00
|
|
|
move(position);
|
|
|
|
|
else
|
|
|
|
|
move(alternative);
|
|
|
|
|
|
2010-07-09 15:56:43 +02:00
|
|
|
if (pos().y() < 0)
|
|
|
|
|
move(alternative2);
|
2010-07-20 15:01:50 +02:00
|
|
|
if ((pos().y() + height()) > parentWidget()->height())
|
2011-07-27 11:51:51 +02:00
|
|
|
move(x(), parentWidget()->height() - height() - 10);
|
2010-07-22 13:35:38 +02:00
|
|
|
|
|
|
|
|
m_originalPos = pos();
|
|
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
if (m_pos.x() > 0 && pinned) {
|
2010-07-22 13:35:38 +02:00
|
|
|
move(m_pos);
|
|
|
|
|
show();
|
2010-08-03 12:48:00 +02:00
|
|
|
setPinButton();
|
|
|
|
|
} else {
|
|
|
|
|
setLineButton();
|
2010-07-22 13:35:38 +02:00
|
|
|
}
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContextPaneWidget::deactivate()
|
|
|
|
|
{
|
|
|
|
|
hide();
|
|
|
|
|
if (m_bauhausColorDialog)
|
|
|
|
|
m_bauhausColorDialog->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
void ContextPaneWidget::setOptions(bool enabled, bool pinned)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
m_disableAction->setChecked(enabled);
|
|
|
|
|
m_resetAction->setChecked(pinned);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomColorDialog *ContextPaneWidget::colorDialog()
|
2010-07-06 11:05:43 +02:00
|
|
|
{
|
|
|
|
|
if (m_bauhausColorDialog.isNull()) {
|
2010-08-12 15:43:13 +02:00
|
|
|
m_bauhausColorDialog = new CustomColorDialog(parentWidget());
|
2010-07-06 11:05:43 +02:00
|
|
|
m_bauhausColorDialog->hide();
|
2010-07-26 13:47:59 +02:00
|
|
|
setSecondaryTarget(m_bauhausColorDialog.data());
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_bauhausColorDialog.data();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContextPaneWidget::setProperties(::QmlJS::PropertyReader *propertyReader)
|
|
|
|
|
{
|
|
|
|
|
ContextPaneTextWidget *textWidget = qobject_cast<ContextPaneTextWidget*>(m_currentWidget);
|
|
|
|
|
if (textWidget)
|
|
|
|
|
textWidget->setProperties(propertyReader);
|
2010-07-15 16:44:53 +02:00
|
|
|
|
2010-07-19 12:06:40 +02:00
|
|
|
EasingContextPane *easingWidget = qobject_cast<EasingContextPane*>(m_currentWidget);
|
|
|
|
|
if (easingWidget)
|
|
|
|
|
easingWidget->setProperties(propertyReader);
|
|
|
|
|
|
2010-07-15 16:44:53 +02:00
|
|
|
ContextPaneWidgetImage *imageWidget = qobject_cast<ContextPaneWidgetImage*>(m_currentWidget);
|
|
|
|
|
if (imageWidget)
|
|
|
|
|
imageWidget->setProperties(propertyReader);
|
|
|
|
|
|
|
|
|
|
ContextPaneWidgetRectangle *rectangleWidget = qobject_cast<ContextPaneWidgetRectangle*>(m_currentWidget);
|
|
|
|
|
if (rectangleWidget)
|
|
|
|
|
rectangleWidget->setProperties(propertyReader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContextPaneWidget::setPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
ContextPaneWidgetImage *imageWidget = qobject_cast<ContextPaneWidgetImage*>(m_currentWidget);
|
|
|
|
|
if (imageWidget)
|
|
|
|
|
imageWidget->setPath(path);
|
|
|
|
|
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-05 17:42:15 +02:00
|
|
|
bool ContextPaneWidget::setType(const QStringList &types)
|
2010-07-06 11:05:43 +02:00
|
|
|
{
|
2010-07-15 16:44:53 +02:00
|
|
|
m_imageWidget->hide();
|
2010-07-30 14:30:19 +02:00
|
|
|
m_borderImageWidget->hide();
|
2010-07-15 16:44:53 +02:00
|
|
|
m_textWidget->hide();
|
|
|
|
|
m_rectangleWidget->hide();
|
2010-07-19 12:06:40 +02:00
|
|
|
m_easingWidget->hide();
|
2010-07-15 16:44:53 +02:00
|
|
|
|
2010-10-08 12:44:16 +02:00
|
|
|
if (types.contains("Text") ||
|
|
|
|
|
types.contains("TextEdit") ||
|
|
|
|
|
types.contains("TextInput")) {
|
2010-07-06 11:05:43 +02:00
|
|
|
m_currentWidget = m_textWidget;
|
|
|
|
|
m_textWidget->show();
|
|
|
|
|
m_textWidget->setStyleVisible(true);
|
|
|
|
|
m_textWidget->setVerticalAlignmentVisible(true);
|
2010-08-05 17:42:15 +02:00
|
|
|
if (types.contains("TextInput")) {
|
2010-07-06 11:05:43 +02:00
|
|
|
m_textWidget->setVerticalAlignmentVisible(false);
|
|
|
|
|
m_textWidget->setStyleVisible(false);
|
2010-08-05 17:42:15 +02:00
|
|
|
} else if (types.contains("TextEdit")) {
|
2010-07-06 11:05:43 +02:00
|
|
|
m_textWidget->setStyleVisible(false);
|
|
|
|
|
}
|
2010-07-22 13:35:38 +02:00
|
|
|
resize(sizeHint());
|
2010-07-06 11:05:43 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-19 12:06:40 +02:00
|
|
|
|
2010-08-05 17:42:15 +02:00
|
|
|
if (m_easingWidget->acceptsType(types)) {
|
2010-07-19 12:06:40 +02:00
|
|
|
m_currentWidget = m_easingWidget;
|
|
|
|
|
m_easingWidget->show();
|
2010-07-22 13:35:38 +02:00
|
|
|
resize(sizeHint());
|
2010-07-19 12:06:40 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-08-05 17:42:15 +02:00
|
|
|
if (types.contains("Rectangle")) {
|
2010-07-15 16:44:53 +02:00
|
|
|
m_currentWidget = m_rectangleWidget;
|
2011-03-10 13:05:23 +01:00
|
|
|
m_rectangleWidget->enabableGradientEditing(!isPropertyChanges());
|
2010-07-15 16:44:53 +02:00
|
|
|
m_rectangleWidget->show();
|
2010-07-22 13:35:38 +02:00
|
|
|
resize(sizeHint());
|
2010-07-15 16:44:53 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-30 14:30:19 +02:00
|
|
|
|
2010-08-05 17:42:15 +02:00
|
|
|
if (types.contains("BorderImage")) {
|
2010-07-30 14:30:19 +02:00
|
|
|
m_currentWidget = m_borderImageWidget;
|
|
|
|
|
m_borderImageWidget->show();
|
|
|
|
|
resize(sizeHint());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-05 17:42:15 +02:00
|
|
|
if (types.contains("Image")) {
|
2010-07-15 16:44:53 +02:00
|
|
|
m_currentWidget = m_imageWidget;
|
|
|
|
|
m_imageWidget->show();
|
2010-07-22 13:35:38 +02:00
|
|
|
resize(sizeHint());
|
2010-07-15 16:44:53 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-06 11:05:43 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-05 17:42:15 +02:00
|
|
|
bool ContextPaneWidget::acceptsType(const QStringList &types)
|
2010-07-19 12:06:40 +02:00
|
|
|
{
|
2010-10-08 12:44:16 +02:00
|
|
|
return types.contains("Text") || types.contains("TextEdit") || types.contains("TextInput") || m_easingWidget->acceptsType(types) ||
|
2010-08-06 10:54:47 +02:00
|
|
|
types.contains("Rectangle") || types.contains("Image") || types.contains("BorderImage");
|
2010-07-19 12:06:40 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-06 11:05:43 +02:00
|
|
|
void ContextPaneWidget::onTogglePane()
|
|
|
|
|
{
|
|
|
|
|
if (!m_currentWidget)
|
|
|
|
|
return;
|
2010-08-03 12:48:00 +02:00
|
|
|
if (m_pinned) {
|
|
|
|
|
m_pos = QPoint(-1,-1);
|
|
|
|
|
move(m_originalPos);
|
|
|
|
|
setLineButton();
|
|
|
|
|
} else {
|
|
|
|
|
deactivate();
|
2010-08-13 13:56:23 +02:00
|
|
|
emit closed();
|
2010-08-03 12:48:00 +02:00
|
|
|
}
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContextPaneWidget::onShowColorDialog(bool checked, const QPoint &p)
|
2012-11-28 20:28:42 +02:00
|
|
|
{
|
2010-07-06 11:05:43 +02:00
|
|
|
if (checked) {
|
|
|
|
|
colorDialog()->setParent(parentWidget());
|
|
|
|
|
colorDialog()->move(p);
|
|
|
|
|
colorDialog()->show();
|
|
|
|
|
colorDialog()->raise();
|
|
|
|
|
} else {
|
|
|
|
|
colorDialog()->hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-04 13:56:34 +02:00
|
|
|
void ContextPaneWidget::onDisable(bool b)
|
2012-11-28 20:28:42 +02:00
|
|
|
{
|
2010-08-12 15:43:13 +02:00
|
|
|
enabledChanged(b);
|
2010-08-04 13:56:34 +02:00
|
|
|
if (!b) {
|
|
|
|
|
hide();
|
|
|
|
|
colorDialog()->hide();
|
|
|
|
|
}
|
2010-07-06 11:05:43 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-02 17:10:16 +02:00
|
|
|
void ContextPaneWidget::onResetPosition(bool toggle)
|
2010-07-07 13:07:47 +02:00
|
|
|
{
|
2010-08-02 17:10:16 +02:00
|
|
|
if (!toggle) {
|
2010-08-03 12:48:00 +02:00
|
|
|
setLineButton();
|
2010-08-02 17:10:16 +02:00
|
|
|
m_pos = QPoint(-1,-1);
|
|
|
|
|
move(m_originalPos);
|
2010-08-03 12:48:00 +02:00
|
|
|
} else {
|
|
|
|
|
setPinButton();
|
2010-08-02 17:10:16 +02:00
|
|
|
}
|
2010-07-07 13:07:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 12:48:00 +02:00
|
|
|
void ContextPaneWidget::protectedMoved()
|
|
|
|
|
{
|
|
|
|
|
setPinButton();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-06 11:05:43 +02:00
|
|
|
QWidget* ContextPaneWidget::createFontWidget()
|
2012-11-28 20:28:42 +02:00
|
|
|
{
|
2010-07-06 11:05:43 +02:00
|
|
|
m_textWidget = new ContextPaneTextWidget(this);
|
|
|
|
|
connect(m_textWidget, SIGNAL(propertyChanged(QString,QVariant)), this, SIGNAL(propertyChanged(QString,QVariant)));
|
|
|
|
|
connect(m_textWidget, SIGNAL(removeProperty(QString)), this, SIGNAL(removeProperty(QString)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_textWidget, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)));
|
2010-07-06 11:05:43 +02:00
|
|
|
|
|
|
|
|
return m_textWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 12:06:40 +02:00
|
|
|
QWidget* ContextPaneWidget::createEasingWidget()
|
|
|
|
|
{
|
|
|
|
|
m_easingWidget = new EasingContextPane(this);
|
|
|
|
|
|
|
|
|
|
connect(m_easingWidget, SIGNAL(propertyChanged(QString,QVariant)), this, SIGNAL(propertyChanged(QString,QVariant)));
|
|
|
|
|
connect(m_easingWidget, SIGNAL(removeProperty(QString)), this, SIGNAL(removeProperty(QString)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_easingWidget, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)));
|
2010-07-19 12:06:40 +02:00
|
|
|
|
|
|
|
|
return m_easingWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:44:53 +02:00
|
|
|
QWidget *ContextPaneWidget::createImageWidget()
|
|
|
|
|
{
|
|
|
|
|
m_imageWidget = new ContextPaneWidgetImage(this);
|
|
|
|
|
connect(m_imageWidget, SIGNAL(propertyChanged(QString,QVariant)), this, SIGNAL(propertyChanged(QString,QVariant)));
|
|
|
|
|
connect(m_imageWidget, SIGNAL(removeProperty(QString)), this, SIGNAL(removeProperty(QString)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_imageWidget, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)));
|
2010-07-15 16:44:53 +02:00
|
|
|
|
|
|
|
|
return m_imageWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-30 14:30:19 +02:00
|
|
|
QWidget *ContextPaneWidget::createBorderImageWidget()
|
|
|
|
|
{
|
|
|
|
|
m_borderImageWidget = new ContextPaneWidgetImage(this, true);
|
|
|
|
|
connect(m_borderImageWidget, SIGNAL(propertyChanged(QString,QVariant)), this, SIGNAL(propertyChanged(QString,QVariant)));
|
|
|
|
|
connect(m_borderImageWidget, SIGNAL(removeProperty(QString)), this, SIGNAL(removeProperty(QString)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_borderImageWidget, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)));
|
2010-07-30 14:30:19 +02:00
|
|
|
|
|
|
|
|
return m_borderImageWidget;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:44:53 +02:00
|
|
|
QWidget *ContextPaneWidget::createRectangleWidget()
|
|
|
|
|
{
|
|
|
|
|
m_rectangleWidget = new ContextPaneWidgetRectangle(this);
|
|
|
|
|
connect(m_rectangleWidget, SIGNAL(propertyChanged(QString,QVariant)), this, SIGNAL(propertyChanged(QString,QVariant)));
|
|
|
|
|
connect(m_rectangleWidget, SIGNAL(removeProperty(QString)), this, SIGNAL(removeProperty(QString)));
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_rectangleWidget, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)));
|
2010-07-15 16:44:53 +02:00
|
|
|
|
|
|
|
|
return m_rectangleWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 12:48:00 +02:00
|
|
|
void ContextPaneWidget::setPinButton()
|
|
|
|
|
{
|
|
|
|
|
m_toolButton->setAutoRaise(true);
|
|
|
|
|
m_pinned = true;
|
|
|
|
|
|
|
|
|
|
m_toolButton->setIcon(QPixmap::fromImage(QImage(pin_xpm)));
|
|
|
|
|
m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
2010-08-04 14:02:51 +02:00
|
|
|
m_toolButton->setFixedSize(20, 20);
|
2010-09-01 11:54:00 +02:00
|
|
|
m_toolButton->setToolTip(tr("Unpins the toolbar and moves it to the default position."));
|
2010-08-03 12:48:00 +02:00
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
pinnedChanged(true);
|
2010-08-03 12:48:00 +02:00
|
|
|
if (m_resetAction) {
|
|
|
|
|
m_resetAction->blockSignals(true);
|
|
|
|
|
m_resetAction->setChecked(true);
|
|
|
|
|
m_resetAction->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContextPaneWidget::setLineButton()
|
|
|
|
|
{
|
|
|
|
|
m_pinned = false;
|
|
|
|
|
m_toolButton->setAutoRaise(true);
|
2010-08-17 15:40:46 +02:00
|
|
|
m_toolButton->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
|
2010-08-03 12:48:00 +02:00
|
|
|
m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
2010-08-04 14:02:51 +02:00
|
|
|
m_toolButton->setFixedSize(20, 20);
|
2010-09-15 15:16:13 +02:00
|
|
|
m_toolButton->setToolTip(tr("Hides this toolbar. This toolbar can be"
|
|
|
|
|
" permanently disabled in the options page or in the context menu."));
|
2010-08-03 12:48:00 +02:00
|
|
|
|
2010-08-12 15:43:13 +02:00
|
|
|
pinnedChanged(false);
|
2010-08-03 12:48:00 +02:00
|
|
|
if (m_resetAction) {
|
|
|
|
|
m_resetAction->blockSignals(true);
|
|
|
|
|
m_resetAction->setChecked(false);
|
|
|
|
|
m_resetAction->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-06 11:05:43 +02:00
|
|
|
|
|
|
|
|
} //QmlDesigner
|
|
|
|
|
|
|
|
|
|
|