12#include "DockWidgetInstantiator_p.h"
14#include "../DockRegistry_p.h"
18QString DockWidgetInstantiator::uniqueName()
const
23void DockWidgetInstantiator::setUniqueName(
const QString &name)
26 Q_EMIT uniqueNameChanged();
29QString DockWidgetInstantiator::source()
const
31 return m_sourceFilename;
34void DockWidgetInstantiator::setSource(
const QString &source)
36 m_sourceFilename = source;
37 Q_EMIT sourceChanged();
45TitleBar *DockWidgetInstantiator::actualTitleBar()
const
50QString DockWidgetInstantiator::title()
const
52 return m_dockWidget ? m_dockWidget->title() :
QString();
55void DockWidgetInstantiator::setTitle(
const QString &title)
58 m_dockWidget->setTitle(title);
62bool DockWidgetInstantiator::isFocused()
const
64 return m_dockWidget && m_dockWidget->isFocused();
67bool DockWidgetInstantiator::isFloating()
const
69 return m_dockWidget && m_dockWidget->isFloating();
72void DockWidgetInstantiator::setFloating(
bool is)
75 m_dockWidget->setFloating(is);
79void DockWidgetInstantiator::addDockWidgetAsTab(DockWidgetInstantiator *other,
83 m_dockWidget->addDockWidgetAsTab(other ? other->dockWidget() : nullptr, option);
86void DockWidgetInstantiator::addDockWidgetAsTab(
DockWidgetBase *other,
90 m_dockWidget->addDockWidgetAsTab(other, option);
93void DockWidgetInstantiator::addDockWidgetToContainingWindow(
DockWidgetBase *other,
100 m_dockWidget->addDockWidgetToContainingWindow(other, location, relativeTo,
104void DockWidgetInstantiator::addDockWidgetToContainingWindow(DockWidgetInstantiator *other,
106 DockWidgetInstantiator *relativeTo,
111 m_dockWidget->addDockWidgetToContainingWindow(
112 other ? other->dockWidget() : nullptr, location,
113 relativeTo ? relativeTo->dockWidget() : nullptr,
InitialOption(option, initialSize));
116void DockWidgetInstantiator::setAsCurrentTab()
119 m_dockWidget->setAsCurrentTab();
122void DockWidgetInstantiator::forceClose()
125 m_dockWidget->forceClose();
128Q_INVOKABLE
bool DockWidgetInstantiator::close()
131 return m_dockWidget->close();
136void DockWidgetInstantiator::show()
139 m_dockWidget->show();
142void DockWidgetInstantiator::raise()
145 m_dockWidget->raise();
148void DockWidgetInstantiator::moveToSideBar()
151 m_dockWidget->moveToSideBar();
154void DockWidgetInstantiator::classBegin()
159void DockWidgetInstantiator::componentComplete()
161 if (m_uniqueName.isEmpty()) {
162 qWarning() << Q_FUNC_INFO <<
"Each DockWidget need an unique name. Set the uniqueName property.";
166 if (DockRegistry::self()->containsDockWidget(m_uniqueName)) {
172 qWarning() << Q_FUNC_INFO <<
"Unexpected bug.";
175 const auto childItems = this->childItems();
176 if (m_sourceFilename.isEmpty() && childItems.size() != 1) {
177 qWarning() << Q_FUNC_INFO <<
"Either 'source' property must be set or add exactly one child"
178 <<
"; source=" << m_sourceFilename <<
"; num children=" << childItems.size();
182 m_dockWidget =
new DockWidgetQuick(m_uniqueName, {}, {}, qmlEngine(
this));
184 connect(m_dockWidget, &DockWidgetQuick::titleChanged,
this,
185 &DockWidgetInstantiator::titleChanged);
186 connect(m_dockWidget, &DockWidgetQuick::actualTitleBarChanged,
this,
187 &DockWidgetInstantiator::actualTitleBarChanged);
188 connect(m_dockWidget, &DockWidgetQuick::optionsChanged,
this,
189 &DockWidgetInstantiator::optionsChanged);
190 connect(m_dockWidget, &DockWidgetQuick::shown,
this, &DockWidgetInstantiator::shown);
191 connect(m_dockWidget, &DockWidgetQuick::hidden,
this, &DockWidgetInstantiator::hidden);
192 connect(m_dockWidget, &DockWidgetQuick::iconChanged,
this,
193 &DockWidgetInstantiator::iconChanged);
194 connect(m_dockWidget, &DockWidgetQuick::widgetChanged,
this,
195 &DockWidgetInstantiator::widgetChanged);
196 connect(m_dockWidget, &DockWidgetQuick::isFocusedChanged,
this,
197 &DockWidgetInstantiator::isFocusedChanged);
198 connect(m_dockWidget, &DockWidgetQuick::isFocusedChanged,
this,
199 &DockWidgetInstantiator::isFocusedChanged);
200 connect(m_dockWidget, &DockWidgetQuick::isOverlayedChanged,
this,
201 &DockWidgetInstantiator::isOverlayedChanged);
202 connect(m_dockWidget, &DockWidgetQuick::isFloatingChanged,
this,
203 &DockWidgetInstantiator::isFloatingChanged);
204 connect(m_dockWidget, &DockWidgetQuick::removedFromSideBar,
this,
205 &DockWidgetInstantiator::removedFromSideBar);
206 connect(m_dockWidget, &DockWidgetQuick::windowActiveAboutToChange,
this,
207 &DockWidgetInstantiator::windowActiveAboutToChange);
210 if (m_sourceFilename.isEmpty()) {
211 m_dockWidget->setWidget(childItems.constFirst());
213 m_dockWidget->setWidget(m_sourceFilename);
216 if (!m_title.isEmpty())
217 m_dockWidget->setTitle(m_title);
219 if (m_isFloating.has_value())
220 m_dockWidget->setFloating(m_isFloating.value());
222 Q_EMIT dockWidgetChanged();