@@ -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. |
|
|
19 |
|| name. |
|
|
20 |
|| name.endsWith(" |
|
|
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]. |
|
|
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 = Q |
|
|
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