##// END OF EJS Templates
demoLauncher fixed again
Marek Rosa -
r2236:3577330858e8
parent child
Show More
@@ -1,48 +1,46
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
7
8 Widget::Widget(QWidget *parent)
8 Widget::Widget(QWidget *parent)
9 : QWidget(parent),
9 : QWidget(parent),
10 m_demoApp(0)
10 m_demoApp(0)
11 {
11 {
12 QList<QFileInfo> appList;
12 QList<QFileInfo> appList;
13 QDir appFolder = QDir(BINPATH);
13 QDir appFolder = QDir(BINPATH);
14 appList = appFolder.entryInfoList(QDir::Files);
14 appList = appFolder.entryInfoList(QDir::Files);
15
15
16 for (int k = appList.count() - 1; k >= 0; k--) {
16 for (int k = appList.count() - 1; k >= 0; k--) {
17 QString name = appList[k].fileName();
17 QString name = appList[k].fileName();
18 if (name.endsWith("exp")
18 if (name.startsWith("tst_")
19 || name.endsWith("dll")
19 || name.startsWith("demoLauncher")
20 || name.endsWith("lib")
20 || (name.right(4).left(1) == "." && !name.endsWith("exe")))
21 || name.startsWith("tst_")
22 || name.startsWith("demoLauncher"))
23 appList.removeAt(k);
21 appList.removeAt(k);
24 }
22 }
25
23
26 QGridLayout* demosLayout = new QGridLayout;
24 QGridLayout* demosLayout = new QGridLayout;
27 for( int i = 0; i < appList.count(); i++) {
25 for( int i = 0; i < appList.count(); i++) {
28 QPushButton *button = new QPushButton(appList[i].fileName());
26 QPushButton *button = new QPushButton(appList[i].baseName());
29 connect(button, SIGNAL(clicked()), this, SLOT (runApp()));
27 connect(button, SIGNAL(clicked()), this, SLOT (runApp()));
30 demosLayout->addWidget(button, i%10, i/10);
28 demosLayout->addWidget(button, i%10, i/10);
31 }
29 }
32 setLayout(demosLayout);
30 setLayout(demosLayout);
33 }
31 }
34
32
35 Widget::~Widget()
33 Widget::~Widget()
36 {
34 {
37 if (m_demoApp)
35 if (m_demoApp)
38 m_demoApp->close();
36 m_demoApp->close();
39 }
37 }
40
38
41 void Widget::runApp()
39 void Widget::runApp()
42 {
40 {
43 QString name = qobject_cast<QPushButton *>(sender())->text();
41 QString name = qobject_cast<QPushButton *>(sender())->text();
44 QString program = QApplication::applicationDirPath() + QDir::separator() + name;
42 QString program = QDir(BINPATH).absolutePath() + QDir::separator() + name;
45
43
46 m_demoApp = new QProcess(this);
44 m_demoApp = new QProcess(this);
47 m_demoApp->start(program);
45 m_demoApp->start(program);
48 }
46 }
General Comments 0
You need to be logged in to leave comments. Login now