#ifdef ENABLE_DECODE
#include "widgets/decodermenu.hpp"
#endif
-#include "widgets/hidingmenubar.hpp"
#include <inttypes.h>
#include <stdint.h>
icon.addFile(QString(":/icons/sigrok-logo-notext.png"));
setWindowIcon(icon);
- // Setup the menu bar
- pv::widgets::HidingMenuBar *const menu_bar =
- new pv::widgets::HidingMenuBar(this);
-
- // File Menu
- QMenu *const menu_file = new QMenu;
- menu_file->setTitle(tr("&File"));
-
action_open_->setText(tr("&Open..."));
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_);
action_save_as_->setText(tr("&Save As..."));
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_);
action_save_selection_as_->setText(tr("Save Selected &Range As..."));
action_save_selection_as_->setIcon(QIcon::fromTheme("document-save-as",
QIcon(":/icons/document-save-as.png")));
action_save_selection_as_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
action_save_selection_as_->setObjectName(QString::fromUtf8("actionSaveSelectionAs"));
- menu_file->addAction(action_save_selection_as_);
-
- menu_file->addSeparator();
widgets::ExportMenu *menu_file_export = new widgets::ExportMenu(this,
device_manager_.context());
connect(menu_file_export,
SIGNAL(format_selected(std::shared_ptr<sigrok::OutputFormat>)),
this, SLOT(export_file(std::shared_ptr<sigrok::OutputFormat>)));
- menu_file->addAction(menu_file_export->menuAction());
widgets::ImportMenu *menu_file_import = new widgets::ImportMenu(this,
device_manager_.context());
connect(menu_file_import,
SIGNAL(format_selected(std::shared_ptr<sigrok::InputFormat>)),
this, SLOT(import_file(std::shared_ptr<sigrok::InputFormat>)));
- menu_file->addAction(menu_file_import->menuAction());
-
- menu_file->addSeparator();
action_connect_->setText(tr("&Connect to Device..."));
action_connect_->setObjectName(QString::fromUtf8("actionConnect"));
- menu_file->addAction(action_connect_);
-
- menu_file->addSeparator();
action_quit_->setText(tr("&Quit"));
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(tr("&View"));
action_view_zoom_in_->setText(tr("Zoom &In"));
action_view_zoom_in_->setIcon(QIcon::fromTheme("zoom-in",
action_view_zoom_in_->setShortcut(QKeySequence::ZoomIn);
action_view_zoom_in_->setObjectName(
QString::fromUtf8("actionViewZoomIn"));
- menu_view->addAction(action_view_zoom_in_);
action_view_zoom_out_->setText(tr("Zoom &Out"));
action_view_zoom_out_->setIcon(QIcon::fromTheme("zoom-out",
action_view_zoom_out_->setShortcut(QKeySequence::ZoomOut);
action_view_zoom_out_->setObjectName(
QString::fromUtf8("actionViewZoomOut"));
- menu_view->addAction(action_view_zoom_out_);
action_view_zoom_fit_->setCheckable(true);
action_view_zoom_fit_->setText(tr("Zoom to &Fit"));
action_view_zoom_fit_->setShortcut(QKeySequence(Qt::Key_F));
action_view_zoom_fit_->setObjectName(
QString::fromUtf8("actionViewZoomFit"));
- menu_view->addAction(action_view_zoom_fit_);
action_view_zoom_one_to_one_->setText(tr("Zoom to O&ne-to-One"));
action_view_zoom_one_to_one_->setIcon(QIcon::fromTheme("zoom-original",
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();
action_view_sticky_scrolling_->setCheckable(true);
action_view_sticky_scrolling_->setChecked(true);
action_view_sticky_scrolling_->setObjectName(
QString::fromUtf8("actionViewStickyScrolling"));
action_view_sticky_scrolling_->setText(tr("&Sticky Scrolling"));
- menu_view->addAction(action_view_sticky_scrolling_);
-
- menu_view->addSeparator();
action_view_coloured_bg_->setCheckable(true);
action_view_coloured_bg_->setChecked(true);
action_view_coloured_bg_->setObjectName(
QString::fromUtf8("actionViewColouredBg"));
action_view_coloured_bg_->setText(tr("Use &coloured backgrounds"));
- menu_view->addAction(action_view_coloured_bg_);
-
- menu_view->addSeparator();
action_view_show_cursors_->setCheckable(true);
action_view_show_cursors_->setIcon(QIcon::fromTheme("show-cursors",
action_view_show_cursors_->setObjectName(
QString::fromUtf8("actionViewShowCursors"));
action_view_show_cursors_->setText(tr("Show &Cursors"));
- menu_view->addAction(action_view_show_cursors_);
- // Decoders Menu
#ifdef ENABLE_DECODE
- QMenu *const menu_decoders = new QMenu;
- menu_decoders->setTitle(tr("&Decoders"));
-
menu_decoders_add_->setTitle(tr("&Add"));
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(tr("&Help"));
-
action_about_->setObjectName(QString::fromUtf8("actionAbout"));
action_about_->setText(tr("&About..."));
- menu_help->addAction(action_about_);
- menu_bar->addAction(menu_file->menuAction());
- menu_bar->addAction(menu_view->menuAction());
-#ifdef ENABLE_DECODE
- menu_bar->addAction(menu_decoders->menuAction());
-#endif
- menu_bar->addAction(menu_help->menuAction());
-
- setMenuBar(menu_bar);
QMetaObject::connectSlotsByName(this);
- // Also add all actions to the main window for always-enabled hotkeys
- for (QAction* action : menu_bar->actions())
- this->addAction(action);
-
// Setup the toolbar
main_bar_ = new toolbars::MainBar(session_, *this);
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2015 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <QKeyEvent>
-
-#include "hidingmenubar.hpp"
-
-namespace pv {
-namespace widgets {
-
-HidingMenuBar::HidingMenuBar(QWidget *parent) :
- QMenuBar(parent)
-{
- setHidden(true);
- connect(this, SIGNAL(triggered(QAction*)),
- this, SLOT(item_triggered()));
-}
-
-void HidingMenuBar::focusOutEvent(QFocusEvent *event)
-{
- if (event->reason() != Qt::PopupFocusReason)
- setHidden(true);
- QMenuBar::focusOutEvent(event);
-}
-
-void HidingMenuBar::keyPressEvent(QKeyEvent *event)
-{
- if (event->key() == Qt::Key_Escape)
- setHidden(true);
- QMenuBar::keyPressEvent(event);
-}
-
-void HidingMenuBar::item_triggered()
-{
- setHidden(true);
-}
-
-} // namespace widgets
-} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2015 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PULSEVIEW_PV_WIDGETS_HIDINGMENUBAR_HPP
-#define PULSEVIEW_PV_WIDGETS_HIDINGMENUBAR_HPP
-
-#include <QMenuBar>
-
-namespace pv {
-namespace widgets {
-
-/**
- * A menu bar widget that only remains visible while it retains focus.
- */
-class HidingMenuBar : public QMenuBar
-{
- Q_OBJECT
-
-public:
- /**
- * Constructor
- * @param parent The parent widget.
- */
- HidingMenuBar(QWidget *parent = nullptr);
-
-private:
- /**
- * Handles the event that the widget loses keyboard focus.
- * @param e the representation of the event details.
- */
- void focusOutEvent(QFocusEvent *event);
-
- /**
- * Handles the event that a key is depressed.
- * @param e the representation of the event details.
- */
- void keyPressEvent(QKeyEvent *event);
-
-private Q_SLOTS:
- /**
- * Handles a menu items being triggered.
- */
- void item_triggered();
-};
-
-} // widgets
-} // pv
-
-#endif // PULSEVIEW_PV_WIDGETS_HIDINGMENUBAR_HPP