forked from qt-creator/qt-creator
Utils: Add round progress indicator widget
Change-Id: Ia3a51fb99ae6cec1b7b3c135d272e92d503128dc Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
BIN
src/libs/utils/images/progressindicator_big.png
Normal file
BIN
src/libs/utils/images/progressindicator_big.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/libs/utils/images/progressindicator_big@2x.png
Normal file
BIN
src/libs/utils/images/progressindicator_big@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src/libs/utils/images/progressindicator_small.png
Normal file
BIN
src/libs/utils/images/progressindicator_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 305 B |
BIN
src/libs/utils/images/progressindicator_small@2x.png
Normal file
BIN
src/libs/utils/images/progressindicator_small@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 397 B |
90
src/libs/utils/progressindicator.cpp
Normal file
90
src/libs/utils/progressindicator.cpp
Normal file
@@ -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 <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
74
src/libs/utils/progressindicator.h
Normal file
74
src/libs/utils/progressindicator.h
Normal file
@@ -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 <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
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
|
||||
@@ -17,3 +17,9 @@ linux-* {
|
||||
win32: LIBS += -luser32 -lshell32
|
||||
# PortsGatherer
|
||||
win32: LIBS += -liphlpapi -lws2_32
|
||||
|
||||
HEADERS += \
|
||||
progressindicator.h
|
||||
|
||||
SOURCES += \
|
||||
progressindicator.cpp
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
<file>images/crumblepath-segment-hover.png</file>
|
||||
<file>images/crumblepath-segment-selected-end.png</file>
|
||||
<file>images/crumblepath-segment-selected.png</file>
|
||||
<file>images/progressindicator_big.png</file>
|
||||
<file>images/progressindicator_big@2x.png</file>
|
||||
<file>images/progressindicator_small.png</file>
|
||||
<file>images/progressindicator_small@2x.png</file>
|
||||
<file>images/triangle_vert.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -581,6 +581,28 @@
|
||||
y1="587"
|
||||
x2="181"
|
||||
y2="599" />
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath4556">
|
||||
<rect
|
||||
id="rect4558"
|
||||
width="16"
|
||||
height="16"
|
||||
x="281"
|
||||
y="584"
|
||||
style="fill:none" />
|
||||
</clipPath>
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath3536">
|
||||
<rect
|
||||
style="opacity:0.41699997;fill:none;stroke:none"
|
||||
id="rect3538"
|
||||
width="64"
|
||||
height="64"
|
||||
x="329"
|
||||
y="536" />
|
||||
</clipPath>
|
||||
<linearGradient
|
||||
id="linearGradient4137-8">
|
||||
<stop
|
||||
@@ -1027,6 +1049,214 @@
|
||||
transform="matrix(1,0,0,-1,16,1184)"
|
||||
width="100%"
|
||||
height="100%" />
|
||||
<g
|
||||
id="src/libs/utils/images/progressindicator_small"
|
||||
clip-path="url(#clipPath4556)"
|
||||
transform="matrix(-1,0,0,1,578,0)">
|
||||
<g
|
||||
id="g4504">
|
||||
<rect
|
||||
id="rect3693"
|
||||
width="16"
|
||||
height="16"
|
||||
x="281"
|
||||
y="584"
|
||||
style="fill:none" />
|
||||
<rect
|
||||
style="fill:#9d9d9d;fill-opacity:1;stroke:none"
|
||||
id="rect3698"
|
||||
width="2"
|
||||
height="5"
|
||||
x="288"
|
||||
y="584" />
|
||||
</g>
|
||||
<use
|
||||
style="opacity:0.83"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,503.25335,-30.961074)"
|
||||
id="use4511"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.66"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0,1,-1,0,881,303)"
|
||||
id="use4525"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.49"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.70710678,0.70710678,-0.70710678,-0.70710678,911.96107,806.25335)"
|
||||
id="use4528"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-1,0,0,-1,578,1184)"
|
||||
id="use4530"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.70710678,-0.70710678,0.70710678,-0.70710678,74.746645,1214.9611)"
|
||||
id="use4532"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0,-1,1,0,-303,881)"
|
||||
id="use4534"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,-333.96107,377.74665)"
|
||||
id="use4536"
|
||||
xlink:href="#g4504"
|
||||
y="0"
|
||||
x="0" />
|
||||
</g>
|
||||
<g
|
||||
id="src/libs/utils/images/progressindicator_big"
|
||||
clip-path="url(#clipPath3536)"
|
||||
transform="matrix(-1,0,0,1,722,0)">
|
||||
<g
|
||||
id="g3369">
|
||||
<rect
|
||||
y="536"
|
||||
x="329"
|
||||
height="64"
|
||||
width="64"
|
||||
id="rect3365"
|
||||
style="opacity:0.41699997;fill:none;stroke:none" />
|
||||
<rect
|
||||
rx="2"
|
||||
style="fill:#6d6d6d;fill-opacity:1;stroke:none"
|
||||
id="rect3367"
|
||||
width="4"
|
||||
height="17"
|
||||
x="359"
|
||||
y="536"
|
||||
ry="2" />
|
||||
</g>
|
||||
<use
|
||||
style="opacity:0.887"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.8660254,0.5,-0.5,0.8660254,332.36483,-104.40243)"
|
||||
id="use3463"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.773"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.5,0.8660254,-0.8660254,0.5,672.40243,-28.635171)"
|
||||
id="use3467"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.66"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0,1,-1,0,929,207)"
|
||||
id="use3469"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.547"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.5,0.8660254,-0.8660254,-0.5,1033.4024,539.36483)"
|
||||
id="use3471"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.433"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.8660254,0.5,-0.5,-0.8660254,957.63514,879.40243)"
|
||||
id="use3473"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-1,0,0,-1,721.99997,1136)"
|
||||
id="use3475"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.8660254,-0.5,0.5,-0.8660254,389.63514,1240.4024)"
|
||||
id="use3477"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(-0.5,-0.8660254,0.8660254,-0.5,49.597541,1164.6351)"
|
||||
id="use3479"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0,-1,1,0,-207.00003,928.99993)"
|
||||
id="use3481"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.5,-0.8660254,0.8660254,0.5,-311.40246,596.6351)"
|
||||
id="use3483"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
<use
|
||||
style="opacity:0.32"
|
||||
height="600"
|
||||
width="800"
|
||||
transform="matrix(0.8660254,-0.5,0.5,0.8660254,-235.6352,256.5975)"
|
||||
id="use3485"
|
||||
xlink:href="#g3369"
|
||||
y="0"
|
||||
x="0" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
|
||||
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user