summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@kde.org>2011-04-10 22:56:31 -0400
committerZack Rusin <zack@kde.org>2011-04-10 22:56:31 -0400
commit3438a524eb988749c39d849cb0127996d6656471 (patch)
treefcbce602348ffa9f911e954a7eaf4535bc206ebb
parenta68464141d0ad5a833d5661a52b06950db6c61a5 (diff)
Add a trace dialog.
-rw-r--r--gui/CMakeLists.txt2
-rw-r--r--gui/mainwindow.cpp13
-rw-r--r--gui/mainwindow.h1
-rw-r--r--gui/qapitrace.qrc1
-rw-r--r--gui/resources/document-new.pngbin0 -> 1410 bytes
-rw-r--r--gui/tracedialog.cpp68
-rw-r--r--gui/tracedialog.h25
-rw-r--r--gui/ui/mainwindow.ui28
-rw-r--r--gui/ui/tracedialog.ui110
9 files changed, 239 insertions, 9 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 8da0f613..068ffa3f 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -15,6 +15,7 @@ set(qapitrace_SRCS
retracer.cpp
settingsdialog.cpp
shaderssourcewidget.cpp
+ tracedialog.cpp
vertexdatainterpreter.cpp
)
@@ -27,6 +28,7 @@ set(qapitrace_UIS
ui/mainwindow.ui
ui/retracerdialog.ui
ui/settings.ui
+ ui/tracedialog.ui
ui/shaderssourcewidget.ui
)
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index ff9f05ca..e2d58b6c 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -9,6 +9,7 @@
#include "retracer.h"
#include "settingsdialog.h"
#include "shaderssourcewidget.h"
+#include "tracedialog.h"
#include "ui_retracerdialog.h"
#include "vertexdatainterpreter.h"
@@ -37,6 +38,16 @@ MainWindow::MainWindow()
initConnections();
}
+void MainWindow::createTrace()
+{
+ TraceDialog dialog;
+
+ if (dialog.exec() == QDialog::Accepted) {
+ qDebug()<< "App : " <<dialog.applicationPath();
+ qDebug()<< " Arguments: "<<dialog.arguments();
+ }
+}
+
void MainWindow::openTrace()
{
QString fileName =
@@ -510,6 +521,8 @@ void MainWindow::initConnections()
m_vdataInterpreter, SLOT(setStartingOffset(int)));
+ connect(m_ui.actionNew, SIGNAL(triggered()),
+ this, SLOT(createTrace()));
connect(m_ui.actionOpen, SIGNAL(triggered()),
this, SLOT(openTrace()));
connect(m_ui.actionQuit, SIGNAL(triggered()),
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index 313180a1..be0c4154 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -33,6 +33,7 @@ public slots:
private slots:
void callItemSelected(const QModelIndex &index);
+ void createTrace();
void openTrace();
void filterTrace();
void replayStart();
diff --git a/gui/qapitrace.qrc b/gui/qapitrace.qrc
index 6623f1fe..10311a90 100644
--- a/gui/qapitrace.qrc
+++ b/gui/qapitrace.qrc
@@ -2,6 +2,7 @@
<qresource>
<file>resources/application-exit.png</file>
<file>resources/dialog-information.png</file>
+ <file>resources/document-new.png</file>
<file>resources/document-open.png</file>
<file>resources/media-playback-start.png</file>
<file>resources/media-playback-stop.png</file>
diff --git a/gui/resources/document-new.png b/gui/resources/document-new.png
new file mode 100644
index 00000000..3d0f5cc1
--- /dev/null
+++ b/gui/resources/document-new.png
Binary files differ
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"
diff --git a/gui/tracedialog.h b/gui/tracedialog.h
new file mode 100644
index 00000000..d5e502dd
--- /dev/null
+++ b/gui/tracedialog.h
@@ -0,0 +1,25 @@
+#ifndef TRACEDIALOG_H
+#define TRACEDIALOG_H
+
+#include "ui_tracedialog.h"
+#include <QDialog>
+
+class TraceDialog : public QDialog, public Ui_TraceDialog
+{
+ Q_OBJECT
+public:
+ TraceDialog(QWidget *parent = 0);
+
+ void accept();
+
+ QString applicationPath() const;
+ QStringList arguments() const;
+
+private slots:
+ void browse();
+
+private:
+ bool isFileOk(const QString &fileName);
+};
+
+#endif
diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui
index 89b5836c..574bfa26 100644
--- a/gui/ui/mainwindow.ui
+++ b/gui/ui/mainwindow.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>787</width>
- <height>758</height>
+ <height>756</height>
</rect>
</property>
<property name="windowTitle">
@@ -48,14 +48,6 @@
<height>21</height>
</rect>
</property>
- <widget class="QMenu" name="menuFile">
- <property name="title">
- <string>&amp;File</string>
- </property>
- <addaction name="actionOpen"/>
- <addaction name="separator"/>
- <addaction name="actionQuit"/>
- </widget>
<widget class="QMenu" name="menu_Trace">
<property name="title">
<string>&amp;Trace</string>
@@ -66,6 +58,15 @@
<addaction name="separator"/>
<addaction name="actionOptions"/>
</widget>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionNew"/>
+ <addaction name="actionOpen"/>
+ <addaction name="separator"/>
+ <addaction name="actionQuit"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menu_Trace"/>
</widget>
@@ -437,6 +438,15 @@
<string>Options</string>
</property>
</action>
+ <action name="actionNew">
+ <property name="icon">
+ <iconset resource="../qapitrace.qrc">
+ <normaloff>:/resources/document-new.png</normaloff>:/resources/document-new.png</iconset>
+ </property>
+ <property name="text">
+ <string>New</string>
+ </property>
+ </action>
<zorder>stateDock</zorder>
<zorder>vertexDataDock</zorder>
</widget>
diff --git a/gui/ui/tracedialog.ui b/gui/ui/tracedialog.ui
new file mode 100644
index 00000000..149881f7
--- /dev/null
+++ b/gui/ui/tracedialog.ui
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TraceDialog</class>
+ <widget class="QDialog" name="TraceDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>401</width>
+ <height>95</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Application:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="applicationEdit">
+ <property name="placeholderText">
+ <string>Application to trace</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseButton">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Arguments:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="argumentsEdit">
+ <property name="placeholderText">
+ <string>Separate arguments with &quot;;&quot;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>TraceDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>TraceDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>