summaryrefslogtreecommitdiff
path: root/src/private
diff options
context:
space:
mode:
Diffstat (limited to 'src/private')
-rw-r--r--src/private/AbstractCheckable.qml17
-rw-r--r--src/private/BasicButton.qml46
-rw-r--r--src/private/Control.qml6
-rw-r--r--src/private/ScrollBar.qml2
-rw-r--r--src/private/ScrollViewHelper.qml12
-rw-r--r--src/private/Style.qml3
-rw-r--r--src/private/TabBar.qml11
-rw-r--r--src/private/plugin.cpp4
-rw-r--r--src/private/private.pro6
-rw-r--r--src/private/qmldir2
-rw-r--r--src/private/qquickabstractstyle.cpp (renamed from src/private/qquickpaddedstyle.cpp)58
-rw-r--r--src/private/qquickabstractstyle_p.h (renamed from src/private/qquickpaddedstyle_p.h)25
-rw-r--r--src/private/qquickcontrolsettings.cpp11
-rw-r--r--src/private/qquickcontrolsettings_p.h3
-rw-r--r--src/private/qquickstyleitem.cpp108
-rw-r--r--src/private/qquickstyleitem_p.h9
-rw-r--r--src/private/style.js15
17 files changed, 221 insertions, 117 deletions
diff --git a/src/private/AbstractCheckable.qml b/src/private/AbstractCheckable.qml
index ba203e4d..02348b71 100644
--- a/src/private/AbstractCheckable.qml
+++ b/src/private/AbstractCheckable.qml
@@ -69,10 +69,16 @@ Control {
/*!
\qmlproperty bool AbstractCheckable::pressed
- This property is \c true if the control is pressed.
+ This property is \c true if the control is being pressed.
Set this property to manually invoke a mouse click.
*/
- readonly property alias pressed: mouseArea.effectivePressed
+ property alias pressed: mouseArea.effectivePressed
+
+ /*! \qmlproperty bool AbstractCheckcable::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: mouseArea.containsMouse
/*!
This property is \c true if the control is checked.
@@ -99,13 +105,6 @@ Control {
/*! \internal */
property var __cycleStatesHandler: cycleRadioButtonStates
- /*! \internal
-
- This property is \c true if the control currently contains the
- mouse cursor.
- */
- readonly property alias __containsMouse: mouseArea.containsMouse
-
activeFocusOnTab: true
MouseArea {
diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml
index 3ef4b6e9..b5e9ab8f 100644
--- a/src/private/BasicButton.qml
+++ b/src/private/BasicButton.qml
@@ -42,6 +42,7 @@ import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Styles 1.0
+import "style.js" as StyleHelpers
/*!
\qmltype BasicButton
@@ -58,8 +59,14 @@ Control {
/*! \qmlproperty bool BasicButton::pressed
- This property holds whether the button is pressed. */
- readonly property bool pressed: behavior.effectivePressed
+ This property holds whether the button is being pressed. */
+ readonly property alias pressed: behavior.effectivePressed
+
+ /*! \qmlproperty bool BasicButton::hovered
+
+ This property indicates whether the control is being hovered.
+ */
+ readonly property alias hovered: behavior.containsMouse
/*! This property holds whether the button is checkable.
@@ -83,6 +90,9 @@ Control {
If a button has an action associated, the action defines the
button's properties like checked, text, tooltip etc.
+ When an action is set, it's still possible to override the \l text,
+ \l tooltip, \l iconSource, and \l iconName properties.
+
The default value is \c null. */
property Action action: null
@@ -91,17 +101,39 @@ Control {
The default value is \c false. */
property bool activeFocusOnPress: false
+ /*! This property holds the text shown on the button. If the button has no
+ text, the \l text property will be an empty string.
+
+ The default value is the empty string.
+ */
+ property string text: action ? action.text : ""
+
/*! This property holds the button tooltip. */
- property string tooltip
+ property string tooltip: action ? (action.tooltip || StyleHelpers.removeMnemonics(action.text)) : ""
+
+ /*! This property holds the icon shown on the button. If the button has no
+ icon, the iconSource property will be an empty string.
+
+ The default value is the empty string.
+ */
+ property url iconSource: action ? action.iconSource : ""
+
+ /*! The image label source as theme name.
+ When an icon from the platform icon theme is found, this takes
+ precedence over iconSource.
+ */
+ property string iconName: action ? action.iconName : ""
/*! \internal */
property color __textColor: syspal.text
/*! \internal */
property string __position: "only"
/*! \internal */
- property alias __containsMouse: behavior.containsMouse
+ readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName)
/*! \internal */
property Action __action: action || ownAction
+ /*! \internal */
+ readonly property Action __iconAction: __iconOverriden ? ownAction : __action
/*! \internal */
onExclusiveGroupChanged: {
@@ -119,7 +151,8 @@ Control {
Action {
id: ownAction
- iconSource: !button.action ? button.iconSource : ""
+ iconSource: !button.action || __iconOverriden ? button.iconSource : ""
+ iconName: !button.action || __iconOverriden ? button.iconName : ""
}
Connections {
@@ -181,9 +214,6 @@ Control {
enabled: action.enabled
checkable: action.checkable
checked: action.checked
- text: action.text
- iconSource: action.iconSource
- tooltip: action.tooltip
}
}
]
diff --git a/src/private/Control.qml b/src/private/Control.qml
index d518adb2..05916c0a 100644
--- a/src/private/Control.qml
+++ b/src/private/Control.qml
@@ -64,14 +64,14 @@ FocusScope {
property Item __panel: panelLoader.item
/*! \internal */
- property var styleHints: []
+ property var styleHints
implicitWidth: __panel ? __panel.implicitWidth: 0
implicitHeight: __panel ? __panel.implicitHeight: 0
activeFocusOnTab: false
/*! \internal */
- property alias __controlState: styleLoader.controlState
+ property alias __styleData: styleLoader.styleData
Loader {
id: panelLoader
@@ -82,7 +82,7 @@ FocusScope {
id: styleLoader
sourceComponent: style
property Item __control: root
- property QtObject controlState: null
+ property QtObject styleData: null
onStatusChanged: {
if (status === Loader.Error)
console.error("Failed to load Style for", root)
diff --git a/src/private/ScrollBar.qml b/src/private/ScrollBar.qml
index ad26d249..2f8e80bc 100644
--- a/src/private/ScrollBar.qml
+++ b/src/private/ScrollBar.qml
@@ -75,7 +75,7 @@ Item {
sourceComponent: __style ? __style.__scrollbar : null
onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
property alias __control: scrollbar
- property QtObject controlState: QtObject {
+ property QtObject __styleData: QtObject {
readonly property alias horizontal: internal.horizontal
readonly property alias upPressed: scrollbar.upPressed
readonly property alias downPressed: scrollbar.downPressed
diff --git a/src/private/ScrollViewHelper.qml b/src/private/ScrollViewHelper.qml
index cf5c514f..9e8e78d6 100644
--- a/src/private/ScrollViewHelper.qml
+++ b/src/private/ScrollViewHelper.qml
@@ -57,6 +57,8 @@ Item {
property int availableWidth
property int contentHeight
property int contentWidth
+ property real originX
+ property real originY
property int leftMargin: outerFrame ? root.__style.padding.left : 0
property int rightMargin: outerFrame ? root.__style.padding.right : 0
@@ -74,6 +76,8 @@ Item {
wheelarea.availableHeight = viewport.height
wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
+ wheelarea.originX = flickableItem !== null ? flickableItem.originX : 0
+ wheelarea.originY = flickableItem !== null ? flickableItem.originY : 0
recursionGuard = false
}
}
@@ -123,8 +127,8 @@ Item {
visible: contentWidth > availableWidth
height: visible ? implicitHeight : 0
z: 1
- maximumValue: contentWidth > availableWidth ? contentWidth - availableWidth : 0
- minimumValue: 0
+ maximumValue: contentWidth > availableWidth ? originX + contentWidth - availableWidth : 0
+ minimumValue: originX
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: cornerFill.left
@@ -158,8 +162,8 @@ Item {
width: visible ? implicitWidth : 0
z: 1
anchors.bottom: cornerFill.top
- maximumValue: contentHeight > availableHeight ? contentHeight - availableHeight + __viewTopMargin : 0
- minimumValue: 0
+ maximumValue: contentHeight > availableHeight ? originY + contentHeight - availableHeight + __viewTopMargin : 0
+ minimumValue: originY
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: __scrollBarTopMargin + topMargin
diff --git a/src/private/Style.qml b/src/private/Style.qml
index 990f61dd..6b4c08ef 100644
--- a/src/private/Style.qml
+++ b/src/private/Style.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype Style
@@ -46,7 +47,7 @@ import QtQuick.Controls 1.0
\inqmlmodule QtQuick.Controls.Private 1.0
*/
-QtObject {
+AbstractStyle {
/*! The control attached to this style */
readonly property Item control: __control
diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml
index 49b10584..f51d60b2 100644
--- a/src/private/TabBar.qml
+++ b/src/private/TabBar.qml
@@ -170,7 +170,6 @@ FocusScope {
property int tabindex: index
property bool selected : tabView.currentIndex === index
- property bool hover: containsMouse
property string title: modelData.title
property bool nextSelected: tabView.currentIndex === index + 1
property bool previousSelected: tabView.currentIndex === index - 1
@@ -182,10 +181,8 @@ FocusScope {
onPressed: {
tabView.currentIndex = index;
var next = tabbar.nextItemInFocusChain(true);
- if (__isAncestorOf(tabView.tabAt(currentIndex), next))
+ if (__isAncestorOf(tabView.getTab(currentIndex), next))
next.forceActiveFocus();
- else
- tabitem.forceActiveFocus();
}
Loader {
@@ -193,16 +190,16 @@ FocusScope {
property Item control: tabView
property int index: tabindex
- property real availableWidth: tabbar.availableWidth
- property QtObject tab: QtObject {
+ property QtObject styleData: QtObject {
readonly property alias index: tabitem.tabindex
readonly property alias selected: tabitem.selected
readonly property alias title: tabitem.title
readonly property alias nextSelected: tabitem.nextSelected
readonly property alias previsousSelected: tabitem.previousSelected
- readonly property alias hovered: tabitem.hover
+ readonly property alias hovered: tabitem.containsMouse
readonly property bool activeFocus: tabbar.activeFocus
+ readonly property real availableWidth: tabbar.availableWidth
}
sourceComponent: loader.item ? loader.item.tab : null
diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp
index 17bfed07..e33c2d37 100644
--- a/src/private/plugin.cpp
+++ b/src/private/plugin.cpp
@@ -45,7 +45,7 @@
#include "qquicktooltip_p.h"
#include "qquickcontrolsettings_p.h"
#include "qquickspinboxvalidator_p.h"
-#include "qquickpaddedstyle_p.h"
+#include "qquickabstractstyle_p.h"
#ifndef QT_NO_WIDGETS
#include "qquickstyleitem_p.h"
@@ -81,7 +81,7 @@ public:
void QtQuickControlsPrivatePlugin::registerTypes(const char *uri)
{
- qmlRegisterType<QQuickPaddedStyle>(uri, 1, 0, "PaddedStyle");
+ qmlRegisterType<QQuickAbstractStyle>(uri, 1, 0, "AbstractStyle");
qmlRegisterType<QQuickPadding>();
qmlRegisterType<QQuickRangeModel>(uri, 1, 0, "RangeModel");
qmlRegisterType<QQuickWheelArea>(uri, 1, 0, "WheelArea");
diff --git a/src/private/private.pro b/src/private/private.pro
index 9f892452..803b703f 100644
--- a/src/private/private.pro
+++ b/src/private/private.pro
@@ -1,4 +1,4 @@
-TARGET = qtquickcontrolsprivate
+TARGET = qtquickcontrolsprivateplugin
TARGETPATH = QtQuick/Controls/Private
QT += qml quick gui-private core-private
@@ -10,7 +10,7 @@ HEADERS += \
$$PWD/qquickrangemodel_p_p.h \
$$PWD/qquickcontrolsettings_p.h \
$$PWD/qquickwheelarea_p.h \
- $$PWD/qquickpaddedstyle_p.h \
+ $$PWD/qquickabstractstyle_p.h \
$$PWD/qquickpadding_p.h
SOURCES += \
@@ -20,7 +20,7 @@ SOURCES += \
$$PWD/qquickrangemodel.cpp \
$$PWD/qquickcontrolsettings.cpp \
$$PWD/qquickwheelarea.cpp \
- $$PWD/qquickpaddedstyle.cpp
+ $$PWD/qquickabstractstyle.cpp
# private qml files
QML_FILES += \
diff --git a/src/private/qmldir b/src/private/qmldir
index d4b7fc46..7f73028e 100644
--- a/src/private/qmldir
+++ b/src/private/qmldir
@@ -1,5 +1,5 @@
module QtQuick.Controls.Private
-plugin qtquickcontrolsprivate
+plugin qtquickcontrolsprivateplugin
AbstractCheckable 1.0 AbstractCheckable.qml
Control 1.0 Control.qml
FocusFrame 1.0 FocusFrame.qml
diff --git a/src/private/qquickpaddedstyle.cpp b/src/private/qquickabstractstyle.cpp
index 320a3f53..eba57b03 100644
--- a/src/private/qquickpaddedstyle.cpp
+++ b/src/private/qquickabstractstyle.cpp
@@ -39,30 +39,60 @@
**
****************************************************************************/
-#include "qquickpaddedstyle_p.h"
-#include "qquickpadding_p.h"
+#include "qquickabstractstyle_p.h"
+
+QT_BEGIN_NAMESPACE
/*!
- \qmltype PaddedStyle
- \instantiates QQuickPaddedStyle
+ \qmltype AbstractStyle
+ \instantiates QQuickAbstractStyle
\qmlabstract
\internal
*/
-QT_BEGIN_NAMESPACE
+/*!
+ \qmlproperty int AbstractStyle::padding.top
+ \qmlproperty int AbstractStyle::padding.left
+ \qmlproperty int AbstractStyle::padding.right
+ \qmlproperty int AbstractStyle::padding.bottom
+
+ This grouped property holds the \c top, \c left, \c right and \c bottom padding.
+*/
-QQuickPaddedStyle::QQuickPaddedStyle(QQuickItem *parent) :
- QQuickItem(parent)
+QQuickAbstractStyle::QQuickAbstractStyle(QObject *parent) : QObject(parent)
{
}
-/*!
- \qmlproperty int PaddedStyle::padding.top
- \qmlproperty int PaddedStyle::padding.left
- \qmlproperty int PaddedStyle::padding.right
- \qmlproperty int PaddedStyle::padding.bottom
+QQmlListProperty<QObject> QQuickAbstractStyle::data()
+{
+ return QQmlListProperty<QObject>(this, 0, &QQuickAbstractStyle::data_append, &QQuickAbstractStyle::data_count,
+ &QQuickAbstractStyle::data_at, &QQuickAbstractStyle::data_clear);
+}
- This grouped property holds the \c top, \c left, \c right and \c bottom padding.
-*/
+void QQuickAbstractStyle::data_append(QQmlListProperty<QObject> *list, QObject *object)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ style->m_data.append(object);
+}
+
+int QQuickAbstractStyle::data_count(QQmlListProperty<QObject> *list)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ return style->m_data.count();
+ return 0;
+}
+
+QObject *QQuickAbstractStyle::data_at(QQmlListProperty<QObject> *list, int index)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ return style->m_data.at(index);
+ return 0;
+}
+
+void QQuickAbstractStyle::data_clear(QQmlListProperty<QObject> *list)
+{
+ if (QQuickAbstractStyle *style = qobject_cast<QQuickAbstractStyle *>(list->object))
+ style->m_data.clear();
+}
QT_END_NAMESPACE
diff --git a/src/private/qquickpaddedstyle_p.h b/src/private/qquickabstractstyle_p.h
index 1a5a3c95..13764053 100644
--- a/src/private/qquickpaddedstyle_p.h
+++ b/src/private/qquickabstractstyle_p.h
@@ -39,29 +39,40 @@
**
****************************************************************************/
-#ifndef QQUICKPADDEDSTYLE_H
-#define QQUICKPADDEDSTYLE_H
+#ifndef QQUICKABSTRACTSTYLE_H
+#define QQUICKABSTRACTSTYLE_H
-#include <QtQuick/QQuickItem>
-#include <QtQml/QQmlListProperty>
+#include <QtCore/qobject.h>
+#include <QtQml/qqmllist.h>
#include "qquickpadding_p.h"
QT_BEGIN_NAMESPACE
-class QQuickPaddedStyle : public QQuickItem
+class QQuickAbstractStyle : public QObject
{
Q_OBJECT
Q_PROPERTY(QQuickPadding* padding READ padding CONSTANT)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "data")
public:
- QQuickPaddedStyle(QQuickItem *parent = 0);
+ QQuickAbstractStyle(QObject *parent = 0);
+
QQuickPadding* padding() { return &m_padding; }
+ QQmlListProperty<QObject> data();
+
private:
+ static void data_append(QQmlListProperty<QObject> *list, QObject *object);
+ static int data_count(QQmlListProperty<QObject> *list);
+ static QObject *data_at(QQmlListProperty<QObject> *list, int index);
+ static void data_clear(QQmlListProperty<QObject> *list);
+
QQuickPadding m_padding;
+ QList<QObject *> m_data;
};
QT_END_NAMESPACE
-#endif // QQUICKPADDEDSTYLE_H
+#endif // QQUICKABSTRACTSTYLE_H
diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp
index 44db49c2..e2daa17f 100644
--- a/src/private/qquickcontrolsettings.cpp
+++ b/src/private/qquickcontrolsettings.cpp
@@ -133,4 +133,15 @@ QString QQuickControlSettings::styleFilePath() const
return m_path + QLatin1Char('/') + m_name;
}
+extern Q_GUI_EXPORT int qt_defaultDpiX();
+
+qreal QQuickControlSettings::dpiScaleFactor() const
+{
+#ifndef Q_OS_MAC
+ return (qreal(qt_defaultDpiX()) / 96.0);
+#endif
+ return 1.0;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h
index 98e85151..8ff0ecbf 100644
--- a/src/private/qquickcontrolsettings_p.h
+++ b/src/private/qquickcontrolsettings_p.h
@@ -55,6 +55,7 @@ class QQuickControlSettings : public QObject
Q_PROPERTY(QUrl style READ style NOTIFY styleChanged)
Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged)
Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged)
+ Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT)
public:
QQuickControlSettings(QQmlEngine *engine);
@@ -67,6 +68,8 @@ public:
QString stylePath() const;
void setStylePath(const QString &path);
+ qreal dpiScaleFactor() const;
+
signals:
void styleChanged();
void styleNameChanged();
diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp
index cfbb36c8..115841ad 100644
--- a/src/private/qquickstyleitem.cpp
+++ b/src/private/qquickstyleitem.cpp
@@ -177,8 +177,9 @@ void QQuickStyleItem::initStyleOption()
if (m_styleoption)
m_styleoption->state = 0;
- QPlatformTheme::Font platformFont = (m_hints.indexOf("mini") != -1) ? QPlatformTheme::MiniFont :
- (m_hints.indexOf("small") != -1) ? QPlatformTheme::SmallFont :
+ QString sizeHint = m_hints.value("size").toString();
+ QPlatformTheme::Font platformFont = (sizeHint == "mini") ? QPlatformTheme::MiniFont :
+ (sizeHint == "small") ? QPlatformTheme::SmallFont :
QPlatformTheme::SystemFont;
switch (m_itemType) {
@@ -266,11 +267,12 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionHeader::SortDown
: activeControl() == "up" ?
QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
- if (hints().contains("beginning"))
+ QString headerpos = m_properties.value("headerpos").toString();
+ if (headerpos == "beginning")
opt->position = QStyleOptionHeader::Beginning;
- else if (hints().contains("end"))
+ else if (headerpos == "end")
opt->position = QStyleOptionHeader::End;
- else if (hints().contains("only"))
+ else if (headerpos == "only")
opt->position = QStyleOptionHeader::OnlyOneSection;
else
opt->position = QStyleOptionHeader::Middle;
@@ -318,32 +320,30 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionTab *opt = qstyleoption_cast<QStyleOptionTab*>(m_styleoption);
opt->text = text();
- if (m_properties["hasFrame"].toBool())
+ if (m_properties.value("hasFrame").toBool())
opt->features |= QStyleOptionTab::HasFrame;
- if (hints().length() > 2) {
- QString orientation = hints()[0];
- QString position = hints()[1];
- QString selectedPosition = hints()[2];
-
- opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ QString orientation = m_properties.value("orientation").toString();
+ QString position = m_properties.value("tabpos").toString();
+ QString selectedPosition = m_properties.value("selectedpos").toString();
+
+ opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ if (position == QLatin1String("beginning"))
+ opt->position = QStyleOptionTab::Beginning;
+ else if (position == QLatin1String("end"))
+ opt->position = QStyleOptionTab::End;
+ else if (position == QLatin1String("only"))
+ opt->position = QStyleOptionTab::OnlyOneTab;
+ else
+ opt->position = QStyleOptionTab::Middle;
- if (position == QLatin1String("beginning"))
- opt->position = QStyleOptionTab::Beginning;
- else if (position == QLatin1String("end"))
- opt->position = QStyleOptionTab::End;
- else if (position == QLatin1String("only"))
- opt->position = QStyleOptionTab::OnlyOneTab;
- else
- opt->position = QStyleOptionTab::Middle;
+ if (selectedPosition == QLatin1String("next"))
+ opt->selectedPosition = QStyleOptionTab::NextIsSelected;
+ else if (selectedPosition == QLatin1String("previous"))
+ opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
+ else
+ opt->selectedPosition = QStyleOptionTab::NotAdjacent;
- if (selectedPosition == QLatin1String("next"))
- opt->selectedPosition = QStyleOptionTab::NextIsSelected;
- else if (selectedPosition == QLatin1String("previous"))
- opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
- else
- opt->selectedPosition = QStyleOptionTab::NotAdjacent;
- }
} break;
@@ -459,7 +459,7 @@ void QQuickStyleItem::initStyleOption()
QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
if (!on())
opt->state |= QStyle::State_Off;
- if (m_hints.contains("partiallyChecked"))
+ if (m_properties.value("partiallyChecked").toBool())
opt->state |= QStyle::State_NoChange;
opt->text = text();
}
@@ -643,9 +643,9 @@ void QQuickStyleItem::initStyleOption()
if (m_horizontal)
m_styleoption->state |= QStyle::State_Horizontal;
- if (m_hints.indexOf("mini") != -1) {
+ if (sizeHint == "mini") {
m_styleoption->state |= QStyle::State_Mini;
- } else if (m_hints.indexOf("small") != -1) {
+ } else if (sizeHint == "small") {
m_styleoption->state |= QStyle::State_Small;
}
@@ -734,7 +734,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, 40);
+ size = QSize(200, style().contains("windows") ? 30 : 42);
break;
case ToolButton: {
QStyleOptionToolButton *btn = qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
@@ -801,10 +801,14 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height)
case Edit:
#ifdef Q_OS_MAC
if (style() =="mac") {
- if (m_hints.indexOf("small") != -1 || m_hints.indexOf("mini") != -1)
+ QString sizeHint = m_hints.value("size").toString();
+ if ((sizeHint == "small") || (sizeHint == "mini"))
size = QSize(width, 19);
else
size = QSize(width, 22);
+ if (style() == "mac" && hints().value("rounded").toBool())
+ size += QSize(4, 4);
+
} else
#endif
{
@@ -938,8 +942,8 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
if (metric == "comboboxpopup") {
return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption);
} else if (metric == "highlightedTextColor") {
- QPalette pal = qApp->palette();
- pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive);
+ QPalette pal = QApplication::palette("QAbstractItemView");
+ pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup());
return pal.highlightedText().color().name();
} else if (metric == "textColor") {
QPalette pal = qApp->palette();
@@ -965,7 +969,7 @@ QVariant QQuickStyleItem::styleHint(const QString &metric)
// Add SH_Menu_SpaceActivatesItem, SH_Menu_SubMenuPopupDelay
}
-void QQuickStyleItem::setHints(const QStringList &str)
+void QQuickStyleItem::setHints(const QVariantMap &str)
{
if (m_hints != str) {
m_hints = str;
@@ -983,6 +987,11 @@ void QQuickStyleItem::setHints(const QStringList &str)
}
}
+void QQuickStyleItem::resetHints()
+{
+ m_hints.clear();
+}
+
void QQuickStyleItem::setElementType(const QString &str)
{
@@ -1192,8 +1201,11 @@ void QQuickStyleItem::paint(QPainter *painter)
pixmap.fill(Qt::transparent);
QPainter pixpainter(&pixmap);
qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter);
- if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected())
- pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight());
+ if ((style() == "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());
+ }
QPixmapCache::insert(pmKey, pixmap);
}
painter->drawPixmap(0, 0, pixmap);
@@ -1208,7 +1220,7 @@ void QQuickStyleItem::paint(QPainter *painter)
case ToolButton:
#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("segmented") != -1) {
+ if (style() == "mac" && hints().value("segmented").toBool()) {
const QPaintDevice *target = painter->device();
HIThemeSegmentDrawInfo sgi;
sgi.version = 0;
@@ -1224,9 +1236,10 @@ void QQuickStyleItem::paint(QPainter *painter)
}
SInt32 button_height;
GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height);
- sgi.position = hints().contains("leftmost") ? kHIThemeSegmentPositionFirst:
- hints().contains("rightmost") ? kHIThemeSegmentPositionLast :
- hints().contains("h_middle") ? kHIThemeSegmentPositionMiddle :
+ QString buttonPos = m_properties.value("position").toString();
+ sgi.position = buttonPos == "leftmost" ? kHIThemeSegmentPositionFirst :
+ buttonPos == "rightmost" ? kHIThemeSegmentPositionLast :
+ buttonPos == "h_middle" ? kHIThemeSegmentPositionMiddle :
kHIThemeSegmentPositionOnly;
QRect centered = m_styleoption->rect;
centered.setHeight(button_height);
@@ -1254,12 +1267,7 @@ void QQuickStyleItem::paint(QPainter *painter)
qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter);
break;
case FocusFrame:
-#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("rounded") != -1)
- break; // embedded in the line itself
- else
-#endif
- qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter);
+ qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter);
break;
case FocusRect:
qApp->style()->drawPrimitive(QStyle::PE_FrameFocusRect, m_styleoption, painter);
@@ -1285,7 +1293,7 @@ void QQuickStyleItem::paint(QPainter *painter)
break;
case Edit: {
#ifdef Q_OS_MAC
- if (style() == "mac" && hints().indexOf("rounded") != -1) {
+ if (style() == "mac" && hints().value("rounded").toBool()) {
const QPaintDevice *target = painter->device();
HIThemeFrameDrawInfo fdi;
fdi.version = 0;
@@ -1296,9 +1304,7 @@ void QQuickStyleItem::paint(QPainter *painter)
if ((m_styleoption->state & QStyle::State_ReadOnly) || !(m_styleoption->state & QStyle::State_Enabled))
fdi.state = kThemeStateInactive;
fdi.isFocused = hasFocus();
- HIRect hirect = qt_hirectForQRect(m_styleoption->rect,
- QRect(frame_size, frame_size,
- frame_size * 2, frame_size * 2));
+ HIRect hirect = qt_hirectForQRect(m_styleoption->rect.adjusted(2, 2, -2, 2), QRect(0, 0, 0, 0));
HIThemeDrawFrame(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal);
} else
#endif
diff --git a/src/private/qquickstyleitem_p.h b/src/private/qquickstyleitem_p.h
index 6deaeb16..eee9e6e5 100644
--- a/src/private/qquickstyleitem_p.h
+++ b/src/private/qquickstyleitem_p.h
@@ -67,7 +67,7 @@ class QQuickStyleItem: public QQuickItem
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged)
Q_PROPERTY( QString style READ style NOTIFY styleChanged)
- Q_PROPERTY( QStringList hints READ hints WRITE setHints NOTIFY hintChanged)
+ Q_PROPERTY( QVariantMap hints READ hints WRITE setHints NOTIFY hintChanged RESET resetHints)
Q_PROPERTY( QVariantMap properties READ properties WRITE setProperties NOTIFY propertiesChanged)
Q_PROPERTY( QFont font READ font NOTIFY fontChanged)
@@ -140,7 +140,7 @@ public:
QString elementType() const { return m_type; }
QString text() const { return m_text; }
QString activeControl() const { return m_activeControl; }
- QStringList hints() const { return m_hints; }
+ QVariantMap hints() const { return m_hints; }
QVariantMap properties() const { return m_properties; }
QFont font() const { return m_font;}
QString style() const;
@@ -161,8 +161,9 @@ public:
void setElementType(const QString &str);
void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}}
void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}}
- void setHints(const QStringList &str);
+ void setHints(const QVariantMap &str);
void setProperties(const QVariantMap &props) { if (m_properties != props) { m_properties = props; emit propertiesChanged(); } }
+ void resetHints();
int contentWidth() const { return m_contentWidth; }
void setContentWidth(int arg);
@@ -228,7 +229,7 @@ protected:
QString m_type;
QString m_text;
QString m_activeControl;
- QStringList m_hints;
+ QVariantMap m_hints;
QVariantMap m_properties;
QFont m_font;
diff --git a/src/private/style.js b/src/private/style.js
index 81d6b563..2c47ff0e 100644
--- a/src/private/style.js
+++ b/src/private/style.js
@@ -40,13 +40,24 @@
.pragma library
-function replaceAmpersands(match, p1, p2, p3) {
+function underlineAmpersands(match, p1, p2, p3) {
if (p2 === "&")
return p1.concat(p2, p3)
return p1.concat("<u>", p2, "</u>", p3)
}
+function removeAmpersands(match, p1, p2, p3) {
+ return p1.concat(p2, p3)
+}
+
+function replaceAmpersands(text, replaceFunction) {
+ return text.replace(/([^&]*)&(.)([^&]*)/g, replaceFunction)
+}
+
function stylizeMnemonics(text) {
+ return replaceAmpersands(text, underlineAmpersands)
+}
- return text.replace(/([^&]*)&(.)([^&]*)/g, replaceAmpersands)
+function removeMnemonics(text) {
+ return replaceAmpersands(text, removeAmpersands)
}