Skip to content

Commit

Permalink
uic: Write fully qualified enum values for QMainWindow enumerations
Browse files Browse the repository at this point in the history
Task-number: PYSIDE-2492
Task-number: PYSIDE-1735
Task-number: QTBUG-118473
Change-Id: Ief50914bae3cc8e55f61113e8c8b6d6d24fe2c0f
Reviewed-by: Jarek Kobus <[email protected]>
  • Loading branch information
FriedemannKleint committed Nov 15, 2023
1 parent 39ce0e3 commit effe9bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/tools/uic/cpp/cppwriteinitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ namespace {
return expandEnum(value, "QSizePolicy::Policy"_L1);
}

inline QString expandToolBarArea(const QString &value)
{
return expandEnum(value, "Qt::ToolBarArea"_L1);
}

inline QString expandDockWidgetArea(const QString &value)
{
return expandEnum(value, "Qt::DockWidgetArea"_L1);
}

// figure out the toolbar area of a DOM attrib list.
// By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value.
QString toolBarAreaStringFromDOMAttributes(const CPP::WriteInitialization::DomPropertyMap &attributes) {
Expand All @@ -59,9 +69,7 @@ namespace {
default:
break;
}
if (!result.startsWith("Qt::"_L1))
result.prepend("Qt::"_L1);
return result + ", "_L1;
return expandToolBarArea(result) + ", "_L1;
}

// Write a statement to create a spacer item.
Expand Down Expand Up @@ -709,8 +717,8 @@ void WriteInitialization::acceptWidget(DomWidget *node)
} else if (cwi->extends(className, "QDockWidget")) {
m_output << m_indent << parentWidget << language::derefPointer << "addDockWidget(";
if (DomProperty *pstyle = attributes.value("dockWidgetArea"_L1)) {
m_output << "Qt" << language::qualifier
<< language::dockWidgetArea(pstyle->elementNumber()) << ", ";
QString a = expandDockWidgetArea(language::dockWidgetArea(pstyle->elementNumber()));
m_output << language::enumValue(a) << ", ";
}
m_output << varName << ")" << language::eol;
} else if (m_uic->customWidgetsInfo()->extends(className, "QStatusBar")) {
Expand Down
4 changes: 2 additions & 2 deletions tests/auto/tools/uic/baseline/trpreviewtool.ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Ui_TrPreviewToolClass
mainToolBar = new QToolBar(TrPreviewToolClass);
mainToolBar->setObjectName("mainToolBar");
mainToolBar->setOrientation(Qt::Horizontal);
TrPreviewToolClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
TrPreviewToolClass->addToolBar(Qt::ToolBarArea::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(TrPreviewToolClass);
statusBar->setObjectName("statusBar");
TrPreviewToolClass->setStatusBar(statusBar);
Expand All @@ -115,7 +115,7 @@ class Ui_TrPreviewToolClass
vboxLayout->addWidget(viewForms);

dwForms->setWidget(dockWidgetContents);
TrPreviewToolClass->addDockWidget(Qt::LeftDockWidgetArea, dwForms);
TrPreviewToolClass->addDockWidget(Qt::DockWidgetArea::LeftDockWidgetArea, dwForms);

menuBar->addAction(menuFile->menuAction());
menuBar->addAction(menuView->menuAction());
Expand Down

0 comments on commit effe9bd

Please sign in to comment.