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