diff options
Diffstat (limited to 'src/controls/Private')
-rw-r--r-- | src/controls/Private/BasicTableView.qml | 4 | ||||
-rw-r--r-- | src/controls/Private/ColumnMenuContent.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/ScrollBar.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/ScrollViewHelper.qml | 10 | ||||
-rw-r--r-- | src/controls/Private/qquickcontrolsettings.cpp | 2 | ||||
-rw-r--r-- | src/controls/Private/qquickstyleitem.cpp | 312 |
6 files changed, 170 insertions, 162 deletions
diff --git a/src/controls/Private/BasicTableView.qml b/src/controls/Private/BasicTableView.qml index 822086ee..afec226d 100644 --- a/src/controls/Private/BasicTableView.qml +++ b/src/controls/Private/BasicTableView.qml @@ -677,7 +677,7 @@ ScrollView { onPositionChanged: { if (drag.active && modelData.movable && pressed && columnCount > 1) { // only do this while dragging for (var h = columnCount-1 ; h >= 0 ; --h) { - if (drag.target.x + listView.contentX + headerRowDelegate.width/2 > headerRow.children[h].x) { + if (headerRow.children[h].visible && drag.target.x + headerRowDelegate.width/2 > headerRow.children[h].x) { repeater.targetIndex = h break } @@ -715,7 +715,7 @@ ScrollView { } parent: tableHeader x: __implicitX - property double __implicitX: headerRowDelegate.x - listView.contentX + property double __implicitX: headerRowDelegate.x width: modelData.width height: parent.height sourceComponent: root.headerDelegate diff --git a/src/controls/Private/ColumnMenuContent.qml b/src/controls/Private/ColumnMenuContent.qml index 4d0f944d..d184524e 100644 --- a/src/controls/Private/ColumnMenuContent.qml +++ b/src/controls/Private/ColumnMenuContent.qml @@ -201,7 +201,7 @@ Item { onPositionChanged: updateCurrentItem({ "x": mouse.x, "y": mouse.y }) onPressed: updateCurrentItem({ "x": mouse.x, "y": mouse.y }) onReleased: { - if (currentItem.__menuItem.enabled) { + if (currentItem && currentItem.__menuItem.enabled) { if (currentItem.styleData.type === MenuItemType.Menu) { showCurrentItemSubMenu(true) } else { diff --git a/src/controls/Private/ScrollBar.qml b/src/controls/Private/ScrollBar.qml index f6f5e26d..ca9c21cd 100644 --- a/src/controls/Private/ScrollBar.qml +++ b/src/controls/Private/ScrollBar.qml @@ -88,7 +88,7 @@ Item { property int pageStep: internal.horizontal ? width : height property bool scrollToClickposition: internal.scrollToClickPosition anchors.fill: parent - cursorShape: __panel.visible ? Qt.ArrowCursor : Qt.IBeamCursor // forces a cursor change + cursorShape: __panel && __panel.visible ? Qt.ArrowCursor : Qt.IBeamCursor // forces a cursor change property bool autoincrement: false property bool scrollToClickPosition: __style ? __style.scrollToClickedPosition : 0 diff --git a/src/controls/Private/ScrollViewHelper.qml b/src/controls/Private/ScrollViewHelper.qml index d34aa555..24def4c9 100644 --- a/src/controls/Private/ScrollViewHelper.qml +++ b/src/controls/Private/ScrollViewHelper.qml @@ -58,10 +58,10 @@ Item { property int verticalScrollBarPolicy: Qt.ScrollBarAsNeeded - property int leftMargin: outerFrame ? root.__style.padding.left : 0 - property int rightMargin: outerFrame ? root.__style.padding.right : 0 - property int topMargin: outerFrame ? root.__style.padding.top : 0 - property int bottomMargin: outerFrame ? root.__style.padding.bottom : 0 + property int leftMargin: outerFrame && root.__style ? root.__style.padding.left : 0 + property int rightMargin: outerFrame && root.__style ? root.__style.padding.right : 0 + property int topMargin: outerFrame && root.__style ? root.__style.padding.top : 0 + property int bottomMargin: outerFrame && root.__style ? root.__style.padding.bottom : 0 anchors.fill: parent @@ -101,7 +101,7 @@ Item { Loader { id: cornerFill z: 1 - sourceComponent: __style.corner + sourceComponent: __style ? __style.corner : null anchors.right: parent.right anchors.bottom: parent.bottom anchors.bottomMargin: bottomMargin diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index 0f22f127..9e76cb07 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -120,7 +120,7 @@ QUrl QQuickControlSettings::makeStyleComponentUrl(const QString &controlStyleNam { QString styleFilePath = makeStyleComponentPath(controlStyleName, styleDirPath); - if (styleDirPath.startsWith(QStringLiteral(":/"))) + if (styleDirPath.startsWith(QLatin1String(":/"))) return QUrl(QStringLiteral("qrc") + styleFilePath); return QUrl::fromLocalFile(styleFilePath); diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index 3cf8ebbe..c8be5685 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -284,9 +284,9 @@ void QQuickStyleItem::initStyleOption() if (m_styleoption) m_styleoption->state = 0; - QString sizeHint = m_hints.value("size").toString(); - QPlatformTheme::Font platformFont = (sizeHint == "mini") ? QPlatformTheme::MiniFont : - (sizeHint == "small") ? QPlatformTheme::SmallFont : + QString sizeHint = m_hints.value(QStringLiteral("size")).toString(); + QPlatformTheme::Font platformFont = (sizeHint == QLatin1String("mini")) ? QPlatformTheme::MiniFont : + (sizeHint == QLatin1String("small")) ? QPlatformTheme::SmallFont : QPlatformTheme::SystemFont; bool needsResolvePalette = true; @@ -298,10 +298,10 @@ void QQuickStyleItem::initStyleOption() QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption); opt->text = text(); - opt->icon = m_properties["icon"].value<QIcon>(); + opt->icon = m_properties[QStringLiteral("icon")].value<QIcon>(); int e = qApp->style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, 0); opt->iconSize = QSize(e, e); - opt->features = (activeControl() == "default") ? + opt->features = activeControl() == QLatin1String("default") ? QStyleOptionButton::DefaultButton : QStyleOptionButton::None; if (platformFont == QPlatformTheme::SystemFont) @@ -309,11 +309,11 @@ void QQuickStyleItem::initStyleOption() const QFont *font = QGuiApplicationPrivate::platformTheme()->font(platformFont); if (font) opt->fontMetrics = QFontMetrics(*font); - QObject * menu = m_properties["menu"].value<QObject *>(); + QObject * menu = m_properties[QStringLiteral("menu")].value<QObject *>(); if (menu) { opt->features |= QStyleOptionButton::HasMenu; #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { if (platformFont == QPlatformTheme::PushButtonFont) menu->setProperty("__xOffset", 12); else @@ -337,7 +337,7 @@ void QQuickStyleItem::initStyleOption() QStyleOptionViewItem *opt = qstyleoption_cast<QStyleOptionViewItem*>(m_styleoption); opt->features = 0; - if (activeControl() == "alternate") + if (activeControl() == QLatin1String("alternate")) opt->features |= QStyleOptionViewItem::Alternate; } break; @@ -375,9 +375,9 @@ void QQuickStyleItem::initStyleOption() m_styleoption = new QStyleOption; m_styleoption->state = QStyle::State_Item; // We don't want to fully support Win 95 - if (m_properties.value("hasChildren").toBool()) + if (m_properties.value(QStringLiteral("hasChildren")).toBool()) m_styleoption->state |= QStyle::State_Children; - if (m_properties.value("hasSibling").toBool()) // Even this one could go away + if (m_properties.value(QStringLiteral("hasSibling")).toBool()) // Even this one could go away m_styleoption->state |= QStyle::State_Sibling; if (m_on) m_styleoption->state |= QStyle::State_Open; @@ -389,17 +389,17 @@ void QQuickStyleItem::initStyleOption() QStyleOptionHeader *opt = qstyleoption_cast<QStyleOptionHeader*>(m_styleoption); opt->text = text(); - opt->textAlignment = static_cast<Qt::AlignmentFlag>(m_properties.value("textalignment").toInt()); - opt->sortIndicator = activeControl() == "down" ? + opt->textAlignment = static_cast<Qt::AlignmentFlag>(m_properties.value(QStringLiteral("textalignment")).toInt()); + opt->sortIndicator = activeControl() == QLatin1String("down") ? QStyleOptionHeader::SortDown - : activeControl() == "up" ? + : activeControl() == QLatin1String("up") ? QStyleOptionHeader::SortUp : QStyleOptionHeader::None; - QString headerpos = m_properties.value("headerpos").toString(); - if (headerpos == "beginning") + QString headerpos = m_properties.value(QStringLiteral("headerpos")).toString(); + if (headerpos == QLatin1String("beginning")) opt->position = QStyleOptionHeader::Beginning; - else if (headerpos == "end") + else if (headerpos == QLatin1String("end")) opt->position = QStyleOptionHeader::End; - else if (headerpos == "only") + else if (headerpos == QLatin1String("only")) opt->position = QStyleOptionHeader::OnlyOneSection; else opt->position = QStyleOptionHeader::Middle; @@ -417,9 +417,9 @@ void QQuickStyleItem::initStyleOption() opt->state |= QStyle::State_AutoRaise; opt->activeSubControls = QStyle::SC_ToolButton; opt->text = text(); - opt->icon = m_properties["icon"].value<QIcon>(); + opt->icon = m_properties[QStringLiteral("icon")].value<QIcon>(); - if (m_properties.value("menu").toBool()) { + if (m_properties.value(QStringLiteral("menu")).toBool()) { opt->subControls |= QStyle::SC_ToolButtonMenu; opt->features = QStyleOptionToolButton::HasMenu; } @@ -451,14 +451,14 @@ void QQuickStyleItem::initStyleOption() QStyleOptionTab *opt = qstyleoption_cast<QStyleOptionTab*>(m_styleoption); opt->text = text(); - if (m_properties.value("hasFrame").toBool()) + if (m_properties.value(QStringLiteral("hasFrame")).toBool()) opt->features |= QStyleOptionTab::HasFrame; - QString orientation = m_properties.value("orientation").toString(); - QString position = m_properties.value("tabpos").toString(); - QString selectedPosition = m_properties.value("selectedpos").toString(); + QString orientation = m_properties.value(QStringLiteral("orientation")).toString(); + QString position = m_properties.value(QStringLiteral("tabpos")).toString(); + QString selectedPosition = m_properties.value(QStringLiteral("selectedpos")).toString(); - opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + opt->shape = orientation == QLatin1String("Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; if (position == QLatin1String("beginning")) opt->position = QStyleOptionTab::Beginning; else if (position == QLatin1String("end")) @@ -500,8 +500,8 @@ void QQuickStyleItem::initStyleOption() m_styleoption = new QStyleOptionTabWidgetFrame(); QStyleOptionTabWidgetFrame *opt = qstyleoption_cast<QStyleOptionTabWidgetFrame*>(m_styleoption); - opt->selectedTabRect = m_properties["selectedTabRect"].toRect(); - opt->shape = m_properties["orientation"] == Qt::BottomEdge ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + opt->selectedTabRect = m_properties[QStringLiteral("selectedTabRect")].toRect(); + opt->shape = m_properties[QStringLiteral("orientation")] == Qt::BottomEdge ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; if (minimum()) opt->selectedTabRect = QRect(value(), 0, minimum(), height()); opt->tabBarSize = QSize(minimum() , height()); @@ -525,7 +525,7 @@ void QQuickStyleItem::initStyleOption() QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption); opt->text = text(); opt->menuItemType = QStyleOptionMenuItem::Normal; - setProperty("_q_showUnderlined", m_hints["showUnderlined"].toBool()); + setProperty("_q_showUnderlined", m_hints[QStringLiteral("showUnderlined")].toBool()); if (const QFont *font = QGuiApplicationPrivate::platformTheme()->font(QPlatformTheme::MenuBarFont)) { opt->font = *font; @@ -550,9 +550,9 @@ void QQuickStyleItem::initStyleOption() setProperty("_q_isComboBoxPopupItem", m_itemType == ComboBoxItem); QQuickMenuItemType::MenuItemType type = - static_cast<QQuickMenuItemType::MenuItemType>(m_properties["type"].toInt()); + static_cast<QQuickMenuItemType::MenuItemType>(m_properties[QStringLiteral("type")].toInt()); if (type == QQuickMenuItemType::ScrollIndicator) { - int scrollerDirection = m_properties["scrollerDirection"].toInt(); + int scrollerDirection = m_properties[QStringLiteral("scrollerDirection")].toInt(); opt->menuItemType = QStyleOptionMenuItem::Scroller; opt->state |= scrollerDirection == Qt::UpArrow ? QStyle::State_UpArrow : QStyle::State_DownArrow; @@ -566,21 +566,21 @@ void QQuickStyleItem::initStyleOption() } else { opt->menuItemType = QStyleOptionMenuItem::Normal; - QString shortcut = m_properties["shortcut"].toString(); + QString shortcut = m_properties[QStringLiteral("shortcut")].toString(); if (!shortcut.isEmpty()) { opt->text += QLatin1Char('\t') + shortcut; opt->tabWidth = qMax(opt->tabWidth, qRound(textWidth(shortcut))); } - if (m_properties["checkable"].toBool()) { + if (m_properties[QStringLiteral("checkable")].toBool()) { opt->checked = on(); - QVariant exclusive = m_properties["exclusive"]; + QVariant exclusive = m_properties[QStringLiteral("exclusive")]; opt->checkType = exclusive.toBool() ? QStyleOptionMenuItem::Exclusive : QStyleOptionMenuItem::NonExclusive; } } - if (m_properties["icon"].canConvert<QIcon>()) - opt->icon = m_properties["icon"].value<QIcon>(); + if (m_properties[QStringLiteral("icon")].canConvert<QIcon>()) + opt->icon = m_properties[QStringLiteral("icon")].value<QIcon>(); setProperty("_q_showUnderlined", m_hints["showUnderlined"].toBool()); if (const QFont *font = QGuiApplicationPrivate::platformTheme()->font(m_itemType == ComboBoxItem ? QPlatformTheme::ComboMenuItemFont : QPlatformTheme::MenuFont)) { @@ -600,7 +600,7 @@ void QQuickStyleItem::initStyleOption() QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption); if (!on()) opt->state |= QStyle::State_Off; - if (m_properties.value("partiallyChecked").toBool()) + if (m_properties.value(QStringLiteral("partiallyChecked")).toBool()) opt->state |= QStyle::State_NoChange; opt->text = text(); } @@ -625,10 +625,11 @@ void QQuickStyleItem::initStyleOption() if (font) opt->fontMetrics = QFontMetrics(*font); opt->currentText = text(); - opt->editable = m_properties["editable"].toBool(); + opt->editable = m_properties[QStringLiteral("editable")].toBool(); #ifdef Q_OS_OSX - if (m_properties["popup"].canConvert<QObject *>() && style() == "mac") { - QObject *popup = m_properties["popup"].value<QObject *>(); + if (m_properties[QStringLiteral("popup")].canConvert<QObject *>() + && style() == QLatin1String("mac")) { + QObject *popup = m_properties[QStringLiteral("popup")].value<QObject *>(); if (platformFont == QPlatformTheme::MiniFont) { popup->setProperty("__xOffset", -2); popup->setProperty("__yOffset", 5); @@ -690,8 +691,8 @@ void QQuickStyleItem::initStyleOption() opt->sliderValue = value(); opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle; - opt->tickPosition = (activeControl() == "ticks" ? - QSlider::TicksBelow : QSlider::NoTicks); + opt->tickPosition = activeControl() == QLatin1String("ticks") ? + QSlider::TicksBelow : QSlider::NoTicks; if (opt->tickPosition != QSlider::NoTicks) opt->subControls |= QStyle::SC_SliderTickmarks; @@ -718,12 +719,12 @@ void QQuickStyleItem::initStyleOption() opt->lineWidth = 1; opt->subControls = QStyle::SC_GroupBoxLabel; opt->features = 0; - if (m_properties["sunken"].toBool()) { // Qt draws an ugly line here so I ignore it + if (m_properties[QStringLiteral("sunken")].toBool()) { // Qt draws an ugly line here so I ignore it opt->subControls |= QStyle::SC_GroupBoxFrame; } else { opt->features |= QStyleOptionFrame::Flat; } - if (m_properties["checkable"].toBool()) + if (m_properties[QStringLiteral("checkable")].toBool()) opt->subControls |= QStyle::SC_GroupBoxCheckBox; } @@ -805,9 +806,9 @@ void QQuickStyleItem::initStyleOption() } } - if (sizeHint == "mini") { + if (sizeHint == QLatin1String("mini")) { m_styleoption->state |= QStyle::State_Mini; - } else if (sizeHint == "small") { + } else if (sizeHint == QLatin1String("small")) { m_styleoption->state |= QStyle::State_Small; } @@ -888,7 +889,7 @@ QString QQuickStyleItem::style() const style = style.toLower(); if (style.startsWith(QLatin1Char('q'))) style = style.right(style.length() - 1); - if (style.endsWith("style")) + if (style.endsWith(QLatin1String("style"))) style = style.left(style.length() - 5); return style; } @@ -902,10 +903,9 @@ QString QQuickStyleItem::hitTest(int px, int py) qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), QPoint(px,py), 0); if (subcontrol == QStyle::SC_SpinBoxUp) - return "up"; + return QStringLiteral("up"); else if (subcontrol == QStyle::SC_SpinBoxDown) - return "down"; - + return QStringLiteral("down"); } break; @@ -914,32 +914,40 @@ QString QQuickStyleItem::hitTest(int px, int py) qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), QPoint(px,py), 0); if (subcontrol == QStyle::SC_SliderHandle) - return "handle"; - + return QStringLiteral("handle"); } break; + case ScrollBar: { subcontrol = qApp->style()->hitTestComplexControl(QStyle::CC_ScrollBar, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), QPoint(px,py), 0); - if (subcontrol == QStyle::SC_ScrollBarSlider) - return "handle"; + switch (subcontrol) { + case QStyle::SC_ScrollBarSlider: + return QStringLiteral("handle"); + + case QStyle::SC_ScrollBarSubLine: + return QStringLiteral("up"); + + case QStyle::SC_ScrollBarSubPage: + return QStringLiteral("upPage"); - if (subcontrol == QStyle::SC_ScrollBarSubLine) - return "up"; - else if (subcontrol == QStyle::SC_ScrollBarSubPage) - return "upPage"; + case QStyle::SC_ScrollBarAddLine: + return QStringLiteral("down"); - if (subcontrol == QStyle::SC_ScrollBarAddLine) - return "down"; - else if (subcontrol == QStyle::SC_ScrollBarAddPage) - return "downPage"; + case QStyle::SC_ScrollBarAddPage: + return QStringLiteral("downPage"); + + default: + break; + } } break; + default: break; } - return "none"; + return QStringLiteral("none"); } QSize QQuickStyleItem::sizeFromContents(int width, int height) @@ -955,7 +963,7 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) size = qApp->style()->sizeFromContents(QStyle::CT_CheckBox, m_styleoption, QSize(width,height)); break; case ToolBar: - size = QSize(200, style().contains("windows") ? 30 : 42); + size = QSize(200, style().contains(QLatin1String("windows")) ? 30 : 42); break; case ToolButton: { QStyleOptionToolButton *btn = qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption); @@ -999,7 +1007,7 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) int newHeight = qMax(height, contentHeight); size = qApp->style()->sizeFromContents(QStyle::CT_PushButton, m_styleoption, QSize(newWidth, newHeight)); } #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { // Cancel out QMacStylePrivate::PushButton*Offset, or part of it size -= QSize(7, 6); } @@ -1022,20 +1030,20 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) break; case SpinBox: #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { size = qApp->style()->sizeFromContents(QStyle::CT_SpinBox, m_styleoption, QSize(width, height + 5)); break; } #endif // fall through if not mac case Edit: #ifdef Q_OS_OSX - if (style() =="mac") { - QString sizeHint = m_hints.value("size").toString(); - if ((sizeHint == "small") || (sizeHint == "mini")) + if (style() == QLatin1String("mac")) { + QString sizeHint = m_hints.value(QStringLiteral("size")).toString(); + if (sizeHint == QLatin1String("small") || sizeHint == QLatin1String("mini")) size = QSize(width, 19); else size = QSize(width, 22); - if (style() == "mac" && hints().value("rounded").toBool()) + if (hints().value(QStringLiteral("rounded")).toBool()) size += QSize(4, 4); } else @@ -1069,7 +1077,7 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) case Header: size = qApp->style()->sizeFromContents(QStyle::CT_HeaderSection, m_styleoption, QSize(width,height)); #ifdef Q_OS_OSX - if (style() =="mac") + if (style() == QLatin1String("mac")) size.setHeight(15); #endif break; @@ -1120,7 +1128,7 @@ qreal QQuickStyleItem::baselineOffset() case ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(m_styleoption)) { r = qApp->style()->subControlRect(QStyle::CC_ComboBox, combo, QStyle::SC_ComboBoxEditField); - if (style() != QStringLiteral("mac")) + if (style() != QLatin1String("mac")) r.adjust(0,0,0,1); } break; @@ -1140,7 +1148,7 @@ qreal QQuickStyleItem::baselineOffset() surplus++; int result = r.top() + surplus/2 + fm.ascent(); #ifdef Q_OS_OSX - if (style() == QStringLiteral("mac")) { + if (style() == QLatin1String("mac")) { switch (m_itemType) { case Button: case Edit: @@ -1200,47 +1208,47 @@ void QQuickStyleItem::updateRect() int QQuickStyleItem::pixelMetric(const QString &metric) { - if (metric == "scrollbarExtent") + if (metric == QLatin1String("scrollbarExtent")) return qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0 ); - else if (metric == "defaultframewidth") + else if (metric == QLatin1String("defaultframewidth")) return qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, m_styleoption); - else if (metric == "taboverlap") + else if (metric == QLatin1String("taboverlap")) return qApp->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ); - else if (metric == "tabbaseoverlap") + else if (metric == QLatin1String("tabbaseoverlap")) return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, m_styleoption ); - else if (metric == "tabhspace") + else if (metric == QLatin1String("tabhspace")) return qApp->style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0 ); - else if (metric == "indicatorwidth") + else if (metric == QLatin1String("indicatorwidth")) return qApp->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, 0 ); - else if (metric == "tabvspace") + else if (metric == QLatin1String("tabvspace")) return qApp->style()->pixelMetric(QStyle::PM_TabBarTabVSpace, 0 ); - else if (metric == "tabbaseheight") + else if (metric == QLatin1String("tabbaseheight")) return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0 ); - else if (metric == "tabvshift") + else if (metric == QLatin1String("tabvshift")) return qApp->style()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, 0 ); - else if (metric == "menubarhmargin") + else if (metric == QLatin1String("menubarhmargin")) return qApp->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0 ); - else if (metric == "menubarvmargin") + else if (metric == QLatin1String("menubarvmargin")) return qApp->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0 ); - else if (metric == "menubarpanelwidth") + else if (metric == QLatin1String("menubarpanelwidth")) return qApp->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0 ); - else if (metric == "menubaritemspacing") + else if (metric == QLatin1String("menubaritemspacing")) return qApp->style()->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0 ); - else if (metric == "spacebelowmenubar") + else if (metric == QLatin1String("spacebelowmenubar")) return qApp->style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, m_styleoption); - else if (metric == "menuhmargin") + else if (metric == QLatin1String("menuhmargin")) return qApp->style()->pixelMetric(QStyle::PM_MenuHMargin, 0 ); - else if (metric == "menuvmargin") + else if (metric == QLatin1String("menuvmargin")) return qApp->style()->pixelMetric(QStyle::PM_MenuVMargin, 0 ); - else if (metric == "menupanelwidth") + else if (metric == QLatin1String("menupanelwidth")) return qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0 ); - else if (metric == "submenuoverlap") + else if (metric == QLatin1String("submenuoverlap")) return qApp->style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0 ); - else if (metric == "splitterwidth") + else if (metric == QLatin1String("splitterwidth")) return qApp->style()->pixelMetric(QStyle::PM_SplitterWidth, 0 ); - else if (metric == "scrollbarspacing") + else if (metric == QLatin1String("scrollbarspacing")) return abs(qApp->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, 0 )); - else if (metric == "treeviewindentation") + else if (metric == QLatin1String("treeviewindentation")) return qApp->style()->pixelMetric(QStyle::PM_TreeViewIndentation, 0 ); return 0; } @@ -1248,30 +1256,30 @@ int QQuickStyleItem::pixelMetric(const QString &metric) QVariant QQuickStyleItem::styleHint(const QString &metric) { initStyleOption(); - if (metric == "comboboxpopup") { + if (metric == QLatin1String("comboboxpopup")) { return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption); - } else if (metric == "highlightedTextColor") { + } else if (metric == QLatin1String("highlightedTextColor")) { return m_styleoption->palette.highlightedText().color().name(); - } else if (metric == "textColor") { + } else if (metric == QLatin1String("textColor")) { QPalette pal = m_styleoption->palette; pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive); return pal.text().color().name(); - } else if (metric == "focuswidget") { + } else if (metric == QLatin1String("focuswidget")) { return qApp->style()->styleHint(QStyle::SH_FocusFrame_AboveWidget); - } else if (metric == "tabbaralignment") { + } else if (metric == QLatin1String("tabbaralignment")) { int result = qApp->style()->styleHint(QStyle::SH_TabBar_Alignment); if (result == Qt::AlignCenter) - return "center"; - return "left"; - } else if (metric == "externalScrollBars") { + return QStringLiteral("center"); + return QStringLiteral("left"); + } else if (metric == QLatin1String("externalScrollBars")) { return qApp->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents); - } else if (metric == "scrollToClickPosition") + } else if (metric == QLatin1String("scrollToClickPosition")) return qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition); - else if (metric == "activateItemOnSingleClick") + else if (metric == QLatin1String("activateItemOnSingleClick")) return qApp->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick); - else if (metric == "submenupopupdelay") + else if (metric == QLatin1String("submenupopupdelay")) return qApp->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, m_styleoption); - else if (metric == "wheelScrollLines") + else if (metric == QLatin1String("wheelScrollLines")) return qApp->wheelScrollLines(); return 0; @@ -1316,76 +1324,76 @@ void QQuickStyleItem::setElementType(const QString &str) } // Only enable visible if the widget can animate - if (str == "menu") { + if (str == QLatin1String("menu")) { m_itemType = Menu; - } else if (str == "menuitem") { + } else if (str == QLatin1String("menuitem")) { m_itemType = MenuItem; - } else if (str == "item" || str == "itemrow" || str == "header") { + } else if (str == QLatin1String("item") || str == QLatin1String("itemrow") || str == QLatin1String("header")) { #ifdef Q_OS_OSX m_font.setPointSize(11.0); emit fontChanged(); #endif - if (str == "header") { + if (str == QLatin1String("header")) { m_itemType = Header; } else { - m_itemType = (str == "item") ? Item : ItemRow; + m_itemType = str == QLatin1String("item") ? Item : ItemRow; } - } else if (str == "itembranchindicator") { + } else if (str == QLatin1String("itembranchindicator")) { m_itemType = ItemBranchIndicator; - } else if (str == "groupbox") { + } else if (str == QLatin1String("groupbox")) { m_itemType = GroupBox; - } else if (str == "tab") { + } else if (str == QLatin1String("tab")) { m_itemType = Tab; - } else if (str == "tabframe") { + } else if (str == QLatin1String("tabframe")) { m_itemType = TabFrame; - } else if (str == "comboboxitem") { + } else if (str == QLatin1String("comboboxitem")) { // Gtk uses qobject cast, hence we need to separate this from menuitem // On mac, we temporarily use the menu item because it has more accurate // palette. m_itemType = ComboBoxItem; - } else if (str == "toolbar") { + } else if (str == QLatin1String("toolbar")) { m_itemType = ToolBar; - } else if (str == "toolbutton") { + } else if (str == QLatin1String("toolbutton")) { m_itemType = ToolButton; - } else if (str == "slider") { + } else if (str == QLatin1String("slider")) { m_itemType = Slider; - } else if (str == "frame") { + } else if (str == QLatin1String("frame")) { m_itemType = Frame; - } else if (str == "combobox") { + } else if (str == QLatin1String("combobox")) { m_itemType = ComboBox; - } else if (str == "splitter") { + } else if (str == QLatin1String("splitter")) { m_itemType = Splitter; - } else if (str == "progressbar") { + } else if (str == QLatin1String("progressbar")) { m_itemType = ProgressBar; - } else if (str == "button") { + } else if (str == QLatin1String("button")) { m_itemType = Button; - } else if (str == "checkbox") { + } else if (str == QLatin1String("checkbox")) { m_itemType = CheckBox; - } else if (str == "radiobutton") { + } else if (str == QLatin1String("radiobutton")) { m_itemType = RadioButton; - } else if (str == "edit") { + } else if (str == QLatin1String("edit")) { m_itemType = Edit; - } else if (str == "spinbox") { + } else if (str == QLatin1String("spinbox")) { m_itemType = SpinBox; - } else if (str == "scrollbar") { + } else if (str == QLatin1String("scrollbar")) { m_itemType = ScrollBar; - } else if (str == "widget") { + } else if (str == QLatin1String("widget")) { m_itemType = Widget; - } else if (str == "focusframe") { + } else if (str == QLatin1String("focusframe")) { m_itemType = FocusFrame; - } else if (str == "focusrect") { + } else if (str == QLatin1String("focusrect")) { m_itemType = FocusRect; - } else if (str == "dial") { + } else if (str == QLatin1String("dial")) { m_itemType = Dial; - } else if (str == "statusbar") { + } else if (str == QLatin1String("statusbar")) { m_itemType = StatusBar; - } else if (str == "machelpbutton") { + } else if (str == QLatin1String("machelpbutton")) { m_itemType = MacHelpButton; - } else if (str == "scrollareacorner") { + } else if (str == QLatin1String("scrollareacorner")) { m_itemType = ScrollAreaCorner; - } else if (str == "menubar") { + } else if (str == QLatin1String("menubar")) { m_itemType = MenuBar; - } else if (str == "menubaritem") { + } else if (str == QLatin1String("menubaritem")) { m_itemType = MenuBarItem; } else { m_itemType = Undefined; @@ -1500,7 +1508,7 @@ void QQuickStyleItem::paint(QPainter *painter) switch (m_itemType) { case Button: #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { // Add back what was substracted in sizeFromContents() m_styleoption->rect.adjust(-4, -2, 3, 4); } @@ -1517,7 +1525,7 @@ void QQuickStyleItem::paint(QPainter *painter) pixmap.fill(Qt::transparent); QPainter pixpainter(&pixmap); qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter); - if ((style() == "mac" || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected)) && selected()) { + if ((style() == QLatin1String("mac") || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected)) && selected()) { QPalette pal = QApplication::palette("QAbstractItemView"); pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup()); pixpainter.fillRect(m_styleoption->rect, pal.highlight()); @@ -1539,7 +1547,7 @@ void QQuickStyleItem::paint(QPainter *painter) case ToolButton: #ifdef Q_OS_OSX - if (style() == "mac" && hints().value("segmented").toBool()) { + if (style() == QLatin1String("mac") && hints().value(QStringLiteral("segmented")).toBool()) { const QPaintDevice *target = painter->device(); HIThemeSegmentDrawInfo sgi; sgi.version = 0; @@ -1555,10 +1563,10 @@ void QQuickStyleItem::paint(QPainter *painter) } SInt32 button_height; GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height); - QString buttonPos = m_properties.value("position").toString(); - sgi.position = buttonPos == "leftmost" ? kHIThemeSegmentPositionFirst : - buttonPos == "rightmost" ? kHIThemeSegmentPositionLast : - buttonPos == "h_middle" ? kHIThemeSegmentPositionMiddle : + QString buttonPos = m_properties.value(QStringLiteral("position")).toString(); + sgi.position = buttonPos == QLatin1String("leftmost") ? kHIThemeSegmentPositionFirst : + buttonPos == QLatin1String("rightmost") ? kHIThemeSegmentPositionLast : + buttonPos == QLatin1String("h_middle") ? kHIThemeSegmentPositionMiddle : kHIThemeSegmentPositionOnly; QRect centered = m_styleoption->rect; centered.setHeight(button_height); @@ -1571,7 +1579,7 @@ void QQuickStyleItem::paint(QPainter *painter) break; case Tab: #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { m_styleoption->rect.translate(0, 1); // Unhack QMacStyle's hack qApp->style()->drawControl(QStyle::CE_TabBarTabShape, m_styleoption, painter); m_styleoption->rect.translate(0, -1); @@ -1616,7 +1624,7 @@ void QQuickStyleItem::paint(QPainter *painter) break; case Edit: { #ifdef Q_OS_OSX - if (style() == "mac" && hints().value("rounded").toBool()) { + if (style() == QLatin1String("mac") && hints().value(QStringLiteral("rounded")).toBool()) { const QPaintDevice *target = painter->device(); HIThemeFrameDrawInfo fdi; fdi.version = 0; @@ -1674,7 +1682,7 @@ void QQuickStyleItem::paint(QPainter *painter) case SpinBox: #ifdef Q_OS_MAC // macstyle depends on the embedded qlineedit to fill the editfield background - if (style() == "mac") { + if (style() == QLatin1String("mac")) { QRect editRect = qApp->style()->subControlRect(QStyle::CC_SpinBox, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), QStyle::SC_SpinBoxEditField); @@ -1702,14 +1710,14 @@ void QQuickStyleItem::paint(QPainter *painter) painter->fillRect(m_styleoption->rect, m_styleoption->palette.window().color()); qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter); painter->save(); - painter->setPen(style() != "fusion" ? m_styleoption->palette.dark().color().darker(120) : + painter->setPen(style() != QLatin1String("fusion") ? m_styleoption->palette.dark().color().darker(120) : m_styleoption->palette.window().color().lighter(107)); painter->drawLine(m_styleoption->rect.bottomLeft(), m_styleoption->rect.bottomRight()); painter->restore(); break; case StatusBar: #ifdef Q_OS_OSX - if (style() == "mac") { + if (style() == QLatin1String("mac")) { qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter); painter->setPen(m_styleoption->palette.dark().color().darker(120)); painter->drawLine(m_styleoption->rect.topLeft(), m_styleoption->rect.topRight()); @@ -1876,20 +1884,20 @@ QPixmap QQuickTableRowImageProvider::requestPixmap(const QString &id, QSize *siz QString style = qApp->style()->metaObject()->className(); opt.features = 0; - if (id.contains("selected")) + if (id.contains(QLatin1String("selected"))) opt.state |= QStyle::State_Selected; - if (id.contains("active")) { + if (id.contains(QLatin1String("active"))) { opt.state |= QStyle::State_Active; opt.palette.setCurrentColorGroup(QPalette::Active); } else opt.palette.setCurrentColorGroup(QPalette::Inactive); - if (id.contains("alternate")) + if (id.contains(QLatin1String("alternate"))) opt.features |= QStyleOptionViewItem::Alternate; QPalette pal = QApplication::palette("QAbstractItemView"); - if (opt.state & QStyle::State_Selected && (style.contains("Mac") || + if (opt.state & QStyle::State_Selected && (style.contains(QLatin1String("Mac")) || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected))) { pal.setCurrentColorGroup(opt.palette.currentColorGroup()); pixmap.fill(pal.highlight().color()); |