6#include <QtDesigner/qextensionmanager.h>
7#include <QtDesigner/abstractformeditor.h>
9#include <QtWidgets/qmdiarea.h>
10#include <QtWidgets/qmdisubwindow.h>
11#include <QtWidgets/qapplication.h>
12#include <QtCore/qdebug.h>
13#include <QtCore/qhash.h>
17using namespace Qt::StringLiterals;
29 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).size();
36 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).at(index)->widget();
41 if (QMdiSubWindow *sub = m_mdiArea->activeSubWindow())
42 return m_mdiArea->subWindowList(QMdiArea::CreationOrder).indexOf(sub);
49 qDebug() <<
"** WARNING Attempt to QMdiAreaContainer::setCurrentIndex(-1)";
52 QMdiSubWindow *frame = m_mdiArea->subWindowList(QMdiArea::CreationOrder).at(index);
53 m_mdiArea->setActiveSubWindow(frame);
58 QMdiSubWindow *frame = m_mdiArea->addSubWindow(widget, Qt::Window);
60 m_mdiArea->cascadeSubWindows();
61 positionNewMdiChild(m_mdiArea, frame);
68 enum { MinSize = 20 };
69 const QPoint pos = mdiChild->pos();
70 const QSize areaSize = area->size();
71 switch (QApplication::layoutDirection()) {
72 case Qt::LayoutDirectionAuto:
73 case Qt::LeftToRight: {
74 const QSize fullSize = QSize(areaSize.width() - pos.x(), areaSize.height() - pos.y());
75 if (fullSize.width() > MinSize && fullSize.height() > MinSize)
76 mdiChild->resize(fullSize);
79 case Qt::RightToLeft: {
80 const QSize fullSize = QSize(pos.x() + mdiChild->width(), areaSize.height() - pos.y());
81 if (fullSize.width() > MinSize && fullSize.height() > MinSize) {
82 mdiChild->move(0, pos.y());
83 mdiChild->resize(fullSize);
97 auto subWins = m_mdiArea->subWindowList(QMdiArea::CreationOrder);
98 if (index >= 0 && index < subWins.size()) {
99 QMdiSubWindow *f = subWins.at(index);
100 m_mdiArea->removeSubWindow(f->widget());
113 QDesignerPropertySheet(mdiArea, parent),
114 m_windowTitleProperty(u"windowTitle"_s)
116 createFakeProperty(subWindowNameC, QString());
117 createFakeProperty(subWindowTitleC, QString());
122 static const QHash<QString, MdiAreaProperty> mdiAreaPropertyHash = {
123 {subWindowNameC, MdiAreaSubWindowName},
124 {subWindowTitleC, MdiAreaSubWindowTitle}
126 return mdiAreaPropertyHash.value(name, MdiAreaNone);
131 switch (mdiAreaProperty(propertyName(index))) {
132 case MdiAreaSubWindowName:
133 if (QWidget *w = currentWindow())
134 w->setObjectName(value.toString());
136 case MdiAreaSubWindowTitle:
137 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
138 const int index = cws->indexOf(m_windowTitleProperty);
139 cws->setProperty(index, value);
140 cws->setChanged(index,
true);
144 QDesignerPropertySheet::setProperty(index, value);
152 switch (mdiAreaProperty(propertyName(index))) {
153 case MdiAreaSubWindowName:
154 setProperty(index, QVariant(QString()));
155 setChanged(index,
false);
157 case MdiAreaSubWindowTitle:
158 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
159 const int index = cws->indexOf(m_windowTitleProperty);
160 rc = cws->reset(index);
164 rc = QDesignerPropertySheet::reset(index);
172 switch (mdiAreaProperty(propertyName(index))) {
173 case MdiAreaSubWindowName:
174 if (QWidget *w = currentWindow())
175 return w->objectName();
176 return QVariant(QString());
177 case MdiAreaSubWindowTitle:
178 if (QWidget *w = currentWindow())
179 return w->windowTitle();
180 return QVariant(QString());
184 return QDesignerPropertySheet::property(index);
189 switch (mdiAreaProperty(propertyName(index))) {
190 case MdiAreaSubWindowName:
191 case MdiAreaSubWindowTitle:
192 return currentWindow() !=
nullptr;
196 return QDesignerPropertySheet::isEnabled(index);
202 switch (mdiAreaProperty(propertyName(index))) {
203 case MdiAreaSubWindowName:
204 rc = currentWindow() !=
nullptr;
206 case MdiAreaSubWindowTitle:
207 if (QDesignerPropertySheetExtension *cws = currentWindowSheet()) {
208 const int index = cws->indexOf(m_windowTitleProperty);
209 rc = cws->isChanged(index);
213 rc = QDesignerPropertySheet::isChanged(index);
221 if (
const QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), object())) {
222 const int ci = c->currentIndex();
225 return c->widget(ci);
232 QWidget *cw = currentWindow();
235 return qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), cw);
240 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