diff options
Diffstat (limited to 'gui/tracedialog.cpp')
-rw-r--r-- | gui/tracedialog.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/gui/tracedialog.cpp b/gui/tracedialog.cpp new file mode 100644 index 00000000..a25c7aca --- /dev/null +++ b/gui/tracedialog.cpp @@ -0,0 +1,68 @@ +#include "tracedialog.h" + +#include <QDebug> +#include <QFileDialog> +#include <QMessageBox> + +TraceDialog::TraceDialog(QWidget *parent) + : QDialog(parent) +{ + setupUi(this); + + connect(browseButton, SIGNAL(clicked()), + this, SLOT(browse())); +} + +QString TraceDialog::applicationPath() const +{ + return applicationEdit->text(); +} + +QStringList TraceDialog::arguments() const +{ + QStringList args = + argumentsEdit->text().split(';'); + return args; +} + +void TraceDialog::browse() +{ + QString fileName = + QFileDialog::getOpenFileName( + this, + tr("Find the application"), + QDir::currentPath()); + + if (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" |