Creating lib: qmleditorwidgets
The library qmleditorwidgets contains widgets and image resources what are shared between QuickToolBar and QmlDesigner This library is created to make QuickToolBar independent from QmlDesigner plugin. All the widgets I moved to qmleditorwidgets are removed from QmlDesigner in this patch
@@ -10,5 +10,7 @@ SUBDIRS = \
|
|||||||
utils/process_stub.pro \
|
utils/process_stub.pro \
|
||||||
cplusplus \
|
cplusplus \
|
||||||
qmljs \
|
qmljs \
|
||||||
|
qmljsdebugger \
|
||||||
|
qmleditorwidgets \
|
||||||
symbianutils \
|
symbianutils \
|
||||||
3rdparty
|
3rdparty
|
||||||
|
|||||||
240
src/libs/qmleditorwidgets/colorbox.cpp
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "colorbox.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
static inline QString properName(const QColor &color)
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
if (color.alpha() == 255)
|
||||||
|
s.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
|
||||||
|
else
|
||||||
|
s.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline QColor properColor(const QString &str)
|
||||||
|
{
|
||||||
|
if (str.isEmpty())
|
||||||
|
return QColor();
|
||||||
|
int lalpha = 255;
|
||||||
|
QString lcolorStr = str;
|
||||||
|
if (lcolorStr.at(0) == '#' && lcolorStr.length() == 9) {
|
||||||
|
QString alphaStr = lcolorStr;
|
||||||
|
alphaStr.truncate(3);
|
||||||
|
lcolorStr.remove(0, 3);
|
||||||
|
lcolorStr = "#" + lcolorStr;
|
||||||
|
alphaStr.remove(0,1);
|
||||||
|
bool v;
|
||||||
|
lalpha = alphaStr.toInt(&v, 16);
|
||||||
|
if (!v)
|
||||||
|
lalpha = 255;
|
||||||
|
}
|
||||||
|
QColor lcolor(lcolorStr);
|
||||||
|
if (lcolorStr.contains('#'))
|
||||||
|
lcolor.setAlpha(lalpha);
|
||||||
|
return lcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int clamp(int x, int lower, int upper)
|
||||||
|
{
|
||||||
|
if (x < lower)
|
||||||
|
x = lower;
|
||||||
|
if (x > upper)
|
||||||
|
x = upper;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
void ColorBox::setHue(int newHue)
|
||||||
|
{
|
||||||
|
if (m_color.hsvHue() == newHue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
m_color.setHsv(newHue,m_color.hsvSaturation(),m_color.value());
|
||||||
|
m_color.setAlpha(oldAlpha);
|
||||||
|
update();
|
||||||
|
emit hueChanged();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ColorBox::hue() const
|
||||||
|
{
|
||||||
|
int retval = m_color.hsvHue();
|
||||||
|
if (retval<0) retval=0;
|
||||||
|
if (retval>359) retval=359;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setAlpha(int newAlpha)
|
||||||
|
{
|
||||||
|
if (m_color.alpha() == newAlpha)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_color.setAlpha(newAlpha);
|
||||||
|
update();
|
||||||
|
emit alphaChanged();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ColorBox::strColor() const
|
||||||
|
{
|
||||||
|
return properName(m_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setStrColor(const QString &colorStr)
|
||||||
|
{
|
||||||
|
if (properName(m_color) == colorStr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setColor(properColor(colorStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
if (m_color == color)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int oldsaturation = m_color.hsvSaturation();
|
||||||
|
int oldvalue = m_color.value();
|
||||||
|
int oldhue = m_color.hsvHue();
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
m_color=color;
|
||||||
|
update();
|
||||||
|
if (oldhue != m_color.hsvHue()) emit hueChanged();
|
||||||
|
if (oldsaturation != saturation()) emit saturationChanged();
|
||||||
|
if (oldvalue != value()) emit valueChanged();
|
||||||
|
if (oldAlpha != alpha()) emit alphaChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setSaturation(int newsaturation)
|
||||||
|
{
|
||||||
|
if (m_color.hsvSaturation()==newsaturation) return;
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
m_color.setHsv(m_color.hsvHue(),newsaturation,m_color.value());
|
||||||
|
m_color.setAlpha(oldAlpha);
|
||||||
|
update();
|
||||||
|
emit saturationChanged();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setCurrent(int x, int y)
|
||||||
|
{
|
||||||
|
QColor newColor;
|
||||||
|
x = clamp(x, 0, 120);
|
||||||
|
y = clamp(y, 0, 120);
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
newColor.setHsv(hue(), (x*255) / 120, 255 - (y*255) / 120);
|
||||||
|
newColor.setAlpha(oldAlpha);
|
||||||
|
setColor(newColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::setValue(int newvalue)
|
||||||
|
{
|
||||||
|
if (m_color.value()==newvalue) return;
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
m_color.setHsv(m_color.hsvHue(),m_color.hsvSaturation(),newvalue);
|
||||||
|
m_color.setAlpha(oldAlpha);
|
||||||
|
update();
|
||||||
|
emit valueChanged();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(event);
|
||||||
|
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
if ((m_color.saturation()>1) && (m_color.value()>1))
|
||||||
|
m_saturatedColor.setHsv(m_color.hsvHue(),255,255);
|
||||||
|
|
||||||
|
if ((hue() != m_lastHue) || (m_cache.isNull())) {
|
||||||
|
m_lastHue = hue();
|
||||||
|
|
||||||
|
int fixedHue = clamp(m_lastHue, 0, 359);
|
||||||
|
|
||||||
|
m_cache = QPixmap(120, 120);
|
||||||
|
|
||||||
|
int height = 120;
|
||||||
|
int width = 120;
|
||||||
|
|
||||||
|
QPainter chacheP(&m_cache);
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
for (int x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
QColor c;
|
||||||
|
c.setHsv(fixedHue, (x*255) / width, 255 - (y*255) / height);
|
||||||
|
chacheP.setPen(c);
|
||||||
|
chacheP.drawPoint(x ,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.drawPixmap(5, 5, m_cache);
|
||||||
|
|
||||||
|
int x = clamp(m_color.hsvSaturationF() * 120, 0, 119) + 5;
|
||||||
|
int y = clamp(120 - m_color.valueF() * 120, 0, 119) + 5;
|
||||||
|
|
||||||
|
p.setPen(QColor(255, 255, 255, 50));
|
||||||
|
p.drawLine(5, y, x-1, y);
|
||||||
|
p.drawLine(x+1, y, width()-7, y);
|
||||||
|
p.drawLine(x, 5, x, y-1);
|
||||||
|
p.drawLine(x, y+1, x, height()-7);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
// The current cell marker is set to the cell the mouse is pressed in
|
||||||
|
QPoint pos = e->pos();
|
||||||
|
m_mousePressed = true;
|
||||||
|
setCurrent(pos.x() - 5, pos.y() - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::mouseReleaseEvent(QMouseEvent * /* event */)
|
||||||
|
{
|
||||||
|
if (m_mousePressed)
|
||||||
|
emit colorChanged();
|
||||||
|
m_mousePressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorBox::mouseMoveEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (!m_mousePressed)
|
||||||
|
return;
|
||||||
|
QPoint pos = e->pos();
|
||||||
|
setCurrent(pos.x() - 5, pos.y() - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
98
src/libs/qmleditorwidgets/colorbox.h
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 COLORBOX_H
|
||||||
|
#define COLORBOX_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <qdeclarative.h>
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT ColorBox : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString strColor READ strColor WRITE setStrColor NOTIFY colorChanged)
|
||||||
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
|
Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged)
|
||||||
|
Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
|
||||||
|
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
|
||||||
|
Q_PROPERTY(int alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorBox(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_saturatedColor(Qt::white), m_lastHue(0)
|
||||||
|
{
|
||||||
|
setFixedWidth(130);
|
||||||
|
setFixedHeight(130);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHue(int newHue);
|
||||||
|
int hue() const;
|
||||||
|
void setAlpha(int newAlpha);
|
||||||
|
int alpha() const { return m_color.alpha(); }
|
||||||
|
void setStrColor(const QString &colorStr);
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
QString strColor() const;
|
||||||
|
QColor color() const { return m_color; }
|
||||||
|
int saturation() const { return m_color.hsvSaturation(); }
|
||||||
|
void setSaturation(int newsaturation);
|
||||||
|
int value() const { return m_color.value(); }
|
||||||
|
void setValue(int newvalue);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorChanged();
|
||||||
|
void hueChanged();
|
||||||
|
void saturationChanged();
|
||||||
|
void valueChanged();
|
||||||
|
void alphaChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
void setCurrent(int x, int y);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_color;
|
||||||
|
QColor m_saturatedColor;
|
||||||
|
bool m_mousePressed;
|
||||||
|
int m_lastHue;
|
||||||
|
QPixmap m_cache;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
QML_DECLARE_TYPE(QmlEditorWidgets::ColorBox);
|
||||||
|
|
||||||
|
#endif //COLORBOX_H
|
||||||
152
src/libs/qmleditorwidgets/colorbutton.cpp
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "colorbutton.h"
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
static inline QPixmap tilePixMap(int size)
|
||||||
|
{
|
||||||
|
const int checkerbordSize= size;
|
||||||
|
QPixmap tilePixmap(checkerbordSize * 2, checkerbordSize * 2);
|
||||||
|
tilePixmap.fill(Qt::white);
|
||||||
|
QPainter tilePainter(&tilePixmap);
|
||||||
|
QColor color(220, 220, 220);
|
||||||
|
tilePainter.fillRect(0, 0, checkerbordSize, checkerbordSize, color);
|
||||||
|
tilePainter.fillRect(checkerbordSize, checkerbordSize, checkerbordSize, checkerbordSize, color);
|
||||||
|
return tilePixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool isColorString(const QString &colorString)
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
if (colorString.size() == 9 && colorString.at(0) == QLatin1Char('#')) {
|
||||||
|
// #rgba
|
||||||
|
for (int i = 1; i < 9; ++i) {
|
||||||
|
const QChar c = colorString.at(i);
|
||||||
|
if ((c >= QLatin1Char('0') && c <= QLatin1Char('9'))
|
||||||
|
|| (c >= QLatin1Char('a') && c <= QLatin1Char('f'))
|
||||||
|
|| (c >= QLatin1Char('A') && c <= QLatin1Char('F')))
|
||||||
|
continue;
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ok = QColor::isValidColor(colorString);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline QColor properColor(const QString &str)
|
||||||
|
{
|
||||||
|
if (str.isEmpty())
|
||||||
|
return QColor();
|
||||||
|
int lalpha = 255;
|
||||||
|
QString lcolorStr = str;
|
||||||
|
if (lcolorStr.at(0) == '#' && lcolorStr.length() == 9) {
|
||||||
|
QString alphaStr = lcolorStr;
|
||||||
|
alphaStr.truncate(3);
|
||||||
|
lcolorStr.remove(0, 3);
|
||||||
|
lcolorStr = "#" + lcolorStr;
|
||||||
|
alphaStr.remove(0,1);
|
||||||
|
bool v;
|
||||||
|
lalpha = alphaStr.toInt(&v, 16);
|
||||||
|
if (!v)
|
||||||
|
lalpha = 255;
|
||||||
|
}
|
||||||
|
QColor lcolor(lcolorStr);
|
||||||
|
if (lcolorStr.contains('#'))
|
||||||
|
lcolor.setAlpha(lalpha);
|
||||||
|
return lcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
void ColorButton::setColor(const QString &colorStr)
|
||||||
|
{
|
||||||
|
if (m_colorString == colorStr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
setEnabled(isColorString(colorStr));
|
||||||
|
|
||||||
|
m_colorString = colorStr;
|
||||||
|
update();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor ColorButton::convertedColor() const
|
||||||
|
{
|
||||||
|
return properColor(m_colorString);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorButton::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QToolButton::paintEvent(event);
|
||||||
|
if (!isEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QColor color = properColor(m_colorString);
|
||||||
|
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
|
||||||
|
QRect r(0, 0, width() - 2, height() - 2);
|
||||||
|
p.drawTiledPixmap(r.adjusted(1, 1, -1, -1), tilePixMap(9));
|
||||||
|
if (isEnabled())
|
||||||
|
p.setBrush(color);
|
||||||
|
else
|
||||||
|
p.setBrush(Qt::transparent);
|
||||||
|
|
||||||
|
if (color.value() > 80)
|
||||||
|
p.setPen(QColor(0x444444));
|
||||||
|
else
|
||||||
|
p.setPen(QColor(0x9e9e9e));
|
||||||
|
p.drawRect(r.translated(1, 1));
|
||||||
|
|
||||||
|
if (m_showArrow) {
|
||||||
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
QVector<QPointF> points;
|
||||||
|
if (isChecked()) {
|
||||||
|
points.append(QPointF(2, 3));
|
||||||
|
points.append(QPointF(8, 3));
|
||||||
|
points.append(QPointF(5, 9));
|
||||||
|
} else {
|
||||||
|
points.append(QPointF(8, 6));
|
||||||
|
points.append(QPointF(2, 9));
|
||||||
|
points.append(QPointF(2, 3));
|
||||||
|
}
|
||||||
|
p.translate(0.5, 0.5);
|
||||||
|
p.setBrush(QColor(0xaaaaaa));
|
||||||
|
p.setPen(QColor(0x444444));
|
||||||
|
p.drawPolygon(points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
74
src/libs/qmleditorwidgets/colorbutton.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 COLORBUTTON_H
|
||||||
|
#define COLORBUTTON_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <qdeclarative.h>
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT ColorButton : public QToolButton {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
|
Q_PROPERTY(bool noColor READ noColor WRITE setNoColor)
|
||||||
|
Q_PROPERTY(bool showArrow READ showArrow WRITE setShowArrow)
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorButton(QWidget *parent = 0) : QToolButton (parent), m_colorString("#ffffff"), m_noColor(false), m_showArrow(true) {}
|
||||||
|
|
||||||
|
void setColor(const QString &colorStr);
|
||||||
|
QString color() const { return m_colorString; }
|
||||||
|
QColor convertedColor() const;
|
||||||
|
bool noColor() const { return m_noColor; }
|
||||||
|
void setNoColor(bool f) { m_noColor = f; update(); }
|
||||||
|
bool showArrow() const { return m_showArrow; }
|
||||||
|
void setShowArrow(bool b) { m_showArrow = b; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
private:
|
||||||
|
QString m_colorString;
|
||||||
|
bool m_noColor;
|
||||||
|
bool m_showArrow;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
QML_DECLARE_TYPE(QmlEditorWidgets::ColorButton);
|
||||||
|
|
||||||
|
#endif //COLORBUTTON_H
|
||||||
47
src/libs/qmleditorwidgets/colorwidget.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "colorwidget.h"
|
||||||
|
#include <qdeclarative.h>
|
||||||
|
|
||||||
|
#include "colorbox.h"
|
||||||
|
#include "colorbutton.h"
|
||||||
|
#include "huecontrol.h"
|
||||||
|
#include "gradientline.h"
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
void ColorWidget::registerDeclarativeTypes() {
|
||||||
|
qmlRegisterType<QmlEditorWidgets::ColorButton>("Bauhaus",1,0,"ColorButton");
|
||||||
|
qmlRegisterType<QmlEditorWidgets::HueControl>("Bauhaus",1,0,"HueControl");
|
||||||
|
qmlRegisterType<QmlEditorWidgets::ColorBox>("Bauhaus",1,0,"ColorBox");
|
||||||
|
qmlRegisterType<QmlEditorWidgets::GradientLine>("Bauhaus",1,0,"GradientLine");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
58
src/libs/qmleditorwidgets/colorwidget.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 COLORWIDGET_H
|
||||||
|
#define COLORWIDGET_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QWeakPointer>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QToolButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class ColorWidget {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void registerDeclarativeTypes();
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} //QmlDesigner
|
||||||
|
|
||||||
|
#endif //COLORWIDGET_H
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="6">
|
<item row="0" column="6">
|
||||||
<widget class="QmlDesigner::FontSizeSpinBox" name="fontSizeSpinBox">
|
<widget class="QmlEditorWidgets::FontSizeSpinBox" name="fontSizeSpinBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -337,7 +337,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QmlDesigner::ColorButton" name="textColorButton">
|
<widget class="QmlEditorWidgets::ColorButton" name="textColorButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>22</horstretch>
|
<horstretch>22</horstretch>
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="4">
|
||||||
<widget class="QmlDesigner::ColorButton" name="colorButton">
|
<widget class="QmlEditorWidgets::ColorButton" name="colorButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>22</horstretch>
|
<horstretch>22</horstretch>
|
||||||
@@ -412,12 +412,12 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QmlDesigner::ColorButton</class>
|
<class>QmlEditorWidgets::ColorButton</class>
|
||||||
<extends>QToolButton</extends>
|
<extends>QToolButton</extends>
|
||||||
<header location="global">colorwidget.h</header>
|
<header location="global">colorbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QmlDesigner::FontSizeSpinBox</class>
|
<class>QmlEditorWidgets::FontSizeSpinBox</class>
|
||||||
<extends>QSpinBox</extends>
|
<extends>QSpinBox</extends>
|
||||||
<header location="global">fontsizespinbox.h</header>
|
<header location="global">fontsizespinbox.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
@@ -1,10 +1,40 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "contextpanetextwidget.h"
|
#include "contextpanetextwidget.h"
|
||||||
#include "contextpanewidget.h"
|
#include "contextpanewidget.h"
|
||||||
|
#include "customcolordialog.h"
|
||||||
#include "ui_contextpanetext.h"
|
#include "ui_contextpanetext.h"
|
||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
ContextPaneTextWidget::ContextPaneTextWidget(QWidget *parent) :
|
ContextPaneTextWidget::ContextPaneTextWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@@ -1,6 +1,36 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 CONTEXTPANETEXTWIDGET_H
|
#ifndef CONTEXTPANETEXTWIDGET_H
|
||||||
#define CONTEXTPANETEXTWIDGET_H
|
#define CONTEXTPANETEXTWIDGET_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@@ -14,11 +44,11 @@ namespace QmlJS {
|
|||||||
class PropertyReader;
|
class PropertyReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
class BauhausColorDialog;
|
class CustomColorDialog;
|
||||||
|
|
||||||
class ContextPaneTextWidget : public QWidget
|
class QMLEDITORWIDGETS_EXPORT ContextPaneTextWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -1,5 +1,33 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "contextpanewidget.h"
|
#include "contextpanewidget.h"
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <QFontComboBox>
|
#include <QFontComboBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
@@ -11,14 +39,15 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <qmldesignerplugin.h>
|
|
||||||
#include "colorwidget.h"
|
#include "colorwidget.h"
|
||||||
#include "contextpanetextwidget.h"
|
#include "contextpanetextwidget.h"
|
||||||
#include "easingcontextpane.h"
|
#include "easingcontextpane.h"
|
||||||
#include "contextpanewidgetimage.h"
|
#include "contextpanewidgetimage.h"
|
||||||
#include "contextpanewidgetrectangle.h"
|
#include "contextpanewidgetrectangle.h"
|
||||||
|
#include "customcolordialog.h"
|
||||||
|
#include "colorbutton.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
/* XPM */
|
/* XPM */
|
||||||
static const char * const line_xpm[] = {
|
static const char * const line_xpm[] = {
|
||||||
@@ -137,11 +166,6 @@ ContextPaneWidget::ContextPaneWidget(QWidget *parent) : DragWidget(parent), m_cu
|
|||||||
m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
m_toolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||||
m_toolButton->setFixedSize(16, 16);
|
m_toolButton->setFixedSize(16, 16);
|
||||||
|
|
||||||
if (Internal::BauhausPlugin::pluginInstance()->settings().pinContextPane)
|
|
||||||
setPinButton();
|
|
||||||
else
|
|
||||||
setLineButton();
|
|
||||||
|
|
||||||
m_toolButton->setToolTip(tr("Hides this toolbar. This toolbar can be permantly disabled in the options or in the context menu."));
|
m_toolButton->setToolTip(tr("Hides this toolbar. This toolbar can be permantly disabled in the options or in the context menu."));
|
||||||
connect(m_toolButton, SIGNAL(clicked()), this, SLOT(onTogglePane()));
|
connect(m_toolButton, SIGNAL(clicked()), this, SLOT(onTogglePane()));
|
||||||
layout->addWidget(m_toolButton, 0, 0, 1, 1);
|
layout->addWidget(m_toolButton, 0, 0, 1, 1);
|
||||||
@@ -182,7 +206,7 @@ ContextPaneWidget::~ContextPaneWidget()
|
|||||||
m_bauhausColorDialog.clear();
|
m_bauhausColorDialog.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2)
|
void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2, bool pinned)
|
||||||
{
|
{
|
||||||
//uncheck all color buttons
|
//uncheck all color buttons
|
||||||
foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
|
foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
|
||||||
@@ -192,13 +216,11 @@ void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, c
|
|||||||
update();
|
update();
|
||||||
resize(sizeHint());
|
resize(sizeHint());
|
||||||
show();
|
show();
|
||||||
rePosition(pos, alternative, alternative2);
|
rePosition(pos, alternative, alternative2, pinned);
|
||||||
raise();
|
raise();
|
||||||
m_resetAction->setChecked(Internal::BauhausPlugin::pluginInstance()->settings().pinContextPane);
|
|
||||||
m_disableAction->setChecked(Internal::BauhausPlugin::pluginInstance()->settings().enableContextPane);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative, const QPoint &alternative2)
|
void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alternative, const QPoint &alternative2, bool pinned)
|
||||||
{
|
{
|
||||||
if ((position.x() + width()) < parentWidget()->width())
|
if ((position.x() + width()) < parentWidget()->width())
|
||||||
move(position);
|
move(position);
|
||||||
@@ -212,7 +234,7 @@ void ContextPaneWidget::rePosition(const QPoint &position, const QPoint &alterna
|
|||||||
|
|
||||||
m_originalPos = pos();
|
m_originalPos = pos();
|
||||||
|
|
||||||
if (m_pos.x() > 0 && (Internal::BauhausPlugin::pluginInstance()->settings().pinContextPane)) {
|
if (m_pos.x() > 0 && pinned) {
|
||||||
move(m_pos);
|
move(m_pos);
|
||||||
show();
|
show();
|
||||||
setPinButton();
|
setPinButton();
|
||||||
@@ -228,10 +250,17 @@ void ContextPaneWidget::deactivate()
|
|||||||
m_bauhausColorDialog->hide();
|
m_bauhausColorDialog->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
BauhausColorDialog *ContextPaneWidget::colorDialog()
|
void ContextPaneWidget::setOptions(bool enabled, bool pinned)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_disableAction->setChecked(enabled);
|
||||||
|
m_resetAction->setChecked(pinned);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomColorDialog *ContextPaneWidget::colorDialog()
|
||||||
{
|
{
|
||||||
if (m_bauhausColorDialog.isNull()) {
|
if (m_bauhausColorDialog.isNull()) {
|
||||||
m_bauhausColorDialog = new BauhausColorDialog(parentWidget());
|
m_bauhausColorDialog = new CustomColorDialog(parentWidget());
|
||||||
m_bauhausColorDialog->hide();
|
m_bauhausColorDialog->hide();
|
||||||
setSecondaryTarget(m_bauhausColorDialog.data());
|
setSecondaryTarget(m_bauhausColorDialog.data());
|
||||||
}
|
}
|
||||||
@@ -351,9 +380,7 @@ void ContextPaneWidget::onShowColorDialog(bool checked, const QPoint &p)
|
|||||||
|
|
||||||
void ContextPaneWidget::onDisable(bool b)
|
void ContextPaneWidget::onDisable(bool b)
|
||||||
{
|
{
|
||||||
DesignerSettings designerSettings = Internal::BauhausPlugin::pluginInstance()->settings();
|
enabledChanged(b);
|
||||||
designerSettings.enableContextPane = b;
|
|
||||||
Internal::BauhausPlugin::pluginInstance()->setSettings(designerSettings);
|
|
||||||
if (!b) {
|
if (!b) {
|
||||||
hide();
|
hide();
|
||||||
colorDialog()->hide();
|
colorDialog()->hide();
|
||||||
@@ -438,9 +465,7 @@ void ContextPaneWidget::setPinButton()
|
|||||||
m_toolButton->setFixedSize(20, 20);
|
m_toolButton->setFixedSize(20, 20);
|
||||||
m_toolButton->setToolTip(tr("Unpins the toolbar. The toolbar will be moved to its default position."));
|
m_toolButton->setToolTip(tr("Unpins the toolbar. The toolbar will be moved to its default position."));
|
||||||
|
|
||||||
DesignerSettings designerSettings = Internal::BauhausPlugin::pluginInstance()->settings();
|
pinnedChanged(true);
|
||||||
designerSettings.pinContextPane = true;
|
|
||||||
Internal::BauhausPlugin::pluginInstance()->setSettings(designerSettings);
|
|
||||||
if (m_resetAction) {
|
if (m_resetAction) {
|
||||||
m_resetAction->blockSignals(true);
|
m_resetAction->blockSignals(true);
|
||||||
m_resetAction->setChecked(true);
|
m_resetAction->setChecked(true);
|
||||||
@@ -457,9 +482,7 @@ void ContextPaneWidget::setLineButton()
|
|||||||
m_toolButton->setFixedSize(20, 20);
|
m_toolButton->setFixedSize(20, 20);
|
||||||
m_toolButton->setToolTip(tr("Hides this toolbar. This toolbar can be permantly disabled in the options or in the context menu."));
|
m_toolButton->setToolTip(tr("Hides this toolbar. This toolbar can be permantly disabled in the options or in the context menu."));
|
||||||
|
|
||||||
DesignerSettings designerSettings = Internal::BauhausPlugin::pluginInstance()->settings();
|
pinnedChanged(false);
|
||||||
designerSettings.pinContextPane = false;
|
|
||||||
Internal::BauhausPlugin::pluginInstance()->setSettings(designerSettings);
|
|
||||||
if (m_resetAction) {
|
if (m_resetAction) {
|
||||||
m_resetAction->blockSignals(true);
|
m_resetAction->blockSignals(true);
|
||||||
m_resetAction->setChecked(false);
|
m_resetAction->setChecked(false);
|
||||||
@@ -1,6 +1,36 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 CONTEXTPANEWIDGET_H
|
#ifndef CONTEXTPANEWIDGET_H
|
||||||
#define CONTEXTPANEWIDGET_H
|
#define CONTEXTPANEWIDGET_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QGraphicsEffect>
|
#include <QGraphicsEffect>
|
||||||
@@ -11,15 +41,15 @@ namespace QmlJS {
|
|||||||
class PropertyReader;
|
class PropertyReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
class BauhausColorDialog;
|
class CustomColorDialog;
|
||||||
class ContextPaneTextWidget;
|
class ContextPaneTextWidget;
|
||||||
class EasingContextPane;
|
class EasingContextPane;
|
||||||
class ContextPaneWidgetRectangle;
|
class ContextPaneWidgetRectangle;
|
||||||
class ContextPaneWidgetImage;
|
class ContextPaneWidgetImage;
|
||||||
|
|
||||||
class DragWidget : public QFrame
|
class QMLEDITORWIDGETS_EXPORT DragWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -42,17 +72,18 @@ private:
|
|||||||
QWeakPointer<QWidget> m_secondaryTarget;
|
QWeakPointer<QWidget> m_secondaryTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContextPaneWidget : public DragWidget
|
class QMLEDITORWIDGETS_EXPORT ContextPaneWidget : public DragWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ContextPaneWidget(QWidget *parent = 0);
|
explicit ContextPaneWidget(QWidget *parent = 0);
|
||||||
~ContextPaneWidget();
|
~ContextPaneWidget();
|
||||||
void activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2);
|
void activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2, bool pinned);
|
||||||
void rePosition(const QPoint &pos, const QPoint &alternative , const QPoint &alternative3);
|
void rePosition(const QPoint &pos, const QPoint &alternative , const QPoint &alternative3, bool pinned);
|
||||||
void deactivate();
|
void deactivate();
|
||||||
BauhausColorDialog *colorDialog();
|
void setOptions(bool enabled, bool pinned);
|
||||||
|
CustomColorDialog *colorDialog();
|
||||||
void setProperties(QmlJS::PropertyReader *propertyReader);
|
void setProperties(QmlJS::PropertyReader *propertyReader);
|
||||||
void setPath(const QString &path);
|
void setPath(const QString &path);
|
||||||
bool setType(const QStringList &types);
|
bool setType(const QStringList &types);
|
||||||
@@ -67,6 +98,8 @@ signals:
|
|||||||
void propertyChanged(const QString &, const QVariant &);
|
void propertyChanged(const QString &, const QVariant &);
|
||||||
void removeProperty(const QString &);
|
void removeProperty(const QString &);
|
||||||
void removeAndChangeProperty(const QString &, const QString &, const QVariant &, bool);
|
void removeAndChangeProperty(const QString &, const QString &, const QVariant &, bool);
|
||||||
|
void pinnedChanged(bool);
|
||||||
|
void enabledChanged(bool);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDisable(bool);
|
void onDisable(bool);
|
||||||
@@ -93,7 +126,7 @@ private:
|
|||||||
ContextPaneWidgetImage *m_imageWidget;
|
ContextPaneWidgetImage *m_imageWidget;
|
||||||
ContextPaneWidgetImage *m_borderImageWidget;
|
ContextPaneWidgetImage *m_borderImageWidget;
|
||||||
ContextPaneWidgetRectangle *m_rectangleWidget;
|
ContextPaneWidgetRectangle *m_rectangleWidget;
|
||||||
QWeakPointer<BauhausColorDialog> m_bauhausColorDialog;
|
QWeakPointer<CustomColorDialog> m_bauhausColorDialog;
|
||||||
QWeakPointer<QAction> m_resetAction;
|
QWeakPointer<QAction> m_resetAction;
|
||||||
QWeakPointer<QAction> m_disableAction;
|
QWeakPointer<QAction> m_disableAction;
|
||||||
QString m_colorName;
|
QString m_colorName;
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="FileWidget" name="fileWidget">
|
<widget class="QmlEditorWidgets::FileWidget" name="fileWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -298,7 +298,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>FileWidget</class>
|
<class>QmlEditorWidgets::FileWidget</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header location="global">filewidget.h</header>
|
<header location="global">filewidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
@@ -1,3 +1,32 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "contextpanewidgetimage.h"
|
#include "contextpanewidgetimage.h"
|
||||||
#include "ui_contextpanewidgetimage.h"
|
#include "ui_contextpanewidgetimage.h"
|
||||||
#include "ui_contextpanewidgetborderimage.h"
|
#include "ui_contextpanewidgetborderimage.h"
|
||||||
@@ -11,7 +40,7 @@
|
|||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
bool LabelFilter::eventFilter(QObject *obj, QEvent *event)
|
bool LabelFilter::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,36 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 CONTEXTPANEWIDGETIMAGE_H
|
#ifndef CONTEXTPANEWIDGETIMAGE_H
|
||||||
#define CONTEXTPANEWIDGETIMAGE_H
|
#define CONTEXTPANEWIDGETIMAGE_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -14,14 +44,15 @@ namespace Ui {
|
|||||||
}
|
}
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class FileWidget;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
class PropertyReader;
|
class PropertyReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class FileWidget;
|
||||||
|
|
||||||
class PreviewLabel : public QLabel
|
class PreviewLabel : public QLabel
|
||||||
{
|
{
|
||||||
@@ -90,7 +121,7 @@ private:
|
|||||||
bool m_borderImage;
|
bool m_borderImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContextPaneWidgetImage : public QWidget
|
class QMLEDITORWIDGETS_EXPORT ContextPaneWidgetImage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1" colspan="3">
|
<item row="0" column="1" colspan="3">
|
||||||
<widget class="FileWidget" name="fileWidget">
|
<widget class="QmlEditorWidgets::FileWidget" name="fileWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>FileWidget</class>
|
<class>QmlEditorWidgets::FileWidget</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header location="global">filewidget.h</header>
|
<header location="global">filewidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
@@ -1,10 +1,40 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "contextpanewidgetrectangle.h"
|
#include "contextpanewidgetrectangle.h"
|
||||||
#include "ui_contextpanewidgetrectangle.h"
|
#include "ui_contextpanewidgetrectangle.h"
|
||||||
#include "contextpanewidget.h"
|
#include "contextpanewidget.h"
|
||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
|
#include <customcolordialog.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
ContextPaneWidgetRectangle::ContextPaneWidgetRectangle(QWidget *parent) :
|
ContextPaneWidgetRectangle::ContextPaneWidgetRectangle(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@@ -1,6 +1,36 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 CONTEXTPANEWIDGETRECTANGLE_H
|
#ifndef CONTEXTPANEWIDGETRECTANGLE_H
|
||||||
#define CONTEXTPANEWIDGETRECTANGLE_H
|
#define CONTEXTPANEWIDGETRECTANGLE_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -13,9 +43,9 @@ namespace QmlJS {
|
|||||||
class PropertyReader;
|
class PropertyReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
class ContextPaneWidgetRectangle : public QWidget
|
class QMLEDITORWIDGETS_EXPORT ContextPaneWidgetRectangle : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="5">
|
<item row="0" column="1" colspan="5">
|
||||||
<widget class="QmlDesigner::GradientLine" name="gradientLine" native="true">
|
<widget class="QmlEditorWidgets::GradientLine" name="gradientLine" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>160</width>
|
<width>160</width>
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QmlDesigner::ColorButton" name="colorColorButton">
|
<widget class="QmlEditorWidgets::ColorButton" name="colorColorButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>22</width>
|
<width>22</width>
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QmlDesigner::ColorButton" name="borderColorButton">
|
<widget class="QmlEditorWidgets::ColorButton" name="borderColorButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>22</width>
|
<width>22</width>
|
||||||
@@ -296,14 +296,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QmlDesigner::ColorButton</class>
|
<class>QmlEditorWidgets::ColorButton</class>
|
||||||
<extends>QToolButton</extends>
|
<extends>QToolButton</extends>
|
||||||
<header location="global">colorwidget.h</header>
|
<header location="global">colorbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QmlDesigner::GradientLine</class>
|
<class>QmlEditorWidgets::GradientLine</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header location="global">colorwidget.h</header>
|
<header location="global">gradientline.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
180
src/libs/qmleditorwidgets/customcolordialog.cpp
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "customcolordialog.h"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QGraphicsEffect>
|
||||||
|
#include "huecontrol.h"
|
||||||
|
#include "colorbox.h"
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent )
|
||||||
|
{
|
||||||
|
|
||||||
|
setFrameStyle(QFrame::NoFrame);
|
||||||
|
setFrameShape(QFrame::StyledPanel);
|
||||||
|
setFrameShadow(QFrame::Sunken);
|
||||||
|
|
||||||
|
QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect;
|
||||||
|
dropShadowEffect->setBlurRadius(6);
|
||||||
|
dropShadowEffect->setOffset(2, 2);
|
||||||
|
setGraphicsEffect(dropShadowEffect);
|
||||||
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
|
m_hueControl = new HueControl(this);
|
||||||
|
m_colorBox = new ColorBox(this);
|
||||||
|
|
||||||
|
QWidget *colorFrameWidget = new QWidget(this);
|
||||||
|
QVBoxLayout* vBox = new QVBoxLayout(colorFrameWidget);
|
||||||
|
colorFrameWidget->setLayout(vBox);
|
||||||
|
vBox->setSpacing(0);
|
||||||
|
vBox->setMargin(0);
|
||||||
|
vBox->setContentsMargins(0,5,0,28);
|
||||||
|
|
||||||
|
m_beforeColorWidget = new QFrame(colorFrameWidget);
|
||||||
|
m_beforeColorWidget->setFixedSize(30, 18);
|
||||||
|
m_beforeColorWidget->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
m_currentColorWidget = new QFrame(colorFrameWidget);
|
||||||
|
m_currentColorWidget->setFixedSize(30, 18);
|
||||||
|
m_currentColorWidget->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
vBox->addWidget(m_beforeColorWidget);
|
||||||
|
vBox->addWidget(m_currentColorWidget);
|
||||||
|
|
||||||
|
|
||||||
|
m_rSpinBox = new QDoubleSpinBox(this);
|
||||||
|
m_gSpinBox = new QDoubleSpinBox(this);
|
||||||
|
m_bSpinBox = new QDoubleSpinBox(this);
|
||||||
|
m_alphaSpinBox = new QDoubleSpinBox(this);
|
||||||
|
|
||||||
|
QGridLayout *gridLayout = new QGridLayout(this);
|
||||||
|
gridLayout->setSpacing(4);
|
||||||
|
gridLayout->setVerticalSpacing(4);
|
||||||
|
gridLayout->setMargin(4);
|
||||||
|
setLayout(gridLayout);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_colorBox, 0, 0, 4, 1);
|
||||||
|
gridLayout->addWidget(m_hueControl, 0, 1, 4, 1);
|
||||||
|
|
||||||
|
gridLayout->addWidget(colorFrameWidget, 0, 2, 2, 1);
|
||||||
|
|
||||||
|
gridLayout->addWidget(new QLabel("R", this), 0, 3, 1, 1);
|
||||||
|
gridLayout->addWidget(new QLabel("G", this), 1, 3, 1, 1);
|
||||||
|
gridLayout->addWidget(new QLabel("B", this), 2, 3, 1, 1);
|
||||||
|
gridLayout->addWidget(new QLabel("A", this), 3, 3, 1, 1);
|
||||||
|
|
||||||
|
gridLayout->addWidget(m_rSpinBox, 0, 4, 1, 1);
|
||||||
|
gridLayout->addWidget(m_gSpinBox, 1, 4, 1, 1);
|
||||||
|
gridLayout->addWidget(m_bSpinBox, 2, 4, 1, 1);
|
||||||
|
gridLayout->addWidget(m_alphaSpinBox, 3, 4, 1, 1);
|
||||||
|
|
||||||
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
|
||||||
|
|
||||||
|
QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||||
|
QPushButton *applyButton = buttonBox->addButton(QDialogButtonBox::Apply);
|
||||||
|
|
||||||
|
gridLayout->addWidget(buttonBox, 4, 0, 1, 2);
|
||||||
|
|
||||||
|
resize(sizeHint());
|
||||||
|
|
||||||
|
connect(m_colorBox, SIGNAL(colorChanged()), this, SLOT(onColorBoxChanged()));
|
||||||
|
connect(m_alphaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
|
||||||
|
connect(m_rSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
|
||||||
|
connect(m_gSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
|
||||||
|
connect(m_bSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged()));
|
||||||
|
connect(m_hueControl, SIGNAL(hueChanged(int)), this, SLOT(onHueChanged(int)));
|
||||||
|
|
||||||
|
connect(applyButton, SIGNAL(pressed()), this, SLOT(onAccept()));
|
||||||
|
connect(cancelButton, SIGNAL(pressed()), this, SIGNAL(rejected()));
|
||||||
|
|
||||||
|
m_alphaSpinBox->setMaximum(1);
|
||||||
|
m_rSpinBox->setMaximum(1);
|
||||||
|
m_gSpinBox->setMaximum(1);
|
||||||
|
m_bSpinBox->setMaximum(1);
|
||||||
|
m_alphaSpinBox->setSingleStep(0.1);
|
||||||
|
m_rSpinBox->setSingleStep(0.1);
|
||||||
|
m_gSpinBox->setSingleStep(0.1);
|
||||||
|
m_bSpinBox->setSingleStep(0.1);
|
||||||
|
|
||||||
|
m_blockUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorDialog::setupColor(const QColor &color)
|
||||||
|
{
|
||||||
|
QPalette pal = m_beforeColorWidget->palette();
|
||||||
|
pal.setColor(QPalette::Background, color);
|
||||||
|
m_beforeColorWidget->setPalette(pal);
|
||||||
|
setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorDialog::spinBoxChanged()
|
||||||
|
{
|
||||||
|
if (m_blockUpdate)
|
||||||
|
return;
|
||||||
|
QColor newColor;
|
||||||
|
newColor.setAlphaF(m_alphaSpinBox->value());
|
||||||
|
newColor.setRedF(m_rSpinBox->value());
|
||||||
|
newColor.setGreenF(m_gSpinBox->value());
|
||||||
|
newColor.setBlueF(m_bSpinBox->value());
|
||||||
|
setColor(newColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorDialog::onColorBoxChanged()
|
||||||
|
{
|
||||||
|
if (m_blockUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setColor(m_colorBox->color());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomColorDialog::setupWidgets()
|
||||||
|
{
|
||||||
|
m_blockUpdate = true;
|
||||||
|
m_hueControl->setHue(m_color.hsvHue());
|
||||||
|
m_alphaSpinBox->setValue(m_color.alphaF());
|
||||||
|
m_rSpinBox->setValue(m_color.redF());
|
||||||
|
m_gSpinBox->setValue(m_color.greenF());
|
||||||
|
m_bSpinBox->setValue(m_color.blueF());
|
||||||
|
m_colorBox->setColor(m_color);
|
||||||
|
QPalette pal = m_currentColorWidget->palette();
|
||||||
|
pal.setColor(QPalette::Background, m_color);
|
||||||
|
m_currentColorWidget->setPalette(pal);
|
||||||
|
m_blockUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
110
src/libs/qmleditorwidgets/customcolordialog.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 CUSTOMCOLORDIALOG_H
|
||||||
|
#define CUSTOMCOLORDIALOG_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class ColorBox;
|
||||||
|
class HueControl;
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT CustomColorDialog : public QFrame {
|
||||||
|
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
CustomColorDialog(QWidget *parent = 0);
|
||||||
|
QColor color() const { return m_color; }
|
||||||
|
void setupColor(const QColor &color);
|
||||||
|
void setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
if (color == m_color)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_color = color;
|
||||||
|
setupWidgets();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void changeColor(const QColor &color) { setColor(color); }
|
||||||
|
void spinBoxChanged();
|
||||||
|
void onColorBoxChanged();
|
||||||
|
void onHueChanged(int newHue)
|
||||||
|
{
|
||||||
|
if (m_blockUpdate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_color.hsvHue() == newHue)
|
||||||
|
return;
|
||||||
|
m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
|
||||||
|
setupWidgets();
|
||||||
|
emit colorChanged();
|
||||||
|
}
|
||||||
|
void onAccept()
|
||||||
|
{
|
||||||
|
emit accepted(m_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void colorChanged();
|
||||||
|
void accepted(const QColor &color);
|
||||||
|
void rejected();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setupWidgets();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QFrame *m_beforeColorWidget;
|
||||||
|
QFrame *m_currentColorWidget;
|
||||||
|
ColorBox *m_colorBox;
|
||||||
|
HueControl *m_hueControl;
|
||||||
|
|
||||||
|
QDoubleSpinBox *m_rSpinBox;
|
||||||
|
QDoubleSpinBox *m_gSpinBox;
|
||||||
|
QDoubleSpinBox *m_bSpinBox;
|
||||||
|
QDoubleSpinBox *m_alphaSpinBox;
|
||||||
|
|
||||||
|
QColor m_color;
|
||||||
|
bool m_blockUpdate;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
#endif //CUSTOMCOLORDIALOG_H
|
||||||
@@ -1,3 +1,32 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "easingcontextpane.h"
|
#include "easingcontextpane.h"
|
||||||
#include "ui_easingcontextpane.h"
|
#include "ui_easingcontextpane.h"
|
||||||
#include <qmljs/qmljspropertyreader.h>
|
#include <qmljs/qmljspropertyreader.h>
|
||||||
@@ -7,7 +36,7 @@
|
|||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QSequentialAnimationGroup>
|
#include <QSequentialAnimationGroup>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
class PixmapItem : public QObject, public QGraphicsPixmapItem
|
class PixmapItem : public QObject, public QGraphicsPixmapItem
|
||||||
{
|
{
|
||||||
@@ -269,13 +298,13 @@ void EasingContextPane::setBounce()
|
|||||||
|
|
||||||
} //QmlDesigner
|
} //QmlDesigner
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_durationSpinBox_valueChanged(int newValue)
|
void QmlEditorWidgets::EasingContextPane::on_durationSpinBox_valueChanged(int newValue)
|
||||||
{
|
{
|
||||||
m_simulation->updateCurve(m_easingGraph->easingCurve(),ui->durationSpinBox->value());
|
m_simulation->updateCurve(m_easingGraph->easingCurve(),ui->durationSpinBox->value());
|
||||||
emit propertyChanged(QLatin1String("duration"), newValue);
|
emit propertyChanged(QLatin1String("duration"), newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_easingShapeComboBox_currentIndexChanged(QString newShape)
|
void QmlEditorWidgets::EasingContextPane::on_easingShapeComboBox_currentIndexChanged(QString newShape)
|
||||||
{
|
{
|
||||||
if (newShape=="Linear")
|
if (newShape=="Linear")
|
||||||
setLinear();
|
setLinear();
|
||||||
@@ -299,7 +328,7 @@ void QmlDesigner::EasingContextPane::on_easingShapeComboBox_currentIndexChanged(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_easingExtremesComboBox_currentIndexChanged(QString newExtremes)
|
void QmlEditorWidgets::EasingContextPane::on_easingExtremesComboBox_currentIndexChanged(QString newExtremes)
|
||||||
{
|
{
|
||||||
if (m_easingGraph->easingExtremes() != newExtremes) {
|
if (m_easingGraph->easingExtremes() != newExtremes) {
|
||||||
m_easingGraph->setEasingExtremes(newExtremes);
|
m_easingGraph->setEasingExtremes(newExtremes);
|
||||||
@@ -311,7 +340,7 @@ void QmlDesigner::EasingContextPane::on_easingExtremesComboBox_currentIndexChang
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_amplitudeSpinBox_valueChanged(double newAmplitude)
|
void QmlEditorWidgets::EasingContextPane::on_amplitudeSpinBox_valueChanged(double newAmplitude)
|
||||||
{
|
{
|
||||||
if ((newAmplitude != m_easingGraph->amplitude()) &&
|
if ((newAmplitude != m_easingGraph->amplitude()) &&
|
||||||
(m_easingGraph->easingShape()=="Bounce" || m_easingGraph->easingShape()=="Elastic")) {
|
(m_easingGraph->easingShape()=="Bounce" || m_easingGraph->easingShape()=="Elastic")) {
|
||||||
@@ -321,7 +350,7 @@ void QmlDesigner::EasingContextPane::on_amplitudeSpinBox_valueChanged(double new
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_periodSpinBox_valueChanged(double newPeriod)
|
void QmlEditorWidgets::EasingContextPane::on_periodSpinBox_valueChanged(double newPeriod)
|
||||||
{
|
{
|
||||||
if ((newPeriod != m_easingGraph->period()) && (m_easingGraph->easingShape()=="Elastic")) {
|
if ((newPeriod != m_easingGraph->period()) && (m_easingGraph->easingShape()=="Elastic")) {
|
||||||
m_easingGraph->setPeriod(newPeriod);
|
m_easingGraph->setPeriod(newPeriod);
|
||||||
@@ -331,7 +360,7 @@ void QmlDesigner::EasingContextPane::on_periodSpinBox_valueChanged(double newPer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_overshootSpinBox_valueChanged(double newOvershoot)
|
void QmlEditorWidgets::EasingContextPane::on_overshootSpinBox_valueChanged(double newOvershoot)
|
||||||
{
|
{
|
||||||
if ((newOvershoot != m_easingGraph->overshoot()) && (m_easingGraph->easingShape()=="Back")) {
|
if ((newOvershoot != m_easingGraph->overshoot()) && (m_easingGraph->easingShape()=="Back")) {
|
||||||
m_easingGraph->setOvershoot(newOvershoot);
|
m_easingGraph->setOvershoot(newOvershoot);
|
||||||
@@ -340,7 +369,7 @@ void QmlDesigner::EasingContextPane::on_overshootSpinBox_valueChanged(double new
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesigner::EasingContextPane::on_playButton_clicked()
|
void QmlEditorWidgets::EasingContextPane::on_playButton_clicked()
|
||||||
{
|
{
|
||||||
setGraphDisplayMode(SimulationMode);
|
setGraphDisplayMode(SimulationMode);
|
||||||
startAnimation();
|
startAnimation();
|
||||||
@@ -1,3 +1,32 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 EASINGCONTEXTPANE_H
|
#ifndef EASINGCONTEXTPANE_H
|
||||||
#define EASINGCONTEXTPANE_H
|
#define EASINGCONTEXTPANE_H
|
||||||
|
|
||||||
@@ -17,7 +46,7 @@ namespace QmlJS {
|
|||||||
class PropertyReader;
|
class PropertyReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
class EasingSimulation;
|
class EasingSimulation;
|
||||||
|
|
||||||
class EasingContextPane : public QWidget
|
class EasingContextPane : public QWidget
|
||||||
@@ -1,3 +1,32 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "easinggraph.h"
|
#include "easinggraph.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -1,3 +1,32 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 EASINGGRAPH_H
|
#ifndef EASINGGRAPH_H
|
||||||
#define EASINGGRAPH_H
|
#define EASINGGRAPH_H
|
||||||
|
|
||||||
11
src/libs/qmleditorwidgets/easingpane/easingpane.pri
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
VPATH += $$PWD
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
SOURCES += $$PWD/easinggraph.cpp \
|
||||||
|
$$PWD/easingcontextpane.cpp
|
||||||
|
|
||||||
|
HEADERS += $$PWD/easinggraph.h \
|
||||||
|
$$PWD/easingcontextpane.h
|
||||||
|
|
||||||
|
QT += declarative
|
||||||
|
RESOURCES += $$PWD/easingpane.qrc
|
||||||
|
FORMS += $$PWD/easingcontextpane.ui
|
||||||
|
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 194 B |
142
src/libs/qmleditorwidgets/filewidget.cpp
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "filewidget.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
FileWidget::FileWidget(QWidget *parent) : QWidget(parent), m_filter("(*.*)"), m_showComboBox(false), m_lock(false)
|
||||||
|
{
|
||||||
|
m_pushButton = new QToolButton(this);
|
||||||
|
m_pushButton->setFixedWidth(32);
|
||||||
|
m_lineEdit = new QLineEdit(this);
|
||||||
|
m_comboBox = new QComboBox(this);
|
||||||
|
m_comboBox->hide();
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||||
|
setLayout(layout);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(m_lineEdit);
|
||||||
|
layout->addWidget(m_comboBox);
|
||||||
|
m_comboBox->setEditable(true);
|
||||||
|
layout->addWidget(m_pushButton);
|
||||||
|
m_pushButton->setText("...");
|
||||||
|
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(lineEditChanged()));
|
||||||
|
connect(m_pushButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
|
||||||
|
connect(m_comboBox, SIGNAL(editTextChanged(const QString &)), this, SLOT(comboBoxChanged()));
|
||||||
|
m_currentPath = QDir::currentPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWidget::~FileWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::setShowComboBox(bool show)
|
||||||
|
{
|
||||||
|
m_showComboBox = show;
|
||||||
|
m_comboBox->setVisible(show);
|
||||||
|
m_lineEdit->setVisible(!show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::lineEditChanged()
|
||||||
|
{
|
||||||
|
if (m_lock)
|
||||||
|
return;
|
||||||
|
setFileNameStr(m_lineEdit->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::comboBoxChanged()
|
||||||
|
{
|
||||||
|
if (m_lock)
|
||||||
|
return;
|
||||||
|
setFileNameStr(m_comboBox->currentText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::buttonPressed()
|
||||||
|
{
|
||||||
|
QString path = m_currentPath;
|
||||||
|
QString newFile = QFileDialog::getOpenFileName(0, tr("Open File"), path, m_filter);
|
||||||
|
if (!newFile.isEmpty())
|
||||||
|
setFileNameStr(newFile);
|
||||||
|
|
||||||
|
m_currentPath = QFileInfo(newFile).absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::setFileNameStr(const QString &fileName)
|
||||||
|
{
|
||||||
|
setFileName(QUrl(fileName));
|
||||||
|
}
|
||||||
|
void FileWidget::setFileName(const QUrl &fileName)
|
||||||
|
{
|
||||||
|
if (fileName == m_fileName)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_fileName = fileName;
|
||||||
|
if (m_lineEdit->text() != fileName.toString()) {
|
||||||
|
m_lineEdit->setText(fileName.toString());
|
||||||
|
m_lineEdit->setToolTip(m_fileName.toString());
|
||||||
|
}
|
||||||
|
if (m_comboBox->currentText() != fileName.toString()) {
|
||||||
|
m_comboBox->setEditText(m_fileName.toString());
|
||||||
|
m_comboBox->setToolTip(m_fileName.toString());
|
||||||
|
}
|
||||||
|
emit fileNameChanged(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileWidget::setupComboBox()
|
||||||
|
{
|
||||||
|
m_lock = true;
|
||||||
|
m_comboBox->clear();
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
|
||||||
|
|
||||||
|
if (m_path.isValid())
|
||||||
|
dir = QDir(m_path.toLocalFile());
|
||||||
|
|
||||||
|
QStringList filterList = m_filter.split(' ');
|
||||||
|
|
||||||
|
QDirIterator it(dir.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QString absolutePath = it.next();
|
||||||
|
m_comboBox->addItem(dir.relativeFilePath(absolutePath));
|
||||||
|
}
|
||||||
|
m_comboBox->setEditText(m_fileName.toString());
|
||||||
|
|
||||||
|
m_lock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
|
||||||
123
src/libs/qmleditorwidgets/filewidget.h
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 FILEWIDGET_H
|
||||||
|
#define FILEWIDGET_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT FileWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
|
Q_PROPERTY(QString fileName READ fileName WRITE setFileNameStr NOTIFY fileNameChanged)
|
||||||
|
Q_PROPERTY(QString filter READ filter WRITE setFilter)
|
||||||
|
Q_PROPERTY(bool showComboBox READ showComboBox WRITE setShowComboBox)
|
||||||
|
Q_PROPERTY(QUrl path READ path WRITE setPath)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
FileWidget(QWidget *parent = 0);
|
||||||
|
~FileWidget();
|
||||||
|
|
||||||
|
QString fileName() const
|
||||||
|
{ return m_fileName.toString(); }
|
||||||
|
|
||||||
|
void setText(const QString &/*text*/)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPath(const QUrl &url) { m_path = url; setupComboBox(); }
|
||||||
|
|
||||||
|
QUrl path() const { return m_path; }
|
||||||
|
|
||||||
|
QString text() const
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFilter(const QString &filter)
|
||||||
|
{
|
||||||
|
m_filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString filter() const
|
||||||
|
{
|
||||||
|
return m_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setShowComboBox(bool show);
|
||||||
|
|
||||||
|
bool showComboBox() const
|
||||||
|
{ return m_showComboBox; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setFileName(const QUrl &fileName);
|
||||||
|
void setFileNameStr(const QString &fileName);
|
||||||
|
void buttonPressed();
|
||||||
|
void lineEditChanged();
|
||||||
|
void comboBoxChanged();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileNameChanged(const QUrl &fileName);
|
||||||
|
void itemNodeChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void setupComboBox();
|
||||||
|
|
||||||
|
QToolButton *m_pushButton;
|
||||||
|
QLineEdit *m_lineEdit;
|
||||||
|
QComboBox *m_comboBox;
|
||||||
|
QUrl m_fileName;
|
||||||
|
QUrl m_path;
|
||||||
|
QString m_filter;
|
||||||
|
bool m_showComboBox;
|
||||||
|
bool m_lock;
|
||||||
|
QString m_currentPath;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -1,9 +1,38 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
#include "fontsizespinbox.h"
|
#include "fontsizespinbox.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegExpValidator>
|
#include <QRegExpValidator>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
FontSizeSpinBox::FontSizeSpinBox(QWidget *parent) :
|
FontSizeSpinBox::FontSizeSpinBox(QWidget *parent) :
|
||||||
QAbstractSpinBox(parent), m_isPointSize(true), m_value(0)
|
QAbstractSpinBox(parent), m_isPointSize(true), m_value(0)
|
||||||
@@ -1,11 +1,41 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 FONTSIZESPINBOX_H
|
#ifndef FONTSIZESPINBOX_H
|
||||||
#define FONTSIZESPINBOX_H
|
#define FONTSIZESPINBOX_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
#include <QAbstractSpinBox>
|
#include <QAbstractSpinBox>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
class FontSizeSpinBox : public QAbstractSpinBox
|
class QMLEDITORWIDGETS_EXPORT FontSizeSpinBox : public QAbstractSpinBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
354
src/libs/qmleditorwidgets/gradientline.cpp
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "gradientline.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
static inline QPixmap tilePixMap(int size)
|
||||||
|
{
|
||||||
|
const int checkerbordSize= size;
|
||||||
|
QPixmap tilePixmap(checkerbordSize * 2, checkerbordSize * 2);
|
||||||
|
tilePixmap.fill(Qt::white);
|
||||||
|
QPainter tilePainter(&tilePixmap);
|
||||||
|
QColor color(220, 220, 220);
|
||||||
|
tilePainter.fillRect(0, 0, checkerbordSize, checkerbordSize, color);
|
||||||
|
tilePainter.fillRect(checkerbordSize, checkerbordSize, checkerbordSize, checkerbordSize, color);
|
||||||
|
return tilePixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
void GradientLine::setGradient(const QLinearGradient &gradient)
|
||||||
|
{
|
||||||
|
m_gradient = gradient;
|
||||||
|
m_useGradient = true;
|
||||||
|
setupGradient();
|
||||||
|
emit gradientChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline QColor invertColor(const QColor color)
|
||||||
|
{
|
||||||
|
QColor c = color.toHsv();
|
||||||
|
c.setHsv(c.hue(), c.saturation(), 255 - c.value());
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
GradientLine::GradientLine(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
m_activeColor(Qt::black),
|
||||||
|
m_gradientName("gradient"),
|
||||||
|
m_colorIndex(0),
|
||||||
|
m_dragActive(false),
|
||||||
|
m_yOffset(0),
|
||||||
|
m_create(false),
|
||||||
|
m_active(false),
|
||||||
|
m_dragOff(false),
|
||||||
|
m_useGradient(true)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||||
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
setFixedHeight(50);
|
||||||
|
setMinimumWidth(160);
|
||||||
|
resize(160, 50);
|
||||||
|
m_colorList << m_activeColor << QColor(Qt::white);
|
||||||
|
m_stops << 0 << 1;
|
||||||
|
updateGradient();
|
||||||
|
setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::setGradientName(const QString &newName)
|
||||||
|
{
|
||||||
|
if (newName == m_gradientName)
|
||||||
|
return;
|
||||||
|
m_gradientName = newName;
|
||||||
|
setup();
|
||||||
|
emit gradientNameChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::setActiveColor(const QColor &newColor)
|
||||||
|
{
|
||||||
|
if (newColor.name() == m_activeColor.name() && newColor.alpha() == m_activeColor.alpha())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_activeColor = newColor;
|
||||||
|
m_colorList.removeAt(currentColorIndex());
|
||||||
|
m_colorList.insert(currentColorIndex(), m_activeColor);
|
||||||
|
updateGradient();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::setupGradient()
|
||||||
|
{
|
||||||
|
if (m_useGradient) {
|
||||||
|
m_colorList.clear();
|
||||||
|
m_stops.clear();
|
||||||
|
foreach (const QGradientStop &stop, m_gradient.stops()) {
|
||||||
|
m_stops << stop.first;
|
||||||
|
m_colorList << stop.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateGradient();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GradientLine::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::ShortcutOverride)
|
||||||
|
if (static_cast<QKeyEvent*>(event)->matches(QKeySequence::Delete)) {
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QWidget::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::keyPressEvent(QKeyEvent * event)
|
||||||
|
{
|
||||||
|
if (event->matches(QKeySequence::Delete)) {
|
||||||
|
if ((currentColorIndex()) != 0 && (currentColorIndex() < m_stops.size() - 1)) {
|
||||||
|
m_dragActive = false;
|
||||||
|
m_stops.removeAt(currentColorIndex());
|
||||||
|
m_colorList.removeAt(currentColorIndex());
|
||||||
|
updateGradient();
|
||||||
|
setCurrentIndex(0);
|
||||||
|
//delete item
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(event);
|
||||||
|
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
if (!isEnabled()) {
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(QColor(0x444444));
|
||||||
|
p.drawRect(9, 31, width() - 14, height() - 32);
|
||||||
|
|
||||||
|
p.drawTiledPixmap(10, 32, width() - 16, height() - 34, tilePixMap(8));
|
||||||
|
} else {
|
||||||
|
|
||||||
|
QLinearGradient linearGradient(QPointF(0, 0), QPointF(width(), 0));
|
||||||
|
|
||||||
|
for (int i =0; i < m_stops.size(); i++)
|
||||||
|
linearGradient.setColorAt(m_stops.at(i), m_colorList.at(i));
|
||||||
|
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(QColor(0x444444));
|
||||||
|
p.drawRect(9, 31, width() - 14, height() - 32);
|
||||||
|
|
||||||
|
|
||||||
|
p.drawTiledPixmap(9, 31, width() - 16, height() - 34, tilePixMap(8));
|
||||||
|
|
||||||
|
p.setBrush(linearGradient);
|
||||||
|
p.setPen(QColor(0x222222));
|
||||||
|
p.drawRect(8, 30, width() - 14, height() - 32);
|
||||||
|
p.setPen(QColor(255, 255, 255, 40));
|
||||||
|
p.drawRect(9, 31, width() - 16, height() - 34);
|
||||||
|
|
||||||
|
p.setPen(Qt::black);
|
||||||
|
|
||||||
|
for (int i =0; i < m_colorList.size(); i++) {
|
||||||
|
int localYOffset = 0;
|
||||||
|
QColor arrowColor(Qt::black);
|
||||||
|
if (i == currentColorIndex()) {
|
||||||
|
localYOffset = m_yOffset;
|
||||||
|
arrowColor = QColor(0x909090);
|
||||||
|
}
|
||||||
|
p.setPen(arrowColor);
|
||||||
|
if (i == 0 || i == (m_colorList.size() - 1))
|
||||||
|
localYOffset = 0;
|
||||||
|
|
||||||
|
int pos = qreal((width() - 16)) * m_stops.at(i) + 9;
|
||||||
|
p.setBrush(arrowColor);
|
||||||
|
QVector<QPointF> points;
|
||||||
|
points.append(QPointF(pos + 0.5, 28.5 + localYOffset)); //triangle
|
||||||
|
points.append(QPointF(pos - 3.5, 22.5 + localYOffset));
|
||||||
|
points.append(QPointF(pos + 4.5, 22.5 + localYOffset));
|
||||||
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
p.drawPolygon(points);
|
||||||
|
p.setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(QColor(0x424242));
|
||||||
|
p.drawRect(pos - 4, 9 + localYOffset, 10, 11);
|
||||||
|
|
||||||
|
p.drawTiledPixmap(pos - 4, 9 + localYOffset, 9, 10, tilePixMap(5));
|
||||||
|
p.setPen(QColor(0x424242));
|
||||||
|
p.setBrush(m_colorList.at(i));
|
||||||
|
p.drawRect(pos - 5, 8 + localYOffset, 10, 11);
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(QColor(255, 255, 255, 30));
|
||||||
|
p.drawRect(pos - 4, 9 + localYOffset, 8, 9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
event->accept();
|
||||||
|
int xPos = event->pos().x();
|
||||||
|
int yPos = event->pos().y();
|
||||||
|
|
||||||
|
int draggedIndex = -1;
|
||||||
|
m_create = false;
|
||||||
|
m_dragActive = false;
|
||||||
|
if ((yPos > 10) && (yPos < 30))
|
||||||
|
for (int i =0; i < m_stops.size(); i++) {
|
||||||
|
int pos = qreal((width() - 16)) * m_stops.at(i) + 9;
|
||||||
|
if (((xPos + 5) > pos) && ((xPos - 5) < pos)) {
|
||||||
|
draggedIndex = i;
|
||||||
|
m_dragActive = true;
|
||||||
|
m_dragStart = event->pos();
|
||||||
|
setCurrentIndex(draggedIndex);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (draggedIndex == -1)
|
||||||
|
m_create = true;
|
||||||
|
}
|
||||||
|
setFocus(Qt::MouseFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
m_dragActive = false;
|
||||||
|
m_create = false;
|
||||||
|
emit openColorDialog(event->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
event->accept();
|
||||||
|
if (m_dragActive == false && m_create) {
|
||||||
|
qreal stopPos = qreal(event->pos().x() - 9) / qreal((width() - 15));
|
||||||
|
int index = -1;
|
||||||
|
for (int i =0; i < m_stops.size() - 1; i++) {
|
||||||
|
if ((stopPos > m_stops.at(i)) && (index == -1))
|
||||||
|
index = i +1;
|
||||||
|
}
|
||||||
|
if (index != -1 && (m_useGradient)) { //creating of items only in base state
|
||||||
|
m_stops.insert(index, stopPos);
|
||||||
|
m_colorList.insert(index, QColor(Qt::white));
|
||||||
|
setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_dragActive = false;
|
||||||
|
m_yOffset = 0;
|
||||||
|
updateGradient();
|
||||||
|
update();
|
||||||
|
setFocus(Qt::MouseFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_dragActive) {
|
||||||
|
event->accept();
|
||||||
|
int xPos = event->pos().x();
|
||||||
|
int pos = qreal((width() - 20)) * m_stops.at(currentColorIndex()) + 8;
|
||||||
|
int offset = m_dragOff ? 2 : 20;
|
||||||
|
if (xPos < pos + offset && xPos > pos - offset) {
|
||||||
|
m_dragOff = false;
|
||||||
|
int xDistance = event->pos().x() - m_dragStart.x();
|
||||||
|
qreal distance = qreal(xDistance) / qreal((width() - 20));
|
||||||
|
qreal newStop = m_stops.at(currentColorIndex()) + distance;
|
||||||
|
if ((newStop >=0) && (newStop <= 1))
|
||||||
|
m_stops[currentColorIndex()] = newStop;
|
||||||
|
m_yOffset += event->pos().y() - m_dragStart.y();
|
||||||
|
if (m_yOffset > 0 || m_useGradient) { //deleting only in base state
|
||||||
|
m_yOffset = 0;
|
||||||
|
} else if ((m_yOffset < - 12) && (currentColorIndex()) != 0 && (currentColorIndex() < m_stops.size() - 1)) {
|
||||||
|
m_yOffset = 0;
|
||||||
|
m_dragActive = false;
|
||||||
|
m_stops.removeAt(currentColorIndex());
|
||||||
|
m_colorList.removeAt(currentColorIndex());
|
||||||
|
updateGradient();
|
||||||
|
setCurrentIndex(0);
|
||||||
|
//delete item
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_dragOff = true;
|
||||||
|
}
|
||||||
|
m_dragStart = event->pos();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline QColor normalizeColor(const QColor &color)
|
||||||
|
{
|
||||||
|
QColor newColor = QColor(color.name());
|
||||||
|
newColor.setAlpha(color.alpha());
|
||||||
|
return newColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline qreal roundReal(qreal real)
|
||||||
|
{
|
||||||
|
int i = real * 100;
|
||||||
|
return qreal(i) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::updateGradient()
|
||||||
|
{
|
||||||
|
if (m_useGradient) {
|
||||||
|
QGradientStops stops;
|
||||||
|
for (int i = 0;i < m_stops.size(); i++) {
|
||||||
|
stops.append(QPair<qreal, QColor>(m_stops.at(i), m_colorList.at(i)));
|
||||||
|
}
|
||||||
|
m_gradient.setStops(stops);
|
||||||
|
emit gradientChanged();
|
||||||
|
} else {
|
||||||
|
if (!active())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GradientLine::setCurrentIndex(int i)
|
||||||
|
{
|
||||||
|
if (i == m_colorIndex)
|
||||||
|
return;
|
||||||
|
m_colorIndex = i;
|
||||||
|
m_activeColor = m_colorList.at(i);
|
||||||
|
emit activeColorChanged();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
101
src/libs/qmleditorwidgets/gradientline.h
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 GRADIENTLINE_H
|
||||||
|
#define GRADIENTLINE_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QLinearGradient>
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT GradientLine : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged)
|
||||||
|
Q_PROPERTY(QString gradientName READ gradientName WRITE setGradientName NOTIFY gradientNameChanged)
|
||||||
|
Q_PROPERTY(bool active READ active WRITE setActive)
|
||||||
|
Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
GradientLine(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QString gradientName() const { return m_gradientName; }
|
||||||
|
void setGradientName(const QString &newName);
|
||||||
|
QColor activeColor() const { return m_activeColor; }
|
||||||
|
void setActiveColor(const QColor &newColor);
|
||||||
|
bool active() const { return m_active; }
|
||||||
|
void setActive(bool a) { m_active = a; }
|
||||||
|
QLinearGradient gradient() const { return m_gradient; }
|
||||||
|
void setGradient(const QLinearGradient &);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setupGradient();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void activeColorChanged();
|
||||||
|
void itemNodeChanged();
|
||||||
|
void gradientNameChanged();
|
||||||
|
void gradientChanged();
|
||||||
|
void openColorDialog(const QPoint &pos);
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *event);
|
||||||
|
void keyPressEvent(QKeyEvent * event);
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setup();
|
||||||
|
void updateGradient();
|
||||||
|
int currentColorIndex() const { return m_colorIndex; }
|
||||||
|
void setCurrentIndex(int i);
|
||||||
|
|
||||||
|
QColor m_activeColor;
|
||||||
|
QString m_gradientName;
|
||||||
|
QList<QColor> m_colorList;
|
||||||
|
QList<qreal> m_stops;
|
||||||
|
int m_colorIndex;
|
||||||
|
bool m_dragActive;
|
||||||
|
QPoint m_dragStart;
|
||||||
|
QLinearGradient m_gradient;
|
||||||
|
int m_yOffset;
|
||||||
|
bool m_create;
|
||||||
|
bool m_active;
|
||||||
|
bool m_dragOff;
|
||||||
|
bool m_useGradient;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
#endif //GRADIENTLINE_H
|
||||||
127
src/libs/qmleditorwidgets/huecontrol.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "huecontrol.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
static inline int clamp(int x, int lower, int upper)
|
||||||
|
{
|
||||||
|
if (x < lower)
|
||||||
|
x = lower;
|
||||||
|
if (x > upper)
|
||||||
|
x = upper;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
void HueControl::setCurrent(int y)
|
||||||
|
{
|
||||||
|
y = clamp(y, 0, 120);
|
||||||
|
int oldAlpha = m_color.alpha();
|
||||||
|
m_color.setHsv((y * 359)/120, m_color.hsvSaturation(), m_color.value());
|
||||||
|
m_color.setAlpha(oldAlpha);
|
||||||
|
update(); // redraw pointer
|
||||||
|
emit hueChanged(m_color.hsvHue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void HueControl::setHue(int newHue)
|
||||||
|
{
|
||||||
|
if (m_color.hsvHue() == newHue)
|
||||||
|
return;
|
||||||
|
m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
|
||||||
|
update();
|
||||||
|
emit hueChanged(m_color.hsvHue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void HueControl::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(event);
|
||||||
|
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
int localHeight = 120;
|
||||||
|
|
||||||
|
if (m_cache.isNull()) {
|
||||||
|
m_cache = QPixmap(10, localHeight);
|
||||||
|
|
||||||
|
QPainter cacheP(&m_cache);
|
||||||
|
|
||||||
|
for (int i = 0; i < localHeight; i++)
|
||||||
|
{
|
||||||
|
QColor c;
|
||||||
|
c.setHsv( (i*359) / 120.0, 255,255);
|
||||||
|
cacheP.fillRect(0, i, 10, i + 1, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.drawPixmap(0, 5, m_cache);
|
||||||
|
|
||||||
|
QVector<QPointF> points;
|
||||||
|
|
||||||
|
int y = m_color.hueF() * 120 + 5;
|
||||||
|
|
||||||
|
points.append(QPointF(5, y));
|
||||||
|
points.append(QPointF(15, y + 5));
|
||||||
|
points.append(QPointF(15, y - 5));
|
||||||
|
|
||||||
|
|
||||||
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
p.translate(0.5, 1.5);
|
||||||
|
p.setPen(QColor(0, 0, 0, 120));
|
||||||
|
p.drawPolygon(points);
|
||||||
|
p.translate(0, -1);
|
||||||
|
p.setPen(0x222222);
|
||||||
|
p.setBrush(QColor(0x707070));
|
||||||
|
p.drawPolygon(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HueControl::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
// The current cell marker is set to the cell the mouse is pressed in
|
||||||
|
QPoint pos = e->pos();
|
||||||
|
m_mousePressed = true;
|
||||||
|
setCurrent(pos.y() - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HueControl::mouseReleaseEvent(QMouseEvent * /* event */)
|
||||||
|
{
|
||||||
|
m_mousePressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HueControl::mouseMoveEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (!m_mousePressed)
|
||||||
|
return;
|
||||||
|
QPoint pos = e->pos();
|
||||||
|
setCurrent(pos.y() - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
75
src/libs/qmleditorwidgets/huecontrol.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** 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 HUECONTROL_H
|
||||||
|
#define HUECONTROL_H
|
||||||
|
|
||||||
|
#include <qmleditorwidgets_global.h>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <qdeclarative.h>
|
||||||
|
|
||||||
|
namespace QmlEditorWidgets {
|
||||||
|
|
||||||
|
class QMLEDITORWIDGETS_EXPORT HueControl : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(qreal hue READ hue WRITE setHue NOTIFY hueChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
HueControl(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_mousePressed(false)
|
||||||
|
{
|
||||||
|
setFixedWidth(28);
|
||||||
|
setFixedHeight(130);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHue(int newHue);
|
||||||
|
int hue() const { return m_color.hsvHue(); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void hueChanged(int hue);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *);
|
||||||
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
|
void setCurrent(int y);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_color;
|
||||||
|
bool m_mousePressed;
|
||||||
|
QPixmap m_cache;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlEditorWidgets
|
||||||
|
|
||||||
|
QML_DECLARE_TYPE(QmlEditorWidgets::HueControl);
|
||||||
|
|
||||||
|
#endif //HUECONTROL_H
|
||||||
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 312 B After Width: | Height: | Size: 312 B |
|
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 221 B |
|
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 533 B After Width: | Height: | Size: 533 B |
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 480 B |
|
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 347 B After Width: | Height: | Size: 347 B |
|
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 393 B |
|
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 226 B After Width: | Height: | Size: 226 B |
|
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 540 B |
|
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 420 B After Width: | Height: | Size: 420 B |
|
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 633 B After Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 504 B |
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 893 B |
|
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 367 B |
|
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
|
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 217 B |
|
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 647 B |
|
Before Width: | Height: | Size: 700 B After Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 776 B After Width: | Height: | Size: 776 B |
|
Before Width: | Height: | Size: 571 B After Width: | Height: | Size: 571 B |
|
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 574 B |
|
Before Width: | Height: | Size: 791 B After Width: | Height: | Size: 791 B |
|
Before Width: | Height: | Size: 730 B After Width: | Height: | Size: 730 B |
|
Before Width: | Height: | Size: 808 B After Width: | Height: | Size: 808 B |
|
Before Width: | Height: | Size: 790 B After Width: | Height: | Size: 790 B |
|
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 709 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B |
|
Before Width: | Height: | Size: 970 B After Width: | Height: | Size: 970 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 731 B |
|
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
|
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 731 B |
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 717 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 410 B |