- // Setup the central widget
- _central_widget = new QWidget(this);
- _vertical_layout = new QVBoxLayout(_central_widget);
- _vertical_layout->setSpacing(6);
- _vertical_layout->setContentsMargins(0, 0, 0, 0);
- setCentralWidget(_central_widget);
-
- _view = new pv::view::View(_session, this);
-
- _vertical_layout->addWidget(_view);
-
- // Setup the menu bar
- QMenuBar *const menu_bar = new QMenuBar(this);
- menu_bar->setGeometry(QRect(0, 0, 400, 25));
-
- // File Menu
- QMenu *const menu_file = new QMenu;
- menu_file->setTitle(QApplication::translate(
- "MainWindow", "&File", 0, QApplication::UnicodeUTF8));
-
- QAction *const action_open = new QAction(this);
- action_open->setText(QApplication::translate(
- "MainWindow", "&Open...", 0, QApplication::UnicodeUTF8));
- action_open->setIcon(QIcon::fromTheme("document-open",
- QIcon(":/icons/document-open.png")));
- 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);
- action_connect->setText(QApplication::translate(
- "MainWindow", "&Connect to Device...", 0,
- QApplication::UnicodeUTF8));
- action_connect->setObjectName(QString::fromUtf8("actionConnect"));
- menu_file->addAction(action_connect);
-
- menu_file->addSeparator();
-
- QAction *action_quit = new QAction(this);
- action_quit->setText(QApplication::translate(
- "MainWindow", "&Quit", 0, QApplication::UnicodeUTF8));
- action_quit->setIcon(QIcon::fromTheme("application-exit",
- QIcon(":/icons/application-exit.png")));
- action_quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
- action_quit->setObjectName(QString::fromUtf8("actionQuit"));
- menu_file->addAction(action_quit);
-
- // View Menu
- QMenu *menu_view = new QMenu;
- menu_view->setTitle(QApplication::translate(
- "MainWindow", "&View", 0, QApplication::UnicodeUTF8));
-
- QAction *const action_view_zoom_in = new QAction(this);
- action_view_zoom_in->setText(QApplication::translate(
- "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);
-
- QAction *const action_view_zoom_out = new QAction(this);
- action_view_zoom_out->setText(QApplication::translate(
- "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);
-
- QAction *const action_view_zoom_fit = new QAction(this);
- action_view_zoom_fit->setText(QApplication::translate(
- "MainWindow", "Zoom to &Fit", 0, QApplication::UnicodeUTF8));
- action_view_zoom_fit->setIcon(QIcon::fromTheme("zoom-fit",
- QIcon(":/icons/zoom-fit.png")));
- action_view_zoom_fit->setShortcut(QKeySequence(Qt::Key_F));
- action_view_zoom_fit->setObjectName(
- QString::fromUtf8("actionViewZoomFit"));
- menu_view->addAction(action_view_zoom_fit);
-
- QAction *const action_view_zoom_one_to_one = new QAction(this);
- action_view_zoom_one_to_one->setText(QApplication::translate(
- "MainWindow", "Zoom to &One-to-One", 0,
- QApplication::UnicodeUTF8));
- action_view_zoom_one_to_one->setIcon(QIcon::fromTheme("zoom-original",
- QIcon(":/icons/zoom-original.png")));
- action_view_zoom_one_to_one->setShortcut(QKeySequence(Qt::Key_O));
- action_view_zoom_one_to_one->setObjectName(
- QString::fromUtf8("actionViewZoomOneToOne"));
- menu_view->addAction(action_view_zoom_one_to_one);
-
- menu_view->addSeparator();
-
- QAction *action_view_show_cursors = new QAction(this);
- action_view_show_cursors->setCheckable(true);
- action_view_show_cursors->setChecked(_view->cursors_shown());
- action_view_show_cursors->setShortcut(QKeySequence(Qt::Key_C));
- action_view_show_cursors->setObjectName(
- QString::fromUtf8("actionViewShowCursors"));
- action_view_show_cursors->setText(QApplication::translate(
- "MainWindow", "Show &Cursors", 0, QApplication::UnicodeUTF8));
- menu_view->addAction(action_view_show_cursors);
-
- // Decoders Menu
-#ifdef ENABLE_DECODE
- QMenu *const menu_decoders = new QMenu;
- menu_decoders->setTitle(QApplication::translate(
- "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8));
-
- pv::widgets::DecoderMenu *const menu_decoders_add =
- new pv::widgets::DecoderMenu(menu_decoders);
- menu_decoders_add->setTitle(QApplication::translate(
- "MainWindow", "&Add", 0, QApplication::UnicodeUTF8));
- connect(menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)),
- this, SLOT(add_decoder(srd_decoder*)));
-
- menu_decoders->addMenu(menu_decoders_add);
-#endif
-
- // Help Menu
- QMenu *const menu_help = new QMenu;
- menu_help->setTitle(QApplication::translate(
- "MainWindow", "&Help", 0, QApplication::UnicodeUTF8));
-
- QAction *const action_about = new QAction(this);
- action_about->setObjectName(QString::fromUtf8("actionAbout"));
- action_about->setText(QApplication::translate(
- "MainWindow", "&About...", 0, QApplication::UnicodeUTF8));
- menu_help->addAction(action_about);
+ view_sticky_scrolling_shortcut_ = new QShortcut(QKeySequence(Qt::Key_S), this, SLOT(on_view_sticky_scrolling_shortcut()));
+ view_sticky_scrolling_shortcut_->setAutoRepeat(false);
+
+ view_show_sampling_points_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Period), this, SLOT(on_view_show_sampling_points_shortcut()));
+ view_show_sampling_points_shortcut_->setAutoRepeat(false);
+
+ view_show_analog_minor_grid_shortcut_ = new QShortcut(QKeySequence(Qt::Key_G), this, SLOT(on_view_show_analog_minor_grid_shortcut()));
+ view_show_analog_minor_grid_shortcut_->setAutoRepeat(false);
+
+ view_colored_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_colored_bg_shortcut()));
+ view_colored_bg_shortcut_->setAutoRepeat(false);
+
+ // Set up the tab area
+ new_session_button_ = new QToolButton();
+ new_session_button_->setIcon(QIcon::fromTheme("document-new",
+ QIcon(":/icons/document-new.png")));
+ new_session_button_->setToolTip(tr("Create New Session"));
+ new_session_button_->setAutoRaise(true);
+
+ run_stop_button_ = new QToolButton();
+ run_stop_button_->setAutoRaise(true);
+ run_stop_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ run_stop_button_->setToolTip(tr("Start/Stop Acquisition"));
+
+ run_stop_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Space), run_stop_button_, SLOT(click()));
+ run_stop_shortcut_->setAutoRepeat(false);
+
+ settings_button_ = new QToolButton();
+ settings_button_->setIcon(QIcon::fromTheme("preferences-system",
+ QIcon(":/icons/preferences-system.png")));
+ settings_button_->setToolTip(tr("Settings"));
+ settings_button_->setAutoRaise(true);
+
+ QFrame *separator1 = new QFrame();
+ separator1->setFrameStyle(QFrame::VLine | QFrame::Raised);
+ QFrame *separator2 = new QFrame();
+ separator2->setFrameStyle(QFrame::VLine | QFrame::Raised);
+
+ QHBoxLayout* layout = new QHBoxLayout();
+ layout->setContentsMargins(2, 2, 2, 2);
+ layout->addWidget(new_session_button_);
+ layout->addWidget(separator1);
+ layout->addWidget(run_stop_button_);
+ layout->addWidget(separator2);
+ layout->addWidget(settings_button_);
+
+ static_tab_widget_ = new QWidget();
+ static_tab_widget_->setLayout(layout);
+
+ session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
+ session_selector_.setTabsClosable(true);
+
+ close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
+ close_application_shortcut_->setAutoRepeat(false);
+
+ close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab()));
+
+ connect(new_session_button_, SIGNAL(clicked(bool)),
+ this, SLOT(on_new_session_clicked()));
+ connect(run_stop_button_, SIGNAL(clicked(bool)),
+ this, SLOT(on_run_stop_clicked()));
+ connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
+ this, SLOT(on_capture_state_changed(QObject*)));
+ connect(settings_button_, SIGNAL(clicked(bool)),
+ this, SLOT(on_settings_clicked()));
+
+ connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
+ this, SLOT(on_tab_close_requested(int)));
+ connect(&session_selector_, SIGNAL(currentChanged(int)),
+ this, SLOT(on_tab_changed(int)));
+
+
+ connect(static_cast<QApplication *>(QCoreApplication::instance()),
+ SIGNAL(focusChanged(QWidget*, QWidget*)),
+ this, SLOT(on_focus_changed()));
+}