From 7cbf3685565d7f62c9a01b090a4c1600b4abe220 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 13 Sep 2017 11:32:27 +0200 Subject: Imagine: fix QRC paths Using ApplicationWindow as an example, its NinePatchImage url is assigned like so: source: Imagine.path + "applicationwindow-background" If Imagine.path is set to ":/images" by the user, then the final URL would be: QUrl("file:///home/user/qt/qtbase/qml/QtQuick/Controls.2/Imagine/:/images/applicationwindow-background") We could use a QUrl for QQuickImagineStyle::path, but we don't want to support anything other than local paths. Instead, we add a private "url" property that returns a URL that we construct correctly in C++ ourselves, and then the Imagine QML controls files use that property. Change-Id: Ic4d1910bbc7f7b6f80f257496ae6131777a19401 Reviewed-by: J-P Nurmi --- src/imports/controls/imagine/ApplicationWindow.qml | 6 ++--- src/imports/controls/imagine/BusyIndicator.qml | 4 +-- src/imports/controls/imagine/Button.qml | 2 +- src/imports/controls/imagine/CheckBox.qml | 4 +-- src/imports/controls/imagine/CheckDelegate.qml | 4 +-- src/imports/controls/imagine/ComboBox.qml | 6 ++--- src/imports/controls/imagine/DelayButton.qml | 6 ++--- src/imports/controls/imagine/Dial.qml | 4 +-- src/imports/controls/imagine/Dialog.qml | 8 +++--- src/imports/controls/imagine/DialogButtonBox.qml | 2 +- src/imports/controls/imagine/Drawer.qml | 6 ++--- src/imports/controls/imagine/Frame.qml | 2 +- src/imports/controls/imagine/GroupBox.qml | 4 +-- src/imports/controls/imagine/ItemDelegate.qml | 2 +- src/imports/controls/imagine/Label.qml | 2 +- src/imports/controls/imagine/Menu.qml | 6 ++--- src/imports/controls/imagine/MenuItem.qml | 6 ++--- src/imports/controls/imagine/MenuSeparator.qml | 4 +-- src/imports/controls/imagine/Page.qml | 2 +- src/imports/controls/imagine/PageIndicator.qml | 4 +-- src/imports/controls/imagine/Pane.qml | 2 +- src/imports/controls/imagine/Popup.qml | 6 ++--- src/imports/controls/imagine/ProgressBar.qml | 8 +++--- src/imports/controls/imagine/RadioButton.qml | 4 +-- src/imports/controls/imagine/RadioDelegate.qml | 4 +-- src/imports/controls/imagine/RangeSlider.qml | 8 +++--- src/imports/controls/imagine/RoundButton.qml | 2 +- src/imports/controls/imagine/ScrollBar.qml | 4 +-- src/imports/controls/imagine/ScrollIndicator.qml | 4 +-- src/imports/controls/imagine/Slider.qml | 6 ++--- src/imports/controls/imagine/SpinBox.qml | 8 +++--- src/imports/controls/imagine/StackView.qml | 2 +- src/imports/controls/imagine/SwipeDelegate.qml | 2 +- src/imports/controls/imagine/SwipeView.qml | 2 +- src/imports/controls/imagine/Switch.qml | 6 ++--- src/imports/controls/imagine/SwitchDelegate.qml | 6 ++--- src/imports/controls/imagine/TabBar.qml | 2 +- src/imports/controls/imagine/TabButton.qml | 2 +- src/imports/controls/imagine/TextArea.qml | 2 +- src/imports/controls/imagine/TextField.qml | 2 +- src/imports/controls/imagine/ToolBar.qml | 2 +- src/imports/controls/imagine/ToolButton.qml | 2 +- src/imports/controls/imagine/ToolSeparator.qml | 4 +-- src/imports/controls/imagine/ToolTip.qml | 2 +- src/imports/controls/imagine/Tumbler.qml | 2 +- .../controls/imagine/qquickimaginestyle.cpp | 30 +++++++++++++++++++--- .../controls/imagine/qquickimaginestyle_p.h | 3 +++ 47 files changed, 118 insertions(+), 93 deletions(-) (limited to 'src/imports/controls') diff --git a/src/imports/controls/imagine/ApplicationWindow.qml b/src/imports/controls/imagine/ApplicationWindow.qml index d0e7870a..d0219da0 100644 --- a/src/imports/controls/imagine/ApplicationWindow.qml +++ b/src/imports/controls/imagine/ApplicationWindow.qml @@ -45,7 +45,7 @@ T.ApplicationWindow { // ### remove? overlay.modal: NinePatchImage { - source: Imagine.path + "applicationwindow-overlay" + source: Imagine.url + "applicationwindow-overlay" NinePatchImageSelector on source { states: [ {"modal": true} @@ -55,7 +55,7 @@ T.ApplicationWindow { // ### remove? overlay.modeless: NinePatchImage { - source: Imagine.path + "applicationwindow-overlay" + source: Imagine.url + "applicationwindow-overlay" NinePatchImageSelector on source { states: [ {"modal": false} @@ -67,7 +67,7 @@ T.ApplicationWindow { width: window.width height: window.height - source: Imagine.path + "applicationwindow-background" + source: Imagine.url + "applicationwindow-background" NinePatchImageSelector on source { states: [ {"active": window.active} diff --git a/src/imports/controls/imagine/BusyIndicator.qml b/src/imports/controls/imagine/BusyIndicator.qml index c8ee92bd..a1ce3f7b 100644 --- a/src/imports/controls/imagine/BusyIndicator.qml +++ b/src/imports/controls/imagine/BusyIndicator.qml @@ -58,7 +58,7 @@ T.BusyIndicator { visible: control.running || animator.running Behavior on opacity { OpacityAnimator { id: animator; duration: 250 } } - source: Imagine.path + "busyindicator-animation" + source: Imagine.url + "busyindicator-animation" AnimatedImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -74,7 +74,7 @@ T.BusyIndicator { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "busyindicator-background" + source: Imagine.url + "busyindicator-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Button.qml b/src/imports/controls/imagine/Button.qml index 910491fa..8ccedbf8 100644 --- a/src/imports/controls/imagine/Button.qml +++ b/src/imports/controls/imagine/Button.qml @@ -81,7 +81,7 @@ T.Button { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "button-background" + source: Imagine.url + "button-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/CheckBox.qml b/src/imports/controls/imagine/CheckBox.qml index 0d37626a..01426054 100644 --- a/src/imports/controls/imagine/CheckBox.qml +++ b/src/imports/controls/imagine/CheckBox.qml @@ -60,7 +60,7 @@ T.CheckBox { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 - source: Imagine.path + "checkbox-indicator" + source: Imagine.url + "checkbox-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -92,7 +92,7 @@ T.CheckBox { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "checkbox-background" + source: Imagine.url + "checkbox-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/CheckDelegate.qml b/src/imports/controls/imagine/CheckDelegate.qml index 3660186d..e98a612c 100644 --- a/src/imports/controls/imagine/CheckDelegate.qml +++ b/src/imports/controls/imagine/CheckDelegate.qml @@ -66,7 +66,7 @@ T.CheckDelegate { x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding y: control.topPadding + (control.availableHeight - height) / 2 - source: Imagine.path + "checkdelegate-indicator" + source: Imagine.url + "checkdelegate-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -101,7 +101,7 @@ T.CheckDelegate { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "checkdelegate-background" + source: Imagine.url + "checkdelegate-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ComboBox.qml b/src/imports/controls/imagine/ComboBox.qml index 663b288c..1a85b675 100644 --- a/src/imports/controls/imagine/ComboBox.qml +++ b/src/imports/controls/imagine/ComboBox.qml @@ -65,7 +65,7 @@ T.ComboBox { x: control.mirrored ? control.padding : control.width - width - control.padding y: control.topPadding + (control.availableHeight - height) / 2 - source: Imagine.path + "combobox-indicator" + source: Imagine.url + "combobox-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -107,7 +107,7 @@ T.ComboBox { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "combobox-background" + source: Imagine.url + "combobox-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -155,7 +155,7 @@ T.ComboBox { width: control.popup.width + leftInset + rightInset height: control.popup.height + topInset + bottomInset - source: Imagine.path + "combobox-popup" + source: Imagine.url + "combobox-popup" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/DelayButton.qml b/src/imports/controls/imagine/DelayButton.qml index 05f38a10..3b2eb8bb 100644 --- a/src/imports/controls/imagine/DelayButton.qml +++ b/src/imports/controls/imagine/DelayButton.qml @@ -74,7 +74,7 @@ T.DelayButton { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "delaybutton-background" + source: Imagine.url + "delaybutton-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -92,7 +92,7 @@ T.DelayButton { height: parent.height visible: false - source: Imagine.path + "delaybutton-progress" + source: Imagine.url + "delaybutton-progress" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -111,7 +111,7 @@ T.DelayButton { height: parent.height visible: false - source: Imagine.path + "delaybutton-mask" + source: Imagine.url + "delaybutton-mask" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Dial.qml b/src/imports/controls/imagine/Dial.qml index 22dd44b6..04f8e1b8 100644 --- a/src/imports/controls/imagine/Dial.qml +++ b/src/imports/controls/imagine/Dial.qml @@ -56,7 +56,7 @@ T.Dial { x: background.x + background.width / 2 - handle.width / 2 y: background.y + background.height / 2 - handle.height / 2 - source: Imagine.path + "dial-handle" + source: Imagine.url + "dial-handle" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -85,7 +85,7 @@ T.Dial { width: Math.max(64, Math.min(control.width, control.height)) height: width - source: Imagine.path + "dial-background" + source: Imagine.url + "dial-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Dialog.qml b/src/imports/controls/imagine/Dialog.qml index 80dd0896..e7a8cce5 100644 --- a/src/imports/controls/imagine/Dialog.qml +++ b/src/imports/controls/imagine/Dialog.qml @@ -65,7 +65,7 @@ T.Dialog { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "dialog-background" + source: Imagine.url + "dialog-background" NinePatchImageSelector on source { states: [ {"modal": control.modal}, @@ -85,7 +85,7 @@ T.Dialog { width: parent.width height: parent.height - source: Imagine.path + "dialog-title" + source: Imagine.url + "dialog-title" NinePatchImageSelector on source { states: [ {"modal": control.modal}, @@ -100,7 +100,7 @@ T.Dialog { } T.Overlay.modal: NinePatchImage { - source: Imagine.path + "dialog-overlay" + source: Imagine.url + "dialog-overlay" NinePatchImageSelector on source { states: [ {"modal": true} @@ -109,7 +109,7 @@ T.Dialog { } T.Overlay.modeless: NinePatchImage { - source: Imagine.path + "dialog-overlay" + source: Imagine.url + "dialog-overlay" NinePatchImageSelector on source { states: [ {"modal": false} diff --git a/src/imports/controls/imagine/DialogButtonBox.qml b/src/imports/controls/imagine/DialogButtonBox.qml index ea23d7b2..ae0e64de 100644 --- a/src/imports/controls/imagine/DialogButtonBox.qml +++ b/src/imports/controls/imagine/DialogButtonBox.qml @@ -75,7 +75,7 @@ T.DialogButtonBox { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "dialogbuttonbox-background" + source: Imagine.url + "dialogbuttonbox-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Drawer.qml b/src/imports/controls/imagine/Drawer.qml index 0bf4e9df..f52f9554 100644 --- a/src/imports/controls/imagine/Drawer.qml +++ b/src/imports/controls/imagine/Drawer.qml @@ -63,7 +63,7 @@ T.Drawer { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "drawer-background" + source: Imagine.url + "drawer-background" NinePatchImageSelector on source { states: [ {"modal": control.modal}, @@ -77,7 +77,7 @@ T.Drawer { } T.Overlay.modal: NinePatchImage { - source: Imagine.path + "drawer-overlay" + source: Imagine.url + "drawer-overlay" NinePatchImageSelector on source { states: [ {"modal": true} @@ -86,7 +86,7 @@ T.Drawer { } T.Overlay.modeless: NinePatchImage { - source: Imagine.path + "drawer-overlay" + source: Imagine.url + "drawer-overlay" NinePatchImageSelector on source { states: [ {"modal": false} diff --git a/src/imports/controls/imagine/Frame.qml b/src/imports/controls/imagine/Frame.qml index f506e97d..43c852f1 100644 --- a/src/imports/controls/imagine/Frame.qml +++ b/src/imports/controls/imagine/Frame.qml @@ -58,7 +58,7 @@ T.Frame { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "frame-background" + source: Imagine.url + "frame-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/GroupBox.qml b/src/imports/controls/imagine/GroupBox.qml index 6d12d378..8ff48c42 100644 --- a/src/imports/controls/imagine/GroupBox.qml +++ b/src/imports/controls/imagine/GroupBox.qml @@ -78,7 +78,7 @@ T.GroupBox { width: parent.width height: parent.height - source: Imagine.path + "groupbox-title" + source: Imagine.url + "groupbox-title" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -94,7 +94,7 @@ T.GroupBox { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - control.topPadding + control.padding - source: Imagine.path + "groupbox-background" + source: Imagine.url + "groupbox-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ItemDelegate.qml b/src/imports/controls/imagine/ItemDelegate.qml index b8600631..1d16faf4 100644 --- a/src/imports/controls/imagine/ItemDelegate.qml +++ b/src/imports/controls/imagine/ItemDelegate.qml @@ -79,7 +79,7 @@ T.ItemDelegate { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "itemdelegate-background" + source: Imagine.url + "itemdelegate-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Label.qml b/src/imports/controls/imagine/Label.qml index 87d9f708..0db416e1 100644 --- a/src/imports/controls/imagine/Label.qml +++ b/src/imports/controls/imagine/Label.qml @@ -50,7 +50,7 @@ T.Label { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "label-background" + source: Imagine.url + "label-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Menu.qml b/src/imports/controls/imagine/Menu.qml index c666dfbb..80bda5ec 100644 --- a/src/imports/controls/imagine/Menu.qml +++ b/src/imports/controls/imagine/Menu.qml @@ -76,7 +76,7 @@ T.Menu { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "menu-background" + source: Imagine.url + "menu-background" NinePatchImageSelector on source { states: [ {"modal": control.modal}, @@ -86,7 +86,7 @@ T.Menu { } T.Overlay.modal: NinePatchImage { - source: Imagine.path + "menu-overlay" + source: Imagine.url + "menu-overlay" NinePatchImageSelector on source { states: [ {"modal": true} @@ -95,7 +95,7 @@ T.Menu { } T.Overlay.modeless: NinePatchImage { - source: Imagine.path + "menu-overlay" + source: Imagine.url + "menu-overlay" NinePatchImageSelector on source { states: [ {"modal": false} diff --git a/src/imports/controls/imagine/MenuItem.qml b/src/imports/controls/imagine/MenuItem.qml index 52b39f7b..8b576444 100644 --- a/src/imports/controls/imagine/MenuItem.qml +++ b/src/imports/controls/imagine/MenuItem.qml @@ -84,7 +84,7 @@ T.MenuItem { y: control.topPadding + (control.availableHeight - height) / 2 visible: control.subMenu - source: Imagine.path + "menuitem-arrow" + source: Imagine.url + "menuitem-arrow" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -103,7 +103,7 @@ T.MenuItem { y: control.topPadding + (control.availableHeight - height) / 2 visible: control.checkable - source: Imagine.path + "menuitem-indicator" + source: Imagine.url + "menuitem-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -122,7 +122,7 @@ T.MenuItem { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "menuitem-background" + source: Imagine.url + "menuitem-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/MenuSeparator.qml b/src/imports/controls/imagine/MenuSeparator.qml index 2dbb0a45..d445a9e1 100644 --- a/src/imports/controls/imagine/MenuSeparator.qml +++ b/src/imports/controls/imagine/MenuSeparator.qml @@ -53,7 +53,7 @@ T.MenuSeparator { bottomPadding: background ? background.bottomPadding : 0 contentItem: NinePatchImage { - source: Imagine.path + "menuseparator-separator" + source: Imagine.url + "menuseparator-separator" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -67,7 +67,7 @@ T.MenuSeparator { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "menuseparator-background" + source: Imagine.url + "menuseparator-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Page.qml b/src/imports/controls/imagine/Page.qml index 9a50b8a0..f3bdba51 100644 --- a/src/imports/controls/imagine/Page.qml +++ b/src/imports/controls/imagine/Page.qml @@ -64,7 +64,7 @@ T.Page { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "page-background" + source: Imagine.url + "page-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/PageIndicator.qml b/src/imports/controls/imagine/PageIndicator.qml index dcaf36c6..fafd73d3 100644 --- a/src/imports/controls/imagine/PageIndicator.qml +++ b/src/imports/controls/imagine/PageIndicator.qml @@ -53,7 +53,7 @@ T.PageIndicator { bottomPadding: background ? background.bottomPadding : 0 delegate: Image { - source: Imagine.path + "pageindicator-delegate" + source: Imagine.url + "pageindicator-delegate" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -79,7 +79,7 @@ T.PageIndicator { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "pageindicator-background" + source: Imagine.url + "pageindicator-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Pane.qml b/src/imports/controls/imagine/Pane.qml index c72653c1..b0029d49 100644 --- a/src/imports/controls/imagine/Pane.qml +++ b/src/imports/controls/imagine/Pane.qml @@ -58,7 +58,7 @@ T.Pane { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "pane-background" + source: Imagine.url + "pane-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/Popup.qml b/src/imports/controls/imagine/Popup.qml index f4591866..08fcfc69 100644 --- a/src/imports/controls/imagine/Popup.qml +++ b/src/imports/controls/imagine/Popup.qml @@ -60,7 +60,7 @@ T.Popup { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "popup-background" + source: Imagine.url + "popup-background" NinePatchImageSelector on source { states: [ {"modal": control.modal}, @@ -70,7 +70,7 @@ T.Popup { } T.Overlay.modal: NinePatchImage { - source: Imagine.path + "popup-overlay" + source: Imagine.url + "popup-overlay" NinePatchImageSelector on source { states: [ {"modal": true} @@ -79,7 +79,7 @@ T.Popup { } T.Overlay.modeless: NinePatchImage { - source: Imagine.path + "popup-overlay" + source: Imagine.url + "popup-overlay" NinePatchImageSelector on source { states: [ {"modal": false} diff --git a/src/imports/controls/imagine/ProgressBar.qml b/src/imports/controls/imagine/ProgressBar.qml index 17d5ed90..89645d3c 100644 --- a/src/imports/controls/imagine/ProgressBar.qml +++ b/src/imports/controls/imagine/ProgressBar.qml @@ -64,7 +64,7 @@ T.ProgressBar { height: parent.height visible: !control.indeterminate && mask.status === Image.Null - source: Imagine.path + "progressbar-progress" + source: Imagine.url + "progressbar-progress" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -82,7 +82,7 @@ T.ProgressBar { playing: control.indeterminate visible: control.indeterminate && mask.status === Image.Null - source: Imagine.path + "progressbar-animation" + source: Imagine.url + "progressbar-animation" AnimatedImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -98,7 +98,7 @@ T.ProgressBar { height: parent.height visible: false - source: Imagine.path + "progressbar-mask" + source: Imagine.url + "progressbar-mask" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -127,7 +127,7 @@ T.ProgressBar { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "progressbar-background" + source: Imagine.url + "progressbar-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/RadioButton.qml b/src/imports/controls/imagine/RadioButton.qml index 942d66e2..8df27fcc 100644 --- a/src/imports/controls/imagine/RadioButton.qml +++ b/src/imports/controls/imagine/RadioButton.qml @@ -60,7 +60,7 @@ T.RadioButton { x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 - source: Imagine.path + "radiobutton-indicator" + source: Imagine.url + "radiobutton-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -91,7 +91,7 @@ T.RadioButton { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "radiobutton-background" + source: Imagine.url + "radiobutton-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/RadioDelegate.qml b/src/imports/controls/imagine/RadioDelegate.qml index a5f84dc1..25d7dd2d 100644 --- a/src/imports/controls/imagine/RadioDelegate.qml +++ b/src/imports/controls/imagine/RadioDelegate.qml @@ -66,7 +66,7 @@ T.RadioDelegate { x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding y: control.topPadding + (control.availableHeight - height) / 2 - source: Imagine.path + "radiodelegate-indicator" + source: Imagine.url + "radiodelegate-indicator" ImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -100,7 +100,7 @@ T.RadioDelegate { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "radiodelegate-background" + source: Imagine.url + "radiodelegate-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/RangeSlider.qml b/src/imports/controls/imagine/RangeSlider.qml index 7a43da0e..b902806a 100644 --- a/src/imports/controls/imagine/RangeSlider.qml +++ b/src/imports/controls/imagine/RangeSlider.qml @@ -58,7 +58,7 @@ T.RangeSlider { x: control.leftPadding + (control.horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) - source: Imagine.path + "rangeslider-handle" + source: Imagine.url + "rangeslider-handle" ImageSelector on source { states: [ {"first": true}, @@ -77,7 +77,7 @@ T.RangeSlider { x: control.leftPadding + (control.horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) - source: Imagine.path + "rangeslider-handle" + source: Imagine.url + "rangeslider-handle" ImageSelector on source { states: [ {"second": true}, @@ -98,7 +98,7 @@ T.RangeSlider { height: control.height + topInset + bottomInset scale: control.horizontal && control.mirrored ? -1 : 1 - source: Imagine.path + "rangeslider-background" + source: Imagine.url + "rangeslider-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, @@ -116,7 +116,7 @@ T.RangeSlider { width: control.horizontal ? control.second.position * (parent.width - control.first.handle.width) - control.first.position * (parent.width - control.first.handle.width) : parent.width height: control.vertical ? control.second.position * (parent.height - control.first.handle.height) - control.first.position * (parent.height - control.first.handle.height): parent.height - source: Imagine.path + "rangeslider-progress" + source: Imagine.url + "rangeslider-progress" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/RoundButton.qml b/src/imports/controls/imagine/RoundButton.qml index bac86b5c..e3ee269b 100644 --- a/src/imports/controls/imagine/RoundButton.qml +++ b/src/imports/controls/imagine/RoundButton.qml @@ -72,7 +72,7 @@ T.RoundButton { height: control.height + topInset + bottomInset // ### TODO: radius? - source: Imagine.path + "roundbutton-background" + source: Imagine.url + "roundbutton-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ScrollBar.qml b/src/imports/controls/imagine/ScrollBar.qml index e0cdda0c..ad764242 100644 --- a/src/imports/controls/imagine/ScrollBar.qml +++ b/src/imports/controls/imagine/ScrollBar.qml @@ -58,7 +58,7 @@ T.ScrollBar { width: control.availableWidth height: control.availableHeight - source: Imagine.path + "scrollbar-handle" + source: Imagine.url + "scrollbar-handle" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, @@ -78,7 +78,7 @@ T.ScrollBar { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "scrollbar-background" + source: Imagine.url + "scrollbar-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/ScrollIndicator.qml b/src/imports/controls/imagine/ScrollIndicator.qml index 377ba4f7..a0ab8783 100644 --- a/src/imports/controls/imagine/ScrollIndicator.qml +++ b/src/imports/controls/imagine/ScrollIndicator.qml @@ -56,7 +56,7 @@ T.ScrollIndicator { width: control.availableWidth height: control.availableHeight - source: Imagine.path + "scrollindicator-handle" + source: Imagine.url + "scrollindicator-handle" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, @@ -74,7 +74,7 @@ T.ScrollIndicator { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "scrollindicator-background" + source: Imagine.url + "scrollindicator-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/Slider.qml b/src/imports/controls/imagine/Slider.qml index 3d369865..af927806 100644 --- a/src/imports/controls/imagine/Slider.qml +++ b/src/imports/controls/imagine/Slider.qml @@ -56,7 +56,7 @@ T.Slider { x: control.leftPadding + (control.horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) - source: Imagine.path + "slider-handle" + source: Imagine.url + "slider-handle" ImageSelector on source { states: [ {"vertical": control.vertical}, @@ -76,7 +76,7 @@ T.Slider { height: control.height + topInset + bottomInset scale: control.horizontal && control.mirrored ? -1 : 1 - source: Imagine.path + "slider-background" + source: Imagine.url + "slider-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, @@ -101,7 +101,7 @@ T.Slider { ? control.handle.height / 2 + control.position * (parent.height - control.handle.height) : parent.height - source: Imagine.path + "slider-progress" + source: Imagine.url + "slider-progress" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/SpinBox.qml b/src/imports/controls/imagine/SpinBox.qml index ab5567b5..ebadb860 100644 --- a/src/imports/controls/imagine/SpinBox.qml +++ b/src/imports/controls/imagine/SpinBox.qml @@ -85,7 +85,7 @@ T.SpinBox { height: control.height visible: control.editable - source: Imagine.path + "spinbox-editor" + source: Imagine.url + "spinbox-editor" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -102,7 +102,7 @@ T.SpinBox { x: control.mirrored ? 0 : parent.width - width height: parent.height - source: Imagine.path + "spinbox-indicator" + source: Imagine.url + "spinbox-indicator" NinePatchImageSelector on source { states: [ {"up": true}, @@ -121,7 +121,7 @@ T.SpinBox { x: control.mirrored ? parent.width - width : 0 height: parent.height - source: Imagine.path + "spinbox-indicator" + source: Imagine.url + "spinbox-indicator" NinePatchImageSelector on source { states: [ {"down": true}, @@ -140,7 +140,7 @@ T.SpinBox { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "spinbox-background" + source: Imagine.url + "spinbox-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/StackView.qml b/src/imports/controls/imagine/StackView.qml index 5b15b2c1..d462239a 100644 --- a/src/imports/controls/imagine/StackView.qml +++ b/src/imports/controls/imagine/StackView.qml @@ -79,7 +79,7 @@ T.StackView { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "stackview-background" + source: Imagine.url + "stackview-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/SwipeDelegate.qml b/src/imports/controls/imagine/SwipeDelegate.qml index f6e475c4..be88fb7d 100644 --- a/src/imports/controls/imagine/SwipeDelegate.qml +++ b/src/imports/controls/imagine/SwipeDelegate.qml @@ -81,7 +81,7 @@ T.SwipeDelegate { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "swipedelegate-background" + source: Imagine.url + "swipedelegate-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/SwipeView.qml b/src/imports/controls/imagine/SwipeView.qml index e84ff6b0..8410d0bd 100644 --- a/src/imports/controls/imagine/SwipeView.qml +++ b/src/imports/controls/imagine/SwipeView.qml @@ -73,7 +73,7 @@ T.SwipeView { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "swipeview-background" + source: Imagine.url + "swipeview-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/Switch.qml b/src/imports/controls/imagine/Switch.qml index f6d1348e..a4a33e29 100644 --- a/src/imports/controls/imagine/Switch.qml +++ b/src/imports/controls/imagine/Switch.qml @@ -62,7 +62,7 @@ T.Switch { width: Math.max(implicitWidth, handle.leftPadding && handle.rightPadding ? handle.implicitWidth : 2 * handle.implicitWidth) height: Math.max(implicitHeight, handle.implicitHeight) - source: Imagine.path + "switch-indicator" + source: Imagine.url + "switch-indicator" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -83,7 +83,7 @@ T.Switch { x: Math.max(minPos, Math.min(maxPos, control.visualPosition * parent.width - (width / 2))) y: (parent.height - height) / 2 - source: Imagine.path + "switch-handle" + source: Imagine.url + "switch-handle" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -120,7 +120,7 @@ T.Switch { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "switch-background" + source: Imagine.url + "switch-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/SwitchDelegate.qml b/src/imports/controls/imagine/SwitchDelegate.qml index 97bb03b9..0c9bfb15 100644 --- a/src/imports/controls/imagine/SwitchDelegate.qml +++ b/src/imports/controls/imagine/SwitchDelegate.qml @@ -68,7 +68,7 @@ T.SwitchDelegate { width: Math.max(implicitWidth, handle.leftPadding && handle.rightPadding ? handle.implicitWidth : 2 * handle.implicitWidth) height: Math.max(implicitHeight, handle.implicitHeight) - source: Imagine.path + "switchdelegate-indicator" + source: Imagine.url + "switchdelegate-indicator" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -90,7 +90,7 @@ T.SwitchDelegate { x: Math.max(minPos, Math.min(maxPos, control.visualPosition * parent.width - (width / 2))) y: (parent.height - height) / 2 - source: Imagine.path + "switchdelegate-handle" + source: Imagine.url + "switchdelegate-handle" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, @@ -130,7 +130,7 @@ T.SwitchDelegate { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "switchdelegate-background" + source: Imagine.url + "switchdelegate-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/TabBar.qml b/src/imports/controls/imagine/TabBar.qml index 1ce009a0..49e7b425 100644 --- a/src/imports/controls/imagine/TabBar.qml +++ b/src/imports/controls/imagine/TabBar.qml @@ -73,7 +73,7 @@ T.TabBar { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "tabbar-background" + source: Imagine.url + "tabbar-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/TabButton.qml b/src/imports/controls/imagine/TabButton.qml index 6ed6ea7f..aa87f472 100644 --- a/src/imports/controls/imagine/TabButton.qml +++ b/src/imports/controls/imagine/TabButton.qml @@ -77,7 +77,7 @@ T.TabButton { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "tabbutton-background" + source: Imagine.url + "tabbutton-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/TextArea.qml b/src/imports/controls/imagine/TextArea.qml index 18fe0c81..ac212b95 100644 --- a/src/imports/controls/imagine/TextArea.qml +++ b/src/imports/controls/imagine/TextArea.qml @@ -82,7 +82,7 @@ T.TextArea { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "textarea-background" + source: Imagine.url + "textarea-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/TextField.qml b/src/imports/controls/imagine/TextField.qml index 93f43d14..a6449884 100644 --- a/src/imports/controls/imagine/TextField.qml +++ b/src/imports/controls/imagine/TextField.qml @@ -82,7 +82,7 @@ T.TextField { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "textfield-background" + source: Imagine.url + "textfield-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ToolBar.qml b/src/imports/controls/imagine/ToolBar.qml index 6da2d171..a4bf9c1f 100644 --- a/src/imports/controls/imagine/ToolBar.qml +++ b/src/imports/controls/imagine/ToolBar.qml @@ -58,7 +58,7 @@ T.ToolBar { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "toolbar-background" + source: Imagine.url + "toolbar-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ToolButton.qml b/src/imports/controls/imagine/ToolButton.qml index 815e48eb..b82b59fd 100644 --- a/src/imports/controls/imagine/ToolButton.qml +++ b/src/imports/controls/imagine/ToolButton.qml @@ -77,7 +77,7 @@ T.ToolButton { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "toolbutton-background" + source: Imagine.url + "toolbutton-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/ToolSeparator.qml b/src/imports/controls/imagine/ToolSeparator.qml index 68839f64..99a45938 100644 --- a/src/imports/controls/imagine/ToolSeparator.qml +++ b/src/imports/controls/imagine/ToolSeparator.qml @@ -53,7 +53,7 @@ T.ToolSeparator { bottomPadding: background ? background.bottomPadding : 0 contentItem: NinePatchImage { - source: Imagine.path + "toolseparator-separator" + source: Imagine.url + "toolseparator-separator" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, @@ -69,7 +69,7 @@ T.ToolSeparator { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "toolseparator-background" + source: Imagine.url + "toolseparator-background" NinePatchImageSelector on source { states: [ {"vertical": control.vertical}, diff --git a/src/imports/controls/imagine/ToolTip.qml b/src/imports/controls/imagine/ToolTip.qml index d509b3d5..cc89a728 100644 --- a/src/imports/controls/imagine/ToolTip.qml +++ b/src/imports/controls/imagine/ToolTip.qml @@ -74,7 +74,7 @@ T.ToolTip { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "tooltip-background" + source: Imagine.url + "tooltip-background" NinePatchImageSelector on source { states: [ // ### diff --git a/src/imports/controls/imagine/Tumbler.qml b/src/imports/controls/imagine/Tumbler.qml index dbcd3146..5e1c913c 100644 --- a/src/imports/controls/imagine/Tumbler.qml +++ b/src/imports/controls/imagine/Tumbler.qml @@ -76,7 +76,7 @@ T.Tumbler { width: control.width + leftInset + rightInset height: control.height + topInset + bottomInset - source: Imagine.path + "tumbler-background" + source: Imagine.url + "tumbler-background" NinePatchImageSelector on source { states: [ {"disabled": !control.enabled}, diff --git a/src/imports/controls/imagine/qquickimaginestyle.cpp b/src/imports/controls/imagine/qquickimaginestyle.cpp index e103421e..7617fbf5 100644 --- a/src/imports/controls/imagine/qquickimaginestyle.cpp +++ b/src/imports/controls/imagine/qquickimaginestyle.cpp @@ -64,17 +64,16 @@ QQuickImagineStyle *QQuickImagineStyle::qmlAttachedProperties(QObject *object) QString QQuickImagineStyle::path() const { - return m_path; // ### TODO: url? + return m_path; } void QQuickImagineStyle::setPath(const QString &path) { - QString p = ensureSlash(path); m_explicitPath = true; - if (m_path == p) + if (m_path == path) return; - m_path = p; + m_path = path; propagatePath(); emit pathChanged(); @@ -110,6 +109,29 @@ void QQuickImagineStyle::resetPath() inheritPath(imagine ? imagine->path() : *GlobalPath()); } +QUrl QQuickImagineStyle::url() const +{ + // Using ApplicationWindow as an example, its NinePatchImage url + // was previously assigned like this: + // + // soruce: Imagine.path + "applicationwindow-background" + // + // If Imagine.path is set to ":/images" by the user, then the final URL would be: + // + // QUrl("file:///home/user/qt/qtbase/qml/QtQuick/Controls.2/Imagine/:/images/applicationwindow-background") + // + // To ensure that the correct URL is constructed, we do it ourselves here, + // and then the control QML files use the "url" property instead. + const QString path = ensureSlash(m_path); + if (path.startsWith(QLatin1String("qrc"))) + return QUrl(path); + + if (path.startsWith(QLatin1String(":/"))) + return QUrl(QLatin1String("qrc") + path); + + return QUrl::fromLocalFile(path); +} + void QQuickImagineStyle::attachedParentChange(QQuickAttachedObject *newParent, QQuickAttachedObject *oldParent) { Q_UNUSED(oldParent); diff --git a/src/imports/controls/imagine/qquickimaginestyle_p.h b/src/imports/controls/imagine/qquickimaginestyle_p.h index fc4b21b8..88b92c00 100644 --- a/src/imports/controls/imagine/qquickimaginestyle_p.h +++ b/src/imports/controls/imagine/qquickimaginestyle_p.h @@ -58,6 +58,7 @@ class QQuickImagineStyle : public QQuickAttachedObject { Q_OBJECT Q_PROPERTY(QString path READ path WRITE setPath RESET resetPath NOTIFY pathChanged FINAL) + Q_PROPERTY(QUrl url READ url NOTIFY pathChanged FINAL) public: explicit QQuickImagineStyle(QObject *parent = nullptr); @@ -70,6 +71,8 @@ public: void propagatePath(); void resetPath(); + QUrl url() const; + Q_SIGNALS: void pathChanged(); -- cgit v1.2.3