X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=65071330da07e1d24c5955448ad44efe3f929383;hp=d693ddc35e6c7b5ecc8cfc444d2cdc9754e5b937;hb=b926e4eeef6db657601ebd4bbededdf9d329cdd6;hpb=2ad82c2e40b6865481733913a2c32735602f63c4 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index d693ddc3..65071330 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -110,6 +110,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, action_view_zoom_fit_(new QAction(this)), action_view_zoom_one_to_one_(new QAction(this)), action_view_sticky_scrolling_(new QAction(this)), + action_view_coloured_bg_(new QAction(this)), action_view_show_cursors_(new QAction(this)), action_about_(new QAction(this)) #ifdef ENABLE_DECODE @@ -176,6 +177,11 @@ QAction* MainWindow::action_view_sticky_scrolling() const return action_view_sticky_scrolling_; } +QAction* MainWindow::action_view_coloured_bg() const +{ + return action_view_coloured_bg_; +} + QAction* MainWindow::action_view_show_cursors() const { return action_view_show_cursors_; @@ -459,7 +465,7 @@ void MainWindow::setup_ui() QString::fromUtf8("actionViewZoomOneToOne")); menu_view->addAction(action_view_zoom_one_to_one_); - menu_file->addSeparator(); + menu_view->addSeparator(); action_view_sticky_scrolling_->setCheckable(true); action_view_sticky_scrolling_->setChecked(true); @@ -473,6 +479,18 @@ void MainWindow::setup_ui() menu_view->addSeparator(); + action_view_coloured_bg_->setCheckable(true); + action_view_coloured_bg_->setChecked(true); + action_view_coloured_bg_->setShortcut(QKeySequence(Qt::Key_B)); + action_view_coloured_bg_->setObjectName( + QString::fromUtf8("actionViewColouredBg")); + action_view_coloured_bg_->setText(tr("Use &coloured backgrounds")); + menu_view->addAction(action_view_coloured_bg_); + + view_->enable_coloured_bg(action_view_coloured_bg_->isChecked()); + + menu_view->addSeparator(); + action_view_show_cursors_->setCheckable(true); action_view_show_cursors_->setChecked(view_->cursors_shown()); action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors", @@ -549,8 +567,9 @@ void MainWindow::select_init_device() QSettings settings; map dev_info; list key_list; + shared_ptr device; - // Re-select last used device if possible. + // Re-select last used device if possible but only if it's not demo settings.beginGroup("Device"); key_list.push_back("vendor"); key_list.push_back("model"); @@ -568,8 +587,24 @@ void MainWindow::select_init_device() dev_info.insert(std::make_pair(key, value)); } - const shared_ptr device = - device_manager_.find_device_from_info(dev_info); + if (dev_info.count("model") > 0) + if (dev_info.at("model").find("Demo device") == std::string::npos) + device = device_manager_.find_device_from_info(dev_info); + + // When we can't find a device similar to the one we used last + // time and there is at least one device aside from demo, use it + if (!device) { + for (shared_ptr dev : device_manager_.devices()) { + dev_info = device_manager_.get_device_info(dev); + + if (dev_info.count("model") > 0) + if (dev_info.at("model").find("Demo device") == std::string::npos) { + device = dev; + break; + } + } + } + select_device(device); update_device_list(); @@ -794,6 +829,11 @@ void MainWindow::on_actionViewStickyScrolling_triggered() view_->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); } +void MainWindow::on_actionViewColouredBg_triggered() +{ + view_->enable_coloured_bg(action_view_coloured_bg_->isChecked()); +} + void MainWindow::on_actionViewShowCursors_triggered() { assert(view_);