##// END OF EJS Templates
demoLauncher should now work on all platforms
Marek Rosa -
r2234:db665d87eeda
parent child
Show More
@@ -1,7 +1,8
1 !include( ../demos.pri ):error( "Couldn't find the demos.pri file!" )
1 !include( ../demos.pri ):error( "Couldn't find the demos.pri file!" )
2 include(charts/charts.pri)
3
2
4 TARGET = demoLauncher
3 TARGET = demoLauncher
5 SOURCES += main.cpp\
4 SOURCES += main.cpp\
6 widget.cpp
5 widget.cpp
7 HEADERS += widget.h
6 HEADERS += widget.h
7
8 DEFINES += "BINPATH=$$join($$CHART_BUILD_BIN_DIR, ", ")"
@@ -1,46 +1,48
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 <QTimer>
8
7
9 Widget::Widget(QWidget *parent)
8 Widget::Widget(QWidget *parent)
10 : QWidget(parent),
9 : QWidget(parent),
11 m_demoApp(0)
10 m_demoApp(0)
12 {
11 {
13 QList<QFileInfo> appList;
12 QList<QFileInfo> appList;
14
13 QDir appFolder = QDir(BINPATH);
15 QDir appFolder(QApplication::applicationDirPath());
16 appList = appFolder.entryInfoList(QDir::Files);
14 appList = appFolder.entryInfoList(QDir::Files);
17
15
18 for (int k = appList.count() - 1; k >= 0; k--) {
16 for (int k = appList.count() - 1; k >= 0; k--) {
19 QString name = appList[k].fileName();
17 QString name = appList[k].fileName();
20 if (name.endsWith("exp") || name.endsWith("dll") || name.endsWith("lib") || name.startsWith("tst_"))
18 if (name.endsWith("exp")
19 || name.endsWith("dll")
20 || name.endsWith("lib")
21 || name.startsWith("tst_")
22 || name.startsWith("demoLauncher"))
21 appList.removeAt(k);
23 appList.removeAt(k);
22 }
24 }
23
25
24 QGridLayout* demosLayout = new QGridLayout;
26 QGridLayout* demosLayout = new QGridLayout;
25 for( int i = 0; i < appList.count(); i++) {
27 for( int i = 0; i < appList.count(); i++) {
26 QPushButton *button = new QPushButton(appList[i].fileName());
28 QPushButton *button = new QPushButton(appList[i].fileName());
27 connect(button, SIGNAL(clicked()), this, SLOT (runApp()));
29 connect(button, SIGNAL(clicked()), this, SLOT (runApp()));
28 demosLayout->addWidget(button, i%10, i/10);
30 demosLayout->addWidget(button, i%10, i/10);
29 }
31 }
30 setLayout(demosLayout);
32 setLayout(demosLayout);
31 }
33 }
32
34
33 Widget::~Widget()
35 Widget::~Widget()
34 {
36 {
35 if (m_demoApp)
37 if (m_demoApp)
36 m_demoApp->close();
38 m_demoApp->close();
37 }
39 }
38
40
39 void Widget::runApp()
41 void Widget::runApp()
40 {
42 {
41 QString name = qobject_cast<QPushButton *>(sender())->text();
43 QString name = qobject_cast<QPushButton *>(sender())->text();
42 QString program = QApplication::applicationDirPath() + QDir::separator() + name;
44 QString program = QApplication::applicationDirPath() + QDir::separator() + name;
43
45
44 m_demoApp = new QProcess(this);
46 m_demoApp = new QProcess(this);
45 m_demoApp->start(program);
47 m_demoApp->start(program);
46 }
48 }
@@ -1,24 +1,23
1 #ifndef WIDGET_H
1 #ifndef WIDGET_H
2 #define WIDGET_H
2 #define WIDGET_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5
5
6 class QProcess;
6 class QProcess;
7
7
8 class Widget : public QWidget
8 class Widget : public QWidget
9 {
9 {
10 Q_OBJECT
10 Q_OBJECT
11
11
12 public:
12 public:
13 Widget(QWidget *parent = 0);
13 Widget(QWidget *parent = 0);
14 ~Widget();
14 ~Widget();
15
15
16 public slots:
16 public slots:
17 void runApp();
17 void runApp();
18 // void runAppShow();
19
18
20 private:
19 private:
21 QProcess *m_demoApp;
20 QProcess *m_demoApp;
22 };
21 };
23
22
24 #endif // WIDGET_H
23 #endif // WIDGET_H
General Comments 0
You need to be logged in to leave comments. Login now