Skip to content

Commit f3dc4c3

Browse files
vsklencarwonder-sk
vsklencar
authored andcommitted
[QgsQuick] Customizable icons for external source widget
..and date time widget. Changes in other widgets due to passing a whole style object to components.
1 parent a337758 commit f3dc4c3

9 files changed

+63
-50
lines changed

src/quickgui/plugin/components/qgsquickicontextitem.qml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import QgsQuick 0.1 as QgsQuick
55
Item {
66
property real iconSize
77
property color fontColor
8+
property real fontPixelSize: root.iconSize * 0.75
89
property string iconSource
910
property string labelText
1011

@@ -32,7 +33,7 @@ Item {
3233
id: text
3334
height: root.iconSize
3435
text: root.labelText
35-
font.pixelSize: root.iconSize * 0.75
36+
font.pixelSize: root.fontPixelSize
3637
color: root.fontColor
3738
anchors.leftMargin: root.iconSize + fieldItem.textMargin
3839
x: root.iconSize + fieldItem.textMargin

src/quickgui/plugin/editor/qgsquickcheckbox.qml

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ Item {
3535

3636
CheckBox {
3737
property var currentValue: value
38-
height: customStyle.height
38+
height: customStyle.fields.height
3939
id: checkBox
4040
leftPadding: 0
4141
checked: value == config['CheckedState']
4242

4343
indicator: Rectangle {
44-
implicitWidth: customStyle.height
45-
implicitHeight: customStyle.height
46-
radius: customStyle.cornerRadius
47-
border.color: checkBox.activeFocus ? customStyle.fontColor : "grey"
44+
implicitWidth: customStyle.fields.height
45+
implicitHeight: customStyle.fields.height
46+
radius: customStyle.fields.cornerRadius
47+
border.color: checkBox.activeFocus ? customStyle.fields.fontColor : "grey"
4848
border.width: 1
4949
Rectangle {
5050
visible: checkBox.checked
51-
color: customStyle.fontColor
52-
radius: customStyle.cornerRadius
51+
color: customStyle.fields.fontColor
52+
radius: customStyle.fields.cornerRadius
5353
anchors.margins: 4
5454
anchors.fill: parent
5555
}

src/quickgui/plugin/editor/qgsquickdatetime.qml

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ Item {
4848

4949
Item {
5050
Layout.fillWidth: true
51-
Layout.minimumHeight: customStyle.height
51+
Layout.minimumHeight: customStyle.fields.height
5252

5353
TextField {
5454
id: label
5555

5656
anchors.fill: parent
5757
verticalAlignment: Text.AlignVCenter
58-
font.pixelSize: customStyle.fontPixelSize
58+
font.pixelSize: customStyle.fields.fontPixelSize
5959
padding: 0
6060
background: Rectangle {
61-
radius: customStyle.cornerRadius
61+
radius: customStyle.fields.cornerRadius
6262

63-
border.color: label.activeFocus ? customStyle.activeColor : customStyle.normalColor
63+
border.color: label.activeFocus ? customStyle.fields.activeColor : customStyle.fields.normalColor
6464
border.width: label.activeFocus ? 2 : 1
65-
color: customStyle.backgroundColor
65+
color: customStyle.fields.backgroundColor
6666
}
6767

6868
inputMethodHints: Qt.ImhDigitsOnly
@@ -95,7 +95,7 @@ Item {
9595
}
9696
}
9797

98-
color: main.currentValue === undefined ? 'transparent' : customStyle.fontColor
98+
color: main.currentValue === undefined ? 'transparent' : customStyle.fields.fontColor
9999

100100
MouseArea {
101101
enabled: config['calendar_popup']
@@ -146,7 +146,7 @@ Item {
146146
sourceSize.height: fieldItem.iconSize
147147
autoTransform: true
148148
fillMode: Image.PreserveAspectFit
149-
source: QgsQuick.Utils.getThemeIcon("ic_today")
149+
source: customStyle.icons.today
150150
anchors.right: parent.right
151151
anchors.verticalCenter: parent.verticalCenter
152152
visible: fieldItem.enabled
@@ -161,7 +161,7 @@ Item {
161161
ColorOverlay {
162162
anchors.fill: todayBtn
163163
source: todayBtn
164-
color: customStyle.fontColor
164+
color: customStyle.fields.fontColor
165165
visible: todayBtn.visible
166166
}
167167
}
@@ -211,11 +211,11 @@ Item {
211211
if (main.currentValue === undefined)
212212
{
213213
label.text = qsTr('(no date)')
214-
label.color = customStyle.fontColor
214+
label.color = customStyle.fields.fontColor
215215
}
216216
else
217217
{
218-
label.color = customStyle.fontColor
218+
label.color = customStyle.fields.fontColor
219219
label.text = new Date(value).toLocaleString(Qt.locale(), config['display_format'] )
220220
}
221221
}

src/quickgui/plugin/editor/qgsquickexternalresource.qml

+18-16
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ Item {
2828
signal valueChanged(var value, bool isNull)
2929

3030
property var image: image
31-
property var cameraIcon: QgsQuick.Utils.getThemeIcon("ic_camera")
32-
property var deleteIcon: QgsQuick.Utils.getThemeIcon("ic_delete_forever_white")
33-
property var galleryIcon: QgsQuick.Utils.getThemeIcon("ic_gallery")
34-
property var brokenImageSource: QgsQuick.Utils.getThemeIcon("ic_broken_image_black")
35-
property var notavailableImageSource: QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white")
36-
property real iconSize: customStyle.height * 0.75
31+
property var cameraIcon: customStyle.icons.camera
32+
property var deleteIcon: customStyle.icons.remove
33+
property var galleryIcon: customStyle.icons.gallery
34+
property var brokenImageIcon: customStyle.icons.brokenImage
35+
property var notAvailableImageIcon: customStyle.icons.notAvailable
36+
property real iconSize: customStyle.fields.height * 0.75
3737
property real textMargin: QgsQuick.Utils.dp * 10
3838

3939
id: fieldItem
4040
enabled: true // its interactive widget
41-
height: customStyle.height * 3
41+
height: customStyle.fields.height * 3
4242
anchors {
4343
left: parent.left
4444
right: parent.right
@@ -66,15 +66,15 @@ Item {
6666
height: window.height
6767
width: window.width
6868
edge: Qt.RightEdge
69-
imageButtonSize: customStyle.height
69+
imageButtonSize: fieldItem.iconSize
7070
}
7171

7272
Rectangle {
7373
id: imageContainer
7474
width: parent.width
75-
height: customStyle.height * 3
76-
color: customStyle.backgroundColor
77-
radius: customStyle.cornerRadius
75+
height: parent.height
76+
color: customStyle.fields.backgroundColor
77+
radius: customStyle.fields.cornerRadius
7878

7979
Image {
8080
property var currentValue: value
@@ -145,7 +145,7 @@ Item {
145145
ColorOverlay {
146146
anchors.fill: deleteIcon
147147
source: deleteIcon
148-
color: customStyle.attentionColor
148+
color: customStyle.fields.attentionColor
149149
}
150150
}
151151

@@ -159,7 +159,8 @@ Item {
159159
QgsQuick.IconTextItem {
160160
id: photoButton
161161
iconSize: fieldItem.iconSize
162-
fontColor: customStyle.fontColor
162+
fontColor: customStyle.fields.fontColor
163+
fontPixelSize: fieldItem.iconSize/2
163164
iconSource: fieldItem.cameraIcon
164165
labelText: qsTr("Take a Photo")
165166

@@ -180,7 +181,8 @@ Item {
180181
QgsQuick.IconTextItem {
181182
id: browseButton
182183
iconSize: fieldItem.iconSize
183-
fontColor: customStyle.fontColor
184+
fontColor: customStyle.fields.fontColor
185+
fontPixelSize: fieldItem.iconSize/2
184186
iconSource: fieldItem.galleryIcon
185187
labelText: qsTr("Add From a Gallery")
186188

@@ -198,8 +200,8 @@ Item {
198200
QgsQuick.IconTextItem {
199201
id: infoItem
200202
iconSize: fieldItem.iconSize/2
201-
fontColor: customStyle.fontColor
202-
iconSource: fieldItem.brokenImageSource
203+
fontColor: customStyle.fields.fontColor
204+
iconSource: fieldItem.brokenImageIcon
203205
labelText: qsTr("Image is broken: ") + image.currentValue
204206

205207
visible: fieldItem.state === "broken" || fieldItem.state === "notAvailable"

src/quickgui/plugin/editor/qgsquicktextedit.qml

+12-12
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ Item {
3737

3838
TextField {
3939
id: textField
40-
height: textArea.height == 0 ? customStyle.height : 0
40+
height: textArea.height == 0 ? customStyle.fields.height : 0
4141
topPadding: 10 * QgsQuick.Utils.dp
4242
bottomPadding: 10 * QgsQuick.Utils.dp
4343
visible: height !== 0
4444
anchors.left: parent.left
4545
anchors.right: parent.right
46-
font.pixelSize: customStyle.fontPixelSize
47-
color: customStyle.fontColor
46+
font.pixelSize: customStyle.fields.fontPixelSize
47+
color: customStyle.fields.fontColor
4848

4949
text: value || ''
5050
inputMethodHints: field.isNumeric || widget == 'Range' ? field.precision === 0 ? Qt.ImhDigitsOnly : Qt.ImhFormattedNumbersOnly : Qt.ImhNone
@@ -63,10 +63,10 @@ Item {
6363

6464
background: Rectangle {
6565
anchors.fill: parent
66-
border.color: textField.activeFocus ? customStyle.activeColor : customStyle.normalColor
66+
border.color: textField.activeFocus ? customStyle.fields.activeColor : customStyle.fields.normalColor
6767
border.width: textField.activeFocus ? 2 : 1
68-
color: customStyle.backgroundColor
69-
radius: customStyle.cornerRadius
68+
color: customStyle.fields.backgroundColor
69+
radius: customStyle.fields.cornerRadius
7070
}
7171

7272
onTextChanged: {
@@ -77,20 +77,20 @@ Item {
7777
TextArea {
7878
id: textArea
7979
height: config['IsMultiline'] === true ? undefined : 0
80-
topPadding: customStyle.height * 0.25
81-
bottomPadding: customStyle.height * 0.25
80+
topPadding: customStyle.fields.height * 0.25
81+
bottomPadding: customStyle.fields.height * 0.25
8282
visible: height !== 0
8383
anchors.left: parent.left
8484
anchors.right: parent.right
85-
font.pixelSize: customStyle.fontPixelSize
85+
font.pixelSize: customStyle.fields.fontPixelSize
8686
wrapMode: Text.Wrap
87-
color: customStyle.fontColor
87+
color: customStyle.fields.fontColor
8888
text: value || ''
8989
textFormat: config['UseHtml'] ? TextEdit.RichText : TextEdit.PlainText
9090

9191
background: Rectangle {
92-
color: customStyle.backgroundColor
93-
radius: customStyle.cornerRadius
92+
color: customStyle.fields.backgroundColor
93+
radius: customStyle.fields.cornerRadius
9494
}
9595

9696
onEditingFinished: {

src/quickgui/plugin/editor/qgsquickvaluemap.qml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Item {
2828

2929
id: fieldItem
3030
enabled: !readOnly
31-
height: customStyle.height
31+
height: customStyle.fields.height
3232
anchors {
3333
left: parent.left
3434
right: parent.right
@@ -40,7 +40,7 @@ Item {
4040
property var reverseConfig: ({})
4141
property var currentValue: value
4242

43-
comboStyle: customStyle
43+
comboStyle: customStyle.fields
4444
textRole: 'text'
4545
height: parent.height
4646
model: ListModel {

src/quickgui/plugin/editor/qgsquickvaluerelation.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Item {
4242
property var reversedMap: ({})
4343
property var currentValue: value
4444

45-
comboStyle: customStyle
45+
comboStyle: customStyle.fields
4646
textRole: 'text'
4747
height: parent.height
4848
model: ListModel {

src/quickgui/plugin/qgsquickfeatureform.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ Item {
373373
property var field: Field
374374
property var constraintValid: ConstraintValid
375375
property var homePath: form.project ? form.project.homePath : ""
376-
property var customStyle: form.style.fields
376+
property var customStyle: form.style
377377
property var externalResourceHandler: form.externalResourceHandler
378378
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable
379379

src/quickgui/plugin/qgsquickfeatureformstyling.qml

+10
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,14 @@ QtObject {
7171
property int fontPixelSize: 48 * QgsQuick.Utils.dp
7272

7373
}
74+
75+
property QtObject icons: QtObject {
76+
property var camera: QgsQuick.Utils.getThemeIcon("ic_camera")
77+
property var remove: QgsQuick.Utils.getThemeIcon("ic_delete_forever_white")
78+
property var gallery: QgsQuick.Utils.getThemeIcon("ic_gallery")
79+
property var brokenImage: QgsQuick.Utils.getThemeIcon("ic_broken_image_black")
80+
property var notAvailable: QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white")
81+
property var today: QgsQuick.Utils.getThemeIcon("ic_today")
82+
}
83+
7484
}

0 commit comments

Comments
 (0)