duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

collapsiblewidget.h (742B)


      1 // https://stackoverflow.com/questions/32476006/how-to-make-an-expandable-collapsable-section-widget-in-qt
      2 
      3 #pragma once
      4 
      5 #include <QtCore/QParallelAnimationGroup>
      6 #include <QtWidgets/QScrollArea>
      7 #include <QtWidgets/QToolButton>
      8 #include <QtWidgets/QVBoxLayout>
      9 #include <QtWidgets/QWidget>
     10 
     11 class CollapsibleWidget : public QWidget
     12 {
     13   Q_OBJECT
     14 private:
     15   QVBoxLayout mainLayout;
     16   QToolButton toggleButton;
     17   QParallelAnimationGroup toggleAnimation;
     18   QScrollArea contentArea;
     19   int animationDuration{300};
     20 
     21 public:
     22   explicit CollapsibleWidget(const QString& title = "", const int animationDuration = 300, QWidget* parent = 0);
     23 
     24   QScrollArea* getScrollArea() { return &contentArea; }
     25 
     26   void setContentLayout(QLayout* contentLayout);
     27 };