Skip to content

Commit

Permalink
Refactor to lookup numericLocale less frequently.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Oct 11, 2014
1 parent 10909a3 commit c1534a7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 32 deletions.
11 changes: 5 additions & 6 deletions src/qml/filters/dynamictext/ui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Item {
property string rectProperty: 'geometry'
property string valignProperty: 'valign'
property string halignProperty: 'halign'

property rect filterRect: filter.getRect(rectProperty)
property var _locale: Qt.locale(application.numericLocale)

Component.onCompleted: {
if (filter.isNew) {
Expand Down Expand Up @@ -85,12 +85,11 @@ Item {
filterRect.y = y
filterRect.width = w
filterRect.height = h
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((x / profile.width * 100).toLocaleString(locale))
.arg((y / profile.height * 100).toLocaleString(locale))
.arg((w / profile.width * 100).toLocaleString(locale))
.arg((h / profile.height * 100).toLocaleString(locale)))
.arg((x / profile.width * 100).toLocaleString(_locale))
.arg((y / profile.height * 100).toLocaleString(_locale))
.arg((w / profile.width * 100).toLocaleString(_locale))
.arg((h / profile.height * 100).toLocaleString(_locale)))
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/qml/filters/dynamictext/vui.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Flickable {
property string rectProperty: 'geometry'
property string halignProperty: 'valign'
property string valignProperty: 'halign'
property var _locale: Qt.locale(application.numericLocale)

width: 400
height: 200
Expand Down Expand Up @@ -103,12 +104,11 @@ Flickable {
filterRect.y = Math.round(rect.y / rectangle.heightScale)
filterRect.width = Math.round(rect.width / rectangle.widthScale)
filterRect.height = Math.round(rect.height / rectangle.heightScale)
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((filterRect.x / profile.width * 100).toLocaleString(locale))
.arg((filterRect.y / profile.height * 100).toLocaleString(locale))
.arg((filterRect.width / profile.width * 100).toLocaleString(locale))
.arg((filterRect.height / profile.height * 100).toLocaleString(locale)))
.arg((filterRect.x / profile.width * 100).toLocaleString(_locale))
.arg((filterRect.y / profile.height * 100).toLocaleString(_locale))
.arg((filterRect.width / profile.width * 100).toLocaleString(_locale))
.arg((filterRect.height / profile.height * 100).toLocaleString(_locale)))
}
}
}
Expand All @@ -126,12 +126,11 @@ Flickable {
rectangle.aspectRatio = getAspectRatio()
rectangle.setHandles(filterRect)
var rect = rectangle.rectangle
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((Math.round(rect.x / rectangle.widthScale) / profile.width * 100).toLocaleString(locale))
.arg((Math.round(rect.y / rectangle.heightScale) / profile.height * 100).toLocaleString(locale))
.arg((Math.round(rect.width / rectangle.widthScale) / profile.width * 100).toLocaleString(locale))
.arg((Math.round(rect.height / rectangle.heightScale) / profile.height * 100).toLocaleString(locale)))
.arg((Math.round(rect.x / rectangle.widthScale) / profile.width * 100).toLocaleString(_locale))
.arg((Math.round(rect.y / rectangle.heightScale) / profile.height * 100).toLocaleString(_locale))
.arg((Math.round(rect.width / rectangle.widthScale) / profile.width * 100).toLocaleString(_locale))
.arg((Math.round(rect.height / rectangle.heightScale) / profile.height * 100).toLocaleString(_locale)))
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/qml/filters/size_position/SizePositionUI.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Item {
property string rectProperty
property string valignProperty
property string halignProperty
property var _locale: Qt.locale(application.numericLocale)

property rect filterRect: filter.getRect(rectProperty)

Expand Down Expand Up @@ -74,12 +75,11 @@ Item {
filterRect.y = y
filterRect.width = w
filterRect.height = h
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((x / profile.width * 100).toLocaleString(locale))
.arg((y / profile.height * 100).toLocaleString(locale))
.arg((w / profile.width * 100).toLocaleString(locale))
.arg((h / profile.height * 100).toLocaleString(locale)))
.arg((x / profile.width * 100).toLocaleString(_locale))
.arg((y / profile.height * 100).toLocaleString(_locale))
.arg((w / profile.width * 100).toLocaleString(_locale))
.arg((h / profile.height * 100).toLocaleString(_locale)))
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/qml/filters/size_position/SizePositionVUI.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Flickable {
property string fillProperty
property string halignProperty
property string valignProperty
property var _locale: Qt.locale(application.numericLocale)

width: 400
height: 200
Expand Down Expand Up @@ -68,12 +69,11 @@ Flickable {
filterRect.y = Math.round(rect.y / rectangle.heightScale)
filterRect.width = Math.round(rect.width / rectangle.widthScale)
filterRect.height = Math.round(rect.height / rectangle.heightScale)
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((filterRect.x / profile.width * 100).toLocaleString(locale))
.arg((filterRect.y / profile.height * 100).toLocaleString(locale))
.arg((filterRect.width / profile.width * 100).toLocaleString(locale))
.arg((filterRect.height / profile.height * 100).toLocaleString(locale)))
.arg((filterRect.x / profile.width * 100).toLocaleString(_locale))
.arg((filterRect.y / profile.height * 100).toLocaleString(_locale))
.arg((filterRect.width / profile.width * 100).toLocaleString(_locale))
.arg((filterRect.height / profile.height * 100).toLocaleString(_locale)))
}
}
}
Expand All @@ -90,12 +90,11 @@ Flickable {
rectangle.aspectRatio = getAspectRatio()
rectangle.setHandles(filterRect)
var rect = rectangle.rectangle
var locale = Qt.locale(application.numericLocale)
filter.set(rectProperty, '%1%/%2%:%3%x%4%'
.arg((Math.round(rect.x / rectangle.widthScale) / profile.width * 100).toLocaleString(locale))
.arg((Math.round(rect.y / rectangle.heightScale) / profile.height * 100).toLocaleString(locale))
.arg((Math.round(rect.width / rectangle.widthScale) / profile.width * 100).toLocaleString(locale))
.arg((Math.round(rect.height / rectangle.heightScale) / profile.height * 100).toLocaleString(locale)))
.arg((Math.round(rect.x / rectangle.widthScale) / profile.width * 100).toLocaleString(_locale))
.arg((Math.round(rect.y / rectangle.heightScale) / profile.height * 100).toLocaleString(_locale))
.arg((Math.round(rect.width / rectangle.widthScale) / profile.width * 100).toLocaleString(_locale))
.arg((Math.round(rect.height / rectangle.heightScale) / profile.height * 100).toLocaleString(_locale)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qmltypes/qmlapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class QmlApplication : public QObject
Q_PROPERTY(QColor toolTipBaseColor READ toolTipBaseColor NOTIFY paletteChanged)
Q_PROPERTY(QColor toolTipTextColor READ toolTipTextColor NOTIFY paletteChanged)
Q_PROPERTY(QString OS READ OS CONSTANT)
Q_PROPERTY(QString numericLocale READ numericLocale)
Q_PROPERTY(QString numericLocale READ numericLocale CONSTANT)

public:
static QmlApplication& singleton();
Expand Down

0 comments on commit c1534a7

Please sign in to comment.