X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fwidgets%2Fpopup.hpp;h=879c5f9d83542e3a4fc50485441554cabdc9ea24;hb=8845be3c9c7d5aca02fb2efc4038f4735a5242d6;hp=c6f931f69c1496141154198c57ee1087ece36be6;hpb=7a01bd3654ed046216308fa64edfd79be7cd525f;p=pulseview.git diff --git a/pv/widgets/popup.hpp b/pv/widgets/popup.hpp index c6f931f6..879c5f9d 100644 --- a/pv/widgets/popup.hpp +++ b/pv/widgets/popup.hpp @@ -14,18 +14,35 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #ifndef PULSEVIEW_PV_WIDGETS_POPUP_HPP #define PULSEVIEW_PV_WIDGETS_POPUP_HPP +#include #include namespace pv { namespace widgets { + +// A regular QScrollArea has a fixed size and provides scroll bars when the +// content can't be shown in its entirety. However, we want no horizontal +// scroll bar and want the scroll area to adjust its width to fit the content +// instead. +// Inspired by https://stackoverflow.com/questions/21253755/qscrollarea-with-dynamically-changing-contents?answertab=votes#tab-top +class QWidthAdjustingScrollArea : public QScrollArea +{ + Q_OBJECT + +public: + QWidthAdjustingScrollArea(QWidget* parent = nullptr); + void setWidget(QWidget* w); + bool eventFilter(QObject* obj, QEvent* ev); +}; + + class Popup : public QWidget { Q_OBJECT @@ -52,9 +69,9 @@ public: void set_position(const QPoint point, Position pos); - bool eventFilter(QObject *obj, QEvent *evt); + bool eventFilter(QObject *obj, QEvent *event); - void show(); + virtual void show(); private: bool space_for_arrow() const; @@ -78,10 +95,10 @@ private: void resizeEvent(QResizeEvent*); - void mouseReleaseEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *event); protected: - void showEvent(QShowEvent *e); + void showEvent(QShowEvent *); Q_SIGNALS: void closed();