[PATCH] gui: Add Save As menu option.

José Fonseca jose.r.fonseca at gmail.com
Mon Mar 30 04:05:56 PDT 2015


Pushed. Thanks.

Jose

On Fri, Mar 27, 2015 at 8:38 PM, Alexander Trukhin <alxtry at gmail.com> wrote:

> https://github.com/apitrace/apitrace/issues/305
> Signed-off-by: Alexander Trukhin <alxtry at gmail.com>
> ---
>  gui/mainwindow.cpp   | 24 ++++++++++++++++++++++++
>  gui/mainwindow.h     |  1 +
>  gui/ui/mainwindow.ui | 13 +++++++++++++
>  3 files changed, 38 insertions(+)
>
> diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
> index 9bf5024..ba1cc79 100644
> --- a/gui/mainwindow.cpp
> +++ b/gui/mainwindow.cpp
> @@ -102,6 +102,22 @@ void MainWindow::openTrace()
>      }
>  }
>
> +void MainWindow::saveTrace()
> +{
> +    QString localFile = m_trace->fileName();
> +
> +    QString fileName =
> +            QFileDialog::getSaveFileName(
> +                this,
> +                tr("Save Trace As"),
> +                QFileInfo(localFile).fileName(),
> +                tr("Trace Files (*.trace);;All Files (*)"));
> +
> +    if (!fileName.isEmpty()) {
> +        QFile::copy(localFile, fileName);
> +    }
> +}
> +
>  void MainWindow::pullTrace()
>  {
>      QString androidFile = AndroidFileDialog::getOpenFileName(this,
> tr("Open trace file"), _("/sdcard"), _(".trace"));
> @@ -1027,6 +1043,8 @@ void MainWindow::initConnections()
>              this, SLOT(createTrace()));
>      connect(m_ui.actionOpen, SIGNAL(triggered()),
>              this, SLOT(openTrace()));
> +    connect(m_ui.actionSave, SIGNAL(triggered()),
> +            this, SLOT(saveTrace()));
>      connect(m_ui.actionPullTrace, SIGNAL(triggered()),
>              this, SLOT(pullTrace()));
>      connect(m_ui.actionPushTrace, SIGNAL(triggered()),
> @@ -1138,6 +1156,9 @@ void MainWindow::updateActionsState(bool
> traceLoaded, bool stopped)
>      m_ui.actionLinkTrace->setEnabled(false);
>      m_ui.actionRetraceOnAndroid->setEnabled(false);
>      if (traceLoaded) {
> +        /* File */
> +        m_ui.actionSave          ->setEnabled(true);
> +
>          /* Edit */
>          m_ui.actionFind          ->setEnabled(true);
>          m_ui.actionGo            ->setEnabled(true);
> @@ -1160,6 +1181,9 @@ void MainWindow::updateActionsState(bool
> traceLoaded, bool stopped)
>          m_ui.actionTrim          ->setEnabled(true);
>      }
>      else {
> +        /* File */
> +        m_ui.actionSave          ->setEnabled(false);
> +
>          /* Edit */
>          m_ui.actionFind          ->setEnabled(false);
>          m_ui.actionGo            ->setEnabled(false);
> diff --git a/gui/mainwindow.h b/gui/mainwindow.h
> index cd16faf..22799ff 100644
> --- a/gui/mainwindow.h
> +++ b/gui/mainwindow.h
> @@ -52,6 +52,7 @@ private slots:
>      void callItemActivated(const QModelIndex &index);
>      void createTrace();
>      void openTrace();
> +    void saveTrace();
>      void pullTrace();
>      void pushTrace();
>      void linkTrace();
> diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui
> index 475db57..af7eadc 100644
> --- a/gui/ui/mainwindow.ui
> +++ b/gui/ui/mainwindow.ui
> @@ -67,6 +67,7 @@
>      </widget>
>      <addaction name="actionNew"/>
>      <addaction name="actionOpen"/>
> +    <addaction name="actionSave"/>
>      <addaction name="separator"/>
>      <addaction name="menu_Android"/>
>      <addaction name="separator"/>
> @@ -560,6 +561,18 @@
>      <string>Ctrl+O</string>
>     </property>
>    </action>
> +  <action name="actionSave">
> +   <property name="icon">
> +    <iconset resource="../qapitrace.qrc">
> +
>  <normaloff>:/resources/document-edit.png</normaloff>:/resources/document-edit.png</iconset>
> +   </property>
> +   <property name="text">
> +    <string>&Save As...</string>
> +   </property>
> +   <property name="shortcut">
> +    <string>Ctrl+S</string>
> +   </property>
> +  </action>
>    <action name="actionQuit">
>     <property name="icon">
>      <iconset resource="../qapitrace.qrc">
> --
> 2.3.3
>
> _______________________________________________
> apitrace mailing list
> apitrace at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/apitrace
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/apitrace/attachments/20150330/eb09f56c/attachment.html>


More information about the apitrace mailing list