Merge branch 'master' of https://gitee.com/290198252/qsswraper
commit
8efd1d63b9
Binary file not shown.
30
Qss.cpp
30
Qss.cpp
|
@ -23,6 +23,7 @@
|
|||
#include <QTimer>
|
||||
#include <QCoreApplication>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QPainterPath>
|
||||
|
||||
#define QSSDIALOG_SHADOW_WIDTH 12
|
||||
#define QSSDIALOG_BODER_WIDTH 0
|
||||
|
@ -533,6 +534,9 @@ void QssMainWindow::showEvent(QShowEvent *ev)
|
|||
bool QssMainWindow::eventFilter(QObject * obj, QEvent * ev){
|
||||
if (obj == m_frame)
|
||||
{
|
||||
if (ev->type() == QEvent::Paint){
|
||||
|
||||
}
|
||||
if (ev->type() == QEvent::MouseMove)
|
||||
{
|
||||
QMouseEvent * mouseEv = dynamic_cast<QMouseEvent *>(ev);
|
||||
|
@ -665,6 +669,11 @@ void QssMainWindow::SetScale(float scale)
|
|||
|
||||
}
|
||||
|
||||
void QssMainWindow::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
QssDialog::QssDialog(QWidget *parent)
|
||||
: QDialog(0),
|
||||
m_parent(parent),
|
||||
|
@ -1736,7 +1745,8 @@ bool QssMaskWidget::eventFilter(QObject *obj, QEvent *ev)
|
|||
if(obj != this){
|
||||
if(mParent != nullptr){
|
||||
if(mParent->parentWidget() != nullptr){
|
||||
this->move(mParent->parentWidget()->geometry().width()/2,mParent->parentWidget()->geometry().height()/2);
|
||||
this->move(mParent->parentWidget()->geometry().width()/2,
|
||||
mParent->parentWidget()->geometry().height()/2);
|
||||
this->show();
|
||||
this->raise();
|
||||
}
|
||||
|
@ -1751,14 +1761,6 @@ bool QssMaskWidget::eventFilter(QObject *obj, QEvent *ev)
|
|||
|
||||
void QssMaskWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
// QPainter paint(this);
|
||||
// auto kBackgroundColor = QColor(20, 20, 20,20);
|
||||
//// kBackgroundColor.setAlpha( 1);// 透明度为0
|
||||
// paint.setRenderHint(QPainter::Antialiasing, true);
|
||||
// paint.setPen(Qt::NoPen);
|
||||
// paint.setBrush(QBrush(kBackgroundColor, Qt::SolidPattern));//设置画刷形式
|
||||
// paint.drawRect(0, 0, width(), height());
|
||||
// paint.end();
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
@ -1773,19 +1775,19 @@ QSSASyncProcess::~QSSASyncProcess()
|
|||
this->mThread.terminate();
|
||||
}
|
||||
|
||||
int QSSASyncProcess::Start()
|
||||
int QSSASyncProcess::Start(void *p)
|
||||
{
|
||||
this->moveToThread(&mThread);
|
||||
connect(this, SIGNAL(StartRun()), this, SLOT(Run()));
|
||||
connect(this, SIGNAL(StartRun(void *)), this, SLOT(Run(void *)));
|
||||
connect(&mThread, &QThread::finished, this, &QObject::deleteLater);
|
||||
|
||||
mThread.start();
|
||||
emit StartRun();
|
||||
emit StartRun(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QSSASyncProcess::Run()
|
||||
void QSSASyncProcess::Run(void *)
|
||||
{
|
||||
qDebug()<<"test run";
|
||||
emit(Done());
|
||||
}
|
||||
|
||||
|
|
10
Qss.h
10
Qss.h
|
@ -254,6 +254,8 @@ protected:
|
|||
virtual void ScaleChanged(float scale) ;
|
||||
virtual WId GetWID() const;
|
||||
virtual void SetScale(float scale) ;
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QRect m_rcValid;//桌面最大可用尺寸
|
||||
QRect m_rcNormal;//还原后窗口尺寸
|
||||
|
@ -497,13 +499,13 @@ class QSSASyncProcess : public QObject{
|
|||
public:
|
||||
QSSASyncProcess(QWidget *parent = nullptr);
|
||||
~QSSASyncProcess();
|
||||
int Start();
|
||||
int Start(void*);
|
||||
signals:
|
||||
void DonePercent(int);
|
||||
void Done();
|
||||
void StartRun();
|
||||
protected slots:
|
||||
virtual void Run();
|
||||
void StartRun(void *);
|
||||
public slots:
|
||||
virtual void Run(void *) ;
|
||||
protected:
|
||||
QWidget *mParent;
|
||||
QThread mThread;
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "chart_callout.h"
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtWidgets/QGraphicsSceneMouseEvent>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtCharts/QChart>
|
||||
|
||||
ChartCallout::ChartCallout(QChart *chart):
|
||||
QGraphicsItem(chart),
|
||||
m_chart(chart)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QRectF ChartCallout::boundingRect() const
|
||||
{
|
||||
QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor));
|
||||
QRectF rect;
|
||||
rect.setLeft(qMin(m_rect.left(), anchor.x()));
|
||||
rect.setRight(qMax(m_rect.right(), anchor.x()));
|
||||
rect.setTop(qMin(m_rect.top(), anchor.y()));
|
||||
rect.setBottom(qMax(m_rect.bottom(), anchor.y()));
|
||||
return rect;
|
||||
}
|
||||
|
||||
void ChartCallout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(m_rect, 5, 5);
|
||||
|
||||
QPointF anchor = mapFromParent(m_chart->mapToPosition(m_anchor));
|
||||
if (!m_rect.contains(anchor)) {
|
||||
QPointF point1, point2;
|
||||
|
||||
// establish the position of the anchor point in relation to m_rect
|
||||
bool above = anchor.y() <= m_rect.top();
|
||||
bool aboveCenter = anchor.y() > m_rect.top() && anchor.y() <= m_rect.center().y();
|
||||
bool belowCenter = anchor.y() > m_rect.center().y() && anchor.y() <= m_rect.bottom();
|
||||
bool below = anchor.y() > m_rect.bottom();
|
||||
|
||||
bool onLeft = anchor.x() <= m_rect.left();
|
||||
bool leftOfCenter = anchor.x() > m_rect.left() && anchor.x() <= m_rect.center().x();
|
||||
bool rightOfCenter = anchor.x() > m_rect.center().x() && anchor.x() <= m_rect.right();
|
||||
bool onRight = anchor.x() > m_rect.right();
|
||||
|
||||
// get the nearest m_rect corner.
|
||||
qreal x = (onRight + rightOfCenter) * m_rect.width();
|
||||
qreal y = (below + belowCenter) * m_rect.height();
|
||||
bool cornerCase = (above && onLeft) || (above && onRight) || (below && onLeft) || (below && onRight);
|
||||
bool vertical = qAbs(anchor.x() - x) > qAbs(anchor.y() - y);
|
||||
|
||||
qreal x1 = x + leftOfCenter * 10 - rightOfCenter * 20 + cornerCase * !vertical * (onLeft * 10 - onRight * 20);
|
||||
qreal y1 = y + aboveCenter * 10 - belowCenter * 20 + cornerCase * vertical * (above * 10 - below * 20);;
|
||||
point1.setX(x1);
|
||||
point1.setY(y1);
|
||||
|
||||
qreal x2 = x + leftOfCenter * 20 - rightOfCenter * 10 + cornerCase * !vertical * (onLeft * 20 - onRight * 10);;
|
||||
qreal y2 = y + aboveCenter * 20 - belowCenter * 10 + cornerCase * vertical * (above * 20 - below * 10);;
|
||||
point2.setX(x2);
|
||||
point2.setY(y2);
|
||||
|
||||
path.moveTo(point1);
|
||||
path.lineTo(anchor);
|
||||
path.lineTo(point2);
|
||||
path = path.simplified();
|
||||
}
|
||||
painter->setBrush(QColor(255, 255, 255));
|
||||
painter->drawPath(path);
|
||||
painter->drawText(m_textRect, m_text);
|
||||
}
|
||||
|
||||
void ChartCallout::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->setAccepted(true);
|
||||
}
|
||||
|
||||
void ChartCallout::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton){
|
||||
setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton)));
|
||||
event->setAccepted(true);
|
||||
} else {
|
||||
event->setAccepted(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ChartCallout::setText(const QString &text)
|
||||
{
|
||||
m_text = text;
|
||||
QFontMetrics metrics(m_font);
|
||||
m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text);
|
||||
m_textRect.translate(5, 5);
|
||||
prepareGeometryChange();
|
||||
m_rect = m_textRect.adjusted(-5, -5, 5, 5);
|
||||
}
|
||||
|
||||
void ChartCallout::setAnchor(QPointF point)
|
||||
{
|
||||
m_anchor = point;
|
||||
}
|
||||
|
||||
void ChartCallout::updateGeometry()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
setPos(m_chart->mapToPosition(m_anchor) + QPoint(10, -50));
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CALLOUT_H
|
||||
#define CALLOUT_H
|
||||
|
||||
#include <QtCharts/QChartGlobal>
|
||||
#include <QtWidgets/QGraphicsItem>
|
||||
#include <QtGui/QFont>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_CHARTS_BEGIN_NAMESPACE
|
||||
class QChart;
|
||||
QT_CHARTS_END_NAMESPACE
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
class ChartCallout : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
ChartCallout(QChart *parent);
|
||||
|
||||
void setText(const QString &text);
|
||||
void setAnchor(QPointF point);
|
||||
void updateGeometry();
|
||||
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
QRectF m_textRect;
|
||||
QRectF m_rect;
|
||||
QPointF m_anchor;
|
||||
QFont m_font;
|
||||
QChart *m_chart;
|
||||
};
|
||||
|
||||
#endif // CALLOUT_H
|
|
@ -0,0 +1,69 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "drilldownchart.h"
|
||||
#include <QtCharts/QBarCategoryAxis>
|
||||
#include <QtCharts/QValueAxis>
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
DrilldownChart::DrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||
: QChart(QChart::ChartTypeCartesian, parent, wFlags),
|
||||
m_currentSeries(0),
|
||||
m_axisX(new QBarCategoryAxis()),
|
||||
m_axisY(new QValueAxis())
|
||||
{
|
||||
addAxis(m_axisY, Qt::AlignLeft);
|
||||
addAxis(m_axisX, Qt::AlignBottom);
|
||||
}
|
||||
|
||||
void DrilldownChart::changeSeries(DrilldownBarSeries *series)
|
||||
{
|
||||
if (m_currentSeries)
|
||||
removeSeries(m_currentSeries);
|
||||
|
||||
m_currentSeries = series;
|
||||
|
||||
// Reset axis
|
||||
m_axisX->setCategories(m_currentSeries->categories());
|
||||
addSeries(series);
|
||||
series->attachAxis(m_axisX);
|
||||
series->attachAxis(m_axisY);
|
||||
m_axisY->setRange(0,m_currentSeries->maxValue());
|
||||
setTitle(series->name());
|
||||
}
|
||||
|
||||
void DrilldownChart::handleClicked(int index, QBarSet *barset)
|
||||
{
|
||||
Q_UNUSED(barset)
|
||||
DrilldownBarSeries *series = static_cast<DrilldownBarSeries *>(sender());
|
||||
changeSeries(series->drilldownSeries(index));
|
||||
}
|
||||
|
||||
#include "moc_drilldownchart.cpp"
|
|
@ -0,0 +1,62 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DRILLDOWNCHART_H
|
||||
#define DRILLDOWNCHART_H
|
||||
|
||||
#include <QtCharts/QChart>
|
||||
#include "drilldownseries.h"
|
||||
|
||||
namespace QtCharts {
|
||||
class QBarCategoryAxis;
|
||||
class QValueAxis;
|
||||
}
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
//! [1]
|
||||
class DrilldownChart : public QChart
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DrilldownChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {});
|
||||
|
||||
void changeSeries(DrilldownBarSeries *series);
|
||||
|
||||
public Q_SLOTS:
|
||||
void handleClicked(int index, QBarSet *barset);
|
||||
|
||||
private:
|
||||
DrilldownBarSeries *m_currentSeries;
|
||||
QBarCategoryAxis *m_axisX;
|
||||
QValueAxis *m_axisY;
|
||||
};
|
||||
//! [1]
|
||||
|
||||
#endif // DRILLDOWNCHART_H
|
|
@ -0,0 +1,60 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "drilldownseries.h"
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
DrilldownBarSeries::DrilldownBarSeries(QStringList categories, int maxValue, QObject *parent)
|
||||
: QStackedBarSeries(parent),
|
||||
m_maxValue(maxValue)
|
||||
{
|
||||
m_categories = categories;
|
||||
}
|
||||
|
||||
void DrilldownBarSeries::mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries)
|
||||
{
|
||||
m_DrilldownSeries[index] = drilldownSeries;
|
||||
}
|
||||
|
||||
DrilldownBarSeries *DrilldownBarSeries::drilldownSeries(int index)
|
||||
{
|
||||
return m_DrilldownSeries[index];
|
||||
}
|
||||
|
||||
QStringList DrilldownBarSeries::categories()
|
||||
{
|
||||
return m_categories;
|
||||
}
|
||||
|
||||
int DrilldownBarSeries::maxValue()
|
||||
{
|
||||
return m_maxValue;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef DRILLDOWNSERIES_H
|
||||
#define DRILLDOWNSERIES_H
|
||||
|
||||
#include <QtCharts/QStackedBarSeries>
|
||||
#include <QtCore/QMap>
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
//! [1]
|
||||
class DrilldownBarSeries : public QStackedBarSeries
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DrilldownBarSeries(QStringList categories, int maxValue, QObject *parent = 0);
|
||||
|
||||
void mapDrilldownSeries(int index, DrilldownBarSeries *drilldownSeries);
|
||||
|
||||
DrilldownBarSeries *drilldownSeries(int index);
|
||||
|
||||
QStringList categories();
|
||||
|
||||
int maxValue();
|
||||
|
||||
private:
|
||||
QMap<int, DrilldownBarSeries *> m_DrilldownSeries;
|
||||
QStringList m_categories;
|
||||
int m_maxValue;
|
||||
};
|
||||
//! [1]
|
||||
|
||||
#endif // DRILLDOWNSERIES_H
|
|
@ -0,0 +1,48 @@
|
|||
#include "loading_widget.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
LoadingAnimationWidget::LoadingAnimationWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_rotate(false),
|
||||
m_timer(nullptr),
|
||||
m_pixmap(nullptr)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
qDebug()<<"LoadingAnimationWidget";
|
||||
connect(m_timer,SIGNAL(timeout()),this,SLOT(timerout()));
|
||||
}
|
||||
|
||||
void LoadingAnimationWidget::SetPixmap(QPixmap *p)
|
||||
{
|
||||
connect(m_timer,SIGNAL(timeout()),this,SLOT(timerout()));
|
||||
|
||||
m_timer->setInterval(100);
|
||||
m_timer->start(40);
|
||||
m_pixmap = p;
|
||||
}
|
||||
|
||||
void LoadingAnimationWidget::timerout()
|
||||
{
|
||||
m_rotate =true;
|
||||
update();
|
||||
}
|
||||
|
||||
void LoadingAnimationWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
static int rotate = 0;
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing,true);
|
||||
painter.translate(width()/2,height()/2);
|
||||
|
||||
if(m_rotate)
|
||||
{
|
||||
rotate = (rotate+5)%360;
|
||||
m_rotate =false;
|
||||
}
|
||||
|
||||
painter.rotate(rotate);
|
||||
if(nullptr != m_pixmap)
|
||||
painter.drawPixmap(-m_pixmap->width()/2,-m_pixmap->height()/2,*m_pixmap);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef LOADING_WIDGET_H
|
||||
#define LOADING_WIDGET_H
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QPixmap>
|
||||
|
||||
class LoadingAnimationWidget:public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadingAnimationWidget(QWidget *parent);
|
||||
LoadingAnimationWidget(QWidget *parent,QPixmap*);
|
||||
void SetPixmap(QPixmap*);
|
||||
bool m_rotate;
|
||||
QTimer *m_timer;
|
||||
QPixmap *m_pixmap;
|
||||
public slots:
|
||||
void timerout();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
private:
|
||||
LoadingAnimationWidget();
|
||||
};
|
||||
|
||||
#endif // LOADING_WIDGET_H
|
|
@ -0,0 +1,107 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qchartwrap.h"
|
||||
#include <QtGui/QResizeEvent>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtCharts/QChart>
|
||||
#include <QtCharts/QLineSeries>
|
||||
#include <QtCharts/QSplineSeries>
|
||||
#include <QtWidgets/QGraphicsTextItem>
|
||||
#include "chart_callout.h"
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
QChartWrap::QChartWrap(QWidget *parent)
|
||||
: QChartView(parent),
|
||||
m_coordX(0),
|
||||
m_coordY(0),
|
||||
m_tooltip(0)
|
||||
{
|
||||
setDragMode(QGraphicsView::NoDrag);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
// chart
|
||||
this->chart()->setAcceptHoverEvents(true);
|
||||
|
||||
setRenderHint(QPainter::Antialiasing);
|
||||
scene()->addItem(this->chart());
|
||||
m_coordX = new QGraphicsSimpleTextItem(this->chart());
|
||||
m_coordX->setPos(0, this->chart()->size().height());
|
||||
m_coordX->setText("X: ");
|
||||
m_coordY = new QGraphicsSimpleTextItem(this->chart());
|
||||
m_coordY->setPos(100, this->chart()->size().height());
|
||||
m_coordY->setText("Y: ");
|
||||
|
||||
this->setMouseTracking(true);
|
||||
this->chart()->setMargins(QMargins(0,0,0,0));
|
||||
}
|
||||
|
||||
void QChartWrap::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if (scene()) {
|
||||
scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
|
||||
this->chart()->resize(event->size());
|
||||
m_coordX->setPos(0, this->chart()->size().height() - 20);
|
||||
m_coordY->setPos(100, this->chart()->size().height() - 20);
|
||||
const auto callouts = m_callouts;
|
||||
for (ChartCallout *callout : callouts)
|
||||
callout->updateGeometry();
|
||||
}
|
||||
QChartView::resizeEvent(event);
|
||||
}
|
||||
|
||||
void QChartWrap::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_coordX->setText(QString("X: %1").arg(this->chart()->mapToValue(event->pos()).x()));
|
||||
m_coordY->setText(QString("Y: %1").arg(this->chart()->mapToValue(event->pos()).y()));
|
||||
QChartView::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void QChartWrap::keepCallout()
|
||||
{
|
||||
m_callouts.append(m_tooltip);
|
||||
m_tooltip = new ChartCallout(this->chart());
|
||||
}
|
||||
|
||||
void QChartWrap::tooltip(QPointF point, bool state)
|
||||
{
|
||||
if (m_tooltip == 0)
|
||||
m_tooltip = new ChartCallout(this->chart());
|
||||
|
||||
if (state) {
|
||||
m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y()));
|
||||
m_tooltip->setAnchor(point);
|
||||
m_tooltip->setZValue(11);
|
||||
m_tooltip->updateGeometry();
|
||||
m_tooltip->show();
|
||||
} else {
|
||||
m_tooltip->hide();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the Qt Charts module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** 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 The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef VIEW_H
|
||||
#define VIEW_H
|
||||
#include <QtWidgets/QGraphicsView>
|
||||
#include <QtCharts/QChartGlobal>
|
||||
|
||||
#include <QtGui/QResizeEvent>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtCharts/QChart>
|
||||
#include <QtCharts/QLineSeries>
|
||||
#include <QtCharts/QSplineSeries>
|
||||
#include <QtCharts/QChartView>
|
||||
|
||||
#include <QtWidgets/QGraphicsTextItem>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsScene;
|
||||
class QMouseEvent;
|
||||
class QResizeEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_CHARTS_BEGIN_NAMESPACE
|
||||
class QChart;
|
||||
QT_CHARTS_END_NAMESPACE
|
||||
|
||||
class ChartCallout;
|
||||
|
||||
QT_CHARTS_USE_NAMESPACE
|
||||
|
||||
|
||||
class QChartWrap: public QChartView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QChartWrap(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
public slots:
|
||||
void keepCallout();
|
||||
void tooltip(QPointF point, bool state);
|
||||
|
||||
private:
|
||||
QGraphicsSimpleTextItem *m_coordX;
|
||||
QGraphicsSimpleTextItem *m_coordY;
|
||||
ChartCallout *m_tooltip;
|
||||
QList<ChartCallout *> m_callouts;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue