diff options
Diffstat (limited to 'src/designer/src')
86 files changed, 1077 insertions, 702 deletions
diff --git a/src/designer/src/components/buddyeditor/buddyeditor.cpp b/src/designer/src/components/buddyeditor/buddyeditor.cpp index 7593326db..93e143c2a 100644 --- a/src/designer/src/components/buddyeditor/buddyeditor.cpp +++ b/src/designer/src/components/buddyeditor/buddyeditor.cpp @@ -329,7 +329,7 @@ void BuddyEditor::autoBuddy() { // Any labels? LabelList labelList = background()->findChildren<QLabel*>(); - if (labelList.empty()) + if (labelList.isEmpty()) return; // Find already used buddies QWidgetList usedBuddies; @@ -355,7 +355,7 @@ void BuddyEditor::autoBuddy() } } // Add the list in one go. - if (labelList.empty()) + if (labelList.isEmpty()) return; const int count = labelList.size(); Q_ASSERT(count == buddies.size()); diff --git a/src/designer/src/components/formeditor/embeddedoptionspage.cpp b/src/designer/src/components/formeditor/embeddedoptionspage.cpp index 96a6c7c4a..91474c6aa 100644 --- a/src/designer/src/components/formeditor/embeddedoptionspage.cpp +++ b/src/designer/src/components/formeditor/embeddedoptionspage.cpp @@ -265,7 +265,7 @@ void EmbeddedOptionsControlPrivate::sortAndPopulateProfileCombo() // Clear items until only "None" is left for (int i = m_profileCombo->count() - 1; i > 0; i--) m_profileCombo->removeItem(i); - if (!m_sortedProfiles.empty()) { + if (!m_sortedProfiles.isEmpty()) { std::sort(m_sortedProfiles.begin(), m_sortedProfiles.end(), deviceProfileLessThan); m_profileCombo->addItems(existingProfileNames()); } diff --git a/src/designer/src/components/formeditor/formeditor.cpp b/src/designer/src/components/formeditor/formeditor.cpp index 335241e5f..05e7fc4ee 100644 --- a/src/designer/src/components/formeditor/formeditor.cpp +++ b/src/designer/src/components/formeditor/formeditor.cpp @@ -44,6 +44,7 @@ #include "spacer_propertysheet.h" #include "line_propertysheet.h" #include "layout_propertysheet.h" +#include "qdesigner_dockwidget_p.h" #include "qdesigner_stackedbox_p.h" #include "qdesigner_toolbox_p.h" #include "qdesigner_tabwidget_p.h" @@ -111,6 +112,7 @@ FormEditor::FormEditor(QObject *parent) QMenuActionProviderFactory::registerExtension(mgr, actionProviderExtensionId); QDesignerDefaultPropertySheetFactory::registerExtension(mgr); + QDockWidgetPropertySheetFactory::registerExtension(mgr); QLayoutWidgetPropertySheetFactory::registerExtension(mgr); SpacerPropertySheetFactory::registerExtension(mgr); LinePropertySheetFactory::registerExtension(mgr); diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index 464d7f618..91896f06a 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -178,7 +178,7 @@ FormWindow::Selection::~Selection() void FormWindow::Selection::clear() { - if (!m_usedSelections.empty()) { + if (!m_usedSelections.isEmpty()) { for (auto it = m_usedSelections.begin(), mend = m_usedSelections.end(); it != mend; ++it) it.value()->setWidget(nullptr); m_usedSelections.clear(); @@ -684,6 +684,7 @@ bool FormWindow::handleMouseMoveEvent(QWidget *, QWidget *, QMouseEvent *e) const bool blocked = blockSelectionChanged(true); QWidgetList sel = selectedWidgets(); + const QWidgetList originalSelection = sel; simplifySelection(&sel); QSet<QWidget*> widget_set; @@ -733,9 +734,14 @@ bool FormWindow::handleMouseMoveEvent(QWidget *, QWidget *, QMouseEvent *e) } } + // In case when we have reduced the selection (by calling simplifySelection() + // beforehand) we still need to hide selection handles for children widgets + for (auto *widget : originalSelection) + m_selection->hide(widget); + blockSelectionChanged(blocked); - if (!sel.empty()) // reshow selection? + if (!sel.isEmpty()) // reshow selection? if (QDesignerMimeData::execDrag(item_list, core()->topLevel()) == Qt::IgnoreAction && dropType == QDesignerDnDItemInterface::MoveDrop) for (QWidget *widget : qAsConst(sel)) m_selection->show(widget); @@ -940,7 +946,7 @@ bool FormWindow::isMainContainer(const QWidget *w) const void FormWindow::updateChildSelections(QWidget *w) { const QWidgetList l = w->findChildren<QWidget*>(); - if (!l.empty()) { + if (!l.isEmpty()) { const QWidgetList::const_iterator lcend = l.constEnd(); for (QWidgetList::const_iterator it = l.constBegin(); it != lcend; ++it) { QWidget *w = *it; @@ -1150,19 +1156,19 @@ bool FormWindow::unify(QObject *w, QString &s, bool changeIt) const QDesignerMetaDataBaseInterface *metaDataBase = core()->metaDataBase(); const QWidgetList widgetChildren = main->findChildren<QWidget*>(); - if (!widgetChildren.empty()) + if (!widgetChildren.isEmpty()) insertNames(metaDataBase, widgetChildren.constBegin(), widgetChildren.constEnd(), w, existingNames); const QList<QLayout *> layoutChildren = main->findChildren<QLayout*>(); - if (!layoutChildren.empty()) + if (!layoutChildren.isEmpty()) insertNames(metaDataBase, layoutChildren.constBegin(), layoutChildren.constEnd(), w, existingNames); const QList<QAction *> actionChildren = main->findChildren<QAction*>(); - if (!actionChildren.empty()) + if (!actionChildren.isEmpty()) insertNames(metaDataBase, actionChildren.constBegin(), actionChildren.constEnd(), w, existingNames); const QList<QButtonGroup *> buttonGroupChildren = main->findChildren<QButtonGroup*>(); - if (!buttonGroupChildren.empty()) + if (!buttonGroupChildren.isEmpty()) insertNames(metaDataBase, buttonGroupChildren.constBegin(), buttonGroupChildren.constEnd(), w, existingNames); const StringSet::const_iterator enEnd = existingNames.constEnd(); @@ -1695,7 +1701,7 @@ QWidget *FormWindow::containerForPaste() const // Try to find a close parent, for example a non-laid-out // QFrame/QGroupBox when a widget within it is selected. QWidgetList selection = selectedWidgets(); - if (selection.empty()) + if (selection.isEmpty()) break; simplifySelection(&selection); @@ -2252,7 +2258,7 @@ QAction *FormWindow::createSelectAncestorSubMenu(QWidget *w) for (QWidget *p = w->parentWidget(); p && p != mc; p = p->parentWidget()) if (isManaged(p) && !isWidgetSelected(p)) parents.push_back(p); - if (parents.empty()) + if (parents.isEmpty()) return nullptr; // Create a submenu listing the managed, unselected parents QMenu *menu = new QMenu; diff --git a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp index 18126c145..4c93c7674 100644 --- a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp +++ b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp @@ -165,7 +165,7 @@ void FormWindowWidgetStack::addTool(QDesignerFormWindowToolInterface *tool) m_layout->addWidget(w); } else { // The form editor might not have a tool initially, use dummy. Assert on anything else - Q_ASSERT(m_tools.empty()); + Q_ASSERT(m_tools.isEmpty()); m_layout->addWidget(m_formContainer); } diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index d1edb231c..692b20c54 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -71,7 +71,6 @@ #endif #include <QtWidgets/qmdiarea.h> #include <QtWidgets/qmdisubwindow.h> -#include <QtWidgets/qdesktopwidget.h> #include <QtWidgets/qmessagebox.h> #include <QtCore/qdebug.h> @@ -567,7 +566,7 @@ static inline QWidget *findLayoutContainer(const FormWindow *fw) { QWidgetList l(fw->selectedWidgets()); fw->simplifySelection(&l); - return l.empty() ? fw->mainContainer() : l.front(); + return l.isEmpty() ? fw->mainContainer() : l.constFirst(); } void FormWindowManager::createLayout() @@ -617,7 +616,7 @@ void FormWindowManager::slotActionSimplifyLayoutActivated() if (selectedWidgets.size() != 1) return; SimplifyLayoutCommand *cmd = new SimplifyLayoutCommand(m_activeFormWindow); - if (cmd->init(selectedWidgets.front())) { + if (cmd->init(selectedWidgets.constFirst())) { m_activeFormWindow->commandHistory()->push(cmd); } else { delete cmd; @@ -754,7 +753,7 @@ QSet<QWidget *> FormWindowManager::getUnsortedLayoutsToBeBroken(bool firstOnly) for (QWidget *selectedWidget : qAsConst(selection)) { // find all layouts const QWidgetList &list = layoutsToBeBroken(selectedWidget); - if (!list.empty()) { + if (!list.isEmpty()) { for (QWidget *widget : list) layouts.insert(widget); if (firstOnly) diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index 4ccd7210b..de03c6792 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -244,7 +244,7 @@ void FormWindowSettings::setData(const FormWindowData &data) m_ui->authorLineEdit->setText(data.author); - if (data.includeHints.empty()) { + if (data.includeHints.isEmpty()) { m_ui->includeHintsTextEdit->clear(); } else { m_ui->includeHintsTextEdit->setText(data.includeHints.join(QLatin1Char('\n'))); diff --git a/src/designer/src/components/formeditor/layout_propertysheet.cpp b/src/designer/src/components/formeditor/layout_propertysheet.cpp index e0e456d32..0bb3ecb2f 100644 --- a/src/designer/src/components/formeditor/layout_propertysheet.cpp +++ b/src/designer/src/components/formeditor/layout_propertysheet.cpp @@ -103,7 +103,7 @@ static bool isIntegerList(const QString &s) static LayoutPropertyType layoutPropertyType(const QString &name) { static QHash<QString, LayoutPropertyType> namePropertyMap; - if (namePropertyMap.empty()) { + if (namePropertyMap.isEmpty()) { namePropertyMap.insert(QLatin1String(leftMargin), LayoutPropertyLeftMargin); namePropertyMap.insert(QLatin1String(topMargin), LayoutPropertyTopMargin); namePropertyMap.insert(QLatin1String(rightMargin), LayoutPropertyRightMargin); diff --git a/src/designer/src/components/formeditor/previewactiongroup.cpp b/src/designer/src/components/formeditor/previewactiongroup.cpp index 89c3a0ae7..e0f3b7db1 100644 --- a/src/designer/src/components/formeditor/previewactiongroup.cpp +++ b/src/designer/src/components/formeditor/previewactiongroup.cpp @@ -98,7 +98,7 @@ void PreviewActionGroup::updateDeviceProfiles() const DeviceProfileList profiles = settings.deviceProfiles(); const ActionList al = actions(); // Separator? - const bool hasProfiles = !profiles.empty(); + const bool hasProfiles = !profiles.isEmpty(); al.at(MaxDeviceActions)->setVisible(hasProfiles); int index = 0; if (hasProfiles) { diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index dd1144d7c..ff4a42744 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -516,14 +516,14 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) ui->setAttributeConnectslotsbyname(false); const QVariantMap designerFormData = m_formWindow->formData(); - if (!designerFormData.empty()) { + if (!designerFormData.isEmpty()) { DomPropertyList domPropertyList; const QVariantMap::const_iterator cend = designerFormData.constEnd(); for (QVariantMap::const_iterator it = designerFormData.constBegin(); it != cend; ++it) { if (DomProperty *prop = variantToDomProperty(this, widget->metaObject(), it.key(), it.value())) domPropertyList += prop; } - if (!domPropertyList.empty()) { + if (!domPropertyList.isEmpty()) { DomDesignerData* domDesignerFormData = new DomDesignerData; domDesignerFormData->setElementProperty(domPropertyList); ui->setElementDesignerdata(domDesignerFormData); @@ -590,7 +590,7 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) const MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(m_formWindow->mainContainer()); const QStringList fakeSlots = item->fakeSlots(); const QStringList fakeSignals =item->fakeSignals(); - if (!fakeSlots.empty() || !fakeSignals.empty()) { + if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) { DomSlots *domSlots = new DomSlots(); domSlots->setElementSlot(fakeSlots); domSlots->setElementSignal(fakeSignals); @@ -708,7 +708,7 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) // Register all button groups the form builder adds as children of the main container for them to be found // in the signal slot editor const QObjectList mchildren = mainWidget->children(); - if (!mchildren.empty()) { + if (!mchildren.isEmpty()) { QDesignerMetaDataBaseInterface *mdb = core()->metaDataBase(); const QObjectList::const_iterator cend = mchildren.constEnd(); for (QObjectList::const_iterator it = mchildren.constBegin(); it != cend; ++it) @@ -740,7 +740,7 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) // Initialize the mainwindow geometry. Has it been explicitly specified? bool hasExplicitGeometry = false; const auto &properties = ui->elementWidget()->elementProperty(); - if (!properties.empty()) { + if (!properties.isEmpty()) { const QString geometry = QStringLiteral("geometry"); for (const DomProperty *p : properties) { if (p->attributeName() == geometry) { @@ -941,7 +941,7 @@ static bool readDomEnumerationValue(const DomProperty *p, void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - if (properties.empty()) + if (properties.isEmpty()) return; QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o); @@ -1692,7 +1692,7 @@ DomUI *QDesignerResource::copy(const FormBuilderClipboard &selection) ui_widget->setAttributeName(QLatin1String(clipboardObjectName)); bool hasItems = false; // Widgets - if (!selection.m_widgets.empty()) { + if (!selection.m_widgets.isEmpty()) { QVector<DomWidget *> ui_widget_list; const int size = selection.m_widgets.size(); for (int i=0; i< size; ++i) { @@ -1703,19 +1703,19 @@ DomUI *QDesignerResource::copy(const FormBuilderClipboard &selection) if (ui_child) ui_widget_list.append(ui_child); } - if (!ui_widget_list.empty()) { + if (!ui_widget_list.isEmpty()) { ui_widget->setElementWidget(ui_widget_list); hasItems = true; } } // actions - if (!selection.m_actions.empty()) { + if (!selection.m_actions.isEmpty()) { QVector<DomAction *> domActions; for (QAction* action : qAsConst(selection.m_actions)) { if (DomAction *domAction = createDom(action)) domActions += domAction; } - if (!domActions.empty()) { + if (!domActions.isEmpty()) { ui_widget-> setElementAction(domActions); hasItems = true; } @@ -1750,7 +1750,7 @@ FormBuilderClipboard QDesignerResource::paste(DomUI *ui, QWidget *widgetParent, const DomWidget *topLevel = ui->elementWidget(); initialize(ui); const auto &domWidgets = topLevel->elementWidget(); - if (!domWidgets.empty()) { + if (!domWidgets.isEmpty()) { const QPoint offset = m_formWindow->grid(); for (DomWidget* domWidget : domWidgets) { if (QWidget *w = create(domWidget, widgetParent)) { @@ -1857,7 +1857,7 @@ DomCustomWidgets *QDesignerResource::saveCustomWidgets() WidgetDataBaseItem *internalItem = static_cast<WidgetDataBaseItem *>(item); const QStringList fakeSlots = internalItem->fakeSlots(); const QStringList fakeSignals = internalItem->fakeSignals(); - if (!fakeSlots.empty() || !fakeSignals.empty()) { + if (!fakeSlots.isEmpty() || !fakeSignals.isEmpty()) { DomSlots *domSlots = new DomSlots(); domSlots->setElementSlot(fakeSlots); domSlots->setElementSignal(fakeSignals); @@ -2212,7 +2212,7 @@ QActionGroup *QDesignerResource::createActionGroup(QObject *parent, const QStrin void QDesignerResource::applyAttributesToPropertySheet(const DomWidget *ui_widget, QWidget *widget) { const DomPropertyList attributes = ui_widget->elementAttribute(); - if (attributes.empty()) + if (attributes.isEmpty()) return; QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), widget); const DomPropertyList::const_iterator acend = attributes.constEnd(); diff --git a/src/designer/src/components/formeditor/qmdiarea_container.cpp b/src/designer/src/components/formeditor/qmdiarea_container.cpp index e33c99367..e1930501f 100644 --- a/src/designer/src/components/formeditor/qmdiarea_container.cpp +++ b/src/designer/src/components/formeditor/qmdiarea_container.cpp @@ -144,7 +144,7 @@ QMdiAreaPropertySheet::MdiAreaProperty QMdiAreaPropertySheet::mdiAreaProperty(co { using MdiAreaPropertyHash = QHash<QString, MdiAreaProperty>; static MdiAreaPropertyHash mdiAreaPropertyHash; - if (mdiAreaPropertyHash.empty()) { + if (mdiAreaPropertyHash.isEmpty()) { mdiAreaPropertyHash.insert(QLatin1String(subWindowNameC), MdiAreaSubWindowName); mdiAreaPropertyHash.insert(QLatin1String(subWindowTitleC), MdiAreaSubWindowTitle); } diff --git a/src/designer/src/components/formeditor/qwizard_container.cpp b/src/designer/src/components/formeditor/qwizard_container.cpp index dbc7084eb..5853fbf98 100644 --- a/src/designer/src/components/formeditor/qwizard_container.cpp +++ b/src/designer/src/components/formeditor/qwizard_container.cpp @@ -65,15 +65,12 @@ QWidget *QWizardContainer::widget(int index) const int QWizardContainer::currentIndex() const { - const IdList idList = m_wizard->pageIds(); - const int currentId = m_wizard->currentId(); - const int rc = idList.empty() ? -1 : idList.indexOf(currentId); - return rc; + return m_wizard->pageIds().indexOf(m_wizard->currentId()); } void QWizardContainer::setCurrentIndex(int index) { - if (index < 0 || m_wizard->pageIds().empty()) + if (index < 0 || m_wizard->pageIds().isEmpty()) return; int currentIdx = currentIndex(); diff --git a/src/designer/src/components/formeditor/templateoptionspage.cpp b/src/designer/src/components/formeditor/templateoptionspage.cpp index b1c0dc2d4..e50260406 100644 --- a/src/designer/src/components/formeditor/templateoptionspage.cpp +++ b/src/designer/src/components/formeditor/templateoptionspage.cpp @@ -79,7 +79,7 @@ void TemplateOptionsWidget::setTemplatePaths(const QStringList &l) { // add paths and select 0 m_ui->m_templatePathListWidget->clear(); - if (l.empty()) { + if (l.isEmpty()) { // disable button templatePathSelectionChanged(); } else { @@ -98,7 +98,7 @@ void TemplateOptionsWidget::addTemplatePath() const QList<QListWidgetItem *> existing = m_ui->m_templatePathListWidget->findItems(templatePath, Qt::MatchExactly); - if (!existing.empty()) + if (!existing.isEmpty()) return; QListWidgetItem *newItem = new QListWidgetItem(templatePath); @@ -110,15 +110,15 @@ void TemplateOptionsWidget::removeTemplatePath() { const QList<QListWidgetItem *> selectedPaths = m_ui->m_templatePathListWidget->selectedItems(); - if (selectedPaths.empty()) + if (selectedPaths.isEmpty()) return; - delete selectedPaths.front(); + delete selectedPaths.constFirst(); } void TemplateOptionsWidget::templatePathSelectionChanged() { const QList<QListWidgetItem *> selectedPaths = m_ui->m_templatePathListWidget->selectedItems(); - m_ui->m_removeTemplatePathButton->setEnabled(!selectedPaths.empty()); + m_ui->m_removeTemplatePathButton->setEnabled(!selectedPaths.isEmpty()); } QString TemplateOptionsWidget::chooseTemplatePath(QDesignerFormEditorInterface *core, QWidget *parent) diff --git a/src/designer/src/components/objectinspector/objectinspector.cpp b/src/designer/src/components/objectinspector/objectinspector.cpp index 4267fea22..248041811 100644 --- a/src/designer/src/components/objectinspector/objectinspector.cpp +++ b/src/designer/src/components/objectinspector/objectinspector.cpp @@ -424,7 +424,7 @@ bool ObjectInspector::ObjectInspectorPrivate::selectObject(QObject *o) using ModelIndexSet = QSet<QModelIndex>; const QModelIndexList objectIndexes = indexesOf(o); - if (objectIndexes.empty()) + if (objectIndexes.isEmpty()) return false; QItemSelectionModel *selectionModel = m_treeView->selectionModel(); @@ -432,8 +432,10 @@ bool ObjectInspector::ObjectInspectorPrivate::selectObject(QObject *o) const ModelIndexSet currentSelectedItems(currentSelectedItemList.cbegin(), currentSelectedItemList.cend()); // Change in selection? - if (!currentSelectedItems.empty() && currentSelectedItems == ModelIndexSet(objectIndexes.cbegin(), objectIndexes.cend())) + if (!currentSelectedItems.isEmpty() + && currentSelectedItems == ModelIndexSet(objectIndexes.cbegin(), objectIndexes.cend())) { return true; + } // do select and update selectIndexRange(objectIndexes, MakeCurrent); @@ -442,7 +444,7 @@ bool ObjectInspector::ObjectInspectorPrivate::selectObject(QObject *o) void ObjectInspector::ObjectInspectorPrivate::selectIndexRange(const QModelIndexList &indexes, unsigned flags) { - if (indexes.empty()) + if (indexes.isEmpty()) return; QItemSelectionModel::SelectionFlags selectFlags = QItemSelectionModel::Select|QItemSelectionModel::Rows; @@ -459,7 +461,7 @@ void ObjectInspector::ObjectInspectorPrivate::selectIndexRange(const QModelIndex selectFlags &= ~(QItemSelectionModel::Clear|QItemSelectionModel::Current); } if (flags & MakeCurrent) - m_treeView->scrollTo(indexes.front(), QAbstractItemView::EnsureVisible); + m_treeView->scrollTo(indexes.constFirst(), QAbstractItemView::EnsureVisible); } void ObjectInspector::ObjectInspectorPrivate::clear() @@ -528,10 +530,10 @@ void ObjectInspector::ObjectInspectorPrivate::setFormWindowBlocked(QDesignerForm bool applySelection = !mainContainerIsCurrent(m_formWindow); if (!applySelection) { const QModelIndexList currentIndexes = m_treeView->selectionModel()->selectedRows(0); - if (currentIndexes.empty()) { + if (currentIndexes.isEmpty()) { applySelection = true; } else { - applySelection = selectionType(m_formWindow, objectAt(currentIndexes.front())) == ManagedWidgetSelection; + applySelection = selectionType(m_formWindow, objectAt(currentIndexes.constFirst())) == ManagedWidgetSelection; } } if (applySelection) @@ -590,7 +592,7 @@ void ObjectInspector::ObjectInspectorPrivate::slotSelectionChanged(const QItemSe // some index lists are multicolumn ranges QObjectVector ObjectInspector::ObjectInspectorPrivate::indexesToObjects(const QModelIndexList &indexes) const { - if (indexes.empty()) + if (indexes.isEmpty()) return QObjectVector(); QObjectVector rc; rc.reserve(indexes.size()); @@ -638,11 +640,11 @@ void ObjectInspector::ObjectInspectorPrivate::synchronizeSelection(const QItemSe const QModelIndexList currentSelectedIndexes = m_treeView->selectionModel()->selectedRows(0); int deselectedManagedWidgetCount = 0; - if (!deselected.empty()) + if (!deselected.isEmpty()) deselectedManagedWidgetCount = selectInCursor(m_formWindow, deselected, false); - if (newlySelected.empty()) { // Nothing selected - if (currentSelectedIndexes.empty()) // Do not allow a null-selection, reset to main container + if (newlySelected.isEmpty()) { // Nothing selected + if (currentSelectedIndexes.isEmpty()) // Do not allow a null-selection, reset to main container m_formWindow->clearSelection(!m_withinClearSelection); return; } @@ -660,7 +662,7 @@ void ObjectInspector::ObjectInspectorPrivate::synchronizeSelection(const QItemSe } // And now for the unmanaged selection m_formWindow->clearSelection(false); - QObject *unmanagedObject = newlySelected.front(); + QObject *unmanagedObject = newlySelected.constFirst(); m_core->propertyEditor()->setObject(unmanagedObject); m_core->propertyEditor()->setEnabled(true); // open container page if it is a single widget @@ -670,7 +672,7 @@ void ObjectInspector::ObjectInspectorPrivate::synchronizeSelection(const QItemSe } // Open container page if it is a single widget if (newlySelected.size() == 1) { - QObject *object = newlySelected.back(); + QObject *object = newlySelected.constFirst(); if (object->isWidgetType()) showContainersCurrentPage(static_cast<QWidget*>(object)); } @@ -693,7 +695,7 @@ void ObjectInspector::ObjectInspectorPrivate::getSelection(Selection &s) const return; const QModelIndexList currentSelectedIndexes = m_treeView->selectionModel()->selectedRows(0); - if (currentSelectedIndexes.empty()) + if (currentSelectedIndexes.isEmpty()) return; // sort objects diff --git a/src/designer/src/components/objectinspector/objectinspectormodel.cpp b/src/designer/src/components/objectinspector/objectinspectormodel.cpp index 6baf4bcdc..b980d3967 100644 --- a/src/designer/src/components/objectinspector/objectinspectormodel.cpp +++ b/src/designer/src/components/objectinspector/objectinspectormodel.cpp @@ -290,7 +290,7 @@ namespace qdesigner_internal { } QObjectList children = object->children(); - if (!children.empty()) { + if (!children.isEmpty()) { ButtonGroupList buttonGroups; std::sort(children.begin(), children.end(), sortEntry); const QObjectList::const_iterator cend = children.constEnd(); @@ -310,7 +310,7 @@ namespace qdesigner_internal { } } // Add button groups - if (!buttonGroups.empty()) { + if (!buttonGroups.isEmpty()) { const ButtonGroupList::const_iterator bgcend = buttonGroups.constEnd(); for (ButtonGroupList::const_iterator bgit = buttonGroups.constBegin(); bgit != bgcend; ++bgit) createModelRecursion(fwi, object, *bgit, model, ctx); @@ -319,7 +319,7 @@ namespace qdesigner_internal { if (object->isWidgetType()) { // Add actions const ActionList actions = static_cast<QWidget*>(object)->actions(); - if (!actions.empty()) { + if (!actions.isEmpty()) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) if (ctx.mdb->item(*it)) { @@ -415,7 +415,7 @@ namespace qdesigner_internal { void ObjectInspectorModel::rebuild(const ObjectModel &newModel) { clearItems(); - if (newModel.empty()) + if (newModel.isEmpty()) return; const ObjectModel::const_iterator mcend = newModel.constEnd(); @@ -424,7 +424,7 @@ namespace qdesigner_internal { StandardItemList rootRow = createModelRow(it->object()); it->setItems(rootRow, m_icons); appendRow(rootRow); - m_objectIndexMultiMap.insert(it->object(), indexFromItem(rootRow.front())); + m_objectIndexMultiMap.insert(it->object(), indexFromItem(rootRow.constFirst())); for (++it; it != mcend; ++it) { // Add to parent item, found via map const QModelIndex parentIndex = m_objectIndexMultiMap.value(it->parent(), QModelIndex()); @@ -433,7 +433,7 @@ namespace qdesigner_internal { StandardItemList row = createModelRow(it->object()); it->setItems(row, m_icons); parentItem->appendRow(row); - m_objectIndexMultiMap.insert(it->object(), indexFromItem(row.front())); + m_objectIndexMultiMap.insert(it->object(), indexFromItem(row.constFirst())); } } diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index 2f1a65940..ad1b6505c 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -2272,7 +2272,7 @@ void DesignerEditorFactory::disconnectPropertyManager(QtVariantPropertyManager * template <class EditorContainer, class Editor, class SetterParameter, class Value> static inline void applyToEditors(const EditorContainer &list, void (Editor::*setter)(SetterParameter), const Value &value) { - if (list.empty()) { + if (list.isEmpty()) { return; } for (auto it = list.constBegin(), end = list.constEnd(); it != end; ++it) { @@ -2659,7 +2659,7 @@ void DesignerEditorFactory::slotStringTextChanged(const QString &value) PropertySheetStringValue strVal = qvariant_cast<PropertySheetStringValue>(val); strVal.setValue(value); // Disable translation if no translation subproperties exist. - if (varProp->subProperties().empty()) + if (varProp->subProperties().isEmpty()) strVal.setTranslatable(false); val = QVariant::fromValue(strVal); } else { @@ -2725,7 +2725,7 @@ void DesignerEditorFactory::slotStringListChanged(const QStringList &value) PropertySheetStringListValue listValue = qvariant_cast<PropertySheetStringListValue>(val); listValue.setValue(value); // Disable translation if no translation subproperties exist. - if (varProp->subProperties().empty()) + if (varProp->subProperties().isEmpty()) listValue.setTranslatable(false); val = QVariant::fromValue(listValue); } else { diff --git a/src/designer/src/components/propertyeditor/fontpropertymanager.cpp b/src/designer/src/components/propertyeditor/fontpropertymanager.cpp index a29867011..b34b288a5 100644 --- a/src/designer/src/components/propertyeditor/fontpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/fontpropertymanager.cpp @@ -86,7 +86,7 @@ namespace qdesigner_internal { // Map the font family names to display names retrieved from the XML configuration static QStringList designerFamilyNames(QStringList families, const FontPropertyManager::NameMap &nm) { - if (nm.empty()) + if (nm.isEmpty()) return families; const auto ncend = nm.constEnd(); @@ -117,9 +117,9 @@ namespace qdesigner_internal { m_propertyToAntialiasing[property] = antialiasing; m_antialiasingToProperty[antialiasing] = property; // Fiddle family names - if (!m_familyMappings.empty()) { + if (!m_familyMappings.isEmpty()) { const PropertyToSubPropertiesMap::iterator it = m_propertyToFontSubProperties.find(m_createdFontProperty); - QtVariantProperty *familyProperty = vm->variantProperty(it.value().front()); + QtVariantProperty *familyProperty = vm->variantProperty(it.value().constFirst()); const QString enumNamesAttribute = QStringLiteral("enumNames"); QStringList plainFamilyNames = familyProperty->attributeValue(enumNamesAttribute).toStringList(); // Did someone load fonts or something? diff --git a/src/designer/src/components/propertyeditor/paletteeditor.cpp b/src/designer/src/components/propertyeditor/paletteeditor.cpp index 4bb1bf450..64ed49a61 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/src/designer/src/components/propertyeditor/paletteeditor.cpp @@ -31,13 +31,29 @@ #include <iconloader_p.h> #include <qtcolorbutton.h> +#include <private/formbuilderextra_p.h> +#include <private/ui4_p.h> + #include <QtDesigner/abstractformeditor.h> #include <QtDesigner/abstractformwindowmanager.h> +#include <QtCore/qfile.h> #include <QtCore/qmetaobject.h> +#include <QtCore/qsavefile.h> +#include <QtCore/qxmlstream.h> +#include <QtGui/qguiapplication.h> #include <QtGui/qpainter.h> +#include <QtGui/qscreen.h> +#if QT_CONFIG(clipboard) +# include <QtGui/qclipboard.h> +#endif +#include <QtWidgets/qaction.h> +#include <QtWidgets/qfiledialog.h> +#include <QtWidgets/qmessagebox.h> +#include <QtWidgets/qpushbutton.h> #include <QtWidgets/qtoolbutton.h> #include <QtWidgets/qlabel.h> +#include <QtWidgets/qmenu.h> #include <QtWidgets/qheaderview.h> QT_BEGIN_NAMESPACE @@ -48,14 +64,15 @@ enum { BrushRole = 33 }; PaletteEditor::PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent) : QDialog(parent), - m_currentColorGroup(QPalette::Active), m_paletteModel(new PaletteModel(this)), - m_modelUpdated(false), - m_paletteUpdated(false), - m_compute(true), m_core(core) { ui.setupUi(this); + auto saveButton = ui.buttonBox->addButton(tr("Save..."), QDialogButtonBox::ActionRole); + connect(saveButton, &QPushButton::clicked, this, &PaletteEditor::save); + auto loadButton = ui.buttonBox->addButton(tr("Load..."), QDialogButtonBox::ActionRole); + connect(loadButton, &QPushButton::clicked, this, &PaletteEditor::load); + ui.paletteView->setModel(m_paletteModel); updatePreviewPalette(); updateStyledButton(); @@ -71,6 +88,14 @@ PaletteEditor::PaletteEditor(QDesignerFormEditorInterface *core, QWidget *parent ui.paletteView->setRootIsDecorated(false); ui.paletteView->setColumnHidden(2, true); ui.paletteView->setColumnHidden(3, true); + ui.paletteView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui.paletteView, &QWidget::customContextMenuRequested, + this, &PaletteEditor::viewContextMenuRequested); + + const auto itemRect = ui.paletteView->visualRect(m_paletteModel->index(0, 0)); + const int minHeight = qMin(itemRect.height() * QPalette::NColorRoles, + (screen()->geometry().height() * 2) / 3); + ui.paletteView->setMinimumSize({itemRect.width() * 4, minHeight}); } PaletteEditor::~PaletteEditor() = default; @@ -221,6 +246,145 @@ QPalette PaletteEditor::getPalette(QDesignerFormEditorInterface *core, QWidget* return result == QDialog::Accepted ? dlg.palette() : init; } +void PaletteEditor::viewContextMenuRequested(const QPoint &pos) +{ + const auto index = ui.paletteView->indexAt(pos); + if (!index.isValid()) + return; + auto brush = m_paletteModel->brushAt(index); + const auto color = brush.color(); + if (!m_contextMenu) { + m_contextMenu = new QMenu(this); + m_lighterAction = m_contextMenu->addAction(tr("Lighter")); + m_darkerAction = m_contextMenu->addAction(tr("Darker")); + m_copyColorAction = m_contextMenu->addAction(QString()); + } + const auto rgb = color.rgb() & 0xffffffu; + const bool isBlack = rgb == 0u; + m_lighterAction->setEnabled(rgb != 0xffffffu); + m_darkerAction->setDisabled(isBlack); + m_copyColorAction->setText(tr("Copy color %1").arg(color.name())); + auto action = m_contextMenu->exec(ui.paletteView->viewport()->mapToGlobal(pos)); + if (!action) + return; + if (action == m_copyColorAction) { +#if QT_CONFIG(clipboard) + QGuiApplication::clipboard()->setText(color.name()); +#endif + return; + } + // Fall through to darker/lighter. Note: black cannot be made lighter due + // to QTBUG-9343. + enum : int { factor = 120 }; + const QColor newColor = action == m_darkerAction + ? color.darker(factor) + : (isBlack ? QColor(0x404040u) : color.lighter(factor)); + brush.setColor(newColor); + m_paletteModel->setData(index, QVariant(brush), BrushRole); +} + +static inline QString paletteSuffix() { return QStringLiteral("xml"); } + +static inline QString paletteFilter() +{ + return PaletteEditor::tr("QPalette UI file (*.xml)"); +} + +static bool savePalette(const QString &fileName, const QPalette &pal, QString *errorMessage) +{ + QSaveFile file; + file.setFileName(fileName); + if (!file.open(QIODevice::WriteOnly)) { + *errorMessage = PaletteEditor::tr("Cannot open %1 for writing: %2") + .arg(QDir::toNativeSeparators(fileName), file.errorString()); + return false; + } + { + QScopedPointer<DomPalette> domPalette(QFormBuilderExtra::savePalette(pal)); + QXmlStreamWriter writer(&file); + writer.setAutoFormatting(true); + writer.setAutoFormattingIndent(1); + writer.writeStartDocument(); + domPalette->write(writer); + writer.writeEndDocument(); + } + const bool result = file.commit(); + if (!result) { + *errorMessage = PaletteEditor::tr("Cannot write %1: %2") + .arg(QDir::toNativeSeparators(fileName), file.errorString()); + } + return result; +} + +static QString msgCannotReadPalette(const QString &fileName, const QXmlStreamReader &reader, + const QString &why) +{ + return PaletteEditor::tr("Cannot read palette from %1:%2:%3") + .arg(QDir::toNativeSeparators(fileName)).arg(reader.lineNumber()).arg(why); +} + +static inline QString msgCannotReadPalette(const QString &fileName, const QXmlStreamReader &reader) +{ + return msgCannotReadPalette(fileName, reader, reader.errorString()); +} + +static bool loadPalette(const QString &fileName, QPalette *pal, QString *errorMessage) +{ + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + *errorMessage = PaletteEditor::tr("Cannot open %1 for reading: %2") + .arg(QDir::toNativeSeparators(fileName), file.errorString()); + return false; + } + QXmlStreamReader reader(&file); + if (!reader.readNextStartElement()) { + *errorMessage = msgCannotReadPalette(fileName, reader); + return false; + } + if (reader.name() != QLatin1String("palette")) { + const auto why = PaletteEditor::tr("Invalid element \"%1\", expected \"palette\".") + .arg(reader.name().toString()); + *errorMessage = msgCannotReadPalette(fileName, reader, why); + return false; + } + QScopedPointer<DomPalette> domPalette(new DomPalette); + domPalette->read(reader); + if (reader.hasError()) { + *errorMessage = msgCannotReadPalette(fileName, reader); + return false; + } + *pal = QFormBuilderExtra::loadPalette(domPalette.data()); + return true; +} + +void PaletteEditor::save() +{ + QFileDialog dialog(this, tr("Save Palette"), QString(), paletteFilter()); + dialog.setAcceptMode(QFileDialog::AcceptSave); + dialog.setDefaultSuffix(paletteSuffix()); + while (dialog.exec() == QDialog::Accepted) { + QString errorMessage; + if (savePalette(dialog.selectedFiles().constFirst(), palette(), &errorMessage)) + break; + QMessageBox::warning(this, tr("Error Writing Palette"), errorMessage); + } +} + +void PaletteEditor::load() +{ + QFileDialog dialog(this, tr("Load Palette"), QString(), paletteFilter()); + dialog.setAcceptMode(QFileDialog::AcceptOpen); + while (dialog.exec() == QDialog::Accepted) { + QPalette pal; + QString errorMessage; + if (loadPalette(dialog.selectedFiles().constFirst(), &pal, &errorMessage)) { + setPalette(pal); + break; + } + QMessageBox::warning(this, tr("Error Reading Palette"), errorMessage); + } +} + ////////////////////// PaletteModel::PaletteModel(QObject *parent) : @@ -230,14 +394,17 @@ PaletteModel::PaletteModel(QObject *parent) : const int index = meta->indexOfProperty("colorRole"); const QMetaProperty p = meta->property(index); const QMetaEnum e = p.enumerator(); + m_roleEntries.reserve(QPalette::NColorRoles); for (int r = QPalette::WindowText; r < QPalette::NColorRoles; r++) { - m_roleNames[static_cast<QPalette::ColorRole>(r)] = QLatin1String(e.key(r)); + const auto role = static_cast<QPalette::ColorRole>(r); + if (role != QPalette::NoRole) + m_roleEntries.append({QLatin1String(e.key(r)), role}); } } int PaletteModel::rowCount(const QModelIndex &) const { - return m_roleNames.count(); + return m_roleEntries.size(); } int PaletteModel::columnCount(const QModelIndex &) const @@ -245,29 +412,35 @@ int PaletteModel::columnCount(const QModelIndex &) const return 4; } +QBrush PaletteModel::brushAt(const QModelIndex &index) const +{ + return m_palette.brush(columnToGroup(index.column()), roleAt(index.row())); +} + QVariant PaletteModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); - if (index.row() < 0 || index.row() >= QPalette::NColorRoles) + if (index.row() < 0 || index.row() >= m_roleEntries.size()) return QVariant(); if (index.column() < 0 || index.column() >= 4) return QVariant(); if (index.column() == 0) { if (role == Qt::DisplayRole) - return m_roleNames[static_cast<QPalette::ColorRole>(index.row())]; + return m_roleEntries.at(index.row()).name; if (role == Qt::EditRole) { const uint mask = m_palette.resolve(); - if (mask & (1 << index.row())) + if (mask & (1 << int(roleAt(index.row())))) return true; return false; } return QVariant(); } + if (role == Qt::ToolTipRole) + return brushAt(index).color().name(); if (role == BrushRole) - return m_palette.brush(columnToGroup(index.column()), - static_cast<QPalette::ColorRole>(index.row())); + return brushAt(index); return QVariant(); } @@ -276,17 +449,19 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int if (!index.isValid()) return false; + const int row = index.row(); + const auto colorRole = roleAt(row); + if (index.column() != 0 && role == BrushRole) { const QBrush br = qvariant_cast<QBrush>(value); - const QPalette::ColorRole r = static_cast<QPalette::ColorRole>(index.row()); const QPalette::ColorGroup g = columnToGroup(index.column()); - m_palette.setBrush(g, r, br); + m_palette.setBrush(g, colorRole, br); - QModelIndex idxBegin = PaletteModel::index(r, 0); - QModelIndex idxEnd = PaletteModel::index(r, 3); + QModelIndex idxBegin = PaletteModel::index(row, 0); + QModelIndex idxEnd = PaletteModel::index(row, 3); if (m_compute) { - m_palette.setBrush(QPalette::Inactive, r, br); - switch (r) { + m_palette.setBrush(QPalette::Inactive, colorRole, br); + switch (colorRole) { case QPalette::WindowText: case QPalette::Text: case QPalette::ButtonText: @@ -298,18 +473,18 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int m_palette.setBrush(QPalette::Disabled, QPalette::Text, br); m_palette.setBrush(QPalette::Disabled, QPalette::ButtonText, br); idxBegin = PaletteModel::index(0, 0); - idxEnd = PaletteModel::index(m_roleNames.count() - 1, 3); + idxEnd = PaletteModel::index(m_roleEntries.size() - 1, 3); break; case QPalette::Window: m_palette.setBrush(QPalette::Disabled, QPalette::Base, br); m_palette.setBrush(QPalette::Disabled, QPalette::Window, br); - idxBegin = PaletteModel::index(QPalette::Base, 0); + idxBegin = PaletteModel::index(rowOf(QPalette::Base), 0); break; case QPalette::Highlight: //m_palette.setBrush(QPalette::Disabled, QPalette::Highlight, c.dark(120)); break; default: - m_palette.setBrush(QPalette::Disabled, r, br); + m_palette.setBrush(QPalette::Disabled, colorRole, br); break; } } @@ -320,22 +495,21 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int if (index.column() == 0 && role == Qt::EditRole) { uint mask = m_palette.resolve(); const bool isMask = qvariant_cast<bool>(value); - const int r = index.row(); if (isMask) - mask |= (1 << r); + mask |= (1 << int(colorRole)); else { - m_palette.setBrush(QPalette::Active, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Active, static_cast<QPalette::ColorRole>(r))); - m_palette.setBrush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Inactive, static_cast<QPalette::ColorRole>(r))); - m_palette.setBrush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r), - m_parentPalette.brush(QPalette::Disabled, static_cast<QPalette::ColorRole>(r))); - - mask &= ~(1 << index.row()); + m_palette.setBrush(QPalette::Active, colorRole, + m_parentPalette.brush(QPalette::Active, colorRole)); + m_palette.setBrush(QPalette::Inactive, colorRole, + m_parentPalette.brush(QPalette::Inactive, colorRole)); + m_palette.setBrush(QPalette::Disabled, colorRole, + m_parentPalette.brush(QPalette::Disabled, colorRole)); + + mask &= ~(1 << int(colorRole)); } m_palette.resolve(mask); emit paletteChanged(m_palette); - const QModelIndex idxEnd = PaletteModel::index(r, 3); + const QModelIndex idxEnd = PaletteModel::index(row, 3); emit dataChanged(index, idxEnd); return true; } @@ -375,7 +549,7 @@ void PaletteModel::setPalette(const QPalette &palette, const QPalette &parentPal m_parentPalette = parentPalette; m_palette = palette; const QModelIndex idxBegin = index(0, 0); - const QModelIndex idxEnd = index(m_roleNames.count() - 1, 3); + const QModelIndex idxEnd = index(m_roleEntries.size() - 1, 3); emit dataChanged(idxBegin, idxEnd); } @@ -397,6 +571,15 @@ int PaletteModel::groupToColumn(QPalette::ColorGroup group) const return 3; } +int PaletteModel::rowOf(QPalette::ColorRole role) const +{ + for (int row = 0, size = m_roleEntries.size(); row < size; ++row) { + if (m_roleEntries.at(row).role == role) + return row; + } + return -1; +} + ////////////////////////// BrushEditor::BrushEditor(QDesignerFormEditorInterface *core, QWidget *parent) : diff --git a/src/designer/src/components/propertyeditor/paletteeditor.h b/src/designer/src/components/propertyeditor/paletteeditor.h index 6124340dc..b4d649163 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.h +++ b/src/designer/src/components/propertyeditor/paletteeditor.h @@ -34,7 +34,9 @@ QT_BEGIN_NAMESPACE +class QAction; class QListView; +class QMenu; class QLabel; class QtColorButton; class QDesignerFormEditorInterface; @@ -65,6 +67,9 @@ private slots: void on_detailsRadio_clicked(); void paletteChanged(const QPalette &palette); + void viewContextMenuRequested(const QPoint &pos); + void save(); + void load(); protected: @@ -81,12 +86,16 @@ private: Ui::PaletteEditor ui; QPalette m_editPalette; QPalette m_parentPalette; - QPalette::ColorGroup m_currentColorGroup; class PaletteModel *m_paletteModel; - bool m_modelUpdated; - bool m_paletteUpdated; - bool m_compute; QDesignerFormEditorInterface *m_core; + QAction *m_lighterAction = nullptr; + QAction *m_darkerAction = nullptr; + QAction *m_copyColorAction = nullptr; + QMenu *m_contextMenu = nullptr; + QPalette::ColorGroup m_currentColorGroup = QPalette::Active; + bool m_modelUpdated = false; + bool m_paletteUpdated = false; + bool m_compute = true; }; @@ -108,18 +117,27 @@ public: QPalette getPalette() const; void setPalette(const QPalette &palette, const QPalette &parentPalette); + QBrush brushAt(const QModelIndex &index) const; + QPalette::ColorRole colorRole() const { return QPalette::NoRole; } void setCompute(bool on) { m_compute = on; } signals: void paletteChanged(const QPalette &palette); private: + struct RoleEntry + { + QString name; + QPalette::ColorRole role; + }; QPalette::ColorGroup columnToGroup(int index) const; int groupToColumn(QPalette::ColorGroup group) const; + QPalette::ColorRole roleAt(int row) const { return m_roleEntries.at(row).role; } + int rowOf(QPalette::ColorRole role) const; QPalette m_palette; QPalette m_parentPalette; - QMap<QPalette::ColorRole, QString> m_roleNames; + QVector<RoleEntry> m_roleEntries; bool m_compute = true; }; diff --git a/src/designer/src/components/propertyeditor/paletteeditor.ui b/src/designer/src/components/propertyeditor/paletteeditor.ui index aa5965d79..2bb8cfedc 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.ui +++ b/src/designer/src/components/propertyeditor/paletteeditor.ui @@ -1,4 +1,5 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <comment>********************************************************************* ** ** Copyright (C) 2016 The Qt Company Ltd. @@ -27,175 +28,183 @@ ** *********************************************************************</comment> <class>qdesigner_internal::PaletteEditor</class> - <widget class="QDialog" name="qdesigner_internal::PaletteEditor" > - <property name="geometry" > + <widget class="QDialog" name="qdesigner_internal::PaletteEditor"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>365</width> - <height>409</height> + <width>918</width> + <height>599</height> </rect> </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Edit Palette</string> </property> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QGroupBox" name="advancedBox" > - <property name="minimumSize" > - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="title" > - <string>Tune Palette</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QtColorButton" name="buildButton" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>13</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGroupBox" name="advancedBox"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="title"> + <string>Tune Palette</string> + </property> + <layout class="QGridLayout"> + <property name="leftMargin"> + <number>9</number> </property> - <property name="text" > - <string/> + <property name="topMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="1" column="0" colspan="4" > - <widget class="QTreeView" name="paletteView" > - <property name="minimumSize" > - <size> - <width>0</width> - <height>200</height> - </size> + <property name="rightMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="0" column="3" > - <widget class="QRadioButton" name="detailsRadio" > - <property name="text" > - <string>Show Details</string> + <property name="bottomMargin"> + <number>9</number> </property> - </widget> - </item> - <item row="0" column="2" > - <widget class="QRadioButton" name="computeRadio" > - <property name="text" > - <string>Compute Details</string> + <property name="spacing"> + <number>6</number> </property> - <property name="checked" > - <bool>true</bool> + <item row="0" column="1"> + <widget class="QtColorButton" name="buildButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Ignored"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="0" colspan="4"> + <widget class="QTreeView" name="paletteView"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>200</height> + </size> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QRadioButton" name="detailsRadio"> + <property name="text"> + <string>Show Details</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="computeRadio"> + <property name="text"> + <string>Compute Details</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Quick</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="GroupBox126"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Preview</string> + </property> + <layout class="QGridLayout"> + <property name="leftMargin"> + <number>8</number> </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Quick</string> + <property name="topMargin"> + <number>8</number> </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="GroupBox126" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title" > - <string>Preview</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="2" > - <widget class="QRadioButton" name="disabledRadio" > - <property name="text" > - <string>Disabled</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QRadioButton" name="inactiveRadio" > - <property name="text" > - <string>Inactive</string> + <property name="rightMargin"> + <number>8</number> </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QRadioButton" name="activeRadio" > - <property name="text" > - <string>Active</string> + <property name="bottomMargin"> + <number>8</number> </property> - <property name="checked" > - <bool>true</bool> + <property name="spacing"> + <number>6</number> </property> - </widget> - </item> - <item row="1" column="0" colspan="3" > - <widget class="qdesigner_internal::PreviewFrame" native="1" name="previewFrame" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </widget> + <item row="0" column="2"> + <widget class="QRadioButton" name="disabledRadio"> + <property name="text"> + <string>Disabled</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="inactiveRadio"> + <property name="text"> + <string>Inactive</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QRadioButton" name="activeRadio"> + <property name="text"> + <string>Active</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0" colspan="3"> + <widget class="qdesigner_internal::PreviewFrame" name="previewFrame" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> </property> </widget> </item> @@ -221,11 +230,11 @@ <receiver>qdesigner_internal::PaletteEditor</receiver> <slot>accept()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>180</x> <y>331</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>134</x> <y>341</y> </hint> @@ -237,11 +246,11 @@ <receiver>qdesigner_internal::PaletteEditor</receiver> <slot>reject()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>287</x> <y>329</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>302</x> <y>342</y> </hint> diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index af590a7d5..85724eb01 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -363,7 +363,7 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare break; } // Restore expansionState from QVariant map - if (!expansionState.empty()) { + if (!expansionState.isEmpty()) { const QVariantMap::const_iterator cend = expansionState.constEnd(); for (QVariantMap::const_iterator it = expansionState.constBegin(); it != cend; ++it) m_expansionState.insert(it.key(), it.value().toBool()); @@ -386,7 +386,7 @@ void PropertyEditor::saveSettings() const settings->setValue(QLatin1String(SortedKeyC), QVariant(m_sorting)); // Save last expansionState as QVariant map QVariantMap expansionState; - if (!m_expansionState.empty()) { + if (!m_expansionState.isEmpty()) { const QMap<QString, bool>::const_iterator cend = m_expansionState.constEnd(); for (QMap<QString, bool>::const_iterator it = m_expansionState.constBegin(); it != cend; ++it) expansionState.insert(it.key(), QVariant(it.value())); @@ -436,7 +436,7 @@ void PropertyEditor::storePropertiesExpansionState(const QList<QtBrowserItem *> { const QChar bar = QLatin1Char('|'); for (QtBrowserItem *propertyItem : items) { - if (!propertyItem->children().empty()) { + if (!propertyItem->children().isEmpty()) { QtProperty *property = propertyItem->property(); const QString propertyName = property->propertyName(); const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property); @@ -459,7 +459,7 @@ void PropertyEditor::storeExpansionState() for (QtBrowserItem *item : items) { const QString groupName = item->property()->propertyName(); QList<QtBrowserItem *> propertyItems = item->children(); - if (!propertyItems.empty()) + if (!propertyItems.isEmpty()) m_expansionState[groupName] = isExpanded(item); // properties stuff here @@ -814,7 +814,7 @@ void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVari } // Rich text string property with comment: Store/Update the font the rich text editor dialog starts out with - if (type == QVariant::String && !property->subProperties().empty()) { + if (type == QVariant::String && !property->subProperties().isEmpty()) { const int fontIndex = m_propertySheet->indexOf(m_strings.m_fontProperty); if (fontIndex != -1) property->setAttribute(m_strings.m_fontAttribute, m_propertySheet->property(fontIndex)); @@ -1093,8 +1093,8 @@ void PropertyEditor::setObject(QObject *object) lastGroup = groupProperty; lastProperty = nullptr; // Append at end const QList<QtProperty*> subProperties = lastGroup->subProperties(); - if (!subProperties.empty()) - lastProperty = subProperties.back(); + if (!subProperties.isEmpty()) + lastProperty = subProperties.constLast(); lastGroup = groupProperty; } if (!m_groups.contains(groupProperty)) @@ -1123,7 +1123,7 @@ void PropertyEditor::setObject(QObject *object) QMap<QString, QtVariantProperty *> groups = m_nameToGroup; for (auto itGroup = groups.cbegin(), end = groups.cend(); itGroup != end; ++itGroup) { QtVariantProperty *groupProperty = itGroup.value(); - if (groupProperty->subProperties().empty()) { + if (groupProperty->subProperties().isEmpty()) { if (groupProperty == m_dynamicGroup) m_dynamicGroup = nullptr; delete groupProperty; @@ -1247,7 +1247,7 @@ void PropertyEditor::editProperty(const QString &name) if (QtVariantProperty *property = m_nameToProperty.value(name, 0)) { const QList<QtBrowserItem *> items = m_currentBrowser->items(property); if (items.size() == 1) - browserItem = items.front(); + browserItem = items.constFirst(); } if (browserItem == nullptr) return; diff --git a/src/designer/src/components/signalsloteditor/connectdialog.cpp b/src/designer/src/components/signalsloteditor/connectdialog.cpp index 571ddba12..6eef6dcc7 100644 --- a/src/designer/src/components/signalsloteditor/connectdialog.cpp +++ b/src/designer/src/components/signalsloteditor/connectdialog.cpp @@ -140,20 +140,20 @@ void ConnectDialog::setSignalSlot(const QString &signal, const QString &slot) { ListWidgetItems sigItems = m_ui.signalList->findItems(signal, Qt::MatchExactly); - if (sigItems.empty()) { + if (sigItems.isEmpty()) { m_ui.showAllCheckBox->setChecked(true); sigItems = m_ui.signalList->findItems(signal, Qt::MatchExactly); } - if (!sigItems.empty()) { - selectSignal(sigItems.front()); + if (!sigItems.isEmpty()) { + selectSignal(sigItems.constFirst()); ListWidgetItems slotItems = m_ui.slotList->findItems(slot, Qt::MatchExactly); - if (slotItems.empty()) { + if (slotItems.isEmpty()) { m_ui.showAllCheckBox->setChecked(true); slotItems = m_ui.slotList->findItems(slot, Qt::MatchExactly); } - if (!slotItems.empty()) - selectSlot(slotItems.front()); + if (!slotItems.isEmpty()) + selectSlot(slotItems.constFirst()); } } diff --git a/src/designer/src/components/signalsloteditor/signalslot_utils.cpp b/src/designer/src/components/signalsloteditor/signalslot_utils.cpp index f913b5bdf..c7a960ef3 100644 --- a/src/designer/src/components/signalsloteditor/signalslot_utils.cpp +++ b/src/designer/src/components/signalsloteditor/signalslot_utils.cpp @@ -93,7 +93,7 @@ static void memberList(QDesignerFormEditorInterface *core, const QString className = wdbItem->name(); const QStringList wdbFakeMethods = member_type == qdesigner_internal::SlotMember ? wdbItem->fakeSlots() : wdbItem->fakeSignals(); - if (!wdbFakeMethods.empty()) + if (!wdbFakeMethods.isEmpty()) for (const QString &fakeMethod : wdbFakeMethods) if (predicate(fakeMethod)) { *it = ClassNameSignaturePair(className, fakeMethod); @@ -106,7 +106,7 @@ static void memberList(QDesignerFormEditorInterface *core, if (const qdesigner_internal::MetaDataBaseItem *mdbItem = metaDataBase->metaDataBaseItem(object)) { const QStringList mdbFakeMethods = member_type == qdesigner_internal::SlotMember ? mdbItem->fakeSlots() : mdbItem->fakeSignals(); - if (!mdbFakeMethods.empty()) + if (!mdbFakeMethods.isEmpty()) for (const QString &fakeMethod : mdbFakeMethods) if (predicate(fakeMethod)) { *it = ClassNameSignaturePair(className, fakeMethod); @@ -266,7 +266,7 @@ namespace qdesigner_internal { { QMap<QString, QString> rc; memberList(core, object, type, true, EqualsPredicate(signature), SignatureIterator(&rc)); - return !rc.empty(); + return !rc.isEmpty(); } // ### deprecated diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index c2f53a46e..175b4f6a8 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -105,7 +105,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) // Add managed actions and actions with managed menus const ActionList actions = mainContainer->findChildren<QAction*>(); - if (!actions.empty()) { + if (!actions.isEmpty()) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { QAction *a = *it; @@ -123,7 +123,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) // Add managed buttons groups const ButtonGroupList buttonGroups = mainContainer->findChildren<QButtonGroup *>(); - if (!buttonGroups.empty()) { + if (!buttonGroups.isEmpty()) { const ButtonGroupList::const_iterator cend = buttonGroups.constEnd(); for (ButtonGroupList::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) if (mdb->item(*it)) diff --git a/src/designer/src/components/taskmenu/button_taskmenu.cpp b/src/designer/src/components/taskmenu/button_taskmenu.cpp index 5791c6991..80e9d45c3 100644 --- a/src/designer/src/components/taskmenu/button_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/button_taskmenu.cpp @@ -211,7 +211,7 @@ CreateButtonGroupCommand::CreateButtonGroupCommand(QDesignerFormWindowInterface bool CreateButtonGroupCommand::init(const ButtonList &bl) { - if (bl.empty()) + if (bl.isEmpty()) return false; QDesignerFormWindowInterface *fw = formWindow(); QButtonGroup *buttonGroup = new QButtonGroup(fw->mainContainer()); @@ -286,9 +286,9 @@ RemoveButtonsFromGroupCommand::RemoveButtonsFromGroupCommand(QDesignerFormWindow bool RemoveButtonsFromGroupCommand::init(const ButtonList &bl) { - if (bl.empty()) + if (bl.isEmpty()) return false; - QButtonGroup *group = bl.front()->group(); + QButtonGroup *group = bl.constFirst()->group(); if (!group) return false; if (bl.size() >= group->buttons().size()) @@ -560,7 +560,7 @@ static ButtonList buttonList(const QDesignerFormWindowCursorInterface *cursor) static QUndoCommand *createRemoveButtonsCommand(QDesignerFormWindowInterface *fw, const ButtonList &bl) { - QButtonGroup *bg = bl.front()->group(); + QButtonGroup *bg = bl.constFirst()->group(); // Complete group or 1-member group? if (bl.size() >= bg->buttons().size() - 1) { BreakButtonGroupCommand *breakCmd = new BreakButtonGroupCommand(fw); @@ -588,7 +588,7 @@ void ButtonTaskMenu::createGroup() const ButtonList bl = buttonList(fw->cursor()); // Do we need to remove the buttons from an existing group? QUndoCommand *removeCmd = nullptr; - if (bl.front()->group()) { + if (bl.constFirst()->group()) { removeCmd = createRemoveButtonsCommand(fw, bl); if (!removeCmd) return; @@ -651,7 +651,7 @@ void ButtonTaskMenu::addToGroup(QAction *a) const ButtonList bl = buttonList(fw->cursor()); // Do we need to remove the buttons from an existing group? QUndoCommand *removeCmd = nullptr; - if (bl.front()->group()) { + if (bl.constFirst()->group()) { removeCmd = createRemoveButtonsCommand(fw, bl); if (!removeCmd) return; diff --git a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp index 30fbc2337..c44fa4169 100644 --- a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -174,7 +174,7 @@ static QWidget *decorationFromDomWidget(DomUI *dom_ui, QDesignerFormEditorInterf QWidget *fakeTopLevel = builder.createUI(dom_ui, nullptr); fakeTopLevel->setParent(nullptr, Qt::ToolTip); // Container // Actual widget - const DomWidget *domW = dom_ui->elementWidget()->elementWidget().front(); + const DomWidget *domW = dom_ui->elementWidget()->elementWidget().constFirst(); QWidget *w = fakeTopLevel->findChildren<QWidget*>().constFirst(); Q_ASSERT(w); // hack begin; diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp index dd17b3a4e..a170fa7c7 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -160,7 +160,7 @@ void WidgetBoxTreeWidget::restoreExpandedState() const auto &closedCategoryList = settings->value(groupKey + QLatin1String(widgetBoxExpandedKeyC), QStringList()).toStringList(); const StringSet closedCategories(closedCategoryList.cbegin(), closedCategoryList.cend()); expandAll(); - if (closedCategories.empty()) + if (closedCategories.isEmpty()) return; if (const int numCategories = categoryCount()) { @@ -594,8 +594,7 @@ static inline bool isValidIcon(const QIcon &icon) { if (!icon.isNull()) { const QList<QSize> availableSizes = icon.availableSizes(); - if (!availableSizes.empty()) - return !availableSizes.front().isEmpty(); + return !availableSizes.isEmpty() && !availableSizes.constFirst().isEmpty(); } return false; } @@ -606,7 +605,7 @@ WidgetBoxTreeWidget::CategoryList WidgetBoxTreeWidget::loadCustomCategoryList() const QDesignerPluginManager *pm = m_core->pluginManager(); const QDesignerPluginManager::CustomWidgetList customWidgets = pm->registeredCustomWidgets(); - if (customWidgets.empty()) + if (customWidgets.isEmpty()) return result; static const QString customCatName = tr("Custom Widgets"); diff --git a/src/designer/src/designer/appfontdialog.cpp b/src/designer/src/designer/appfontdialog.cpp index b1a3942df..c5524be7f 100644 --- a/src/designer/src/designer/appfontdialog.cpp +++ b/src/designer/src/designer/appfontdialog.cpp @@ -122,7 +122,7 @@ void AppFontManager::restore(const QDesignerSettingsInterface *s, const QString if (debugAppFontWidget) qDebug() << "AppFontManager::restoring" << fontFiles.size() << "fonts from " << prefix; - if (!fontFiles.empty()) { + if (!fontFiles.isEmpty()) { QString errorMessage; const QStringList::const_iterator cend = fontFiles.constEnd(); for (QStringList::const_iterator it = fontFiles.constBegin(); it != cend; ++it) @@ -311,7 +311,7 @@ void AppFontWidget::addFiles() const QStringList files = QFileDialog::getOpenFileNames(this, tr("Add Font Files"), QString(), tr("Font files (*.ttf)")); - if (files.empty()) + if (files.isEmpty()) return; QString errorMessage; @@ -331,7 +331,7 @@ void AppFontWidget::addFiles() static void removeFonts(const QModelIndexList &selectedIndexes, AppFontModel *model, QWidget *dialogParent) { - if (selectedIndexes.empty()) + if (selectedIndexes.isEmpty()) return; // Reverse sort top level rows and remove @@ -382,7 +382,7 @@ void AppFontWidget::slotRemoveAll() void AppFontWidget::selectionChanged(const QItemSelection &selected, const QItemSelection & /*deselected*/) { - m_removeButton->setEnabled(!selected.indexes().empty()); + m_removeButton->setEnabled(!selected.indexes().isEmpty()); } void AppFontWidget::save(QDesignerSettingsInterface *s, const QString &prefix) diff --git a/src/designer/src/designer/mainwindow.cpp b/src/designer/src/designer/mainwindow.cpp index 3a1ae3ce9..d47be9ad0 100644 --- a/src/designer/src/designer/mainwindow.cpp +++ b/src/designer/src/designer/mainwindow.cpp @@ -151,7 +151,7 @@ QStringList DockedMdiArea::uiFiles(const QMimeData *d) const if (!d->hasFormat(QLatin1String(uriListMimeFormatC))) return rc; const QList<QUrl> urls = d->urls(); - if (urls.empty()) + if (urls.isEmpty()) return rc; const QList<QUrl>::const_iterator cend = urls.constEnd(); for (QList<QUrl>::const_iterator it = urls.constBegin(); it != cend; ++it) { @@ -169,7 +169,7 @@ bool DockedMdiArea::event(QEvent *event) switch (event->type()) { case QEvent::DragEnter: { QDragEnterEvent *e = static_cast<QDragEnterEvent*>(event); - if (!uiFiles(e->mimeData()).empty()) { + if (!uiFiles(e->mimeData()).isEmpty()) { e->acceptProposedAction(); return true; } @@ -338,7 +338,7 @@ QMdiSubWindow *DockedMainWindow::createMdiSubWindow(QWidget *fw, Qt::WindowFlags // designer menu actions if (designerCloseActionShortCut == QKeySequence(QKeySequence::Close)) { const ActionList systemMenuActions = rc->systemMenu()->actions(); - if (!systemMenuActions.empty()) { + if (!systemMenuActions.isEmpty()) { const ActionList::const_iterator cend = systemMenuActions.constEnd(); for (ActionList::const_iterator it = systemMenuActions.constBegin(); it != cend; ++it) { if ( (*it)->shortcut() == designerCloseActionShortCut) { diff --git a/src/designer/src/designer/newform.cpp b/src/designer/src/designer/newform.cpp index 797e60149..12553c393 100644 --- a/src/designer/src/designer/newform.cpp +++ b/src/designer/src/designer/newform.cpp @@ -104,7 +104,7 @@ QDialogButtonBox *NewForm::createButtonBox() QMenu *recentFilesMenu = new QMenu(tr("&Recent Forms"), m_recentButton); // Pop the "Recent Files" stuff in here. const QList<QAction *> recentActions = da->recentFilesActions()->actions(); - if (!recentActions.empty()) { + if (!recentActions.isEmpty()) { const QList<QAction *>::const_iterator acend = recentActions.constEnd(); for (QList<QAction *>::const_iterator it = recentActions.constBegin(); it != acend; ++it) { recentFilesMenu->addAction(*it); diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index ff244ec29..4344b1c07 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -252,7 +252,7 @@ QDesigner::ParseArgumentsResult QDesigner::parseCommandLineArguments() m_suppressNewFormShow = m_workbench->readInBackup(); - if (!options.files.empty()) { + if (!options.files.isEmpty()) { const QStringList::const_iterator cend = options.files.constEnd(); for (QStringList::const_iterator it = options.files.constBegin(); it != cend; ++it) { // Ensure absolute paths for recent file list to be unique diff --git a/src/designer/src/designer/qdesigner_settings.cpp b/src/designer/src/designer/qdesigner_settings.cpp index 8ac61c52a..e8ac4be54 100644 --- a/src/designer/src/designer/qdesigner_settings.cpp +++ b/src/designer/src/designer/qdesigner_settings.cpp @@ -40,7 +40,6 @@ #include <QtCore/qvariant.h> #include <QtCore/qdir.h> -#include <QtWidgets/qdesktopwidget.h> #include <QtWidgets/qstyle.h> #include <QtWidgets/qlistview.h> diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index f2a8b5d1c..6262747dd 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -58,7 +58,6 @@ #include <QtWidgets/qactiongroup.h> #include <QtGui/qevent.h> #include <QtGui/qscreen.h> -#include <QtWidgets/qdesktopwidget.h> #include <QtWidgets/qdockwidget.h> #include <QtWidgets/qmenu.h> #include <QtWidgets/qmenubar.h> @@ -569,9 +568,9 @@ QRect QDesignerWorkbench::desktopGeometry() const case NeutralMode: break; } - const int screenNumber = widget ? QApplication::desktop()->screenNumber(widget) : 0; - auto screen = QGuiApplication::screens().value(screenNumber, QGuiApplication::primaryScreen()); - return screen->availableGeometry(); + const auto screen = widget ? widget->screen() : QGuiApplication::primaryScreen(); + return screen ? screen->availableGeometry() + : QGuiApplication::primaryScreen()->availableGeometry(); } QRect QDesignerWorkbench::availableGeometry() const @@ -579,9 +578,8 @@ QRect QDesignerWorkbench::availableGeometry() const if (m_mode == DockedMode) return m_dockedMainWindow->mdiArea()->geometry(); - const int screenNumber = QApplication::desktop()->screenNumber(widgetBoxToolWindow()); - auto screen = QGuiApplication::screens().value(screenNumber, QGuiApplication::primaryScreen()); - return screen->availableGeometry(); + const auto screen = widgetBoxToolWindow()->screen(); + return screen ? screen->availableGeometry() : QGuiApplication::primaryScreen()->availableGeometry() ; } int QDesignerWorkbench::marginHint() const @@ -608,7 +606,7 @@ void QDesignerWorkbench::removeFormWindow(QDesignerFormWindow *formWindow) m_windowMenu->removeAction(action); } - if (m_formWindows.empty()) { + if (m_formWindows.isEmpty()) { m_actionManager->setWindowListSeparatorVisible(false); // Show up new form dialog unless closing if (loadOk && m_state == StateUp @@ -1079,7 +1077,7 @@ void QDesignerWorkbench::restoreUISettings() ToolWindowFontSettings fontSettings = QDesignerSettings(m_core).toolWindowFont(); const QFont &font = fontSettings.m_useFont ? fontSettings.m_font : qApp->font(); - if (font == m_toolWindows.front()->font()) + if (font == m_toolWindows.constFirst()->font()) return; for (QDesignerToolWindow *tw : qAsConst(m_toolWindows)) diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp index 86cbb4959..2aeea2a74 100644 --- a/src/designer/src/lib/shared/actioneditor.cpp +++ b/src/designer/src/lib/shared/actioneditor.cpp @@ -325,7 +325,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow) void ActionEditor::slotSelectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) { - const bool hasSelection = !selected.indexes().empty(); + const bool hasSelection = !selected.indexes().isEmpty(); #if QT_CONFIG(clipboard) m_actionCopy->setEnabled(hasSelection); m_actionCut->setEnabled(hasSelection); @@ -349,7 +349,7 @@ void ActionEditor::slotCurrentItemChanged(QAction *action) QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector()); - if (action->associatedWidgets().empty()) { + if (action->associatedWidgets().isEmpty()) { // Special case: action not in object tree. Deselect all and set in property editor fw->clearSelection(false); if (oi) @@ -528,7 +528,7 @@ static inline QString textPropertyValue(const QDesignerPropertySheetExtension *s return ps.value(); } -void ActionEditor::editAction(QAction *action) +void ActionEditor::editAction(QAction *action, int column) { if (!action) return; @@ -546,6 +546,24 @@ void ActionEditor::editAction(QAction *action) oldActionData.checkable = action->isCheckable(); dlg.setActionData(oldActionData); + switch (column) { + case qdesigner_internal::ActionModel::NameColumn: + dlg.focusName(); + break; + case qdesigner_internal::ActionModel::TextColumn: + dlg.focusText(); + break; + case qdesigner_internal::ActionModel::ShortCutColumn: + dlg.focusShortcut(); + break; + case qdesigner_internal::ActionModel::CheckedColumn: + dlg.focusCheckable(); + break; + case qdesigner_internal::ActionModel::ToolTipColumn: + dlg.focusTooltip(); + break; + } + if (!dlg.exec()) return; @@ -602,8 +620,9 @@ void ActionEditor::deleteActions(QDesignerFormWindowInterface *fw, const ActionL { // We need a macro even in the case of single action because the commands might cause the // scheduling of other commands (signal slots connections) - const QString description = actions.size() == 1 ? - tr("Remove action '%1'").arg(actions.front()->objectName()) : tr("Remove actions"); + const QString description = actions.size() == 1 + ? tr("Remove action '%1'").arg(actions.constFirst()->objectName()) + : tr("Remove actions"); fw->beginCommand(description); for (QAction *action : actions) { RemoveActionCommand *cmd = new RemoveActionCommand(fw); @@ -644,7 +663,7 @@ void ActionEditor::slotDelete() return; const ActionView::ActionList selection = m_actionView->selectedActions(); - if (selection.empty()) + if (selection.isEmpty()) return; deleteActions(fw, selection); @@ -784,7 +803,7 @@ void ActionEditor::slotCopy() return; const ActionView::ActionList selection = m_actionView->selectedActions(); - if (selection.empty()) + if (selection.isEmpty()) return; copyActions(fw, selection); @@ -797,7 +816,7 @@ void ActionEditor::slotCut() return; const ActionView::ActionList selection = m_actionView->selectedActions(); - if (selection.empty()) + if (selection.isEmpty()) return; copyActions(fw, selection); @@ -826,7 +845,7 @@ void ActionEditor::slotContextMenuRequested(QContextMenuEvent *e, QAction *item) // Associated Widgets if (QAction *action = m_actionView->currentAction()) { const QWidgetList associatedWidgets = ActionModel::associatedWidgets(action); - if (!associatedWidgets.empty()) { + if (!associatedWidgets.isEmpty()) { QMenu *associatedWidgetsSubMenu = menu.addMenu(tr("Used In")); for (QWidget *w : associatedWidgets) { associatedWidgetsSubMenu->addAction(w->objectName(), diff --git a/src/designer/src/lib/shared/actioneditor_p.h b/src/designer/src/lib/shared/actioneditor_p.h index 321dbfb32..2f78887ba 100644 --- a/src/designer/src/lib/shared/actioneditor_p.h +++ b/src/designer/src/lib/shared/actioneditor_p.h @@ -100,7 +100,7 @@ public slots: private slots: void slotCurrentItemChanged(QAction *item); void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void editAction(QAction *item); + void editAction(QAction *item, int column = -1); void editCurrentAction(); void navigateToSlotCurrentAction(); void slotActionChanged(); @@ -117,7 +117,7 @@ private slots: #endif signals: - void itemActivated(QAction *item); + void itemActivated(QAction *item, int column); // Context menu for item or global menu if item == 0. void contextMenuRequested(QMenu *menu, QAction *item); diff --git a/src/designer/src/lib/shared/actionrepository.cpp b/src/designer/src/lib/shared/actionrepository.cpp index 2d91a5f00..6162d02e2 100644 --- a/src/designer/src/lib/shared/actionrepository.cpp +++ b/src/designer/src/lib/shared/actionrepository.cpp @@ -107,7 +107,7 @@ void ActionModel::update(int row) for (int i = 0; i < NumColumns; i++) list += item(row, i); - setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list); + setItems(m_core, actionOfItem(list.constFirst()), m_emptyIcon, list); } void ActionModel::remove(int row) @@ -132,7 +132,7 @@ QModelIndex ActionModel::addAction(QAction *action) } setItems(m_core, action, m_emptyIcon, items); appendRow(items); - return indexFromItem(items.front()); + return indexFromItem(items.constFirst()); } // Find the associated menus and toolbars, ignore toolbuttons @@ -190,7 +190,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, item->setWhatsThis(firstTooltip); // Used const QWidgetList associatedDesignerWidgets = associatedWidgets(action); - const bool used = !associatedDesignerWidgets.empty(); + const bool used = !associatedDesignerWidgets.isEmpty(); item = sl[UsedColumn]; item->setCheckState(used ? Qt::Checked : Qt::Unchecked); if (used) { @@ -308,14 +308,14 @@ static void handleImageDropEvent(const QAbstractItemView *iv, QDropEvent *event, void startActionDrag(QWidget *dragParent, ActionModel *model, const QModelIndexList &indexes, Qt::DropActions supportedActions) { - if (indexes.empty()) + if (indexes.isEmpty()) return; QDrag *drag = new QDrag(dragParent); QMimeData *data = model->mimeData(indexes); drag->setMimeData(data); if (ActionRepositoryMimeData *actionMimeData = qobject_cast<ActionRepositoryMimeData *>(data)) - drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(actionMimeData->actionList().front())); + drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(actionMimeData->actionList().constFirst())); drag->exec(supportedActions); } @@ -392,7 +392,7 @@ void ActionTreeView::currentChanged(const QModelIndex ¤t, const QModelInde void ActionTreeView::slotActivated(const QModelIndex &index) { - emit actionActivated(m_model->actionAt(index)); + emit actionActivated(m_model->actionAt(index), index.column()); } void ActionTreeView::startDrag(Qt::DropActions supportedActions) @@ -499,7 +499,8 @@ ActionView::ActionView(QWidget *parent) : // make it possible for vs integration to reimplement edit action dialog // [which it shouldn't do actually] - connect(m_actionListView, &ActionListView::actionActivated, this, &ActionView::activated); + connect(m_actionListView, &ActionListView::actionActivated, + this, [this](QAction *a) { this->activated(a, -1); }); connect(m_actionTreeView, &ActionTreeView::actionActivated, this, &ActionView::activated); connect(m_actionListView, &ActionListView::currentActionChanged, diff --git a/src/designer/src/lib/shared/actionrepository_p.h b/src/designer/src/lib/shared/actionrepository_p.h index a68b3371f..333093a09 100644 --- a/src/designer/src/lib/shared/actionrepository_p.h +++ b/src/designer/src/lib/shared/actionrepository_p.h @@ -124,7 +124,7 @@ public slots: signals: void actionContextMenuRequested(QContextMenuEvent *event, QAction *); void currentActionChanged(QAction *action); - void actionActivated(QAction *action); + void actionActivated(QAction *action, int column); protected slots: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; @@ -215,7 +215,7 @@ public slots: signals: void contextMenuRequested(QContextMenuEvent *event, QAction *); void currentChanged(QAction *action); - void activated(QAction *action); + void activated(QAction *action, int column); void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); void resourceImageDropped(const QString &data, QAction *action); diff --git a/src/designer/src/lib/shared/connectionedit.cpp b/src/designer/src/lib/shared/connectionedit.cpp index a55465440..8916c4e1c 100644 --- a/src/designer/src/lib/shared/connectionedit.cpp +++ b/src/designer/src/lib/shared/connectionedit.cpp @@ -1371,7 +1371,7 @@ static ConnectionEdit::ConnectionSet findConnectionsOf(const ConnectionEdit::Con void ConnectionEdit::widgetRemoved(QWidget *widget) { // Remove all connections of that widget and its children. - if (m_con_list.empty()) + if (m_con_list.isEmpty()) return; QWidgetList child_list = widget->findChildren<QWidget*>(); @@ -1388,7 +1388,7 @@ void ConnectionEdit::widgetRemoved(QWidget *widget) void ConnectionEdit::objectRemoved(QObject *o) { // Remove all connections of that object and its children (in case of action groups). - if (m_con_list.empty()) + if (m_con_list.isEmpty()) return; QObjectList child_list = o->children(); diff --git a/src/designer/src/lib/shared/dialoggui.cpp b/src/designer/src/lib/shared/dialoggui.cpp index 8c537ab34..613a42143 100644 --- a/src/designer/src/lib/shared/dialoggui.cpp +++ b/src/designer/src/lib/shared/dialoggui.cpp @@ -211,13 +211,13 @@ QString DialogGui::getOpenImageFileName(QWidget *parent, const QString &caption, return QString(); const QStringList selectedFiles = fileDialog.selectedFiles(); - if (selectedFiles.empty()) + if (selectedFiles.isEmpty()) return QString(); if (selectedFilter) *selectedFilter = fileDialog.selectedNameFilter(); - return selectedFiles.front(); + return selectedFiles.constFirst(); #else return getOpenFileName(parent, caption, dir, filter, selectedFilter, options); #endif @@ -232,7 +232,7 @@ QStringList DialogGui::getOpenImageFileNames(QWidget *parent, const QString &cap return QStringList(); const QStringList selectedFiles = fileDialog.selectedFiles(); - if (!selectedFiles.empty() && selectedFilter) + if (!selectedFiles.isEmpty() && selectedFilter) *selectedFilter = fileDialog.selectedNameFilter(); return selectedFiles; diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index 8d4bab6c7..48d6ee488 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -476,7 +476,7 @@ void FormLayoutMenu::populate(QWidget *w, QDesignerFormWindowInterface *fw, Acti { switch (LayoutInfo::managedLayoutType(fw->core(), w)) { case LayoutInfo::Form: - if (!actions.empty() && !actions.back()->isSeparator()) + if (!actions.isEmpty() && !actions.constLast()->isSeparator()) actions.push_back(m_separator1); actions.push_back(m_populateFormAction); actions.push_back(m_separator2); diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index 8c35ea700..6814cd04f 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -446,7 +446,7 @@ void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list) // the signal slot editor are connected to widgetRemoved() and add their // own commands (for example, to delete w's connections) const QString description = widget_list.size() == 1 ? - tr("Delete '%1'").arg(widget_list.front()->objectName()) : tr("Delete"); + tr("Delete '%1'").arg(widget_list.constFirst()->objectName()) : tr("Delete"); commandHistory()->beginMacro(description); for (QWidget *w : qAsConst(widget_list)) { @@ -467,16 +467,16 @@ QMenu *FormWindowBase::createExtensionTaskMenu(QDesignerFormWindowInterface *fw, if (const QDesignerTaskMenuExtension *extTaskMenu = qt_extension<QDesignerTaskMenuExtension*>(em, o)) actions += extTaskMenu->taskActions(); if (const QDesignerTaskMenuExtension *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, QStringLiteral("QDesignerInternalTaskMenuExtension")))) { - if (!actions.empty()) { + if (!actions.isEmpty()) { QAction *a = new QAction(fw); a->setSeparator(true); actions.push_back(a); } actions += intTaskMenu->taskActions(); } - if (actions.empty()) + if (actions.isEmpty()) return nullptr; - if (trailingSeparator && !actions.back()->isSeparator()) { + if (trailingSeparator && !actions.constLast()->isSeparator()) { QAction *a = new QAction(fw); a->setSeparator(true); actions.push_back(a); diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp index 436d5223b..f121f31d6 100644 --- a/src/designer/src/lib/shared/layout.cpp +++ b/src/designer/src/lib/shared/layout.cpp @@ -1143,7 +1143,7 @@ inline QRect expandGeometry(const QRect &rect) template <class GridLikeLayout, int LayoutType, int GridMode> QWidgetList GridLayout<GridLikeLayout, LayoutType, GridMode>::buildGrid(const QWidgetList &widgetList) { - if (widgetList.empty()) + if (widgetList.isEmpty()) return QWidgetList(); // Pixel to cell conversion: diff --git a/src/designer/src/lib/shared/layoutinfo.cpp b/src/designer/src/lib/shared/layoutinfo.cpp index 30cfabfda..d4a3286d0 100644 --- a/src/designer/src/lib/shared/layoutinfo.cpp +++ b/src/designer/src/lib/shared/layoutinfo.cpp @@ -65,7 +65,7 @@ LayoutInfo::Type LayoutInfo::layoutType(const QDesignerFormEditorInterface *core static const QHash<QString, LayoutInfo::Type> &layoutNameTypeMap() { static QHash<QString, LayoutInfo::Type> nameTypeMap; - if (nameTypeMap.empty()) { + if (nameTypeMap.isEmpty()) { nameTypeMap.insert(QStringLiteral("QVBoxLayout"), LayoutInfo::VBox); nameTypeMap.insert(QStringLiteral("QHBoxLayout"), LayoutInfo::HBox); nameTypeMap.insert(QStringLiteral("QGridLayout"), LayoutInfo::Grid); @@ -178,7 +178,7 @@ LayoutInfo::Type LayoutInfo::laidoutWidgetType(const QDesignerFormEditorInterfac // 3) Some child layout (see below comment about Q3GroupBox) const QList<QLayout*> childLayouts = parentLayout->findChildren<QLayout*>(); - if (childLayouts.empty()) + if (childLayouts.isEmpty()) return NoLayout; const QList<QLayout*>::const_iterator lcend = childLayouts.constEnd(); for (QList<QLayout*>::const_iterator it = childLayouts.constBegin(); it != lcend; ++it) { diff --git a/src/designer/src/lib/shared/morphmenu.cpp b/src/designer/src/lib/shared/morphmenu.cpp index ee09dfafd..9f700bb22 100644 --- a/src/designer/src/lib/shared/morphmenu.cpp +++ b/src/designer/src/lib/shared/morphmenu.cpp @@ -228,7 +228,7 @@ QLabel *buddyLabelOf(QDesignerFormWindowInterface *fw, QWidget *w) { using LabelList = QList<QLabel *>; const LabelList labelList = fw->findChildren<QLabel*>(); - if (labelList.empty()) + if (labelList.isEmpty()) return nullptr; const LabelList::const_iterator cend = labelList.constEnd(); for (LabelList::const_iterator it = labelList.constBegin(); it != cend; ++it ) @@ -586,7 +586,7 @@ bool MorphMenu::populateMenu(QWidget *w, QDesignerFormWindowInterface *fw) return false; const QStringList c = MorphWidgetCommand::candidateClasses(fw, w); - if (c.empty()) + if (c.isEmpty()) return false; // Pull up diff --git a/src/designer/src/lib/shared/newactiondialog.cpp b/src/designer/src/lib/shared/newactiondialog.cpp index 676d4a80a..d5380bfcb 100644 --- a/src/designer/src/lib/shared/newactiondialog.cpp +++ b/src/designer/src/lib/shared/newactiondialog.cpp @@ -78,7 +78,7 @@ NewActionDialog::NewActionDialog(ActionEditor *parent) : this, &NewActionDialog::slotResetKeySequence); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - m_ui->editActionText->setFocus(); + focusText(); updateButtons(); QDesignerFormWindowInterface *form = parent->formWindow(); @@ -96,6 +96,31 @@ NewActionDialog::~NewActionDialog() delete m_ui; } +void NewActionDialog::focusName() +{ + m_ui->editObjectName->setFocus(); +} + +void NewActionDialog::focusText() +{ + m_ui->editActionText->setFocus(); +} + +void NewActionDialog::focusTooltip() +{ + m_ui->tooltipEditor->setFocus(); +} + +void NewActionDialog::focusShortcut() +{ + m_ui->keySequenceEdit->setFocus(); +} + +void NewActionDialog::focusCheckable() +{ + m_ui->checkableCheckBox->setFocus(); +} + QString NewActionDialog::actionText() const { return m_ui->editActionText->text(); diff --git a/src/designer/src/lib/shared/newactiondialog_p.h b/src/designer/src/lib/shared/newactiondialog_p.h index 8eddcbe72..f6e3b1dd7 100644 --- a/src/designer/src/lib/shared/newactiondialog_p.h +++ b/src/designer/src/lib/shared/newactiondialog_p.h @@ -89,6 +89,13 @@ public: QString actionText() const; QString actionName() const; +public slots: + void focusName(); + void focusText(); + void focusTooltip(); + void focusShortcut(); + void focusCheckable(); + private slots: void on_editActionText_textEdited(const QString &text); void on_editObjectName_textEdited(const QString &text); diff --git a/src/designer/src/lib/shared/newformwidget.cpp b/src/designer/src/lib/shared/newformwidget.cpp index b3853ae21..32a65c7de 100644 --- a/src/designer/src/lib/shared/newformwidget.cpp +++ b/src/designer/src/lib/shared/newformwidget.cpp @@ -183,7 +183,7 @@ NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent connect(m_ui->profileComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &NewFormWidget::slotDeviceProfileIndexChanged); - if (m_deviceProfiles.empty()) { + if (m_deviceProfiles.isEmpty()) { m_ui->profileComboBox->setEnabled(false); } else { const DeviceProfileList::const_iterator dcend = m_deviceProfiles.constEnd(); @@ -446,7 +446,7 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri void NewFormWidget::loadFrom(const QString &title, const QStringList &nameList, const QString &selectedItem, QTreeWidgetItem *&selectedItemFound) { - if (nameList.empty()) + if (nameList.isEmpty()) return; QTreeWidgetItem *root = new QTreeWidgetItem(m_ui->treeWidget); root->setFlags(root->flags() & ~Qt::ItemIsSelectable); diff --git a/src/designer/src/lib/shared/pluginmanager.cpp b/src/designer/src/lib/shared/pluginmanager.cpp index ddc8cd611..8abe94c12 100644 --- a/src/designer/src/lib/shared/pluginmanager.cpp +++ b/src/designer/src/lib/shared/pluginmanager.cpp @@ -589,7 +589,7 @@ QStringList QDesignerPluginManager::findPlugins(const QString &path) return QStringList(); const QFileInfoList infoList = dir.entryInfoList(QDir::Files); - if (infoList.empty()) + if (infoList.isEmpty()) return QStringList(); // Load symbolic links but make sure all file names are unique as not @@ -738,7 +738,7 @@ void QDesignerPluginManager::ensureInitialized() m_d->clearCustomWidgets(); // Add the static custom widgets const QObjectList staticPluginObjects = QPluginLoader::staticInstances(); - if (!staticPluginObjects.empty()) { + if (!staticPluginObjects.isEmpty()) { const QString staticPluginPath = QCoreApplication::applicationFilePath(); for (QObject *o : staticPluginObjects) m_d->addCustomWidgets(o, staticPluginPath, designerLanguage); diff --git a/src/designer/src/lib/shared/previewconfigurationwidget.cpp b/src/designer/src/lib/shared/previewconfigurationwidget.cpp index f9ddb4b5e..6089f91a6 100644 --- a/src/designer/src/lib/shared/previewconfigurationwidget.cpp +++ b/src/designer/src/lib/shared/previewconfigurationwidget.cpp @@ -63,13 +63,13 @@ enum { SkinComboNoneIndex = 0 }; // find default skins (resources) static const Skins &defaultSkins() { static Skins rc; - if (rc.empty()) { + if (rc.isEmpty()) { const QString skinPath = QLatin1String(skinResourcePathC); QString pattern = QStringLiteral("*."); pattern += QLatin1String(skinExtensionC); const QDir dir(skinPath, pattern); const QFileInfoList list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name); - if (list.empty()) + if (list.isEmpty()) return rc; const QFileInfoList::const_iterator lcend = list.constEnd(); for (QFileInfoList::const_iterator it = list.constBegin(); it != lcend; ++it) @@ -171,7 +171,7 @@ QStringList PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::userS void PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::addUserSkins(const QStringList &files) { - if (files.empty()) + if (files.isEmpty()) return; const QStringList ::const_iterator fcend = files.constEnd(); for (QStringList::const_iterator it = files.constBegin(); it != fcend; ++it) { @@ -281,7 +281,7 @@ int PreviewConfigurationWidget::PreviewConfigurationWidgetPrivate::browseSkin() break; // check: 1) name already there - const QString directory = directories.front(); + const QString directory = directories.constFirst(); const QString name = QFileInfo(directory).baseName(); const int existingIndex = m_ui.m_skinCombo->findText(name); if (existingIndex != -1 && existingIndex != SkinComboNoneIndex && existingIndex != m_browseSkinIndex) { diff --git a/src/designer/src/lib/shared/previewmanager.cpp b/src/designer/src/lib/shared/previewmanager.cpp index 4649901f9..2fbe2e012 100644 --- a/src/designer/src/lib/shared/previewmanager.cpp +++ b/src/designer/src/lib/shared/previewmanager.cpp @@ -772,11 +772,11 @@ QWidget *PreviewManager::showPreview(const QDesignerFormWindowInterface *fw, // If its the first one, position relative to form. // 2nd, attempt to tile right (for comparing styles) or cascade const QSize size = widget->size(); - const bool firstPreview = d->m_previews.empty(); + const bool firstPreview = d->m_previews.isEmpty(); if (firstPreview) { widget->move(fw->mapToGlobal(QPoint(Spacing, Spacing))); } else { - if (QWidget *lastPreview = d->m_previews.back().m_widget) { + if (QWidget *lastPreview = d->m_previews.constLast().m_widget) { QDesktopWidget *desktop = qApp->desktop(); const QRect lastPreviewGeometry = lastPreview->frameGeometry(); const QRect availGeometry = desktop->availableGeometry(lastPreview); @@ -798,7 +798,7 @@ QWidget *PreviewManager::showPreview(const QDesignerFormWindowInterface *fw, QWidget *PreviewManager::raise(const QDesignerFormWindowInterface *fw, const PreviewConfiguration &pc) { using PreviewDataList = PreviewManagerPrivate::PreviewDataList; - if (d->m_previews.empty()) + if (d->m_previews.isEmpty()) return nullptr; // find matching window @@ -816,7 +816,7 @@ QWidget *PreviewManager::raise(const QDesignerFormWindowInterface *fw, const Pre void PreviewManager::closeAllPreviews() { - if (!d->m_previews.empty()) { + if (!d->m_previews.isEmpty()) { d->m_updateBlocked = true; d->m_activePreview = nullptr; for (auto it = d->m_previews.constBegin(), cend = d->m_previews.constEnd(); it != cend ;++it) { @@ -843,7 +843,7 @@ void PreviewManager::updatePreviewClosed(QWidget *w) ++it; } } - if (d->m_previews.empty()) + if (d->m_previews.isEmpty()) emit lastPreviewClosed(); } diff --git a/src/designer/src/lib/shared/promotionmodel.cpp b/src/designer/src/lib/shared/promotionmodel.cpp index c2dd25523..37136ced6 100644 --- a/src/designer/src/lib/shared/promotionmodel.cpp +++ b/src/designer/src/lib/shared/promotionmodel.cpp @@ -129,7 +129,7 @@ namespace qdesigner_internal { // Set the item index as user data on the item. const PromotedClasses promotedClasses = m_core->promotion()->promotedClasses(); - if (promotedClasses.empty()) + if (promotedClasses.isEmpty()) return; const QSet<QString> usedPromotedClasses = m_core->promotion()->referencedPromotedClassNames(); @@ -143,7 +143,7 @@ namespace qdesigner_internal { if (baseClass != it->baseItem) { baseClass = it->baseItem; const StandardItemList baseRow = baseModelRow(it->baseItem); - baseItem = baseRow.front(); + baseItem = baseRow.constFirst(); appendRow(baseRow); } Q_ASSERT(baseItem); @@ -187,7 +187,7 @@ namespace qdesigner_internal { QModelIndex PromotionModel::indexOfClass(const QString &className) const { const StandardItemList matches = findItems (className, Qt::MatchFixedString|Qt::MatchCaseSensitive|Qt::MatchRecursive); - return matches.empty() ? QModelIndex() : indexFromItem (matches.front()); + return matches.isEmpty() ? QModelIndex() : indexFromItem (matches.constFirst()); } } // namespace qdesigner_internal diff --git a/src/designer/src/lib/shared/promotiontaskmenu.cpp b/src/designer/src/lib/shared/promotiontaskmenu.cpp index bb5631d32..33554707a 100644 --- a/src/designer/src/lib/shared/promotiontaskmenu.cpp +++ b/src/designer/src/lib/shared/promotiontaskmenu.cpp @@ -111,7 +111,7 @@ void PromotionTaskMenu::setDemoteLabel(const QString &demoteLabel) PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDesignerFormWindowInterface *formWindow) { // clear out old - if (!m_promotionActions.empty()) { + if (!m_promotionActions.isEmpty()) { qDeleteAll(m_promotionActions); m_promotionActions.clear(); } @@ -122,7 +122,7 @@ PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDe // Check for a homogenous selection const PromotionSelectionList promotionSelection = promotionSelectionList(formWindow); - if (promotionSelection.empty()) + if (promotionSelection.isEmpty()) return NoHomogenousSelection; QDesignerFormEditorInterface *core = formWindow->core(); @@ -137,7 +137,7 @@ PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDe // figure out candidates const QString baseClassName = WidgetFactory::classNameOf(core, m_widget); const WidgetDataBaseItemList candidates = promotionCandidates(core->widgetDataBase(), baseClassName ); - if (candidates.empty()) { + if (candidates.isEmpty()) { // Is this thing promotable at all? return QDesignerPromotionDialog::baseClassNames(core->promotion()).contains(baseClassName) ? CanPromote : NotApplicable; } @@ -230,7 +230,7 @@ void PromotionTaskMenu::slotDemoteFromCustomWidget() { QDesignerFormWindowInterface *fw = formWindow(); const PromotionSelectionList promotedWidgets = promotionSelectionList(fw); - Q_ASSERT(!promotedWidgets.empty() && isPromoted(fw->core(), promotedWidgets.front())); + Q_ASSERT(!promotedWidgets.isEmpty() && isPromoted(fw->core(), promotedWidgets.constFirst())); // ### use the undo stack DemoteFromCustomWidgetCommand *cmd = new DemoteFromCustomWidgetCommand(fw); diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp index 7346b98f3..59c27f5f5 100644 --- a/src/designer/src/lib/shared/qdesigner_command.cpp +++ b/src/designer/src/lib/shared/qdesigner_command.cpp @@ -235,7 +235,7 @@ void InsertWidgetCommand::refreshBuddyLabels() using LabelList = QList<QLabel *>; const LabelList label_list = formWindow()->findChildren<QLabel*>(); - if (label_list.empty()) + if (label_list.isEmpty()) return; const QString buddyProperty = QStringLiteral("buddy"); @@ -350,7 +350,7 @@ void ManageWidgetCommandHelper::init(const QDesignerFormWindowInterface *fw, QWi m_managedChildren.clear(); const QWidgetList children = m_widget->findChildren<QWidget *>(); - if (children.empty()) + if (children.isEmpty()) return; m_managedChildren.reserve(children.size()); @@ -370,7 +370,7 @@ void ManageWidgetCommandHelper::manage(QDesignerFormWindowInterface *fw) { // Manage the managed children after parent fw->manageWidget(m_widget); - if (!m_managedChildren.empty()) { + if (!m_managedChildren.isEmpty()) { const WidgetVector::const_iterator lcend = m_managedChildren.constEnd(); for (WidgetVector::const_iterator it = m_managedChildren.constBegin(); it != lcend; ++it) fw->manageWidget(*it); @@ -380,7 +380,7 @@ void ManageWidgetCommandHelper::manage(QDesignerFormWindowInterface *fw) void ManageWidgetCommandHelper::unmanage(QDesignerFormWindowInterface *fw) { // Unmanage the managed children first - if (!m_managedChildren.empty()) { + if (!m_managedChildren.isEmpty()) { const WidgetVector::const_iterator lcend = m_managedChildren.constEnd(); for (WidgetVector::const_iterator it = m_managedChildren.constBegin(); it != lcend; ++it) fw->unmanageWidget(*it); @@ -665,7 +665,7 @@ DemoteFromCustomWidgetCommand::DemoteFromCustomWidgetCommand void DemoteFromCustomWidgetCommand::init(const WidgetList &promoted) { - m_promote_cmd.init(promoted, promotedCustomClassName(core(), promoted.front())); + m_promote_cmd.init(promoted, promotedCustomClassName(core(), promoted.constFirst())); } void DemoteFromCustomWidgetCommand::redo() @@ -695,7 +695,7 @@ void CursorSelectionState::save(const QDesignerFormWindowInterface *formWindow) void CursorSelectionState::restore(QDesignerFormWindowInterface *formWindow) const { - if (m_selection.empty()) { + if (m_selection.isEmpty()) { formWindow->clearSelection(true); } else { // Select current as last @@ -2692,7 +2692,7 @@ void RemoveActionCommand::redo() core()->actionEditor()->setFormWindow(fw); core()->actionEditor()->unmanageAction(m_action); - if (!m_actionData.empty()) + if (!m_actionData.isEmpty()) core()->objectInspector()->setFormWindow(fw); } @@ -2702,7 +2702,7 @@ void RemoveActionCommand::undo() core()->actionEditor()->manageAction(m_action); for (const ActionDataItem &item : qAsConst(m_actionData)) item.widget->insertAction(item.before, m_action); - if (!m_actionData.empty()) + if (!m_actionData.isEmpty()) core()->objectInspector()->setFormWindow(formWindow()); } diff --git a/src/designer/src/lib/shared/qdesigner_dnditem.cpp b/src/designer/src/lib/shared/qdesigner_dnditem.cpp index db714d950..a4add41ff 100644 --- a/src/designer/src/lib/shared/qdesigner_dnditem.cpp +++ b/src/designer/src/lib/shared/qdesigner_dnditem.cpp @@ -206,7 +206,7 @@ Qt::DropAction QDesignerMimeData::proposedDropAction() const Qt::DropAction QDesignerMimeData::execDrag(const QDesignerDnDItems &items, QWidget * dragSource) { - if (items.empty()) + if (items.isEmpty()) return Qt::IgnoreAction; QDrag *drag = new QDrag(dragSource); diff --git a/src/designer/src/lib/shared/qdesigner_dockwidget.cpp b/src/designer/src/lib/shared/qdesigner_dockwidget.cpp index 278f9b829..d29fcaba2 100644 --- a/src/designer/src/lib/shared/qdesigner_dockwidget.cpp +++ b/src/designer/src/lib/shared/qdesigner_dockwidget.cpp @@ -35,11 +35,23 @@ #include <QtDesigner/qextensionmanager.h> #include <QtDesigner/abstractformwindowcursor.h> +#include <qdesigner_propertysheet_p.h> + #include <QtWidgets/qmainwindow.h> #include <QtWidgets/qlayout.h> QT_BEGIN_NAMESPACE +bool QDockWidgetPropertySheet::isEnabled(int index) const +{ + const QString &name = propertyName(index); + if (name == QLatin1String("dockWidgetArea")) + return static_cast<const QDesignerDockWidget *>(object())->docked(); + if (name == QLatin1String("docked")) + return static_cast<const QDesignerDockWidget *>(object())->inMainWindow(); + return QDesignerPropertySheet::isEnabled(index); +} + QDesignerDockWidget::QDesignerDockWidget(QWidget *parent) : QDockWidget(parent) { diff --git a/src/designer/src/lib/shared/qdesigner_dockwidget_p.h b/src/designer/src/lib/shared/qdesigner_dockwidget_p.h index 7db332495..a39ece90d 100644 --- a/src/designer/src/lib/shared/qdesigner_dockwidget_p.h +++ b/src/designer/src/lib/shared/qdesigner_dockwidget_p.h @@ -41,6 +41,9 @@ #define QDESIGNER_DOCKWIDGET_H #include "shared_global_p.h" + +#include <qdesigner_propertysheet_p.h> + #include <QtWidgets/qdockwidget.h> QT_BEGIN_NAMESPACE @@ -50,8 +53,8 @@ class QDesignerFormWindowInterface; class QDESIGNER_SHARED_EXPORT QDesignerDockWidget: public QDockWidget { Q_OBJECT - Q_PROPERTY(Qt::DockWidgetArea dockWidgetArea READ dockWidgetArea WRITE setDockWidgetArea DESIGNABLE docked STORED false) - Q_PROPERTY(bool docked READ docked WRITE setDocked DESIGNABLE inMainWindow STORED false) + Q_PROPERTY(Qt::DockWidgetArea dockWidgetArea READ dockWidgetArea WRITE setDockWidgetArea DESIGNABLE true STORED false) + Q_PROPERTY(bool docked READ docked WRITE setDocked DESIGNABLE true STORED false) public: QDesignerDockWidget(QWidget *parent = nullptr); ~QDesignerDockWidget() override; @@ -69,6 +72,18 @@ private: QMainWindow *findMainWindow() const; }; +class QDESIGNER_SHARED_EXPORT QDockWidgetPropertySheet : public QDesignerPropertySheet +{ + Q_OBJECT +public: + using QDesignerPropertySheet::QDesignerPropertySheet; + + bool isEnabled(int index) const override; +}; + +using QDockWidgetPropertySheetFactory = + QDesignerPropertySheetFactory<QDockWidget, QDockWidgetPropertySheet>; + QT_END_NAMESPACE #endif // QDESIGNER_DOCKWIDGET_H diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index 260316381..3b25125af 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -226,7 +226,7 @@ static bool readDomEnumerationValue(const DomProperty *p, void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - if (properties.empty()) + if (properties.isEmpty()) return; const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o); diff --git a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index 7c44ec4f7..f1a15c48e 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -103,7 +103,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for using LabelList = QList<QLabel *>; const LabelList label_list = form->findChildren<QLabel*>(); - if (label_list.empty()) + if (label_list.isEmpty()) return; const QString buddyProperty = QStringLiteral("buddy"); diff --git a/src/designer/src/lib/shared/qdesigner_introspection.cpp b/src/designer/src/lib/shared/qdesigner_introspection.cpp index 3001d6b76..344fed976 100644 --- a/src/designer/src/lib/shared/qdesigner_introspection.cpp +++ b/src/designer/src/lib/shared/qdesigner_introspection.cpp @@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE // Qt Implementation static QStringList byteArrayListToStringList(const QByteArrayList &l) { - if (l.empty()) + if (l.isEmpty()) return QStringList(); QStringList rc; for (const QByteArray &b : l) diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp index 93371ac06..2e62aab7f 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp @@ -36,7 +36,7 @@ QT_BEGIN_NAMESPACE static QList<QByteArray> stringListToByteArray(const QStringList &l) { - if (l.empty()) + if (l.isEmpty()) return QList<QByteArray>(); QList<QByteArray> rc; const QStringList::const_iterator cend = l.constEnd(); diff --git a/src/designer/src/lib/shared/qdesigner_menu.cpp b/src/designer/src/lib/shared/qdesigner_menu.cpp index 88668ea45..c56a4517b 100644 --- a/src/designer/src/lib/shared/qdesigner_menu.cpp +++ b/src/designer/src/lib/shared/qdesigner_menu.cpp @@ -708,7 +708,7 @@ QDesignerMenu::ActionDragCheck QDesignerMenu::checkAction(QAction *action) const void QDesignerMenu::dragEnterEvent(QDragEnterEvent *event) { const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); - if (!d || d->actionList().empty()) { + if (!d || d->actionList().isEmpty()) { event->ignore(); return; } @@ -740,7 +740,7 @@ void QDesignerMenu::dragMoveEvent(QDragMoveEvent *event) } const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); - if (!d || d->actionList().empty()) { + if (!d || d->actionList().isEmpty()) { event->ignore(); return; } @@ -785,7 +785,7 @@ void QDesignerMenu::dropEvent(QDropEvent *event) QDesignerFormWindowInterface *fw = formWindow(); const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); - if (!d || d->actionList().empty()) { + if (!d || d->actionList().isEmpty()) { event->ignore(); return; } diff --git a/src/designer/src/lib/shared/qdesigner_menubar.cpp b/src/designer/src/lib/shared/qdesigner_menubar.cpp index e212eff82..287a2fc3c 100644 --- a/src/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/src/designer/src/lib/shared/qdesigner_menubar.cpp @@ -604,7 +604,7 @@ QDesignerMenuBar::ActionDragCheck QDesignerMenuBar::checkAction(QAction *action) void QDesignerMenuBar::dragEnterEvent(QDragEnterEvent *event) { const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); - if (!d || d->actionList().empty()) { + if (!d || d->actionList().isEmpty()) { event->ignore(); return; } @@ -629,7 +629,7 @@ void QDesignerMenuBar::dragEnterEvent(QDragEnterEvent *event) void QDesignerMenuBar::dragMoveEvent(QDragMoveEvent *event) { const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData()); - if (!d || d->actionList().empty()) { + if (!d || d->actionList().isEmpty()) { event->ignore(); return; } diff --git a/src/designer/src/lib/shared/qdesigner_objectinspector.cpp b/src/designer/src/lib/shared/qdesigner_objectinspector.cpp index e07504259..c672dca70 100644 --- a/src/designer/src/lib/shared/qdesigner_objectinspector.cpp +++ b/src/designer/src/lib/shared/qdesigner_objectinspector.cpp @@ -50,7 +50,7 @@ void Selection::clear() bool Selection::empty() const { - return managed.empty() && unmanaged.empty() && objects.empty(); + return managed.isEmpty() && unmanaged.isEmpty() && objects.isEmpty(); } QObjectList Selection::selection() const diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp index 2d8169960..08b2848fd 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp @@ -48,7 +48,7 @@ namespace { // Return a set of on-promotable classes const QSet<QString> &nonPromotableClasses() { static QSet<QString> rc; - if (rc.empty()) { + if (rc.isEmpty()) { rc.insert(QStringLiteral("Line")); rc.insert(QStringLiteral("QAction")); rc.insert(QStringLiteral("Spacer")); @@ -225,7 +225,7 @@ namespace qdesigner_internal { // convert map into list. PromotedClasses rc; - if (baseClassPromotedMap.empty()) + if (baseClassPromotedMap.isEmpty()) return rc; const BaseClassPromotedMap::const_iterator bcend = baseClassPromotedMap.constEnd(); @@ -262,7 +262,7 @@ namespace qdesigner_internal { // check the scratchpad of the widget box if (QDesignerWidgetBoxInterface *widgetBox = m_core->widgetBox()) { const QStringList scratchPadClasses = getScratchPadClasses(widgetBox); - if (!scratchPadClasses.empty()) { + if (!scratchPadClasses.isEmpty()) { // Check whether these are actually promoted QDesignerWidgetDataBaseInterface *widgetDataBase = m_core->widgetDataBase(); QStringList::const_iterator cend = scratchPadClasses.constEnd(); diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp index 7058b0c81..1ec5cd9ae 100644 --- a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp @@ -290,7 +290,7 @@ namespace qdesigner_internal { const QStringList &QDesignerPromotionDialog::baseClassNames(const QDesignerPromotionInterface *promotion) { using WidgetDataBaseItemList = QList<QDesignerWidgetDataBaseItemInterface *>; static QStringList rc; - if (rc.empty()) { + if (rc.isEmpty()) { // Convert the item list into a string list. const WidgetDataBaseItemList dbItems = promotion->promotionBaseClasses(); const WidgetDataBaseItemList::const_iterator cend = dbItems.constEnd(); @@ -351,7 +351,7 @@ namespace qdesigner_internal { QDesignerWidgetDataBaseItemInterface *QDesignerPromotionDialog::databaseItemAt(const QItemSelection &selected, unsigned &flags) const { flags = 0; const QModelIndexList indexes = selected.indexes(); - if (indexes.empty()) + if (indexes.isEmpty()) return nullptr; const PromotionModel::ModelData data = m_model->modelData(indexes.constFirst()); QDesignerWidgetDataBaseItemInterface *dbItem = data.promotedItem; diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 8b564ab6f..eab11e033 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -646,7 +646,7 @@ PropertyHelper::PropertyHelper(QObject* object, m_objectType = OT_Widget; } else { if (const QAction *action = qobject_cast<const QAction *>(m_object)) - m_objectType = action->associatedWidgets().empty() ? OT_FreeAction : OT_AssociatedAction; + m_objectType = action->associatedWidgets().isEmpty() ? OT_FreeAction : OT_AssociatedAction; } if(debugPropertyCommands) @@ -982,7 +982,7 @@ bool PropertyListCommand::add(QObject *object, const QString &propertyName) const PropertyDescription description(propertyName, sheet, index); - if (m_propertyHelperList.empty()) { + if (m_propertyHelperList.isEmpty()) { // first entry m_propertyDescription = description; } else { @@ -1018,7 +1018,7 @@ bool PropertyListCommand::initList(const QObjectList &list, const QString &aprop add(o, apropertyName); } - return !propertyHelperList().empty(); + return !propertyHelperList().isEmpty(); } diff --git a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp index 3a26553fd..69f1cdf87 100644 --- a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp @@ -49,7 +49,7 @@ using PropertyNameTypeMap = QHash<QString, StringPropertyParameters>; static const PropertyNameTypeMap &stringPropertyTypes() { static PropertyNameTypeMap propertyNameTypeMap; - if (propertyNameTypeMap.empty()) { + if (propertyNameTypeMap.isEmpty()) { const StringPropertyParameters richtext(ValidationRichText, true); // Accessibility. Both are texts the narrator reads propertyNameTypeMap.insert(QStringLiteral("accessibleDescription"), richtext); diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index eafc0de4f..5ec212ec3 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -470,7 +470,7 @@ QString QDesignerPropertySheetPrivate::transformLayoutPropertyName(int index) co { using TypeNameMap = QMap<QDesignerPropertySheet::PropertyType, QString>; static TypeNameMap typeNameMap; - if (typeNameMap.empty()) { + if (typeNameMap.isEmpty()) { typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutObjectName, QStringLiteral("objectName")); typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutLeftMargin, QStringLiteral("leftMargin")); typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutTopMargin, QStringLiteral("topMargin")); @@ -519,7 +519,7 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromNam { typedef QHash<QString, PropertyType> PropertyTypeHash; static PropertyTypeHash propertyTypeHash; - if (propertyTypeHash.empty()) { + if (propertyTypeHash.isEmpty()) { propertyTypeHash.insert(QLatin1String(layoutObjectNameC), PropertyLayoutObjectName); propertyTypeHash.insert(QLatin1String(layoutLeftMarginC), PropertyLayoutLeftMargin); propertyTypeHash.insert(QLatin1String(layoutTopMarginC), PropertyLayoutTopMargin); @@ -676,7 +676,7 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) using ByteArrayList = QList<QByteArray>; const ByteArrayList names = object->dynamicPropertyNames(); - if (!names.empty()) { + if (!names.isEmpty()) { const ByteArrayList::const_iterator cend = names.constEnd(); for (ByteArrayList::const_iterator it = names.constBegin(); it != cend; ++it) { const char* cName = it->constData(); diff --git a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp index 2f003cf6c..9500f0673 100644 --- a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -120,7 +120,7 @@ QTabBar *QTabWidgetEventFilter::tabBar() const if (!m_cachedTabBar) { const QList<QTabBar *> tabBars = m_tabWidget->findChildren<QTabBar *>(); Q_ASSERT(tabBars.size() == 1); - m_cachedTabBar = tabBars.front(); + m_cachedTabBar = tabBars.constFirst(); } return m_cachedTabBar; @@ -406,7 +406,7 @@ QTabWidgetPropertySheet::TabWidgetProperty QTabWidgetPropertySheet::tabWidgetPro { using TabWidgetPropertyHash = QHash<QString, TabWidgetProperty>; static TabWidgetPropertyHash tabWidgetPropertyHash; - if (tabWidgetPropertyHash.empty()) { + if (tabWidgetPropertyHash.isEmpty()) { tabWidgetPropertyHash.insert(QLatin1String(currentTabTextKey), PropertyCurrentTabText); tabWidgetPropertyHash.insert(QLatin1String(currentTabNameKey), PropertyCurrentTabName); tabWidgetPropertyHash.insert(QLatin1String(currentTabIconKey), PropertyCurrentTabIcon); diff --git a/src/designer/src/lib/shared/qdesigner_toolbar.cpp b/src/designer/src/lib/shared/qdesigner_toolbar.cpp index 28c2ca285..840d99a57 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -138,7 +138,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) } // Append separator - if (actions.empty() || !actions.back()->isSeparator()) { + if (actions.isEmpty() || !actions.constLast()->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Append Separator"), nullptr); itemData.setValue(static_cast<QAction*>(nullptr)); newSeperatorAct->setData(itemData); @@ -448,7 +448,8 @@ QRect ToolBarEventFilter::freeArea(const QToolBar *tb) { QRect rc = QRect(QPoint(0, 0), tb->size()); const ActionList actionList = tb->actions(); - QRect exclusionRectangle = actionList.empty() ? handleArea(tb) : tb->actionGeometry(actionList.back()); + QRect exclusionRectangle = actionList.isEmpty() + ? handleArea(tb) : tb->actionGeometry(actionList.constLast()); switch (tb->orientation()) { case Qt::Horizontal: switch (tb->layoutDirection()) { diff --git a/src/designer/src/lib/shared/qdesigner_toolbox.cpp b/src/designer/src/lib/shared/qdesigner_toolbox.cpp index f0c0dc726..3a7ed6307 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbox.cpp @@ -256,7 +256,7 @@ QToolBoxWidgetPropertySheet::ToolBoxProperty QToolBoxWidgetPropertySheet::toolBo { using ToolBoxPropertyHash = QHash<QString, ToolBoxProperty>; static ToolBoxPropertyHash toolBoxPropertyHash; - if (toolBoxPropertyHash.empty()) { + if (toolBoxPropertyHash.isEmpty()) { toolBoxPropertyHash.insert(QLatin1String(currentItemTextKey), PropertyCurrentItemText); toolBoxPropertyHash.insert(QLatin1String(currentItemNameKey), PropertyCurrentItemName); toolBoxPropertyHash.insert(QLatin1String(currentItemIconKey), PropertyCurrentItemIcon); diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index a7c4fdd72..40b7d8464 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -198,7 +198,7 @@ namespace qdesigner_internal QString DesignerMetaFlags::toString(int value, SerializationMode sm) const { const QStringList flagIds = flags(value); - if (flagIds.empty()) + if (flagIds.isEmpty()) return QString(); const QChar delimiter = QLatin1Char('|'); diff --git a/src/designer/src/lib/shared/qlayout_widget.cpp b/src/designer/src/lib/shared/qlayout_widget.cpp index 852002838..52965171f 100644 --- a/src/designer/src/lib/shared/qlayout_widget.cpp +++ b/src/designer/src/lib/shared/qlayout_widget.cpp @@ -217,7 +217,7 @@ static bool removeEmptyCellsOnGrid(GridLikeLayout *grid, const QRect &area) } } // remove, starting from last - if (!indexesToBeRemoved.empty()) { + if (!indexesToBeRemoved.isEmpty()) { std::stable_sort(indexesToBeRemoved.begin(), indexesToBeRemoved.end()); for (int i = indexesToBeRemoved.size() - 1; i >= 0; i--) delete grid->takeAt(indexesToBeRemoved[i]); @@ -979,7 +979,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const void GridLayoutHelper::popState(const QDesignerFormEditorInterface *core, QWidget *widgetWithManagedLayout) { - Q_ASSERT(!m_states.empty()); + Q_ASSERT(!m_states.isEmpty()); const GridLayoutState state = m_states.pop(); state.applyToLayout(core, widgetWithManagedLayout); } @@ -1137,7 +1137,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const void FormLayoutHelper::popState(const QDesignerFormEditorInterface *core, QWidget *widgetWithManagedLayout) { QFormLayout *formLayout = qobject_cast<QFormLayout *>(LayoutInfo::managedLayout(core, widgetWithManagedLayout)); - Q_ASSERT(!m_states.empty() && formLayout); + Q_ASSERT(!m_states.isEmpty() && formLayout); const FormLayoutState storedState = m_states.pop(); const FormLayoutState currentState = state(formLayout); diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index 705d7b608..3d79379b2 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -224,7 +224,7 @@ void QSimpleResource::handleDomCustomWidgets(const QDesignerFormEditorInterface // (derived first, max depth: promoted custom plugin = 2) for (int iteration = 0; iteration < 2; iteration++) { addCustomWidgetsToWidgetDatabase(core, custom_widget_list); - if (custom_widget_list.empty()) + if (custom_widget_list.isEmpty()) return; } // Oops, there are classes left whose base class could not be found. @@ -250,7 +250,7 @@ FormBuilderClipboard::FormBuilderClipboard(QWidget *w) bool FormBuilderClipboard::empty() const { - return m_widgets.empty() && m_actions.empty(); + return m_widgets.isEmpty() && m_actions.isEmpty(); } } diff --git a/src/designer/src/lib/shared/qtresourcemodel.cpp b/src/designer/src/lib/shared/qtresourcemodel.cpp index 1586fcf44..7801cf580 100644 --- a/src/designer/src/lib/shared/qtresourcemodel.cpp +++ b/src/designer/src/lib/shared/qtresourcemodel.cpp @@ -169,7 +169,7 @@ const QByteArray *QtResourceModelPrivate::createResource(const QString &path, QS *errorCount = library.failedResources().size(); *contents = resMap.keys(); - if (resMap.empty()) + if (resMap.isEmpty()) break; buffer.close(); diff --git a/src/designer/src/lib/shared/shared_settings.cpp b/src/designer/src/lib/shared/shared_settings.cpp index b759555bd..2800e89c5 100644 --- a/src/designer/src/lib/shared/shared_settings.cpp +++ b/src/designer/src/lib/shared/shared_settings.cpp @@ -90,7 +90,7 @@ Grid QDesignerSharedSettings::defaultGrid() const Grid grid; const QVariantMap defaultGridMap = m_settings->value(QLatin1String(defaultGridKey), QVariantMap()).toMap(); - if (!defaultGridMap.empty()) + if (!defaultGridMap.isEmpty()) grid.fromVariantMap(defaultGridMap); return grid; } @@ -103,7 +103,7 @@ void QDesignerSharedSettings::setDefaultGrid(const Grid &grid) const QStringList &QDesignerSharedSettings::defaultFormTemplatePaths() { static QStringList rc; - if (rc.empty()) { + if (rc.isEmpty()) { // Ensure default form template paths const QString templatePath = QStringLiteral("/templates"); // home @@ -300,7 +300,7 @@ QDesignerSharedSettings::DeviceProfileList QDesignerSharedSettings::deviceProfil { DeviceProfileList rc; const QStringList xmls = deviceProfileXml(); - if (xmls.empty()) + if (xmls.isEmpty()) return rc; // De-serialize QString errorMessage; diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp index 5c0d9e1fe..9b7575177 100644 --- a/src/designer/src/lib/shared/signalslotdialog.cpp +++ b/src/designer/src/lib/shared/signalslotdialog.cpp @@ -270,7 +270,7 @@ void SignaturePanel::slotAdd() newSlot += QString::number(i); // Always add number, Avoid setting 'slot' for first entry newSlot += QLatin1Char('('); // check for function name independent of parameters - if (m_model->findItems(newSlot, Qt::MatchStartsWith, 0).empty()) { + if (m_model->findItems(newSlot, Qt::MatchStartsWith, 0).isEmpty()) { newSlot += QLatin1Char(')'); QStandardItem * item = createEditableItem(newSlot); m_model->appendRow(item); @@ -290,13 +290,13 @@ int SignaturePanel::count(const QString &signature) const void SignaturePanel::slotRemove() { const QModelIndexList selectedIndexes = m_listView->selectionModel()->selectedIndexes (); - if (selectedIndexes.empty()) + if (selectedIndexes.isEmpty()) return; closeEditor(); // scroll to previous - if (const int row = selectedIndexes.front().row()) - m_listView->setCurrentIndex (selectedIndexes.front().sibling(row - 1, 0)); + if (const int row = selectedIndexes.constFirst().row()) + m_listView->setCurrentIndex (selectedIndexes.constFirst().sibling(row - 1, 0)); for (int i = selectedIndexes.size() - 1; i >= 0; i--) qDeleteAll(m_model->takeRow(selectedIndexes[i].row())); @@ -304,7 +304,7 @@ void SignaturePanel::slotRemove() void SignaturePanel::slotSelectionChanged(const QItemSelection &selected, const QItemSelection &) { - m_removeButton->setEnabled(!selected.indexes().empty()); + m_removeButton->setEnabled(!selected.indexes().isEmpty()); } void SignaturePanel::setData(const SignalSlotDialogData &d) diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp index 88e8841b6..e78cb81b4 100644 --- a/src/designer/src/lib/shared/textpropertyeditor.cpp +++ b/src/designer/src/lib/shared/textpropertyeditor.cpp @@ -259,7 +259,7 @@ namespace qdesigner_internal { break; case ValidationURL: { static QStringList urlCompletions; - if (urlCompletions.empty()) { + if (urlCompletions.isEmpty()) { urlCompletions.push_back(QStringLiteral("about:blank")); urlCompletions.push_back(QStringLiteral("http://")); urlCompletions.push_back(QStringLiteral("http://www.")); diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp index 5fecd4c98..8c6382112 100644 --- a/src/designer/src/lib/shared/widgetdatabase.cpp +++ b/src/designer/src/lib/shared/widgetdatabase.cpp @@ -373,7 +373,7 @@ void WidgetDataBase::loadPlugins() unsigned replacedPlugins = 0; unsigned addedPlugins = 0; unsigned removedPlugins = 0; - if (!pluginList.empty()) { + if (!pluginList.isEmpty()) { ItemList::const_iterator cend = pluginList.constEnd(); for (ItemList::const_iterator it = pluginList.constBegin();it != cend; ++it ) { QDesignerWidgetDataBaseItemInterface* pluginItem = *it; @@ -399,7 +399,7 @@ void WidgetDataBase::loadPlugins() } } // 4) remove classes that have not been matched. The stored indexes become invalid while deleting. - if (!existingCustomClasses.empty()) { + if (!existingCustomClasses.isEmpty()) { NameIndexMap::const_iterator cend = existingCustomClasses.constEnd(); for (NameIndexMap::const_iterator it = existingCustomClasses.constBegin();it != cend; ++it ) { const int index = indexOfClassName(it.key()); @@ -503,7 +503,7 @@ static inline bool suitableForNewForm(const QString &className) QStringList WidgetDataBase::formWidgetClasses(const QDesignerFormEditorInterface *core) { static QStringList rc; - if (rc.empty()) { + if (rc.isEmpty()) { const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase(); const int widgetCount = wdb->count(); for (int i = 0; i < widgetCount; i++) { diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index b723b7a34..04e3fd1de 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -219,7 +219,7 @@ QWidget *QAbstractFormBuilder::create(DomUI *ui, QWidget *parentWidget) if (QWidget *widget = create(ui_widget, parentWidget)) { // Reparent button groups that were actually created to main container for them to be found in the signal/slot part const ButtonGroupHash &buttonGroups = d->buttonGroups(); - if (!buttonGroups.empty()) { + if (!buttonGroups.isEmpty()) { const ButtonGroupHash::const_iterator cend = buttonGroups.constEnd(); for (ButtonGroupHash::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) if (it.value().second) @@ -297,7 +297,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge } const auto &addActions = ui_widget->elementAddAction(); - if (!addActions.empty()) { + if (!addActions.isEmpty()) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomActionRef *ui_action_ref : addActions) { const QString name = ui_action_ref->attributeName(); @@ -881,7 +881,7 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout const DomSpacer *ui_spacer = ui_layoutItem->elementSpacer(); const auto &spacerProperties = ui_spacer->elementProperty(); - if (!spacerProperties.empty()) { + if (!spacerProperties.isEmpty()) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomProperty *p : spacerProperties) { const QVariant v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p); // ### remove me @@ -959,27 +959,7 @@ QVariant QAbstractFormBuilder::toVariant(const QMetaObject *meta, DomProperty *p void QAbstractFormBuilder::setupColorGroup(QPalette &palette, QPalette::ColorGroup colorGroup, DomColorGroup *group) { - // old format - const auto &colors = group->elementColor(); - for (int role = 0; role < colors.size(); ++role) { - const DomColor *color = colors.at(role); - const QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); - palette.setColor(colorGroup, QPalette::ColorRole(role), c); - } - - // new format - const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); - - const auto colorRoles = group->elementColorRole(); - for (const DomColorRole *colorRole : colorRoles) { - if (colorRole->hasAttributeRole()) { - const int r = colorRole_enum.keyToValue(colorRole->attributeRole().toLatin1()); - if (r != -1) { - const QBrush br = setupBrush(colorRole->elementBrush()); - palette.setBrush(colorGroup, static_cast<QPalette::ColorRole>(r), br); - } - } - } + QFormBuilderExtra::setupColorGroup(&palette, colorGroup, group); } /*! @@ -987,26 +967,8 @@ void QAbstractFormBuilder::setupColorGroup(QPalette &palette, QPalette::ColorGro */ DomColorGroup *QAbstractFormBuilder::saveColorGroup(const QPalette &palette) { - - const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); - - DomColorGroup *group = new DomColorGroup(); - QVector<DomColorRole *> colorRoles; - - const uint mask = palette.resolve(); - for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) { - if (mask & (1 << role)) { - const QBrush &br = palette.brush(QPalette::ColorRole(role)); - - DomColorRole *colorRole = new DomColorRole(); - colorRole->setElementBrush(saveBrush(br)); - colorRole->setAttributeRole(QLatin1String(colorRole_enum.valueToKey(role))); - colorRoles.append(colorRole); - } - } - - group->setElementColorRole(colorRoles); - return group; + return QFormBuilderExtra::saveColorGroup(palette, + palette.currentColorGroup()); } /*! @@ -1014,143 +976,12 @@ DomColorGroup *QAbstractFormBuilder::saveColorGroup(const QPalette &palette) */ QBrush QAbstractFormBuilder::setupBrush(DomBrush *brush) { - QBrush br; - if (!brush->hasAttributeBrushStyle()) - return br; - - const Qt::BrushStyle style = enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::BrushStyle>("brushStyle", - brush->attributeBrushStyle().toLatin1().constData()); - - if (style == Qt::LinearGradientPattern || - style == Qt::RadialGradientPattern || - style == Qt::ConicalGradientPattern) { - const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType"); - const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread"); - const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate"); - - const DomGradient *gradient = brush->elementGradient(); - const QGradient::Type type = enumKeyToValue<QGradient::Type>(gradientType_enum, gradient->attributeType().toLatin1()); - - - QGradient *gr = nullptr; - - if (type == QGradient::LinearGradient) { - gr = new QLinearGradient(QPointF(gradient->attributeStartX(), gradient->attributeStartY()), - QPointF(gradient->attributeEndX(), gradient->attributeEndY())); - } else if (type == QGradient::RadialGradient) { - gr = new QRadialGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()), - gradient->attributeRadius(), - QPointF(gradient->attributeFocalX(), gradient->attributeFocalY())); - } else if (type == QGradient::ConicalGradient) { - gr = new QConicalGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()), - gradient->attributeAngle()); - } - if (!gr) - return br; - - const QGradient::Spread spread = enumKeyToValue<QGradient::Spread>(gradientSpread_enum, gradient->attributeSpread().toLatin1()); - gr->setSpread(spread); - - const QGradient::CoordinateMode coord = enumKeyToValue<QGradient::CoordinateMode>(gradientCoordinate_enum, gradient->attributeCoordinateMode().toLatin1()); - gr->setCoordinateMode(coord); - - const auto &stops = gradient->elementGradientStop(); - for (const DomGradientStop *stop : stops) { - const DomColor *color = stop->elementColor(); - gr->setColorAt(stop->attributePosition(), QColor::fromRgb(color->elementRed(), - color->elementGreen(), color->elementBlue(), color->attributeAlpha())); - } - br = QBrush(*gr); - delete gr; - } else if (style == Qt::TexturePattern) { - const DomProperty *texture = brush->elementTexture(); - if (texture && texture->kind() == DomProperty::Pixmap) { - br.setTexture(domPropertyToPixmap(texture)); - } - } else { - const DomColor *color = brush->elementColor(); - br.setColor(QColor::fromRgb(color->elementRed(), - color->elementGreen(), color->elementBlue(), color->attributeAlpha())); - br.setStyle((Qt::BrushStyle)style); - } - return br; + return QFormBuilderExtra::setupBrush(brush); } -/*! - \internal -*/ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br) { - const QMetaEnum brushStyle_enum = metaEnum<QAbstractFormBuilderGadget>("brushStyle"); - - DomBrush *brush = new DomBrush(); - const Qt::BrushStyle style = br.style(); - brush->setAttributeBrushStyle(QLatin1String(brushStyle_enum.valueToKey(style))); - if (style == Qt::LinearGradientPattern || - style == Qt::RadialGradientPattern || - style == Qt::ConicalGradientPattern) { - const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType"); - const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread"); - const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate"); - - DomGradient *gradient = new DomGradient(); - const QGradient *gr = br.gradient(); - const QGradient::Type type = gr->type(); - gradient->setAttributeType(QLatin1String(gradientType_enum.valueToKey(type))); - gradient->setAttributeSpread(QLatin1String(gradientSpread_enum.valueToKey(gr->spread()))); - gradient->setAttributeCoordinateMode(QLatin1String(gradientCoordinate_enum.valueToKey(gr->coordinateMode()))); - QVector<DomGradientStop *> stops; - const QGradientStops st = gr->stops(); - for (const QGradientStop &pair : st) { - DomGradientStop *stop = new DomGradientStop(); - stop->setAttributePosition(pair.first); - DomColor *color = new DomColor(); - color->setElementRed(pair.second.red()); - color->setElementGreen(pair.second.green()); - color->setElementBlue(pair.second.blue()); - color->setAttributeAlpha(pair.second.alpha()); - stop->setElementColor(color); - stops.append(stop); - } - gradient->setElementGradientStop(stops); - if (type == QGradient::LinearGradient) { - auto lgr = static_cast<const QLinearGradient *>(gr); - gradient->setAttributeStartX(lgr->start().x()); - gradient->setAttributeStartY(lgr->start().y()); - gradient->setAttributeEndX(lgr->finalStop().x()); - gradient->setAttributeEndY(lgr->finalStop().y()); - } else if (type == QGradient::RadialGradient) { - auto rgr = static_cast<const QRadialGradient *>(gr); - gradient->setAttributeCentralX(rgr->center().x()); - gradient->setAttributeCentralY(rgr->center().y()); - gradient->setAttributeFocalX(rgr->focalPoint().x()); - gradient->setAttributeFocalY(rgr->focalPoint().y()); - gradient->setAttributeRadius(rgr->radius()); - } else if (type == QGradient::ConicalGradient) { - auto cgr = static_cast<const QConicalGradient *>(gr); - gradient->setAttributeCentralX(cgr->center().x()); - gradient->setAttributeCentralY(cgr->center().y()); - gradient->setAttributeAngle(cgr->angle()); - } - - brush->setElementGradient(gradient); - } else if (style == Qt::TexturePattern) { - const QPixmap pixmap = br.texture(); - if (!pixmap.isNull()) { - DomProperty *p = new DomProperty; - setPixmapProperty(*p, pixmapPaths(pixmap)); - brush->setElementTexture(p); - } - } else { - const QColor &c = br.color(); - DomColor *color = new DomColor(); - color->setElementRed(c.red()); - color->setElementGreen(c.green()); - color->setElementBlue(c.blue()); - color->setAttributeAlpha(c.alpha()); - brush->setElementColor(color); - } - return brush; + return QFormBuilderExtra::saveBrush(br); } /*! @@ -1761,7 +1592,7 @@ DomButtonGroups *QAbstractFormBuilder::saveButtonGroups(const QWidget *mainConta { // Save fst order buttongroup children of maincontainer const QObjectList &mchildren = mainContainer->children(); - if (mchildren.empty()) + if (mchildren.isEmpty()) return nullptr; QVector<DomButtonGroup *> domGroups; for (QObject *o : mchildren) { @@ -1769,7 +1600,7 @@ DomButtonGroups *QAbstractFormBuilder::saveButtonGroups(const QWidget *mainConta if (DomButtonGroup* dg = createDom(bg)) domGroups.push_back(dg); } - if (domGroups.empty()) + if (domGroups.isEmpty()) return nullptr; DomButtonGroups *rc = new DomButtonGroups; rc->setElementButtonGroup(domGroups); @@ -2432,7 +2263,7 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox static QString buttonGroupName(const DomWidget *ui_widget) { const auto &attributes = ui_widget->elementAttribute(); - if (attributes.empty()) + if (attributes.isEmpty()) return QString(); const QString buttonGroupProperty = QLatin1String(buttonGroupPropertyC); for (const DomProperty *p : attributes) { @@ -2696,6 +2527,8 @@ QMetaEnum QAbstractFormBuilder::toolBarAreaMetaEnum() return metaEnum<QAbstractFormBuilderGadget>("toolBarArea"); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + /*! \internal Return paths of an icon. @@ -2720,6 +2553,8 @@ QAbstractFormBuilder::IconPaths QAbstractFormBuilder::pixmapPaths(const QPixmap return IconPaths(); } +#endif // < Qt 6 + /*! \internal Set up a DOM property with icon. @@ -2746,16 +2581,11 @@ void QAbstractFormBuilder::setIconProperty(DomProperty &p, const IconPaths &ip) void QAbstractFormBuilder::setPixmapProperty(DomProperty &p, const IconPaths &ip) const { - DomResourcePixmap *pix = new DomResourcePixmap; - if (!ip.second.isEmpty()) - pix->setAttributeResource(ip.second); - - pix->setText(ip.first); - - p.setAttributeName(QFormBuilderStrings::instance().pixmapAttribute); - p.setElementPixmap(pix); + QFormBuilderExtra::setPixmapProperty(&p, ip); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + /*! \internal Convenience. Return DOM property for icon; 0 if icon.isNull(). @@ -2768,6 +2598,8 @@ DomProperty* QAbstractFormBuilder::iconToDomProperty(const QIcon &icon) const return nullptr; } +#endif // < Qt 6 + /*! \internal \since 4.4 @@ -2819,6 +2651,8 @@ const DomResourcePixmap *QAbstractFormBuilder::domPixmap(const DomProperty* p) { return nullptr; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + /*! \internal Create icon from DOM. @@ -2873,6 +2707,8 @@ QPixmap QAbstractFormBuilder::domPropertyToPixmap(const DomProperty* p) return QPixmap(); } +#endif // < Qt 6 + /*! \fn void QAbstractFormBuilder::createConnections ( DomConnections *, QWidget * ) \internal diff --git a/src/designer/src/lib/uilib/abstractformbuilder.h b/src/designer/src/lib/uilib/abstractformbuilder.h index 486359099..fa6449c30 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.h +++ b/src/designer/src/lib/uilib/abstractformbuilder.h @@ -243,17 +243,20 @@ protected: // A Pair of icon path/qrc path. using IconPaths = QPair<QString, QString>; - IconPaths iconPaths(const QIcon &) const; - IconPaths pixmapPaths(const QPixmap &) const; void setIconProperty(DomProperty &, const IconPaths &) const; void setPixmapProperty(DomProperty &, const IconPaths &) const; - DomProperty* iconToDomProperty(const QIcon &) const; static const DomResourcePixmap *domPixmap(const DomProperty* p); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + IconPaths iconPaths(const QIcon &) const; + IconPaths pixmapPaths(const QPixmap &) const; + DomProperty* iconToDomProperty(const QIcon &) const; QIcon domPropertyToIcon(const DomResourcePixmap *); QIcon domPropertyToIcon(const DomProperty* p); QPixmap domPropertyToPixmap(const DomResourcePixmap* p); QPixmap domPropertyToPixmap(const DomProperty* p); +#endif private: // diff --git a/src/designer/src/lib/uilib/formbuilder.cpp b/src/designer/src/lib/uilib/formbuilder.cpp index 31bfdfde4..4230e27f7 100644 --- a/src/designer/src/lib/uilib/formbuilder.cpp +++ b/src/designer/src/lib/uilib/formbuilder.cpp @@ -517,7 +517,7 @@ QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - if (properties.empty()) + if (properties.isEmpty()) return; const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp index 01d79c557..14174711f 100644 --- a/src/designer/src/lib/uilib/formbuilderextra.cpp +++ b/src/designer/src/lib/uilib/formbuilderextra.cpp @@ -50,6 +50,7 @@ #include "formbuilderextra_p.h" #include "abstractformbuilder.h" +#include "properties_p.h" #include "resourcebuilder_p.h" #include "textbuilder_p.h" #include "ui4_p.h" @@ -206,7 +207,7 @@ bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &prope void QFormBuilderExtra::applyInternalProperties() const { - if (m_buddies.empty()) + if (m_buddies.isEmpty()) return; const BuddyHash::const_iterator cend = m_buddies.constEnd(); @@ -222,7 +223,7 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode } const QWidgetList widgets = label->topLevelWidget()->findChildren<QWidget*>(buddyName); - if (widgets.empty()) { + if (widgets.isEmpty()) { label->setBuddy(nullptr); return false; } @@ -386,7 +387,7 @@ inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(in return true; } const QVector<QStringRef> list = s.splitRef(QLatin1Char(',')); - if (list.empty()) { + if (list.isEmpty()) { clearPerCellValue(l, count, setter, defaultValue); return true; } @@ -511,6 +512,234 @@ void QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(QGridLayout *grid) clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth); } +void QFormBuilderExtra::setPixmapProperty(DomProperty *p, const QPair<QString, QString> &ip) +{ + DomResourcePixmap *pix = new DomResourcePixmap; + if (!ip.second.isEmpty()) + pix->setAttributeResource(ip.second); + + pix->setText(ip.first); + + p->setAttributeName(QFormBuilderStrings::instance().pixmapAttribute); + p->setElementPixmap(pix); +} + +void QFormBuilderExtra::setupColorGroup(QPalette *palette, QPalette::ColorGroup colorGroup, + const DomColorGroup *group) +{ + // old format + const auto &colors = group->elementColor(); + for (int role = 0; role < colors.size(); ++role) { + const DomColor *color = colors.at(role); + const QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); + palette->setColor(colorGroup, QPalette::ColorRole(role), c); + } + + // new format + const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); + + const auto colorRoles = group->elementColorRole(); + for (const DomColorRole *colorRole : colorRoles) { + if (colorRole->hasAttributeRole()) { + const int r = colorRole_enum.keyToValue(colorRole->attributeRole().toLatin1()); + if (r != -1) { + const QBrush br = setupBrush(colorRole->elementBrush()); + palette->setBrush(colorGroup, static_cast<QPalette::ColorRole>(r), br); + } + } + } +} + +DomColorGroup *QFormBuilderExtra::saveColorGroup(const QPalette &palette, + QPalette::ColorGroup colorGroup) +{ + + const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); + + DomColorGroup *group = new DomColorGroup(); + QVector<DomColorRole *> colorRoles; + + const uint mask = palette.resolve(); + for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) { + if (mask & (1 << role)) { + const QBrush &br = palette.brush(colorGroup, QPalette::ColorRole(role)); + + DomColorRole *colorRole = new DomColorRole(); + colorRole->setElementBrush(saveBrush(br)); + colorRole->setAttributeRole(QLatin1String(colorRole_enum.valueToKey(role))); + colorRoles.append(colorRole); + } + } + + group->setElementColorRole(colorRoles); + return group; +} + +DomPalette *QFormBuilderExtra::savePalette(const QPalette &palette) +{ + DomPalette *dom = new DomPalette(); + dom->setElementActive(QFormBuilderExtra::saveColorGroup(palette, QPalette::Active)); + dom->setElementInactive(QFormBuilderExtra::saveColorGroup(palette, QPalette::Inactive)); + dom->setElementDisabled(QFormBuilderExtra::saveColorGroup(palette, QPalette::Disabled)); + + return dom; +} + +QPalette QFormBuilderExtra::loadPalette(const DomPalette *dom) +{ + QPalette palette; + + if (dom->elementActive()) + QFormBuilderExtra::setupColorGroup(&palette, QPalette::Active, dom->elementActive()); + + if (dom->elementInactive()) + QFormBuilderExtra::setupColorGroup(&palette, QPalette::Inactive, dom->elementInactive()); + + if (dom->elementDisabled()) + QFormBuilderExtra::setupColorGroup(&palette, QPalette::Disabled, dom->elementDisabled()); + + palette.setCurrentColorGroup(QPalette::Active); + return palette; +} + +QBrush QFormBuilderExtra::setupBrush(const DomBrush *brush) +{ + QBrush br; + if (!brush->hasAttributeBrushStyle()) + return br; + + const Qt::BrushStyle style = enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::BrushStyle>("brushStyle", + brush->attributeBrushStyle().toLatin1().constData()); + + if (style == Qt::LinearGradientPattern || + style == Qt::RadialGradientPattern || + style == Qt::ConicalGradientPattern) { + const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType"); + const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread"); + const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate"); + + const DomGradient *gradient = brush->elementGradient(); + const QGradient::Type type = enumKeyToValue<QGradient::Type>(gradientType_enum, gradient->attributeType().toLatin1()); + + + QGradient *gr = nullptr; + + if (type == QGradient::LinearGradient) { + gr = new QLinearGradient(QPointF(gradient->attributeStartX(), gradient->attributeStartY()), + QPointF(gradient->attributeEndX(), gradient->attributeEndY())); + } else if (type == QGradient::RadialGradient) { + gr = new QRadialGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()), + gradient->attributeRadius(), + QPointF(gradient->attributeFocalX(), gradient->attributeFocalY())); + } else if (type == QGradient::ConicalGradient) { + gr = new QConicalGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()), + gradient->attributeAngle()); + } + if (!gr) + return br; + + const QGradient::Spread spread = enumKeyToValue<QGradient::Spread>(gradientSpread_enum, gradient->attributeSpread().toLatin1()); + gr->setSpread(spread); + + const QGradient::CoordinateMode coord = enumKeyToValue<QGradient::CoordinateMode>(gradientCoordinate_enum, gradient->attributeCoordinateMode().toLatin1()); + gr->setCoordinateMode(coord); + + const auto &stops = gradient->elementGradientStop(); + for (const DomGradientStop *stop : stops) { + const DomColor *color = stop->elementColor(); + gr->setColorAt(stop->attributePosition(), QColor::fromRgb(color->elementRed(), + color->elementGreen(), color->elementBlue(), color->attributeAlpha())); + } + br = QBrush(*gr); + delete gr; + } else if (style == Qt::TexturePattern) { + const DomProperty *texture = brush->elementTexture(); + if (texture && texture->kind() == DomProperty::Pixmap) { + br.setTexture({}); + } + } else { + const DomColor *color = brush->elementColor(); + br.setColor(QColor::fromRgb(color->elementRed(), + color->elementGreen(), color->elementBlue(), color->attributeAlpha())); + br.setStyle((Qt::BrushStyle)style); + } + return br; +} + +DomBrush *QFormBuilderExtra::saveBrush(const QBrush &br) +{ + const QMetaEnum brushStyle_enum = metaEnum<QAbstractFormBuilderGadget>("brushStyle"); + + DomBrush *brush = new DomBrush(); + const Qt::BrushStyle style = br.style(); + brush->setAttributeBrushStyle(QLatin1String(brushStyle_enum.valueToKey(style))); + if (style == Qt::LinearGradientPattern || + style == Qt::RadialGradientPattern || + style == Qt::ConicalGradientPattern) { + const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType"); + const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread"); + const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate"); + + DomGradient *gradient = new DomGradient(); + const QGradient *gr = br.gradient(); + const QGradient::Type type = gr->type(); + gradient->setAttributeType(QLatin1String(gradientType_enum.valueToKey(type))); + gradient->setAttributeSpread(QLatin1String(gradientSpread_enum.valueToKey(gr->spread()))); + gradient->setAttributeCoordinateMode(QLatin1String(gradientCoordinate_enum.valueToKey(gr->coordinateMode()))); + QVector<DomGradientStop *> stops; + const QGradientStops st = gr->stops(); + for (const QGradientStop &pair : st) { + DomGradientStop *stop = new DomGradientStop(); + stop->setAttributePosition(pair.first); + DomColor *color = new DomColor(); + color->setElementRed(pair.second.red()); + color->setElementGreen(pair.second.green()); + color->setElementBlue(pair.second.blue()); + color->setAttributeAlpha(pair.second.alpha()); + stop->setElementColor(color); + stops.append(stop); + } + gradient->setElementGradientStop(stops); + if (type == QGradient::LinearGradient) { + auto lgr = static_cast<const QLinearGradient *>(gr); + gradient->setAttributeStartX(lgr->start().x()); + gradient->setAttributeStartY(lgr->start().y()); + gradient->setAttributeEndX(lgr->finalStop().x()); + gradient->setAttributeEndY(lgr->finalStop().y()); + } else if (type == QGradient::RadialGradient) { + auto rgr = static_cast<const QRadialGradient *>(gr); + gradient->setAttributeCentralX(rgr->center().x()); + gradient->setAttributeCentralY(rgr->center().y()); + gradient->setAttributeFocalX(rgr->focalPoint().x()); + gradient->setAttributeFocalY(rgr->focalPoint().y()); + gradient->setAttributeRadius(rgr->radius()); + } else if (type == QGradient::ConicalGradient) { + auto cgr = static_cast<const QConicalGradient *>(gr); + gradient->setAttributeCentralX(cgr->center().x()); + gradient->setAttributeCentralY(cgr->center().y()); + gradient->setAttributeAngle(cgr->angle()); + } + + brush->setElementGradient(gradient); + } else if (style == Qt::TexturePattern) { + const QPixmap pixmap = br.texture(); + if (!pixmap.isNull()) { + DomProperty *p = new DomProperty; + QFormBuilderExtra::setPixmapProperty(p, {}); + brush->setElementTexture(p); + } + } else { + const QColor &c = br.color(); + DomColor *color = new DomColor(); + color->setElementRed(c.red()); + color->setElementGreen(c.green()); + color->setElementBlue(c.blue()); + color->setAttributeAlpha(c.alpha()); + brush->setElementColor(color); + } + return brush; +} + // ------------ QFormBuilderStrings QFormBuilderStrings::QFormBuilderStrings() : diff --git a/src/designer/src/lib/uilib/formbuilderextra_p.h b/src/designer/src/lib/uilib/formbuilderextra_p.h index 54fbfbe66..b0239f6b1 100644 --- a/src/designer/src/lib/uilib/formbuilderextra_p.h +++ b/src/designer/src/lib/uilib/formbuilderextra_p.h @@ -69,6 +69,7 @@ #include <QtCore/qstringlist.h> #include <QtCore/qmap.h> #include <QtCore/qdir.h> +#include <QtGui/qpalette.h> QT_BEGIN_NAMESPACE @@ -89,9 +90,13 @@ namespace QFormInternal { #endif +class DomBrush; class DomButtonGroups; class DomButtonGroup; +class DomColorGroup; class DomCustomWidget; +class DomPalette; +class DomProperty; class DomUI; class QAbstractFormBuilder; @@ -175,6 +180,16 @@ public: static bool setGridLayoutColumnMinimumWidth(const QString &, QGridLayout *); static void clearGridLayoutColumnMinimumWidth(QGridLayout *); + static void setPixmapProperty(DomProperty *p, const QPair<QString, QString> &ip); + static QPalette loadPalette(const DomPalette *dom); + static void setupColorGroup(QPalette *palette, QPalette::ColorGroup colorGroup, + const DomColorGroup *group); + static DomColorGroup *saveColorGroup(const QPalette &palette, + QPalette::ColorGroup colorGroup); + static DomPalette *savePalette(const QPalette &palette); + static QBrush setupBrush(const DomBrush *brush); + static DomBrush *saveBrush(const QBrush &br); + QStringList m_pluginPaths; QMap<QString, QDesignerCustomWidgetInterface*> m_customWidgets; diff --git a/src/designer/src/lib/uilib/ui4.cpp b/src/designer/src/lib/uilib/ui4.cpp index 879426b0d..bc58c202b 100644 --- a/src/designer/src/lib/uilib/ui4.cpp +++ b/src/designer/src/lib/uilib/ui4.cpp @@ -81,7 +81,7 @@ void DomUI::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("version")) { setAttributeVersion(attribute.value().toString()); continue; @@ -116,7 +116,7 @@ void DomUI::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("author"), Qt::CaseInsensitive)) { setElementAuthor(reader.readElementText()); continue; @@ -603,7 +603,7 @@ void DomIncludes::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { auto *v = new DomInclude(); v->read(reader); @@ -643,7 +643,7 @@ void DomInclude::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -658,7 +658,7 @@ void DomInclude::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -700,7 +700,7 @@ void DomResources::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -711,7 +711,7 @@ void DomResources::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { auto *v = new DomResource(); v->read(reader); @@ -754,7 +754,7 @@ void DomResource::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -765,7 +765,7 @@ void DomResource::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -803,7 +803,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -814,7 +814,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { auto *v = new DomAction(); v->read(reader); @@ -908,7 +908,7 @@ void DomAction::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -923,7 +923,7 @@ void DomAction::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -984,7 +984,7 @@ void DomActionRef::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -995,7 +995,7 @@ void DomActionRef::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1029,7 +1029,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1040,7 +1040,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1103,7 +1103,7 @@ void DomButtonGroups::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) { auto *v = new DomButtonGroup(); v->read(reader); @@ -1148,7 +1148,7 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) { auto *v = new DomCustomWidget(); v->read(reader); @@ -1188,7 +1188,7 @@ void DomHeader::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -1199,7 +1199,7 @@ void DomHeader::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1241,7 +1241,7 @@ void DomCustomWidget::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; @@ -1495,7 +1495,7 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toInt()); continue; @@ -1510,7 +1510,7 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1541,7 +1541,7 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toString()); continue; @@ -1556,7 +1556,7 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1591,7 +1591,7 @@ void DomTabStops::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("tabstop"), Qt::CaseInsensitive)) { m_tabStop.append(reader.readElementText()); continue; @@ -1637,7 +1637,7 @@ void DomLayout::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -1672,7 +1672,7 @@ void DomLayout::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1781,7 +1781,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -1808,7 +1808,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { auto *v = new DomWidget(); v->read(reader); @@ -1932,7 +1932,7 @@ void DomRow::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1977,7 +1977,7 @@ void DomColumn::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2023,7 +2023,7 @@ void DomItem::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -2038,7 +2038,7 @@ void DomItem::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2123,7 +2123,7 @@ void DomWidget::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -2142,7 +2142,7 @@ void DomWidget::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { m_class.append(reader.readElementText()); continue; @@ -2366,7 +2366,7 @@ void DomSpacer::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -2377,7 +2377,7 @@ void DomSpacer::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2420,7 +2420,7 @@ void DomColor::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("alpha")) { setAttributeAlpha(attribute.value().toInt()); continue; @@ -2431,7 +2431,7 @@ void DomColor::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("red"), Qt::CaseInsensitive)) { setElementRed(reader.readElementText().toInt()); continue; @@ -2516,7 +2516,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("position")) { setAttributePosition(attribute.value().toDouble()); continue; @@ -2527,7 +2527,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); @@ -2590,7 +2590,7 @@ void DomGradient::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("startx")) { setAttributeStartX(attribute.value().toDouble()); continue; @@ -2649,7 +2649,7 @@ void DomGradient::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) { auto *v = new DomGradientStop(); v->read(reader); @@ -2746,7 +2746,7 @@ void DomBrush::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("brushstyle")) { setAttributeBrushStyle(attribute.value().toString()); continue; @@ -2757,7 +2757,7 @@ void DomBrush::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); @@ -2867,7 +2867,7 @@ void DomColorRole::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("role")) { setAttributeRole(attribute.value().toString()); continue; @@ -2878,7 +2878,7 @@ void DomColorRole::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { auto *v = new DomBrush(); v->read(reader); @@ -2944,7 +2944,7 @@ void DomColorGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) { auto *v = new DomColorRole(); v->read(reader); @@ -3005,7 +3005,7 @@ void DomPalette::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) { auto *v = new DomColorGroup(); v->read(reader); @@ -3124,7 +3124,7 @@ void DomFont::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("family"), Qt::CaseInsensitive)) { setElementFamily(reader.readElementText()); continue; @@ -3330,7 +3330,7 @@ void DomPoint::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -3392,7 +3392,7 @@ void DomRect::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -3489,7 +3489,7 @@ void DomLocale::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; @@ -3504,7 +3504,7 @@ void DomLocale::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -3535,7 +3535,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("hsizetype")) { setAttributeHSizeType(attribute.value().toString()); continue; @@ -3550,7 +3550,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hsizetype"), Qt::CaseInsensitive)) { setElementHSizeType(reader.readElementText().toInt()); continue; @@ -3654,7 +3654,7 @@ void DomSize::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; @@ -3716,7 +3716,7 @@ void DomDate::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; @@ -3796,7 +3796,7 @@ void DomTime::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; @@ -3876,7 +3876,7 @@ void DomDateTime::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; @@ -4012,7 +4012,7 @@ void DomStringList::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -4035,7 +4035,7 @@ void DomStringList::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { m_string.append(reader.readElementText()); continue; @@ -4085,7 +4085,7 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("resource")) { setAttributeResource(attribute.value().toString()); continue; @@ -4100,7 +4100,7 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -4148,7 +4148,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("theme")) { setAttributeTheme(attribute.value().toString()); continue; @@ -4163,7 +4163,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); @@ -4449,7 +4449,7 @@ void DomString::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -4472,7 +4472,7 @@ void DomString::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -4517,7 +4517,7 @@ void DomPointF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; @@ -4579,7 +4579,7 @@ void DomRectF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; @@ -4677,7 +4677,7 @@ void DomSizeF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; @@ -4739,7 +4739,7 @@ void DomChar::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("unicode"), Qt::CaseInsensitive)) { setElementUnicode(reader.readElementText().toInt()); continue; @@ -4786,7 +4786,7 @@ void DomUrl::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { auto *v = new DomString(); v->read(reader); @@ -4921,7 +4921,7 @@ void DomProperty::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -4936,7 +4936,7 @@ void DomProperty::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("bool"), Qt::CaseInsensitive)) { setElementBool(reader.readElementText()); continue; @@ -5681,7 +5681,7 @@ void DomConnections::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) { auto *v = new DomConnection(); v->read(reader); @@ -5725,7 +5725,7 @@ void DomConnection::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("sender"), Qt::CaseInsensitive)) { setElementSender(reader.readElementText()); continue; @@ -5858,7 +5858,7 @@ void DomConnectionHints::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) { auto *v = new DomConnectionHint(); v->read(reader); @@ -5898,7 +5898,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; @@ -5909,7 +5909,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -5978,7 +5978,7 @@ void DomDesignerData::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -6023,7 +6023,7 @@ void DomSlots::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { m_signal.append(reader.readElementText()); continue; @@ -6081,7 +6081,7 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) { auto *v = new DomPropertyToolTip(); v->read(reader); @@ -6136,7 +6136,7 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -6147,7 +6147,7 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -6175,7 +6175,7 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -6194,7 +6194,7 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; diff --git a/src/designer/src/uitools/quiloader.cpp b/src/designer/src/uitools/quiloader.cpp index e5f157fb1..4aec975d9 100644 --- a/src/designer/src/uitools/quiloader.cpp +++ b/src/designer/src/uitools/quiloader.cpp @@ -438,7 +438,7 @@ void FormBuilderPrivate::applyProperties(QObject *o, const QList<DomProperty*> & if (!m_trwatch) m_trwatch = new TranslationWatcher(o, m_class, m_idBased); - if (properties.empty()) + if (properties.isEmpty()) return; // Unlike string item roles, string properties are not loaded via the textBuilder |