]> sigrok.org Git - pulseview.git/commitdiff
Set trigger buttons as checked depending on the trigger type
authorJoel Holdsworth <redacted>
Mon, 27 May 2013 11:24:37 +0000 (12:24 +0100)
committerJoel Holdsworth <redacted>
Mon, 27 May 2013 11:24:37 +0000 (12:24 +0100)
pv/view/logicsignal.cpp
pv/view/logicsignal.h

index ea138fa76d2b2285e50c588ed26b833c4e1df170..c8713114fbf1a8bea4e785a0e49b83958578da16 100644 (file)
@@ -81,16 +81,27 @@ LogicSignal::LogicSignal(pv::SigSession &session, const sr_probe *const probe,
 
        _separator.setSeparator(true);
 
+       _trigger_none.setCheckable(true);
        connect(&_trigger_none, SIGNAL(triggered()),
                this, SLOT(on_trigger_none()));
+
+       _trigger_rising.setCheckable(true);
        connect(&_trigger_rising, SIGNAL(triggered()),
                this, SLOT(on_trigger_rising()));
+
+       _trigger_high.setCheckable(true);
        connect(&_trigger_high, SIGNAL(triggered()),
                this, SLOT(on_trigger_high()));
+
+       _trigger_falling.setCheckable(true);
        connect(&_trigger_falling, SIGNAL(triggered()),
                this, SLOT(on_trigger_falling()));
+
+       _trigger_low.setCheckable(true);
        connect(&_trigger_low, SIGNAL(triggered()),
                this, SLOT(on_trigger_low()));
+
+       _trigger_change.setCheckable(true);
        connect(&_trigger_change, SIGNAL(triggered()),
                this, SLOT(on_trigger_change()));
 }
@@ -128,6 +139,8 @@ const list<QAction*> LogicSignal::get_context_bar_actions()
                                &_trigger_low, actions);
                        add_trigger_action(trig_types, 'c',
                                &_trigger_change, actions);
+               
+                       update_trigger_actions();
                }
 
                g_variant_unref(gvar);
@@ -246,6 +259,18 @@ void LogicSignal::add_trigger_action(const char *trig_types, char type,
                }
 }
 
+void LogicSignal::update_trigger_actions()
+{
+       const char cur_trigger = _probe->trigger ?
+               _probe->trigger[0] : '\0';
+       _trigger_none.setChecked(cur_trigger == '\0');
+       _trigger_rising.setChecked(cur_trigger == 'r');
+       _trigger_high.setChecked(cur_trigger == '1');
+       _trigger_falling.setChecked(cur_trigger == 'f');
+       _trigger_low.setChecked(cur_trigger == '0');
+       _trigger_change.setChecked(cur_trigger == 'c');
+}
+
 void LogicSignal::set_trigger(char type)
 {
        const char trigger_type_string[2] = {type, 0};
@@ -262,6 +287,8 @@ void LogicSignal::set_trigger(char type)
                sr_dev_trigger_set(sdi, i, (i == _probe->index) ?
                        trigger_string : NULL);
        }
+
+       update_trigger_actions();
 }
 
 void LogicSignal::on_trigger_none()
index 81a6e7c0c2b3e735c2725c05bb6cd82cda780ad1..37870be6ed23928115f1462802d51057e05e3b31 100644 (file)
@@ -77,6 +77,8 @@ private:
        static void add_trigger_action(const char *trig_types, char type,
                QAction *action, std::list<QAction*> &actions);
 
+       void update_trigger_actions();
+
        void set_trigger(char type);
 
 private slots: