@@ -1,55 +1,59 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
7 | ** This file is part of the Qt Enterprise Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
10 | ** Licensees holding valid Qt Enterprise licenses may use this file in | |
11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
11 | ** accordance with the Qt Enterprise License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "graphicsbutton.h" |
|
21 | #include "graphicsbutton.h" | |
22 | #include <QPainter> |
|
22 | #include <QPainter> | |
23 | #include <QProcess> |
|
23 | #include <QProcess> | |
24 | #include <QMouseEvent> |
|
24 | #include <QMouseEvent> | |
25 |
|
25 | |||
26 | GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : |
|
26 | GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : | |
27 | QWidget(parent), |
|
27 | QWidget(parent), | |
28 | m_path(path), |
|
28 | m_path(path), | |
29 | m_appFolder(appFolder), |
|
29 | m_appFolder(appFolder), | |
30 | m_app(app), |
|
30 | m_app(app), | |
31 | m_demoApp(0) |
|
31 | m_demoApp(0) | |
32 | { |
|
32 | { | |
33 | m_pixmap = QPixmap(path); |
|
33 | m_pixmap = QPixmap(path); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | GraphicsButton::~GraphicsButton() |
|
36 | GraphicsButton::~GraphicsButton() | |
37 | { |
|
37 | { | |
38 | if (m_demoApp) |
|
38 | if (m_demoApp) | |
39 | m_demoApp->close(); |
|
39 | m_demoApp->close(); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void GraphicsButton::mousePressEvent(QMouseEvent *event) |
|
42 | void GraphicsButton::mousePressEvent(QMouseEvent *event) | |
43 | { |
|
43 | { | |
44 | QString program = m_appFolder.absolutePath() + QDir::separator() + m_app; |
|
44 | QString program = m_appFolder.absolutePath() + QDir::separator() + m_app; | |
|
45 | if (m_demoApp) { | |||
|
46 | m_demoApp->close(); | |||
|
47 | delete m_demoApp; | |||
|
48 | } | |||
45 | m_demoApp = new QProcess(this); |
|
49 | m_demoApp = new QProcess(this); | |
46 | m_demoApp->start(program); |
|
50 | m_demoApp->start(program); | |
47 | event->accept(); |
|
51 | event->accept(); | |
48 | } |
|
52 | } | |
49 |
|
53 | |||
50 | void GraphicsButton::paintEvent(QPaintEvent *event) |
|
54 | void GraphicsButton::paintEvent(QPaintEvent *event) | |
51 | { |
|
55 | { | |
52 | QPainter painter(this); |
|
56 | QPainter painter(this); | |
53 | painter.drawPixmap(0, 0, this->width(), this->height(), m_pixmap); |
|
57 | painter.drawPixmap(0, 0, this->width(), this->height(), m_pixmap); | |
54 | QWidget::paintEvent(event); |
|
58 | QWidget::paintEvent(event); | |
55 | } |
|
59 | } |
General Comments 0
You need to be logged in to leave comments.
Login now