X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fruler.cpp;h=9f7cff2c6341e6f40dd86de31e388c6ee66f701f;hb=3af62a24878d4b0b0ec20c3bc7f142149ffc36be;hp=c043aacf2b160d926a557915e2bafe95c397329a;hpb=333d5bbc0a326e6fa82db44f3e6ba8dd79cafdd8;p=pulseview.git diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index c043aac..9f7cff2 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -58,8 +59,10 @@ Ruler::Ruler(View &parent) : this, SLOT(hover_point_changed())); } -void Ruler::paintEvent(QPaintEvent *event) +void Ruler::paintEvent(QPaintEvent*) { + using namespace Qt; + QPainter p(this); p.setRenderHint(QPainter::Antialiasing); @@ -79,16 +82,15 @@ void Ruler::paintEvent(QPaintEvent *event) } while (tick_period < min_period && unit < countof(ScaleUnits)); const unsigned int prefix = (order - FirstSIPrefixPower) / 3; - assert(prefix >= 0); assert(prefix < countof(SIPrefixes)); const double multiplier = pow(10.0, - prefix * 3 - FirstSIPrefixPower); const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX, - Qt::AlignLeft | Qt::AlignTop, "8").height(); + AlignLeft | AlignTop, "8").height(); // Draw the tick marks - p.setPen(Qt::black); + p.setPen(palette().color(foregroundRole())); const double minor_tick_period = tick_period / MinorTickSubdivision; const double first_major_division = @@ -113,8 +115,8 @@ void Ruler::paintEvent(QPaintEvent *event) QString s; QTextStream ts(&s); ts << (t * multiplier) << SIPrefixes[prefix] << "s"; - p.drawText(x, 0, 0, text_height, Qt::AlignCenter | - Qt::AlignTop | Qt::TextDontClip, s); + p.drawText(x, 0, 0, text_height, AlignCenter | + AlignTop | TextDontClip, s); p.drawLine(QPointF(x, text_height), QPointF(x, height())); }