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