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