1 /*************************************************************************** 2 qgsuserinputwidget.h 3 -------------------------------------- 4 Date : 04.2015 5 Copyright : (C) 2015 Denis Rouzaud 6 Email : denis.rouzaud@gmail.com 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 17 #ifndef QGSUSERINPUTWIDGET_H 18 #define QGSUSERINPUTWIDGET_H 19 20 #include "qgis_sip.h" 21 #include "qgis_gui.h" 22 #include "qgsfloatingwidget.h" 23 24 #include <QMap> 25 #include <QBoxLayout> 26 27 class QBoxLayout; 28 class QFrame; 29 30 31 /** 32 * \ingroup gui 33 * \brief The QgsUserInputWidget class is a floating widget that shall be used to display widgets for user inputs. 34 * It can be used by map tools, plugins, etc. 35 * Several widgets can be displayed at once, they will be separated by a separator. 36 * Widgets will be either layout horizontally or vertically. 37 * The widget is automatically hidden if it contains no widget. 38 * \since QGIS 2.10 39 */ 40 class GUI_EXPORT QgsUserInputWidget : public QgsFloatingWidget 41 { 42 Q_OBJECT 43 public: 44 45 //! Constructor for QgsUserInputWidget 46 QgsUserInputWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr ); 47 48 /** 49 * Add a widget to be displayed in the dock. 50 * \param widget widget to add. Ownership is not transferred. 51 */ 52 void addUserInputWidget( QWidget *widget ); 53 54 protected: 55 // will not display the dock if it contains no widget 56 void paintEvent( QPaintEvent *event ) override; 57 58 private slots: 59 void widgetDestroyed( QObject *obj ); 60 61 private: 62 //! change layout direction 63 void setLayoutDirection( QBoxLayout::Direction direction ); 64 65 // list of widget with their corresponding line separator 66 QMap<QWidget *, QFrame *> mWidgetList; 67 68 bool mLayoutHorizontal = true; 69 QBoxLayout *mLayout = nullptr; 70 }; 71 72 #endif // QGSUSERINPUTWIDGET_H 73