]> sigrok.org Git - pulseview.git/commitdiff
MainWindow: Remove menu bar
authorSoeren Apel <redacted>
Mon, 22 Aug 2016 15:32:34 +0000 (17:32 +0200)
committerSoeren Apel <redacted>
Mon, 22 Aug 2016 15:32:34 +0000 (17:32 +0200)
CMakeLists.txt
pv/mainwindow.cpp
pv/widgets/hidingmenubar.cpp [deleted file]
pv/widgets/hidingmenubar.hpp [deleted file]

index 532e6f3b46b70305c56f19c220b8d6da3827f075..0b28850258cdb88d56a1eab520a0d6500a7bdeb1 100644 (file)
@@ -266,7 +266,6 @@ set(pulseview_SOURCES
        pv/widgets/colourpopup.cpp
        pv/widgets/devicetoolbutton.cpp
        pv/widgets/exportmenu.cpp
-       pv/widgets/hidingmenubar.cpp
        pv/widgets/importmenu.cpp
        pv/widgets/popup.cpp
        pv/widgets/popuptoolbutton.cpp
@@ -319,7 +318,6 @@ set(pulseview_HEADERS
        pv/widgets/colourpopup.hpp
        pv/widgets/devicetoolbutton.hpp
        pv/widgets/exportmenu.hpp
-       pv/widgets/hidingmenubar.hpp
        pv/widgets/importmenu.hpp
        pv/widgets/popup.hpp
        pv/widgets/popuptoolbutton.hpp
index 33870145232afdd654a750cac5046169d7051201..b3377f7ab9154208bad84f8fbbc6750c6c1df046 100644 (file)
@@ -64,7 +64,6 @@
 #ifdef ENABLE_DECODE
 #include "widgets/decodermenu.hpp"
 #endif
-#include "widgets/hidingmenubar.hpp"
 
 #include <inttypes.h>
 #include <stdint.h>
@@ -439,36 +438,23 @@ void MainWindow::setup_ui()
        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());
@@ -476,7 +462,6 @@ void MainWindow::setup_ui()
        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());
@@ -484,26 +469,15 @@ void MainWindow::setup_ui()
        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",
@@ -512,7 +486,6 @@ void MainWindow::setup_ui()
        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",
@@ -520,7 +493,6 @@ void MainWindow::setup_ui()
        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"));
@@ -529,7 +501,6 @@ void MainWindow::setup_ui()
        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",
@@ -537,9 +508,6 @@ void MainWindow::setup_ui()
        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);
@@ -547,9 +515,6 @@ void MainWindow::setup_ui()
        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);
@@ -557,9 +522,6 @@ void MainWindow::setup_ui()
        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",
@@ -568,42 +530,18 @@ void MainWindow::setup_ui()
        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);
 
diff --git a/pv/widgets/hidingmenubar.cpp b/pv/widgets/hidingmenubar.cpp
deleted file mode 100644 (file)
index 4e50e3b..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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
diff --git a/pv/widgets/hidingmenubar.hpp b/pv/widgets/hidingmenubar.hpp
deleted file mode 100644 (file)
index 9e75e28..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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