##// END OF EJS Templates
Try to fix arm build
Jani Honkonen -
r2347:09f915f3cb7e
parent child
Show More
@@ -1,141 +1,141
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "pentool.h"
22 22 #include <QPushButton>
23 23 #include <QDoubleSpinBox>
24 24 #include <QComboBox>
25 25 #include <QFormLayout>
26 26 #include <QColorDialog>
27 27
28 28 PenTool::PenTool(QString title, QWidget *parent)
29 29 : QWidget(parent)
30 30 {
31 31 setWindowTitle(title);
32 32 setWindowFlags(Qt::Tool);
33 33
34 34 m_colorButton = new QPushButton();
35 35
36 36 m_widthSpinBox = new QDoubleSpinBox();
37 37
38 38 m_styleCombo = new QComboBox();
39 39 m_styleCombo->addItem("NoPen");
40 40 m_styleCombo->addItem("SolidLine");
41 41 m_styleCombo->addItem("DashLine");
42 42 m_styleCombo->addItem("DotLine");
43 43 m_styleCombo->addItem("DashDotLine");
44 44 m_styleCombo->addItem("DashDotDotLine");
45 45
46 46 m_capStyleCombo = new QComboBox();
47 47 m_capStyleCombo->addItem("FlatCap", Qt::FlatCap);
48 48 m_capStyleCombo->addItem("SquareCap", Qt::SquareCap);
49 49 m_capStyleCombo->addItem("RoundCap", Qt::RoundCap);
50 50
51 51 m_joinStyleCombo = new QComboBox();
52 52 m_joinStyleCombo->addItem("MiterJoin", Qt::MiterJoin);
53 53 m_joinStyleCombo->addItem("BevelJoin", Qt::BevelJoin);
54 54 m_joinStyleCombo->addItem("RoundJoin", Qt::RoundJoin);
55 55 m_joinStyleCombo->addItem("SvgMiterJoin", Qt::SvgMiterJoin);
56 56
57 57 QFormLayout *layout = new QFormLayout();
58 58 layout->addRow("Color", m_colorButton);
59 59 layout->addRow("Width", m_widthSpinBox);
60 60 layout->addRow("Style", m_styleCombo);
61 61 layout->addRow("Cap style", m_capStyleCombo);
62 62 layout->addRow("Join style", m_joinStyleCombo);
63 63 setLayout(layout);
64 64
65 65 connect(m_colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
66 66 connect(m_widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateWidth(double)));
67 67 connect(m_styleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStyle(int)));
68 68 connect(m_capStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateCapStyle(int)));
69 69 connect(m_joinStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateJoinStyle(int)));
70 70 }
71 71
72 72 void PenTool::setPen(const QPen &pen)
73 73 {
74 74 m_pen = pen;
75 75 m_colorButton->setText(m_pen.color().name());
76 76 m_widthSpinBox->setValue(m_pen.widthF());
77 77 m_styleCombo->setCurrentIndex(m_pen.style()); // index matches the enum
78 78 m_capStyleCombo->setCurrentIndex(m_capStyleCombo->findData(m_pen.capStyle()));
79 79 m_joinStyleCombo->setCurrentIndex(m_joinStyleCombo->findData(m_pen.joinStyle()));
80 80 }
81 81
82 82 QPen PenTool::pen() const
83 83 {
84 84 return m_pen;
85 85 }
86 86
87 87 QString PenTool::name()
88 88 {
89 89 return name(m_pen);
90 90 }
91 91
92 92 QString PenTool::name(const QPen &pen)
93 93 {
94 94 return pen.color().name() + ":" + QString::number(pen.widthF());
95 95 }
96 96
97 97 void PenTool::showColorDialog()
98 98 {
99 99 QColorDialog dialog(m_pen.color());
100 100 dialog.show();
101 101 dialog.exec();
102 102 m_pen.setColor(dialog.selectedColor());
103 103 m_colorButton->setText(m_pen.color().name());
104 104 emit changed();
105 105 }
106 106
107 107 void PenTool::updateWidth(double width)
108 108 {
109 if (!qFuzzyCompare(width, m_pen.widthF())) {
109 if (!qFuzzyCompare((qreal) width, m_pen.widthF())) {
110 110 m_pen.setWidthF(width);
111 111 emit changed();
112 112 }
113 113 }
114 114
115 115 void PenTool::updateStyle(int style)
116 116 {
117 117 if (m_pen.style() != style) {
118 118 m_pen.setStyle((Qt::PenStyle) style);
119 119 emit changed();
120 120 }
121 121 }
122 122
123 123 void PenTool::updateCapStyle(int index)
124 124 {
125 125 Qt::PenCapStyle capStyle = (Qt::PenCapStyle) m_capStyleCombo->itemData(index).toInt();
126 126 if (m_pen.capStyle() != capStyle) {
127 127 m_pen.setCapStyle(capStyle);
128 128 emit changed();
129 129 }
130 130 }
131 131
132 132 void PenTool::updateJoinStyle(int index)
133 133 {
134 134 Qt::PenJoinStyle joinStyle = (Qt::PenJoinStyle) m_joinStyleCombo->itemData(index).toInt();
135 135 if (m_pen.joinStyle() != joinStyle) {
136 136 m_pen.setJoinStyle(joinStyle);
137 137 emit changed();
138 138 }
139 139 }
140 140
141 141 #include "moc_pentool.cpp"
General Comments 0
You need to be logged in to leave comments. Login now