qRegisterMetaType<util::Timestamp>("util::Timestamp");
qRegisterMetaType<uint64_t>("uint64_t");
+ GlobalSettings::register_change_handler(GlobalSettings::Key_View_ColouredBG,
+ bind(&MainWindow::on_settingViewColouredBg_changed, this, _1));
+
setup_ui();
restore_ui_settings();
shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
views::ViewType type, Session &session)
{
+ GlobalSettings settings;
+
QMainWindow *main_window = nullptr;
for (auto entry : session_windows_)
if (entry.first.get() == &session)
SLOT(trigger_event(util::Timestamp)));
v->enable_sticky_scrolling(true);
- v->enable_coloured_bg(true);
+ v->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
shared_ptr<MainBar> main_bar = session.main_bar();
if (!main_bar) {
void MainWindow::on_view_coloured_bg_shortcut()
{
- shared_ptr<views::ViewBase> viewbase = get_active_view();
- views::TraceView::View* view =
- qobject_cast<views::TraceView::View*>(viewbase.get());
- if (view)
- view->toggle_coloured_bg();
+ GlobalSettings settings;
+
+ bool state = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
+ settings.setValue(GlobalSettings::Key_View_ColouredBG, !state);
+}
+
+void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value)
+{
+ bool state = new_value.toBool();
+
+ for (auto entry : view_docks_) {
+ shared_ptr<views::ViewBase> viewbase = entry.second;
+
+ // Only trace views have this setting
+ views::TraceView::View* view =
+ qobject_cast<views::TraceView::View*>(viewbase.get());
+ if (view)
+ view->enable_coloured_bg(state);
+ }
}
void MainWindow::on_actionAbout_triggered()
void on_tab_close_requested(int index);
void on_view_sticky_scrolling_shortcut();
-
void on_view_coloured_bg_shortcut();
+ void on_settingViewColouredBg_changed(const QVariant new_value);
+
void on_actionAbout_triggered();
void on_close_current_tab();
#include "tracepalette.hpp"
#include "view.hpp"
-#include <pv/widgets/colourbutton.hpp>
-#include <pv/widgets/popup.hpp>
+#include "pv/globalsettings.hpp"
+#include "pv/widgets/colourbutton.hpp"
+#include "pv/widgets/popup.hpp"
namespace pv {
namespace views {
Trace::Trace(std::shared_ptr<data::SignalBase> channel) :
base_(channel),
- coloured_bg_(true), // Default setting is set in MainWindow::setup_ui()
popup_(nullptr),
popup_form_(nullptr)
{
+ GlobalSettings settings;
+ coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
+
connect(channel.get(), SIGNAL(name_changed(const QString&)),
this, SLOT(on_name_changed(const QString&)));
connect(channel.get(), SIGNAL(colour_changed(const QColor&)),
#include "viewport.hpp"
#include "pv/session.hpp"
+#include "pv/globalsettings.hpp"
#include "pv/devices/device.hpp"
#include "pv/data/logic.hpp"
#include "pv/data/logicsegment.hpp"
offset_(0),
updating_scroll_(false),
sticky_scrolling_(false), // Default setting is set in MainWindow::setup_ui()
- coloured_bg_(false),
always_zoom_to_fit_(false),
tick_period_(0),
tick_prefix_(pv::util::SIPrefix::yocto),
saved_v_offset_(0),
size_finalized_(false)
{
+ GlobalSettings settings;
+ coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
+
connect(scrollarea_.horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(h_scroll_value_changed(int)));
connect(scrollarea_.verticalScrollBar(), SIGNAL(valueChanged(int)),
sticky_scrolling_ = !sticky_scrolling_;
}
-bool View::get_coloured_bg(void)
-{
- return coloured_bg_;
-}
-
void View::enable_coloured_bg(bool state)
{
const vector<shared_ptr<TraceTreeItem>> items(
list_by_type<TraceTreeItem>());
- coloured_bg_ = state;
-
for (shared_ptr<TraceTreeItem> i : items) {
// Can't cast to Trace because it's abstract, so we need to
// check for any derived classes individually
viewport_->update();
}
-void View::toggle_coloured_bg(void)
-{
- enable_coloured_bg(!coloured_bg_);
-}
-
bool View::cursors_shown() const
{
return show_cursors_;
*/
void toggle_sticky_scrolling(void);
- /**
- * Get current coloured_bg state. Returns true if coloured backgrounds are enabled.
- */
- bool get_coloured_bg(void);
-
/**
* Enables or disables coloured trace backgrounds. If they're not
* coloured then they will use alternating colors.
*/
void enable_coloured_bg(bool state);
- /**
- * Toggle coloured backgrounds.
- */
- void toggle_coloured_bg(void);
-
/**
* Returns true if cursors are displayed. false otherwise.
*/