+void CursorPair::on_setting_changed(const QString &key, const QVariant &value)
+{
+ if (key == GlobalSettings::Key_View_CursorFillColor)
+ fill_color_ = QColor::fromRgba(value.value<uint32_t>());
+}
+
+void CursorPair::on_hover_point_changed(const QWidget* widget, const QPoint& hp)
+{
+ if (widget != view_.ruler())
+ return;
+
+ if (!label_incomplete_)
+ return;
+
+ if (label_area_.contains(hp))
+ QToolTip::showText(view_.mapToGlobal(hp), format_string());
+ else
+ QToolTip::hideText(); // TODO Will break other tooltips when there can be others
+}
+
+QString CursorPair::format_string_sub(int time_precision, int freq_precision, bool show_unit)
+{
+ const pv::util::SIPrefix prefix = view_.tick_prefix();
+ const pv::util::Timestamp diff = abs(second_->time() - first_->time());
+
+ const QString time = Ruler::format_time_with_distance(
+ diff, diff, prefix, (show_unit ? view_.time_unit() : pv::util::TimeUnit::None),
+ time_precision, false);
+
+ // We can only show a frequency when there's a time base
+ if (view_.time_unit() == pv::util::TimeUnit::Time) {
+ const QString freq = util::format_value_si(
+ 1 / diff.convert_to<double>(), pv::util::SIPrefix::unspecified,
+ freq_precision, (show_unit ? "Hz" : nullptr), false);
+
+ return QString("%1 / %2").arg(time, freq);
+ } else
+ // In this case, we return the number of samples, really
+ return time;
+}
+