]> git.cworth.org Git - apitrace/commitdiff
gui/mainwindow: Add functions that toggle actions enables and use it.
authorAlexandr Akulich <akulichalexander@gmail.com>
Fri, 7 Dec 2012 10:59:52 +0000 (16:59 +0600)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 8 Dec 2012 13:02:07 +0000 (13:02 +0000)
Added enabling/disabling of few more actions.
Cleanup .ui file (set actions to default state).

gui/mainwindow.cpp
gui/mainwindow.h
gui/ui/mainwindow.ui

index caf9e370236ebed41d8aa29409cc3e253b1457a4..d6ebd2f9e1ecbe3a107222b684cda6c1e826c7e3 100644 (file)
@@ -48,6 +48,7 @@ MainWindow::MainWindow()
       m_nonDefaultsLookupEvent(0)
 {
     m_ui.setupUi(this);
+    updateActionsState(false);
     initObjects();
     initConnections();
 }
@@ -228,11 +229,7 @@ void MainWindow::replayProfile()
 void MainWindow::replayStop()
 {
     m_retracer->quit();
-    m_ui.actionStop->setEnabled(false);
-    m_ui.actionReplay->setEnabled(true);
-    m_ui.actionProfile->setEnabled(true);
-    m_ui.actionLookupState->setEnabled(true);
-    m_ui.actionShowThumbnails->setEnabled(true);
+    updateActionsState(true, true);
 }
 
 void MainWindow::newTraceFile(const QString &fileName)
@@ -243,18 +240,11 @@ void MainWindow::newTraceFile(const QString &fileName)
     m_trace->setFileName(fileName);
 
     if (fileName.isEmpty()) {
-        m_ui.actionReplay->setEnabled(false);
-        m_ui.actionProfile->setEnabled(false);
-        m_ui.actionLookupState->setEnabled(false);
-        m_ui.actionShowThumbnails->setEnabled(false);
+        updateActionsState(false);
         setWindowTitle(tr("QApiTrace"));
     } else {
+        updateActionsState(true);
         QFileInfo info(fileName);
-        m_ui.actionReplay->setEnabled(true);
-        m_ui.actionProfile->setEnabled(true);
-        m_ui.actionLookupState->setEnabled(true);
-        m_ui.actionShowThumbnails->setEnabled(true);
-        m_ui.actionTrim->setEnabled(true);
         setWindowTitle(
             tr("QApiTrace - %1").arg(info.fileName()));
     }
@@ -262,12 +252,7 @@ void MainWindow::newTraceFile(const QString &fileName)
 
 void MainWindow::replayFinished(const QString &message)
 {
-    m_ui.actionStop->setEnabled(false);
-    m_ui.actionReplay->setEnabled(true);
-    m_ui.actionProfile->setEnabled(true);
-    m_ui.actionLookupState->setEnabled(true);
-    m_ui.actionShowThumbnails->setEnabled(true);
-
+    updateActionsState(true);
     m_progressBar->hide();
     statusBar()->showMessage(message, 2000);
     m_stateEvent = 0;
@@ -280,11 +265,7 @@ void MainWindow::replayFinished(const QString &message)
 
 void MainWindow::replayError(const QString &message)
 {
-    m_ui.actionStop->setEnabled(false);
-    m_ui.actionReplay->setEnabled(true);
-    m_ui.actionProfile->setEnabled(true);
-    m_ui.actionLookupState->setEnabled(true);
-    m_ui.actionShowThumbnails->setEnabled(true);
+    updateActionsState(true);
     m_stateEvent = 0;
     m_nonDefaultsLookupEvent = 0;
 
@@ -936,6 +917,47 @@ void MainWindow::initConnections()
             this, SLOT(slotJumpTo(int)));
 }
 
+void MainWindow::updateActionsState(bool traceLoaded, bool stopped)
+{
+    if (traceLoaded) {
+        /* Edit */
+        m_ui.actionFind          ->setEnabled(true);
+        m_ui.actionGo            ->setEnabled(true);
+        m_ui.actionGoFrameStart  ->setEnabled(true);
+        m_ui.actionGoFrameEnd    ->setEnabled(true);
+
+        /* Trace */
+        if (stopped) {
+            m_ui.actionStop->setEnabled(false);
+            m_ui.actionReplay->setEnabled(true);
+        }
+        else {
+            m_ui.actionStop->setEnabled(true);
+            m_ui.actionReplay->setEnabled(false);
+        }
+
+        m_ui.actionProfile       ->setEnabled(true);
+        m_ui.actionLookupState   ->setEnabled(true);
+        m_ui.actionShowThumbnails->setEnabled(true);
+        m_ui.actionTrim          ->setEnabled(true);
+    }
+    else {
+        /* Edit */
+        m_ui.actionFind          ->setEnabled(false);
+        m_ui.actionGo            ->setEnabled(false);
+        m_ui.actionGoFrameStart  ->setEnabled(false);
+        m_ui.actionGoFrameEnd    ->setEnabled(false);
+
+        /* Trace */
+        m_ui.actionReplay        ->setEnabled(false);
+        m_ui.actionProfile       ->setEnabled(false);
+        m_ui.actionStop          ->setEnabled(false);
+        m_ui.actionLookupState   ->setEnabled(false);
+        m_ui.actionShowThumbnails->setEnabled(false);
+        m_ui.actionTrim          ->setEnabled(false);
+    }
+}
+
 void MainWindow::closeEvent(QCloseEvent * event)
 {
     m_profileDialog->close();
index 2248127f76aae57b8acd4728c7b090ad628564da..78267efca4c9f5cd98bb4eb0b48a5bc980ae3ceb 100644 (file)
@@ -98,6 +98,7 @@ private slots:
 private:
     void initObjects();
     void initConnections();
+    void updateActionsState(bool traceLoaded, bool stopped = true);
     void newTraceFile(const QString &fileName);
     void replayTrace(bool dumpState, bool dumpThumbnails);
     void trimEvent();
index 0135d1cf6ee27bd1b416c131debb70945c07c552..06f4503af50d92cf3015ce7baaecb3aaed588252 100644 (file)
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="url" stdset="0">
+       <property name="url">
         <url>
          <string>about:blank</string>
         </url>
    </property>
   </action>
   <action name="actionReplay">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="icon">
     <iconset resource="../qapitrace.qrc">
      <normaloff>:/resources/media-playback-start.png</normaloff>:/resources/media-playback-start.png</iconset>
    </property>
   </action>
   <action name="actionStop">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="icon">
     <iconset resource="../qapitrace.qrc">
      <normaloff>:/resources/media-playback-stop.png</normaloff>:/resources/media-playback-stop.png</iconset>
    </property>
   </action>
   <action name="actionLookupState">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="icon">
     <iconset resource="../qapitrace.qrc">
      <normaloff>:/resources/media-record.png</normaloff>:/resources/media-record.png</iconset>
    </property>
   </action>
   <action name="actionShowThumbnails">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="text">
     <string>Show &amp;Thumbnails</string>
    </property>
    </property>
   </action>
   <action name="actionTrim">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="text">
     <string>Tr&amp;im</string>
    </property>
    </property>
   </action>
   <action name="actionProfile">
-   <property name="enabled">
-    <bool>false</bool>
-   </property>
    <property name="text">
     <string>&amp;Profile</string>
    </property>