QtBase: examples/widgets/painting code style
Change-Id: I3d3c6f3bae20ac8383279437f8f89c92195a704f Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
parent
92724e533d
commit
cbf3771e86
@ -48,7 +48,10 @@
|
||||
#include <QPolygonF>
|
||||
|
||||
class HoverPoints;
|
||||
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class XFormView : public ArthurFrame
|
||||
{
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(basicdrawing);
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "renderarea.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
//! [0]
|
||||
RenderArea::RenderArea(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
@ -80,4 +80,4 @@ private:
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
||||
#endif // RENDERAREA_H
|
||||
|
@ -38,11 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "renderarea.h"
|
||||
#include "window.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
//! [0]
|
||||
const int IdRole = Qt::UserRole;
|
||||
//! [0]
|
||||
|
@ -84,4 +84,4 @@ private:
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
||||
#endif // WINDOW_H
|
||||
|
@ -162,31 +162,31 @@ CompositionWidget::CompositionWidget(QWidget *parent)
|
||||
#endif
|
||||
|
||||
QGridLayout *modesLayout = new QGridLayout(modesGroup);
|
||||
modesLayout->addWidget(rbClear, 0, 0);
|
||||
modesLayout->addWidget(rbSource, 1, 0);
|
||||
modesLayout->addWidget(rbDest, 2, 0);
|
||||
modesLayout->addWidget(rbSourceOver, 3, 0);
|
||||
modesLayout->addWidget(rbDestOver, 4, 0);
|
||||
modesLayout->addWidget(rbSourceIn, 5, 0);
|
||||
modesLayout->addWidget(rbDestIn, 6, 0);
|
||||
modesLayout->addWidget(rbSourceOut, 7, 0);
|
||||
modesLayout->addWidget(rbDestOut, 8, 0);
|
||||
modesLayout->addWidget(rbSourceAtop, 9, 0);
|
||||
modesLayout->addWidget(rbDestAtop, 10, 0);
|
||||
modesLayout->addWidget(rbXor, 11, 0);
|
||||
modesLayout->addWidget(rbClear, 0, 0);
|
||||
modesLayout->addWidget(rbSource, 1, 0);
|
||||
modesLayout->addWidget(rbDest, 2, 0);
|
||||
modesLayout->addWidget(rbSourceOver, 3, 0);
|
||||
modesLayout->addWidget(rbDestOver, 4, 0);
|
||||
modesLayout->addWidget(rbSourceIn, 5, 0);
|
||||
modesLayout->addWidget(rbDestIn, 6, 0);
|
||||
modesLayout->addWidget(rbSourceOut, 7, 0);
|
||||
modesLayout->addWidget(rbDestOut, 8, 0);
|
||||
modesLayout->addWidget(rbSourceAtop, 9, 0);
|
||||
modesLayout->addWidget(rbDestAtop, 10, 0);
|
||||
modesLayout->addWidget(rbXor, 11, 0);
|
||||
|
||||
modesLayout->addWidget(rbPlus, 0, 1);
|
||||
modesLayout->addWidget(rbMultiply, 1, 1);
|
||||
modesLayout->addWidget(rbScreen, 2, 1);
|
||||
modesLayout->addWidget(rbOverlay, 3, 1);
|
||||
modesLayout->addWidget(rbDarken, 4, 1);
|
||||
modesLayout->addWidget(rbLighten, 5, 1);
|
||||
modesLayout->addWidget(rbColorDodge, 6, 1);
|
||||
modesLayout->addWidget(rbColorBurn, 7, 1);
|
||||
modesLayout->addWidget(rbHardLight, 8, 1);
|
||||
modesLayout->addWidget(rbSoftLight, 9, 1);
|
||||
modesLayout->addWidget(rbDifference, 10, 1);
|
||||
modesLayout->addWidget(rbExclusion, 11, 1);
|
||||
modesLayout->addWidget(rbPlus, 0, 1);
|
||||
modesLayout->addWidget(rbMultiply, 1, 1);
|
||||
modesLayout->addWidget(rbScreen, 2, 1);
|
||||
modesLayout->addWidget(rbOverlay, 3, 1);
|
||||
modesLayout->addWidget(rbDarken, 4, 1);
|
||||
modesLayout->addWidget(rbLighten, 5, 1);
|
||||
modesLayout->addWidget(rbColorDodge, 6, 1);
|
||||
modesLayout->addWidget(rbColorBurn, 7, 1);
|
||||
modesLayout->addWidget(rbHardLight, 8, 1);
|
||||
modesLayout->addWidget(rbSoftLight, 9, 1);
|
||||
modesLayout->addWidget(rbDifference, 10, 1);
|
||||
modesLayout->addWidget(rbExclusion, 11, 1);
|
||||
|
||||
|
||||
QVBoxLayout *circleColorLayout = new QVBoxLayout(circleColorGroup);
|
||||
@ -345,12 +345,10 @@ void CompositionRenderer::paint(QPainter *painter)
|
||||
if (usesOpenGL()) {
|
||||
|
||||
int new_pbuf_size = m_pbuffer_size;
|
||||
if (size().width() > m_pbuffer_size ||
|
||||
size().height() > m_pbuffer_size)
|
||||
if (size().width() > m_pbuffer_size || size().height() > m_pbuffer_size)
|
||||
new_pbuf_size *= 2;
|
||||
|
||||
if (size().width() < m_pbuffer_size/2 &&
|
||||
size().height() < m_pbuffer_size/2)
|
||||
if (size().width() < m_pbuffer_size/2 && size().height() < m_pbuffer_size/2)
|
||||
new_pbuf_size /= 2;
|
||||
|
||||
if (!m_pbuffer || new_pbuf_size != m_pbuffer_size) {
|
||||
@ -488,7 +486,8 @@ void CompositionRenderer::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
void CompositionRenderer::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (m_current_object == Circle) setCirclePos(e->pos() + m_offset);
|
||||
if (m_current_object == Circle)
|
||||
setCirclePos(e->pos() + m_offset);
|
||||
}
|
||||
|
||||
void CompositionRenderer::mouseReleaseEvent(QMouseEvent *)
|
||||
@ -513,10 +512,11 @@ void CompositionRenderer::setCirclePos(const QPointF &pos)
|
||||
m_circle_pos = pos;
|
||||
const QRect newRect = rectangle_around(m_circle_pos).toAlignedRect();
|
||||
#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
|
||||
if (usesOpenGL())
|
||||
if (usesOpenGL()) {
|
||||
update();
|
||||
else
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
update(oldRect | newRect);
|
||||
update(oldRect | newRect);
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,10 @@
|
||||
#include <QPainter>
|
||||
#include <QEvent>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QRadioButton)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPushButton;
|
||||
class QRadioButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#ifdef QT_OPENGL_SUPPORT
|
||||
#include <QtOpenGL>
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <QtOpenGL>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Q_INIT_RESOURCE(deform);
|
||||
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "circlewidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//! [0]
|
||||
@ -111,13 +111,10 @@ void CircleWidget::paintEvent(QPaintEvent *)
|
||||
if (alpha > 0) {
|
||||
painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3));
|
||||
|
||||
if (floatBased) {
|
||||
painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0,
|
||||
diameter, diameter));
|
||||
} else {
|
||||
painter.drawEllipse(QRect(-diameter / 2, -diameter / 2,
|
||||
diameter, diameter));
|
||||
}
|
||||
if (floatBased)
|
||||
painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter));
|
||||
else
|
||||
painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,4 +70,4 @@ private:
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
||||
#endif // CIRCLEWIDGET_H
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
@ -38,11 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "circlewidget.h"
|
||||
#include "window.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
//! [0]
|
||||
Window::Window()
|
||||
{
|
||||
|
@ -67,4 +67,4 @@ private:
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
||||
#endif // WINDOW_H
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "pathdeform.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -53,7 +53,8 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <qmath.h>
|
||||
|
||||
PathDeformControls::PathDeformControls(QWidget *parent, PathDeformRenderer* renderer, bool smallScreen)
|
||||
PathDeformControls::PathDeformControls(QWidget *parent,
|
||||
PathDeformRenderer* renderer, bool smallScreen)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_renderer = renderer;
|
||||
@ -64,7 +65,6 @@ PathDeformControls::PathDeformControls(QWidget *parent, PathDeformRenderer* rend
|
||||
layoutForDesktop();
|
||||
}
|
||||
|
||||
|
||||
void PathDeformControls::layoutForDesktop()
|
||||
{
|
||||
QGroupBox* mainGroup = new QGroupBox(this);
|
||||
@ -223,8 +223,8 @@ void PathDeformControls::layoutForSmallScreen()
|
||||
mainLayout->addWidget(okButton);
|
||||
mainLayout->addWidget(quitButton);
|
||||
|
||||
connect(quitButton, SIGNAL(clicked()), this, SLOT(emitQuitSignal()));
|
||||
connect(okButton, SIGNAL(clicked()), this, SLOT(emitOkSignal()));
|
||||
connect(quitButton, SIGNAL(clicked()), this, SIGNAL(quitPressed()));
|
||||
connect(okButton, SIGNAL(clicked()), this, SIGNAL(okPressed()));
|
||||
connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int)));
|
||||
connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int)));
|
||||
connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int)));
|
||||
@ -244,14 +244,6 @@ void PathDeformControls::layoutForSmallScreen()
|
||||
m_renderer->setText(tr("Qt"));
|
||||
}
|
||||
|
||||
|
||||
void PathDeformControls::emitQuitSignal()
|
||||
{ emit quitPressed(); }
|
||||
|
||||
void PathDeformControls::emitOkSignal()
|
||||
{ emit okPressed(); }
|
||||
|
||||
|
||||
PathDeformWidget::PathDeformWidget(QWidget *parent, bool smallScreen)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -293,14 +285,14 @@ void PathDeformWidget::hideControls()
|
||||
void PathDeformWidget::setStyle( QStyle * style )
|
||||
{
|
||||
QWidget::setStyle(style);
|
||||
if (m_controls != 0)
|
||||
{
|
||||
m_controls->setStyle(style);
|
||||
if (m_controls == 0)
|
||||
return;
|
||||
|
||||
m_controls->setStyle(style);
|
||||
|
||||
QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
|
||||
foreach (QWidget *w, widgets)
|
||||
w->setStyle(style);
|
||||
}
|
||||
QList<QWidget *> widgets = m_controls->findChildren<QWidget *>();
|
||||
foreach (QWidget *w, widgets)
|
||||
w->setStyle(style);
|
||||
}
|
||||
|
||||
static inline QRect circle_bounds(const QPointF ¢er, qreal radius, qreal compensation)
|
||||
@ -445,8 +437,6 @@ void PathDeformRenderer::timerEvent(QTimerEvent *e)
|
||||
|
||||
m_pos += QPointF(dx, dy);
|
||||
|
||||
|
||||
|
||||
if (m_pos.x() - m_radius < 0) {
|
||||
m_direction.setX(-m_direction.x());
|
||||
m_pos.setX(m_radius);
|
||||
@ -565,7 +555,6 @@ QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QP
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
void PathDeformRenderer::paint(QPainter *painter)
|
||||
{
|
||||
int pad_x = 5;
|
||||
@ -611,8 +600,6 @@ void PathDeformRenderer::paint(QPainter *painter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PathDeformRenderer::setRadius(int radius)
|
||||
{
|
||||
qreal max = qMax(m_radius, (qreal)radius);
|
||||
@ -620,13 +607,12 @@ void PathDeformRenderer::setRadius(int radius)
|
||||
generateLensPixmap();
|
||||
if (!m_animated || m_radius < max) {
|
||||
#ifdef QT_OPENGL_SUPPORT
|
||||
if (usesOpenGL()) {
|
||||
if (usesOpenGL()){
|
||||
update();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
update(circle_bounds(m_pos, max, m_fontSize));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
update(circle_bounds(m_pos, max, m_fontSize));
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,10 +623,9 @@ void PathDeformRenderer::setIntensity(int intensity)
|
||||
#ifdef QT_OPENGL_SUPPORT
|
||||
if (usesOpenGL()) {
|
||||
update();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
update(circle_bounds(m_pos, m_radius, m_fontSize));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
update(circle_bounds(m_pos, m_radius, m_fontSize));
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +44,9 @@
|
||||
|
||||
#include "arthurwidgets.h"
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QBasicTimer>
|
||||
#include <QDateTime>
|
||||
#include <QPainterPath>
|
||||
|
||||
class PathDeformRenderer : public ArthurFrame
|
||||
{
|
||||
@ -113,8 +113,8 @@ private:
|
||||
QPointF m_offset;
|
||||
QPointF m_direction;
|
||||
QPointF m_mousePress;
|
||||
bool m_mouseDrag;
|
||||
bool m_smallScreen;
|
||||
bool m_mouseDrag;
|
||||
bool m_smallScreen;
|
||||
};
|
||||
|
||||
class PathDeformControls : public QWidget
|
||||
@ -129,9 +129,6 @@ private:
|
||||
PathDeformRenderer* m_renderer;
|
||||
void layoutForDesktop();
|
||||
void layoutForSmallScreen();
|
||||
private slots:
|
||||
void emitQuitSignal();
|
||||
void emitOkSignal();
|
||||
};
|
||||
|
||||
class PathDeformWidget : public QWidget
|
||||
@ -139,7 +136,7 @@ class PathDeformWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
PathDeformWidget(QWidget *parent, bool smallScreen);
|
||||
void setStyle ( QStyle * style );
|
||||
void setStyle (QStyle * style );
|
||||
|
||||
private:
|
||||
PathDeformRenderer *m_renderer;
|
||||
|
@ -52,7 +52,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
||||
sampleSizes << 32 << 24 << 16 << 14 << 12 << 8 << 4 << 2 << 1;
|
||||
markedCount = 0;
|
||||
setupFontTree();
|
||||
@ -86,10 +85,8 @@ void MainWindow::setupFontTree()
|
||||
QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
|
||||
styleItem->setText(0, style);
|
||||
styleItem->setCheckState(0, Qt::Unchecked);
|
||||
styleItem->setData(0, Qt::UserRole,
|
||||
QVariant(database.weight(family, style)));
|
||||
styleItem->setData(0, Qt::UserRole + 1,
|
||||
QVariant(database.italic(family, style)));
|
||||
styleItem->setData(0, Qt::UserRole, QVariant(database.weight(family, style)));
|
||||
styleItem->setData(0, Qt::UserRole + 1, QVariant(database.italic(family, style)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,13 +174,11 @@ void MainWindow::updateStyles(QTreeWidgetItem *item, int column)
|
||||
else
|
||||
--markedCount;
|
||||
|
||||
if (state == Qt::Checked &&
|
||||
parent->checkState(0) == Qt::Unchecked) {
|
||||
if (state == Qt::Checked && parent->checkState(0) == Qt::Unchecked) {
|
||||
// Mark parent items when child items are checked.
|
||||
parent->setCheckState(0, Qt::Checked);
|
||||
|
||||
} else if (state == Qt::Unchecked &&
|
||||
parent->checkState(0) == Qt::Checked) {
|
||||
} else if (state == Qt::Unchecked && parent->checkState(0) == Qt::Checked) {
|
||||
|
||||
bool marked = false;
|
||||
for (int row = 0; row < parent->childCount(); ++row) {
|
||||
@ -343,16 +338,16 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
|
||||
qreal scale = qMin(xScale, yScale);
|
||||
|
||||
qreal remainingHeight = printer->pageRect().height()/scale - height;
|
||||
qreal spaceHeight = (remainingHeight/4.0) / (items.count() + 1);
|
||||
qreal interLineHeight = (remainingHeight/4.0) / (sampleSizes.count() * items.count());
|
||||
qreal spaceHeight = (remainingHeight / 4.0) / (items.count() + 1);
|
||||
qreal interLineHeight = (remainingHeight / 4.0) / (sampleSizes.count() * items.count());
|
||||
|
||||
painter->save();
|
||||
painter->translate(printer->pageRect().width()/2.0, printer->pageRect().height()/2.0);
|
||||
painter->translate(printer->pageRect().width() / 2.0, printer->pageRect().height() / 2.0);
|
||||
painter->scale(scale, scale);
|
||||
painter->setBrush(QBrush(Qt::black));
|
||||
|
||||
qreal x = -width/2.0;
|
||||
qreal y = -height/2.0 - remainingHeight/4.0 + spaceHeight;
|
||||
qreal x = -width / 2.0;
|
||||
qreal y = -height / 2.0 - remainingHeight / 4.0 + spaceHeight;
|
||||
|
||||
foreach (QTreeWidgetItem *item, items) {
|
||||
QString style = item->text(0);
|
||||
@ -368,8 +363,7 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
|
||||
font.family()).arg(style));
|
||||
y += rect.height();
|
||||
painter->setFont(font);
|
||||
painter->drawText(QPointF(x, y),
|
||||
QString("%1 %2").arg(family).arg(style));
|
||||
painter->drawText(QPointF(x, y), QString("%1 %2").arg(family).arg(style));
|
||||
y += interLineHeight;
|
||||
}
|
||||
y += spaceHeight;
|
||||
@ -377,4 +371,4 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
#endif
|
||||
#endif // QT_NO_PRINTER
|
||||
|
@ -84,4 +84,4 @@ private:
|
||||
int markedCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -62,7 +62,6 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent)
|
||||
|
||||
} else {
|
||||
setAttribute(Qt::WA_NoBackground);
|
||||
|
||||
}
|
||||
|
||||
QPolygonF points;
|
||||
@ -81,13 +80,11 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent)
|
||||
connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged()));
|
||||
}
|
||||
|
||||
|
||||
QPolygonF ShadeWidget::points() const
|
||||
{
|
||||
return m_hoverPoints->points();
|
||||
}
|
||||
|
||||
|
||||
uint ShadeWidget::colorAt(int x)
|
||||
{
|
||||
generateShade();
|
||||
@ -104,7 +101,6 @@ uint ShadeWidget::colorAt(int x)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ShadeWidget::setGradientStops(const QGradientStops &stops)
|
||||
{
|
||||
if (m_shade_type == ARGBShade) {
|
||||
@ -121,7 +117,6 @@ void ShadeWidget::setGradientStops(const QGradientStops &stops)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShadeWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
generateShade();
|
||||
@ -133,7 +128,6 @@ void ShadeWidget::paintEvent(QPaintEvent *)
|
||||
p.drawRect(0, 0, width() - 1, height() - 1);
|
||||
}
|
||||
|
||||
|
||||
void ShadeWidget::generateShade()
|
||||
{
|
||||
if (m_shade.isNull() || m_shade.size() != size()) {
|
||||
@ -167,11 +161,8 @@ void ShadeWidget::generateShade()
|
||||
p.fillRect(rect(), shade);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
GradientEditor::GradientEditor(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -195,13 +186,11 @@ GradientEditor::GradientEditor(QWidget *parent)
|
||||
connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
|
||||
}
|
||||
|
||||
|
||||
inline static bool x_less_than(const QPointF &p1, const QPointF &p2)
|
||||
{
|
||||
return p1.x() < p2.x();
|
||||
}
|
||||
|
||||
|
||||
void GradientEditor::pointsUpdated()
|
||||
{
|
||||
qreal w = m_alpha_shade->width();
|
||||
@ -217,9 +206,9 @@ void GradientEditor::pointsUpdated()
|
||||
|
||||
qSort(points.begin(), points.end(), x_less_than);
|
||||
|
||||
for (int i=0; i<points.size(); ++i) {
|
||||
for (int i = 0; i < points.size(); ++i) {
|
||||
qreal x = int(points.at(i).x());
|
||||
if (i+1 < points.size() && x == points.at(i+1).x())
|
||||
if (i + 1 < points.size() && x == points.at(i + 1).x())
|
||||
continue;
|
||||
QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16,
|
||||
(0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8,
|
||||
@ -237,7 +226,6 @@ void GradientEditor::pointsUpdated()
|
||||
emit gradientStopsChanged(stops);
|
||||
}
|
||||
|
||||
|
||||
static void set_shade_points(const QPolygonF &points, ShadeWidget *shade)
|
||||
{
|
||||
shade->hoverPoints()->setPoints(points);
|
||||
@ -255,7 +243,7 @@ void GradientEditor::setGradientStops(const QGradientStops &stops)
|
||||
qreal h_blue = m_blue_shade->height();
|
||||
qreal h_alpha = m_alpha_shade->height();
|
||||
|
||||
for (int i=0; i<stops.size(); ++i) {
|
||||
for (int i = 0; i < stops.size(); ++i) {
|
||||
qreal pos = stops.at(i).first;
|
||||
QRgb color = stops.at(i).second.rgba();
|
||||
pts_red << QPointF(pos * m_red_shade->width(), h_red - qRed(color) * h_red / 255);
|
||||
@ -454,7 +442,6 @@ void GradientWidget::setDefault(int config)
|
||||
m_renderer->setGradientStops(stops);
|
||||
}
|
||||
|
||||
|
||||
GradientRenderer::GradientRenderer(QWidget *parent)
|
||||
: ArthurFrame(parent)
|
||||
{
|
||||
@ -477,7 +464,6 @@ void GradientRenderer::setGradientStops(const QGradientStops &stops)
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void GradientRenderer::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
setDescriptionEnabled(false);
|
||||
@ -503,7 +489,7 @@ void GradientRenderer::paint(QPainter *p)
|
||||
g = QConicalGradient(pts.at(0), angle);
|
||||
}
|
||||
|
||||
for (int i=0; i<m_stops.size(); ++i)
|
||||
for (int i = 0; i < m_stops.size(); ++i)
|
||||
g.setColorAt(m_stops.at(i).first, m_stops.at(i).second);
|
||||
|
||||
g.setSpread(m_spread);
|
||||
|
@ -44,7 +44,9 @@
|
||||
|
||||
#include "arthurwidgets.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QRadioButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class HoverPoints;
|
||||
|
||||
@ -52,6 +54,7 @@ class HoverPoints;
|
||||
class ShadeWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ShadeType {
|
||||
RedShade,
|
||||
@ -88,6 +91,7 @@ private:
|
||||
class GradientEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GradientEditor(QWidget *parent);
|
||||
|
||||
@ -106,10 +110,10 @@ private:
|
||||
ShadeWidget *m_alpha_shade;
|
||||
};
|
||||
|
||||
|
||||
class GradientRenderer : public ArthurFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GradientRenderer(QWidget *parent);
|
||||
void paint(QPainter *p);
|
||||
@ -139,10 +143,10 @@ private:
|
||||
Qt::BrushStyle m_gradientType;
|
||||
};
|
||||
|
||||
|
||||
class GradientWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GradientWidget(QWidget *parent);
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Q_INIT_RESOURCE(gradients);
|
||||
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "imagecomposer.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
//! [0]
|
||||
static const QSize resultSize(200, 200);
|
||||
//! [0]
|
||||
@ -91,10 +91,8 @@ ImageComposer::ImageComposer()
|
||||
|
||||
//! [3]
|
||||
connect(sourceButton, SIGNAL(clicked()), this, SLOT(chooseSource()));
|
||||
connect(operatorComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(recalculateResult()));
|
||||
connect(destinationButton, SIGNAL(clicked()),
|
||||
this, SLOT(chooseDestination()));
|
||||
connect(operatorComboBox, SIGNAL(activated(int)), this, SLOT(recalculateResult()));
|
||||
connect(destinationButton, SIGNAL(clicked()), this, SLOT(chooseDestination()));
|
||||
//! [3]
|
||||
|
||||
//! [4]
|
||||
@ -128,8 +126,7 @@ void ImageComposer::chooseSource()
|
||||
//! [7]
|
||||
void ImageComposer::chooseDestination()
|
||||
{
|
||||
chooseImage(tr("Choose Destination Image"), &destinationImage,
|
||||
destinationButton);
|
||||
chooseImage(tr("Choose Destination Image"), &destinationImage, destinationButton);
|
||||
}
|
||||
//! [7]
|
||||
|
||||
|
@ -84,4 +84,4 @@ private:
|
||||
};
|
||||
//! [1]
|
||||
|
||||
#endif
|
||||
#endif // IMAGECOMPOSER_H
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "imagecomposer.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
//! [0]
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
@ -38,10 +38,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "renderarea.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
//! [0]
|
||||
RenderArea::RenderArea(const QPainterPath &path, QWidget *parent)
|
||||
: QWidget(parent), path(path)
|
||||
@ -119,8 +119,7 @@ void RenderArea::paintEvent(QPaintEvent *)
|
||||
painter.translate(-50.0, -50.0);
|
||||
|
||||
//! [9] //! [10]
|
||||
painter.setPen(QPen(penColor, penWidth, Qt::SolidLine, Qt::RoundCap,
|
||||
Qt::RoundJoin));
|
||||
painter.setPen(QPen(penColor, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
QLinearGradient gradient(0, 0, 0, 100);
|
||||
gradient.setColorAt(0.0, fillColor1);
|
||||
gradient.setColorAt(1.0, fillColor2);
|
||||
|
@ -77,4 +77,4 @@ private:
|
||||
};
|
||||
//! [1]
|
||||
|
||||
#endif
|
||||
#endif // RENDERAREA_H
|
||||
|
@ -38,13 +38,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "renderarea.h"
|
||||
#include "window.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "renderarea.h"
|
||||
#include "window.h"
|
||||
|
||||
//! [0]
|
||||
const float Pi = 3.14159f;
|
||||
//! [0]
|
||||
@ -153,13 +153,11 @@ Window::Window()
|
||||
//! [12]
|
||||
fillColor1ComboBox = new QComboBox;
|
||||
populateWithColors(fillColor1ComboBox);
|
||||
fillColor1ComboBox->setCurrentIndex(
|
||||
fillColor1ComboBox->findText("mediumslateblue"));
|
||||
fillColor1ComboBox->setCurrentIndex(fillColor1ComboBox->findText("mediumslateblue"));
|
||||
|
||||
fillColor2ComboBox = new QComboBox;
|
||||
populateWithColors(fillColor2ComboBox);
|
||||
fillColor2ComboBox->setCurrentIndex(
|
||||
fillColor2ComboBox->findText("cornsilk"));
|
||||
fillColor2ComboBox->setCurrentIndex(fillColor2ComboBox->findText("cornsilk"));
|
||||
|
||||
fillGradientLabel = new QLabel(tr("&Fill Gradient:"));
|
||||
fillGradientLabel->setBuddy(fillColor1ComboBox);
|
||||
@ -175,8 +173,7 @@ Window::Window()
|
||||
|
||||
penColorComboBox = new QComboBox;
|
||||
populateWithColors(penColorComboBox);
|
||||
penColorComboBox->setCurrentIndex(
|
||||
penColorComboBox->findText("darkslateblue"));
|
||||
penColorComboBox->setCurrentIndex(penColorComboBox->findText("darkslateblue"));
|
||||
|
||||
penColorLabel = new QLabel(tr("Pen &Color:"));
|
||||
penColorLabel->setBuddy(penColorComboBox);
|
||||
@ -191,20 +188,14 @@ Window::Window()
|
||||
//! [12]
|
||||
|
||||
//! [16]
|
||||
connect(fillRuleComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(fillRuleChanged()));
|
||||
connect(fillColor1ComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(fillGradientChanged()));
|
||||
connect(fillColor2ComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(fillGradientChanged()));
|
||||
connect(penColorComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(penColorChanged()));
|
||||
connect(fillRuleComboBox, SIGNAL(activated(int)), this, SLOT(fillRuleChanged()));
|
||||
connect(fillColor1ComboBox, SIGNAL(activated(int)), this, SLOT(fillGradientChanged()));
|
||||
connect(fillColor2ComboBox, SIGNAL(activated(int)), this, SLOT(fillGradientChanged()));
|
||||
connect(penColorComboBox, SIGNAL(activated(int)), this, SLOT(penColorChanged()));
|
||||
|
||||
for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++) {
|
||||
connect(penWidthSpinBox, SIGNAL(valueChanged(int)),
|
||||
*it, SLOT(setPenWidth(int)));
|
||||
connect(rotationAngleSpinBox, SIGNAL(valueChanged(int)),
|
||||
*it, SLOT(setRotationAngle(int)));
|
||||
connect(penWidthSpinBox, SIGNAL(valueChanged(int)), *it, SLOT(setPenWidth(int)));
|
||||
connect(rotationAngleSpinBox, SIGNAL(valueChanged(int)), *it, SLOT(setRotationAngle(int)));
|
||||
}
|
||||
|
||||
//! [16] //! [17]
|
||||
@ -246,7 +237,7 @@ void Window::fillRuleChanged()
|
||||
{
|
||||
Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt();
|
||||
|
||||
for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++)
|
||||
for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it)
|
||||
(*it)->setFillRule(rule);
|
||||
}
|
||||
//! [19]
|
||||
@ -257,7 +248,7 @@ void Window::fillGradientChanged()
|
||||
QColor color1 = qvariant_cast<QColor>(currentItemData(fillColor1ComboBox));
|
||||
QColor color2 = qvariant_cast<QColor>(currentItemData(fillColor2ComboBox));
|
||||
|
||||
for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++)
|
||||
for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it)
|
||||
(*it)->setFillGradient(color1, color2);
|
||||
}
|
||||
//! [20]
|
||||
@ -267,7 +258,7 @@ void Window::penColorChanged()
|
||||
{
|
||||
QColor color = qvariant_cast<QColor>(currentItemData(penColorComboBox));
|
||||
|
||||
for(QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); it++)
|
||||
for (QList<RenderArea*>::iterator it = renderAreas.begin(); it != renderAreas.end(); ++it)
|
||||
(*it)->setPenColor(color);
|
||||
}
|
||||
//! [21]
|
||||
|
@ -87,4 +87,4 @@ private:
|
||||
};
|
||||
//! [2]
|
||||
|
||||
#endif
|
||||
#endif // WINDOW_H
|
||||
|
@ -40,6 +40,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "pathstroke.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -39,9 +39,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "pathstroke.h"
|
||||
#include "arthurstyle.h"
|
||||
#include "arthurwidgets.h"
|
||||
#include "pathstroke.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -236,11 +236,9 @@ void PathStrokeControls::layoutForDesktop()
|
||||
|
||||
|
||||
// Set up connections
|
||||
connect(animated, SIGNAL(toggled(bool)),
|
||||
m_renderer, SLOT(setAnimation(bool)));
|
||||
connect(animated, SIGNAL(toggled(bool)), m_renderer, SLOT(setAnimation(bool)));
|
||||
|
||||
connect(penWidth, SIGNAL(valueChanged(int)),
|
||||
m_renderer, SLOT(setPenWidth(int)));
|
||||
connect(penWidth, SIGNAL(valueChanged(int)), m_renderer, SLOT(setPenWidth(int)));
|
||||
|
||||
connect(showSourceButton, SIGNAL(clicked()), m_renderer, SLOT(showSource()));
|
||||
#ifdef QT_OPENGL_SUPPORT
|
||||
@ -332,10 +330,14 @@ void PathStrokeControls::layoutForSmallScreens()
|
||||
}
|
||||
|
||||
void PathStrokeControls::emitQuitSignal()
|
||||
{ emit quitPressed(); }
|
||||
{
|
||||
emit quitPressed();
|
||||
}
|
||||
|
||||
void PathStrokeControls::emitOkSignal()
|
||||
{ emit okPressed(); }
|
||||
{
|
||||
emit okPressed();
|
||||
}
|
||||
|
||||
|
||||
PathStrokeWidget::PathStrokeWidget(bool smallScreen)
|
||||
@ -362,19 +364,16 @@ PathStrokeWidget::PathStrokeWidget(bool smallScreen)
|
||||
connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit()));
|
||||
}
|
||||
|
||||
|
||||
void PathStrokeWidget::showControls()
|
||||
{
|
||||
m_controls->showFullScreen();
|
||||
}
|
||||
|
||||
|
||||
void PathStrokeWidget::hideControls()
|
||||
{
|
||||
m_controls->hide();
|
||||
}
|
||||
|
||||
|
||||
void PathStrokeWidget::setStyle( QStyle * style )
|
||||
{
|
||||
QWidget::setStyle(style);
|
||||
@ -388,7 +387,6 @@ void PathStrokeWidget::setStyle( QStyle * style )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PathStrokeRenderer::PathStrokeRenderer(QWidget *parent, bool smallScreen)
|
||||
: ArthurFrame(parent)
|
||||
{
|
||||
@ -420,9 +418,8 @@ void PathStrokeRenderer::paint(QPainter *painter)
|
||||
path.moveTo(m_points.at(0));
|
||||
|
||||
if (m_pathMode == LineMode) {
|
||||
for (int i=1; i<m_points.size(); ++i) {
|
||||
for (int i=1; i<m_points.size(); ++i)
|
||||
path.lineTo(m_points.at(i));
|
||||
}
|
||||
} else {
|
||||
int i=1;
|
||||
while (i + 2 < m_points.size()) {
|
||||
@ -595,67 +592,67 @@ bool PathStrokeRenderer::event(QEvent *e)
|
||||
case QEvent::TouchBegin:
|
||||
touchBegin = true;
|
||||
case QEvent::TouchUpdate:
|
||||
{
|
||||
const QTouchEvent *const event = static_cast<const QTouchEvent*>(e);
|
||||
const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
|
||||
foreach (const QTouchEvent::TouchPoint &touchPoint, points) {
|
||||
const int id = touchPoint.id();
|
||||
switch (touchPoint.state()) {
|
||||
case Qt::TouchPointPressed:
|
||||
{
|
||||
// find the point, move it
|
||||
QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values());
|
||||
int activePoint = -1;
|
||||
qreal distance = -1;
|
||||
const int pointsCount = m_points.size();
|
||||
for (int i=0; i<pointsCount; ++i) {
|
||||
if (activePoints.contains(i))
|
||||
continue;
|
||||
{
|
||||
const QTouchEvent *const event = static_cast<const QTouchEvent*>(e);
|
||||
const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
|
||||
foreach (const QTouchEvent::TouchPoint &touchPoint, points) {
|
||||
const int id = touchPoint.id();
|
||||
switch (touchPoint.state()) {
|
||||
case Qt::TouchPointPressed:
|
||||
{
|
||||
// find the point, move it
|
||||
QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values());
|
||||
int activePoint = -1;
|
||||
qreal distance = -1;
|
||||
const int pointsCount = m_points.size();
|
||||
for (int i=0; i<pointsCount; ++i) {
|
||||
if (activePoints.contains(i))
|
||||
continue;
|
||||
|
||||
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length();
|
||||
if ((distance < 0 && d < 12 * m_pointSize) || d < distance) {
|
||||
distance = d;
|
||||
activePoint = i;
|
||||
}
|
||||
}
|
||||
if (activePoint != -1) {
|
||||
m_fingerPointMapping.insert(touchPoint.id(), activePoint);
|
||||
m_points[activePoint] = touchPoint.pos();
|
||||
}
|
||||
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length();
|
||||
if ((distance < 0 && d < 12 * m_pointSize) || d < distance) {
|
||||
distance = d;
|
||||
activePoint = i;
|
||||
}
|
||||
break;
|
||||
case Qt::TouchPointReleased:
|
||||
{
|
||||
// move the point and release
|
||||
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
|
||||
m_points[it.value()] = touchPoint.pos();
|
||||
m_fingerPointMapping.erase(it);
|
||||
}
|
||||
break;
|
||||
case Qt::TouchPointMoved:
|
||||
{
|
||||
// move the point
|
||||
const int pointIdx = m_fingerPointMapping.value(id, -1);
|
||||
if (pointIdx >= 0)
|
||||
m_points[pointIdx] = touchPoint.pos();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (activePoint != -1) {
|
||||
m_fingerPointMapping.insert(touchPoint.id(), activePoint);
|
||||
m_points[activePoint] = touchPoint.pos();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (m_fingerPointMapping.isEmpty()) {
|
||||
e->ignore();
|
||||
return false;
|
||||
} else {
|
||||
if (touchBegin) {
|
||||
m_wasAnimated = m_timer.isActive();
|
||||
setAnimation(false);
|
||||
}
|
||||
update();
|
||||
return true;
|
||||
case Qt::TouchPointReleased:
|
||||
{
|
||||
// move the point and release
|
||||
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
|
||||
m_points[it.value()] = touchPoint.pos();
|
||||
m_fingerPointMapping.erase(it);
|
||||
break;
|
||||
}
|
||||
case Qt::TouchPointMoved:
|
||||
{
|
||||
// move the point
|
||||
const int pointIdx = m_fingerPointMapping.value(id, -1);
|
||||
if (pointIdx >= 0)
|
||||
m_points[pointIdx] = touchPoint.pos();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_fingerPointMapping.isEmpty()) {
|
||||
e->ignore();
|
||||
return false;
|
||||
} else {
|
||||
if (touchBegin) {
|
||||
m_wasAnimated = m_timer.isActive();
|
||||
setAnimation(false);
|
||||
}
|
||||
update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QEvent::TouchEnd:
|
||||
if (m_fingerPointMapping.isEmpty()) {
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define PATHSTROKE_H
|
||||
|
||||
#include "arthurwidgets.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
class PathStrokeRenderer : public ArthurFrame
|
||||
@ -126,6 +127,7 @@ private:
|
||||
class PathStrokeControls : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathStrokeControls(QWidget* parent, PathStrokeRenderer* renderer, bool smallScreen);
|
||||
|
||||
@ -154,6 +156,7 @@ private slots:
|
||||
class PathStrokeWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathStrokeWidget(bool smallScreen);
|
||||
void setStyle ( QStyle * style );
|
||||
@ -165,7 +168,6 @@ private:
|
||||
private slots:
|
||||
void showControls();
|
||||
void hideControls();
|
||||
|
||||
};
|
||||
|
||||
#endif // PATHSTROKE_H
|
||||
|
@ -38,10 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "renderarea.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
|
||||
//! [0]
|
||||
RenderArea::RenderArea(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
@ -41,7 +41,6 @@
|
||||
#ifndef RENDERAREA_H
|
||||
#define RENDERAREA_H
|
||||
|
||||
#include <QFont>
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
#include <QRect>
|
||||
@ -87,4 +86,4 @@ private:
|
||||
};
|
||||
//! [2]
|
||||
|
||||
#endif
|
||||
#endif // RENDERAREA_H
|
||||
|
@ -38,10 +38,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
|
||||
//! [0]
|
||||
Window::Window()
|
||||
{
|
||||
@ -148,8 +149,7 @@ void Window::setupShapes()
|
||||
shapes.append(text);
|
||||
shapes.append(truck);
|
||||
|
||||
connect(shapeComboBox, SIGNAL(activated(int)),
|
||||
this, SLOT(shapeSelected(int)));
|
||||
connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeSelected(int)));
|
||||
}
|
||||
//! [7]
|
||||
|
||||
|
@ -41,12 +41,12 @@
|
||||
#ifndef WINDOW_H
|
||||
#define WINDOW_H
|
||||
|
||||
#include "renderarea.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QPainterPath>
|
||||
#include <QWidget>
|
||||
|
||||
#include "renderarea.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user