69 br = geom.bottomRight();
70 tl = QPoint(geom.topLeft().x() +
m_barWidth, geom.topLeft().y());
72 br = geom.bottomRight();
73 tl = QPoint(geom.topLeft().x(), geom.topLeft().y() +
m_barWidth);
78 QRect available(tl, br);
80 int size = qMin(available.height(), available.width());
82 available.moveTop(available.y() + (available.height() - size)/2);
84 available.moveLeft(available.x() + (available.width() - size)/2);
86 available.setSize(QSize(size, size));
95 qreal x = 0.5 * width();
96 qreal y = 0.5 * height();
101 y = qMin((1.0 - coordinate.x())*(height()-offset*2)+offset, (qreal)height());
103 x = qMin(coordinate.x()*(width()-offset*2)+offset, (qreal)width());
107 QPointF left (innerRect.left(),innerRect.center().y());
108 QList <QLineF> polygonLines;
109 polygonLines.append(QLineF(left, innerRect.topLeft()));
110 polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topRight()));
111 polygonLines.append(QLineF(innerRect.topRight(), innerRect.bottomRight()));
112 polygonLines.append(QLineF(innerRect.bottomRight(), innerRect.bottomLeft()));
113 polygonLines.append(QLineF(innerRect.bottomLeft(), left));
115 qreal totalLength =0.0;
116 Q_FOREACH(QLineF line, polygonLines) {
117 totalLength += line.length();
120 qreal
length = coordinate.x()*totalLength;
121 QPointF intersect(x,y);
122 Q_FOREACH(QLineF line, polygonLines) {
124 intersect = line.pointAt(
length/line.length());
129 x = qRound(intersect.x());
130 y = qRound(intersect.y());
136 QPointF bottom (innerRect.center().x(), innerRect.bottom());
137 QList <QLineF> polygonLines;
138 polygonLines.append(QLineF(bottom, innerRect.bottomLeft()));
139 polygonLines.append(QLineF(innerRect.bottomLeft(), innerRect.topLeft()));
140 polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topRight()));
141 polygonLines.append(QLineF(innerRect.topRight(), innerRect.bottomRight()));
142 polygonLines.append(QLineF(innerRect.bottomRight(), bottom));
144 qreal totalLength =0.0;
145 Q_FOREACH(QLineF line, polygonLines) {
146 totalLength += line.length();
149 qreal
length = coordinate.x()*(totalLength/2);
150 QPointF intersect(x,y);
151 if (coordinate.y()==1) {
152 for (
int i = polygonLines.size()-1; i==0; i--) {
153 QLineF line = polygonLines.at(i);
155 intersect = line.pointAt(
length/line.length());
161 Q_FOREACH(QLineF line, polygonLines) {
163 intersect = line.pointAt(
length/line.length());
169 x = qRound(intersect.x());
170 y = qRound(intersect.y());
174 x = qMin(coordinate.x()*(width()-offset*2)+offset, (qreal)width());
175 y = qMin((1.0 - coordinate.y())*(height()-offset*2)+offset, (qreal)height());
190 x = 1.0 - (coordinate.y()-offset)/(height()-offset*2);
192 x = (coordinate.x()-offset)/(width()-offset*2);
197 QPointF left (innerRect.left(),innerRect.center().y());
198 QList <QLineF> polygonLines;
199 polygonLines.append(QLineF(left, innerRect.topLeft()));
200 polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topRight()));
201 polygonLines.append(QLineF(innerRect.topRight(), innerRect.bottomRight()));
202 polygonLines.append(QLineF(innerRect.bottomRight(), innerRect.bottomLeft()));
203 polygonLines.append(QLineF(innerRect.bottomLeft(), left));
205 QLineF radius(coordinate, this->geometry().center());
206 QPointF intersect(0.5,0.5);
208 qreal totalLength = 0.0;
209 bool foundIntersect =
false;
210 Q_FOREACH(QLineF line, polygonLines) {
211 if (line.intersects(radius, &intersect) == QLineF::BoundedIntersection && foundIntersect ==
false)
213 foundIntersect =
true;
214 length+=QLineF(line.p1(), intersect).length();
217 if (foundIntersect==
false) {
220 totalLength+=line.length();
229 QPointF bottom (innerRect.center().x(), innerRect.bottom());
230 QList <QLineF> polygonLines;
231 polygonLines.append(QLineF(bottom, innerRect.bottomLeft()));
232 polygonLines.append(QLineF(innerRect.bottomLeft(), innerRect.topLeft()));
233 polygonLines.append(QLineF(innerRect.topLeft(), innerRect.topRight()));
234 polygonLines.append(QLineF(innerRect.topRight(), innerRect.bottomRight()));
235 polygonLines.append(QLineF(innerRect.bottomRight(), bottom));
237 QLineF radius(coordinate, this->geometry().center());
238 QPointF intersect(0.5,0.5);
240 qreal totalLength = 0.0;
241 bool foundIntersect =
false;
242 Q_FOREACH(QLineF line, polygonLines) {
243 if (line.intersects(radius, &intersect) == QLineF::BoundedIntersection && foundIntersect ==
false)
245 foundIntersect =
true;
246 length+=QLineF(line.p1(), intersect).length();
249 if (foundIntersect==
false) {
252 totalLength+=line.length();
254 int halflength = totalLength/2;
257 x = (halflength - (
length-halflength))/halflength;
266 x = (coordinate.x()-offset)/(width()-offset*2);
267 y = 1.0 - (coordinate.y()-offset)/(height()-offset*2);
269 x = qBound((qreal)0.0, x, (qreal)1.0);
270 y = qBound((qreal)0.0, y, (qreal)1.0);
271 return QPointF(x, y);
287 const int deviceWidth = qCeil(width() * devicePixelRatioF());
288 const int deviceHeight = qCeil(height() * devicePixelRatioF());
290 QImage alphaMask(deviceWidth, deviceHeight, QImage::Format_Alpha8);
292 alphaMask.setDevicePixelRatio(devicePixelRatioF());
293 QPainter painter(&alphaMask);
294 painter.setRenderHint(QPainter::Antialiasing);
295 painter.setBrush(Qt::white);
296 painter.setPen(Qt::NoPen);
300 painter.drawRect(2, 3, width() - 4, height() - 6);
302 painter.drawRect(3, 2, width() - 6, height() - 4);
304 painter.drawRect(2, 2, width() - 4, height() - 4);
305 painter.setBrush(Qt::black);
309 painter.drawRect(3, 3, width() - 6, height() - 6);
320 QBrush fill(Qt::SolidPattern);
329 qreal y = qRound(cursorPoint.y());
330 rect.setCoords(1.5, y - cursorwidth + 0.5, width() - 1.5, y + cursorwidth - 0.5);
332 qreal x = qRound(cursorPoint.x());
333 rect.setCoords(x - cursorwidth + 0.5, 1.5, x + cursorwidth - 0.5, height() - 1.5);
335 painter.setPen(Qt::white);
336 fill.setColor(Qt::white);
337 painter.setBrush(fill);
338 painter.drawRect(
rect);
340 painter.setPen(Qt::black);
341 painter.setBrush(fill);
342 painter.drawRect(
rect.adjusted(1, 1, -1, -1));
346 painter.setPen(Qt::white);
347 fill.setColor(Qt::white);
348 painter.setBrush(fill);
349 painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
350 QPoint mirror(innerRect.center().x()+(innerRect.center().x()-cursorPoint.x()),cursorPoint.y());
351 painter.drawEllipse(mirror, cursorwidth, cursorwidth);
353 painter.setPen(Qt::black);
354 painter.setBrush(fill);
355 painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1);
356 painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1);
359 painter.setPen(Qt::white);
360 fill.setColor(Qt::white);
361 painter.setBrush(fill);
362 painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
364 painter.setPen(Qt::black);
365 painter.setBrush(fill);
366 painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);