Libkleo

adjustingscrollarea.h
1/* -*- mode: c++; c-basic-offset:4 -*-
2 ui/adjustingscrollarea.h
3
4 This file is part of Kleopatra, the KDE keymanager
5 SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB
6 SPDX-FileCopyrightText: 2022 g10 Code GmbH
7 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
8
9 SPDX-License-Identifier: GPL-2.0-or-later
10*/
11
12#pragma once
13
14#include "kleo_export.h"
15
16#include <QScrollArea>
17
18namespace Kleo
19{
20
21/**
22 * This class improves a few aspects of QScrollArea for usage by us, in
23 * particular, for vertically scrollable widgets.
24 *
25 * If sizeAdjustPolicy is set to QAbstractScrollArea::AdjustToContents,
26 * then the scroll area will (try to) adjust its size to the widget to avoid
27 * scroll bars as much as possible.
28 */
29class KLEO_EXPORT AdjustingScrollArea : public QScrollArea
30{
31 Q_OBJECT
32
33public:
34 /**
35 * Creates a scroll area with a QWidget with QVBoxLayout that is flagged
36 * as resizable.
37 */
38 explicit AdjustingScrollArea(QWidget *parent = nullptr);
39 ~AdjustingScrollArea() override;
40
41 /**
42 * Reimplemented to add the minimum size hint of the widget.
43 */
44 QSize minimumSizeHint() const override;
45
46 /**
47 * Reimplemented to remove the caching of the size/size hint of the
48 * widget and to add the horizontal size hint of the vertical scroll bar
49 * unless it is explicitly turned off.
50 */
51 QSize sizeHint() const override;
52
53private:
54 void adjustSizeOfWindowBy(const QSize &extent);
55 bool eventFilter(QObject *obj, QEvent *ev) override;
56};
57
58}
This class improves a few aspects of QScrollArea for usage by us, in particular, for vertically scrol...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.