12 #include "DockWidgetInstantiator_p.h"
14 #include "../DockRegistry_p.h"
18 QString DockWidgetInstantiator::uniqueName()
const
23 void DockWidgetInstantiator::setUniqueName(
const QString &name)
26 Q_EMIT uniqueNameChanged();
29 QString DockWidgetInstantiator::source()
const
31 return m_sourceFilename;
34 void DockWidgetInstantiator::setSource(
const QString &source)
36 m_sourceFilename = source;
37 Q_EMIT sourceChanged();
45 TitleBar *DockWidgetInstantiator::actualTitleBar()
const
50 QString DockWidgetInstantiator::title()
const
52 return m_dockWidget ? m_dockWidget->title() :
QString();
55 void DockWidgetInstantiator::setTitle(
const QString &title)
58 m_dockWidget->setTitle(title);
62 bool DockWidgetInstantiator::isFocused()
const
64 return m_dockWidget && m_dockWidget->isFocused();
67 bool DockWidgetInstantiator::isFloating()
const
69 return m_dockWidget && m_dockWidget->isFloating();
72 void DockWidgetInstantiator::setFloating(
bool is)
75 m_dockWidget->setFloating(is);
79 void DockWidgetInstantiator::addDockWidgetAsTab(DockWidgetInstantiator *other,
83 m_dockWidget->addDockWidgetAsTab(other ? other->dockWidget() :
nullptr, option);
86 void DockWidgetInstantiator::addDockWidgetAsTab(
DockWidgetBase *other,
90 m_dockWidget->addDockWidgetAsTab(other, option);
93 void DockWidgetInstantiator::addDockWidgetToContainingWindow(
DockWidgetBase *other,
100 m_dockWidget->addDockWidgetToContainingWindow(other, location, relativeTo,
104 void 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));
116 void DockWidgetInstantiator::setAsCurrentTab()
119 m_dockWidget->setAsCurrentTab();
122 void DockWidgetInstantiator::forceClose()
125 m_dockWidget->forceClose();
128 Q_INVOKABLE
bool DockWidgetInstantiator::close()
131 return m_dockWidget->close();
136 void DockWidgetInstantiator::show()
139 m_dockWidget->show();
142 void DockWidgetInstantiator::raise()
145 m_dockWidget->raise();
148 void DockWidgetInstantiator::moveToSideBar()
151 m_dockWidget->moveToSideBar();
154 void DockWidgetInstantiator::classBegin()
159 void 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));
185 &DockWidgetInstantiator::titleChanged);
187 &DockWidgetInstantiator::actualTitleBarChanged);
189 &DockWidgetInstantiator::optionsChanged);
193 &DockWidgetInstantiator::iconChanged);
195 &DockWidgetInstantiator::widgetChanged);
197 &DockWidgetInstantiator::isFocusedChanged);
199 &DockWidgetInstantiator::isFocusedChanged);
201 &DockWidgetInstantiator::isOverlayedChanged);
203 &DockWidgetInstantiator::isFloatingChanged);
205 &DockWidgetInstantiator::removedFromSideBar);
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();