From: Joel Holdsworth Date: Sun, 29 Sep 2013 14:50:53 +0000 (+0900) Subject: Removed context bar X-Git-Tag: pulseview-0.2.0~273 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=03ce95a9bb81c05bae0da9de189d280214db67c3 Removed context bar --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fa08273..c2e9001b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,6 @@ set(pulseview_SOURCES pv/prop/binding/binding.cpp pv/prop/binding/decoderoptions.cpp pv/prop/binding/deviceoptions.cpp - pv/toolbars/contextbar.cpp pv/toolbars/samplingbar.cpp pv/view/analogsignal.cpp pv/view/cursor.cpp @@ -153,7 +152,6 @@ set(pulseview_HEADERS pv/dialogs/about.h pv/dialogs/connect.h pv/dialogs/deviceoptions.h - pv/toolbars/contextbar.h pv/toolbars/samplingbar.h pv/view/cursor.h pv/view/decodesignal.h diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index ba232e25..97103ad5 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -40,7 +40,6 @@ #include "dialogs/about.h" #include "dialogs/connect.h" #include "dialogs/decoder.h" -#include "toolbars/contextbar.h" #include "toolbars/samplingbar.h" #include "view/view.h" @@ -98,8 +97,6 @@ void MainWindow::setup_ui() setCentralWidget(_central_widget); _view = new pv::view::View(_session, this); - connect(_view, SIGNAL(selection_changed()), this, - SLOT(view_selection_changed())); _vertical_layout->addWidget(_view); @@ -228,10 +225,6 @@ void MainWindow::setup_ui() SLOT(run_stop())); addToolBar(_sampling_bar); - // Setup the context bar - _context_bar = new toolbars::ContextBar(this); - addToolBar(_context_bar); - // Set the title setWindowTitle(QApplication::translate("MainWindow", "PulseView", 0, QApplication::UnicodeUTF8)); @@ -425,13 +418,4 @@ void MainWindow::capture_state_changed(int state) _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); } -void MainWindow::view_selection_changed() -{ - assert(_context_bar); - - const list > items( - _view->selected_items()); - _context_bar->set_selected_items(items); -} - } // namespace pv diff --git a/pv/mainwindow.h b/pv/mainwindow.h index b4b64f77..d34db1bf 100644 --- a/pv/mainwindow.h +++ b/pv/mainwindow.h @@ -105,8 +105,6 @@ private slots: void capture_state_changed(int state); - void view_selection_changed(); - private: DeviceManager &_device_manager; @@ -137,7 +135,6 @@ private: QToolBar *_toolbar; toolbars::SamplingBar *_sampling_bar; - toolbars::ContextBar *_context_bar; }; } // namespace pv diff --git a/pv/toolbars/contextbar.cpp b/pv/toolbars/contextbar.cpp deleted file mode 100644 index a538d64a..00000000 --- a/pv/toolbars/contextbar.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012 Joel Holdsworth - * - * 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 - -#include -#include - -#include "contextbar.h" - -#include - -using namespace boost; -using namespace std; - -namespace pv { -namespace toolbars { - -ContextBar::ContextBar(QWidget *parent) : - QToolBar(tr("Context Bar"), parent) -{ -} - -void ContextBar::set_selected_items(const list< - weak_ptr > &items) -{ - clear(); - - if (items.empty()) - return; - - if (shared_ptr item = - items.front().lock()) { - - assert(item); - - const list actions( - item->get_context_bar_actions()); - BOOST_FOREACH(QAction *action, actions) { - assert(action); - addAction(action); - } - } -} - -} // namespace toolbars -} // namespace pv diff --git a/pv/toolbars/contextbar.h b/pv/toolbars/contextbar.h deleted file mode 100644 index 6d8e7f3f..00000000 --- a/pv/toolbars/contextbar.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2013 Joel Holdsworth - * - * 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_TOOLBARS_CONTEXTBAR_H -#define PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H - -#include - -#include - -#include - -namespace pv { -namespace toolbars { - -class ContextBar : public QToolBar -{ - Q_OBJECT - -public: - ContextBar(QWidget *parent); - -public: - void set_selected_items(const std::list< - boost::weak_ptr > &items); -}; - -} // namespace toolbars -} // namespace pv - -#endif // PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index a4474dac..53af2643 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -55,13 +55,6 @@ AnalogSignal::~AnalogSignal() { } -const list AnalogSignal::get_context_bar_actions() -{ - list actions; - actions.push_back(_name_action); - return actions; -} - void AnalogSignal::set_scale(float scale) { _scale = scale; diff --git a/pv/view/analogsignal.h b/pv/view/analogsignal.h index 3b92455c..0b6172f8 100644 --- a/pv/view/analogsignal.h +++ b/pv/view/analogsignal.h @@ -47,8 +47,6 @@ public: virtual ~AnalogSignal(); - const std::list get_context_bar_actions(); - void set_scale(float scale); /** diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp index b151b391..bce58a19 100644 --- a/pv/view/decodesignal.cpp +++ b/pv/view/decodesignal.cpp @@ -59,11 +59,6 @@ DecodeSignal::DecodeSignal(pv::SigSession &session, this, SLOT(on_new_decode_data())); } -void DecodeSignal::init_context_bar_actions(QWidget *parent) -{ - (void)parent; -} - bool DecodeSignal::enabled() const { return true; @@ -109,12 +104,6 @@ void DecodeSignal::paint_mid(QPainter &p, int left, int right) } } -const list DecodeSignal::get_context_bar_actions() -{ - list actions; - return actions; -} - QMenu* DecodeSignal::create_context_menu(QWidget *parent) { QMenu *const menu = Trace::create_context_menu(parent); diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h index b9fbb24d..22e0f3d0 100644 --- a/pv/view/decodesignal.h +++ b/pv/view/decodesignal.h @@ -44,8 +44,6 @@ public: DecodeSignal(pv::SigSession &session, boost::shared_ptr decoder, int index); - void init_context_bar_actions(QWidget *parent); - bool enabled() const; void set_view(pv::view::View *view); @@ -66,8 +64,6 @@ public: **/ void paint_mid(QPainter &p, int left, int right); - const std::list get_context_bar_actions(); - QMenu* create_context_menu(QWidget *parent); private: diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 19522fb2..bf8b3659 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -59,7 +59,6 @@ LogicSignal::LogicSignal(pv::SigSession &session, const sr_probe *const probe, shared_ptr data) : Signal(session, probe), _data(data), - _separator(NULL), _trigger_none(NULL), _trigger_rising(NULL), _trigger_high(NULL), @@ -74,94 +73,11 @@ LogicSignal::~LogicSignal() { } -void LogicSignal::init_context_bar_actions(QWidget *parent) -{ - Signal::init_context_bar_actions(parent); - - _separator = new QAction(parent); - _separator->setSeparator(true); - - _trigger_none = new QAction(QIcon(":/icons/trigger-none.svg"), - tr("No trigger"), this); - _trigger_none->setCheckable(true); - connect(_trigger_none, SIGNAL(triggered()), - this, SLOT(on_trigger_none())); - - _trigger_rising = new QAction(QIcon(":/icons/trigger-rising.svg"), - tr("Trigger on rising edge"), this); - _trigger_rising->setCheckable(true); - connect(_trigger_rising, SIGNAL(triggered()), - this, SLOT(on_trigger_rising())); - - _trigger_high = new QAction(QIcon(":/icons/trigger-low.svg"), - tr("Trigger on high level"), this); - _trigger_high->setCheckable(true); - connect(_trigger_high, SIGNAL(triggered()), - this, SLOT(on_trigger_high())); - - _trigger_falling = new QAction(QIcon(":/icons/trigger-falling.svg"), - tr("Trigger on falling edge"), this); - _trigger_falling->setCheckable(true); - connect(_trigger_falling, SIGNAL(triggered()), - this, SLOT(on_trigger_falling())); - - _trigger_low = new QAction(QIcon(":/icons/trigger-low.svg"), - tr("Trigger on low level"), this); - _trigger_low->setCheckable(true); - connect(_trigger_low, SIGNAL(triggered()), - this, SLOT(on_trigger_low())); - - _trigger_change = new QAction(QIcon(":/icons/trigger-change.svg"), - tr("Trigger on rising or falling edge"), this); - _trigger_change->setCheckable(true); - connect(_trigger_change, SIGNAL(triggered()), - this, SLOT(on_trigger_change())); -} - boost::shared_ptr LogicSignal::data() const { return _data; } -const list LogicSignal::get_context_bar_actions() -{ - GVariant *gvar; - list actions; - - actions.push_back(_name_action); - - // Add the trigger actions - const sr_dev_inst *const sdi = _session.get_device(); - if (sr_config_list(sdi->driver, SR_CONF_TRIGGER_TYPE, - &gvar, sdi) == SR_OK) { - const char *const trig_types = - g_variant_get_string(gvar, NULL); - - if (trig_types && trig_types[0] != '\0') { - actions.push_back(_separator); - - actions.push_back(_trigger_none); - - add_trigger_action(trig_types, 'r', - _trigger_rising, actions); - add_trigger_action(trig_types, '1', - _trigger_high, actions); - add_trigger_action(trig_types, 'f', - _trigger_falling, actions); - add_trigger_action(trig_types, '0', - _trigger_low, actions); - add_trigger_action(trig_types, 'c', - _trigger_change, actions); - - update_trigger_actions(); - } - - g_variant_unref(gvar); - } - - return actions; -} - void LogicSignal::paint_back(QPainter &p, int left, int right) { if (_probe->enabled) @@ -272,16 +188,6 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines, p.drawLines(lines, line - lines); } -void LogicSignal::add_trigger_action(const char *trig_types, char type, - QAction *action, list &actions) -{ - while(*trig_types) - if(*trig_types++ == type) { - actions.push_back(action); - break; - } -} - void LogicSignal::update_trigger_actions() { const char cur_trigger = _probe->trigger ? diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h index 18b54981..8b977ae2 100644 --- a/pv/view/logicsignal.h +++ b/pv/view/logicsignal.h @@ -52,12 +52,8 @@ public: virtual ~LogicSignal(); - void init_context_bar_actions(QWidget *parent); - boost::shared_ptr data() const; - const std::list get_context_bar_actions(); - /** * Paints the background layer of the signal with a QPainter * @param p the QPainter to paint into. @@ -81,9 +77,6 @@ private: bool level, double samples_per_pixel, double pixels_offset, float x_offset, float y_offset); - static void add_trigger_action(const char *trig_types, char type, - QAction *action, std::list &actions); - void update_trigger_actions(); void set_trigger(char type); @@ -99,8 +92,6 @@ private slots: private: boost::shared_ptr _data; - QAction *_separator; - QAction *_trigger_none; QAction *_trigger_rising; QAction *_trigger_high; diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h index 323c87e1..41f68117 100644 --- a/pv/view/selectableitem.h +++ b/pv/view/selectableitem.h @@ -54,10 +54,6 @@ public: void select(bool select = true); public: - virtual void init_context_bar_actions(QWidget *parent) = 0; - - virtual const std::list get_context_bar_actions() = 0; - virtual QMenu* create_context_menu(QWidget *parent); protected: diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 446814ed..7c4a11e0 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -51,29 +51,12 @@ const char *const ProbeNames[] = { Signal::Signal(pv::SigSession &session, const sr_probe *const probe) : Trace(session, probe->name), _probe(probe), - _name_action(NULL), _name_widget(NULL), _updating_name_widget(false) { assert(_probe); } -void Signal::init_context_bar_actions(QWidget *parent) -{ - _name_widget = new QComboBox(parent); - _name_widget->setEditable(true); - - _name_action = new QWidgetAction(parent); - _name_action->setDefaultWidget(_name_widget); - - for(unsigned int i = 0; i < countof(ProbeNames); i++) - _name_widget->insertItem(i, ProbeNames[i]); - _name_widget->setEditText(_probe->name); - - connect(_name_widget, SIGNAL(editTextChanged(const QString&)), - this, SLOT(on_text_changed(const QString&))); -} - void Signal::set_name(QString name) { Trace::set_name(name); diff --git a/pv/view/signal.h b/pv/view/signal.h index aff8c4c4..540eb6ed 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -46,8 +46,6 @@ protected: Signal(pv::SigSession &session, const sr_probe *const probe); public: - virtual void init_context_bar_actions(QWidget *parent); - /** * Sets the name of the signal. */ @@ -60,7 +58,6 @@ public: const sr_probe* probe() const; -private: virtual void populate_popup_form(QWidget *parent, QFormLayout *form); private slots: @@ -69,7 +66,6 @@ private slots: protected: const sr_probe *const _probe; - QWidgetAction *_name_action; QComboBox *_name_widget; bool _updating_name_widget; }; diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 5907631a..5fd75dd8 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -39,21 +39,6 @@ TimeMarker::TimeMarker(View &view, const QColor &colour, double time) : { } -void TimeMarker::init_context_bar_actions(QWidget *parent) -{ - _value_widget = new QDoubleSpinBox(parent); - _value_widget->setValue(_time); - _value_widget->setDecimals(6); - _value_widget->setSuffix("s"); - _value_widget->setSingleStep(1e-6); - - _value_action = new QWidgetAction(parent); - _value_action->setDefaultWidget(_value_widget); - - connect(_value_widget, SIGNAL(valueChanged(double)), - this, SLOT(on_value_changed(double))); -} - double TimeMarker::time() const { return _time; @@ -75,13 +60,6 @@ void TimeMarker::paint(QPainter &p, const QRect &rect) p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom())); } -const list TimeMarker::get_context_bar_actions() -{ - list actions; - actions.push_back(_value_action); - return actions; -} - void TimeMarker::on_value_changed(double value) { if (!_updating_value_widget) { diff --git a/pv/view/timemarker.h b/pv/view/timemarker.h index 328d428f..54b9c248 100644 --- a/pv/view/timemarker.h +++ b/pv/view/timemarker.h @@ -51,8 +51,6 @@ protected: TimeMarker(View &view, const QColor &colour, double time); public: - virtual void init_context_bar_actions(QWidget *parent); - /** * Gets the time of the marker. */ @@ -86,12 +84,6 @@ public: virtual void paint_label(QPainter &p, const QRect &rect, unsigned int prefix) = 0; - /** - * Returns a list of context menu items to show in the context - * bar. - */ - const std::list get_context_bar_actions(); - private slots: void on_value_changed(double value); diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 508b91c5..6af03c9c 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -390,7 +390,6 @@ void View::signals_changed() const vector< shared_ptr > traces(get_traces()); BOOST_FOREACH(shared_ptr t, traces) { t->set_view(this); - t->init_context_bar_actions(NULL); t->set_v_offset(offset); offset += SignalHeight + 2 * SignalMargin; }