API Documentation
Loading...
Searching...
No Matches
WidgetInit.h
Go to the documentation of this file.
1#pragma once
2class QWidget;
3namespace NDEVR
4{
5 class DockItem;
6 class QCustomDockWidget;
7 /**--------------------------------------------------------------------------------------------------
8 \brief Provides a way to lazily initialize widgets when needed but still pass them to container
9 dialogs. Useful for adding things to Settings dialogs or other large structures where
10 they may never be initialized.
11 **/
13 {
14 public:
15 WidgetInit(std::function<QWidget*()> init)
16 : m_create_widget(init)
17 {}
18 WidgetInit(QWidget* widget)
19 : m_widget(widget)
20 {}
21 virtual QWidget* getWidget()
22 {
23 if (m_widget == nullptr)
25 return m_widget;
26 }
27 protected:
28 const std::function<QWidget*()> m_create_widget;
29 QWidget* m_widget = nullptr;
30 };
31 /**--------------------------------------------------------------------------------------------------
32 \brief Provides a way to optianally lazily initialize widgets when needed but still pass them
33 to container docks. Useful for adding things to Settings dialogs or other large structures where
34 they may never be initialized.
35 **/
37 {
38 public:
39 DockInit(std::function<QCustomDockWidget*()> init)
40 : m_create_dock(init)
41 {}
43 : m_dock_item(init)
44 {}
45 bool isInit() const
46 {
47 return m_dock_item != nullptr;
48 }
50 {
51 if (m_dock_item == nullptr)
53 return m_dock_item;
54 }
55 protected:
56 const std::function<QCustomDockWidget*()> m_create_dock;
58 };
59}
Provides a way to optianally lazily initialize widgets when needed but still pass them to container d...
Definition WidgetInit.h:37
DockInit(QCustomDockWidget *init)
Definition WidgetInit.h:42
DockInit(std::function< QCustomDockWidget *()> init)
Definition WidgetInit.h:39
virtual QCustomDockWidget * getDock()
Definition WidgetInit.h:49
QCustomDockWidget * m_dock_item
Definition WidgetInit.h:57
bool isInit() const
Definition WidgetInit.h:45
const std::function< QCustomDockWidget *()> m_create_dock
Definition WidgetInit.h:56
Provides a wrapper for a widget that can be docked inside a Container or floated as a top-level windo...
Definition QCustomDockWidget.h:61
Provides a way to lazily initialize widgets when needed but still pass them to container dialogs....
Definition WidgetInit.h:13
WidgetInit(QWidget *widget)
Definition WidgetInit.h:18
const std::function< QWidget *()> m_create_widget
Definition WidgetInit.h:28
WidgetInit(std::function< QWidget *()> init)
Definition WidgetInit.h:15
virtual QWidget * getWidget()
Definition WidgetInit.h:21
QWidget * m_widget
Definition WidgetInit.h:29
Definition ACIColor.h:37