+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>());
+
+ if (key == GlobalSettings::Key_View_CursorShowFrequency)
+ show_frequency_ = value.value<bool>();
+
+ if (key == GlobalSettings::Key_View_CursorShowInterval)
+ show_interval_ = value.value<bool>();
+}
+
+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)
+{
+ QString s = " ";
+
+ 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) {
+ int items = 0;
+
+ if (show_frequency_) {
+ const QString freq = util::format_value_si(
+ 1 / diff.convert_to<double>(), pv::util::SIPrefix::unspecified,
+ freq_precision, (show_unit ? "Hz" : nullptr), false);
+ s = QString("%1").arg(freq);
+ items++;
+ }
+
+ if (show_interval_) {
+ if (items > 0)
+ s = QString("%1 / %2").arg(s, time);
+ else
+ s = QString("%1").arg(time);
+ items++;
+ }
+ } else
+ // In this case, we return the number of samples, really
+ s = time;
+
+ return s;
+}
+