pv/widgets/colourbutton.cpp
pv/widgets/colourpopup.cpp
pv/widgets/devicetoolbutton.cpp
+ pv/widgets/hidingmenubar.cpp
pv/widgets/popup.cpp
pv/widgets/popuptoolbutton.cpp
pv/widgets/sweeptimingwidget.cpp
pv/widgets/colourbutton.hpp
pv/widgets/colourpopup.hpp
pv/widgets/devicetoolbutton.hpp
+ pv/widgets/hidingmenubar.hpp
pv/widgets/popup.hpp
pv/widgets/popuptoolbutton.hpp
pv/widgets/sweeptimingwidget.hpp
#ifdef ENABLE_DECODE
#include "widgets/decodermenu.hpp"
#endif
+#include "widgets/hidingmenubar.hpp"
#include <inttypes.h>
#include <stdint.h>
vertical_layout_->addWidget(view_);
// Setup the menu bar
- QMenuBar *const menu_bar = new QMenuBar(this);
- menu_bar->setGeometry(QRect(0, 0, 400, 25));
+ pv::widgets::HidingMenuBar *const menu_bar =
+ new pv::widgets::HidingMenuBar(this);
// File Menu
QMenu *const menu_file = new QMenu;
QString::fromUtf8("actionViewZoomFit"));
menu_view->addAction(action_view_zoom_fit_);
- action_view_zoom_one_to_one_->setText(tr("Zoom to &One-to-One"));
+ 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",
QIcon(":/icons/zoom-original.png")));
action_view_zoom_one_to_one_->setShortcut(QKeySequence(Qt::Key_O));
event->accept();
}
+void MainWindow::keyReleaseEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_Alt) {
+ menuBar()->setHidden(!menuBar()->isHidden());
+ menuBar()->setFocus();
+ }
+ QMainWindow::keyReleaseEvent(event);
+}
+
void MainWindow::load_file(QString file_name)
{
const QString errorMessage(
/**
* Updates the device list in the toolbar
*/
- void update_device_list();
+ void update_device_list();
+private:
void closeEvent(QCloseEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+
private Q_SLOTS:
void load_file(QString file_name);
--- /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 *e)
+{
+ if (e->reason() != Qt::PopupFocusReason)
+ setHidden(true);
+ QMenuBar::focusOutEvent(e);
+}
+
+void HidingMenuBar::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Escape)
+ setHidden(true);
+ QMenuBar::keyPressEvent(e);
+}
+
+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_H
+#define PULSEVIEW_PV_WIDGETS_HIDINGMENUBAR_H
+
+#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 *e);
+
+ /**
+ * Handles the event that a key is depressed.
+ * @param e the representation of the event details.
+ */
+ void keyPressEvent(QKeyEvent *e);
+
+private Q_SLOTS:
+ /**
+ * Handles a menu items being triggered.
+ */
+ void item_triggered();
+};
+
+} // widgets
+} // pv
+
+#endif // PULSEVIEW_PV_WIDGETS_HIDINGMENUBAR_H