7#include <QtDesigner/qextensionmanager.h>
8#include <QtDesigner/abstractformeditor.h>
10#include <QtWidgets/qmdiarea.h>
11#include <QtWidgets/qmdisubwindow.h>
12#include <QtWidgets/qapplication.h>
13#include <QtCore/qdebug.h>
14#include <QtCore/qhash.h>
18using namespace Qt::StringLiterals;
30 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).size();
37 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).at(index)->widget();
42 if (QMdiSubWindow *sub = m_mdiArea->activeSubWindow())
43 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).indexOf(sub);
50 qDebug() <<
"** WARNING Attempt to QMdiAreaContainer::setCurrentIndex(-1)";
53 QMdiSubWindow *frame = m_mdiArea->subWindowList(QMdiArea::CreationOrder).at(index);
54 m_mdiArea->setActiveSubWindow(frame);
59 QMdiSubWindow *frame = m_mdiArea->addSubWindow(widget, Qt::Window);
61 m_mdiArea->cascadeSubWindows();
62 positionNewMdiChild(m_mdiArea, frame);
69 enum { MinSize = 20 };
70 const QPoint pos = mdiChild->pos();
71 const QSize areaSize = area->size();
72 switch (QApplication::layoutDirection()) {
73 case Qt::LayoutDirectionAuto:
74 case Qt::LeftToRight: {
75 const QSize fullSize = QSize(areaSize.width() - pos.x(), areaSize.height() - pos.y());
76 if (fullSize.width() > MinSize && fullSize.height() > MinSize)
77 mdiChild->resize(fullSize);
80 case Qt::RightToLeft: {
81 const QSize fullSize = QSize(pos.x() + mdiChild->width(), areaSize.height() - pos.y());
82 if (fullSize.width() > MinSize && fullSize.height() > MinSize) {
83 mdiChild->move(0, pos.y());
84 mdiChild->resize(fullSize);
98 auto subWins = m_mdiArea->subWindowList(QMdiArea::CreationOrder);
99 if (index >= 0 && index < subWins.size()) {
100 QMdiSubWindow *f = subWins.at(index);
101 m_mdiArea->removeSubWindow(f->widget());
114 QDesignerPropertySheet(mdiArea, parent),
115 m_windowTitleProperty(u"windowTitle"_s)
117 createFakeProperty(subWindowNameC, QString());
118 createFakeProperty(subWindowTitleC, QString());
123 static const QHash<QString, MdiAreaProperty> mdiAreaPropertyHash = {
124 {subWindowNameC, MdiAreaSubWindowName},
125 {subWindowTitleC, MdiAreaSubWindowTitle}
127 return mdiAreaPropertyHash.value(name, MdiAreaNone);
132 switch (mdiAreaProperty(propertyName(index))) {
133 case MdiAreaSubWindowName:
134 if (QWidget *w = currentWindow())
135 w->setObjectName(value.toString());
137 case MdiAreaSubWindowTitle:
138 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
139 const int index = cws->indexOf(m_windowTitleProperty);
140 cws->setProperty(index, value);
141 cws->setChanged(index,
true);
145 QDesignerPropertySheet::setProperty(index, value);
153 switch (mdiAreaProperty(propertyName(index))) {
154 case MdiAreaSubWindowName:
155 setProperty(index, QVariant(QString()));
156 setChanged(index,
false);
158 case MdiAreaSubWindowTitle:
159 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
160 const int index = cws->indexOf(m_windowTitleProperty);
161 rc = cws->reset(index);
165 rc = QDesignerPropertySheet::reset(index);
173 switch (mdiAreaProperty(propertyName(index))) {
174 case MdiAreaSubWindowName:
175 if (QWidget *w = currentWindow())
176 return w->objectName();
177 return QVariant(QString());
178 case MdiAreaSubWindowTitle:
179 if (QWidget *w = currentWindow())
180 return w->windowTitle();
181 return QVariant(QString());
185 return QDesignerPropertySheet::property(index);
190 switch (mdiAreaProperty(propertyName(index))) {
191 case MdiAreaSubWindowName:
192 case MdiAreaSubWindowTitle:
193 return currentWindow() !=
nullptr;
197 return QDesignerPropertySheet::isEnabled(index);
203 switch (mdiAreaProperty(propertyName(index))) {
204 case MdiAreaSubWindowName:
205 rc = currentWindow() !=
nullptr;
207 case MdiAreaSubWindowTitle:
208 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
209 const int index = cws->indexOf(m_windowTitleProperty);
210 rc = cws->isChanged(index);
214 rc = QDesignerPropertySheet::isChanged(index);
222 if (
const QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), object())) {
223 const int ci = c->currentIndex();
226 return c->widget(ci);
233 QWidget *cw = currentWindow();
236 return qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), cw);
241 return mdiAreaProperty(propertyName) == MdiAreaNone;
int count() const override
void remove(int index) override
int currentIndex() const override
QWidget * widget(int index) const override
void setCurrentIndex(int index) override
bool isChanged(int index) const override
void setProperty(int index, const QVariant &value) override
static bool checkProperty(const QString &propertyName)
bool isEnabled(int index) const override
bool reset(int index) override
QVariant property(int index) const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
static constexpr auto subWindowTitleC
static constexpr auto subWindowNameC