File indexing completed on 2024-05-19 04:44:49
0001 /* 0002 Gwenview: an image viewer 0003 SPDX-FileCopyrightText: 2007 Aurélien Gâteau <agateau@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 */ 0008 #pragma once 0009 0010 // Qt 0011 #include <QFrame> 0012 #include <QPointer> 0013 0014 #include "textaddonswidgets_export.h" 0015 0016 class QPropertyAnimation; 0017 0018 namespace TextAddonsWidgets 0019 { 0020 /** 0021 * This widget is design to contain one child widget, the "content" widget. 0022 * It will start hidden by default. Calling slideIn() will slide in the content 0023 * widget from the top border. Calling slideOut() will slide it out. 0024 */ 0025 class TEXTADDONSWIDGETS_EXPORT SlideContainer : public QFrame 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(int slideHeight READ slideHeight WRITE setSlideHeight) 0029 public: 0030 explicit SlideContainer(QWidget *parent = nullptr); 0031 0032 /** 0033 * Returns the content widget 0034 */ 0035 QWidget *content() const; 0036 0037 /** 0038 * Defines the content widget 0039 */ 0040 void setContent(QWidget *content); 0041 0042 QSize sizeHint() const override; 0043 QSize minimumSizeHint() const override; 0044 0045 [[nodiscard]] int slideHeight() const; 0046 0047 Q_INVOKABLE void setSlideHeight(int height); 0048 0049 public Q_SLOTS: 0050 /** 0051 * Slides the content widget in. 0052 * Calling it multiple times won't cause the animation to be replayed. 0053 */ 0054 void slideIn(); 0055 0056 /** 0057 * Slides the content widget out. 0058 * Calling it multiple times won't cause the animation to be replayed. 0059 */ 0060 void slideOut(); 0061 0062 Q_SIGNALS: 0063 void slidedIn(); 0064 void slidedOut(); 0065 0066 protected: 0067 void resizeEvent(QResizeEvent *) override; 0068 bool eventFilter(QObject *, QEvent *event) override; 0069 0070 private: 0071 TEXTADDONSWIDGETS_NO_EXPORT void slotAnimFinished(); 0072 TEXTADDONSWIDGETS_NO_EXPORT void adjustContentGeometry(); 0073 0074 TEXTADDONSWIDGETS_NO_EXPORT void animTo(int height); 0075 QPointer<QWidget> mContent; 0076 QPointer<QPropertyAnimation> mAnim; 0077 bool mSlidingOut = false; 0078 }; 0079 } /* namespace */