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