From: Soeren Apel Date: Tue, 17 Dec 2019 08:36:43 +0000 (+0100) Subject: DecoderOutputView: Allow for adaptive size constraints X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6961eab0d4bf976cee015afacfa7c25795e574b9;p=pulseview.git DecoderOutputView: Allow for adaptive size constraints --- diff --git a/pv/views/decoder_output/QHexView.cpp b/pv/views/decoder_output/QHexView.cpp index 82b1cd90..06df103b 100644 --- a/pv/views/decoder_output/QHexView.cpp +++ b/pv/views/decoder_output/QHexView.cpp @@ -121,6 +121,11 @@ void QHexView::showFromOffset(size_t offset) viewport()->update(); } +QSizePolicy QHexView::sizePolicy() const +{ + return QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); +} + void QHexView::initialize_byte_iterator(size_t offset) { current_chunk_id_ = 0; diff --git a/pv/views/decoder_output/QHexView.hpp b/pv/views/decoder_output/QHexView.hpp index 37b7e4e4..e7c25567 100644 --- a/pv/views/decoder_output/QHexView.hpp +++ b/pv/views/decoder_output/QHexView.hpp @@ -56,6 +56,7 @@ public: void clear(); void showFromOffset(size_t offset); + virtual QSizePolicy sizePolicy() const; protected: void initialize_byte_iterator(size_t offset); diff --git a/pv/views/decoder_output/view.cpp b/pv/views/decoder_output/view.cpp index 1f712da9..18cb3b44 100644 --- a/pv/views/decoder_output/view.cpp +++ b/pv/views/decoder_output/view.cpp @@ -53,6 +53,7 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : ViewBase(session, is_main_view, parent), // Note: Place defaults in View::reset_view_state(), not here + parent_(parent), decoder_selector_(new QComboBox()), format_selector_(new QComboBox()), class_selector_(new QComboBox()), @@ -93,6 +94,8 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : decoder_selector_->setSizeAdjustPolicy(QComboBox::AdjustToContents); class_selector_->setSizeAdjustPolicy(QComboBox::AdjustToContents); + parent->setSizePolicy(hex_view_->sizePolicy()); // TODO Must be updated when selected widget changes + reset_view_state(); } diff --git a/pv/views/decoder_output/view.hpp b/pv/views/decoder_output/view.hpp index 7644f82a..39869d51 100644 --- a/pv/views/decoder_output/view.hpp +++ b/pv/views/decoder_output/view.hpp @@ -77,6 +77,8 @@ private Q_SLOTS: virtual void perform_delayed_view_update(); private: + QWidget* parent_; + QComboBox *decoder_selector_, *format_selector_, *class_selector_; QStackedWidget *stacked_widget_; QHexView *hex_view_;