]> sigrok.org Git - pulseview.git/blobdiff - pv/view/decodetrace.cpp
Make header width responsive to label text
[pulseview.git] / pv / view / decodetrace.cpp
index beb83b1f20634febe91707867fca8ca0af93c77f..2d641827f13bbd8416f09baa62f74c18cdce5a47 100644 (file)
@@ -27,6 +27,7 @@ extern "C" {
 #include <boost/foreach.hpp>
 
 #include <QAction>
+#include <QApplication>
 #include <QComboBox>
 #include <QFormLayout>
 #include <QLabel>
@@ -107,7 +108,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
        const double scale = _view->scale();
        assert(scale > 0);
 
-       double samplerate = _decoder_stack->get_samplerate();
+       double samplerate = _decoder_stack->samplerate();
 
        // Show sample rate as 1Hz when it is unknown
        if (samplerate == 0.0)
@@ -117,7 +118,8 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
                _decoder_stack->get_start_time()) / scale;
        const double samples_per_pixel = samplerate * scale;
 
-       const int h = (_text_size.height() * 5) / 4;
+       QFontMetrics m(QApplication::font());
+       const int h = (m.boundingRect(QRect(), 0, "Tg").height() * 5) / 4;
 
        assert(_decoder_stack);
        const QString err = _decoder_stack->error_message();
@@ -250,7 +252,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left,
        BOOST_FOREACH (const shared_ptr<Decoder> &dec, stack)
                if (dec && !dec->probes().empty() &&
                        ((logic_signal = (*dec->probes().begin()).second)) &&
-                       ((data = logic_signal->data())))
+                       ((data = logic_signal->logic_data())))
                        break;
 
        if (!data || data->get_snapshots().empty())