open file dialog added for selecting a profile data file and an optional "compare...
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Mon, 26 Mar 2018 18:24:20 +0000 (21:24 +0300)
committerAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Mon, 26 Mar 2018 18:24:20 +0000 (21:24 +0300)
src/analyze/gui/gui.qrc [new file with mode: 0644]
src/analyze/gui/icons/fileopen.png [new file with mode: 0644]
src/analyze/gui/mainwindow.cpp
src/analyze/gui/mainwindow.h
src/analyze/gui/mainwindow_noklib.ui
src/heaptrack_gui.pro

diff --git a/src/analyze/gui/gui.qrc b/src/analyze/gui/gui.qrc
new file mode 100644 (file)
index 0000000..007d3c6
--- /dev/null
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/" >
+        <file>icons/fileopen.png</file>
+    </qresource>
+</RCC>
diff --git a/src/analyze/gui/icons/fileopen.png b/src/analyze/gui/icons/fileopen.png
new file mode 100644 (file)
index 0000000..33e0d63
Binary files /dev/null and b/src/analyze/gui/icons/fileopen.png differ
index 26f95a23900b32fa5f19dcdb4a3b35b0db13e12b..2cbf6f529fb5b0cc8de3db106c7a1f91e4d4a848 100644 (file)
@@ -25,6 +25,7 @@
 #include <ui_mainwindow_noklib.h>
 #include "aboutdialog.h"
 #include <QAbstractButton>
+#include <QFileDialog>
 #else
 #include <ui_mainwindow.h>
 #include <KConfigGroup>
@@ -496,6 +497,7 @@ MainWindow::MainWindow(QWidget* parent)
     setupObjectTreeModel(objectTreeModel, m_ui->objectTreeResults, m_ui->filterClass, m_ui->filterGC);
 
     auto validateInputFile = [this](const QString& path, bool allowEmpty) -> bool {
+        m_ui->messages->hide();
         if (path.isEmpty()) {
             return allowEmpty;
         }
@@ -531,19 +533,24 @@ MainWindow::MainWindow(QWidget* parent)
     m_ui->buttonBox->setEnabled(true);
 
     auto validateInputAndLoadFile = [this, validateInputFile]() {
-       const auto path = m_ui->openFile->text();
+       const auto path = m_ui->openFileEdit->text();
        if (!validateInputFile(path, false)) {
            return;
        }
        Q_ASSERT(!path.isEmpty());
-       const auto base = m_ui->compareTo->text();
+       const auto base = m_ui->compareToEdit->text();
        if (!validateInputFile(base, true)) {
            return;
        }
+       QApplication::setOverrideCursor(Qt::WaitCursor);
        loadFile(path, base);
+       QApplication::restoreOverrideCursor();
     };
 
     connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, validateInputAndLoadFile);
+
+    connect(m_ui->openFileButton1, &QPushButton::clicked, this, &MainWindow::selectOpenFile);
+    connect(m_ui->openFileButton2, &QPushButton::clicked, this, &MainWindow::selectCompareToFile);
 #endif
 
     setupStacks();
@@ -722,6 +729,26 @@ void MainWindow::setupStacks()
 }
 
 #ifdef NO_K_LIB
