X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=0b2805b18e44a1ee0908b2715476d62466faf58e;hp=2e0fa0ffe8746ce70b3886b94c11724fe7e80da1;hb=c2d4e9df36b9c19c691ff6fcb57066fd84a652e3;hpb=269528f55e7fd77f762c2008d257921cd30e1519 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 2e0fa0ff..0b2805b1 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -39,8 +39,10 @@ #include "mainwindow.h" #include "devicemanager.h" +#include "devinst.h" #include "dialogs/about.h" #include "dialogs/connect.h" +#include "dialogs/storeprogress.h" #include "toolbars/samplingbar.h" #include "view/logicsignal.h" #include "view/view.h" @@ -56,8 +58,8 @@ #include #include -using namespace boost; -using namespace std; +using boost::shared_ptr; +using std::list; namespace pv { @@ -121,6 +123,14 @@ void MainWindow::setup_ui() action_open->setObjectName(QString::fromUtf8("actionOpen")); menu_file->addAction(action_open); + QAction *const action_save_as = new QAction(this); + action_save_as->setText(QApplication::translate( + "MainWindow", "&Save As...", 0, QApplication::UnicodeUTF8)); + action_save_as->setIcon(QIcon::fromTheme("document-save-as", + QIcon(":/icons/document-save-as.png"))); + action_save_as->setObjectName(QString::fromUtf8("actionSaveAs")); + menu_file->addAction(action_save_as); + menu_file->addSeparator(); QAction *const action_connect = new QAction(this); @@ -151,6 +161,8 @@ void MainWindow::setup_ui() "MainWindow", "Zoom &In", 0, QApplication::UnicodeUTF8)); action_view_zoom_in->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/icons/zoom-in.png"))); + // simply using Qt::Key_Plus shows no + in the menu + action_view_zoom_in->setShortcut(QKeySequence::ZoomIn); action_view_zoom_in->setObjectName( QString::fromUtf8("actionViewZoomIn")); menu_view->addAction(action_view_zoom_in); @@ -160,6 +172,7 @@ void MainWindow::setup_ui() "MainWindow", "Zoom &Out", 0, QApplication::UnicodeUTF8)); action_view_zoom_out->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/icons/zoom-out.png"))); + action_view_zoom_out->setShortcut(QKeySequence::ZoomOut); action_view_zoom_out->setObjectName( QString::fromUtf8("actionViewZoomOut")); menu_view->addAction(action_view_zoom_out); @@ -271,11 +284,11 @@ void MainWindow::session_error( Q_ARG(QString, info_text)); } -void MainWindow::update_device_list(struct sr_dev_inst *selected_device) +void MainWindow::update_device_list(shared_ptr selected_device) { assert(_sampling_bar); - const list &devices = _device_manager.devices(); + const list< shared_ptr > &devices = _device_manager.devices(); _sampling_bar->set_device_list(devices); if (!selected_device && !devices.empty()) { @@ -283,9 +296,10 @@ void MainWindow::update_device_list(struct sr_dev_inst *selected_device) selected_device = devices.front(); // Try and find the demo device and select that by default - BOOST_FOREACH (struct sr_dev_inst *sdi, devices) - if (strcmp(sdi->driver->name, "demo") == 0) { - selected_device = sdi; + BOOST_FOREACH (shared_ptr dev_inst, devices) + if (strcmp(dev_inst->dev_inst()->driver->name, + "demo") == 0) { + selected_device = dev_inst; } } @@ -318,17 +332,33 @@ void MainWindow::show_session_error( void MainWindow::on_actionOpen_triggered() { - // Enumerate the file formats - QString filters(tr("Sigrok Sessions (*.sr)")); - filters.append(tr(";;All Files (*.*)")); - // Show the dialog const QString file_name = QFileDialog::getOpenFileName( - this, tr("Open File"), "", filters); + this, tr("Open File"), "", tr( + "Sigrok Sessions (*.sr);;" + "All Files (*.*)")); if (!file_name.isEmpty()) load_file(file_name); } +void MainWindow::on_actionSaveAs_triggered() +{ + using pv::dialogs::StoreProgress; + + // Stop any currently running capture session + _session.stop_capture(); + + // Show the dialog + const QString file_name = QFileDialog::getSaveFileName( + this, tr("Save File"), "", tr("Sigrok Sessions (*.sr)")); + + if (file_name.isEmpty()) + return; + + StoreProgress *dlg = new StoreProgress(file_name, _session, this); + dlg->run(); +} + void MainWindow::on_actionConnect_triggered() { // Stop any currently running capture session @@ -338,10 +368,10 @@ void MainWindow::on_actionConnect_triggered() // If the user selected a device, select it in the device list. Select the // current device otherwise. - struct sr_dev_inst *const sdi = dlg.exec() ? + shared_ptr dev_inst = dlg.exec() ? dlg.get_selected_device() : _session.get_device(); - update_device_list(sdi); + update_device_list(dev_inst); } void MainWindow::on_actionQuit_triggered() @@ -400,8 +430,8 @@ void MainWindow::run_stop() { switch(_session.get_capture_state()) { case SigSession::Stopped: - _session.start_capture(_sampling_bar->get_record_length(), - boost::bind(&MainWindow::session_error, this, + _session.start_capture( + boost::bind(&MainWindow::session_error, this, QString("Capture failed"), _1)); break;