From 5e60848942f34213aee259b433c900bc6006a57c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 12 Jan 2015 15:44:53 +0100 Subject: [PATCH] Utils: Add round progress indicator widget Change-Id: Ia3a51fb99ae6cec1b7b3c135d272e92d503128dc Reviewed-by: Eike Ziller --- .../utils/images/progressindicator_big.png | Bin 0 -> 1443 bytes .../utils/images/progressindicator_big@2x.png | Bin 0 -> 2449 bytes .../utils/images/progressindicator_small.png | Bin 0 -> 305 bytes .../images/progressindicator_small@2x.png | Bin 0 -> 397 bytes src/libs/utils/progressindicator.cpp | 90 +++++++ src/libs/utils/progressindicator.h | 74 ++++++ src/libs/utils/utils.pro | 6 + src/libs/utils/utils.qbs | 6 + src/libs/utils/utils.qrc | 4 + src/tools/icons/qtcreatoricons.svg | 230 ++++++++++++++++++ 10 files changed, 410 insertions(+) create mode 100644 src/libs/utils/images/progressindicator_big.png create mode 100644 src/libs/utils/images/progressindicator_big@2x.png create mode 100644 src/libs/utils/images/progressindicator_small.png create mode 100644 src/libs/utils/images/progressindicator_small@2x.png create mode 100644 src/libs/utils/progressindicator.cpp create mode 100644 src/libs/utils/progressindicator.h diff --git a/src/libs/utils/images/progressindicator_big.png b/src/libs/utils/images/progressindicator_big.png new file mode 100644 index 0000000000000000000000000000000000000000..ac854f1e25e081e64a5609e06b33d1fc714d2c82 GIT binary patch literal 1443 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4rT@hhPm4t-!L#RUJvjIasB`QKLZ29|Ns9R z8X7`FLszX@)zHw8mX zw6uhTgo1*C%*@Qf!ouwA?6kDB;^N|rjEwyJ{H(03f`Wp=!ou9#-2D9f?Ck7}jEsVU zf}EV3+}zx(tgOPq!o0k^%*@Q3oScG!g52EPyu7@eoSe+e%>4ZP+}zyk>}-e$Sy@@R zU;q(;D1(@po0|*K4iSVH2(huCpddRt8>|mx6kGvBOCA_N*bwU=4$I5SgJ{pm$;r#h z%g@h;Fd)u@lQ}s#+1c3;#SkkX${>d1fC1PBkZBMph%$(ca5ltM5H6gJYzSOE#4a?W zAQ~~r6O%5mGcYjBDGBlmW?*DwVrFJxWo75!;N;@w=Hcb#;};MR6cQE@5fhh?l$Mc` zS5Qz?R#8z^*U;3`(bdy4G%_+VHM6j^w6eCbvv+WCbaHlaarN}__VxD<2n-1gi-?Sh zijIj(Nli^lOV7y8$<50zC@d-}E-kO9tZ!^;Y3c0h?(XUBpFU&O+<6NYE?Ts7#k!4K zw{6?8bJy>-Qf%)>$&?AOi!_eNPw1kch)?r~izjc+rLCKU7>_P7sPM8{VjcTE^`hhS*h`7i&9tQJbMEJE;65g|?fUBZfBqclJ71l1 z|M5>dmcY=(KmTYXy8Luf%;yMT_?zzV;BnA?s|A%dcNQ`JIA^eb_Em;&7EZ!a4gNfb z&#Y!-6L3nFYWU0$@im;yM2+#mb%q<$8aG5p3b53lS@czOF+&1hI8()eew$l`73>XD zOP?}$^ZZekXuPwNtHt|igWL!8ITkAmk+ zgM0_Rj6~-fYoEQS-9KSdXZy7E4nGvu9~1boSnZ_kzm1%RtK%=4%(YgDvpvvOw112I zjvE5Ij#}H~cpN(PFniY3&AEpQ)R(L4c562+>Ds}u zQ=a20W0Ac;4>QmHL$gjjz3ncgsrG(q&bMu@<(AgV=chR4T1k7wsvN$x+5F9~s9WoH z&#|4Icj;<~wcdwsv#m?Eer5#vvs%X=*;D}_`NuJY1s=4&$BnOBW|rL z{2gIsV=Zqy0tub x(v)z9f^D^2nhaY{8#t_R+pG1Jx%4mdKUdGK_2)f5GB7YOc)I$ztaD0e0sx6AdU^l= literal 0 HcmV?d00001 diff --git a/src/libs/utils/images/progressindicator_big@2x.png b/src/libs/utils/images/progressindicator_big@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..23b488f23abcb331702db32ac0728d2198cb9eb6 GIT binary patch literal 2449 zcmeAS@N?(olHy`uVBq!ia0y~yU}ykg4rT@hhA$5${$yZaiVN@wasB`QKLZ29|Ns9R z8X7`FLszX@)zHw8mX_Ag(2$UjP*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%C+% zVVQHRW9;Y2W?eTuoj6se1gx3zQhxT7D>LjTzj>E7{kXbjzqX8WN}vC!tT`PA?!1{C zx_RbDf2|Y#Ob~|UhU5Rk7lZG z_@u41^5(O~1AD$5*R(wQhOZz>zW>XeCwp1`HQrhpzrdsFO^w2;S*r1iHqPbxFm<_X zL&ij{#~exW77d>{K2Cob^sP_fo3j5yUZp#&rzRD@IA3omYcF#sVpZ)1`K|V;$}`ytmfFFnnCWL3{`ZrOm7Czy|{nDA2ZgMC^EQ-`PK z^nJ1na*0zIl7h}WWB7mADz!mk%IBGV%m)@Vvn^sU)X2EQ{I8q)=~2cN(@Ua$TmHXi zQp&KUJF4~qW54k$294=o#hU83JL)oAJ@o8}AA>+%f;VG;?%T4a|DSuR7`l$WeJ00n z;v$p7`aS#k{=AmZWw^p;k<$D>J1v)COJBts)`lQAX@<4Vdh3h+%{>{#s3H5=@)Tpo z{_rOZ8nPvijx9K1G*^dV?&7%2*w6oB#bg+?+V4tu`+nE<_ilali6Nx#x8|N@PZ*Qd zvpC#gv@!YjQl;qR8aACymX|*-3F|~HIB;SA`xJdfL65Wd7#J8BJYD@<);T3K0RYRK BS)Bj? literal 0 HcmV?d00001 diff --git a/src/libs/utils/images/progressindicator_small.png b/src/libs/utils/images/progressindicator_small.png new file mode 100644 index 0000000000000000000000000000000000000000..8ba536403d84e1a7b885cb71f7d4f650aaa487f8 GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4rT@h1`S>QU>HlMpt<7-_X#oYSpTl zU@(9F{FyUn&Ye4V;lhRU=g*%#d-gmqm^*han4ULh&YZbmFmK*Gh~V70b0LBd5xC$x z{#KCnvL!)&!3<2ytXu+;QqmflS}tzxJ^_K*d8O60E4J-AcJa#B16Ox4FfbhTba4!^ zIKB7sO|d2g5!L`14-?M~Cf>jQ-{+CkV=|Ykd115BqI&0q#t91YqLWT%7Q79}zLqgqqyJ15^Erpw0rIRw~L_KHg>>=pIi%Fo^RC2G%` zlv?L1Rk0asEDvwn{ORx`gTE~@8(aP`|CsVaN%5}7=KVK)KhI4w^ZNSPW}5x>sPDnc z#oJ}4z2@~`{UUZ`QR}_N7pG$7*0Br3MXBbzcPw~2HN%sqsa<%Uy T+RR{JU|{fc^>bP0l+XkK`j@V7 literal 0 HcmV?d00001 diff --git a/src/libs/utils/progressindicator.cpp b/src/libs/utils/progressindicator.cpp new file mode 100644 index 00000000000..10e0f9a5d13 --- /dev/null +++ b/src/libs/utils/progressindicator.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "progressindicator.h" +#include "stylehelper.h" + +#include +#include + +using namespace Utils; + +ProgressIndicator::ProgressIndicator(Size size, QWidget *parent) + : QWidget(parent), + m_rotation(0) +{ + setAttribute(Qt::WA_TransparentForMouseEvents); + m_size = size; + m_rotationStep = size == Small ? 45 : 30; + m_pixmap.load(StyleHelper::dpiSpecificImageFile( + size == Small ? QLatin1String(":/utils/images/progressindicator_small.png") + : QLatin1String(":/utils/images/progressindicator_big.png"))); + m_timer.setInterval(size == Small ? 100 : 80); + m_timer.setSingleShot(false); + connect(&m_timer, &QTimer::timeout, this, &ProgressIndicator::step); +} + +QSize ProgressIndicator::sizeHint() const +{ + return m_pixmap.size() / m_pixmap.devicePixelRatio(); +} + +void ProgressIndicator::paintEvent(QPaintEvent *) +{ + QPainter p(this); + p.setRenderHint(QPainter::SmoothPixmapTransform); + QPoint translate(rect().width() / 2, rect().height() / 2); + QTransform t; + t.translate(translate.x(), translate.y()); + t.rotate(m_rotation); + t.translate(-translate.x(), -translate.y()); + p.setTransform(t); + QSize pixmapUserSize(m_pixmap.size() / m_pixmap.devicePixelRatio()); + p.drawPixmap(QPoint((rect().width() - pixmapUserSize.width()) / 2, + (rect().height() - pixmapUserSize.height()) / 2), + m_pixmap); +} + +void ProgressIndicator::showEvent(QShowEvent *) +{ + m_timer.start(); +} + +void ProgressIndicator::hideEvent(QHideEvent *) +{ + m_timer.stop(); +} + +void ProgressIndicator::step() +{ + m_rotation = (m_rotation + m_rotationStep + 360) % 360; + update(); +} + diff --git a/src/libs/utils/progressindicator.h b/src/libs/utils/progressindicator.h new file mode 100644 index 00000000000..c75fcbe0dc9 --- /dev/null +++ b/src/libs/utils/progressindicator.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://www.qt.io/licensing. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + + +#ifndef PROGRESSINDICATOR_H +#define PROGRESSINDICATOR_H + +#include "utils_global.h" + +#include +#include + +namespace Utils { + +namespace Internal { class ProgressIndicatorPrivate; } + +class QTCREATOR_UTILS_EXPORT ProgressIndicator : public QWidget +{ + Q_OBJECT +public: + enum Size { + Small, + Large + }; + + explicit ProgressIndicator(Size size, QWidget *parent = 0); + + QSize sizeHint() const; + +protected: + void paintEvent(QPaintEvent *); + void showEvent(QShowEvent *); + void hideEvent(QHideEvent *); + +private: + void step(); + + ProgressIndicator::Size m_size; + int m_rotationStep; + int m_rotation; + QTimer m_timer; + QPixmap m_pixmap; +}; + +} // Utils + +#endif // PROGRESSINDICATOR_H diff --git a/src/libs/utils/utils.pro b/src/libs/utils/utils.pro index b857dc9b24d..c6be7af2ae3 100644 --- a/src/libs/utils/utils.pro +++ b/src/libs/utils/utils.pro @@ -17,3 +17,9 @@ linux-* { win32: LIBS += -luser32 -lshell32 # PortsGatherer win32: LIBS += -liphlpapi -lws2_32 + +HEADERS += \ + progressindicator.h + +SOURCES += \ + progressindicator.cpp diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 31aff7ac34e..a2260ba1b69 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -130,6 +130,8 @@ QtcLibrary { "persistentsettings.h", "portlist.cpp", "portlist.h", + "progressindicator.cpp", + "progressindicator.h", "projectintropage.cpp", "projectintropage.h", "projectintropage.ui", @@ -202,6 +204,10 @@ QtcLibrary { "images/crumblepath-segment-selected-end.png", "images/crumblepath-segment-selected.png", "images/crumblepath-segment.png", + "images/progressindicator_big.png", + "images/progressindicator_big@2x.png", + "images/progressindicator_small.png", + "images/progressindicator_small@2x.png", "images/triangle_vert.png", ] diff --git a/src/libs/utils/utils.qrc b/src/libs/utils/utils.qrc index 2748bccb6c8..1209225af4a 100644 --- a/src/libs/utils/utils.qrc +++ b/src/libs/utils/utils.qrc @@ -7,6 +7,10 @@ images/crumblepath-segment-hover.png images/crumblepath-segment-selected-end.png images/crumblepath-segment-selected.png + images/progressindicator_big.png + images/progressindicator_big@2x.png + images/progressindicator_small.png + images/progressindicator_small@2x.png images/triangle_vert.png diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index 2c04f551edb..853e8d1089d 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -581,6 +581,28 @@ y1="587" x2="181" y2="599" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +