From: Soeren Apel Date: Thu, 1 Jun 2017 20:42:20 +0000 (+0200) Subject: View: Limit header pane width X-Git-Tag: pulseview-0.4.0~46 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e0be5f218757a03a2132c50417190b82de1a6bd5;p=pulseview.git View: Limit header pane width --- diff --git a/pv/view/view.cpp b/pv/view/view.cpp index f3afd937..17b9c153 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -204,6 +204,9 @@ View::View(Session &session, bool is_main_view, QWidget *parent) : connect(ruler_, SIGNAL(selection_changed()), this, SIGNAL(selection_changed())); + connect(splitter_, SIGNAL(splitterMoved(int, int)), + this, SLOT(on_splitter_moved())); + connect(this, SIGNAL(hover_point_changed()), this, SLOT(on_hover_point_changed())); @@ -874,7 +877,10 @@ bool View::header_fully_visible() const const int header_pane_width = splitter_->sizes().front(); const int header_width = header_->extended_size_hint().width(); - return (header_pane_width >= header_width); + // Allow for a slight margin of error so that we also accept + // slight differences when e.g. a label name change increased + // the overall width + return (header_pane_width >= (header_width - 10)); } void View::update_layout() @@ -1040,8 +1046,13 @@ void View::row_item_appearance_changed(bool label, bool content) void View::time_item_appearance_changed(bool label, bool content) { - if (label) + if (label) { ruler_->update(); + + // Make sure the header pane width is updated, too + update_layout(); + } + if (content) viewport_->update(); } @@ -1055,6 +1066,15 @@ void View::extents_changed(bool horz, bool vert) lazy_event_handler_.start(); } +void View::on_splitter_moved() +{ + // Setting the maximum width of the header widget doesn't work as + // expected because the splitter would allow the user to make the + // pane wider than that, creating empty space as a result. + // To make this work, we stricly enforce the maximum width by calling + update_layout(); +} + void View::h_scroll_value_changed(int value) { if (updating_scroll_) diff --git a/pv/view/view.hpp b/pv/view/view.hpp index 8d5e60f2..11842131 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -353,6 +353,7 @@ public: private Q_SLOTS: + void on_splitter_moved(); void h_scroll_value_changed(int value); void v_scroll_value_changed();