SLOT(on_view_snapDistance_changed(int)));
trace_view_layout->addRow(tr("Maximum distance from edges before cursors snap to them"), snap_distance_sb);
+ ColorButton* cursor_fill_cb = new ColorButton(parent);
+ cursor_fill_cb->set_color(QColor::fromRgba(
+ settings.value(GlobalSettings::Key_View_CursorFillColor).value<uint32_t>()));
+ connect(cursor_fill_cb, SIGNAL(selected(QColor)),
+ this, SLOT(on_view_cursorFillColor_changed(QColor)));
+ trace_view_layout->addRow(tr("Color to fill cursor area with"), cursor_fill_cb);
+
QComboBox *thr_disp_mode_cb = new QComboBox();
thr_disp_mode_cb->addItem(tr("None"), GlobalSettings::ConvThrDispMode_None);
thr_disp_mode_cb->addItem(tr("Background"), GlobalSettings::ConvThrDispMode_Background);
settings.setValue(GlobalSettings::Key_View_SnapDistance, value);
}
+void Settings::on_view_cursorFillColor_changed(QColor color)
+{
+ GlobalSettings settings;
+ settings.setValue(GlobalSettings::Key_View_CursorFillColor, color.rgba());
+}
+
void Settings::on_view_conversionThresholdDispMode_changed(int state)
{
GlobalSettings settings;
void on_view_showAnalogMinorGrid_changed(int state);
void on_view_showHoverMarker_changed(int state);
void on_view_snapDistance_changed(int value);
+ void on_view_cursorFillColor_changed(QColor color);
void on_view_conversionThresholdDispMode_changed(int state);
void on_view_defaultDivHeight_changed(int value);
void on_view_defaultLogicHeight_changed(int value);
const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight";
const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker";
const QString GlobalSettings::Key_View_SnapDistance = "View_SnapDistance";
+const QString GlobalSettings::Key_View_CursorFillColor = "View_CursorFillColor";
const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable";
const QString GlobalSettings::Key_Dec_ExportFormat = "Dec_ExportFormat";
const QString GlobalSettings::Key_Log_BufferSize = "Log_BufferSize";
if (!contains(Key_Log_NotifyOfStacktrace))
setValue(Key_Log_NotifyOfStacktrace, true);
- // Default theme is bright, so use its color scheme
- set_bright_theme_default_colors();
+ // Default theme is bright, so use its color scheme if undefined
+ if (!contains(Key_View_CursorFillColor))
+ set_bright_theme_default_colors();
}
void GlobalSettings::set_bright_theme_default_colors()
{
setValue(Key_View_FillSignalHighAreaColor,
QColor(0, 0, 0, 5 * 256 / 100).rgba());
+
+ setValue(Key_View_CursorFillColor,
+ QColor(220, 231, 243).rgba());
}
void GlobalSettings::set_dark_theme_default_colors()
{
setValue(Key_View_FillSignalHighAreaColor,
QColor(188, 188, 188, 9 * 256 / 100).rgba());
+
+ setValue(Key_View_CursorFillColor,
+ QColor(60, 60, 60).rgba());
}
bool GlobalSettings::current_theme_is_dark()
static const QString Key_View_DefaultLogicHeight;
static const QString Key_View_ShowHoverMarker;
static const QString Key_View_SnapDistance;
+ static const QString Key_View_CursorFillColor;
static const QString Key_Dec_InitialStateConfigurable;
static const QString Key_Dec_ExportFormat;
static const QString Key_Log_BufferSize;
#include <algorithm>
#include <cassert>
-#include <QDebug>
+#include <QColor>
#include <QToolTip>
#include "cursorpair.hpp"
+#include "pv/globalsettings.hpp"
#include "pv/util.hpp"
#include "ruler.hpp"
#include "view.hpp"
namespace trace {
const int CursorPair::DeltaPadding = 8;
-const QColor CursorPair::ViewportFillColor(220, 231, 243);
CursorPair::CursorPair(View &view) :
TimeItem(view),
first_(new Cursor(view, 0.0)),
second_(new Cursor(view, 1.0))
{
+ GlobalSettings::add_change_handler(this);
+
+ GlobalSettings settings;
+ fill_color_ = QColor::fromRgba(settings.value(
+ GlobalSettings::Key_View_CursorFillColor).value<uint32_t>());
+
connect(&view_, SIGNAL(hover_point_changed(const QWidget*, QPoint)),
this, SLOT(on_hover_point_changed(const QWidget*, QPoint)));
}
+CursorPair::~CursorPair()
+{
+ GlobalSettings::remove_change_handler(this);
+}
+
bool CursorPair::enabled() const
{
return view_.cursors_shown();
return;
p.setPen(Qt::NoPen);
- p.setBrush(QBrush(ViewportFillColor));
+ p.setBrush(fill_color_);
const pair<float, float> offsets(get_cursor_offsets());
const int l = (int)max(min(offsets.first, offsets.second), 0.0f);
return pair<float, float>(first_->get_x(), second_->get_x());
}
+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())
#define PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP
#include "cursor.hpp"
+#include "pv/globalsettings.hpp"
#include <memory>
+#include <QColor>
#include <QPainter>
#include <QRect>
class View;
-class CursorPair : public TimeItem
+class CursorPair : public TimeItem, public GlobalSettingsInterface
{
Q_OBJECT
private:
static const int DeltaPadding;
- static const QColor ViewportFillColor;
public:
/**
*/
CursorPair(View &view);
+ ~CursorPair();
+
/**
* Returns true if the item is visible and enabled.
*/
pv::widgets::Popup* create_popup(QWidget *parent) override;
-public:
QRectF label_rect(const QRectF &rect) const override;
/**
pair<float, float> get_cursor_offsets() const;
+ virtual void on_setting_changed(const QString &key, const QVariant &value) override;
+
public Q_SLOTS:
void on_hover_point_changed(const QWidget* widget, const QPoint &hp);
private:
shared_ptr<Cursor> first_, second_;
+ QColor fill_color_;
QSizeF text_size_;
QRectF label_area_;
* nature, not making assumptions about the kind of item shown.
*/
class TimeItem : public ViewItem
-
{
Q_OBJECT
public:
ViewItem();
-public:
/**
* Returns true if the item is visible and enabled.
*/
*/
virtual void paint_fore(QPainter &p, ViewItemPaintParams &pp);
-public:
/**
* Gets the text color.
* @remarks This color is computed by comparing the lightness