+static void selectFile(QWidget *parent, QLineEdit *fileNameEdit)
+{
+    QString fileName = QFileDialog::getOpenFileName(parent, "Select Data File",
+        "", "GZ (*.gz);; All files (*)");
+    if (!fileName.isEmpty())
+    {
+        fileNameEdit->setText(fileName);
+    }
+}
+
+void MainWindow::selectOpenFile()
+{
+    selectFile(this, m_ui->openFileEdit);
+}
+
+void MainWindow::selectCompareToFile()
+{
+    selectFile(this, m_ui->compareToEdit);
+}
+
 void MainWindow::about()
 {
     AboutDialog dlg(this);
index 8b9f95fb90268cfef75e630d598b44e36cfa5c57..3ed89f892039a21f7c366473c4872e9d674279e9 100644 (file)
@@ -52,6 +52,8 @@ signals:
 
 #ifdef NO_K_LIB
 public slots:
+    void selectOpenFile();
+    void selectCompareToFile();
     void about();
 #endif
 #ifdef QWT_FOUND
index d8db514f392fd91f6e49679e64b3338a904db72e..bf66e389fc5e7a849cb3e9af14a9be2c6fd81901 100644 (file)
            <string>Open Heaptrack Data</string>
           </property>
           <layout class="QFormLayout" name="formLayout">
-           <item row="1" column="1">
-            <widget class="QLineEdit" name="openFile">
-             <property name="toolTip">
-              <string>&lt;qt&gt;&lt;p&gt;This field specifies the primary heaptrack data file. These files are called &lt;tt&gt;heaptrack.$APP.$PID.gz&lt;/tt&gt;. You can produce such a file by profiling your application, e.g. via:&lt;/p&gt;
-&lt;pre&gt;&lt;code&gt;heaptrack &amp;lt;yourapplication&amp;gt; ...&lt;/code&gt;&lt;/pre&gt;
-&lt;p&gt;Or, alternatively, you can attach to a running process via&lt;/p&gt;
-&lt;pre&gt;&lt;code&gt;heaptrack --pid $(pidof &amp;lt;yourapplication&amp;gt;)&lt;/code&gt;&lt;/pre&gt;&lt;/qt&gt;</string>
-             </property>
-             <property name="text">
-              <string>heaptrack.*.*.gz (PLEASE ENTER path/to/heaptrack.$APP.$PID.gz)</string>
-             </property>
-            </widget>
-           </item>
-           <item row="2" column="1">
-            <widget class="QLineEdit" name="compareTo">
-             <property name="toolTip">
-              <string>&lt;qt&gt;You can optionally specify a second heaptrack data file to compare to. If set, this file will be used as a base and its cost gets subtracted from the primary data costs.&lt;/qt&gt;</string>
-             </property>
-             <property name="text">
-              <string>heaptrack.*.*.gz (PLEASE ENTER path/to/heaptrack.$APP.$PID.gz) [OPTIONAL]</string>
-             </property>
-            </widget>
-           </item>
            <item row="1" column="0">
             <widget class="QLabel" name="openFileLabel">
              <property name="text">
               <string>Profile &amp;Data:</string>
              </property>
              <property name="buddy">
-              <cstring>openFile</cstring>
+              <cstring>openFileEdit</cstring>
              </property>
             </widget>
            </item>
+           <item row="1" column="1">
+            <layout class="QHBoxLayout" name="horizontalLayout_1">
+             <item>
+              <widget class="QLineEdit" name="openFileEdit">
+               <property name="toolTip">
+                <string>&lt;qt&gt;&lt;p&gt;This field specifies the primary heaptrack data file. These files are called &lt;tt&gt;heaptrack.$APP.$PID.gz&lt;/tt&gt;. You can produce such a file by profiling your application, e.g. via:&lt;/p&gt;
+     &lt;pre&gt;&lt;code&gt;heaptrack &amp;lt;yourapplication&amp;gt; ...&lt;/code&gt;&lt;/pre&gt;
+     &lt;p&gt;Or, alternatively, you can attach to a running process via&lt;/p&gt;
+     &lt;pre&gt;&lt;code&gt;heaptrack --pid $(pidof &amp;lt;yourapplication&amp;gt;)&lt;/code&gt;&lt;/pre&gt;&lt;/qt&gt;</string>
+               </property>
+               <property name="text">
+                <string>heaptrack.*.*.gz (PLEASE ENTER OR SELECT path/to/heaptrack.$APP.$PID.gz)</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QPushButton" name="openFileButton1">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="text">
+                <string/>
+               </property>
+               <property name="icon">
+                <iconset resource="gui.qrc">
+                 <normaloff>:/icons/fileopen.png</normaloff>:/icons/fileopen.png</iconset>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </item>
            <item row="2" column="0">
             <widget class="QLabel" name="compareToLabel">
              <property name="text">
               <string>Compare to:</string>
              </property>
              <property name="buddy">
-              <cstring>compareTo</cstring>
+              <cstring>compareToEdit</cstring>
              </property>
             </widget>
            </item>
+           <item row="2" column="1">
+            <layout class="QHBoxLayout" name="horizontalLayout_8">
+             <item>
+              <widget class="QLineEdit" name="compareToEdit">
+               <property name="toolTip">
+                <string>&lt;qt&gt;You can optionally specify a second heaptrack data file to compare to. If set, this file will be used as a base and its cost gets subtracted from the primary data costs.&lt;/qt&gt;</string>
+               </property>
+               <property name="text">
+                <string/>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QPushButton" name="openFileButton2">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="icon">
+                <iconset resource="gui.qrc">
+                 <normaloff>:/icons/fileopen.png</normaloff>:/icons/fileopen.png</iconset>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </item>
           </layout>
          </widget>
         </item>
            <layout class="QVBoxLayout" name="verticalLayout">
             <item>
              <widget class="QWidget" name="widget" native="true">
-              <layout class="QHBoxLayout" name="horizontalLayout">
+              <layout class="QHBoxLayout" name="horizontalLayout_9">
                <property name="spacing">
                 <number>6</number>
                </property>
    <container>1</container>
   </customwidget>
  </customwidgets>
- <resources/>
+ <resources>
+  <include location="gui.qrc"/>
+ </resources>
  <connections/>
 </ui>
index fffb344683f101e29b274ed4ac052b0137f6aec0..3fadc2fceae979f76e5194c2ef4cff102cab541c 100644 (file)
@@ -144,4 +144,7 @@ NO_K_LIB {
     FORMS += \
         analyze/gui/mainwindow_noklib.ui \
         analyze/gui/aboutdialog.ui
+
+    RESOURCES += \
+        analyze/gui/gui.qrc
 }