summaryrefslogtreecommitdiff
path: root/gui/tracedialog.cpp
blob: b8e438d9ddddc3c7fe49307f2b41de6778b47854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "tracedialog.h"

#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>

TraceDialog::TraceDialog(QWidget *parent)
    : QDialog(parent)
{
    setupUi(this);

    apiComboBox->addItem("GL");
#ifdef Q_OS_WIN
    apiComboBox->addItem("D3D7");
    apiComboBox->addItem("D3D8");
    apiComboBox->addItem("D3D9");
    apiComboBox->addItem("D3D10");
    apiComboBox->addItem("D3D10_1");
    apiComboBox->addItem("D3D11");
#else
    apiComboBox->addItem("EGL");
#endif

    connect(browseButton, SIGNAL(clicked()),
            this, SLOT(browse()));
}

QString TraceDialog::api() const
{
    return apiComboBox->currentText().toLower();
}

QString TraceDialog::applicationPath() const
{
    return applicationEdit->text();
}

QStringList TraceDialog::arguments() const
{
    QStringList args =
        argumentsEdit->text().split(';', QString::SkipEmptyParts);
    return args;
}

void TraceDialog::browse()
{
    QString fileName =
        QFileDialog::getOpenFileName(
            this,
            tr("Find the application"),
            QDir::currentPath());

    if (!fileName.isEmpty() && isFileOk(fileName)) {
        applicationEdit->setText(fileName);
    }
}

void TraceDialog::accept()
{
    if (isFileOk(applicationEdit->text())) {
        QDialog::accept();
    }
}

bool TraceDialog::isFileOk(const QString &fileName)
{
    QFileInfo fi(fileName);

    if (!fi.exists()) {
        QMessageBox::warning(this, tr("File Missing"),
                             tr("File '%1' doesn't exist.")
                             .arg(fi.fileName()));
        return false;
    }
    if (!fi.isExecutable()) {
        QMessageBox::warning(this, tr("Application Not Runnable"),
                             tr("File '%1' can't be executed.")
                             .arg(fi.fileName()));
        return false;
    }

    return true;
}

#include "tracedialog.moc"