X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=2689060347c19bb186f728fa5b9b16fd66b0fdd9;hb=d9aecf1fcd9af471db3b59de7efc65b9632a6d79;hp=829c95e994e2691db500fdbdfa5706be3352921e;hpb=2445d0b3d64ab051d8a686506910224f9f4e45c7;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 829c95e..2689060 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -23,7 +23,6 @@ #endif #include -#include #include #include @@ -123,6 +122,7 @@ void MainWindow::setup_ui() "MainWindow", "&Open...", 0, QApplication::UnicodeUTF8)); action_open->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/document-open.png"))); + action_open->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); action_open->setObjectName(QString::fromUtf8("actionOpen")); menu_file->addAction(action_open); @@ -131,6 +131,7 @@ void MainWindow::setup_ui() "MainWindow", "&Save As...", 0, QApplication::UnicodeUTF8)); action_save_as->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/icons/document-save-as.png"))); + action_save_as->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); action_save_as->setObjectName(QString::fromUtf8("actionSaveAs")); menu_file->addAction(action_save_as); @@ -220,7 +221,7 @@ void MainWindow::setup_ui() "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8)); pv::widgets::DecoderMenu *const menu_decoders_add = - new pv::widgets::DecoderMenu(menu_decoders); + new pv::widgets::DecoderMenu(menu_decoders, true); menu_decoders_add->setTitle(QApplication::translate( "MainWindow", "&Add", 0, QApplication::UnicodeUTF8)); connect(menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)), @@ -253,10 +254,12 @@ void MainWindow::setup_ui() // Setup the toolbar QToolBar *const toolbar = new QToolBar(tr("Main Toolbar"), this); toolbar->addAction(action_open); + toolbar->addAction(action_save_as); toolbar->addSeparator(); toolbar->addAction(action_view_zoom_in); toolbar->addAction(action_view_zoom_out); toolbar->addAction(action_view_zoom_fit); + toolbar->addAction(action_view_zoom_one_to_one); addToolBar(toolbar); // Setup the sampling bar @@ -287,34 +290,21 @@ void MainWindow::session_error( Q_ARG(QString, info_text)); } -void MainWindow::update_device_list( - shared_ptr selected_device) +void MainWindow::update_device_list() { assert(_sampling_bar); + shared_ptr selected_device = _session.get_device(); list< shared_ptr > devices; std::copy(_device_manager.devices().begin(), _device_manager.devices().end(), std::back_inserter(devices)); - _sampling_bar->set_device_list(devices); + if (std::find(devices.begin(), devices.end(), selected_device) == + devices.end()) + devices.push_back(selected_device); + assert(selected_device); - if (!selected_device && !devices.empty()) { - // Fall back to the first device in the list. - selected_device = devices.front(); - - // Try and find the demo device and select that by default - BOOST_FOREACH (shared_ptr dev_inst, devices) - if (strcmp(dev_inst->dev_inst()->driver->name, - "demo") == 0) { - selected_device = dev_inst; - } - } - - if (selected_device) { - // Setting the selected device in the sampling bar, generates - // an event which updates the selected device in the SigSession. - _sampling_bar->set_selected_device(selected_device); - } + _sampling_bar->set_device_list(devices, selected_device); } void MainWindow::load_file(QString file_name) @@ -322,9 +312,20 @@ void MainWindow::load_file(QString file_name) const QString errorMessage( QString("Failed to load file %1").arg(file_name)); const QString infoMessage; - _session.load_file(file_name.toStdString(), - boost::bind(&MainWindow::session_error, this, - errorMessage, infoMessage)); + + try { + _session.set_file(file_name.toStdString()); + } catch(QString e) { + show_session_error(tr("Failed to load ") + file_name, e); + _session.set_default_device(); + update_device_list(); + return; + } + + update_device_list(); + + _session.start_capture(boost::bind(&MainWindow::session_error, this, + errorMessage, infoMessage)); } void MainWindow::show_session_error( @@ -376,10 +377,10 @@ void MainWindow::on_actionConnect_triggered() // If the user selected a device, select it in the device list. Select the // current device otherwise. - shared_ptr dev_inst = dlg.exec() ? - dlg.get_selected_device() : _session.get_device(); + if (dlg.exec()) + _session.set_device(dlg.get_selected_device()); - update_device_list(dev_inst); + update_device_list(); } void MainWindow::on_actionQuit_triggered()