@@ -1,108 +1,108 | |||||
1 | #include "widget.h" |
|
1 | #include "widget.h" | |
2 | #include <QPushButton> |
|
2 | #include <QPushButton> | |
3 | #include <QDir> |
|
3 | #include <QDir> | |
4 | #include <QGridLayout> |
|
4 | #include <QGridLayout> | |
5 | #include <QApplication> |
|
5 | #include <QApplication> | |
6 | #include <QProcess> |
|
6 | #include <QProcess> | |
7 | #include <QDebug> |
|
7 | #include <QDebug> | |
8 | #include <QLabel> |
|
8 | #include <QLabel> | |
9 | #include <QMouseEvent> |
|
9 | #include <QMouseEvent> | |
10 | #include "graphicsbutton.h" |
|
10 | #include "graphicsbutton.h" | |
11 |
|
11 | |||
12 | Widget::Widget(QWidget *parent) |
|
12 | Widget::Widget(QWidget *parent) | |
13 | : QWidget(parent), |
|
13 | : QWidget(parent), | |
14 | m_demoApp(0) |
|
14 | m_demoApp(0) | |
15 | { |
|
15 | { | |
16 | setMinimumSize(200, 200); |
|
16 | setMinimumSize(200, 200); | |
17 | // Create a list of executables |
|
17 | // Create a list of executables | |
18 | QList<QFileInfo> appList; |
|
18 | QList<QFileInfo> appList; | |
19 | m_appFolder = QDir(QApplication::applicationDirPath()); |
|
19 | m_appFolder = QDir(QApplication::applicationDirPath()); | |
20 |
|
20 | |||
21 | QStringList filter; |
|
21 | QStringList filter; | |
22 | filter << "audio"; |
|
22 | filter << "audio"; | |
23 | filter << "callout"; |
|
23 | filter << "callout"; | |
24 | filter << "chartthemes"; |
|
24 | filter << "chartthemes"; | |
25 | filter << "nesteddonuts"; |
|
25 | filter << "nesteddonuts"; | |
26 | filter << "zoomlinechart"; |
|
26 | filter << "zoomlinechart"; | |
27 | filter << "stackedbarchartdrilldown"; |
|
27 | filter << "stackedbarchartdrilldown"; | |
28 | filter << "piechartcustomization"; |
|
28 | filter << "piechartcustomization"; | |
29 | filter << "barmodelmapper"; |
|
29 | filter << "barmodelmapper"; | |
30 | m_appFolder.setNameFilters(filter); |
|
30 | m_appFolder.setNameFilters(filter); | |
31 | #ifdef Q_OS_MAC |
|
31 | #ifdef Q_OS_MAC | |
32 | // The executable is inside an application bundle (a folder) on OSX |
|
32 | // The executable is inside an application bundle (a folder) on OSX | |
33 | m_appFolder.cdUp(); |
|
33 | m_appFolder.cdUp(); | |
34 | m_appFolder.cdUp(); |
|
34 | m_appFolder.cdUp(); | |
35 | m_appFolder.cdUp(); |
|
35 | m_appFolder.cdUp(); | |
36 | #endif |
|
36 | #endif | |
37 |
|
37 | |||
38 | QDir imageFolder = m_appFolder; |
|
38 | QDir imageFolder = m_appFolder; | |
39 | imageFolder.cdUp(); |
|
39 | imageFolder.cdUp(); | |
40 | imageFolder.cdUp(); |
|
40 | imageFolder.cdUp(); | |
41 |
|
41 | |||
42 | int width = 300; |
|
42 | int width = 300; | |
43 |
|
43 | |||
44 | // Create push buttons for starting the executables |
|
44 | // Create push buttons for starting the executables | |
45 | QGridLayout* demosLayout = new QGridLayout; |
|
45 | QGridLayout* demosLayout = new QGridLayout; | |
46 |
|
46 | |||
47 | GraphicsButton *button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demos_audio.png", m_appFolder, "audio", this); |
|
47 | GraphicsButton *button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demos_audio.png", m_appFolder, "audio", this); | |
48 | demosLayout->addWidget(button, 0, 0); |
|
48 | demosLayout->addWidget(button, 0, 0); | |
49 |
|
49 | |||
50 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_callout.png", m_appFolder, "callout", this); |
|
50 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_callout.png", m_appFolder, "callout", this); | |
51 | demosLayout->addWidget(button, 0, 1); |
|
51 | demosLayout->addWidget(button, 0, 1); | |
52 |
|
52 | |||
53 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demo_chartthemes_blue_cerulean.png", m_appFolder, "chartthemes", this); |
|
53 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demo_chartthemes_blue_cerulean.png", m_appFolder, "chartthemes", this); | |
54 | demosLayout->addWidget(button, 0, 2); |
|
54 | demosLayout->addWidget(button, 0, 2); | |
55 |
|
55 | |||
56 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demos_nesteddonuts.png", m_appFolder, "nesteddonuts", this); |
|
56 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/demos_nesteddonuts.png", m_appFolder, "nesteddonuts", this); | |
57 | demosLayout->addWidget(button, 1, 0); |
|
57 | demosLayout->addWidget(button, 1, 0); | |
58 |
|
58 | |||
59 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_zoomlinechart1.png", m_appFolder, "zoomlinechart", this); |
|
59 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_zoomlinechart1.png", m_appFolder, "zoomlinechart", this); | |
60 | demosLayout->addWidget(button, 1, 1); |
|
60 | demosLayout->addWidget(button, 1, 1); | |
61 |
|
61 | |||
62 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_stackedbarchartdrilldown1.png", m_appFolder, "stackedbarchartdrilldown", this); |
|
62 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_stackedbarchartdrilldown1.png", m_appFolder, "stackedbarchartdrilldown", this); | |
63 | demosLayout->addWidget(button, 1, 2); |
|
63 | demosLayout->addWidget(button, 1, 2); | |
64 |
|
64 | |||
65 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/piechart_customization.png", m_appFolder, "piechartcustomization", this); |
|
65 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/piechart_customization.png", m_appFolder, "piechartcustomization", this); | |
66 | demosLayout->addWidget(button, 2, 0); |
|
66 | demosLayout->addWidget(button, 2, 0); | |
67 |
|
67 | |||
68 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_datetimeaxis.png", m_appFolder, "datetimeaxis", this); |
|
68 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_datetimeaxis.png", m_appFolder, "datetimeaxis", this); | |
69 | demosLayout->addWidget(button, 2, 1); |
|
69 | demosLayout->addWidget(button, 2, 1); | |
70 |
|
70 | |||
71 |
button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_d |
|
71 | button = new GraphicsButton(imageFolder.absolutePath() + "/doc/images/examples_donutbreakdown.png", m_appFolder, "donutbreakdown", this); | |
72 | demosLayout->addWidget(button, 2, 2); |
|
72 | demosLayout->addWidget(button, 2, 2); | |
73 |
|
73 | |||
74 | setLayout(demosLayout); |
|
74 | setLayout(demosLayout); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | Widget::~Widget() |
|
77 | Widget::~Widget() | |
78 | { |
|
78 | { | |
79 | QList<QObject *> children = this->children(); |
|
79 | QList<QObject *> children = this->children(); | |
80 | for (int i = 0; i < children.count(); i++) { |
|
80 | for (int i = 0; i < children.count(); i++) { | |
81 | QProcess *app = qobject_cast<QProcess *>(children.at(i)); |
|
81 | QProcess *app = qobject_cast<QProcess *>(children.at(i)); | |
82 | if (app) |
|
82 | if (app) | |
83 | app->close(); |
|
83 | app->close(); | |
84 | } |
|
84 | } | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | void Widget::runApp() |
|
87 | void Widget::runApp() | |
88 | { |
|
88 | { | |
89 | QString name = qobject_cast<QPushButton *>(sender())->text(); |
|
89 | QString name = qobject_cast<QPushButton *>(sender())->text(); | |
90 | QString program = m_appFolder.absolutePath() + QDir::separator() + name; |
|
90 | QString program = m_appFolder.absolutePath() + QDir::separator() + name; | |
91 | m_demoApp = new QProcess(this); |
|
91 | m_demoApp = new QProcess(this); | |
92 | m_demoApp->start(program); |
|
92 | m_demoApp->start(program); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | void Widget::mousePressEvent(QMouseEvent * event) |
|
95 | void Widget::mousePressEvent(QMouseEvent * event) | |
96 | { |
|
96 | { | |
97 | for (int i = 0; i < layout()->count(); i++) { |
|
97 | for (int i = 0; i < layout()->count(); i++) { | |
98 | QWidget *pic = layout()->itemAt(i)->widget(); |
|
98 | QWidget *pic = layout()->itemAt(i)->widget(); | |
99 | if (pic && pic->rect().contains(pic->mapFromParent(event->pos()))) { |
|
99 | if (pic && pic->rect().contains(pic->mapFromParent(event->pos()))) { | |
100 | QString value = m_map.value(pic); |
|
100 | QString value = m_map.value(pic); | |
101 | QString program = m_appFolder.absolutePath() + QDir::separator() + value; |
|
101 | QString program = m_appFolder.absolutePath() + QDir::separator() + value; | |
102 | m_demoApp = new QProcess(this); |
|
102 | m_demoApp = new QProcess(this); | |
103 | m_demoApp->start(program); |
|
103 | m_demoApp->start(program); | |
104 | event->accept(); |
|
104 | event->accept(); | |
105 | return; |
|
105 | return; | |
106 | } |
|
106 | } | |
107 | } |
|
107 | } | |
108 | } |
|
108 | } |
General Comments 0
You need to be logged in to leave comments.
Login now