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