aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--.qmake.conf2
-rw-r--r--README.md2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter2-lists/main.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter4-models/main.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/+material/ChatToolBar.qml4
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro2
-rw-r--r--examples/quickcontrols2/chattutorial/chapter5-styling/main.qml2
-rw-r--r--examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc4
-rw-r--r--examples/quickcontrols2/contactlist/ContactDelegate.ui.qml127
-rw-r--r--examples/quickcontrols2/contactlist/ContactDialog.qml92
-rw-r--r--examples/quickcontrols2/contactlist/ContactForm.ui.qml119
-rw-r--r--examples/quickcontrols2/contactlist/ContactView.ui.qml87
-rw-r--r--examples/quickcontrols2/contactlist/SectionDelegate.ui.qml64
-rw-r--r--examples/quickcontrols2/contactlist/contactlist.pro22
-rw-r--r--examples/quickcontrols2/contactlist/contactlist.qml117
-rw-r--r--examples/quickcontrols2/contactlist/contactmodel.cpp130
-rw-r--r--examples/quickcontrols2/contactlist/contactmodel.h91
-rw-r--r--examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml88
-rw-r--r--examples/quickcontrols2/contactlist/designer/Backend/qmldir2
-rw-r--r--examples/quickcontrols2/contactlist/doc/images/qtquickcontrols2-contactlist.pngbin0 -> 25824 bytes
-rw-r--r--examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc71
-rw-r--r--examples/quickcontrols2/contactlist/main.cpp66
-rw-r--r--examples/quickcontrols2/gallery/gallery.pro10
-rw-r--r--examples/quickcontrols2/gallery/gallery.qml88
-rw-r--r--examples/quickcontrols2/gallery/gallery.qrc70
-rw-r--r--examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml5
-rw-r--r--examples/quickcontrols2/gallery/pages/ButtonPage.qml13
-rw-r--r--examples/quickcontrols2/gallery/pages/CheckBoxPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/ComboBoxPage.qml3
-rw-r--r--examples/quickcontrols2/gallery/pages/DelegatePage.qml8
-rw-r--r--examples/quickcontrols2/gallery/pages/DialPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/DialogPage.qml216
-rw-r--r--examples/quickcontrols2/gallery/pages/FramePage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/GroupBoxPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/PageIndicatorPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/ProgressBarPage.qml6
-rw-r--r--examples/quickcontrols2/gallery/pages/RadioButtonPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/RangeSliderPage.qml6
-rw-r--r--examples/quickcontrols2/gallery/pages/ScrollBarPage.qml4
-rw-r--r--examples/quickcontrols2/gallery/pages/ScrollIndicatorPage.qml4
-rw-r--r--examples/quickcontrols2/gallery/pages/SliderPage.qml6
-rw-r--r--examples/quickcontrols2/gallery/pages/SpinBoxPage.qml5
-rw-r--r--examples/quickcontrols2/gallery/pages/StackViewPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/SwipeViewPage.qml4
-rw-r--r--examples/quickcontrols2/gallery/pages/SwitchPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/TabBarPage.qml4
-rw-r--r--examples/quickcontrols2/gallery/pages/TextAreaPage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/TextFieldPage.qml3
-rw-r--r--examples/quickcontrols2/gallery/pages/ToolTipPage.qml3
-rw-r--r--examples/quickcontrols2/gallery/pages/TumblerPage.qml3
-rw-r--r--examples/quickcontrols2/gallery/qtquickcontrols2.conf4
-rw-r--r--examples/quickcontrols2/quickcontrols2.pro4
-rw-r--r--examples/quickcontrols2/texteditor/+touch/texteditor.html19
-rw-r--r--examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-desktop.jpgbin0 -> 76304 bytes
-rw-r--r--examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-touch.jpgbin0 -> 31203 bytes
-rw-r--r--examples/quickcontrols2/texteditor/doc/src/qtquickcontrols2-texteditor.qdoc122
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.cpp371
-rw-r--r--examples/quickcontrols2/texteditor/documenthandler.h170
-rw-r--r--examples/quickcontrols2/texteditor/fonts/fontello.ttfbin0 -> 10152 bytes
-rw-r--r--examples/quickcontrols2/texteditor/images/qt-logo.pngbin0 -> 5681 bytes
-rw-r--r--examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml260
-rw-r--r--examples/quickcontrols2/texteditor/qml/texteditor.qml442
-rw-r--r--examples/quickcontrols2/texteditor/qtquickcontrols2.conf11
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.cpp89
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.html44
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.pro22
-rw-r--r--examples/quickcontrols2/texteditor/texteditor.qrc11
-rw-r--r--src/imports/calendar/calendar.pro2
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-calendarmodel.png (renamed from src/imports/controls/doc/images/qtlabscalendar-calendarmodel.png)bin5724 -> 5724 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow-layout.png (renamed from src/imports/controls/doc/images/qtlabscalendar-dayofweekrow-layout.png)bin7455 -> 7455 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow.png (renamed from src/imports/controls/doc/images/qtlabscalendar-dayofweekrow.png)bin2017 -> 2017 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-monthgrid-layout.png (renamed from src/imports/controls/doc/images/qtlabscalendar-monthgrid-layout.png)bin8876 -> 8876 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-monthgrid.png (renamed from src/imports/controls/doc/images/qtlabscalendar-monthgrid.png)bin3827 -> 3827 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn-layout.png (renamed from src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn-layout.png)bin4986 -> 4986 bytes
-rw-r--r--src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn.png (renamed from src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn.png)bin1453 -> 1453 bytes
-rw-r--r--src/imports/calendar/doc/qtlabscalendar.qdocconf37
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-calendarmodel.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-calendarmodel.qml)2
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow-layout.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow-layout.qml)0
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow.qml)0
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid-layout.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid-layout.qml)0
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid.qml)0
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn-layout.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn-layout.qml)0
-rw-r--r--src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn.qml (renamed from src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn.qml)0
-rw-r--r--src/imports/calendar/doc/src/qtlabscalendar-index.qdoc (renamed from src/imports/controls/doc/src/calendar/qtlabscalendar-index.qdoc)8
-rw-r--r--src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc (renamed from src/imports/controls/doc/src/calendar/qtlabscalendar.qdoc)0
-rw-r--r--src/imports/calendar/qquickcalendar.cpp2
-rw-r--r--src/imports/controls/AbstractButton.qml4
-rw-r--r--src/imports/controls/ApplicationWindow.qml12
-rw-r--r--src/imports/controls/BusyIndicator.qml8
-rw-r--r--src/imports/controls/Button.qml16
-rw-r--r--src/imports/controls/CheckBox.qml10
-rw-r--r--src/imports/controls/CheckDelegate.qml12
-rw-r--r--src/imports/controls/CheckIndicator.qml16
-rw-r--r--src/imports/controls/ComboBox.qml21
-rw-r--r--src/imports/controls/Container.qml4
-rw-r--r--src/imports/controls/Control.qml4
-rw-r--r--src/imports/controls/Dial.qml12
-rw-r--r--src/imports/controls/Dialog.qml79
-rw-r--r--src/imports/controls/DialogButtonBox.qml73
-rw-r--r--src/imports/controls/Drawer.qml10
-rw-r--r--src/imports/controls/Frame.qml10
-rw-r--r--src/imports/controls/GroupBox.qml12
-rw-r--r--src/imports/controls/ItemDelegate.qml12
-rw-r--r--src/imports/controls/Label.qml10
-rw-r--r--src/imports/controls/Menu.qml11
-rw-r--r--src/imports/controls/MenuItem.qml10
-rw-r--r--src/imports/controls/MenuSeparator.qml59
-rw-r--r--src/imports/controls/Page.qml20
-rw-r--r--src/imports/controls/PageIndicator.qml8
-rw-r--r--src/imports/controls/Pane.qml10
-rw-r--r--src/imports/controls/Popup.qml10
-rw-r--r--src/imports/controls/ProgressBar.qml10
-rw-r--r--src/imports/controls/RadioButton.qml10
-rw-r--r--src/imports/controls/RadioDelegate.qml12
-rw-r--r--src/imports/controls/RadioIndicator.qml12
-rw-r--r--src/imports/controls/RangeSlider.qml24
-rw-r--r--src/imports/controls/RoundButton.qml79
-rw-r--r--src/imports/controls/ScrollBar.qml8
-rw-r--r--src/imports/controls/ScrollIndicator.qml8
-rw-r--r--src/imports/controls/Slider.qml16
-rw-r--r--src/imports/controls/SpinBox.qml28
-rw-r--r--src/imports/controls/StackView.qml6
-rw-r--r--src/imports/controls/SwipeDelegate.qml12
-rw-r--r--src/imports/controls/SwipeView.qml7
-rw-r--r--src/imports/controls/Switch.qml10
-rw-r--r--src/imports/controls/SwitchDelegate.qml12
-rw-r--r--src/imports/controls/SwitchIndicator.qml16
-rw-r--r--src/imports/controls/TabBar.qml4
-rw-r--r--src/imports/controls/TabButton.qml12
-rw-r--r--src/imports/controls/TextArea.qml12
-rw-r--r--src/imports/controls/TextField.qml16
-rw-r--r--src/imports/controls/ToolBar.qml10
-rw-r--r--src/imports/controls/ToolButton.qml10
-rw-r--r--src/imports/controls/ToolSeparator.qml59
-rw-r--r--src/imports/controls/ToolTip.qml9
-rw-r--r--src/imports/controls/Tumbler.qml27
-rw-r--r--src/imports/controls/controls.pri11
-rw-r--r--src/imports/controls/controls.pro2
-rw-r--r--src/imports/controls/dependencies.json17
-rw-r--r--src/imports/controls/designer/ToolSeparatorSpecifics.qml71
-rw-r--r--src/imports/controls/designer/images/toolseparator-icon.pngbin0 -> 198 bytes
-rw-r--r--src/imports/controls/designer/images/toolseparator-icon16.pngbin0 -> 192 bytes
-rw-r--r--src/imports/controls/designer/images/toolseparator-icon16@2x.pngbin0 -> 213 bytes
-rw-r--r--src/imports/controls/designer/images/toolseparator-icon@2x.pngbin0 -> 239 bytes
-rw-r--r--src/imports/controls/designer/qtquickcontrols2.metainfo41
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox-attached.pngbin0 -> 1993 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox.pngbin0 -> 1987 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.pngbin0 -> 5574 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-menuseparator.pngbin0 -> 5614 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-roundbutton.pngbin0 -> 1001 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-toolseparator-custom.pngbin0 -> 4729 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-toolseparator.pngbin0 -> 7148 bytes
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-tumbler-wrap.gifbin54383 -> 54328 bytes
-rw-r--r--src/imports/controls/doc/qtquickcontrols2.qdocconf8
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modal.qml41
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modeless.qml41
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml44
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox-attached.qml42
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox.qml (renamed from src/imports/controls/doc/snippets/basic-example.qml)23
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml69
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml60
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-roundbutton.qml36
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-stackview-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml59
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-swipeview-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator-custom.qml69
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator.qml68
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-listView.qml46
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-pathView.qml57
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-timePicker.qml99
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-busyindicator-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-disabled.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-focused.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-normal.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-pressed.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-checked.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-disabled.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-focused.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-normal.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkdelegate-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-delegate.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-popup.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-handle.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-checkable.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-label.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-menu-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-delegate.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiodelegate-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-active.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-active.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-handle.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-double.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-down.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-textual.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-up.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipedelegate-custom.qml4
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipeview-indicator.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-checked.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-disabled.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-focused.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-normal.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switchdelegate-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbutton.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-disabled.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-focused.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-normal.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbutton-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-hover.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-pressandhold.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml4
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip.qml2
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-custom.qml3
-rw-r--r--src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-delegate.qml2
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-buttons.qdoc18
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc5
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc60
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc483
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc8
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc8
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-gettingstarted.qdoc17
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-index.qdoc7
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-material.qdoc11
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc4
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc63
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc11
-rw-r--r--src/imports/controls/material/ApplicationWindow.qml6
-rw-r--r--src/imports/controls/material/BoxShadow.qml7
-rw-r--r--src/imports/controls/material/BusyIndicator.qml8
-rw-r--r--src/imports/controls/material/Button.qml43
-rw-r--r--src/imports/controls/material/CheckBox.qml22
-rw-r--r--src/imports/controls/material/CheckDelegate.qml24
-rw-r--r--src/imports/controls/material/CheckIndicator.qml16
-rw-r--r--src/imports/controls/material/ComboBox.qml43
-rw-r--r--src/imports/controls/material/Dial.qml16
-rw-r--r--src/imports/controls/material/Dialog.qml105
-rw-r--r--src/imports/controls/material/DialogButtonBox.qml79
-rw-r--r--src/imports/controls/material/Drawer.qml27
-rw-r--r--src/imports/controls/material/ElevationEffect.qml22
-rw-r--r--src/imports/controls/material/Frame.qml10
-rw-r--r--src/imports/controls/material/GroupBox.qml12
-rw-r--r--src/imports/controls/material/ItemDelegate.qml23
-rw-r--r--src/imports/controls/material/Label.qml8
-rw-r--r--src/imports/controls/material/Menu.qml10
-rw-r--r--src/imports/controls/material/MenuItem.qml24
-rw-r--r--src/imports/controls/material/MenuSeparator.qml55
-rw-r--r--src/imports/controls/material/Page.qml18
-rw-r--r--src/imports/controls/material/PageIndicator.qml8
-rw-r--r--src/imports/controls/material/Pane.qml10
-rw-r--r--src/imports/controls/material/Popup.qml10
-rw-r--r--src/imports/controls/material/ProgressBar.qml8
-rw-r--r--src/imports/controls/material/RadioButton.qml22
-rw-r--r--src/imports/controls/material/RadioDelegate.qml23
-rw-r--r--src/imports/controls/material/RadioIndicator.qml17
-rw-r--r--src/imports/controls/material/RangeSlider.qml12
-rw-r--r--src/imports/controls/material/RectangularGlow.qml240
-rw-r--r--src/imports/controls/material/RoundButton.qml113
-rw-r--r--src/imports/controls/material/ScrollBar.qml48
-rw-r--r--src/imports/controls/material/ScrollIndicator.qml6
-rw-r--r--src/imports/controls/material/Slider.qml11
-rw-r--r--src/imports/controls/material/SliderHandle.qml17
-rw-r--r--src/imports/controls/material/SpinBox.qml56
-rw-r--r--src/imports/controls/material/StackView.qml4
-rw-r--r--src/imports/controls/material/SwipeDelegate.qml28
-rw-r--r--src/imports/controls/material/SwipeView.qml5
-rw-r--r--src/imports/controls/material/Switch.qml19
-rw-r--r--src/imports/controls/material/SwitchDelegate.qml24
-rw-r--r--src/imports/controls/material/SwitchIndicator.qml19
-rw-r--r--src/imports/controls/material/TabBar.qml8
-rw-r--r--src/imports/controls/material/TabButton.qml17
-rw-r--r--src/imports/controls/material/TextArea.qml8
-rw-r--r--src/imports/controls/material/TextField.qml8
-rw-r--r--src/imports/controls/material/ToolBar.qml10
-rw-r--r--src/imports/controls/material/ToolButton.qml25
-rw-r--r--src/imports/controls/material/ToolSeparator.qml59
-rw-r--r--src/imports/controls/material/ToolTip.qml8
-rw-r--r--src/imports/controls/material/Tumbler.qml29
-rw-r--r--src/imports/controls/material/material.pri9
-rw-r--r--src/imports/controls/material/material.pro2
-rw-r--r--src/imports/controls/material/qmldir1
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp55
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip.cpp19
-rw-r--r--src/imports/controls/material/qquickmaterialripple.cpp451
-rw-r--r--src/imports/controls/material/qquickmaterialripple_p.h120
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp133
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h33
-rw-r--r--src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp9
-rw-r--r--src/imports/controls/material/qtquickcontrols2materialstyleplugin.qrc3
-rw-r--r--src/imports/controls/material/shaders/+glslcore/RectangularGlow.frag25
-rw-r--r--src/imports/controls/material/shaders/+hlsl/RectangularGlow.frag21
-rw-r--r--src/imports/controls/material/shaders/RectangularGlow.frag19
-rw-r--r--src/imports/controls/plugins.qmltypes1455
-rw-r--r--src/imports/controls/qquickbusyindicatorring.cpp19
-rw-r--r--src/imports/controls/qquickdefaultstyle.cpp241
-rw-r--r--src/imports/controls/qquickdefaultstyle_p.h145
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp22
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp33
-rw-r--r--src/imports/controls/universal/ApplicationWindow.qml8
-rw-r--r--src/imports/controls/universal/BusyIndicator.qml8
-rw-r--r--src/imports/controls/universal/Button.qml15
-rw-r--r--src/imports/controls/universal/CheckBox.qml8
-rw-r--r--src/imports/controls/universal/CheckDelegate.qml11
-rw-r--r--src/imports/controls/universal/CheckIndicator.qml23
-rw-r--r--src/imports/controls/universal/ComboBox.qml18
-rw-r--r--src/imports/controls/universal/Dial.qml9
-rw-r--r--src/imports/controls/universal/Dialog.qml87
-rw-r--r--src/imports/controls/universal/DialogButtonBox.qml77
-rw-r--r--src/imports/controls/universal/Drawer.qml8
-rw-r--r--src/imports/controls/universal/Frame.qml8
-rw-r--r--src/imports/controls/universal/GroupBox.qml8
-rw-r--r--src/imports/controls/universal/ItemDelegate.qml11
-rw-r--r--src/imports/controls/universal/Label.qml6
-rw-r--r--src/imports/controls/universal/Menu.qml8
-rw-r--r--src/imports/controls/universal/MenuItem.qml9
-rw-r--r--src/imports/controls/universal/MenuSeparator.qml60
-rw-r--r--src/imports/controls/universal/Page.qml18
-rw-r--r--src/imports/controls/universal/PageIndicator.qml6
-rw-r--r--src/imports/controls/universal/Pane.qml8
-rw-r--r--src/imports/controls/universal/Popup.qml8
-rw-r--r--src/imports/controls/universal/ProgressBar.qml8
-rw-r--r--src/imports/controls/universal/RadioButton.qml8
-rw-r--r--src/imports/controls/universal/RadioDelegate.qml11
-rw-r--r--src/imports/controls/universal/RadioIndicator.qml10
-rw-r--r--src/imports/controls/universal/RangeSlider.qml17
-rw-r--r--src/imports/controls/universal/RoundButton.qml85
-rw-r--r--src/imports/controls/universal/ScrollBar.qml9
-rw-r--r--src/imports/controls/universal/ScrollIndicator.qml6
-rw-r--r--src/imports/controls/universal/Slider.qml13
-rw-r--r--src/imports/controls/universal/SpinBox.qml27
-rw-r--r--src/imports/controls/universal/StackView.qml6
-rw-r--r--src/imports/controls/universal/SwipeDelegate.qml9
-rw-r--r--src/imports/controls/universal/Switch.qml6
-rw-r--r--src/imports/controls/universal/SwitchDelegate.qml11
-rw-r--r--src/imports/controls/universal/SwitchIndicator.qml32
-rw-r--r--src/imports/controls/universal/TabBar.qml6
-rw-r--r--src/imports/controls/universal/TabButton.qml10
-rw-r--r--src/imports/controls/universal/TextArea.qml9
-rw-r--r--src/imports/controls/universal/TextField.qml9
-rw-r--r--src/imports/controls/universal/ToolBar.qml8
-rw-r--r--src/imports/controls/universal/ToolButton.qml16
-rw-r--r--src/imports/controls/universal/ToolSeparator.qml59
-rw-r--r--src/imports/controls/universal/ToolTip.qml6
-rw-r--r--src/imports/controls/universal/Tumbler.qml27
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring.cpp4
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip.cpp12
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle.cpp12
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle_p.h2
-rw-r--r--src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp2
-rw-r--r--src/imports/controls/universal/universal.pri5
-rw-r--r--src/imports/controls/universal/universal.pro2
-rw-r--r--src/imports/imports.pro1
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-colordialog-gtk.pngbin0 -> 11057 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-filedialog-gtk.pngbin0 -> 49506 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-folderdialog-gtk.pngbin0 -> 49092 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-fontdialog-gtk.pngbin0 -> 43653 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-menu.pngbin0 -> 6377 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-menubar.pngbin0 -> 71036 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-messagedialog-android.pngbin0 -> 7946 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-messagedialog-informative-android.pngbin0 -> 15759 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-menu.pngbin0 -> 24016 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-message.pngbin0 -> 36932 bytes
-rw-r--r--src/imports/platform/doc/images/qtlabsplatform-systemtrayicon.pngbin0 -> 19927 bytes
-rw-r--r--src/imports/platform/doc/qtlabsplatform.qdocconf37
-rw-r--r--src/imports/platform/doc/src/includes/widgets.qdocinc29
-rw-r--r--src/imports/platform/doc/src/qtlabsplatform-index.qdoc50
-rw-r--r--src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc58
-rw-r--r--src/imports/platform/platform.pri31
-rw-r--r--src/imports/platform/platform.pro22
-rw-r--r--src/imports/platform/plugins.qmltypes460
-rw-r--r--src/imports/platform/qmldir3
-rw-r--r--src/imports/platform/qquickplatformcolordialog.cpp205
-rw-r--r--src/imports/platform/qquickplatformcolordialog_p.h98
-rw-r--r--src/imports/platform/qquickplatformdialog.cpp409
-rw-r--r--src/imports/platform/qquickplatformdialog_p.h153
-rw-r--r--src/imports/platform/qquickplatformfiledialog.cpp660
-rw-r--r--src/imports/platform/qquickplatformfiledialog_p.h196
-rw-r--r--src/imports/platform/qquickplatformfolderdialog.cpp281
-rw-r--r--src/imports/platform/qquickplatformfolderdialog_p.h110
-rw-r--r--src/imports/platform/qquickplatformfontdialog.cpp208
-rw-r--r--src/imports/platform/qquickplatformfontdialog_p.h98
-rw-r--r--src/imports/platform/qquickplatformiconloader.cpp111
-rw-r--r--src/imports/platform/qquickplatformiconloader_p.h89
-rw-r--r--src/imports/platform/qquickplatformmenu.cpp835
-rw-r--r--src/imports/platform/qquickplatformmenu_p.h213
-rw-r--r--src/imports/platform/qquickplatformmenubar.cpp330
-rw-r--r--src/imports/platform/qquickplatformmenubar_p.h120
-rw-r--r--src/imports/platform/qquickplatformmenuitem.cpp612
-rw-r--r--src/imports/platform/qquickplatformmenuitem_p.h191
-rw-r--r--src/imports/platform/qquickplatformmenuitemgroup.cpp390
-rw-r--r--src/imports/platform/qquickplatformmenuitemgroup_p.h123
-rw-r--r--src/imports/platform/qquickplatformmenuseparator.cpp65
-rw-r--r--src/imports/platform/qquickplatformmenuseparator_p.h67
-rw-r--r--src/imports/platform/qquickplatformmessagedialog.cpp383
-rw-r--r--src/imports/platform/qquickplatformmessagedialog_p.h121
-rw-r--r--src/imports/platform/qquickplatformstandardpaths.cpp159
-rw-r--r--src/imports/platform/qquickplatformstandardpaths_p.h90
-rw-r--r--src/imports/platform/qquickplatformsystemtrayicon.cpp441
-rw-r--r--src/imports/platform/qquickplatformsystemtrayicon_p.h139
-rw-r--r--src/imports/platform/qtlabsplatformplugin.cpp115
-rw-r--r--src/imports/platform/widgets/qwidgetplatform_p.h125
-rw-r--r--src/imports/platform/widgets/qwidgetplatformcolordialog.cpp87
-rw-r--r--src/imports/platform/widgets/qwidgetplatformcolordialog_p.h78
-rw-r--r--src/imports/platform/widgets/qwidgetplatformdialog.cpp58
-rw-r--r--src/imports/platform/widgets/qwidgetplatformdialog_p.h66
-rw-r--r--src/imports/platform/widgets/qwidgetplatformfiledialog.cpp140
-rw-r--r--src/imports/platform/widgets/qwidgetplatformfiledialog_p.h84
-rw-r--r--src/imports/platform/widgets/qwidgetplatformfontdialog.cpp87
-rw-r--r--src/imports/platform/widgets/qwidgetplatformfontdialog_p.h78
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmenu.cpp186
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmenu_p.h99
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmenuitem.cpp131
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmenuitem_p.h89
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmessagedialog.cpp85
-rw-r--r--src/imports/platform/widgets/qwidgetplatformmessagedialog_p.h75
-rw-r--r--src/imports/platform/widgets/qwidgetplatformsystemtrayicon.cpp114
-rw-r--r--src/imports/platform/widgets/qwidgetplatformsystemtrayicon_p.h85
-rw-r--r--src/imports/platform/widgets/widgets.pri23
-rw-r--r--src/imports/templates/dependencies.json12
-rw-r--r--src/imports/templates/doc/src/qtquicktemplates2-index.qdoc (renamed from src/imports/controls/doc/src/templates/qtquicktemplates2-index.qdoc)0
-rw-r--r--src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc (renamed from src/imports/controls/doc/src/templates/qtquicktemplates2.qdoc)2
-rw-r--r--src/imports/templates/plugins.qmltypes1141
-rw-r--r--src/imports/templates/qtquicktemplates2plugin.cpp28
-rw-r--r--src/imports/templates/templates.pro2
-rw-r--r--src/quickcontrols2/qquickpaddedrectangle.cpp2
-rw-r--r--src/quickcontrols2/qquickproxytheme.cpp6
-rw-r--r--src/quickcontrols2/qquickproxytheme_p.h3
-rw-r--r--src/quickcontrols2/qquickstyle.cpp183
-rw-r--r--src/quickcontrols2/qquickstyle.h1
-rw-r--r--src/quickcontrols2/qquickstyle_p.h68
-rw-r--r--src/quickcontrols2/qquickstyleattached.cpp36
-rw-r--r--src/quickcontrols2/qquickstyleselector.cpp92
-rw-r--r--src/quickcontrols2/qquickstyleselector_p_p.h5
-rw-r--r--src/quickcontrols2/qquicktumblerview.cpp273
-rw-r--r--src/quickcontrols2/qquicktumblerview_p.h109
-rw-r--r--src/quickcontrols2/quickcontrols2.pri7
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp29
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p.h2
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h2
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp25
-rw-r--r--src/quicktemplates2/qquickbusyindicator.cpp1
-rw-r--r--src/quicktemplates2/qquickbutton.cpp34
-rw-r--r--src/quicktemplates2/qquickbutton_p.h5
-rw-r--r--src/quicktemplates2/qquickbutton_p_p.h68
-rw-r--r--src/quicktemplates2/qquickbuttongroup.cpp38
-rw-r--r--src/quicktemplates2/qquickbuttongroup_p.h1
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp33
-rw-r--r--src/quicktemplates2/qquickcombobox_p.h5
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp32
-rw-r--r--src/quicktemplates2/qquickcontainer_p.h2
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp119
-rw-r--r--src/quicktemplates2/qquickcontrol_p.h5
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h7
-rw-r--r--src/quicktemplates2/qquickdial.cpp14
-rw-r--r--src/quicktemplates2/qquickdial_p.h2
-rw-r--r--src/quicktemplates2/qquickdialog.cpp363
-rw-r--r--src/quicktemplates2/qquickdialog_p.h114
-rw-r--r--src/quicktemplates2/qquickdialog_p_p.h78
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp672
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox_p.h155
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox_p_p.h107
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp2
-rw-r--r--src/quicktemplates2/qquickmenu.cpp2
-rw-r--r--src/quicktemplates2/qquickmenu_p_p.h2
-rw-r--r--src/quicktemplates2/qquickmenuitem.cpp16
-rw-r--r--src/quicktemplates2/qquickmenuitem_p.h3
-rw-r--r--src/quicktemplates2/qquickmenuseparator.cpp80
-rw-r--r--src/quicktemplates2/qquickmenuseparator_p.h75
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp4
-rw-r--r--src/quicktemplates2/qquickoverlay_p_p.h2
-rw-r--r--src/quicktemplates2/qquickpage.cpp199
-rw-r--r--src/quicktemplates2/qquickpage_p.h11
-rw-r--r--src/quicktemplates2/qquickpagelayout.cpp190
-rw-r--r--src/quicktemplates2/qquickpagelayout_p_p.h86
-rw-r--r--src/quicktemplates2/qquickpane.cpp12
-rw-r--r--src/quicktemplates2/qquickpane_p_p.h2
-rw-r--r--src/quicktemplates2/qquickpopup.cpp72
-rw-r--r--src/quicktemplates2/qquickpopup_p.h7
-rw-r--r--src/quicktemplates2/qquickpopup_p_p.h3
-rw-r--r--src/quicktemplates2/qquickpresshandler.cpp42
-rw-r--r--src/quicktemplates2/qquickpresshandler_p_p.h2
-rw-r--r--src/quicktemplates2/qquickprogressbar.cpp1
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp63
-rw-r--r--src/quicktemplates2/qquickrangeslider_p.h8
-rw-r--r--src/quicktemplates2/qquickroundbutton.cpp143
-rw-r--r--src/quicktemplates2/qquickroundbutton_p.h84
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp40
-rw-r--r--src/quicktemplates2/qquickscrollbar_p.h2
-rw-r--r--src/quicktemplates2/qquickscrollindicator.cpp20
-rw-r--r--src/quicktemplates2/qquickslider.cpp36
-rw-r--r--src/quicktemplates2/qquickslider_p.h2
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp59
-rw-r--r--src/quicktemplates2/qquickspinbox_p.h8
-rw-r--r--src/quicktemplates2/qquickstackview.cpp145
-rw-r--r--src/quicktemplates2/qquickstackview_p.cpp252
-rw-r--r--src/quicktemplates2/qquickstackview_p.h14
-rw-r--r--src/quicktemplates2/qquickstackview_p_p.h26
-rw-r--r--src/quicktemplates2/qquickswipe_p.h3
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp241
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p.h27
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp155
-rw-r--r--src/quicktemplates2/qquickswipeview_p.h15
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp4
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp143
-rw-r--r--src/quicktemplates2/qquicktextarea_p.h15
-rw-r--r--src/quicktemplates2/qquicktextarea_p_p.h6
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp129
-rw-r--r--src/quicktemplates2/qquicktextfield_p.h17
-rw-r--r--src/quicktemplates2/qquicktextfield_p_p.h4
-rw-r--r--src/quicktemplates2/qquicktoolseparator.cpp146
-rw-r--r--src/quicktemplates2/qquicktoolseparator_p.h90
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp2
-rw-r--r--src/quicktemplates2/qquicktooltip_p.h2
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp594
-rw-r--r--src/quicktemplates2/qquicktumbler_p.h11
-rw-r--r--src/quicktemplates2/qquicktumbler_p_p.h113
-rw-r--r--src/quicktemplates2/quicktemplates2.pri16
-rw-r--r--tests/auto/accessibility/accessibility.pro2
-rw-r--r--tests/auto/accessibility/data/busyindicator.qml2
-rw-r--r--tests/auto/accessibility/data/button.qml2
-rw-r--r--tests/auto/accessibility/data/checkbox.qml2
-rw-r--r--tests/auto/accessibility/data/checkdelegate.qml2
-rw-r--r--tests/auto/accessibility/data/combobox.qml2
-rw-r--r--tests/auto/accessibility/data/control.qml2
-rw-r--r--tests/auto/accessibility/data/dial.qml2
-rw-r--r--tests/auto/accessibility/data/dialog.qml6
-rw-r--r--tests/auto/accessibility/data/frame.qml2
-rw-r--r--tests/auto/accessibility/data/groupbox.qml2
-rw-r--r--tests/auto/accessibility/data/itemdelegate.qml2
-rw-r--r--tests/auto/accessibility/data/label.qml2
-rw-r--r--tests/auto/accessibility/data/menu.qml2
-rw-r--r--tests/auto/accessibility/data/menuitem.qml2
-rw-r--r--tests/auto/accessibility/data/page.qml2
-rw-r--r--tests/auto/accessibility/data/pageindicator.qml2
-rw-r--r--tests/auto/accessibility/data/pane.qml2
-rw-r--r--tests/auto/accessibility/data/popup.qml2
-rw-r--r--tests/auto/accessibility/data/progressbar.qml2
-rw-r--r--tests/auto/accessibility/data/radiobutton.qml2
-rw-r--r--tests/auto/accessibility/data/rangeslider.qml2
-rw-r--r--tests/auto/accessibility/data/roundbutton.qml6
-rw-r--r--tests/auto/accessibility/data/scrollbar.qml2
-rw-r--r--tests/auto/accessibility/data/scrollindicator.qml2
-rw-r--r--tests/auto/accessibility/data/slider.qml2
-rw-r--r--tests/auto/accessibility/data/spinbox.qml2
-rw-r--r--tests/auto/accessibility/data/switch.qml2
-rw-r--r--tests/auto/accessibility/data/switchdelegate.qml2
-rw-r--r--tests/auto/accessibility/data/tabbar.qml2
-rw-r--r--tests/auto/accessibility/data/tabbutton.qml2
-rw-r--r--tests/auto/accessibility/data/textarea.qml2
-rw-r--r--tests/auto/accessibility/data/textfield.qml2
-rw-r--r--tests/auto/accessibility/data/toolbar.qml2
-rw-r--r--tests/auto/accessibility/data/toolbutton.qml2
-rw-r--r--tests/auto/accessibility/data/tooltip.qml2
-rw-r--r--tests/auto/accessibility/tst_accessibility.cpp2
-rw-r--r--tests/auto/applicationwindow/applicationwindow.pro2
-rw-r--r--tests/auto/applicationwindow/data/activeFocusControl.qml2
-rw-r--r--tests/auto/applicationwindow/data/activefocusontab.qml2
-rw-r--r--tests/auto/applicationwindow/data/attachedProperties.qml2
-rw-r--r--tests/auto/applicationwindow/data/basicapplicationwindow.qml2
-rw-r--r--tests/auto/applicationwindow/data/defaultFocus.qml2
-rw-r--r--tests/auto/applicationwindow/data/fill.qml2
-rw-r--r--tests/auto/applicationwindow/data/focusAfterPopupClosed.qml2
-rw-r--r--tests/auto/applicationwindow/data/font.qml4
-rw-r--r--tests/auto/applicationwindow/data/locale.qml4
-rw-r--r--tests/auto/applicationwindow/tst_applicationwindow.cpp2
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/calendar/calendar.pro2
-rw-r--r--tests/auto/controls/data/TumblerDatePicker.qml4
-rw-r--r--tests/auto/controls/data/TumblerListView.qml (renamed from examples/quickcontrols2/gallery/pages/DrawerPage.qml)42
-rw-r--r--tests/auto/controls/data/TumblerPathView.qml (renamed from examples/quickcontrols2/gallery/pages/MenuPage.qml)40
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml24
-rw-r--r--tests/auto/controls/data/tst_busyindicator.qml2
-rw-r--r--tests/auto/controls/data/tst_button.qml2
-rw-r--r--tests/auto/controls/data/tst_buttongroup.qml28
-rw-r--r--tests/auto/controls/data/tst_checkbox.qml2
-rw-r--r--tests/auto/controls/data/tst_checkdelegate.qml2
-rw-r--r--tests/auto/controls/data/tst_combobox.qml3
-rw-r--r--tests/auto/controls/data/tst_container.qml4
-rw-r--r--tests/auto/controls/data/tst_control.qml44
-rw-r--r--tests/auto/controls/data/tst_dial.qml49
-rw-r--r--tests/auto/controls/data/tst_dialog.qml346
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml188
-rw-r--r--tests/auto/controls/data/tst_drawer.qml2
-rw-r--r--tests/auto/controls/data/tst_frame.qml2
-rw-r--r--tests/auto/controls/data/tst_groupbox.qml2
-rw-r--r--tests/auto/controls/data/tst_itemdelegate.qml2
-rw-r--r--tests/auto/controls/data/tst_label.qml2
-rw-r--r--tests/auto/controls/data/tst_menuitem.qml2
-rw-r--r--tests/auto/controls/data/tst_page.qml142
-rw-r--r--tests/auto/controls/data/tst_pageindicator.qml2
-rw-r--r--tests/auto/controls/data/tst_pane.qml2
-rw-r--r--tests/auto/controls/data/tst_popup.qml8
-rw-r--r--tests/auto/controls/data/tst_progressbar.qml2
-rw-r--r--tests/auto/controls/data/tst_radiobutton.qml2
-rw-r--r--tests/auto/controls/data/tst_radiodelegate.qml2
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml29
-rw-r--r--tests/auto/controls/data/tst_roundbutton.qml79
-rw-r--r--tests/auto/controls/data/tst_scrollbar.qml40
-rw-r--r--tests/auto/controls/data/tst_scrollindicator.qml16
-rw-r--r--tests/auto/controls/data/tst_slider.qml22
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml31
-rw-r--r--tests/auto/controls/data/tst_stackview.qml177
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml349
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml28
-rw-r--r--tests/auto/controls/data/tst_switch.qml2
-rw-r--r--tests/auto/controls/data/tst_switchdelegate.qml2
-rw-r--r--tests/auto/controls/data/tst_tabbar.qml12
-rw-r--r--tests/auto/controls/data/tst_tabbutton.qml2
-rw-r--r--tests/auto/controls/data/tst_textarea.qml192
-rw-r--r--tests/auto/controls/data/tst_textfield.qml192
-rw-r--r--tests/auto/controls/data/tst_toolbar.qml2
-rw-r--r--tests/auto/controls/data/tst_toolbutton.qml2
-rw-r--r--tests/auto/controls/data/tst_toolseparator.qml99
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml5
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml472
-rw-r--r--tests/auto/controls/default/default.pro2
-rw-r--r--tests/auto/controls/default/dependencies.qml5
-rw-r--r--tests/auto/controls/material/dependencies.qml6
-rw-r--r--tests/auto/controls/material/material.pro2
-rw-r--r--tests/auto/controls/universal/dependencies.qml6
-rw-r--r--tests/auto/controls/universal/universal.pro2
-rw-r--r--tests/auto/drawer/data/applicationwindow.qml2
-rw-r--r--tests/auto/drawer/drawer.pro2
-rw-r--r--tests/auto/drawer/tst_drawer.cpp11
-rw-r--r--tests/auto/focus/data/activeFocusOnTab.qml2
-rw-r--r--tests/auto/focus/data/keyNavigation.qml2
-rw-r--r--tests/auto/focus/tst_focus.cpp4
-rw-r--r--tests/auto/menu/data/addItem.qml2
-rw-r--r--tests/auto/menu/data/applicationwindow.qml2
-rw-r--r--tests/auto/menu/data/menuSeparator.qml (renamed from examples/quickcontrols2/gallery/pages/PopupPage.qml)47
-rw-r--r--tests/auto/menu/menu.pro2
-rw-r--r--tests/auto/menu/tst_menu.cpp45
-rw-r--r--tests/auto/platform/data/tst_colordialog.qml61
-rw-r--r--tests/auto/platform/data/tst_filedialog.qml61
-rw-r--r--tests/auto/platform/data/tst_folderdialog.qml61
-rw-r--r--tests/auto/platform/data/tst_fontdialog.qml61
-rw-r--r--tests/auto/platform/data/tst_menu.qml235
-rw-r--r--tests/auto/platform/data/tst_menubar.qml229
-rw-r--r--tests/auto/platform/data/tst_menuitem.qml107
-rw-r--r--tests/auto/platform/data/tst_menuitemgroup.qml380
-rw-r--r--tests/auto/platform/data/tst_menuseparator.qml64
-rw-r--r--tests/auto/platform/data/tst_messagedialog.qml61
-rw-r--r--tests/auto/platform/data/tst_standardpaths.qml78
-rw-r--r--tests/auto/platform/data/tst_systemtrayicon.qml90
-rw-r--r--tests/auto/platform/platform.pro12
-rw-r--r--tests/auto/platform/tst_platform.cpp (renamed from src/imports/controls/material/Ripple.qml)19
-rw-r--r--tests/auto/popup/data/activeFocusOnClose1.qml2
-rw-r--r--tests/auto/popup/data/activeFocusOnClose2.qml2
-rw-r--r--tests/auto/popup/data/applicationwindow.qml2
-rw-r--r--tests/auto/popup/popup.pro2
-rw-r--r--tests/auto/pressandhold/data/dependencies.qml2
-rw-r--r--tests/auto/pressandhold/tst_pressandhold.cpp12
-rw-r--r--tests/auto/qquickmaterialstyle/data/tst_material.qml8
-rw-r--r--tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro4
-rw-r--r--tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc5
-rw-r--r--tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml1
-rw-r--r--tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.pro2
-rw-r--r--tests/auto/qquickstyle/data/dependencies.qml4
-rw-r--r--tests/auto/qquickstyle/qquickstyle.pro1
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp29
-rw-r--r--tests/auto/qquickstyleselector/ResourceStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Control.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Label.qml2
-rw-r--r--tests/auto/qquickstyleselector/qquickstyleselector.pro2
-rw-r--r--tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp75
-rw-r--r--tests/auto/qquickuniversalstyle/data/tst_universal.qml6
-rw-r--r--tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro4
-rw-r--r--tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc5
-rw-r--r--tests/auto/qquickuniversalstyleconf/data/applicationwindow.qml1
-rw-r--r--tests/auto/qquickuniversalstyleconf/qquickuniversalstyleconf.pro2
-rw-r--r--tests/auto/revisions/data/dependencies.qml6
-rw-r--r--tests/auto/revisions/revisions.pro7
-rw-r--r--tests/auto/revisions/tst_revisions.cpp84
-rw-r--r--tests/auto/sanity/BLACKLIST4
-rw-r--r--tests/auto/sanity/data/dependencies.qml2
-rw-r--r--tests/auto/snippets/data/dependencies.qml4
-rw-r--r--tests/auto/snippets/snippets.pro2
-rw-r--r--tests/benchmarks/creationtime/data/dependencies.qml6
-rw-r--r--tests/benchmarks/objectcount/data/dependencies.qml6
-rw-r--r--tests/benchmarks/objectcount/tst_objectcount.cpp2
-rw-r--r--tests/manual/buttons/ButtonLoader.qml91
-rw-r--r--tests/manual/buttons/buttons.cpp52
-rw-r--r--tests/manual/buttons/buttons.pro6
-rw-r--r--tests/manual/buttons/buttons.qml140
-rw-r--r--tests/manual/fonts/main.qml4
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-button.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-menu.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-slider.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-switch.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-tabbar.qml2
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml76
-rw-r--r--tests/manual/gifs/gifrecorder.cpp2
-rw-r--r--tests/manual/gifs/tst_gifs.cpp67
-rw-r--r--tests/manual/manual.pro1
-rw-r--r--tests/manual/styles/styles.qml2
-rw-r--r--tests/manual/testbench/testbench.qml126
-rw-r--r--tests/manual/viewinqwidget/main.qml2
754 files changed, 28532 insertions, 4579 deletions
diff --git a/.gitignore b/.gitignore
index 7955f60b..9f5df423 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,9 @@
/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation
/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models
/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling
+/examples/quickcontrols2/contactlist/contactlist
/examples/quickcontrols2/gallery/gallery
+/examples/quickcontrols2/texteditor/texteditor
/tests/auto/accessibility/tst_accessibility
/tests/auto/applicationwindow/tst_applicationwindow
@@ -22,6 +24,7 @@
/tests/auto/drawer/tst_drawer
/tests/auto/focus/tst_focus
/tests/auto/menu/tst_menu
+/tests/auto/platform/tst_platform
/tests/auto/popup/tst_popup
/tests/auto/pressandhold/tst_pressandhold
/tests/auto/qquickmaterialstyle/tst_qquickmaterialstyle
@@ -30,11 +33,13 @@
/tests/auto/qquickstyleselector/tst_qquickstyleselector
/tests/auto/qquickuniversalstyle/tst_qquickuniversalstyle
/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf
+/tests/auto/revisions/tst_revisions
/tests/auto/sanity/tst_sanity
/tests/auto/snippets/tst_snippets
/tests/auto/styles/tst_styles
/tests/benchmarks/creationtime/tst_creationtime
/tests/benchmarks/objectcount/tst_objectcount
+/tests/manual/buttons/buttons
/tests/manual/fonts/fonts
/tests/manual/gifs/tst_gifs
/tests/manual/styles/styles
@@ -123,3 +128,5 @@ android-*.so-deployment-settings.json
qt.conf
*.version
*.version.in
+*.qmlc
+codeattributions.qdoc
diff --git a/.qmake.conf b/.qmake.conf
index 98def4f4..0104dac8 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -4,4 +4,4 @@ DEFINES += QT_NO_FOREACH
QQC2_SOURCE_TREE = $$PWD
-MODULE_VERSION = 5.7.1
+MODULE_VERSION = 5.8.0
diff --git a/README.md b/README.md
index d0a7a4c6..c2903a57 100644
--- a/README.md
+++ b/README.md
@@ -31,8 +31,6 @@ If you have problems or questions, don't hesitate to:
The MINIMUM REQUIREMENT for building this project is to use the same branch
of Qt 5. The dependencies are *qtbase*, *qtxmlpatterns* and *qtdeclarative*.
-Other optional dependencies include *qtgraphicaleffects* for the Material
-style.
To install the controls into your Qt directory (```QTDIR/qml```):
diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml b/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml
index ff65c53c..4fc97a49 100644
--- a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml
+++ b/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 540
diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml b/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml
index a8d9f478..3a1d4cc9 100644
--- a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml
+++ b/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 540
diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml
index 8beb689f..e45e5b61 100644
--- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Page {
id: root
diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml
index 9590669a..0e0e07fb 100644
--- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Page {
id: root
diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml b/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml
index 5bc9e95d..25d50fb7 100644
--- a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml
+++ b/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
id: window
diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml
index a6491495..4a914b32 100644
--- a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
import io.qt.examples.chattutorial 1.0
diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml
index 5c91a206..183d5a32 100644
--- a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
import io.qt.examples.chattutorial 1.0
diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro b/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro
index d62eacc0..75d37ca3 100644
--- a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro
+++ b/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro
@@ -3,7 +3,7 @@ TEMPLATE = app
QT += qml quick sql
CONFIG += c++11
-!contains(sql-drivers, sqlite): QTPLUGIN += qsqlite
+!qtConfig(sql-sqlite): QTPLUGIN += qsqlite
HEADERS += sqlcontactmodel.h \
sqlconversationmodel.h
diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml b/examples/quickcontrols2/chattutorial/chapter4-models/main.qml
index 5bc9e95d..25d50fb7 100644
--- a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml
+++ b/examples/quickcontrols2/chattutorial/chapter4-models/main.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
id: window
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/+material/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5-styling/+material/ChatToolBar.qml
index b0f42969..0557de7f 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/+material/ChatToolBar.qml
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/+material/ChatToolBar.qml
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
ToolBar {
Material.theme: Material.Dark
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml
index e400e029..072ae241 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ToolBar {
}
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml
index b94ef0b3..9afc2d8c 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
import io.qt.examples.chattutorial 1.0
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml
index afe8b572..a217bc0a 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
import io.qt.examples.chattutorial 1.0
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro b/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro
index 2b15b72d..007d23b3 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro
@@ -3,7 +3,7 @@ TEMPLATE = app
QT += qml quick sql
CONFIG += c++11
-!contains(sql-drivers, sqlite): QTPLUGIN += qsqlite
+!qtConfig(sql-sqlite): QTPLUGIN += qsqlite
HEADERS += sqlcontactmodel.h \
sqlconversationmodel.h
diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml b/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml
index 5bc9e95d..25d50fb7 100644
--- a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml
+++ b/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
id: window
diff --git a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
index afdac5a3..5c80587d 100644
--- a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
+++ b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc
@@ -82,7 +82,7 @@ Once we've set up things in C++, we can move on to the user interface in QML.
\quotefromfile chattutorial/chapter1-settingup/main.qml
\skipto import
-\printuntil import QtQuick.Controls 2.0
+\printuntil import QtQuick.Controls 2.1
First, we import the \l {Qt Quick} module. This gives us
access to graphical primitives such as \l Item, \l Rectangle, \l Text, and so
@@ -727,7 +727,7 @@ their text color to something lighter. The simplest way of doing so is to
import the Material style directly and use the Material attached property:
\code
- import QtQuick.Controls.Material 2.0
+ import QtQuick.Controls.Material 2.1
// ...
diff --git a/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml
new file mode 100644
index 00000000..383bb4ec
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 2.1
+
+ItemDelegate {
+ id: delegate
+
+ checkable: true
+
+ contentItem: ColumnLayout {
+ spacing: 10
+
+ Label {
+ text: fullName
+ font.bold: true
+ elide: Text.ElideRight
+ Layout.fillWidth: true
+ }
+
+ GridLayout {
+ id: grid
+ visible: false
+
+ columns: 2
+ rowSpacing: 10
+ columnSpacing: 10
+
+ Label {
+ text: qsTr("Address:")
+ Layout.leftMargin: 60
+ }
+
+ Label {
+ text: address
+ font.bold: true
+ elide: Text.ElideRight
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("City:")
+ Layout.leftMargin: 60
+ }
+
+ Label {
+ text: city
+ font.bold: true
+ elide: Text.ElideRight
+ Layout.fillWidth: true
+ }
+
+ Label {
+ text: qsTr("Number:")
+ Layout.leftMargin: 60
+ }
+
+ Label {
+ text: number
+ font.bold: true
+ elide: Text.ElideRight
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "expanded"
+ when: delegate.checked
+
+ PropertyChanges {
+ target: grid
+ visible: true
+ }
+ }
+ ]
+}
diff --git a/examples/quickcontrols2/contactlist/ContactDialog.qml b/examples/quickcontrols2/contactlist/ContactDialog.qml
new file mode 100644
index 00000000..54256e47
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/ContactDialog.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.1
+
+Dialog {
+ id: dialog
+
+ signal finished(string fullName, string address, string city, string number)
+
+ function createContact() {
+ form.fullName.clear();
+ form.address.clear();
+ form.city.clear();
+ form.number.clear();
+
+ dialog.title = qsTr("Add Contact");
+ dialog.open();
+ }
+
+ function editContact(contact) {
+ form.fullName.text = contact.fullName;
+ form.address.text = contact.address;
+ form.city.text = contact.city;
+ form.number.text = contact.number;
+
+ dialog.title = qsTr("Edit Contact");
+ dialog.open();
+ }
+
+ x: parent.width / 2 - width / 2
+ y: parent.height / 2 - height / 2
+
+ focus: true
+ modal: true
+ title: qsTr("Add Contact")
+ standardButtons: Dialog.Ok | Dialog.Cancel
+
+ contentItem: ContactForm {
+ id: form
+ }
+
+ onAccepted: finished(form.fullName.text, form.address.text, form.city.text, form.number.text)
+}
diff --git a/examples/quickcontrols2/contactlist/ContactForm.ui.qml b/examples/quickcontrols2/contactlist/ContactForm.ui.qml
new file mode 100644
index 00000000..f3397bb0
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/ContactForm.ui.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 2.1
+
+GridLayout {
+ id: grid
+ property alias fullName: fullName
+ property alias address: address
+ property alias city: city
+ property alias number: number
+ property int minimumInputSize: 120
+ property string placeholderText: qsTr("<enter>")
+
+ rows: 4
+ columns: 2
+
+ Label {
+ text: qsTr("Full Name")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ }
+
+ TextField {
+ id: fullName
+ focus: true
+ Layout.fillWidth: true
+ Layout.minimumWidth: grid.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ placeholderText: grid.placeholderText
+ }
+
+ Label {
+ text: qsTr("Address")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ }
+
+ TextField {
+ id: address
+ Layout.fillWidth: true
+ Layout.minimumWidth: grid.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ placeholderText: grid.placeholderText
+ }
+
+ Label {
+ text: qsTr("City")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ }
+
+ TextField {
+ id: city
+ Layout.fillWidth: true
+ Layout.minimumWidth: grid.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ placeholderText: grid.placeholderText
+ }
+
+ Label {
+ text: qsTr("Number")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ }
+
+ TextField {
+ id: number
+ Layout.fillWidth: true
+ Layout.minimumWidth: grid.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ placeholderText: grid.placeholderText
+ }
+}
diff --git a/examples/quickcontrols2/contactlist/ContactView.ui.qml b/examples/quickcontrols2/contactlist/ContactView.ui.qml
new file mode 100644
index 00000000..2aaaa31d
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/ContactView.ui.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.1
+import Backend 1.0
+
+ListView {
+ id: listView
+
+ signal pressAndHold(int index)
+
+ width: 320
+ height: 480
+
+ focus: true
+ boundsBehavior: Flickable.StopAtBounds
+
+ section.property: "fullName"
+ section.criteria: ViewSection.FirstCharacter
+ section.delegate: SectionDelegate {
+ width: listView.width
+ }
+
+ delegate: ContactDelegate {
+ id: delegate
+ width: listView.width
+
+ Connections {
+ target: delegate
+ onPressAndHold: listView.pressAndHold(index)
+ }
+ }
+
+ model: ContactModel {
+ id: contactModel
+ }
+
+ ScrollBar.vertical: ScrollBar { }
+}
diff --git a/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml b/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml
new file mode 100644
index 00000000..fa64ffbf
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/SectionDelegate.ui.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.1
+
+ToolBar {
+ id: background
+
+ Label {
+ id: label
+ text: section
+ anchors.fill: parent
+ horizontalAlignment: Qt.AlignHCenter
+ verticalAlignment: Qt.AlignVCenter
+ }
+}
diff --git a/examples/quickcontrols2/contactlist/contactlist.pro b/examples/quickcontrols2/contactlist/contactlist.pro
new file mode 100644
index 00000000..9025dbde
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/contactlist.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+TARGET = contactlist
+QT += quick
+
+HEADERS += \
+ contactmodel.h
+
+SOURCES += \
+ main.cpp \
+ contactmodel.cpp
+
+RESOURCES += \
+ $$files(*.qml)
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH = $$PWD/designer
+
+OTHER_FILES += \
+ designer/Backend/*.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/contactlist
+INSTALLS += target
diff --git a/examples/quickcontrols2/contactlist/contactlist.qml b/examples/quickcontrols2/contactlist/contactlist.qml
new file mode 100644
index 00000000..13406fbe
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/contactlist.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.1
+
+ApplicationWindow {
+ id: window
+
+ property int currentContact: -1
+
+ width: 320
+ height: 480
+ visible: true
+ title: qsTr("Contact List")
+
+ ContactDialog {
+ id: contactDialog
+ onFinished: {
+ if (currentContact === -1)
+ contactView.model.append(fullName, address, city, number)
+ else
+ contactView.model.set(currentContact, fullName, address, city, number)
+ }
+ }
+
+ Menu {
+ id: contactMenu
+ x: parent.width / 2 - width / 2
+ y: parent.height / 2 - height / 2
+ modal: true
+
+ Label {
+ padding: 10
+ font.bold: true
+ width: parent.width
+ horizontalAlignment: Qt.AlignHCenter
+ text: currentContact >= 0 ? contactView.model.get(currentContact).fullName : ""
+ }
+ MenuItem {
+ text: qsTr("Edit...")
+ onTriggered: contactDialog.editContact(contactView.model.get(currentContact))
+ }
+ MenuItem {
+ text: qsTr("Remove")
+ onTriggered: contactView.model.remove(currentContact)
+ }
+ }
+
+ ContactView {
+ id: contactView
+ anchors.fill: parent
+ onPressAndHold: {
+ currentContact = index
+ contactMenu.open()
+ }
+ }
+
+ RoundButton {
+ text: qsTr("+")
+ highlighted: true
+ anchors.margins: 10
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ onClicked: {
+ currentContact = -1
+ contactDialog.createContact()
+ }
+ }
+}
diff --git a/examples/quickcontrols2/contactlist/contactmodel.cpp b/examples/quickcontrols2/contactlist/contactmodel.cpp
new file mode 100644
index 00000000..308da2da
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/contactmodel.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "contactmodel.h"
+
+ContactModel::ContactModel(QObject *parent ) : QAbstractListModel(parent)
+{
+ m_contacts.append({ "Angel Hogan", "Chapel St. 368 ", "Clearwater" , "0311 1823993" });
+ m_contacts.append({ "Felicia Patton", "Annadale Lane 2", "Knoxville" , "0368 1244494" });
+ m_contacts.append({ "Grant Crawford", "Windsor Drive 34", "Riverdale" , "0351 7826892" });
+ m_contacts.append({ "Gretchen Little", "Sunset Drive 348", "Virginia Beach" , "0343 1234991" });
+ m_contacts.append({ "Geoffrey Richards", "University Lane 54", "Trussville" , "0423 2144944" });
+ m_contacts.append({ "Henrietta Chavez", "Via Volto San Luca 3", "Piobesi Torinese" , "0399 2826994" });
+ m_contacts.append({ "Harvey Chandler", "North Squaw Creek 11", "Madisonville" , "0343 1244492" });
+ m_contacts.append({ "Miguel Gomez", "Wild Rose Street 13", "Trussville" , "0343 9826996" });
+ m_contacts.append({ "Norma Rodriguez", " Glen Eagles Street 53", "Buffalo" , "0241 5826596" });
+ m_contacts.append({ "Shelia Ramirez", "East Miller Ave 68", "Pickerington" , "0346 4844556" });
+ m_contacts.append({ "Stephanie Moss", "Piazza Trieste e Trento 77", "Roata Chiusani" , "0363 0510490" });
+}
+
+int ContactModel::rowCount(const QModelIndex &) const
+{
+ return m_contacts.count();
+}
+
+QVariant ContactModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < rowCount())
+ switch (role) {
+ case FullNameRole: return m_contacts.at(index.row()).fullName;
+ case AddressRole: return m_contacts.at(index.row()).address;
+ case CityRole: return m_contacts.at(index.row()).city;
+ case NumberRole: return m_contacts.at(index.row()).number;
+ default: return QVariant();
+ }
+ return QVariant();
+}
+
+QHash<int, QByteArray> ContactModel::roleNames() const
+{
+ static const QHash<int, QByteArray> roles {
+ { FullNameRole, "fullName" },
+ { AddressRole, "address" },
+ { CityRole, "city" },
+ { NumberRole, "number" }
+ };
+ return roles;
+}
+
+QVariantMap ContactModel::get(int row) const
+{
+ const Contact contact = m_contacts.value(row);
+ return { {"fullName", contact.fullName}, {"address", contact.address}, {"city", contact.city}, {"number", contact.number} };
+}
+
+void ContactModel::append(const QString &fullName, const QString &address, const QString &city, const QString &number)
+{
+ int row = 0;
+ while (row < m_contacts.count() && fullName > m_contacts.at(row).fullName)
+ ++row;
+ beginInsertRows(QModelIndex(), row, row);
+ m_contacts.insert(row, {fullName, address, city, number});
+ endInsertRows();
+}
+
+void ContactModel::set(int row, const QString &fullName, const QString &address, const QString &city, const QString &number)
+{
+ if (row < 0 || row >= m_contacts.count())
+ return;
+
+ m_contacts.replace(row, { fullName, address, city, number });
+ dataChanged(index(row, 0), index(row, 0), { FullNameRole, AddressRole, CityRole, NumberRole });
+}
+
+void ContactModel::remove(int row)
+{
+ if (row < 0 || row >= m_contacts.count())
+ return;
+
+ beginRemoveRows(QModelIndex(), row, row);
+ m_contacts.removeAt(row);
+ endRemoveRows();
+}
diff --git a/examples/quickcontrols2/contactlist/contactmodel.h b/examples/quickcontrols2/contactlist/contactmodel.h
new file mode 100644
index 00000000..d09602c4
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/contactmodel.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTACTMODEL_H
+#define CONTACTMODEL_H
+
+#include <QAbstractListModel>
+
+class ContactModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ enum ContactRole {
+ FullNameRole = Qt::DisplayRole,
+ AddressRole = Qt::UserRole,
+ CityRole,
+ NumberRole
+ };
+ Q_ENUM(ContactRole)
+
+ ContactModel(QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex & = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QHash<int, QByteArray> roleNames() const;
+
+ Q_INVOKABLE QVariantMap get(int row) const;
+ Q_INVOKABLE void append(const QString &fullName, const QString &address, const QString &city, const QString &number);
+ Q_INVOKABLE void set(int row, const QString &fullName, const QString &address, const QString &city, const QString &number);
+ Q_INVOKABLE void remove(int row);
+
+private:
+ struct Contact {
+ QString fullName;
+ QString address;
+ QString city;
+ QString number;
+ };
+
+ QList<Contact> m_contacts;
+};
+
+#endif // CONTACTMODEL_H
diff --git a/examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml b/examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml
new file mode 100644
index 00000000..b9570934
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/designer/Backend/ContactModel.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+
+ListModel {
+ ListElement {
+ address: "Chapel St. 368"
+ city: "Knoxville"
+ number: "0311 1823993"
+ fullName: "Angel Hogan"
+ }
+
+ ListElement {
+ address: "Annadale Lane 2"
+ city: "Clearwater"
+ number: "0368 1244494"
+ fullName: "Felicia Patton"
+ }
+
+ ListElement {
+ address: "Windsor Drive 34"
+ city: "Riverdale"
+ number: "0368 1244494"
+ fullName: "Grant Crawford"
+ }
+
+ ListElement {
+ address: "Sunset Drive 348"
+ city: "Virginia Beach"
+ number: "0351 7826892"
+ fullName: "Gretchen Little"
+ }
+
+ ListElement {
+ address: "University Lane 54"
+ city: "Trussville"
+ number: "0399 2826994"
+ fullName: "Geoffrey Richards"
+ }
+}
diff --git a/examples/quickcontrols2/contactlist/designer/Backend/qmldir b/examples/quickcontrols2/contactlist/designer/Backend/qmldir
new file mode 100644
index 00000000..8e2037d4
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/designer/Backend/qmldir
@@ -0,0 +1,2 @@
+module Backend
+ContactModel 1.0 ContactModel.qml
diff --git a/examples/quickcontrols2/contactlist/doc/images/qtquickcontrols2-contactlist.png b/examples/quickcontrols2/contactlist/doc/images/qtquickcontrols2-contactlist.png
new file mode 100644
index 00000000..d7424ed3
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/doc/images/qtquickcontrols2-contactlist.png
Binary files differ
diff --git a/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc b/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc
new file mode 100644
index 00000000..17e1aec2
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/doc/src/qtquickcontrols2-contactlist.qdoc
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \example contactlist
+ \title Qt Quick Controls 2 - Contact List
+ \ingroup qtquickcontrols2-examples
+ \brief A QML app using Qt Quick Controls 2 and a C++ class that implements
+ a simple contact list.
+
+ The \e {Contact List Example} shows how to integrate a C++ backend in a way that
+ is compatible with Qt Quick Designer.
+ For the declarative parts of the UI, .ui.qml files are used that can be edited
+ visually in the Qt Quick Designer.
+
+ \image qtquickcontrols2-contactlist.png
+
+ \section1 C++ Backend
+
+ The contact list application allows the user to add, edit, and remove contacts.
+ The actual implementation is done in C++ and exposed as a QAbstractListModel.
+
+ The ContactModel C++ class is registered under a namespace and later
+ imported and instantiated by \e MainForm.ui.qml. For more information about registering C++
+ classes as QML types, see \l {Defining QML Types from C++}.
+
+ \code
+ #include <QtQml/qqml.h>
+ ...
+ qmlRegisterType<ContactModel>("Backend", 1, 0, "ContactModel");
+ ...
+ \endcode
+
+ \section1 Designer Support
+
+ In the designer subdirectory, we create a plugin that replaces the ContactModel
+ in Qt Quick Designer. For this to work we add the following line to \e contactlist.pro.
+
+ \code
+ QML_DESIGNER_IMPORT_PATH = $$PWD/designer
+ \endcode
+
+ Because Qt Quick Designer cannot instantiate the ContactModel C++ class, we define
+ a mockup using a ListModel. This ensures that the ListView using the model shows something
+ in Qt Quick Designer.
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/quickcontrols2/contactlist/main.cpp b/examples/quickcontrols2/contactlist/main.cpp
new file mode 100644
index 00000000..ccad6ff3
--- /dev/null
+++ b/examples/quickcontrols2/contactlist/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+#include "contactmodel.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<ContactModel>("Backend", 1, 0, "ContactModel");
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/contactlist.qml")));
+
+ return app.exec();
+}
diff --git a/examples/quickcontrols2/gallery/gallery.pro b/examples/quickcontrols2/gallery/gallery.pro
index cb0736fd..45496a35 100644
--- a/examples/quickcontrols2/gallery/gallery.pro
+++ b/examples/quickcontrols2/gallery/gallery.pro
@@ -5,12 +5,12 @@ QT += quick quickcontrols2
SOURCES += \
gallery.cpp
-OTHER_FILES += \
- gallery.qml \
- pages/*.qml
-
RESOURCES += \
- gallery.qrc
+ gallery.qml \
+ qtquickcontrols2.conf \
+ $$files(images/*.png) \
+ $$files(images/+material/*.png) \
+ $$files(pages/*.qml)
target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/gallery
INSTALLS += target
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml
index aadbcdec..97985a6d 100644
--- a/examples/quickcontrols2/gallery/gallery.qml
+++ b/examples/quickcontrols2/gallery/gallery.qml
@@ -40,9 +40,9 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
import Qt.labs.settings 1.0
ApplicationWindow {
@@ -105,7 +105,7 @@ ApplicationWindow {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
- source: "qrc:/images/menu.png"
+ source: "images/menu.png"
}
onClicked: optionsMenu.open()
@@ -116,7 +116,7 @@ ApplicationWindow {
MenuItem {
text: "Settings"
- onTriggered: settingsPopup.open()
+ onTriggered: settingsDialog.open()
}
MenuItem {
text: "About"
@@ -157,13 +157,11 @@ ApplicationWindow {
ListElement { title: "CheckBox"; source: "qrc:/pages/CheckBoxPage.qml" }
ListElement { title: "ComboBox"; source: "qrc:/pages/ComboBoxPage.qml" }
ListElement { title: "Dial"; source: "qrc:/pages/DialPage.qml" }
+ ListElement { title: "Dialog"; source: "qrc:/pages/DialogPage.qml" }
ListElement { title: "Delegates"; source: "qrc:/pages/DelegatePage.qml" }
- ListElement { title: "Drawer"; source: "qrc:/pages/DrawerPage.qml" }
ListElement { title: "Frame"; source: "qrc:/pages/FramePage.qml" }
ListElement { title: "GroupBox"; source: "qrc:/pages/GroupBoxPage.qml" }
- ListElement { title: "Menu"; source: "qrc:/pages/MenuPage.qml" }
ListElement { title: "PageIndicator"; source: "qrc:/pages/PageIndicatorPage.qml" }
- ListElement { title: "Popup"; source: "qrc:/pages/PopupPage.qml" }
ListElement { title: "ProgressBar"; source: "qrc:/pages/ProgressBarPage.qml" }
ListElement { title: "RadioButton"; source: "qrc:/pages/RadioButtonPage.qml" }
ListElement { title: "RangeSlider"; source: "qrc:/pages/RangeSliderPage.qml" }
@@ -199,7 +197,7 @@ ApplicationWindow {
anchors.centerIn: parent
anchors.verticalCenterOffset: -50
fillMode: Image.PreserveAspectFit
- source: "qrc:/images/qt-logo.png"
+ source: "images/qt-logo.png"
}
Label {
@@ -216,31 +214,36 @@ ApplicationWindow {
Image {
id: arrow
- source: "qrc:/images/arrow.png"
+ source: "images/arrow.png"
anchors.left: parent.left
anchors.bottom: parent.bottom
}
}
}
- Popup {
- id: settingsPopup
- x: (window.width - width) / 2
- y: window.height / 6
- width: Math.min(window.width, window.height) / 3 * 2
- height: settingsColumn.implicitHeight + topPadding + bottomPadding
+ Dialog {
+ id: settingsDialog
+ x: Math.round((window.width - width) / 2)
+ y: Math.round(window.height / 6)
+ width: Math.round(Math.min(window.width, window.height) / 3 * 2)
modal: true
focus: true
+ title: "Settings"
+
+ standardButtons: Dialog.Ok | Dialog.Cancel
+ onAccepted: {
+ settings.style = styleBox.displayText
+ settingsDialog.close()
+ }
+ onRejected: {
+ styleBox.currentIndex = styleBox.styleIndex
+ settingsDialog.close()
+ }
contentItem: ColumnLayout {
id: settingsColumn
spacing: 20
- Label {
- text: "Settings"
- font.bold: true
- }
-
RowLayout {
spacing: 10
@@ -270,48 +273,14 @@ ApplicationWindow {
Layout.fillWidth: true
Layout.fillHeight: true
}
-
- RowLayout {
- spacing: 10
-
- Button {
- id: okButton
- text: "Ok"
- onClicked: {
- settings.style = styleBox.displayText
- settingsPopup.close()
- }
-
- Material.foreground: Material.primary
- Material.background: "transparent"
- Material.elevation: 0
-
- Layout.preferredWidth: 0
- Layout.fillWidth: true
- }
-
- Button {
- id: cancelButton
- text: "Cancel"
- onClicked: {
- styleBox.currentIndex = styleBox.styleIndex
- settingsPopup.close()
- }
-
- Material.background: "transparent"
- Material.elevation: 0
-
- Layout.preferredWidth: 0
- Layout.fillWidth: true
- }
- }
}
}
- Popup {
+ Dialog {
id: aboutDialog
modal: true
focus: true
+ title: "About"
x: (window.width - width) / 2
y: window.height / 6
width: Math.min(window.width, window.height) / 3 * 2
@@ -322,11 +291,6 @@ ApplicationWindow {
spacing: 20
Label {
- text: "About"
- font.bold: true
- }
-
- Label {
width: aboutDialog.availableWidth
text: "The Qt Quick Controls 2 module delivers the next generation user interface controls based on Qt Quick."
wrapMode: Label.Wrap
diff --git a/examples/quickcontrols2/gallery/gallery.qrc b/examples/quickcontrols2/gallery/gallery.qrc
deleted file mode 100644
index 2dc78732..00000000
--- a/examples/quickcontrols2/gallery/gallery.qrc
+++ /dev/null
@@ -1,70 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>gallery.qml</file>
- <file>qtquickcontrols2.conf</file>
- <file>images/arrow.png</file>
- <file>images/arrow@2x.png</file>
- <file>images/arrow@3x.png</file>
- <file>images/arrow@4x.png</file>
- <file>images/arrows.png</file>
- <file>images/arrows@2x.png</file>
- <file>images/arrows@3x.png</file>
- <file>images/arrows@4x.png</file>
- <file>images/back.png</file>
- <file>images/back@2x.png</file>
- <file>images/back@3x.png</file>
- <file>images/back@4x.png</file>
- <file>images/drawer.png</file>
- <file>images/drawer@2x.png</file>
- <file>images/drawer@3x.png</file>
- <file>images/drawer@4x.png</file>
- <file>images/menu.png</file>
- <file>images/menu@2x.png</file>
- <file>images/menu@3x.png</file>
- <file>images/menu@4x.png</file>
- <file>images/+material/back.png</file>
- <file>images/+material/back@2x.png</file>
- <file>images/+material/back@3x.png</file>
- <file>images/+material/back@4x.png</file>
- <file>images/+material/drawer.png</file>
- <file>images/+material/drawer@2x.png</file>
- <file>images/+material/drawer@3x.png</file>
- <file>images/+material/drawer@4x.png</file>
- <file>images/+material/menu.png</file>
- <file>images/+material/menu@2x.png</file>
- <file>images/+material/menu@3x.png</file>
- <file>images/+material/menu@4x.png</file>
- <file>images/qt-logo.png</file>
- <file>images/qt-logo@2x.png</file>
- <file>images/qt-logo@3x.png</file>
- <file>images/qt-logo@4x.png</file>
- <file>pages/BusyIndicatorPage.qml</file>
- <file>pages/ButtonPage.qml</file>
- <file>pages/CheckBoxPage.qml</file>
- <file>pages/ComboBoxPage.qml</file>
- <file>pages/DialPage.qml</file>
- <file>pages/DrawerPage.qml</file>
- <file>pages/FramePage.qml</file>
- <file>pages/GroupBoxPage.qml</file>
- <file>pages/MenuPage.qml</file>
- <file>pages/PageIndicatorPage.qml</file>
- <file>pages/PopupPage.qml</file>
- <file>pages/ProgressBarPage.qml</file>
- <file>pages/RadioButtonPage.qml</file>
- <file>pages/RangeSliderPage.qml</file>
- <file>pages/ScrollablePage.qml</file>
- <file>pages/ScrollBarPage.qml</file>
- <file>pages/ScrollIndicatorPage.qml</file>
- <file>pages/SliderPage.qml</file>
- <file>pages/SpinBoxPage.qml</file>
- <file>pages/StackViewPage.qml</file>
- <file>pages/SwipeViewPage.qml</file>
- <file>pages/SwitchPage.qml</file>
- <file>pages/TabBarPage.qml</file>
- <file>pages/TextAreaPage.qml</file>
- <file>pages/TextFieldPage.qml</file>
- <file>pages/ToolTipPage.qml</file>
- <file>pages/TumblerPage.qml</file>
- <file>pages/DelegatePage.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml b/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml
index 26950555..403da14e 100644
--- a/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml
+++ b/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
@@ -57,9 +57,6 @@ ScrollablePage {
}
BusyIndicator {
- readonly property int size: Math.min(page.availableWidth, page.availableHeight) / 5
- width: size
- height: size
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/ButtonPage.qml b/examples/quickcontrols2/gallery/pages/ButtonPage.qml
index add29e83..39776380 100644
--- a/examples/quickcontrols2/gallery/pages/ButtonPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ButtonPage.qml
@@ -39,13 +39,12 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
- readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, page.availableWidth / 3))
-
Column {
spacing: 40
width: parent.width
@@ -58,24 +57,24 @@ ScrollablePage {
+ "Buttons are normally used to perform an action, or to answer a question."
}
- Column {
+ ColumnLayout {
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
Button {
text: "First"
- width: itemWidth
+ Layout.fillWidth: true
}
Button {
id: button
text: "Second"
- width: itemWidth
highlighted: true
+ Layout.fillWidth: true
}
Button {
text: "Third"
enabled: false
- width: itemWidth
+ Layout.fillWidth: true
}
}
}
diff --git a/examples/quickcontrols2/gallery/pages/CheckBoxPage.qml b/examples/quickcontrols2/gallery/pages/CheckBoxPage.qml
index ee8b14dc..8d48d32d 100644
--- a/examples/quickcontrols2/gallery/pages/CheckBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/CheckBoxPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
index 66fb10dd..a52fcb67 100644
--- a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
@@ -58,7 +58,6 @@ ScrollablePage {
ComboBox {
model: ["First", "Second", "Third"]
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3))
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/DelegatePage.qml b/examples/quickcontrols2/gallery/pages/DelegatePage.qml
index 3d175fd8..525487d1 100644
--- a/examples/quickcontrols2/gallery/pages/DelegatePage.qml
+++ b/examples/quickcontrols2/gallery/pages/DelegatePage.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.1
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Pane {
padding: 0
@@ -70,17 +70,17 @@ Pane {
text: labelText
width: parent.width
- onClicked: if (swipe.complete) view.model.remove(ourIndex)
-
Component {
id: removeComponent
Rectangle {
- color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444"
+ color: SwipeDelegate.pressed ? "#333" : "#444"
width: parent.width
height: parent.height
clip: true
+ SwipeDelegate.onClicked: view.model.remove(ourIndex)
+
Label {
font.pixelSize: swipeDelegate.font.pixelSize
text: "Remove"
diff --git a/examples/quickcontrols2/gallery/pages/DialPage.qml b/examples/quickcontrols2/gallery/pages/DialPage.qml
index 9f07c11e..b60fa032 100644
--- a/examples/quickcontrols2/gallery/pages/DialPage.qml
+++ b/examples/quickcontrols2/gallery/pages/DialPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/DialogPage.qml b/examples/quickcontrols2/gallery/pages/DialogPage.qml
new file mode 100644
index 00000000..e9a051a3
--- /dev/null
+++ b/examples/quickcontrols2/gallery/pages/DialogPage.qml
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 2.1
+
+ScrollablePage {
+ id: page
+
+ readonly property int buttonWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, page.availableWidth / 3))
+
+ Column {
+ spacing: 40
+ width: parent.width
+
+ Label {
+ width: parent.width
+ wrapMode: Label.Wrap
+ horizontalAlignment: Qt.AlignHCenter
+ text: "Dialog is a popup that is mostly used for short-term tasks "
+ + "and brief communications with the user."
+ }
+
+ Button {
+ text: "Message"
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: buttonWidth
+ onClicked: messageDialog.open()
+
+ Dialog {
+ id: messageDialog
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+
+ title: "Message"
+
+ Label {
+ text: "Lorem ipsum dolor sit amet..."
+ }
+ }
+ }
+
+ Button {
+ id: button
+ text: "Confirmation"
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: buttonWidth
+ onClicked: confirmationDialog.open()
+
+ Dialog {
+ id: confirmationDialog
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ parent: ApplicationWindow.overlay
+
+ modal: true
+ title: "Confirmation"
+ standardButtons: Dialog.Yes | Dialog.No
+
+ Column {
+ spacing: 20
+ anchors.fill: parent
+ Label {
+ text: "The document has been modified.\nDo you want to save your changes?"
+ }
+ CheckBox {
+ text: "Do not ask again"
+ anchors.right: parent.right
+ }
+ }
+ }
+ }
+
+ Button {
+ text: "Content"
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: buttonWidth
+ onClicked: contentDialog.open()
+
+ Dialog {
+ id: contentDialog
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: Math.min(page.width, page.height) / 3 * 2
+ contentHeight: logo.height * 2
+ parent: ApplicationWindow.overlay
+
+ modal: true
+ title: "Content"
+ standardButtons: Dialog.Close
+
+ Flickable {
+ id: flickable
+ clip: true
+ anchors.fill: parent
+ contentHeight: column.height
+
+ Column {
+ id: column
+ spacing: 20
+ width: parent.width
+
+ Image {
+ id: logo
+ width: parent.width / 2
+ anchors.horizontalCenter: parent.horizontalCenter
+ fillMode: Image.PreserveAspectFit
+ source: "../images/qt-logo.png"
+ }
+
+ Label {
+ width: parent.width
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc finibus "
+ + "in est quis laoreet. Interdum et malesuada fames ac ante ipsum primis "
+ + "in faucibus. Curabitur eget justo sollicitudin enim faucibus bibendum. "
+ + "Suspendisse potenti. Vestibulum cursus consequat mauris id sollicitudin. "
+ + "Duis facilisis hendrerit consectetur. Curabitur sapien tortor, efficitur "
+ + "id auctor nec, efficitur et nisl. Ut venenatis eros in nunc placerat, "
+ + "eu aliquam enim suscipit."
+ wrapMode: Label.Wrap
+ }
+ }
+
+ ScrollIndicator.vertical: ScrollIndicator {
+ parent: contentDialog.contentItem
+ anchors.top: flickable.top
+ anchors.bottom: flickable.bottom
+ anchors.right: parent.right
+ anchors.rightMargin: -contentDialog.rightPadding + 1
+ }
+ }
+ }
+ }
+
+ Button {
+ text: "Input"
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: buttonWidth
+ onClicked: inputDialog.open()
+
+ Dialog {
+ id: inputDialog
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ parent: ApplicationWindow.overlay
+
+ focus: true
+ modal: true
+ title: "Input"
+ standardButtons: Dialog.Ok | Dialog.Cancel
+
+ ColumnLayout {
+ spacing: 20
+ anchors.fill: parent
+ Label {
+ elide: Label.ElideRight
+ text: "Please enter the credentials:"
+ Layout.fillWidth: true
+ }
+ TextField {
+ focus: true
+ placeholderText: "Username"
+ Layout.fillWidth: true
+ }
+ TextField {
+ placeholderText: "Password"
+ echoMode: TextField.PasswordEchoOnEdit
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols2/gallery/pages/FramePage.qml b/examples/quickcontrols2/gallery/pages/FramePage.qml
index 51b640c1..b2d24dff 100644
--- a/examples/quickcontrols2/gallery/pages/FramePage.qml
+++ b/examples/quickcontrols2/gallery/pages/FramePage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml b/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
index b0db5374..c4ceb45d 100644
--- a/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/PageIndicatorPage.qml b/examples/quickcontrols2/gallery/pages/PageIndicatorPage.qml
index e7f7e251..43982b43 100644
--- a/examples/quickcontrols2/gallery/pages/PageIndicatorPage.qml
+++ b/examples/quickcontrols2/gallery/pages/PageIndicatorPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml b/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml
index 92f26dd0..a2646fd0 100644
--- a/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml
@@ -39,13 +39,11 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
- readonly property int itemWidth: Math.max(bar.implicitWidth, page.availableWidth / 3)
-
Column {
spacing: 40
width: parent.width
@@ -61,13 +59,11 @@ ScrollablePage {
ProgressBar {
id: bar
value: 0.5
- width: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
ProgressBar {
indeterminate: true
- width: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/RadioButtonPage.qml b/examples/quickcontrols2/gallery/pages/RadioButtonPage.qml
index 0cc1f0bd..452d0425 100644
--- a/examples/quickcontrols2/gallery/pages/RadioButtonPage.qml
+++ b/examples/quickcontrols2/gallery/pages/RadioButtonPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml b/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml
index 62cbeb88..629a788b 100644
--- a/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml
+++ b/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml
@@ -39,13 +39,11 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
- readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3))
-
Column {
spacing: 40
width: parent.width
@@ -61,7 +59,6 @@ ScrollablePage {
id: slider
first.value: 0.25
second.value: 0.75
- width: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
@@ -69,7 +66,6 @@ ScrollablePage {
orientation: Qt.Vertical
first.value: 0.25
second.value: 0.75
- height: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/ScrollBarPage.qml b/examples/quickcontrols2/gallery/pages/ScrollBarPage.qml
index f8f617d7..17be84e6 100644
--- a/examples/quickcontrols2/gallery/pages/ScrollBarPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ScrollBarPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Flickable {
id: flickable
@@ -67,7 +67,7 @@ Flickable {
Image {
rotation: 90
- source: "qrc:/images/arrows.png"
+ source: "../images/arrows.png"
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/ScrollIndicatorPage.qml b/examples/quickcontrols2/gallery/pages/ScrollIndicatorPage.qml
index d76d2de3..f7c23a06 100644
--- a/examples/quickcontrols2/gallery/pages/ScrollIndicatorPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ScrollIndicatorPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Flickable {
id: flickable
@@ -67,7 +67,7 @@ Flickable {
Image {
rotation: 90
- source: "qrc:/images/arrows.png"
+ source: "../images/arrows.png"
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/SliderPage.qml b/examples/quickcontrols2/gallery/pages/SliderPage.qml
index d9853c22..83ae32ef 100644
--- a/examples/quickcontrols2/gallery/pages/SliderPage.qml
+++ b/examples/quickcontrols2/gallery/pages/SliderPage.qml
@@ -39,13 +39,11 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
- readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3))
-
Column {
spacing: 40
width: parent.width
@@ -60,14 +58,12 @@ ScrollablePage {
Slider {
id: slider
value: 0.5
- width: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
Slider {
orientation: Qt.Vertical
value: 0.5
- height: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml
index 2b3664cf..93adc01a 100644
--- a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml
@@ -39,13 +39,11 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
- readonly property int itemWidth: Math.max(box.implicitWidth, Math.min(box.implicitWidth * 2, pane.availableWidth / 3))
-
Column {
spacing: 40
width: parent.width
@@ -61,7 +59,6 @@ ScrollablePage {
SpinBox {
id: box
value: 50
- width: itemWidth
anchors.horizontalCenter: parent.horizontalCenter
editable: true
}
diff --git a/examples/quickcontrols2/gallery/pages/StackViewPage.qml b/examples/quickcontrols2/gallery/pages/StackViewPage.qml
index 4e44c3c8..d99a4b93 100644
--- a/examples/quickcontrols2/gallery/pages/StackViewPage.qml
+++ b/examples/quickcontrols2/gallery/pages/StackViewPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
StackView {
id: stackView
diff --git a/examples/quickcontrols2/gallery/pages/SwipeViewPage.qml b/examples/quickcontrols2/gallery/pages/SwipeViewPage.qml
index d0b0486c..dedacac4 100644
--- a/examples/quickcontrols2/gallery/pages/SwipeViewPage.qml
+++ b/examples/quickcontrols2/gallery/pages/SwipeViewPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Pane {
id: pane
@@ -69,7 +69,7 @@ Pane {
}
Image {
- source: "qrc:/images/arrows.png"
+ source: "../images/arrows.png"
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/SwitchPage.qml b/examples/quickcontrols2/gallery/pages/SwitchPage.qml
index 1315268d..ccaa4e1e 100644
--- a/examples/quickcontrols2/gallery/pages/SwitchPage.qml
+++ b/examples/quickcontrols2/gallery/pages/SwitchPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/TabBarPage.qml b/examples/quickcontrols2/gallery/pages/TabBarPage.qml
index 1b5bdb9b..818cccef 100644
--- a/examples/quickcontrols2/gallery/pages/TabBarPage.qml
+++ b/examples/quickcontrols2/gallery/pages/TabBarPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Page {
id: page
@@ -69,7 +69,7 @@ Page {
}
Image {
- source: "qrc:/images/arrows.png"
+ source: "../images/arrows.png"
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/TextAreaPage.qml b/examples/quickcontrols2/gallery/pages/TextAreaPage.qml
index ca28e2b7..97669f2f 100644
--- a/examples/quickcontrols2/gallery/pages/TextAreaPage.qml
+++ b/examples/quickcontrols2/gallery/pages/TextAreaPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
diff --git a/examples/quickcontrols2/gallery/pages/TextFieldPage.qml b/examples/quickcontrols2/gallery/pages/TextFieldPage.qml
index 9092e10d..1b22fd08 100644
--- a/examples/quickcontrols2/gallery/pages/TextFieldPage.qml
+++ b/examples/quickcontrols2/gallery/pages/TextFieldPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
@@ -58,7 +58,6 @@ ScrollablePage {
TextField {
id: field
placeholderText: "TextField"
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3))
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/pages/ToolTipPage.qml b/examples/quickcontrols2/gallery/pages/ToolTipPage.qml
index e0f769eb..d9bc969d 100644
--- a/examples/quickcontrols2/gallery/pages/ToolTipPage.qml
+++ b/examples/quickcontrols2/gallery/pages/ToolTipPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
@@ -58,7 +58,6 @@ ScrollablePage {
Button {
text: "Tip"
anchors.horizontalCenter: parent.horizontalCenter
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3))
ToolTip.timeout: 5000
ToolTip.visible: pressed
diff --git a/examples/quickcontrols2/gallery/pages/TumblerPage.qml b/examples/quickcontrols2/gallery/pages/TumblerPage.qml
index d12cc999..3b290dcb 100644
--- a/examples/quickcontrols2/gallery/pages/TumblerPage.qml
+++ b/examples/quickcontrols2/gallery/pages/TumblerPage.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollablePage {
id: page
@@ -57,7 +57,6 @@ ScrollablePage {
Tumbler {
model: 10
- visibleItemCount: 5
anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/quickcontrols2/gallery/qtquickcontrols2.conf b/examples/quickcontrols2/gallery/qtquickcontrols2.conf
index ce348f2e..da1a8f41 100644
--- a/examples/quickcontrols2/gallery/qtquickcontrols2.conf
+++ b/examples/quickcontrols2/gallery/qtquickcontrols2.conf
@@ -1,8 +1,8 @@
[Material]
Primary=#41cd52
Accent=#41cd52
-Theme=Light
+Theme=System
[Universal]
Accent=#41cd52
-Theme=Light
+Theme=System
diff --git a/examples/quickcontrols2/quickcontrols2.pro b/examples/quickcontrols2/quickcontrols2.pro
index 4f0f2fcc..458d10db 100644
--- a/examples/quickcontrols2/quickcontrols2.pro
+++ b/examples/quickcontrols2/quickcontrols2.pro
@@ -1,4 +1,6 @@
TEMPLATE = subdirs
SUBDIRS += \
gallery \
- chattutorial
+ chattutorial \
+ texteditor \
+ contactlist
diff --git a/examples/quickcontrols2/texteditor/+touch/texteditor.html b/examples/quickcontrols2/texteditor/+touch/texteditor.html
new file mode 100644
index 00000000..b5f03f25
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/+touch/texteditor.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="qrichtext" content="1">
+ <title>Text Editor Example</title>
+</head>
+<body>
+<body>
+ <p align="center">
+ <img src="qrc:/images/qt-logo.png" />
+ </p>
+ <h2 align="center">
+ Qt Quick Controls 2
+ </h2>
+ <p align="center">
+ This example demonstrates a modern rich text editor.
+ </p>
+</body>
+</html>
diff --git a/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-desktop.jpg b/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-desktop.jpg
new file mode 100644
index 00000000..259e0e8b
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-desktop.jpg
Binary files differ
diff --git a/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-touch.jpg b/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-touch.jpg
new file mode 100644
index 00000000..6a924cdf
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/doc/images/qtquickcontrols2-texteditor-touch.jpg
Binary files differ
diff --git a/examples/quickcontrols2/texteditor/doc/src/qtquickcontrols2-texteditor.qdoc b/examples/quickcontrols2/texteditor/doc/src/qtquickcontrols2-texteditor.qdoc
new file mode 100644
index 00000000..1fee54ce
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/doc/src/qtquickcontrols2-texteditor.qdoc
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \example texteditor
+ \title Qt Quick Controls 2 - Text Editor
+ \ingroup qtquickcontrols2-examples
+ \brief A QML app using Qt Quick Controls 2 and a C++ class to
+ provide a fully-functional rich-text editor application.
+
+ The \e {Text Editor Example} presents a sample HTML file using the TextArea
+ control, preserving the HTML formatting. The application comes with two user
+ interfaces; one for traditional desktop platforms with a mouse pointer, and
+ another simpler, touch-oriented version.
+
+ \section1 Desktop User Interface
+
+ \image qtquickcontrols2-texteditor-desktop.jpg
+
+ The desktop version is a complete text editor with capabilities for formatting
+ text, and opening and saving HTML and plain text files. It demonstrates the
+ native-looking dialogs and menus using the \l{Qt Labs Platform} module. These
+ types are mostly suitable for desktop platforms with support for multiple
+ top-level windows, a mouse pointer, and moderate screen size.
+
+ The desktop UI uses FileDialog for opening and saving files:
+
+ \quotefromfile texteditor/qml/texteditor.qml
+ \skipto FileDialog
+ \printuntil /\bsaveAs\b/
+ \printline }
+
+ It uses FontDialog and ColorDialog for choosing fonts and colors:
+
+ \skipto FontDialog
+ \printuntil /.*colorDialog$/
+ \printuntil /^\s{4}\}$/
+
+ It also uses \l[QML QtLabsPlatform]{Menu} and
+ \l[QML QtLabsPlatform]{MenuItem} that provide a context menu to format text
+ within:
+
+ \skipto /\bMenu\b/
+ \printuntil /^\s{4}\}$/
+
+ \note There is also a standard menubar with more options than the
+ context menu.
+
+ \section1 Touch User Interface
+
+ \image qtquickcontrols2-texteditor-touch.jpg
+
+ The touch user interface is a simplified version of the text editor. It is
+ suitable for touch devices with limited screen size. The example uses
+ \l{Using File Selectors with Qt Quick Controls 2}{file selectors} to load
+ the appropriate user interface automatically.
+
+ Unlike the desktop version, which uses top-level dialogs, the touch version
+ uses the QML \l Dialog type, which is not a top-level window. This type of
+ dialog is fully supported on mobile and embedded platforms that do not support
+ multiple top-level windows.
+
+ \quotefromfile texteditor/qml/+touch/texteditor.qml
+ \skipto /\bDialog\b/
+ \printuntil /^\s{4}\}$/
+
+ \section1 C++ Backend
+
+ Both user interfaces use the same C++ backend, which supports opening, formatting,
+ and editing a document. The C++ class, \c DocumentHandler, extends QObject and is
+ registered as a QML type under the namespace \c {io.qt.examples.texteditor 1.0}.
+
+ The following snippets show how the type is registered under a namespace and later
+ imported and instantiated by \e main.qml. For more information about registering C++
+ classes as QML types, see \l {Defining QML Types from C++}.
+
+ QML type registration:
+
+ \code
+ #include <QtQml/qqml.h>
+ ...
+ qmlRegisterType<DocumentHandler>("io.qt.examples.texteditor", 1, 0, "DocumentHandler");
+ ...
+ \endcode
+
+ QML namespace import:
+
+ \code
+ import io.qt.examples.texteditor 1.0
+ \endcode
+
+ QML instance:
+
+ \quotefromfile texteditor/qml/texteditor.qml
+ \skipto DocumentHandler
+ \printuntil /^\s{4}\}$/
+
+ \include examples-run.qdocinc
+*/
diff --git a/examples/quickcontrols2/texteditor/documenthandler.cpp b/examples/quickcontrols2/texteditor/documenthandler.cpp
new file mode 100644
index 00000000..e57946fd
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/documenthandler.cpp
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "documenthandler.h"
+
+#include <QFile>
+#include <QFileInfo>
+#include <QFileSelector>
+#include <QQmlFile>
+#include <QQmlFileSelector>
+#include <QQuickTextDocument>
+#include <QTextCharFormat>
+#include <QTextCodec>
+#include <QTextDocument>
+
+DocumentHandler::DocumentHandler(QObject *parent)
+ : QObject(parent)
+ , m_document(nullptr)
+ , m_cursorPosition(-1)
+ , m_selectionStart(0)
+ , m_selectionEnd(0)
+{
+}
+
+QQuickTextDocument *DocumentHandler::document() const
+{
+ return m_document;
+}
+
+void DocumentHandler::setDocument(QQuickTextDocument *document)
+{
+ if (document == m_document)
+ return;
+
+ m_document = document;
+ emit documentChanged();
+}
+
+int DocumentHandler::cursorPosition() const
+{
+ return m_cursorPosition;
+}
+
+void DocumentHandler::setCursorPosition(int position)
+{
+ if (position == m_cursorPosition)
+ return;
+
+ m_cursorPosition = position;
+ reset();
+ emit cursorPositionChanged();
+}
+
+int DocumentHandler::selectionStart() const
+{
+ return m_selectionStart;
+}
+
+void DocumentHandler::setSelectionStart(int position)
+{
+ if (position == m_selectionStart)
+ return;
+
+ m_selectionStart = position;
+ emit selectionStartChanged();
+}
+
+int DocumentHandler::selectionEnd() const
+{
+ return m_selectionEnd;
+}
+
+void DocumentHandler::setSelectionEnd(int position)
+{
+ if (position == m_selectionEnd)
+ return;
+
+ m_selectionEnd = position;
+ emit selectionEndChanged();
+}
+
+QString DocumentHandler::fontFamily() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return QString();
+ QTextCharFormat format = cursor.charFormat();
+ return format.font().family();
+}
+
+void DocumentHandler::setFontFamily(const QString &family)
+{
+ QTextCharFormat format;
+ format.setFontFamily(family);
+ mergeFormatOnWordOrSelection(format);
+ emit fontFamilyChanged();
+}
+
+QColor DocumentHandler::textColor() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return QColor(Qt::black);
+ QTextCharFormat format = cursor.charFormat();
+ return format.foreground().color();
+}
+
+void DocumentHandler::setTextColor(const QColor &color)
+{
+ QTextCharFormat format;
+ format.setForeground(QBrush(color));
+ mergeFormatOnWordOrSelection(format);
+ emit textColorChanged();
+}
+
+Qt::Alignment DocumentHandler::alignment() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return Qt::AlignLeft;
+ return textCursor().blockFormat().alignment();
+}
+
+void DocumentHandler::setAlignment(Qt::Alignment alignment)
+{
+ QTextBlockFormat format;
+ format.setAlignment(alignment);
+ QTextCursor cursor = textCursor();
+ cursor.mergeBlockFormat(format);
+ emit alignmentChanged();
+}
+
+bool DocumentHandler::bold() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return false;
+ return textCursor().charFormat().fontWeight() == QFont::Bold;
+}
+
+void DocumentHandler::setBold(bool bold)
+{
+ QTextCharFormat format;
+ format.setFontWeight(bold ? QFont::Bold : QFont::Normal);
+ mergeFormatOnWordOrSelection(format);
+ emit boldChanged();
+}
+
+bool DocumentHandler::italic() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return false;
+ return textCursor().charFormat().fontItalic();
+}
+
+void DocumentHandler::setItalic(bool italic)
+{
+ QTextCharFormat format;
+ format.setFontItalic(italic);
+ mergeFormatOnWordOrSelection(format);
+ emit italicChanged();
+}
+
+bool DocumentHandler::underline() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return false;
+ return textCursor().charFormat().fontUnderline();
+}
+
+void DocumentHandler::setUnderline(bool underline)
+{
+ QTextCharFormat format;
+ format.setFontUnderline(underline);
+ mergeFormatOnWordOrSelection(format);
+ emit underlineChanged();
+}
+
+int DocumentHandler::fontSize() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return 0;
+ QTextCharFormat format = cursor.charFormat();
+ return format.font().pointSize();
+}
+
+void DocumentHandler::setFontSize(int size)
+{
+ if (size <= 0)
+ return;
+
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return;
+
+ if (!cursor.hasSelection())
+ cursor.select(QTextCursor::WordUnderCursor);
+
+ if (cursor.charFormat().property(QTextFormat::FontPointSize).toInt() == size)
+ return;
+
+ QTextCharFormat format;
+ format.setFontPointSize(size);
+ mergeFormatOnWordOrSelection(format);
+ emit fontSizeChanged();
+}
+
+QString DocumentHandler::fileName() const
+{
+ const QString filePath = QQmlFile::urlToLocalFileOrQrc(m_fileUrl);
+ const QString fileName = QFileInfo(filePath).fileName();
+ if (fileName.isEmpty())
+ return QStringLiteral("untitled.txt");
+ return fileName;
+}
+
+QString DocumentHandler::fileType() const
+{
+ return QFileInfo(fileName()).suffix();
+}
+
+QUrl DocumentHandler::fileUrl() const
+{
+ return m_fileUrl;
+}
+
+void DocumentHandler::load(const QUrl &fileUrl)
+{
+ if (fileUrl == m_fileUrl)
+ return;
+
+ QQmlEngine *engine = qmlEngine(this);
+ if (!engine) {
+ qWarning() << "load() called before DocumentHandler has QQmlEngine";
+ return;
+ }
+
+ const QUrl path = QQmlFileSelector::get(engine)->selector()->select(fileUrl);
+ const QString fileName = QQmlFile::urlToLocalFileOrQrc(path);
+ if (QFile::exists(fileName)) {
+ QFile file(fileName);
+ if (file.open(QFile::ReadOnly)) {
+ QByteArray data = file.readAll();
+ QTextCodec *codec = QTextCodec::codecForHtml(data);
+ if (QTextDocument *doc = textDocument())
+ doc->setModified(false);
+
+ emit loaded(codec->toUnicode(data));
+ reset();
+ }
+ }
+
+ m_fileUrl = fileUrl;
+ emit fileUrlChanged();
+}
+
+void DocumentHandler::saveAs(const QUrl &fileUrl)
+{
+ QTextDocument *doc = textDocument();
+ if (!doc)
+ return;
+
+ const QString filePath = fileUrl.toLocalFile();
+ const bool isHtml = QFileInfo(filePath).suffix().contains(QLatin1String("htm"));
+ QFile file(filePath);
+ if (!file.open(QFile::WriteOnly | QFile::Truncate | (isHtml ? QFile::NotOpen : QFile::Text))) {
+ emit error(tr("Cannot save: ") + file.errorString());
+ return;
+ }
+ file.write((isHtml ? doc->toHtml() : doc->toPlainText()).toUtf8());
+ file.close();
+
+ if (fileUrl == m_fileUrl)
+ return;
+
+ m_fileUrl = fileUrl;
+ emit fileUrlChanged();
+}
+
+void DocumentHandler::reset()
+{
+ emit fontFamilyChanged();
+ emit alignmentChanged();
+ emit boldChanged();
+ emit italicChanged();
+ emit underlineChanged();
+ emit fontSizeChanged();
+ emit textColorChanged();
+}
+
+QTextCursor DocumentHandler::textCursor() const
+{
+ QTextDocument *doc = textDocument();
+ if (!doc)
+ return QTextCursor();
+
+ QTextCursor cursor = QTextCursor(doc);
+ if (m_selectionStart != m_selectionEnd) {
+ cursor.setPosition(m_selectionStart);
+ cursor.setPosition(m_selectionEnd, QTextCursor::KeepAnchor);
+ } else {
+ cursor.setPosition(m_cursorPosition);
+ }
+ return cursor;
+}
+
+QTextDocument *DocumentHandler::textDocument() const
+{
+ if (!m_document)
+ return nullptr;
+
+ return m_document->textDocument();
+}
+
+void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
+{
+ QTextCursor cursor = textCursor();
+ if (!cursor.hasSelection())
+ cursor.select(QTextCursor::WordUnderCursor);
+ cursor.mergeCharFormat(format);
+}
diff --git a/examples/quickcontrols2/texteditor/documenthandler.h b/examples/quickcontrols2/texteditor/documenthandler.h
new file mode 100644
index 00000000..dd3c3988
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/documenthandler.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOCUMENTHANDLER_H
+#define DOCUMENTHANDLER_H
+
+#include <QFont>
+#include <QObject>
+#include <QTextCursor>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+class QQuickTextDocument;
+QT_END_NAMESPACE
+
+class DocumentHandler : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QQuickTextDocument *document READ document WRITE setDocument NOTIFY documentChanged)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
+
+ Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
+ Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+
+ Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
+
+ Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
+
+ Q_PROPERTY(QString fileName READ fileName NOTIFY fileUrlChanged)
+ Q_PROPERTY(QString fileType READ fileType NOTIFY fileUrlChanged)
+ Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY fileUrlChanged)
+
+public:
+ explicit DocumentHandler(QObject *parent = nullptr);
+
+ QQuickTextDocument *document() const;
+ void setDocument(QQuickTextDocument *document);
+
+ int cursorPosition() const;
+ void setCursorPosition(int position);
+
+ int selectionStart() const;
+ void setSelectionStart(int position);
+
+ int selectionEnd() const;
+ void setSelectionEnd(int position);
+
+ QString fontFamily() const;
+ void setFontFamily(const QString &family);
+
+ QColor textColor() const;
+ void setTextColor(const QColor &color);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment alignment);
+
+ bool bold() const;
+ void setBold(bool bold);
+
+ bool italic() const;
+ void setItalic(bool italic);
+
+ bool underline() const;
+ void setUnderline(bool underline);
+
+ int fontSize() const;
+ void setFontSize(int size);
+
+ QString fileName() const;
+ QString fileType() const;
+ QUrl fileUrl() const;
+
+public Q_SLOTS:
+ void load(const QUrl &fileUrl);
+ void saveAs(const QUrl &fileUrl);
+
+Q_SIGNALS:
+ void documentChanged();
+ void cursorPositionChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
+
+ void fontFamilyChanged();
+ void textColorChanged();
+ void alignmentChanged();
+
+ void boldChanged();
+ void italicChanged();
+ void underlineChanged();
+
+ void fontSizeChanged();
+
+ void textChanged();
+ void fileUrlChanged();
+
+ void loaded(const QString &text);
+ void error(const QString &message);
+
+private:
+ void reset();
+ QTextCursor textCursor() const;
+ QTextDocument *textDocument() const;
+ void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
+
+ QQuickTextDocument *m_document;
+
+ int m_cursorPosition;
+ int m_selectionStart;
+ int m_selectionEnd;
+
+ QFont m_font;
+ int m_fontSize;
+ QUrl m_fileUrl;
+};
+
+#endif // DOCUMENTHANDLER_H
diff --git a/examples/quickcontrols2/texteditor/fonts/fontello.ttf b/examples/quickcontrols2/texteditor/fonts/fontello.ttf
new file mode 100644
index 00000000..db957652
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/fonts/fontello.ttf
Binary files differ
diff --git a/examples/quickcontrols2/texteditor/images/qt-logo.png b/examples/quickcontrols2/texteditor/images/qt-logo.png
new file mode 100644
index 00000000..e16b4182
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/images/qt-logo.png
Binary files differ
diff --git a/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
new file mode 100644
index 00000000..11d153f5
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/qml/+touch/texteditor.qml
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Layouts 1.3
+import QtQuick.Window 2.0
+
+import io.qt.examples.texteditor 1.0
+
+// TODO:
+// - make designer-friendly
+
+ApplicationWindow {
+ id: window
+ visible: true
+ title: document.fileName + " - Text Editor Example"
+
+ header: ToolBar {
+ leftPadding: 5
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+
+ ToolButton {
+ id: doneEditingButton
+ font.family: "fontello"
+ text: "\uE80A" // icon-ok
+ opacity: !textArea.readOnly ? 1 : 0
+ onClicked: textArea.readOnly = true
+
+ Material.foreground: Material.accent
+ }
+
+ Label {
+ text: qsTr("Text Editor Example")
+ font.bold: true
+ font.pixelSize: 20
+ elide: Label.ElideRight
+ Layout.fillWidth: true
+ }
+
+ ToolButton {
+ font.family: "fontello"
+ text: "\uF142" // icon-ellipsis-vert
+ onClicked: menu.open()
+
+ Menu {
+ id: menu
+
+ MenuItem {
+ text: qsTr("About")
+ onTriggered: aboutDialog.open()
+ }
+ }
+ }
+ }
+ }
+
+ DocumentHandler {
+ id: document
+ document: textArea.textDocument
+ cursorPosition: textArea.cursorPosition
+ selectionStart: textArea.selectionStart
+ selectionEnd: textArea.selectionEnd
+ // textColor: TODO
+ Component.onCompleted: document.load("qrc:/texteditor.html")
+ onLoaded: {
+ textArea.text = text
+ }
+ onError: {
+ errorDialog.text = message
+ errorDialog.visible = true
+ }
+ }
+
+ Flickable {
+ id: flickable
+ flickableDirection: Flickable.VerticalFlick
+ anchors.fill: parent
+
+ TextArea.flickable: TextArea {
+ id: textArea
+ textFormat: Qt.RichText
+ wrapMode: TextArea.Wrap
+ readOnly: true
+ persistentSelection: true
+ // Different styles have different padding and background
+ // decorations, but since this editor is almost taking up the
+ // entire window, we don't need them.
+ leftPadding: 6
+ rightPadding: 6
+ topPadding: 0
+ bottomPadding: 0
+ background: null
+
+ onLinkActivated: Qt.openUrlExternally(link)
+ }
+
+ ScrollBar.vertical: ScrollBar {}
+ }
+
+ footer: ToolBar {
+ visible: !textArea.readOnly && textArea.activeFocus
+
+ Material.primary: "#E0E0E0"
+ Material.elevation: 0
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: toolRow.implicitWidth
+ flickableDirection: Qt.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+
+ Row {
+ id: toolRow
+
+ ToolButton {
+ id: boldButton
+ text: "\uE800" // icon-bold
+ font.family: "fontello"
+ // Don't want to close the virtual keyboard when this is clicked.
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.bold
+ onClicked: document.bold = !document.bold
+ }
+ ToolButton {
+ id: italicButton
+ text: "\uE801" // icon-italic
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.italic
+ onClicked: document.italic = !document.italic
+ }
+ ToolButton {
+ id: underlineButton
+ text: "\uF0CD" // icon-underline
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.underline
+ onClicked: document.underline = !document.underline
+ }
+
+ ToolSeparator {}
+
+ ToolButton {
+ id: alignLeftButton
+ text: "\uE803" // icon-align-left
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignLeft
+ onClicked: document.alignment = Qt.AlignLeft
+ }
+ ToolButton {
+ id: alignCenterButton
+ text: "\uE804" // icon-align-center
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignHCenter
+ onClicked: document.alignment = Qt.AlignHCenter
+ }
+ ToolButton {
+ id: alignRightButton
+ text: "\uE805" // icon-align-right
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignRight
+ onClicked: document.alignment = Qt.AlignRight
+ }
+ ToolButton {
+ id: alignJustifyButton
+ text: "\uE806" // icon-align-justify
+ font.family: "fontello"
+ focusPolicy: Qt.NoFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignJustify
+ onClicked: document.alignment = Qt.AlignJustify
+ }
+ }
+ }
+ }
+
+ RoundButton {
+ id: editButton
+ font.family: "fontello"
+ text: "\uE809" // icon-pencil
+ width: 48
+ height: width
+ // Don't want to use anchors for the y position, because it will anchor
+ // to the footer, leaving a large vertical gap.
+ y: parent.height - height - 12
+ anchors.right: parent.right
+ anchors.margins: 12
+ visible: textArea.readOnly
+ highlighted: true
+
+ onClicked: {
+ textArea.readOnly = false
+ // Force focus on the text area so the cursor and footer show up.
+ textArea.forceActiveFocus()
+ }
+ }
+
+ Dialog {
+ id: aboutDialog
+ standardButtons: Dialog.Ok
+ modal: true
+ x: parent.width / 2 - width / 2
+ y: parent.height / 2 - height / 2
+
+ contentItem: Label {
+ text: qsTr("Qt Quick Controls 2 - Text Editor Example")
+ }
+ }
+}
diff --git a/examples/quickcontrols2/texteditor/qml/texteditor.qml b/examples/quickcontrols2/texteditor/qml/texteditor.qml
new file mode 100644
index 00000000..2247e8f1
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/qml/texteditor.qml
@@ -0,0 +1,442 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Window 2.0
+import Qt.labs.platform 1.0
+
+import io.qt.examples.texteditor 1.0
+
+// TODO:
+// - make designer-friendly
+
+ApplicationWindow {
+ id: window
+ width: 1024
+ height: 600
+ visible: true
+ title: document.fileName + " - Text Editor Example"
+
+ Component.onCompleted: {
+ x = Screen.width / 2 - width / 2
+ y = Screen.height / 2 - height / 2
+ }
+
+ Shortcut {
+ sequence: StandardKey.Open
+ onActivated: openDialog.open()
+ }
+ Shortcut {
+ sequence: StandardKey.SaveAs
+ onActivated: saveDialog.open()
+ }
+ Shortcut {
+ sequence: StandardKey.Quit
+ onActivated: Qt.quit()
+ }
+ Shortcut {
+ sequence: StandardKey.Copy
+ onActivated: textArea.copy()
+ }
+ Shortcut {
+ sequence: StandardKey.Cut
+ onActivated: textArea.cut()
+ }
+ Shortcut {
+ sequence: StandardKey.Paste
+ onActivated: textArea.paste()
+ }
+ Shortcut {
+ sequence: StandardKey.Bold
+ onActivated: document.bold = !document.bold
+ }
+ Shortcut {
+ sequence: StandardKey.Italic
+ onActivated: document.italic = !document.italic
+ }
+ Shortcut {
+ sequence: StandardKey.Underline
+ onActivated: document.underline = !document.underline
+ }
+
+ MenuBar {
+ Menu {
+ title: qsTr("&File")
+
+ MenuItem {
+ text: qsTr("&Open")
+ onTriggered: openDialog.open()
+ }
+ MenuItem {
+ text: qsTr("&Save As...")
+ onTriggered: saveDialog.open()
+ }
+ MenuItem {
+ text: qsTr("&Quit")
+ onTriggered: Qt.quit()
+ }
+ }
+
+ Menu {
+ title: qsTr("&Edit")
+
+ MenuItem {
+ text: qsTr("&Copy")
+ enabled: textArea.selectedText
+ onTriggered: textArea.copy()
+ }
+ MenuItem {
+ text: qsTr("Cu&t")
+ enabled: textArea.selectedText
+ onTriggered: textArea.cut()
+ }
+ MenuItem {
+ text: qsTr("&Paste")
+ enabled: textArea.canPaste
+ onTriggered: textArea.paste()
+ }
+ }
+
+ Menu {
+ title: qsTr("F&ormat")
+
+ MenuItem {
+ text: qsTr("&Bold")
+ checkable: true
+ checked: document.bold
+ onTriggered: document.bold = !document.bold
+ }
+ MenuItem {
+ text: qsTr("&Italic")
+ checkable: true
+ checked: document.italic
+ onTriggered: document.italic = !document.italic
+ }
+ MenuItem {
+ text: qsTr("&Underline")
+ checkable: true
+ checked: document.underline
+ onTriggered: document.underline = !document.underline
+ }
+ }
+ }
+
+ FileDialog {
+ id: openDialog
+ fileMode: FileDialog.OpenFile
+ selectedNameFilter.index: 1
+ nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)"]
+ folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
+ onAccepted: document.load(file)
+ }
+
+ FileDialog {
+ id: saveDialog
+ fileMode: FileDialog.SaveFile
+ defaultSuffix: document.fileType
+ nameFilters: openDialog.nameFilters
+ selectedNameFilter.index: document.fileType === "txt" ? 0 : 1
+ folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
+ onAccepted: document.saveAs(file)
+ }
+
+ FontDialog {
+ id: fontDialog
+ onAccepted: {
+ document.fontFamily = font.family;
+ document.fontSize = font.pointSize;
+ }
+ }
+
+ ColorDialog {
+ id: colorDialog
+ currentColor: "black"
+ }
+
+ MessageDialog {
+ id: errorDialog
+ }
+
+ header: ToolBar {
+ leftPadding: 8
+
+ Flow {
+ id: flow
+ width: parent.width
+
+ Row {
+ id: fileRow
+ ToolButton {
+ id: openButton
+ text: "\uF115" // icon-folder-open-empty
+ font.family: "fontello"
+ onClicked: openDialog.open()
+ }
+ ToolSeparator {
+ contentItem.visible: fileRow.y === editRow.y
+ }
+ }
+
+ Row {
+ id: editRow
+ ToolButton {
+ id: copyButton
+ text: "\uF0C5" // icon-docs
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ enabled: textArea.selectedText
+ onClicked: textArea.copy()
+ }
+ ToolButton {
+ id: cutButton
+ text: "\uE802" // icon-scissors
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ enabled: textArea.selectedText
+ onClicked: textArea.cut()
+ }
+ ToolButton {
+ id: pasteButton
+ text: "\uF0EA" // icon-paste
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ enabled: textArea.canPaste
+ onClicked: textArea.paste()
+ }
+ ToolSeparator {
+ contentItem.visible: editRow.y === formatRow.y
+ }
+ }
+
+ Row {
+ id: formatRow
+ ToolButton {
+ id: boldButton
+ text: "\uE800" // icon-bold
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.bold
+ onClicked: document.bold = !document.bold
+ }
+ ToolButton {
+ id: italicButton
+ text: "\uE801" // icon-italic
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.italic
+ onClicked: document.italic = !document.italic
+ }
+ ToolButton {
+ id: underlineButton
+ text: "\uF0CD" // icon-underline
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.underline
+ onClicked: document.underline = !document.underline
+ }
+ ToolButton {
+ id: fontFamilyToolButton
+ text: qsTr("\uE808") // icon-font
+ font.family: "fontello"
+ font.bold: document.bold
+ font.italic: document.italic
+ font.underline: document.underline
+ onClicked: {
+ fontDialog.currentFont.family = document.fontFamily;
+ fontDialog.currentFont.pointSize = document.fontSize;
+ fontDialog.open();
+ }
+ }
+ ToolButton {
+ id: textColorButton
+ text: "\uF1FC" // icon-brush
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ onClicked: colorDialog.open()
+
+ Rectangle {
+ width: aFontMetrics.width + 3
+ height: 2
+ color: document.textColor
+ parent: textColorButton.contentItem
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.baseline: parent.baseline
+ anchors.baselineOffset: 6
+
+ TextMetrics {
+ id: aFontMetrics
+ font: textColorButton.font
+ text: textColorButton.text
+ }
+ }
+ }
+ ToolSeparator {
+ contentItem.visible: formatRow.y === alignRow.y
+ }
+ }
+
+ Row {
+ id: alignRow
+ ToolButton {
+ id: alignLeftButton
+ text: "\uE803" // icon-align-left
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignLeft
+ onClicked: document.alignment = Qt.AlignLeft
+ }
+ ToolButton {
+ id: alignCenterButton
+ text: "\uE804" // icon-align-center
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignHCenter
+ onClicked: document.alignment = Qt.AlignHCenter
+ }
+ ToolButton {
+ id: alignRightButton
+ text: "\uE805" // icon-align-right
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignRight
+ onClicked: document.alignment = Qt.AlignRight
+ }
+ ToolButton {
+ id: alignJustifyButton
+ text: "\uE806" // icon-align-justify
+ font.family: "fontello"
+ focusPolicy: Qt.TabFocus
+ checkable: true
+ checked: document.alignment == Qt.AlignJustify
+ onClicked: document.alignment = Qt.AlignJustify
+ }
+ }
+ }
+ }
+
+ DocumentHandler {
+ id: document
+ document: textArea.textDocument
+ cursorPosition: textArea.cursorPosition
+ selectionStart: textArea.selectionStart
+ selectionEnd: textArea.selectionEnd
+ textColor: colorDialog.color
+ Component.onCompleted: document.load("qrc:/texteditor.html")
+ onLoaded: {
+ textArea.text = text
+ }
+ onError: {
+ errorDialog.text = message
+ errorDialog.visible = true
+ }
+ }
+
+ Flickable {
+ id: flickable
+ flickableDirection: Flickable.VerticalFlick
+ anchors.fill: parent
+
+ TextArea.flickable: TextArea {
+ id: textArea
+ textFormat: Qt.RichText
+ wrapMode: TextArea.Wrap
+ focus: true
+ selectByMouse: true
+ persistentSelection: true
+ // Different styles have different padding and background
+ // decorations, but since this editor is almost taking up the
+ // entire window, we don't need them.
+ leftPadding: 6
+ rightPadding: 6
+ topPadding: 0
+ bottomPadding: 0
+ background: null
+
+ MouseArea {
+ acceptedButtons: Qt.RightButton
+ anchors.fill: parent
+ onClicked: contextMenu.open()
+ }
+
+ onLinkActivated: Qt.openUrlExternally(link)
+ }
+
+ ScrollBar.vertical: ScrollBar {}
+ }
+
+ Menu {
+ id: contextMenu
+
+ MenuItem {
+ text: qsTr("Copy")
+ enabled: textArea.selectedText
+ onTriggered: textArea.copy()
+ }
+ MenuItem {
+ text: qsTr("Cut")
+ enabled: textArea.selectedText
+ onTriggered: textArea.cut()
+ }
+ MenuItem {
+ text: qsTr("Paste")
+ enabled: textArea.canPaste
+ onTriggered: textArea.paste()
+ }
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: qsTr("Font...")
+ onTriggered: fontDialog.open()
+ }
+
+ MenuItem {
+ text: qsTr("Color...")
+ onTriggered: colorDialog.open()
+ }
+ }
+}
diff --git a/examples/quickcontrols2/texteditor/qtquickcontrols2.conf b/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
new file mode 100644
index 00000000..ecac617f
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/qtquickcontrols2.conf
@@ -0,0 +1,11 @@
+[Controls]
+Style=Material
+
+[Material]
+Primary=White
+Foreground=#444444
+Accent=Blue
+Theme=System
+
+[Universal]
+Theme=System
diff --git a/examples/quickcontrols2/texteditor/texteditor.cpp b/examples/quickcontrols2/texteditor/texteditor.cpp
new file mode 100644
index 00000000..10ba675c
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/texteditor.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifdef QT_WIDGETS_LIB
+#include <QApplication>
+#else
+#include <QGuiApplication>
+#endif
+#include <QFontDatabase>
+#include <QDebug>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <QQmlFileSelector>
+#include <QQuickStyle>
+
+#include "documenthandler.h"
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setApplicationName("Text Editor");
+ QGuiApplication::setOrganizationName("QtProject");
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+#ifdef QT_WIDGETS_LIB
+ QApplication app(argc, argv);
+#else
+ QGuiApplication app(argc, argv);
+#endif
+
+ QFontDatabase fontDatabase;
+ if (fontDatabase.addApplicationFont(":/fonts/fontello.ttf") == -1)
+ qWarning() << "Failed to load fontello.ttf";
+
+ qmlRegisterType<DocumentHandler>("io.qt.examples.texteditor", 1, 0, "DocumentHandler");
+
+ QStringList selectors;
+#ifdef QT_EXTRA_FILE_SELECTOR
+ selectors += QT_EXTRA_FILE_SELECTOR;
+#else
+ if (app.arguments().contains("-touch"))
+ selectors += "touch";
+#endif
+
+ QQmlApplicationEngine engine;
+ QQmlFileSelector::get(&engine)->setExtraSelectors(selectors);
+
+ engine.load(QUrl("qrc:/qml/texteditor.qml"));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
diff --git a/examples/quickcontrols2/texteditor/texteditor.html b/examples/quickcontrols2/texteditor/texteditor.html
new file mode 100644
index 00000000..1310da42
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/texteditor.html
@@ -0,0 +1,44 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="qrichtext" content="1">
+ <title>Text Editor Example</title>
+ <style type="text/css">
+ p,
+ body, <!-- specifiying font-size for body seems to be necessary to avoid bullet points being incorrectly positioned -->
+ li {
+ white-space: pre-wrap;
+ font-size:11pt;
+ }
+ </style>
+</head>
+<body>
+ <p align="center">
+ <img src="qrc:/images/qt-logo.png" />
+ </p>
+ <h2 align="center">
+ Qt Quick Controls 2
+ </h2>
+ <p align="center">
+ This example demonstrates a modern rich text editor. The UI uses Qt Labs Platforms to provide native menus and dialogs.
+ </p>
+ <br />
+ <br />
+ <br />
+
+ <p>
+ Below you'll find a list of the native controls used in this application.
+ </p>
+
+ <ul>
+ <!-- TODO: update the links before the 5.8 release -->
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-menu.html">Menu</a> - provides a QML API for native platform menu popups.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-menubar.html">MenuBar</a> - provides a QML API for native platform menubars.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-menuitem.html">MenuItem</a> - provides a QML API for native platform menu items.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-filedialog.html">FileDialog</a> - provides a QML API for native platform file dialogs.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-fontdialog.html">FontDialog</a> - provides a QML API for native platform font dialogs.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-colordialog.html">ColorDialog</a> - provides a QML API for native platform color dialogs.</li>
+ <li><a href="http://doc-snapshots.qt.io/qt5-dev/qml-qt-labs-platform-messagedialog.html">MessageDialog</a> - provides a QML API for native platform message dialogs.</li>
+ </ul>
+</body>
+</html>
diff --git a/examples/quickcontrols2/texteditor/texteditor.pro b/examples/quickcontrols2/texteditor/texteditor.pro
new file mode 100644
index 00000000..deb24576
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/texteditor.pro
@@ -0,0 +1,22 @@
+TEMPLATE = app
+TARGET = texteditor
+QT += quick quickcontrols2
+qtHaveModule(widgets): QT += widgets
+
+cross_compile: DEFINES += QT_EXTRA_FILE_SELECTOR=\\\"touch\\\"
+
+HEADERS += \
+ documenthandler.h
+
+SOURCES += \
+ texteditor.cpp \
+ documenthandler.cpp
+
+OTHER_FILES += \
+ qml/*.qml
+
+RESOURCES += \
+ texteditor.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/texteditor
+INSTALLS += target
diff --git a/examples/quickcontrols2/texteditor/texteditor.qrc b/examples/quickcontrols2/texteditor/texteditor.qrc
new file mode 100644
index 00000000..8f2da843
--- /dev/null
+++ b/examples/quickcontrols2/texteditor/texteditor.qrc
@@ -0,0 +1,11 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qtquickcontrols2.conf</file>
+ <file>images/qt-logo.png</file>
+ <file>fonts/fontello.ttf</file>
+ <file>qml/texteditor.qml</file>
+ <file>texteditor.html</file>
+ <file>qml/+touch/texteditor.qml</file>
+ <file>+touch/texteditor.html</file>
+ </qresource>
+</RCC>
diff --git a/src/imports/calendar/calendar.pro b/src/imports/calendar/calendar.pro
index 8e9446cc..981860b5 100644
--- a/src/imports/calendar/calendar.pro
+++ b/src/imports/calendar/calendar.pro
@@ -7,6 +7,8 @@ QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
+QMAKE_DOCS = $$PWD/doc/qtlabscalendar.qdocconf
+
OTHER_FILES += \
qmldir
diff --git a/src/imports/controls/doc/images/qtlabscalendar-calendarmodel.png b/src/imports/calendar/doc/images/qtlabscalendar-calendarmodel.png
index 7a140d27..7a140d27 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-calendarmodel.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-calendarmodel.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-dayofweekrow-layout.png b/src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow-layout.png
index 130e3757..130e3757 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-dayofweekrow-layout.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow-layout.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-dayofweekrow.png b/src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow.png
index 6c8424ab..6c8424ab 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-dayofweekrow.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-dayofweekrow.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-monthgrid-layout.png b/src/imports/calendar/doc/images/qtlabscalendar-monthgrid-layout.png
index dd903650..dd903650 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-monthgrid-layout.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-monthgrid-layout.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-monthgrid.png b/src/imports/calendar/doc/images/qtlabscalendar-monthgrid.png
index 0c3b3c41..0c3b3c41 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-monthgrid.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-monthgrid.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn-layout.png b/src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn-layout.png
index b015a3e6..b015a3e6 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn-layout.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn-layout.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn.png b/src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn.png
index 65e25b29..65e25b29 100644
--- a/src/imports/controls/doc/images/qtlabscalendar-weeknumbercolumn.png
+++ b/src/imports/calendar/doc/images/qtlabscalendar-weeknumbercolumn.png
Binary files differ
diff --git a/src/imports/calendar/doc/qtlabscalendar.qdocconf b/src/imports/calendar/doc/qtlabscalendar.qdocconf
new file mode 100644
index 00000000..0e230aa1
--- /dev/null
+++ b/src/imports/calendar/doc/qtlabscalendar.qdocconf
@@ -0,0 +1,37 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+
+project = QtLabsCalendar
+description = Qt Labs Calendar Reference Documentation
+version = $QT_VERSION
+
+qhp.projects = QtLabsCalendar
+
+qhp.QtLabsCalendar.file = qtlabscalendar.qhp
+qhp.QtLabsCalendar.namespace = org.qt-project.qtlabscalendar.$QT_VERSION_TAG
+qhp.QtLabsCalendar.virtualFolder = qtlabscalendar
+qhp.QtLabsCalendar.indexTitle = Qt Labs Calendar
+qhp.QtLabsCalendar.indexRoot =
+
+qhp.QtLabsCalendar.filterAttributes = qtlabscalendar $QT_VERSION qtrefdoc
+qhp.QtLabsCalendar.customFilters.Qt.name = QtLabsCalendar $QT_VERSION
+qhp.QtLabsCalendar.customFilters.Qt.filterAttributes = qtlabscalendar $QT_VERSION
+
+qhp.QtLabsCalendar.subprojects = qmltypes
+qhp.QtLabsCalendar.subprojects.qmltypes.title = QML Types
+qhp.QtLabsCalendar.subprojects.qmltypes.indexTitle = Qt Labs Calendar QML Types
+qhp.QtLabsCalendar.subprojects.qmltypes.selectors = qmlclass
+qhp.QtLabsCalendar.subprojects.qmltypes.sortPages = true
+
+depends = qtcore qtgui qtdoc qtqml qtquick qtquickcontrols2
+
+headerdirs += ../
+sourcedirs += ../ src
+exampledirs += ../ snippets
+imagedirs += images
+
+navigation.landingpage = "Qt Labs Calendar"
+navigation.qmltypespage = "Qt Labs Calendar QML Types"
+
+tagfile = qtlabscalendar.tags
+
+macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-calendarmodel.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-calendarmodel.qml
index dfbf4fbc..37a6ced7 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-calendarmodel.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-calendarmodel.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import Qt.labs.calendar 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
ListView {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow-layout.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow-layout.qml
index ce41d224..ce41d224 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow-layout.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow-layout.qml
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow.qml
index 5ea3714c..5ea3714c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-dayofweekrow.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-dayofweekrow.qml
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid-layout.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid-layout.qml
index 346e6099..346e6099 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid-layout.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid-layout.qml
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid.qml
index 16f872b8..16f872b8 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-monthgrid.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-monthgrid.qml
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn-layout.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn-layout.qml
index d105553f..d105553f 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn-layout.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn-layout.qml
diff --git a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn.qml b/src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn.qml
index e58e5c7b..e58e5c7b 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtlabscalendar-weeknumbercolumn.qml
+++ b/src/imports/calendar/doc/snippets/qtlabscalendar-weeknumbercolumn.qml
diff --git a/src/imports/controls/doc/src/calendar/qtlabscalendar-index.qdoc b/src/imports/calendar/doc/src/qtlabscalendar-index.qdoc
index d99b3880..9456f1cb 100644
--- a/src/imports/controls/doc/src/calendar/qtlabscalendar-index.qdoc
+++ b/src/imports/calendar/doc/src/qtlabscalendar-index.qdoc
@@ -29,11 +29,11 @@
\page qtlabscalendar-index.html
\title Qt Labs Calendar
- \brief The Qt Labs Calendar module provides a set of UI controls for Qt
- Quick.
+ \brief The experimental Qt Labs Calendar module provides a set of UI controls
+ for Qt Quick.
- The Qt Labs Calendar module provides a set of types that can be used
- to build calendars in Qt Quick.
+ The experimental Qt Labs Calendar module provides a set of types that can be
+ used to build calendars in Qt Quick. The module was introduced in Qt 5.7.
\section1 QML Types
diff --git a/src/imports/controls/doc/src/calendar/qtlabscalendar.qdoc b/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc
index a94e5ec6..a94e5ec6 100644
--- a/src/imports/controls/doc/src/calendar/qtlabscalendar.qdoc
+++ b/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc
diff --git a/src/imports/calendar/qquickcalendar.cpp b/src/imports/calendar/qquickcalendar.cpp
index b64759f2..cb543012 100644
--- a/src/imports/calendar/qquickcalendar.cpp
+++ b/src/imports/calendar/qquickcalendar.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
The Qt Labs Calendar module uses 0-based month numbers to be consistent
with the JavaScript Date type, that is used by the QML language. This
means that \c Date::getMonth() can be assigned to MonthGrid::month and
- WeekNumberColumn::month as is. When dealing with dealing with month numbers
+ WeekNumberColumn::month as is. When dealing with month numbers
directly, it is highly recommended to use the following enumeration values
to avoid confusion.
diff --git a/src/imports/controls/AbstractButton.qml b/src/imports/controls/AbstractButton.qml
index 487b452b..a45c6816 100644
--- a/src/imports/controls/AbstractButton.qml
+++ b/src/imports/controls/AbstractButton.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.AbstractButton {
id: control
diff --git a/src/imports/controls/ApplicationWindow.qml b/src/imports/controls/ApplicationWindow.qml
index 98de8946..e82430e5 100644
--- a/src/imports/controls/ApplicationWindow.qml
+++ b/src/imports/controls/ApplicationWindow.qml
@@ -34,20 +34,22 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
import QtQuick.Window 2.2
-import QtQuick.Templates 2.0 as T
+import QtQuick.Templates 2.1 as T
T.ApplicationWindow {
id: window
- color: "#ffffff"
+ color: Default.backgroundColor
overlay.modal: Rectangle {
- color: "#7f28282a"
+ color: Default.overlayModalColor
}
overlay.modeless: Rectangle {
- color: "#1f28282a"
+ color: Default.overlayDimColor
}
}
diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml
index 9be1f046..171e5869 100644
--- a/src/imports/controls/BusyIndicator.qml
+++ b/src/imports/controls/BusyIndicator.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.BusyIndicator {
id: control
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
index 1a974eed..85d52b12 100644
--- a/src/imports/controls/Button.qml
+++ b/src/imports/controls/Button.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Button {
id: control
@@ -54,7 +56,9 @@ T.Button {
text: control.text
font: control.font
opacity: enabled || control.highlighted || control.checked ? 1 : 0.3
- color: control.checked || control.highlighted ? "#ffffff" : (control.visualFocus ? "#0066ff" : (control.down ? "#26282a" : "#353637"))
+ color: control.checked || control.highlighted ?
+ Default.textLightColor :
+ (control.visualFocus ? Default.focusColor : (control.down ? Default.textDarkColor : Default.textColor))
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@@ -65,9 +69,9 @@ T.Button {
implicitHeight: 40
visible: !control.flat || control.down || control.checked || control.highlighted
color: control.checked || control.highlighted ?
- (control.visualFocus ? (control.down ? "#599bff" : "#0066ff") : (control.down ? "#585a5c" : "#353637")) :
- (control.visualFocus ? (control.down ? "#cce0ff" : "#f0f6ff") : (control.down ? "#d0d0d0" : "#e0e0e0"))
- border.color: "#0066ff"
+ (control.visualFocus ? (control.down ? Default.buttonCheckedFocusColor : Default.focusColor) : (control.down ? Default.buttonCheckedPressedColor : Default.textColor)) :
+ (control.visualFocus ? (control.down ? Default.focusPressedColor : Default.focusLightColor) : (control.down ? Default.buttonPressedColor : Default.buttonColor))
+ border.color: Default.focusColor
border.width: control.visualFocus ? 2 : 0
}
}
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index 632097b1..98fb31e1 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.CheckBox {
id: control
@@ -64,7 +64,7 @@ T.CheckBox {
text: control.text
font: control.font
- color: control.down ? "#26282a" : "#353637"
+ color: control.down ? Default.textDarkColor : Default.textColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/CheckDelegate.qml b/src/imports/controls/CheckDelegate.qml
index 96cb48e0..929dc4b5 100644
--- a/src/imports/controls/CheckDelegate.qml
+++ b/src/imports/controls/CheckDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.CheckDelegate {
id: control
@@ -58,7 +58,7 @@ T.CheckDelegate {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -76,6 +76,6 @@ T.CheckDelegate {
implicitWidth: 100
implicitHeight: 40
visible: control.down || control.highlighted
- color: control.down ? "#bdbebf" : "#eeeeee"
+ color: control.down ? Default.delegatePressedColor : Default.delegateColor
}
}
diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml
index 5aad92ef..9078e0c6 100644
--- a/src/imports/controls/CheckIndicator.qml
+++ b/src/imports/controls/CheckIndicator.qml
@@ -34,7 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
Rectangle {
id: indicator
@@ -44,15 +46,19 @@ Rectangle {
implicitWidth: 28
implicitHeight: 28
- color: control.enabled ? (control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : "#ffffff") : "#353637"
+ color: control.enabled ? (control.down
+ ? (control.visualFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : Default.backgroundColor) : Default.disabledDarkColor
border.width: control.visualFocus ? 2 : 1
- border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090")) : "transparent"
+ border.color: control.enabled ? (control.visualFocus
+ ? Default.focusColor
+ : (control.down ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : "transparent"
opacity: enabled ? 1 : 0.3
Image {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
- source: "image://default/check/" + (control.visualFocus ? "#0066ff" : "#353637")
+ source: "image://default/check/" + (control.visualFocus ? Default.focusColor : Default.textColor)
sourceSize.width: width
sourceSize.height: height
visible: control.checkState === Qt.Checked
@@ -63,7 +69,7 @@ Rectangle {
y: (parent.height - height) / 2
width: 16
height: 3
- color: control.visualFocus ? "#0066ff" : "#353637"
+ color: control.visualFocus ? Default.focusColor : Default.frameDarkColor
visible: control.checkState === Qt.PartiallyChecked
}
}
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml
index 31f2e5d9..e174a70d 100644
--- a/src/imports/controls/ComboBox.qml
+++ b/src/imports/controls/ComboBox.qml
@@ -34,10 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ComboBox {
id: control
@@ -59,12 +60,13 @@ T.ComboBox {
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal
highlighted: control.highlightedIndex == index
+ hoverEnabled: control.hoverEnabled
}
indicator: Image {
x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2
- source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637")
+ source: "image://default/double-arrow/" + (control.visualFocus ? Default.focusColor : Default.textColor)
sourceSize.width: width
sourceSize.height: height
opacity: enabled ? 1 : 0.3
@@ -76,7 +78,7 @@ T.ComboBox {
text: control.displayText
font: control.font
- color: control.visualFocus ? "#0066ff" : "#353637"
+ color: control.visualFocus ? Default.focusColor : Default.textColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@@ -87,10 +89,11 @@ T.ComboBox {
implicitWidth: 120
implicitHeight: 40
- color: control.visualFocus ? (control.pressed ? "#cce0ff" : "#f0f6ff") :
- (control.pressed || popup.visible ? "#d0d0d0" : "#e0e0e0")
- border.color: "#0066ff"
+ color: control.visualFocus ? (control.pressed ? Default.focusPressedColor : Default.focusLightColor) :
+ (control.pressed || popup.visible ? Default.buttonPressedColor : Default.buttonColor)
+ border.color: Default.focusColor
border.width: control.visualFocus ? 2 : 0
+ visible: !control.flat || control.pressed
}
popup: T.Popup {
@@ -115,7 +118,7 @@ T.ComboBox {
width: listview.width
height: listview.height
color: "transparent"
- border.color: "#bdbebf"
+ border.color: Default.frameLightColor
}
T.ScrollIndicator.vertical: ScrollIndicator { }
diff --git a/src/imports/controls/Container.qml b/src/imports/controls/Container.qml
index 9e9215f8..d3aa89bc 100644
--- a/src/imports/controls/Container.qml
+++ b/src/imports/controls/Container.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.Container {
id: control
diff --git a/src/imports/controls/Control.qml b/src/imports/controls/Control.qml
index a4bb95fe..92b1cfd2 100644
--- a/src/imports/controls/Control.qml
+++ b/src/imports/controls/Control.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.Control {
id: control
diff --git a/src/imports/controls/Dial.qml b/src/imports/controls/Dial.qml
index cd4d6ba2..67c3b0fb 100644
--- a/src/imports/controls/Dial.qml
+++ b/src/imports/controls/Dial.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Dial {
id: control
@@ -48,7 +48,7 @@ T.Dial {
background: DialRing {
width: control.availableWidth
height: control.availableHeight
- color: control.visualFocus ? "#0066ff" : "#353637"
+ color: control.visualFocus ? Default.focusColor : Default.frameDarkColor
progress: control.position
opacity: control.enabled ? 1 : 0.3
}
@@ -59,7 +59,7 @@ T.Dial {
y: background.y + background.height / 2 - handle.height / 2
width: 14
height: 10
- source: "image://default/dial-indicator/" + (control.visualFocus ? "#0066ff" : "#353637")
+ source: "image://default/dial-indicator/" + (control.visualFocus ? Default.focusColor : Default.textColor)
sourceSize.width: width
sourceSize.height: height
antialiasing: true
diff --git a/src/imports/controls/Dialog.qml b/src/imports/controls/Dialog.qml
new file mode 100644
index 00000000..1cf64164
--- /dev/null
+++ b/src/imports/controls/Dialog.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+
+T.Dialog {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0,
+ contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0)
+ + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+
+ padding: 12
+
+ background: Rectangle {
+ border.color: Default.frameDarkColor
+ }
+
+ header: Label {
+ text: control.title
+ visible: control.title
+ elide: Label.ElideRight
+ font.bold: true
+ padding: 12
+ background: Rectangle {
+ x: 1; y: 1
+ width: parent.width - 2
+ height: parent.height - 1
+ }
+ }
+
+ footer: DialogButtonBox {
+ visible: count > 0
+ }
+}
diff --git a/src/imports/controls/DialogButtonBox.qml b/src/imports/controls/DialogButtonBox.qml
new file mode 100644
index 00000000..9f4ebce5
--- /dev/null
+++ b/src/imports/controls/DialogButtonBox.qml
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+
+T.DialogButtonBox {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ spacing: 1
+ padding: 12
+ alignment: count === 1 ? Qt.AlignRight : undefined
+
+ delegate: Button {
+ width: control.count === 1 ? control.availableWidth / 2 : undefined
+ }
+
+ contentItem: ListView {
+ implicitWidth: contentWidth
+ implicitHeight: 40
+
+ model: control.contentModel
+ spacing: control.spacing
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ snapMode: ListView.SnapToItem
+ }
+
+ background: Rectangle {
+ implicitHeight: 40
+ x: 1; y: 1
+ width: parent.width - 2
+ height: parent.height - 2
+ }
+}
diff --git a/src/imports/controls/Drawer.qml b/src/imports/controls/Drawer.qml
index 6e9ab71f..a90893d9 100644
--- a/src/imports/controls/Drawer.qml
+++ b/src/imports/controls/Drawer.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Drawer {
id: control
@@ -56,14 +58,12 @@ T.Drawer {
enter: Transition { SmoothedAnimation { velocity: 5 } }
exit: Transition { SmoothedAnimation { velocity: 5 } }
- contentItem: Item { }
-
background: Rectangle {
Rectangle {
readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge
width: horizontal ? 1 : parent.width
height: horizontal ? parent.height : 1
- color: "#353637"
+ color: Default.frameDarkColor
x: control.edge === Qt.LeftEdge ? parent.width - 1 : 0
y: control.edge === Qt.TopEdge ? parent.height - 1 : 0
}
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
index b7968cb4..6086d92b 100644
--- a/src/imports/controls/Frame.qml
+++ b/src/imports/controls/Frame.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Frame {
id: control
@@ -48,10 +50,8 @@ T.Frame {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
color: "transparent"
- border.color: "#bdbebf"
+ border.color: Default.frameLightColor
}
}
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index 31f4963f..4f083b15 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.GroupBox {
id: control
@@ -52,15 +54,13 @@ T.GroupBox {
padding: 12
topPadding: padding + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
- contentItem: Item { }
-
label: Text {
x: control.leftPadding
width: control.availableWidth
text: control.title
font: control.font
- color: control.enabled ? "#353637" : "#bdbebf"
+ color: control.enabled ? Default.textColor : Default.textDisabledColor
elide: Text.ElideRight
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
@@ -72,6 +72,6 @@ T.GroupBox {
height: parent.height - control.topPadding + control.padding
color: "transparent"
- border.color: "#bdbebf"
+ border.color: Default.frameLightColor
}
}
diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml
index 519ef3bf..23d72080 100644
--- a/src/imports/controls/ItemDelegate.qml
+++ b/src/imports/controls/ItemDelegate.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ItemDelegate {
id: control
@@ -56,7 +58,7 @@ T.ItemDelegate {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -67,6 +69,8 @@ T.ItemDelegate {
implicitWidth: 100
implicitHeight: 40
visible: control.down || control.highlighted || control.visualFocus
- color: control.visualFocus ? (control.pressed ? "#cce0ff" : "#e5efff") : (control.down ? "#bdbebf" : "#eeeeee")
+ color: control.visualFocus
+ ? (control.pressed ? Default.focusPressedColor : Default.delegateFocusColor)
+ : (control.down ? Default.delegatePressedColor : Default.delegateColor)
}
}
diff --git a/src/imports/controls/Label.qml b/src/imports/controls/Label.qml
index d0f01613..c492cd7a 100644
--- a/src/imports/controls/Label.qml
+++ b/src/imports/controls/Label.qml
@@ -34,12 +34,14 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Label {
id: control
- color: "#26282a"
- linkColor: "#45a7d7" // TODO
+ color: Default.textDarkColor
+ linkColor: Default.textLinkColor
}
diff --git a/src/imports/controls/Menu.qml b/src/imports/controls/Menu.qml
index d9a97cee..e449f6d1 100644
--- a/src/imports/controls/Menu.qml
+++ b/src/imports/controls/Menu.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Menu {
id: control
@@ -63,7 +64,7 @@ T.Menu {
background: Rectangle {
implicitWidth: 200
implicitHeight: 40
- color: "#ffffff"
- border.color: "#353637"
+ color: Default.backgroundColor
+ border.color: Default.frameDarkColor
}
}
diff --git a/src/imports/controls/MenuItem.qml b/src/imports/controls/MenuItem.qml
index 69f00900..cd224393 100644
--- a/src/imports/controls/MenuItem.qml
+++ b/src/imports/controls/MenuItem.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.MenuItem {
id: control
@@ -55,7 +57,7 @@ T.MenuItem {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -79,7 +81,7 @@ T.MenuItem {
y: 1
width: parent.width - 2
height: parent.height - 2
- color: control.visualFocus || control.down ? "#eeeeee" : "transparent"
+ color: control.visualFocus || control.down ? Default.delegateColor : "transparent"
}
}
}
diff --git a/src/imports/controls/MenuSeparator.qml b/src/imports/controls/MenuSeparator.qml
new file mode 100644
index 00000000..ef075ef9
--- /dev/null
+++ b/src/imports/controls/MenuSeparator.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ padding: 2
+ topPadding: padding + 4
+ bottomPadding: padding + 4
+
+ //! [contentItem]
+ contentItem: Rectangle {
+ implicitWidth: 188
+ implicitHeight: 1
+ color: Default.separatorColor
+ }
+ //! [contentItem]
+}
diff --git a/src/imports/controls/Page.qml b/src/imports/controls/Page.qml
index 4ed7efb1..02f81e07 100644
--- a/src/imports/controls/Page.qml
+++ b/src/imports/controls/Page.qml
@@ -34,15 +34,27 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Page {
id: control
- contentItem: Item { }
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(contentWidth,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + topPadding + bottomPadding
+ + (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
background: Rectangle {
- color: "#ffffff"
+ color: Default.backgroundColor
}
}
diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml
index 933bc839..0273af98 100644
--- a/src/imports/controls/PageIndicator.qml
+++ b/src/imports/controls/PageIndicator.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.PageIndicator {
id: control
@@ -53,7 +55,7 @@ T.PageIndicator {
implicitHeight: 8
radius: width / 2
- color: "#28282a" // TODO
+ color: Default.pageIndicatorColor
opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45
Behavior on opacity { OpacityAnimator { duration: 100 } }
diff --git a/src/imports/controls/Pane.qml b/src/imports/controls/Pane.qml
index feb8eb58..2aeeee5d 100644
--- a/src/imports/controls/Pane.qml
+++ b/src/imports/controls/Pane.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Pane {
id: control
@@ -48,9 +50,7 @@ T.Pane {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
- color: "#ffffff"
+ color: Default.backgroundColor
}
}
diff --git a/src/imports/controls/Popup.qml b/src/imports/controls/Popup.qml
index 72428f23..476a1882 100644
--- a/src/imports/controls/Popup.qml
+++ b/src/imports/controls/Popup.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Popup {
id: control
@@ -50,9 +52,7 @@ T.Popup {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
- border.color: "#353637"
+ border.color: Default.frameDarkColor
}
}
diff --git a/src/imports/controls/ProgressBar.qml b/src/imports/controls/ProgressBar.qml
index 45e990ee..a050383b 100644
--- a/src/imports/controls/ProgressBar.qml
+++ b/src/imports/controls/ProgressBar.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.ProgressBar {
id: control
@@ -69,6 +69,6 @@ T.ProgressBar {
width: control.availableWidth
height: 6
- color: "#e4e4e4"
+ color: Default.progressBarColor
}
}
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
index 1100273a..35395d85 100644
--- a/src/imports/controls/RadioButton.qml
+++ b/src/imports/controls/RadioButton.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.RadioButton {
id: control
@@ -64,7 +64,7 @@ T.RadioButton {
text: control.text
font: control.font
- color: control.down ? "#26282a" : "#353637"
+ color: control.down ? Default.textDarkColor : Default.textColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/RadioDelegate.qml b/src/imports/controls/RadioDelegate.qml
index 620417a8..5df649d9 100644
--- a/src/imports/controls/RadioDelegate.qml
+++ b/src/imports/controls/RadioDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.RadioDelegate {
id: control
@@ -58,7 +58,7 @@ T.RadioDelegate {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -76,6 +76,6 @@ T.RadioDelegate {
implicitWidth: 100
implicitHeight: 40
visible: control.down || control.highlighted
- color: control.down ? "#bdbebf" : "#eeeeee"
+ color: control.down ? Default.delegatePressedColor : Default.delegateColor
}
}
diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml
index 05ff6673..15e6f9cf 100644
--- a/src/imports/controls/RadioIndicator.qml
+++ b/src/imports/controls/RadioIndicator.qml
@@ -34,16 +34,20 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
Rectangle {
implicitWidth: 28
implicitHeight: 28
radius: width / 2
- color: control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : (control.visualFocus ? "#f0f6ff" : "#ffffff")
+ color: control.down
+ ? (control.visualFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : (control.visualFocus ? Default.focusLightColor : Default.backgroundColor)
border.width: control.visualFocus ? 2 : 1
- border.color: control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090")
+ border.color: control.visualFocus ? Default.focusColor : (control.down ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)
opacity: enabled ? 1 : 0.3
property Item control
@@ -54,7 +58,7 @@ Rectangle {
width: 20
height: 20
radius: width / 2
- color: control.down ? "#26282a" : "#353637"
+ color: control.down ? Default.textDarkColor : Default.buttonCheckedColor
visible: control.checked
}
}
diff --git a/src/imports/controls/RangeSlider.qml b/src/imports/controls/RangeSlider.qml
index 181550a4..52e28ba4 100644
--- a/src/imports/controls/RangeSlider.qml
+++ b/src/imports/controls/RangeSlider.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.RangeSlider {
id: control
@@ -56,8 +58,12 @@ T.RangeSlider {
implicitHeight: 28
radius: width / 2
border.width: activeFocus ? 2 : 1
- border.color: control.enabled ? (activeFocus ? "#0066ff" : (control.first.pressed ? "#808080" : "#909090")) : "#d6d6d6"
- color: control.enabled ? (first.pressed ? (activeFocus ? "#cce0ff" : "#f6f6f6") : (activeFocus ? "#f0f6ff" : "#ffffff")) : "#fdfdfd"
+ border.color: control.enabled ? (activeFocus
+ ? Default.focusColor
+ : (control.first.pressed ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : Default.indicatorFrameDisabledColor
+ color: control.enabled ? (first.pressed
+ ? (activeFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : (activeFocus ? Default.focusLightColor : Default.backgroundColor)) : Default.indicatorDisabledColor
readonly property bool horizontal: control.orientation === Qt.Horizontal
}
@@ -69,8 +75,12 @@ T.RangeSlider {
implicitHeight: 28
radius: width / 2
border.width: activeFocus ? 2 : 1
- border.color: control.enabled ? (activeFocus ? "#0066ff" : (control.first.pressed ? "#808080" : "#909090")) : "#d6d6d6"
- color: control.enabled ? (second.pressed ? (activeFocus ? "#cce0ff" : "#f6f6f6") : (activeFocus ? "#f0f6ff" : "#ffffff")) : "#fdfdfd"
+ border.color: control.enabled ? (activeFocus
+ ? Default.focusColor
+ : (control.first.pressed ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : Default.indicatorFrameDisabledColor
+ color: control.enabled ? (second.pressed
+ ? (activeFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : (activeFocus ? Default.focusLightColor : Default.backgroundColor)) : Default.indicatorDisabledColor
readonly property bool horizontal: control.orientation === Qt.Horizontal
}
@@ -83,7 +93,7 @@ T.RangeSlider {
width: horizontal ? control.availableWidth : implicitWidth
height: horizontal ? implicitHeight : control.availableHeight
radius: 3
- color: "#e0e0e0"
+ color: Default.buttonColor
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/RoundButton.qml b/src/imports/controls/RoundButton.qml
new file mode 100644
index 00000000..15c01b48
--- /dev/null
+++ b/src/imports/controls/RoundButton.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
+
+T.RoundButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
+
+ padding: 6
+
+ //! [contentItem]
+ contentItem: Text {
+ text: control.text
+ font: control.font
+ opacity: enabled || control.highlighted || control.checked ? 1 : 0.3
+ color: control.checked || control.highlighted ? Default.textLightColor : (control.visualFocus ? Default.focusColor : (control.down ? Default.textDarkColor : Default.textColor))
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideRight
+ }
+ //! [contentItem]
+
+ //! [background]
+ background: Rectangle {
+ implicitWidth: 40
+ implicitHeight: 40
+ radius: control.radius
+ opacity: enabled ? 1 : 0.3
+ visible: !control.flat || control.down || control.checked || control.highlighted
+ color: control.checked || control.highlighted ?
+ (control.visualFocus ? (control.down ? Default.buttonCheckedFocusColor : Default.focusColor) : (control.down ? Default.buttonCheckedPressedColor : Default.buttonCheckedColor)) :
+ (control.visualFocus ? (control.down ? Default.focusPressedColor : Default.focusLightColor) : (control.down ? Default.buttonPressedColor : Default.buttonColor))
+ border.color: Default.focusColor
+ border.width: control.visualFocus ? 2 : 0
+ }
+ //! [background]
+}
diff --git a/src/imports/controls/ScrollBar.qml b/src/imports/controls/ScrollBar.qml
index c77463aa..52ec1995 100644
--- a/src/imports/controls/ScrollBar.qml
+++ b/src/imports/controls/ScrollBar.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ScrollBar {
id: control
@@ -54,7 +56,7 @@ T.ScrollBar {
implicitHeight: 6
radius: width / 2
- color: control.pressed ? "#28282a" : "#bdbebf"
+ color: control.pressed ? Default.scrollBarPressedColor : Default.scrollBarColor
visible: control.size < 1.0
opacity: 0.0
diff --git a/src/imports/controls/ScrollIndicator.qml b/src/imports/controls/ScrollIndicator.qml
index c129e5b8..8ef60ed6 100644
--- a/src/imports/controls/ScrollIndicator.qml
+++ b/src/imports/controls/ScrollIndicator.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ScrollIndicator {
id: control
@@ -53,7 +55,7 @@ T.ScrollIndicator {
implicitWidth: 2
implicitHeight: 2
- color: "#bdbebf"
+ color: Default.scrollBarColor
visible: control.size < 1.0
opacity: 0.0
diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml
index 5e4dc699..2a14d31c 100644
--- a/src/imports/controls/Slider.qml
+++ b/src/imports/controls/Slider.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Slider {
id: control
@@ -53,9 +55,13 @@ T.Slider {
implicitWidth: 28
implicitHeight: 28
radius: width / 2
- color: control.enabled ? (control.pressed ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : (control.visualFocus ? "#f0f6ff" : "#ffffff")) : "#fdfdfd"
+ color: control.enabled ? (control.pressed
+ ? (control.visualFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : (control.visualFocus ? Default.focusLightColor : Default.backgroundColor)) : Default.indicatorDisabledColor
border.width: control.visualFocus ? 2 : 1
- border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.pressed ? "#808080" : "#909090")) : "#d6d6d6"
+ border.color: control.enabled ? (control.visualFocus
+ ? Default.focusColor
+ : (control.pressed ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : Default.indicatorFrameDisabledColor
readonly property bool horizontal: control.orientation === Qt.Horizontal
}
@@ -68,7 +74,7 @@ T.Slider {
width: horizontal ? control.availableWidth : implicitWidth
height: horizontal ? implicitHeight : control.availableHeight
radius: 3
- color: "#e0e0e0"
+ color: Default.buttonColor
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
index dee368e2..fd81337d 100644
--- a/src/imports/controls/SpinBox.qml
+++ b/src/imports/controls/SpinBox.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.SpinBox {
id: control
@@ -66,15 +68,15 @@ T.SpinBox {
opacity: control.enabled ? 1 : 0.3
font: control.font
- color: "#353637"
- selectionColor: "#0066ff"
- selectedTextColor: "#ffffff"
+ color: Default.textColor
+ selectionColor: Default.focusColor
+ selectedTextColor: Default.textLightColor
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: Qt.ImhDigitsOnly
Rectangle {
x: -6 - (down.indicator ? 1 : 0)
@@ -83,7 +85,7 @@ T.SpinBox {
height: control.height
visible: control.activeFocus
color: "transparent"
- border.color: "#0066ff"
+ border.color: Default.focusColor
border.width: 2
}
}
@@ -93,21 +95,21 @@ T.SpinBox {
height: parent.height
implicitWidth: 40
implicitHeight: 40
- color: up.pressed ? "#d0d0d0" : "#e0e0e0"
+ color: up.pressed ? Default.buttonPressedColor : Default.buttonColor
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: enabled ? "#353637" : "#bdbebf"
+ color: enabled ? Default.textColor : Default.textDisabledColor
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: 2
height: parent.width / 3
- color: enabled ? "#353637" : "#bdbebf"
+ color: enabled ? Default.textColor : Default.textDisabledColor
}
}
@@ -116,19 +118,19 @@ T.SpinBox {
height: parent.height
implicitWidth: 40
implicitHeight: 40
- color: down.pressed ? "#d0d0d0" : "#e0e0e0"
+ color: down.pressed ? Default.buttonPressedColor : Default.buttonColor
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: enabled ? "#353637" : "#bdbebf"
+ color: enabled ? Default.textColor : Default.textDisabledColor
}
}
background: Rectangle {
implicitWidth: 140
- border.color: "#e0e0e0"
+ border.color: Default.buttonColor
}
}
diff --git a/src/imports/controls/StackView.qml b/src/imports/controls/StackView.qml
index f70ecf97..96120d2b 100644
--- a/src/imports/controls/StackView.qml
+++ b/src/imports/controls/StackView.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.4
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
T.StackView {
id: control
diff --git a/src/imports/controls/SwipeDelegate.qml b/src/imports/controls/SwipeDelegate.qml
index 6c84dae0..b140eb95 100644
--- a/src/imports/controls/SwipeDelegate.qml
+++ b/src/imports/controls/SwipeDelegate.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.SwipeDelegate {
id: control
@@ -56,7 +58,7 @@ T.SwipeDelegate {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -72,7 +74,9 @@ T.SwipeDelegate {
}
background: Rectangle {
- color: control.visualFocus ? (control.down ? "#cce0ff" : "#e5efff") : (control.down ? "#bdbebf" : "#ffffff")
+ color: control.visualFocus
+ ? (control.down ? Default.focusPressedColor : Default.delegateFocusColor)
+ : (control.down ? Default.delegatePressedColor : Default.backgroundColor)
Behavior on x {
enabled: !control.down
diff --git a/src/imports/controls/SwipeView.qml b/src/imports/controls/SwipeView.qml
index c4e5a570..555775ee 100644
--- a/src/imports/controls/SwipeView.qml
+++ b/src/imports/controls/SwipeView.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
T.SwipeView {
id: control
@@ -48,6 +48,7 @@ T.SwipeView {
contentItem: ListView {
model: control.contentModel
+ interactive: control.interactive
currentIndex: control.currentIndex
spacing: control.spacing
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
index b4717d05..1918189a 100644
--- a/src/imports/controls/Switch.qml
+++ b/src/imports/controls/Switch.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.Switch {
id: control
@@ -64,7 +64,7 @@ T.Switch {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/SwitchDelegate.qml b/src/imports/controls/SwitchDelegate.qml
index f5383628..a030ec07 100644
--- a/src/imports/controls/SwitchDelegate.qml
+++ b/src/imports/controls/SwitchDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.SwitchDelegate {
id: control
@@ -64,7 +64,7 @@ T.SwitchDelegate {
text: control.text
font: control.font
- color: control.enabled ? "#26282a" : "#bdbebf"
+ color: control.enabled ? Default.textDarkColor : Default.textDisabledColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -75,6 +75,6 @@ T.SwitchDelegate {
implicitWidth: 100
implicitHeight: 40
visible: control.down || control.highlighted
- color: control.down ? "#bdbebf" : "#eeeeee"
+ color: control.down ? Default.delegatePressedColor : Default.delegateColor
}
}
diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml
index 261d9999..362ebfef 100644
--- a/src/imports/controls/SwitchIndicator.qml
+++ b/src/imports/controls/SwitchIndicator.qml
@@ -34,7 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
Item {
implicitWidth: 56
@@ -47,9 +49,9 @@ Item {
width: 56
height: 16
radius: 8
- color: control.checked ? (control.visualFocus ? "#0066ff" : "#353637") : "#e0e0e0"
+ color: control.checked ? (control.visualFocus ? Default.focusColor : Default.buttonCheckedColor) : Default.buttonColor
border.width: control.visualFocus ? 2 : 0
- border.color: "#0066ff"
+ border.color: Default.focusColor
}
Rectangle {
@@ -58,9 +60,13 @@ Item {
width: 28
height: 28
radius: 16
- color: control.enabled ? (control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : (control.visualFocus ? "#f0f6ff" : "#ffffff")) : "#fdfdfd"
+ color: control.enabled ? (control.down
+ ? (control.visualFocus ? Default.focusPressedColor : Default.indicatorPressedColor)
+ : (control.visualFocus ? Default.focusLightColor : Default.backgroundColor)) : Default.indicatorDisabledColor
border.width: control.visualFocus ? 2 : 1
- border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090")) : "#d6d6d6"
+ border.color: control.enabled ? (control.visualFocus
+ ? Default.focusColor
+ : (control.down ? Default.indicatorFramePressedColor : Default.indicatorFrameColor)) : Default.indicatorFrameDisabledColor
Behavior on x {
enabled: !control.down
diff --git a/src/imports/controls/TabBar.qml b/src/imports/controls/TabBar.qml
index 22b5329e..21358c39 100644
--- a/src/imports/controls/TabBar.qml
+++ b/src/imports/controls/TabBar.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.TabBar {
id: control
diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml
index 2c5b2708..f0d922a1 100644
--- a/src/imports/controls/TabButton.qml
+++ b/src/imports/controls/TabButton.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.TabButton {
id: control
@@ -53,13 +55,15 @@ T.TabButton {
font: control.font
elide: Text.ElideRight
opacity: enabled ? 1 : 0.3
- color: !control.checked ? "#ffffff" : control.down ? "#26282a" : "#353637"
+ color: !control.checked ? Default.textLightColor : control.down ? Default.textDarkColor : Default.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
implicitHeight: 40
- color: control.down ? (control.checked ? "#e4e4e4" : "#585a5c") : (control.checked ? "transparent" : "#353637")
+ color: control.down
+ ? (control.checked ? Default.tabButtonCheckedPressedColor : Default.tabButtonPressedColor)
+ : (control.checked ? "transparent" : Default.tabButtonColor)
}
}
diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml
index f1ec6dfa..734cc9d0 100644
--- a/src/imports/controls/TextArea.qml
+++ b/src/imports/controls/TextArea.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.TextArea {
id: control
@@ -51,8 +53,8 @@ T.TextArea {
leftPadding: padding + 4
opacity: enabled ? 1 : 0.2
- color: "#353637"
- selectionColor: "#fddd5c"
+ color: Default.textColor
+ selectionColor: Default.textSelectionColor
selectedTextColor: color
Text {
@@ -64,7 +66,7 @@ T.TextArea {
text: control.placeholderText
font: control.font
- color: "#c2c2c2"
+ color: Default.textDisabledLightColor
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml
index fc07e7bb..5e6e91b6 100644
--- a/src/imports/controls/TextField.qml
+++ b/src/imports/controls/TextField.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.TextField {
id: control
@@ -51,8 +53,8 @@ T.TextField {
leftPadding: padding + 4
opacity: enabled ? 1 : 0.2
- color: "#353637"
- selectionColor: "#fddd5c"
+ color: Default.textColor
+ selectionColor: Default.textSelectionColor
selectedTextColor: color
verticalAlignment: TextInput.AlignVCenter
@@ -65,7 +67,7 @@ T.TextField {
text: control.placeholderText
font: control.font
- color: "#bdbebf"
+ color: Default.textDisabledColor
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
@@ -76,7 +78,7 @@ T.TextField {
implicitWidth: 200
implicitHeight: 40
border.width: control.activeFocus ? 2 : 1
- color: control.enabled ? "#ffffff" : "#353637"
- border.color: control.activeFocus ? "#0066ff" : (control.enabled ? "#bdbebf" : "transparent")
+ color: control.enabled ? Default.backgroundColor : Default.disabledDarkColor
+ border.color: control.activeFocus ? Default.focusColor : (control.enabled ? Default.disabledLightColor : "transparent")
}
}
diff --git a/src/imports/controls/ToolBar.qml b/src/imports/controls/ToolBar.qml
index 02b6c6f3..d7c29be7 100644
--- a/src/imports/controls/ToolBar.qml
+++ b/src/imports/controls/ToolBar.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ToolBar {
id: control
@@ -46,10 +48,8 @@ T.ToolBar {
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
- contentItem: Item { }
-
background: Rectangle {
implicitHeight: 40
- color: "#eeeeee"
+ color: Default.delegateColor
}
}
diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml
index 1fda5ba3..8d91da10 100644
--- a/src/imports/controls/ToolButton.qml
+++ b/src/imports/controls/ToolButton.qml
@@ -34,8 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ToolButton {
id: control
@@ -51,7 +53,7 @@ T.ToolButton {
contentItem: Text {
text: control.text
font: control.font
- color: control.enabled ? (control.visualFocus ? "#0066ff" : "#26282a") : "#c2c2c2"
+ color: control.enabled ? (control.visualFocus ? Default.focusColor : Default.textDarkColor) : Default.textDisabledLightColor
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@@ -61,7 +63,7 @@ T.ToolButton {
implicitWidth: 40
implicitHeight: 40
- color: Qt.darker("#33333333", control.enabled && (control.checked || control.highlighted) ? 1.5 : 1.0)
+ color: Qt.darker(Default.toolButtonColor, control.enabled && (control.checked || control.highlighted) ? 1.5 : 1.0)
opacity: control.down ? 1.0 : control.enabled && (control.checked || control.highlighted) ? 0.5 : 0
visible: control.down || (control.enabled && (control.checked || control.highlighted))
}
diff --git a/src/imports/controls/ToolSeparator.qml b/src/imports/controls/ToolSeparator.qml
new file mode 100644
index 00000000..dca746d7
--- /dev/null
+++ b/src/imports/controls/ToolSeparator.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
+
+T.ToolSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ padding: vertical ? 6 : 2
+ topPadding: vertical ? 2 : 6
+ bottomPadding: vertical ? 2 : 6
+
+ //! [contentItem]
+ contentItem: Rectangle {
+ implicitWidth: vertical ? 1 : 30
+ implicitHeight: vertical ? 30 : 1
+ color: Default.separatorColor
+ }
+ //! [contentItem]
+}
diff --git a/src/imports/controls/ToolTip.qml b/src/imports/controls/ToolTip.qml
index 322757c7..bf574c28 100644
--- a/src/imports/controls/ToolTip.qml
+++ b/src/imports/controls/ToolTip.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.ToolTip {
id: control
@@ -61,6 +62,6 @@ T.ToolTip {
}
background: Rectangle {
- border.color: "#353637"
+ border.color: Default.frameDarkColor
}
}
diff --git a/src/imports/controls/Tumbler.qml b/src/imports/controls/Tumbler.qml
index 571d8089..6c89b86d 100644
--- a/src/imports/controls/Tumbler.qml
+++ b/src/imports/controls/Tumbler.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Tumbler {
id: control
@@ -46,29 +47,23 @@ T.Tumbler {
delegate: Text {
id: label
text: modelData
- color: control.visualFocus ? "#0066ff" : "#26282a"
+ color: control.visualFocus ? Default.focusColor : Default.textDarkColor
font: control.font
opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- contentItem: PathView {
- id: pathView
+ contentItem: TumblerView {
+ id: tumblerView
model: control.model
delegate: control.delegate
- clip: true
- pathItemCount: control.visibleItemCount + 1
- preferredHighlightBegin: 0.5
- preferredHighlightEnd: 0.5
- dragMargin: width / 2
-
path: Path {
- startX: pathView.width / 2
- startY: -pathView.delegateHeight / 2
+ startX: tumblerView.width / 2
+ startY: -tumblerView.delegateHeight / 2
PathLine {
- x: pathView.width / 2
- y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
+ x: tumblerView.width / 2
+ y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
}
}
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index dcbcf8e1..79e03db5 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -1,12 +1,14 @@
HEADERS += \
$$PWD/qquickbusyindicatorring_p.h \
$$PWD/qquickprogressstrip_p.h \
- $$PWD/qquickdialring_p.h
+ $$PWD/qquickdialring_p.h \
+ $$PWD/qquickdefaultstyle_p.h
SOURCES += \
$$PWD/qquickbusyindicatorring.cpp \
$$PWD/qquickprogressstrip.cpp \
- $$PWD/qquickdialring.cpp
+ $$PWD/qquickdialring.cpp \
+ $$PWD/qquickdefaultstyle.cpp
QML_CONTROLS = \
AbstractButton.qml \
@@ -20,6 +22,8 @@ QML_CONTROLS = \
Container.qml \
Control.qml \
Dial.qml \
+ Dialog.qml \
+ DialogButtonBox.qml \
Drawer.qml \
Frame.qml \
GroupBox.qml \
@@ -27,6 +31,7 @@ QML_CONTROLS = \
Label.qml \
Menu.qml \
MenuItem.qml \
+ MenuSeparator.qml \
Page.qml \
PageIndicator.qml \
Pane.qml \
@@ -36,6 +41,7 @@ QML_CONTROLS = \
RadioDelegate.qml \
RadioIndicator.qml \
RangeSlider.qml \
+ RoundButton.qml \
ScrollBar.qml \
ScrollIndicator.qml \
Slider.qml \
@@ -52,6 +58,7 @@ QML_CONTROLS = \
TextField.qml \
ToolBar.qml \
ToolButton.qml \
+ ToolSeparator.qml \
ToolTip.qml \
Tumbler.qml
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
index 15c07cf0..9e8a3c27 100644
--- a/src/imports/controls/controls.pro
+++ b/src/imports/controls/controls.pro
@@ -1,6 +1,6 @@
TARGET = qtquickcontrols2plugin
TARGETPATH = QtQuick/Controls.2
-IMPORT_VERSION = 2.0
+IMPORT_VERSION = 2.1
QT += qml quick
QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private
diff --git a/src/imports/controls/dependencies.json b/src/imports/controls/dependencies.json
new file mode 100644
index 00000000..4481dd1c
--- /dev/null
+++ b/src/imports/controls/dependencies.json
@@ -0,0 +1,17 @@
+[
+ {
+ "name": "QtQuick",
+ "type": "module",
+ "version": "2.8"
+ },
+ {
+ "name": "QtQuick.Window",
+ "type": "module",
+ "version": "2.2"
+ },
+ {
+ "name": "QtQuick.Templates",
+ "type": "module",
+ "version": "2.1"
+ }
+]
diff --git a/src/imports/controls/designer/ToolSeparatorSpecifics.qml b/src/imports/controls/designer/ToolSeparatorSpecifics.qml
new file mode 100644
index 00000000..2e967a6e
--- /dev/null
+++ b/src/imports/controls/designer/ToolSeparatorSpecifics.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import HelperWidgets 2.0
+import QtQuick.Layouts 1.3
+
+Column {
+ width: parent.width
+
+ Section {
+ width: parent.width
+ caption: qsTr("ToolSeparator")
+
+ SectionLayout {
+ Label {
+ text: qsTr("Orientation")
+ tooltip: qsTr("The orientation of the separator.")
+ }
+ SecondColumnLayout {
+ ComboBox {
+ backendValue: backendValues.orientation
+ model: [ "Horizontal", "Vertical" ]
+ scope: "Qt"
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+
+ ControlSection {
+ width: parent.width
+ }
+
+ PaddingSection {
+ width: parent.width
+ }
+}
diff --git a/src/imports/controls/designer/images/toolseparator-icon.png b/src/imports/controls/designer/images/toolseparator-icon.png
new file mode 100644
index 00000000..3d2e152f
--- /dev/null
+++ b/src/imports/controls/designer/images/toolseparator-icon.png
Binary files differ
diff --git a/src/imports/controls/designer/images/toolseparator-icon16.png b/src/imports/controls/designer/images/toolseparator-icon16.png
new file mode 100644
index 00000000..97672506
--- /dev/null
+++ b/src/imports/controls/designer/images/toolseparator-icon16.png
Binary files differ
diff --git a/src/imports/controls/designer/images/toolseparator-icon16@2x.png b/src/imports/controls/designer/images/toolseparator-icon16@2x.png
new file mode 100644
index 00000000..979b6426
--- /dev/null
+++ b/src/imports/controls/designer/images/toolseparator-icon16@2x.png
Binary files differ
diff --git a/src/imports/controls/designer/images/toolseparator-icon@2x.png b/src/imports/controls/designer/images/toolseparator-icon@2x.png
new file mode 100644
index 00000000..19287154
--- /dev/null
+++ b/src/imports/controls/designer/images/toolseparator-icon@2x.png
Binary files differ
diff --git a/src/imports/controls/designer/qtquickcontrols2.metainfo b/src/imports/controls/designer/qtquickcontrols2.metainfo
index 81a6d914..c697b3c2 100644
--- a/src/imports/controls/designer/qtquickcontrols2.metainfo
+++ b/src/imports/controls/designer/qtquickcontrols2.metainfo
@@ -388,6 +388,19 @@ MetaInfo {
}
Type {
+ name: "QtQuick.Controls.ToolSeparator"
+ icon: "images/toolseparator-icon16.png"
+
+ ItemLibraryEntry {
+ name: "ToolSeparator"
+ category: "Qt Quick - Controls 2"
+ libraryIcon: "images/toolseparator-icon.png"
+ version: "2.1"
+ requiredImport: "QtQuick.Controls"
+ }
+ }
+
+ Type {
name: "QtQuick.Controls.Tumbler"
icon: "images/tumbler-icon16.png"
@@ -399,4 +412,32 @@ MetaInfo {
requiredImport: "QtQuick.Controls"
}
}
+
+ Type {
+ name: "QtQuick.Controls.TabBar"
+ icon: "images/toolbar-icon16.png"
+
+ ItemLibraryEntry {
+ name: "Tab Bar"
+ category: "Qt Quick - Controls 2"
+ libraryIcon: "images/toolbar-icon.png"
+ version: "2.0"
+ requiredImport: "QtQuick.Controls"
+ Property { name: "width"; type: "int"; value: 240 }
+ }
+ }
+
+ Type {
+ name: "QtQuick.Controls.TabButton"
+ icon: "images/toolbutton-icon16.png"
+
+ ItemLibraryEntry {
+ name: "Tab Button"
+ category: "Qt Quick - Controls 2"
+ libraryIcon: "images/toolbutton-icon.png"
+ version: "2.0"
+ requiredImport: "QtQuick.Controls"
+ Property { name: "text"; type: "binding"; value: "qsTr(\"Tab Button\")" }
+ }
+ }
}
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox-attached.png b/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox-attached.png
new file mode 100644
index 00000000..53ecf83d
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox-attached.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox.png b/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox.png
new file mode 100644
index 00000000..87cece98
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-dialogbuttonbox.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png
new file mode 100644
index 00000000..48785b73
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator-custom.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png
new file mode 100644
index 00000000..beb1cfeb
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-menuseparator.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-roundbutton.png b/src/imports/controls/doc/images/qtquickcontrols2-roundbutton.png
new file mode 100644
index 00000000..9f1d44fc
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-roundbutton.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-toolseparator-custom.png b/src/imports/controls/doc/images/qtquickcontrols2-toolseparator-custom.png
new file mode 100644
index 00000000..4f423154
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-toolseparator-custom.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-toolseparator.png b/src/imports/controls/doc/images/qtquickcontrols2-toolseparator.png
new file mode 100644
index 00000000..253c429b
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-toolseparator.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-tumbler-wrap.gif b/src/imports/controls/doc/images/qtquickcontrols2-tumbler-wrap.gif
index 4821a4e8..8f59eedc 100644
--- a/src/imports/controls/doc/images/qtquickcontrols2-tumbler-wrap.gif
+++ b/src/imports/controls/doc/images/qtquickcontrols2-tumbler-wrap.gif
Binary files differ
diff --git a/src/imports/controls/doc/qtquickcontrols2.qdocconf b/src/imports/controls/doc/qtquickcontrols2.qdocconf
index a9a48343..42ff16f8 100644
--- a/src/imports/controls/doc/qtquickcontrols2.qdocconf
+++ b/src/imports/controls/doc/qtquickcontrols2.qdocconf
@@ -29,27 +29,24 @@ qhp.QtQuickControls2.subprojects.examples.title = Examples
qhp.QtQuickControls2.subprojects.examples.indexTitle = Qt Quick Controls 2 Examples
qhp.QtQuickControls2.subprojects.examples.selectors = fake:example
-depends = qtcore qtgui qtdoc qtqml qtquick qtquickdialogs qtquickcontrols qtquickextras qmake qtsql qtwidgets
+depends = qtcore qtgui qtdoc qtqml qtquick qtquickdialogs qtquickcontrols qtquickextras qmake qtsql qtwidgets qtlabscalendar qtlabsplatform
# Specify the install path under QT_INSTALL_EXAMPLES
# Note: paths passed to \example command must contain the parent directory, e.g.
# \example controls/tabs
exampledirs += ../../../../examples/quickcontrols2 \
../../../quicktemplates2 \
- ../../calendar \
- ../../../../tests/auto/controls/data \
snippets \
snippets/screenshots
examplesinstallpath = quickcontrols2
headerdirs += ../../../quicktemplates2 \
- ../../calendar \
../../../quickcontrols2
sourcedirs += ../../../quicktemplates2 \
- ../../calendar \
../../../quickcontrols2 \
+ ../../templates/doc/src \
src
imagedirs += images
@@ -91,7 +88,6 @@ macro.endstylemethod2 = "\\br"
macro.stylecolor.HTML = "<div style=\"padding:10px;color:#fff;background:\1;\">\1 \2</div>"
macro.nbsp.HTML = "&nbsp;"
-macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}"
#Add output suffix to the html filenames
outputsuffixes = QML
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modal.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modal.qml
new file mode 100644
index 00000000..c151ceed
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modal.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 2.1
+
+Item {
+ width: dialog.implicitWidth
+ height: dialog.implicitHeight
+//! [1]
+Dialog {
+ id: dialog
+ modal: true
+ standardButtons: Dialog.Ok
+}
+//! [1]
+}
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modeless.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modeless.qml
new file mode 100644
index 00000000..45e1c2c0
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog-modeless.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 2.1
+
+Item {
+ width: dialog.implicitWidth
+ height: dialog.implicitHeight
+//! [1]
+Dialog {
+ id: dialog
+ modal: false
+ standardButtons: Dialog.Ok
+}
+//! [1]
+}
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml
new file mode 100644
index 00000000..69e84914
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 2.1
+
+Item {
+ width: dialog.implicitWidth
+ height: dialog.implicitHeight
+//! [1]
+Dialog {
+ id: dialog
+ title: "Title"
+ standardButtons: Dialog.Ok | Dialog.Cancel
+
+ onAccepted: console.log("Ok clicked")
+ onRejected: console.log("Cancel clicked")
+}
+//! [1]
+}
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox-attached.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox-attached.qml
new file mode 100644
index 00000000..a93cda30
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox-attached.qml
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 2.1
+
+//! [1]
+DialogButtonBox {
+ Button {
+ text: qsTr("Save")
+ DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+ }
+ Button {
+ text: qsTr("Close")
+ DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
+ }
+}
+//! [1]
diff --git a/src/imports/controls/doc/snippets/basic-example.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox.qml
index 62ab2466..41e6cf23 100644
--- a/src/imports/controls/doc/snippets/basic-example.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialogbuttonbox.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -25,19 +25,14 @@
**
****************************************************************************/
-//! [0]
-import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick 2.0
+import QtQuick.Controls 2.1
-ApplicationWindow {
- title: "My Application"
- width: 640
- height: 480
- visible: true
+//! [1]
+DialogButtonBox {
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
- Button {
- text: "Push Me"
- anchors.centerIn: parent
- }
+ onAccepted: console.log("Ok clicked")
+ onRejected: console.log("Cancel clicked")
}
-//! [0]
+//! [1]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml
new file mode 100644
index 00000000..b5d8b18b
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator-custom.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [file]
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+Item {
+ id: window
+ width: menu.contentItem.width
+ height: menu.contentItem.height
+ visible: true
+
+// Indent it like this so that the indenting in the generated doc is normal.
+Menu {
+ id: menu
+ contentItem.parent: window
+
+ MenuItem {
+ text: qsTr("New...")
+ }
+ MenuItem {
+ text: qsTr("Open...")
+ }
+ MenuItem {
+ text: qsTr("Save")
+ }
+
+ MenuSeparator {
+ padding: 0
+ topPadding: 12
+ bottomPadding: 12
+ contentItem: Rectangle {
+ implicitWidth: 200
+ implicitHeight: 1
+ color: "#1E000000"
+ }
+ }
+
+ MenuItem {
+ text: qsTr("Exit")
+ }
+}
+}
+//! [file]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml
new file mode 100644
index 00000000..d41d3cf9
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-menuseparator.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [file]
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+Item {
+ id: window
+ width: menu.contentItem.width
+ height: menu.contentItem.height
+ visible: true
+
+// Indent it like this so that the indenting in the generated doc is normal.
+Menu {
+ id: menu
+ contentItem.parent: window
+
+ MenuItem {
+ text: qsTr("New...")
+ }
+ MenuItem {
+ text: qsTr("Open...")
+ }
+ MenuItem {
+ text: qsTr("Save")
+ }
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: qsTr("Exit")
+ }
+}
+}
+//! [file]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-roundbutton.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-roundbutton.qml
new file mode 100644
index 00000000..fa926302
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-roundbutton.qml
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Controls 2.1
+
+//! [1]
+RoundButton {
+ text: "\u2713" // Unicode Character 'CHECK MARK'
+ onClicked: textArea.readOnly = true
+}
+//! [1]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-custom.qml
index 3e40ea2d..898ff6af 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-stackview-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
StackView {
id: control
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml
index db077057..46b2809f 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate.qml
@@ -25,39 +25,56 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Controls 2.0
+import QtQuick 2.8
+import QtQuick.Controls 2.1
//! [1]
ListView {
- width: 200
- height: 300
- clip: true
+ id: listView
+ anchors.fill: parent
model: ListModel {
- id: listModel
- ListElement { title: "Electricity bill" }
- ListElement { title: "Happy Birthday!" }
- ListElement { title: "FW: Cat pictures" }
- ListElement { title: "Hotel visit receipt" }
- ListElement { title: "Customer service" }
+ ListElement { sender: "Bob Bobbleton"; title: "How are you going?" }
+ ListElement { sender: "Rug Emporium"; title: "SALE! All rugs MUST go!" }
+ ListElement { sender: "Electric Co."; title: "Electricity bill 15/07/2016 overdue" }
+ ListElement { sender: "Tips"; title: "Five ways this tip will save your life" }
}
delegate: SwipeDelegate {
id: swipeDelegate
- text: title
+ text: model.sender + " - " + model.title
width: parent.width
- onClicked: if (swipe.complete) listModel.remove(index)
+ ListView.onRemove: SequentialAnimation {
+ PropertyAction {
+ target: swipeDelegate
+ property: "ListView.delayRemove"
+ value: true
+ }
+ NumberAnimation {
+ target: swipeDelegate
+ property: "height"
+ to: 0
+ easing.type: Easing.InOutQuad
+ }
+ PropertyAction {
+ target: swipeDelegate;
+ property: "ListView.delayRemove";
+ value: false
+ }
+ }
- swipe.right: Rectangle {
- color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444"
- width: parent.width
+ swipe.right: Label {
+ id: deleteLabel
+ text: qsTr("Delete")
+ color: "white"
+ verticalAlignment: Label.AlignVCenter
+ padding: 12
height: parent.height
+ anchors.right: parent.right
+
+ SwipeDelegate.onClicked: listView.model.remove(index)
- Label {
- font.pixelSize: swipeDelegate.font.pixelSize
- text: qsTr("Remove")
- color: "white"
- anchors.centerIn: parent
+ background: Rectangle {
+ color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
}
}
}
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipeview-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipeview-custom.qml
index 04b12512..0f862276 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipeview-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipeview-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SwipeView {
id: control
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator-custom.qml
new file mode 100644
index 00000000..7495a993
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator-custom.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Layouts 1.1
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.1
+
+//! [file]
+ToolBar {
+ RowLayout {
+ anchors.fill: parent
+
+ ToolButton {
+ text: qsTr("Action 1")
+ }
+ ToolButton {
+ text: qsTr("Action 2")
+ }
+
+ ToolSeparator {
+ padding: vertical ? 10 : 2
+ topPadding: vertical ? 2 : 10
+ bottomPadding: vertical ? 2 : 10
+
+ contentItem: Rectangle {
+ implicitWidth: parent.vertical ? 1 : 24
+ implicitHeight: parent.vertical ? 24 : 1
+ color: "#c3c3c3"
+ }
+ }
+
+ ToolButton {
+ text: qsTr("Action 3")
+ }
+ ToolButton {
+ text: qsTr("Action 4")
+ }
+
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+}
+//! [file]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator.qml
new file mode 100644
index 00000000..7770d14c
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-toolseparator.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Layouts 1.1
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.1
+
+//! [1]
+ToolBar {
+ RowLayout {
+ anchors.fill: parent
+
+ ToolButton {
+ text: qsTr("Action 1")
+ }
+ ToolButton {
+ text: qsTr("Action 2")
+ }
+
+ ToolSeparator {}
+
+ ToolButton {
+ text: qsTr("Action 3")
+ }
+ ToolButton {
+ text: qsTr("Action 4")
+ }
+
+ ToolSeparator {}
+
+ ToolButton {
+ text: qsTr("Action 5")
+ }
+ ToolButton {
+ text: qsTr("Action 6")
+ }
+
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+}
+//! [1]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-custom.qml
index 94d9c12e..6bb8a45e 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tooltip-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
ToolTip {
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-listView.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-listView.qml
new file mode 100644
index 00000000..ff3ecd81
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-listView.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+
+//! [contentItem]
+Tumbler {
+ id: tumbler
+
+ contentItem: ListView {
+ model: tumbler.model
+ delegate: tumbler.delegate
+
+ snapMode: ListView.SnapToItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin: height / 2 - (height / tumbler.visibleItemCount / 2)
+ preferredHighlightEnd: height / 2 + (height / tumbler.visibleItemCount / 2)
+ clip: true
+ }
+}
+//! [contentItem]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-pathView.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-pathView.qml
new file mode 100644
index 00000000..957112e0
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-pathView.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+
+//! [contentItem]
+Tumbler {
+ id: tumbler
+
+ contentItem: PathView {
+ id: pathView
+ model: tumbler.model
+ delegate: tumbler.delegate
+ clip: true
+ pathItemCount: tumbler.visibleItemCount + 1
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ dragMargin: width / 2
+
+ path: Path {
+ startX: pathView.width / 2
+ startY: -pathView.delegateHeight / 2
+ PathLine {
+ x: pathView.width / 2
+ y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
+ }
+ }
+
+ property real delegateHeight: tumbler.availableHeight / tumbler.visibleItemCount
+ }
+}
+//! [contentItem]
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-timePicker.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-timePicker.qml
new file mode 100644
index 00000000..86276266
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-timePicker.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [tumbler]
+import QtQuick 2.8
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.1
+
+Rectangle {
+ width: frame.implicitWidth + 10
+ height: frame.implicitHeight + 10
+
+ function formatText(count, modelData) {
+ var data = count === 12 ? modelData + 1 : modelData;
+ return data.toString().length < 2 ? "0" + data : data;
+ }
+
+ FontMetrics {
+ id: fontMetrics
+ }
+
+ Component {
+ id: delegateComponent
+
+ Label {
+ text: formatText(Tumbler.tumbler.count, modelData)
+ opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: fontMetrics.font.pixelSize * 1.25
+ }
+ }
+
+ Frame {
+ id: frame
+ padding: 0
+ anchors.centerIn: parent
+
+ Row {
+ id: row
+
+ Tumbler {
+ id: hoursTumbler
+ model: 12
+ delegate: delegateComponent
+ }
+
+ Tumbler {
+ id: minutesTumbler
+ model: 60
+ delegate: delegateComponent
+ }
+
+ Tumbler {
+ id: amPmTumbler
+ model: ["AM", "PM"]
+ delegate: delegateComponent
+ }
+ }
+ }
+}
+//! [tumbler]
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-busyindicator-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-busyindicator-custom.qml
index 82ed9cdc..847ad736 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-busyindicator-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-busyindicator-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
BusyIndicator {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-custom.qml
index eac6b831..dbe53f4d 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-disabled.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-disabled.qml
index f4555c90..c7399b9a 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-disabled.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-disabled.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-focused.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-focused.qml
index a99346a6..ea220fde 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-focused.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-focused.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-normal.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-normal.qml
index f206bcec..385d4abb 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-normal.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-normal.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-pressed.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-pressed.qml
index 8a941561..edf0b324 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-pressed.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-button-pressed.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-checked.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-checked.qml
index 075e6342..e5c466da 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-checked.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-checked.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
text: "Checked"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-custom.qml
index 0465ec80..9645a4b6 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-disabled.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-disabled.qml
index 4878cf31..3bfbb730 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-disabled.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-disabled.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
text: "Disabled"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-focused.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-focused.qml
index 93f1c214..fd7c7fea 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-focused.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-focused.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
text: "Focused"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-normal.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-normal.qml
index a840116e..dba9e7e9 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-normal.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkbox-normal.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
text: "Normal"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkdelegate-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkdelegate-custom.qml
index 483f9838..83f0ef86 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkdelegate-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-checkdelegate-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckDelegate {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-custom.qml
index bd261e52..12d56a56 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ComboBox {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-delegate.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-delegate.qml
index d8b5d1fa..2817d956 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-delegate.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-delegate.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: root
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-popup.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-popup.qml
index 36569e15..1ac43234 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-popup.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-combobox-popup.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: root
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-custom.qml
index efe061d3..1bf9baf4 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Dial {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-handle.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-handle.qml
index 19d943a6..d9a61682 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-handle.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-dial-handle.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Dial {
id: dial
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame-custom.qml
index d11c431e..f2b5d254 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Frame {
background: Rectangle {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame.qml
index 1ede733d..98f177ef 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-frame.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
Frame {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-checkable.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-checkable.qml
index a2999925..db58593f 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-checkable.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-checkable.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
GroupBox {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-custom.qml
index cb9ed049..bf21e022 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
GroupBox {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-label.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-label.qml
index 74d0ea52..bef99d0b 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-label.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox-label.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
GroupBox {
width: 100
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox.qml
index f79f3aef..7d4f328c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-groupbox.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
GroupBox {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate-custom.qml
index 002aae69..0935d8f6 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ItemDelegate {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate.qml
index 143b3323..733434e8 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-itemdelegate.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
ListView {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label-custom.qml
index 98dbdc5e..2eedb29f 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Label {
text: qsTr("Label")
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label.qml
index 4346c0eb..cf59c49a 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-label.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
Label {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-menu-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-menu-custom.qml
index a6971232..f4507714 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-menu-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-menu-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: window
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-custom.qml
index 65112ef4..225ba423 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
PageIndicator {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-delegate.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-delegate.qml
index 4b3ccf23..c7ae046f 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-delegate.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator-delegate.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
PageIndicator {
count: 5
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator.qml
index 237bc6e7..cf91d6f2 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pageindicator.qml
@@ -25,7 +25,7 @@
**
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
PageIndicator {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane-custom.qml
index 80519939..42c30795 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Pane {
background: Rectangle {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane.qml
index 3d86499f..b7b8fa5d 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-pane.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
Pane {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-custom.qml
index 88faed20..9e6779d6 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-progressbar-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ProgressBar {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-custom.qml
index dba262be..1d9661a5 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiobutton-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
RadioButton {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiodelegate-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiodelegate-custom.qml
index 6efb7803..91125921 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiodelegate-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-radiodelegate-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
RadioDelegate {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-custom.qml
index 7e488d14..86fae061 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-rangeslider-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
RangeSlider {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-active.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-active.qml
index 086541c8..1570aff4 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-active.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-active.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
width: 100
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-custom.qml
index 0bf13b3c..05b3f3aa 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollbar-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollBar {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-active.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-active.qml
index c118c7aa..954b449c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-active.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-active.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
width: 100
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-custom.qml
index 5720f4f7..97930e1e 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-scrollindicator-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollIndicator {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-custom.qml
index ebc11f46..6201cbf8 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Slider {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-handle.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-handle.qml
index 20b569f3..fa23972c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-handle.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-slider-handle.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Slider {
value: 0.5
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-custom.qml
index 6433fd80..cfbd8400 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SpinBox {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-double.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-double.qml
index 15af31ae..ad22b856 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-double.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-double.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
SpinBox {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-down.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-down.qml
index 419dae5c..ecd2a659 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-down.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-down.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SpinBox {
value: 50
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-textual.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-textual.qml
index 814b8b28..e6b7c735 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-textual.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-textual.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
SpinBox {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-up.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-up.qml
index b4b0fab3..0b2c3fea 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-up.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox-up.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SpinBox {
value: 50
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox.qml
index 6616ed60..d8c54714 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-spinbox.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
SpinBox {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipedelegate-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipedelegate-custom.qml
index ae63efed..087e17fe 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipedelegate-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipedelegate-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SwipeDelegate {
id: control
@@ -37,7 +37,7 @@ SwipeDelegate {
id: component
Rectangle {
- color: control.swipe.complete && control.down ? "#333" : "#444"
+ color: SwipeDelegate.pressed ? "#333" : "#444"
width: parent.width
height: parent.height
clip: true
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipeview-indicator.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipeview-indicator.qml
index 2ba8df9c..3afcc3e2 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipeview-indicator.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-swipeview-indicator.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
width: 200
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-checked.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-checked.qml
index f9a18b1c..3a6dfc7c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-checked.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-checked.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
text: "Checked"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-custom.qml
index 698c1a05..5152040d 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-disabled.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-disabled.qml
index a40586b5..6eb53084 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-disabled.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-disabled.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
text: "Disabled"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-focused.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-focused.qml
index f98f2c90..6ca19062 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-focused.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-focused.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
text: "Focused"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-normal.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-normal.qml
index a55c2854..339874d7 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-normal.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switch-normal.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
text: "Normal"
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switchdelegate-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switchdelegate-custom.qml
index 8d0daa0a..e06af484 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switchdelegate-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-switchdelegate-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SwitchDelegate {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-custom.qml
index 1873fba9..305101c0 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TabBar {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar.qml
index b445ee67..e3a67c30 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbar.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Column {
width: 300
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbutton.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbutton.qml
index 67e5e1e0..9fef1e59 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbutton.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tabbutton.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
TabBar {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-custom.qml
index f70c7135..dd6035c0 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextArea {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml
index e11750cb..500e09c3 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textarea-flickable.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
width: 100
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-custom.qml
index 0deb0e5c..8e5d897c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextField {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-disabled.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-disabled.qml
index ac798f53..21c351c4 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-disabled.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-disabled.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextField {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-focused.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-focused.qml
index a4e1b3b1..ddea7c51 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-focused.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-focused.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextField {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-normal.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-normal.qml
index 12c7ead9..29f7fb9c 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-normal.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-textfield-normal.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextField {
width: 80
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar-custom.qml
index 3e98808c..e8d268c5 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar-custom.qml
@@ -27,7 +27,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [file]
ToolBar {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml
index 246f3ae5..2ec10c57 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
width: children[0].implicitWidth * 2
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbutton-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbutton-custom.qml
index 10491cb5..449266c1 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbutton-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbutton-custom.qml
@@ -27,7 +27,7 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ToolButton {
id: control
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-hover.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-hover.qml
index 330ab83c..27b03a63 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-hover.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-hover.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
Button {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-pressandhold.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-pressandhold.qml
index eddb09e6..7d285528 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-pressandhold.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-pressandhold.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
//! [1]
Button {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml
index e6a386c1..ca08ce72 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip-slider.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: root
@@ -46,7 +46,7 @@ Item {
ToolTip {
parent: slider.handle
visible: slider.pressed
- text: slider.position.toFixed(1)
+ text: slider.valueAt(slider.position).toFixed(1)
}
}
//! [1]
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip.qml
index 146fe477..3aa26908 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tooltip.qml
@@ -27,7 +27,7 @@
import QtQuick 2.0
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: root
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-custom.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-custom.qml
index d2b4f960..f1c2b806 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-custom.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-custom.qml
@@ -27,12 +27,11 @@
//! [file]
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Tumbler {
id: control
model: 15
- visibleItemCount: 5
background: Item {
Rectangle {
diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-delegate.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-delegate.qml
index 4d389ab7..4d2c7349 100644
--- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-delegate.qml
+++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-tumbler-delegate.qml
@@ -26,7 +26,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Tumbler {
id: tumbler
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-buttons.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-buttons.qdoc
index 5e2c9370..d79dd198 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-buttons.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-buttons.qdoc
@@ -128,6 +128,24 @@
\b {See also} \l RadioButton
+ \section1 RoundButton Control
+
+ \l RoundButton is a clickable control that starts an action, or opens or
+ closes a popup. A round button with a square image icon or one-letter font
+ icon is circular. A circular RoundButton takes less space than a normal
+ \l Button, and can also be used as a floating action button.
+
+ \image qtquickcontrols2-roundbutton.png
+
+ Recommendations:
+
+ \list
+ \li Keep labels short and concise.
+ \li If the text is localized, consider the influence of a longer text on the layout.
+ \endlist
+
+ \b {See also} \l RoundButton
+
\section1 Switch Control
\image qtquickcontrols2-switch.png
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc
index 29bfc99c..d03f2325 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc
@@ -36,14 +36,15 @@
attributes. The following example specifies that the preferred style is the \l {Material style}.
Furthermore, when the application is run with the Material style, its theme is light and the
accent and primary colors are teal and blue grey, respectively. However, if the application
- is run with the \l {Universal style} instead, the theme is dark and the accent color is red.
+ is run with the \l {Universal style} instead, the accent color is red and the appropriate theme
+ is chosen based on the system theme colors.
\code
[Controls]
Style=Material
[Universal]
- Theme=Dark
+ Theme=System
Accent=Red
[Material]
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
index 71ffe350..06201404 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
@@ -49,7 +49,7 @@
\qml
import QtQuick 2.6
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
@@ -92,7 +92,7 @@
your application, refer to it by its filename:
\qml
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
MyButton {
@@ -108,7 +108,7 @@
control, first import the folder into a namespace:
\qml
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
import "controls" as MyControls
ApplicationWindow {
@@ -136,8 +136,6 @@
\list
\li At least one QML file whose name matches a control (for example,
\c Button.qml) must exist.
-
- The Default style will be used for any controls that aren't implemented.
\li The files must be in a directory in the filesystem or in the
\l {The Qt Resource System}{resource system}.
@@ -155,6 +153,10 @@
for example.
\endlist
+ By default, the styling system uses the Default style as a fallback for
+ controls that aren't implemented. To customize or extend any other built-in
+ style, it is possible to specify a different fallback style using \l QQuickStyle.
+
What this means is that you can implement as many controls as you like for
your custom style, and place them almost anywhere. It also allows users to
create their own styles for your application.
@@ -299,7 +301,7 @@
\qml
import QtQuick 2.6
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
import MyStyle 1.0
@@ -488,7 +490,7 @@
\quotefromfile qtquickcontrols2-menu-custom.qml
\skipto import QtQuick 2.6
- \printuntil import QtQuick.Controls 2.0
+ \printuntil import QtQuick.Controls 2.1
\skipto Menu
\printto contentItem.parent: window
\skipline contentItem.parent: window
@@ -503,6 +505,23 @@
\l {Customizing Button}{Button}.
+ \section2 Customizing MenuSeparator
+
+ MenuSeparator consists of two visual items: \l {Control::background}{background}
+ and \l {Control::contentItem}{content item}.
+
+ \image qtquickcontrols2-menuseparator-custom.png
+
+ \quotefromfile qtquickcontrols2-menuseparator-custom.qml
+ \skipto import QtQuick 2.6
+ \printuntil import QtQuick.Controls 2.1
+ \skipto Menu
+ \printto contentItem.parent: window
+ \skipline contentItem.parent: window
+ \printuntil text: qsTr("Exit")
+ \printuntil }
+ \printuntil }
+
\section2 Customizing PageIndicator
PageIndicator consists of a \l {Control::background}{background}, \l {Control::contentItem}{content item}, and \l {PageIndicator::delegate}{delegate}.
@@ -581,6 +600,12 @@
\snippet qtquickcontrols2-rangeslider-custom.qml file
+ \section2 Customizing RoundButton
+
+ RoundButton can be customized in the same manner as
+ \l {Customizing Button}{Button}.
+
+
\section2 Customizing ScrollBar
ScrollBar consists of two visual items: \l {Control::background}{background}
@@ -723,6 +748,16 @@
\snippet qtquickcontrols2-toolbutton-custom.qml file
+ \section2 Customizing ToolSeparator
+
+ ToolSeparator consists of two visual items: \l {Control::background}{background}
+ and \l {Control::contentItem}{content item}.
+
+ \image qtquickcontrols2-toolseparator-custom.png
+
+ \snippet qtquickcontrols2-toolseparator-custom.qml file
+
+
\section2 Customizing ToolTip
ToolTip consists of two visual items: \l {Popup::background}{background}
@@ -730,7 +765,7 @@
\quotefromfile qtquickcontrols2-tooltip-custom.qml
\skipto import QtQuick 2.6
- \printuntil import QtQuick.Controls 2.0
+ \printuntil import QtQuick.Controls 2.1
\skipto ToolTip
\printuntil }
\printuntil }
@@ -747,4 +782,13 @@
\image qtquickcontrols2-tumbler-custom.png
\snippet qtquickcontrols2-tumbler-custom.qml file
+
+ If you want to define your own contentItem, use either a \l ListView or
+ \l PathView as the root item. For a wrapping Tumbler, use PathView:
+
+ \snippet qtquickcontrols2-tumbler-pathView.qml contentItem
+
+ For a non-wrapping Tumbler, use ListView:
+
+ \snippet qtquickcontrols2-tumbler-listView.qml contentItem
*/
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc
index a85890f5..01429b94 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc
@@ -115,14 +115,14 @@
\row
\li Can be used on Desktop
\li Yes
- \li Yes \sup 3
+ \li Yes
\row
\li Can be used on Mobile
- \li Yes \sup 4
+ \li Yes \sup 3
\li Yes
\row
\li Can be used on Embedded
- \li Yes \sup 4
+ \li Yes \sup 3
\li Yes
\row
\li Internal event handling
@@ -133,7 +133,6 @@
\list 1
\li Not officially supported, but technically possible via private APIs
\li Only themes for specific styles can be changed at runtime, styles are fixed
- \li No hover effects
\li Performance may not be optimal
\endlist
@@ -186,185 +185,487 @@
This works with both modules, and will reduce the amount of work needed
when the migration begins.
- \section3 Type Comparison Table
+ \section2 Type Comparison Table
+
+ The first column lists all types available in \l {Qt Quick Controls}
+ {Qt Quick Controls 1}, \l {Qt Quick Dialogs}, and \l {Qt Quick Extras}.
+ The second column documents the respective type in Qt Quick Controls 2.
+ When a direct alternative is not available, the third column contains
+ an alternative that provides related functionality. The last column
+ contains some remarks about the differences between the types in the
+ different modules.
\table
\header
- \li Qt Quick Controls 1, Qt Quick Extras
- \li Qt Quick Controls 2, Qt Labs Calendar
- \row
- \li \mdash
- \li \l [QML QtQuickControls2] {AbstractButton}
+ \li Qt Quick Controls 1
+ \li Qt Quick Controls 2
+ \li Alternatives
+ \li Remarks
\row
\li \l [QML QtQuickControls] {Action}
- \li \span {} {\mdash \nbsp \sub {(see \l [QML QtQuick] {Shortcut} instead)}}
+ \li \mdash
+ \li \l [QML QtQuick] {Shortcut} \br\sup {(Qt Quick)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c Action is an abstract user interface
+ action that is bound to buttons and menu items, and can provide
+ shortcuts.
+ \li \b {Qt Quick}: \c Shortcut provides the shortcut functionality that
+ was previously only provided by \c Action.
+ \endlist
\row
\li \l [QML QtQuickControls] {ApplicationWindow}
\li \l [QML QtQuickControls2] {ApplicationWindow}
+ \li
+ \li
\row
\li \l [QML QtQuickControls] {BusyIndicator}
\li \l [QML QtQuickControls2] {BusyIndicator}
+ \li
+ \li
\row
\li \l [QML QtQuickControls] {Button}
\li \l [QML QtQuickControls2] {Button}
+ \li
+ \li
\row
- \li \l [QML QtQuickExtras] {CircularGauge}
+ \li \l [QML QtQuickControls] {Calendar}
\li \mdash
+ \li \l [QML QtLabsCalendar] {MonthGrid},\br
+ \l [QML QtLabsCalendar] {DayOfWeekRow},\br
+ \l [QML QtLabsCalendar] {WeekNumberColumn} \br\sup {(Qt Labs Calendar)}
+ \li \list
+ \li \b {Qt Labs Calendar}: \c MonthGrid, \c DayOfWeek, and \c WeekNumberColumn
+ are \e experimental unstyled building blocks for calendar views.
+ \endlist
\row
+ \li \l [QML QtQuickControls] {CheckBox}
+ \li \l [QML QtQuickControls2] {CheckBox}
+ \li
+ \li
+ \row
+ \li \l [QML QtQuickControls] {ComboBox}
+ \li \l [QML QtQuickControls2] {ComboBox}
+ \li
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c ComboBox is not editable.
+ \endlist
+ \row
+ \li \l [QML QtQuickControls] {ExclusiveGroup}
\li \mdash
- \li \l [QML QtQuickControls2] {Control}
+ \li \l [QML QtQuickControls2] {ButtonGroup} \br\sup {(Qt Quick Controls 2)}
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c ButtonGroup offers similar functionality.
+ \endlist
+ \row
+ \li \l [QML QtQuickControls] {GroupBox}
+ \li \l [QML QtQuickControls2] {GroupBox}
+ \li
+ \li
\row
+ \li \l [QML QtQuickControls] {Label}
+ \li \l [QML QtQuickControls2] {Label}
+ \li
+ \li
+ \row
+ \li \l [QML QtQuickControls] {Menu}
+ \li \l [QML QtQuickControls2] {Menu}
+ \li \l [QML QtLabsPlatform] {Menu} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c Menu is native on platforms where an
+ implementation is available in the Qt Platform Abstraction Layer.
+ Other platforms use a QML-based top-level menu popup window. \c Menu
+ supports traditional desktop style cascading submenus, but does not
+ work on Embedded Linux because \l EGLFS does not support multiple
+ top-level windows.
+ \li \b {Qt Quick Controls 2}: \c Menu is a non-native \c Item-based popup
+ that is stacked above the application content. Due to this, menu popups
+ are restricted within window boundaries. \c Menu is fully customizable
+ using QML and Qt Quick, and allows adding any \c Items. Traditional
+ desktop oriented features, such as cascading submenus and visualizing
+ keyboard shortcuts are missing.
+ \li \b {Qt Labs Platform}: \c Menu is an \e experimental native menu that
+ uses Qt Widgets as a fallback on platforms where a native implementation
+ is not available in the Qt Platform Abstraction Layer.
+ \endlist
+ \row
+ \li \l [QML QtQuickControls] {MenuBar}
\li \mdash
- \li \l [QML QtQuickControls2] {Container}
+ \li \l [QML QtLabsPlatform] {MenuBar} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c MenuBar is native on platforms where an
+ implementation is available in the Qt Platform Abstraction Layer. Other
+ platforms use a QML-based menubar item stacked at the top of the window.
+ \li \b {Qt Labs Platform}: \c MenuBar is an \e experimental native menubar.
+ It is only available on platforms where a native implementation is available
+ in the Qt Platform Abstraction Layer.
+ \endlist
+ \row
+ \li \l [QML QtQuickControls] {MenuItem},\br
+ \l [QML QtQuickControls] {MenuSeparator}
+ \li \l [QML QtQuickControls2] {MenuItem},\br
+ \l [QML QtQuickControls2] {MenuSeparator}
+ \li \l [QML QtLabsPlatform] {MenuItem},\br
+ \l [QML QtLabsPlatform] {MenuSeparator} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c MenuItem and \c MenuSeparator are native
+ on platforms where an implementation is available in the Qt Platform
+ Abstraction Layer. Other platforms use QML-based menu items and separators.
+ \li \b {Qt Quick Controls 2}: \c MenuItem and \c MenuSeparator are a non-native
+ QML-based menu items and separators that can be fully customized using QML
+ and Qt Quick.
+ \li \b {Qt Labs Platform}: \c MenuItem and \c MenuSeparator are \e experimental
+ native menu items and separators.
+ \endlist
\row
- \li \l [QML QtQuickControls] {Calendar}
- \li \l [QML QtLabsCalendar] {MonthGrid},
- \l [QML QtLabsCalendar] {DayOfWeekRow},
- \l [QML QtLabsCalendar] {WeekNumberColumn}
+ \li \l [QML QtQuickControls] {ProgressBar}
+ \li \l [QML QtQuickControls2] {ProgressBar}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {CheckBox}
- \li \l [QML QtQuickControls2] {CheckBox}
+ \li \l [QML QtQuickControls] {RadioButton}
+ \li \l [QML QtQuickControls2] {RadioButton}
+ \li
+ \li
\row
+ \li \l [QML QtQuickControls] {ScrollView}
\li \mdash
- \li \l [QML QtQuickControls2] {CheckDelegate}
+ \li \l [QML QtQuickControls2] {ScrollBar},\br
+ \l [QML QtQuickControls2] {ScrollIndicator} \br\sup {(Qt Quick Controls 2)}
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c ScrollBar and \c ScrollIndicator offer
+ similar functionality. They can be attached to any \c Flickable to
+ build scrollable views.
+ \endlist
\row
- \li \l [QML QtQuickControls] {ComboBox}
- \li \l [QML QtQuickControls2] {ComboBox}
+ \li \l [QML QtQuickControls] {Slider}
+ \li \l [QML QtQuickControls2] {Slider}
+ \li
+ \li
\row
- \li \l [QML QtQuickExtras] {DelayButton}
+ \li \l [QML QtQuickControls] {SpinBox}
+ \li \l [QML QtQuickControls2] {SpinBox}
+ \li
+ \li
+ \row
+ \li \l [QML QtQuickControls] {SplitView}
\li \mdash
+ \li
+ \li
\row
- \li \l [QML QtQuickExtras] {Dial}
- \li \l [QML QtQuickControls2] {Dial}
+ \li \l [QML QtQuickControls] {StackView},\br
+ \l [QML QtQuickControls] {StackViewDelegate},\br
+ \l [QML QtQuickControls] {Stack}
+ \li \l [QML QtQuickControls2] {StackView}
+ \li
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c StackView provides customizable transitions
+ and attached properties via a single \c StackView type.
+ \endlist
\row
+ \li \l [QML QtQuickControls] {StatusBar}
\li \mdash
- \li \l [QML QtQuickControls2] {Drawer}
+ \li \l [QML QtQuickControls2] {ToolBar} \br\sup {(Qt Quick Controls 2)}
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c ApplicationWindow allows assigning any
+ item or control, such as \c ToolBar, as a header or footer.
+ \endlist
\row
- \li \l [QML QtQuickControls] {ExclusiveGroup}
- \li \l [QML QtQuickControls2] {ButtonGroup}
+ \li \l [QML QtQuickControls] {Switch}
+ \li \l [QML QtQuickControls2] {Switch}
+ \li
+ \li
\row
+ \li \l [QML QtQuickControls] {TabView},\br
+ \l [QML QtQuickControls] {Tab}
\li \mdash
- \li \l [QML QtQuickControls2] {Frame}
+ \li \l [QML QtQuickControls2] {TabBar},\br
+ \l [QML QtQuickControls2] {TabButton} \br\sup {(Qt Quick Controls 2)}
+ \li \list
+ \li \b {Qt Quick Controls 2}: \c TabBar and \c TabButton offer similar
+ functionality, and can be used to build tabbed views.
+ \endlist
\row
- \li \l [QML QtQuickExtras] {Gauge}
+ \li \l [QML QtQuickControls] {TableView}
\li \mdash
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {GroupBox}
- \li \l [QML QtQuickControls2] {GroupBox}
+ \li \l [QML QtQuickControls] {TextArea}
+ \li \l [QML QtQuickControls2] {TextArea}
+ \li
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c TextArea inherits \c ScrollView and is therefore
+ always a scrollable editor.
+ \li \b {Qt Quick Controls 2}: \c TextArea is a simpler multi-line editor that can
+ be optionally attached to a \c Flickable to provide scrolling functionality.
+ This allows using \c TextArea in a scrollable page without having two nested
+ scrollable areas, which can be problematic and cause usability issues.
+ \endlist
\row
- \li \mdash
- \li \l [QML QtQuickControls2] {ItemDelegate}
+ \li \l [QML QtQuickControls] {TextField}
+ \li \l [QML QtQuickControls2] {TextField}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {Label}
- \li \l [QML QtQuickControls2] {Label}
+ \li \l [QML QtQuickControls] {ToolBar}
+ \li \l [QML QtQuickControls2] {ToolBar}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {Menu}
- \li \l [QML QtQuickControls2] {Menu}
+ \li \l [QML QtQuickControls] {ToolButton}
+ \li \l [QML QtQuickControls2] {ToolButton}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {MenuBar}
+ \li \l [QML QtQuickControls] {TreeView}
\li \mdash
+ \li
+ \li
+
+ \header
+ \li Qt Quick Dialogs
+ \li Qt Quick Controls 2
+ \li Alternatives
+ \li Remarks
\row
- \li \l [QML QtQuickControls] {MenuItem}
- \li \l [QML QtQuickControls2] {MenuItem}
+ \li \l [QML QtQuickDialogs] {Dialog}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {Dialog}
+ \li \list
+ \li \b {Qt Quick Dialogs}: \c Dialog is either a top-level window or an \c Item-based popup
+ depending on whether the underlying platform supports multiple top-level windows.
+ \li \b {Qt Quick Controls 2}: \c Dialog is not a top-level window, but an \c Item-based
+ popup that is stacked above the application content. Due to this, dialogs are restricted
+ within window boundaries.
+ \endlist
+ \row
+ \li \l [QML QtQuickDialogs] {ColorDialog},\br
+ \l [QML QtQuickDialogs] {FileDialog},\br
+ \l [QML QtQuickDialogs] {FontDialog},\br
+ \l [QML QtQuickDialogs] {MessageDialog}
+ \li \mdash
+ \li \l [QML QtLabsPlatform] {ColorDialog},\br
+ \l [QML QtLabsPlatform] {FileDialog},\br
+ \l [QML QtLabsPlatform] {FolderDialog},\br
+ \l [QML QtLabsPlatform] {FontDialog},\br
+ \l [QML QtLabsPlatform] {MessageDialog} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Quick Dialogs}: Dialogs are native on platforms where an implementation
+ is available in the Qt Platform Abstraction Layer. Other platforms use either
+ Qt Widgets or QML-based dialogs depending on whether the underlying platform
+ supports multiple top-level windows.
+ \li \b {Qt Labs Platform}: \e Experimental native dialogs that use Qt Widgets as
+ a fallback on platforms where a native implementation is not available in the
+ Qt Platform Abstraction Layer.
+ \endlist
+
+ \header
+ \li Qt Quick Extras
+ \li Qt Quick Controls 2
+ \li Alternatives
+ \li Remarks
\row
+ \li \l [QML QtQuickExtras] {CircularGauge}
\li \mdash
- \li \l [QML QtQuickControls2] {Page}
+ \li
+ \li
\row
+ \li \l [QML QtQuickExtras] {DelayButton}
\li \mdash
- \li \l [QML QtQuickControls2] {PageIndicator}
+ \li
+ \li
\row
+ \li \l [QML QtQuickExtras] {Dial}
+ \li \l [QML QtQuickControls2] {Dial}
+ \li
+ \li
+ \row
+ \li \l [QML QtQuickExtras] {Gauge}
\li \mdash
- \li \l [QML QtQuickControls2] {Pane}
+ \li
+ \li
\row
\li \l [QML QtQuickExtras] {Picture}
\li \mdash
+ \li
+ \li
\row
\li \l [QML QtQuickExtras] {PieMenu}
\li \mdash
+ \li
+ \li
\row
+ \li \l [QML QtQuickExtras] {StatusIndicator}
\li \mdash
- \li \l [QML QtQuickControls2] {Popup}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {ProgressBar}
- \li \l [QML QtQuickControls2] {ProgressBar}
+ \li \l [QML QtQuickExtras] {ToggleButton}
+ \li \mdash
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {RadioButton}
- \li \l [QML QtQuickControls2] {RadioButton}
+ \li \l [QML QtQuickExtras] {Tumbler},\br
+ \l [QML QtQuickExtras] {TumblerColumn}
+ \li \l [QML QtQuickControls2] {Tumbler}
+ \li
+ \li \list
+ \li \b {Qt Quick Extras}: \c Tumbler can consist of multiple columns.
+ \li \b {Qt Quick Controls 2}: \c Tumbler presents a single spinnable wheel.
+ Multiple columns can be created by placing multiple \c Tumblers next
+ to each other.
+ \endlist
+
+ \header
+ \li No Predecessor
+ \li Qt Quick Controls 2
+ \li Alternatives
+ \li Remarks
\row
\li \mdash
- \li \l [QML QtQuickControls2] {RadioDelegate}
+ \li \l [QML QtQuickControls2] {AbstractButton}
+ \li
+ \li
\row
\li \mdash
- \li \l [QML QtQuickControls2] {RangeSlider}
+ \li \l [QML QtQuickControls2] {ButtonGroup}
+ \li \l [QML QtQuickControls] {ExclusiveGroup} \br\sup {(Qt Quick Controls 1)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c ExclusiveGroup offers similar functionality.
+ \endlist
\row
- \li \l [QML QtQuickControls] {ScrollView}
- \li \l [QML QtQuickControls2] {ScrollBar},
- \l [QML QtQuickControls2] {ScrollIndicator}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {CheckDelegate}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {Slider}
- \li \l [QML QtQuickControls2] {Slider}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {Container}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {SplitView}
\li \mdash
+ \li \l [QML QtQuickControls2] {Control}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {SpinBox}
- \li \l [QML QtQuickControls2] {SpinBox}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {Drawer}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {StackView},
- \l [QML QtQuickControls] {StackViewDelegate},
- \l [QML QtQuickControls] {Stack}
- \li \l [QML QtQuickControls2] {StackView}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {Frame}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {StatusBar}
\li \mdash
+ \li \l [QML QtQuickControls2] {ItemDelegate}
+ \li
+ \li
\row
- \li \l [QML QtQuickExtras] {StatusIndicator}
\li \mdash
+ \li \l [QML QtQuickControls2] {Page}
+ \li
+ \li
\row
\li \mdash
- \li \l [QML QtQuickControls2] {SwipeDelegate}
+ \li \l [QML QtQuickControls2] {PageIndicator}
+ \li
+ \li
\row
\li \mdash
- \li \l [QML QtQuickControls2] {SwipeView}
+ \li \l [QML QtQuickControls2] {Pane}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {Switch}
- \li \l [QML QtQuickControls2] {Switch}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {Popup}
+ \li
+ \li
\row
\li \mdash
- \li \l [QML QtQuickControls2] {SwitchDelegate}
+ \li \l [QML QtQuickControls2] {RadioDelegate}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {TabView},
- \l [QML QtQuickControls] {Tab}
- \li \l [QML QtQuickControls2] {TabBar},
- \l [QML QtQuickControls2] {TabButton}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {RangeSlider}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {TableView}
\li \mdash
+ \li \l [QML QtQuickControls2] {RoundButton}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {TextArea}
- \li \l [QML QtQuickControls2] {TextArea}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {ScrollBar},\br
+ \l [QML QtQuickControls2] {ScrollIndicator}
+ \li \l [QML QtQuickControls] {ScrollView} \br\sup {(Qt Quick Controls 1)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c ScrollView offers similar functionality.
+ It combines horizontal and vertical scrollbars, and the background and
+ frame around the scrollable view.
+ \endlist
\row
- \li \l [QML QtQuickControls] {TextField}
- \li \l [QML QtQuickControls2] {TextField}
+ \li \mdash
+ \li \mdash
+ \li \l [QML QtLabsPlatform] {StandardPaths} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Quick Dialogs}: \c FileDialog offers a shortcut property that can be used
+ to access the most common standard paths.
+ \li \b {Qt Labs Platform}: \c StandardPaths offers a separate type to give full access
+ to the standard paths.
+ \endlist
\row
- \li \l [QML QtQuickExtras] {ToggleButton}
\li \mdash
+ \li \l [QML QtQuickControls2] {SwipeDelegate}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {ToolBar}
- \li \l [QML QtQuickControls2] {ToolBar}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {SwipeView}
+ \li
+ \li
\row
- \li \l [QML QtQuickControls] {ToolButton}
- \li \l [QML QtQuickControls2] {ToolButton}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {SwitchDelegate}
+ \li
+ \li
\row
\li \mdash
- \li \l [QML QtQuickControls2] {ToolTip}
+ \li \mdash
+ \li \l [QML QtLabsPlatform] {SystemTrayIcon} \br\sup {(Qt Labs Platform)}
+ \li \list
+ \li \b {Qt Labs Platform}: \c SystemTrayIcon is an \e experimental native
+ system tray icon that uses Qt Widgets as a fallback on platforms where
+ a native implementation is not available in the Qt Platform Abstraction
+ Layer.
+ \endlist
\row
- \li \l [QML QtQuickControls] {TreeView}
\li \mdash
+ \li \l [QML QtQuickControls2] {TabBar},\br
+ \l [QML QtQuickControls2] {TabButton}
+ \li \l [QML QtQuickControls] {TabView} \br\sup {(Qt Quick Controls 1)}
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c TabView offers similar functionality.
+ It combines the tab bar, background and frame around the tabs.
+ \endlist
\row
- \li \l [QML QtQuickExtras] {Tumbler},
- \l [QML QtQuickExtras] {TumblerColumn}
- \li \l [QML QtQuickControls2] {Tumbler}
+ \li \mdash
+ \li \l [QML QtQuickControls2] {ToolSeparator}
+ \li
+ \li
+ \row
+ \li \mdash
+ \li \l [QML QtQuickControls2] {ToolTip}
+ \li
+ \li \list
+ \li \b {Qt Quick Controls 1}: \c Button and \c Action have built-in
+ Qt Widgets-based tooltips.
+ \li \b {Qt Quick Controls 2}: \c ToolTip can be attached to any \c Item.
+ \endlist
\endtable
\section1 Related Information
@@ -374,5 +675,7 @@
\li \l{Qt Quick Controls 2 QML Types}
\li \l{Qt Quick Controls QML Types}
\li \l{Qt Quick Extras QML Types}
+ \li \l{Qt Labs Calendar QML Types}
+ \li \l{Qt Labs Platform QML Types}
\endlist
*/
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc
index 7c1b1c16..c83adf4b 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc
@@ -43,10 +43,18 @@
The value can be either one of the built-in styles, for example \c "Material",
or the path to a custom style such as \c ":/mystyle".
\row
+ \li \c QT_QUICK_CONTROLS_FALLBACK_STYLE
+ \li Specifies a fallback style for \l {Creating a Custom Style}{custom styles}.
+ The value can be one of the built-in styles, for example \c "Material",
+ \row
\li \c QT_QUICK_CONTROLS_CONF
\li Specifies the location of the \l {Qt Quick Controls 2 configuration file}.
By default, the configuration file is loaded from the application's
resources in \c ":/qtquickcontrols2.conf".
+ \row
+ \li \c QT_QUICK_CONTROLS_HOVER_ENABLED
+ \li Specifies whether Qt Quick Controls 2 use \l {Control::hoverEnabled}{hover effects}.
+ The value can be set to \c 0 or \c 1 to disable or enable hover effects, respectively.
\endtable
\l {Material style} specific environment variables:
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
index 86df60c7..a132c6f0 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
@@ -62,7 +62,7 @@
\code
// main.qml
import QtQuick 2.6
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
id: window
@@ -81,7 +81,7 @@
\code
// CustomButton.qml
import QtQuick 2.6
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
Button {
id: control
@@ -103,8 +103,8 @@
// +material/CustomButton.qml
import QtQuick 2.6
import QtGraphicalEffects 1.0
- import QtQuick.Controls 2.0
- import QtQuick.Controls.Material 2.0
+ import QtQuick.Controls 2.1
+ import QtQuick.Controls.Material 2.1
Button {
id: control
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-gettingstarted.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-gettingstarted.qdoc
index 4661e8c9..7eb9eaf4 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-gettingstarted.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-gettingstarted.qdoc
@@ -31,7 +31,22 @@
A basic example of a QML file that makes use of controls is shown here:
- \snippet basic-example.qml 0
+ \qml
+ import QtQuick 2.6
+ import QtQuick.Controls 2.1
+
+ ApplicationWindow {
+ title: "My Application"
+ width: 640
+ height: 480
+ visible: true
+
+ Button {
+ text: "Push Me"
+ anchors.centerIn: parent
+ }
+ }
+ \endqml
\section1 Setting Up Controls from C++
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
index cdb20a27..d3f3ec52 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc
@@ -32,7 +32,8 @@
\brief Provides a set of UI controls for Qt Quick.
Qt Quick Controls 2 provides a set of controls that can be used
- to build complete interfaces in Qt Quick.
+ to build complete interfaces in Qt Quick. The module was introduced
+ in Qt 5.7.
\section1 Prerequisites
@@ -40,7 +41,7 @@
application using the following import statement in your \c {.qml} file:
\code
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
\endcode
The \l{Qt Quick Controls 2 C++ Classes}{C++ classes} can be included into
@@ -85,6 +86,7 @@
\list
\li \l{Qt Quick Controls 2 - Gallery}{Gallery}
\li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat Tutorial}
+ \li \l{Qt Quick Controls 2 - Text Editor}{Text Editor}
\li \l{Qt Quick Controls 2 Examples}{All Examples}
\endlist
@@ -95,5 +97,6 @@
\li \l{Qt Quick Layouts}
\li \l{Qt Quick Templates 2}
\li \l{Qt Labs Calendar}
+ \li \l{Qt Labs Platform}
\endlist
*/
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc
index 9842fee6..d841c46d 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc
@@ -32,7 +32,7 @@
The Material Style is based on the Google Material Design Guidelines.
\l{detailed-desc-material}{More...}
- \styleimport {QtQuick.Controls.Material 2.0} {Qt 5.7}
+ \styleimport {QtQuick.Controls.Material 2.1} {Qt 5.7}
\section1 Attached Properties
@@ -89,8 +89,8 @@
\li
\qml
import QtQuick 2.0
- import QtQuick.Controls 2.0
- import QtQuick.Controls.Material 2.0
+ import QtQuick.Controls 2.1
+ import QtQuick.Controls.Material 2.1
ApplicationWindow {
visible: true
@@ -328,6 +328,11 @@
Available themes:
\value Material.Light Light theme (default)
\value Material.Dark Dark theme
+ \value Material.System System theme
+
+ Setting the theme to \c System chooses either the light or dark theme based
+ on the system theme colors. However, when reading the value of the theme
+ property, the value is never \c System, but the actual theme.
In the following example, the theme for both the pane and the button is set
to \c Material.Dark:
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc
index 52da41a7..2add71b2 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \qmlmodule QtQuick.Controls 2.0
+ \qmlmodule QtQuick.Controls 2.1
\title Qt Quick Controls 2 QML Types
\ingroup qmlmodules
\brief Provides QML types for user interfaces (Qt Quick Controls 2).
@@ -39,7 +39,7 @@
using the following import statement in your .qml file:
\badcode
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
\endcode
\section1 QML Types
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc
new file mode 100644
index 00000000..c4ef1c76
--- /dev/null
+++ b/src/imports/controls/doc/src/qtquickcontrols2-separators.qdoc
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtquickcontrols2-separators.html
+ \title Separator Controls
+ \ingroup qtquickcontrols2-guidelines
+ \brief Guidelines for separator controls
+
+ Qt Quick Controls 2 offers a selection of separators.
+
+ \annotatedlist qtquickcontrols2-separators
+
+ Each type of separator has its own specific use case. The following
+ sections offer guidelines for choosing the appropriate type of separator,
+ depending on the use case.
+
+ \section1 MenuSeparator Control
+
+ \image qtquickcontrols2-menuseparator.png
+
+ \l MenuSeparator should be used to separate items (typically MenuItem
+ controls) in a Menu. Grouping related menu items together makes it easier
+ for the user to interact with the menu. For example, a typical desktop
+ user interface might have \c Undo and \c Redo items in one group, and
+ \c Cut, \c Copy and \c Paste in another.
+
+ \section1 ToolSeparator Control
+
+ \image qtquickcontrols2-toolseparator.png
+
+ \l ToolSeparator should be used to separate items (typically ToolButton
+ controls) in a ToolBar. It can be used in horizontal or vertical toolbars.
+
+ \section1 Related Information
+ \list
+ \li \l {Qt Quick Controls 2 Guidelines}
+ \endlist
+*/
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc
index c0e2daee..104c682f 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc
@@ -32,7 +32,7 @@
The Universal Style is based on the Microsoft Universal Design Guidelines.
\l {detailed-desc-universal}{More...}
- \styleimport {QtQuick.Controls.Universal 2.0} {Qt 5.7}
+ \styleimport {QtQuick.Controls.Universal 2.1} {Qt 5.7}
\section1 Attached Properties
@@ -88,8 +88,8 @@
\li
\qml
import QtQuick 2.0
- import QtQuick.Controls 2.0
- import QtQuick.Controls.Universal 2.0
+ import QtQuick.Controls 2.1
+ import QtQuick.Controls.Universal 2.1
ApplicationWindow {
visible: true
@@ -241,6 +241,11 @@
Available themes:
\value Universal.Light Light theme (default)
\value Universal.Dark Dark theme
+ \value Universal.System System theme
+
+ Setting the theme to \c System chooses either the light or dark theme based
+ on the system theme colors. However, when reading the value of the theme
+ property, the value is never \c System, but the actual theme.
In the following example, the theme for both the pane and the button is set
to \c Universal.Dark:
diff --git a/src/imports/controls/material/ApplicationWindow.qml b/src/imports/controls/material/ApplicationWindow.qml
index db27f25b..0a6b71a3 100644
--- a/src/imports/controls/material/ApplicationWindow.qml
+++ b/src/imports/controls/material/ApplicationWindow.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
import QtQuick.Window 2.2
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.ApplicationWindow {
id: window
diff --git a/src/imports/controls/material/BoxShadow.qml b/src/imports/controls/material/BoxShadow.qml
index b70fcee5..4809838e 100644
--- a/src/imports/controls/material/BoxShadow.qml
+++ b/src/imports/controls/material/BoxShadow.qml
@@ -34,10 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtGraphicalEffects 1.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
-/*!
+/*
A implementation of CSS's box-shadow, used by ElevationEffect for a Material Design
elevation shadow effect.
*/
diff --git a/src/imports/controls/material/BusyIndicator.qml b/src/imports/controls/material/BusyIndicator.qml
index 387ffb71..3077ceb7 100644
--- a/src/imports/controls/material/BusyIndicator.qml
+++ b/src/imports/controls/material/BusyIndicator.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.BusyIndicator {
id: control
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml
index f2fad313..9b3ced25 100644
--- a/src/imports/controls/material/Button.qml
+++ b/src/imports/controls/material/Button.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Button {
id: control
@@ -62,7 +62,7 @@ T.Button {
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
control.flat && control.highlighted ? control.Material.accentColor :
- control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.primaryTextColor
+ control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@@ -78,16 +78,19 @@ T.Button {
width: parent.width
height: parent.height - 12
radius: 2
- color: !control.enabled
- ? control.Material.buttonDisabledColor
- : control.down
- ? control.highlighted ? control.Material.highlightedButtonPressColor
- : control.Material.buttonPressColor
- : control.visualFocus || control.checked
- ? control.highlighted ? control.Material.highlightedButtonHoverColor
- : control.Material.buttonHoverColor
- : control.highlighted ? control.Material.highlightedButtonColor
- : control.Material.buttonColor
+ color: !control.enabled ? control.Material.buttonDisabledColor :
+ control.highlighted ? control.Material.highlightedButtonColor : control.Material.buttonColor
+
+ PaddedRectangle {
+ y: parent.height - 4
+ width: parent.width
+ height: 4
+ radius: 2
+ topPadding: -2
+ clip: true
+ visible: control.checkable && (!control.highlighted || control.flat)
+ color: control.checked && control.enabled ? control.Material.accentColor : control.Material.secondaryTextColor
+ }
Behavior on color {
ColorAnimation {
@@ -102,5 +105,15 @@ T.Button {
layer.effect: ElevationEffect {
elevation: control.Material.elevation
}
+
+ Ripple {
+ clipRadius: 2
+ width: parent.width
+ height: parent.height
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml
index 1c6848d8..979654f7 100644
--- a/src/imports/controls/material/CheckBox.qml
+++ b/src/imports/controls/material/CheckBox.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.CheckBox {
id: control
@@ -58,6 +58,18 @@ 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
control: control
+
+ Ripple {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 28; height: 28
+
+ z: -1
+ anchor: control
+ pressed: control.pressed
+ active: control.down || control.visualFocus || control.hovered
+ color: control.checked ? control.Material.highlightedRippleColor : control.Material.rippleColor
+ }
}
contentItem: Text {
@@ -66,7 +78,7 @@ T.CheckBox {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/CheckDelegate.qml b/src/imports/controls/material/CheckDelegate.qml
index d5785467..aec48bf1 100644
--- a/src/imports/controls/material/CheckDelegate.qml
+++ b/src/imports/controls/material/CheckDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.CheckDelegate {
id: control
@@ -66,7 +66,7 @@ T.CheckDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -76,7 +76,17 @@ T.CheckDelegate {
background: Rectangle {
implicitHeight: 48
- visible: control.down || control.highlighted
- color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor
+ color: control.highlighted ? control.Material.listHighlightColor : "transparent"
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/CheckIndicator.qml b/src/imports/controls/material/CheckIndicator.qml
index f64ca168..afc19bc2 100644
--- a/src/imports/controls/material/CheckIndicator.qml
+++ b/src/imports/controls/material/CheckIndicator.qml
@@ -34,8 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
Rectangle {
id: indicatorItem
@@ -46,7 +47,7 @@ Rectangle {
border.width: control.checked ? width / 2 : 2
radius: 2
- property alias control: ripple.control
+ property Item control
Behavior on border.width {
NumberAnimation {
@@ -62,15 +63,6 @@ Rectangle {
}
}
- Ripple {
- id: ripple
- width: parent.width
- height: width
- control: control
- colored: control.checked
- opacity: control.down || control.visualFocus ? 1 : 0
- }
-
// TODO: This needs to be transparent
Image {
id: checkImage
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index 183bcef9..15987ebc 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -34,18 +34,16 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.ComboBox {
id: control
- Material.elevation: control.pressed ? 8 : 2
-
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
@@ -59,21 +57,23 @@ T.ComboBox {
leftPadding: padding - 4
rightPadding: padding - 4
- // Don't use toolTextColor, as that is often white when we have a white background.
- Material.foreground: Material.foreground === Material.toolTextColor ? undefined : Material.foreground
+ Material.elevation: flat ? control.pressed || control.hovered ? 2 : 0
+ : control.pressed ? 8 : 2
+ Material.background: flat ? "transparent" : undefined
+ Material.foreground: flat ? undefined : Material.primaryTextColor
delegate: MenuItem {
width: control.popup.width
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
- Material.foreground: control.currentIndex === index ? control.Material.accent : control.Material.foreground
+ Material.foreground: control.currentIndex === index ? control.popup.Material.accent : control.popup.Material.foreground
highlighted: control.highlightedIndex === index
+ hoverEnabled: control.hoverEnabled
}
indicator: Image {
x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2
- opacity: !control.enabled ? 0.5 : 1.0
- source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Material/images/drop-indicator.png"
+ source: "image://material/drop-indicator/" + (control.enabled ? control.Material.foreground : control.Material.hintTextColor)
}
contentItem: Text {
@@ -82,7 +82,7 @@ T.ComboBox {
text: control.displayText
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
@@ -95,7 +95,7 @@ T.ComboBox {
// external vertical padding is 6 (to increase touch area)
y: 6
height: parent.height - 12
- radius: 2
+ radius: control.flat ? 0 : 2
color: control.Material.dialogColor
Behavior on color {
@@ -104,17 +104,20 @@ T.ComboBox {
}
}
- layer.enabled: control.enabled && control.Material.elevation > 0
+ layer.enabled: control.enabled && control.Material.background.a > 0
layer.effect: ElevationEffect {
elevation: control.Material.elevation
}
- Rectangle {
+ Ripple {
+ clip: control.flat
+ clipRadius: control.flat ? 0 : 2
width: parent.width
height: parent.height
- radius: parent.radius
- visible: control.visualFocus
- color: control.Material.checkBoxUncheckedRippleColor
+ pressed: control.pressed
+ anchor: control
+ active: control.pressed || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
}
}
@@ -154,7 +157,7 @@ T.ComboBox {
background: Rectangle {
radius: 2
- color: control.Material.dialogColor
+ color: control.popup.Material.dialogColor
layer.enabled: control.enabled
layer.effect: ElevationEffect {
diff --git a/src/imports/controls/material/Dial.qml b/src/imports/controls/material/Dial.qml
index c07cd423..ce76c2a7 100644
--- a/src/imports/controls/material/Dial.qml
+++ b/src/imports/controls/material/Dial.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Dial {
id: control
@@ -55,7 +56,7 @@ T.Dial {
border.color: control.enabled ? control.Material.accentColor : control.Material.hintTextColor
}
- handle: Rectangle {
+ handle: SliderHandle {
id: handleItem
x: background.x + background.width / 2 - handle.width / 2
@@ -72,7 +73,10 @@ T.Dial {
]
implicitWidth: 14
implicitHeight: 14
- radius: width / 2
- color: control.enabled ? control.Material.accentColor : control.Material.hintTextColor
+
+ value: control.value
+ handleHasFocus: control.visualFocus
+ handlePressed: control.pressed
+ handleHovered: control.hovered
}
}
diff --git a/src/imports/controls/material/Dialog.qml b/src/imports/controls/material/Dialog.qml
new file mode 100644
index 00000000..90cda45a
--- /dev/null
+++ b/src/imports/controls/material/Dialog.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
+
+T.Dialog {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0,
+ contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0)
+ + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+
+ padding: 24
+ topPadding: 20
+
+ Material.elevation: 24
+
+ enter: Transition {
+ // grow_fade_in
+ NumberAnimation { property: "scale"; from: 0.9; to: 1.0; easing.type: Easing.OutQuint; duration: 220 }
+ NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.OutCubic; duration: 150 }
+ }
+
+ exit: Transition {
+ // shrink_fade_out
+ NumberAnimation { property: "scale"; from: 1.0; to: 0.9; easing.type: Easing.OutQuint; duration: 220 }
+ NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 }
+ }
+
+ background: Rectangle {
+ radius: 2
+ color: control.Material.dialogColor
+
+ layer.enabled: control.Material.elevation > 0
+ layer.effect: ElevationEffect {
+ elevation: control.Material.elevation
+ }
+ }
+
+ header: Label {
+ text: control.title
+ visible: control.title
+ elide: Label.ElideRight
+ padding: 24
+ bottomPadding: 0
+ // TODO: QPlatformTheme::TitleBarFont
+ font.bold: true
+ font.pixelSize: 16
+ background: PaddedRectangle {
+ radius: 2
+ color: control.Material.dialogColor
+ bottomPadding: -2
+ clip: true
+ }
+ }
+
+ footer: DialogButtonBox {
+ visible: count > 0
+ }
+}
diff --git a/src/imports/controls/material/DialogButtonBox.qml b/src/imports/controls/material/DialogButtonBox.qml
new file mode 100644
index 00000000..312aa4eb
--- /dev/null
+++ b/src/imports/controls/material/DialogButtonBox.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
+
+T.DialogButtonBox {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ spacing: 8
+ padding: 8
+ topPadding: padding - 4
+ bottomPadding: padding - 4
+ alignment: Qt.AlignRight
+
+ Material.foreground: Material.accent
+
+ delegate: Button { flat: true }
+
+ contentItem: ListView {
+ implicitWidth: contentWidth
+ implicitHeight: 48
+
+ model: control.contentModel
+ spacing: control.spacing
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ snapMode: ListView.SnapToItem
+ }
+
+ background: PaddedRectangle {
+ implicitHeight: 52
+ radius: 2
+ color: control.Material.dialogColor
+ topPadding: control.position === T.DialogButtonBox.Footer ? -2 : 0
+ bottomPadding: control.position === T.DialogButtonBox.Header ? -2 : 0
+ clip: true
+ }
+}
diff --git a/src/imports/controls/material/Drawer.qml b/src/imports/controls/material/Drawer.qml
index 1c15e689..7b401b5b 100644
--- a/src/imports/controls/material/Drawer.qml
+++ b/src/imports/controls/material/Drawer.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Drawer {
id: control
@@ -50,17 +50,32 @@ T.Drawer {
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+ topPadding: !dim && edge === Qt.BottomEdge && Material.elevation === 0
+ leftPadding: !dim && edge === Qt.RightEdge && Material.elevation === 0
+ rightPadding: !dim && edge === Qt.LeftEdge && Material.elevation === 0
+ bottomPadding: !dim && edge === Qt.TopEdge && Material.elevation === 0
+
enter: Transition { SmoothedAnimation { velocity: 5 } }
exit: Transition { SmoothedAnimation { velocity: 5 } }
- contentItem: Item { }
+ Material.elevation: 16
background: Rectangle {
color: control.Material.dialogColor
+ Rectangle {
+ readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge
+ width: horizontal ? 1 : parent.width
+ height: horizontal ? parent.height : 1
+ color: control.Material.dividerColor
+ x: control.edge === Qt.LeftEdge ? parent.width - 1 : 0
+ y: control.edge === Qt.TopEdge ? parent.height - 1 : 0
+ visible: !control.dim && control.Material.elevation === 0
+ }
+
layer.enabled: control.position > 0
layer.effect: ElevationEffect {
- elevation: 16
+ elevation: control.Material.elevation
fullHeight: true
}
}
diff --git a/src/imports/controls/material/ElevationEffect.qml b/src/imports/controls/material/ElevationEffect.qml
index 4ee4369c..3cf6623c 100644
--- a/src/imports/controls/material/ElevationEffect.qml
+++ b/src/imports/controls/material/ElevationEffect.qml
@@ -34,27 +34,27 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
-/*!
+/*
An effect for standard Material Design elevation shadows. Useful for using as \c layer.effect.
*/
Item {
id: effect
- /*!
+ /*
The source the effect is applied to.
*/
property var source
- /*!
+ /*
The elevation of the \l source Item.
*/
property int elevation: 0
- /*!
+ /*
Set to \c true if the \l source Item is the same width as its parent and the shadow
should be full width instead of rounding around the corner of the Item.
@@ -62,7 +62,7 @@ Item {
*/
property bool fullWidth: false
- /*!
+ /*
Set to \c true if the \l source Item is the same height as its parent and the shadow
should be full height instead of rounding around the corner of the Item.
@@ -70,7 +70,7 @@ Item {
*/
property bool fullHeight: false
- /*!
+ /*
\internal
The actual source Item the effect is applied to.
@@ -102,7 +102,7 @@ Item {
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
- /*!
+ /*
\internal
The shadows to use for each possible elevation. There are three shadows that when combined
@@ -210,7 +210,7 @@ Item {
{offset: 9, blur: 46, spread: 8}]
]
- /*!
+ /*
\internal
The current shadow based on the elevation.
diff --git a/src/imports/controls/material/Frame.qml b/src/imports/controls/material/Frame.qml
index c2f623ae..08c01353 100644
--- a/src/imports/controls/material/Frame.qml
+++ b/src/imports/controls/material/Frame.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Frame {
id: control
@@ -50,8 +50,6 @@ T.Frame {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
radius: 2
color: control.Material.elevation > 0 ? control.Material.backgroundColor : "transparent"
diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml
index 6d84197c..64b589af 100644
--- a/src/imports/controls/material/GroupBox.qml
+++ b/src/imports/controls/material/GroupBox.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.GroupBox {
id: control
@@ -54,15 +54,13 @@ T.GroupBox {
padding: 12
topPadding: padding + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
- contentItem: Item {}
-
label: Text {
x: control.leftPadding
width: control.availableWidth
text: control.title
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index e43fc981..ec74fbee 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.ItemDelegate {
id: control
@@ -57,7 +58,7 @@ T.ItemDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -67,7 +68,17 @@ T.ItemDelegate {
background: Rectangle {
implicitHeight: 48
- visible: control.down || control.highlighted
- color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor
+ color: control.highlighted ? control.Material.listHighlightColor : "transparent"
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/Label.qml b/src/imports/controls/material/Label.qml
index 8bda5cc2..3a728dc8 100644
--- a/src/imports/controls/material/Label.qml
+++ b/src/imports/controls/material/Label.qml
@@ -34,13 +34,13 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.Label {
id: control
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
linkColor: Material.accentColor
}
diff --git a/src/imports/controls/material/Menu.qml b/src/imports/controls/material/Menu.qml
index b11c00b6..7fe6af0e 100644
--- a/src/imports/controls/material/Menu.qml
+++ b/src/imports/controls/material/Menu.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Menu {
id: control
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml
index 27c2922c..a6dbba2c 100644
--- a/src/imports/controls/material/MenuItem.qml
+++ b/src/imports/controls/material/MenuItem.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.MenuItem {
id: control
@@ -67,7 +67,7 @@ T.MenuItem {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -77,7 +77,17 @@ T.MenuItem {
background: Rectangle {
implicitWidth: 200
implicitHeight: 48
- visible: control.down || control.highlighted
- color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor
+ color: control.highlighted ? control.Material.listHighlightColor : "transparent"
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/MenuSeparator.qml b/src/imports/controls/material/MenuSeparator.qml
new file mode 100644
index 00000000..76cac31b
--- /dev/null
+++ b/src/imports/controls/material/MenuSeparator.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ topPadding: 8
+ bottomPadding: 8
+
+ contentItem: Rectangle {
+ implicitWidth: 200
+ implicitHeight: 1
+ color: control.Material.dividerColor
+ }
+}
diff --git a/src/imports/controls/material/Page.qml b/src/imports/controls/material/Page.qml
index 92c85b58..c91b16c1 100644
--- a/src/imports/controls/material/Page.qml
+++ b/src/imports/controls/material/Page.qml
@@ -34,14 +34,24 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.Page {
id: control
- contentItem: Item { }
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(contentWidth,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + topPadding + bottomPadding
+ + (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
background: Rectangle {
color: control.Material.backgroundColor
diff --git a/src/imports/controls/material/PageIndicator.qml b/src/imports/controls/material/PageIndicator.qml
index 78372afe..5a68df6b 100644
--- a/src/imports/controls/material/PageIndicator.qml
+++ b/src/imports/controls/material/PageIndicator.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.PageIndicator {
id: control
@@ -54,7 +54,7 @@ T.PageIndicator {
implicitHeight: 8
radius: width / 2
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45
Behavior on opacity { OpacityAnimator { duration: 100 } }
diff --git a/src/imports/controls/material/Pane.qml b/src/imports/controls/material/Pane.qml
index 251492ea..4aedbd40 100644
--- a/src/imports/controls/material/Pane.qml
+++ b/src/imports/controls/material/Pane.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Pane {
id: control
@@ -50,8 +50,6 @@ T.Pane {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
color: control.Material.backgroundColor
radius: control.Material.elevation > 0 ? 2 : 0
diff --git a/src/imports/controls/material/Popup.qml b/src/imports/controls/material/Popup.qml
index 19fd6b79..01b3951a 100644
--- a/src/imports/controls/material/Popup.qml
+++ b/src/imports/controls/material/Popup.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Popup {
id: control
@@ -66,8 +66,6 @@ T.Popup {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.OutCubic; duration: 150 }
}
- contentItem: Item { }
-
background: Rectangle {
radius: 2
color: control.Material.dialogColor
diff --git a/src/imports/controls/material/ProgressBar.qml b/src/imports/controls/material/ProgressBar.qml
index eb8bf3ce..2b78be49 100644
--- a/src/imports/controls/material/ProgressBar.qml
+++ b/src/imports/controls/material/ProgressBar.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.ProgressBar {
id: control
diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml
index 3ea2cf4d..32bf1cbd 100644
--- a/src/imports/controls/material/RadioButton.qml
+++ b/src/imports/controls/material/RadioButton.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.RadioButton {
id: control
@@ -58,6 +58,18 @@ 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
control: control
+
+ Ripple {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 28; height: 28
+
+ z: -1
+ anchor: control
+ pressed: control.pressed
+ active: control.down || control.visualFocus || control.hovered
+ color: control.checked ? control.Material.highlightedRippleColor : control.Material.rippleColor
+ }
}
contentItem: Text {
@@ -66,7 +78,7 @@ T.RadioButton {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/RadioDelegate.qml b/src/imports/controls/material/RadioDelegate.qml
index 95bfb19b..349352b4 100644
--- a/src/imports/controls/material/RadioDelegate.qml
+++ b/src/imports/controls/material/RadioDelegate.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.RadioDelegate {
id: control
@@ -65,7 +66,7 @@ T.RadioDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -75,7 +76,17 @@ T.RadioDelegate {
background: Rectangle {
implicitHeight: 48
- visible: control.down || control.highlighted
- color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor
+ color: control.highlighted ? control.Material.listHighlightColor : "transparent"
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/RadioIndicator.qml b/src/imports/controls/material/RadioIndicator.qml
index 4090c732..b1e19656 100644
--- a/src/imports/controls/material/RadioIndicator.qml
+++ b/src/imports/controls/material/RadioIndicator.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
Rectangle {
implicitWidth: 20
@@ -46,16 +46,7 @@ Rectangle {
border.color: control.checked || control.down ? control.Material.accentColor : control.Material.secondaryTextColor
color: "transparent"
- property alias control: ripple.control
-
- Ripple {
- id: ripple
- width: parent.width
- height: width
- control: control
- colored: control.checked
- opacity: control.down || control.visualFocus ? 1 : 0
- }
+ property Item control
Rectangle {
x: (parent.width - width) / 2
diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml
index dc2c25fa..0233f137 100644
--- a/src/imports/controls/material/RangeSlider.qml
+++ b/src/imports/controls/material/RangeSlider.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.RangeSlider {
id: control
@@ -57,6 +57,7 @@ T.RangeSlider {
value: first.value
handleHasFocus: activeFocus
handlePressed: first.pressed
+ handleHovered: first.hovered
}
second.handle: SliderHandle {
@@ -65,6 +66,7 @@ T.RangeSlider {
value: second.value
handleHasFocus: activeFocus
handlePressed: second.pressed
+ handleHovered: second.hovered
}
background: Rectangle {
@@ -74,7 +76,7 @@ T.RangeSlider {
implicitHeight: horizontal ? 48 : 200
width: horizontal ? control.availableWidth : 1
height: horizontal ? 1 : control.availableHeight
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/material/RectangularGlow.qml b/src/imports/controls/material/RectangularGlow.qml
new file mode 100644
index 00000000..32c10500
--- /dev/null
+++ b/src/imports/controls/material/RectangularGlow.qml
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+/*
+ A cross-graphics API implementation of QtGraphicalEffects' RectangularGlow.
+ */
+Item {
+ id: rootItem
+
+ /*
+ This property defines how many pixels outside the item area are reached
+ by the glow.
+
+ The value ranges from 0.0 (no glow) to inf (infinite glow). By default,
+ the property is set to \c 0.0.
+
+ \table
+ \header
+ \li Output examples with different glowRadius values
+ \li
+ \li
+ \row
+ \li \image RectangularGlow_glowRadius1.png
+ \li \image RectangularGlow_glowRadius2.png
+ \li \image RectangularGlow_glowRadius3.png
+ \row
+ \li \b { glowRadius: 10 }
+ \li \b { glowRadius: 20 }
+ \li \b { glowRadius: 40 }
+ \row
+ \li \l spread: 0
+ \li \l spread: 0
+ \li \l spread: 0
+ \row
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \row
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \endtable
+
+ */
+ property real glowRadius: 0.0
+
+ /*
+ This property defines how large part of the glow color is strenghtened
+ near the source edges.
+
+ The value ranges from 0.0 (no strenght increase) to 1.0 (maximum
+ strenght increase). By default, the property is set to \c 0.0.
+
+ \table
+ \header
+ \li Output examples with different spread values
+ \li
+ \li
+ \row
+ \li \image RectangularGlow_spread1.png
+ \li \image RectangularGlow_spread2.png
+ \li \image RectangularGlow_spread3.png
+ \row
+ \li \b { spread: 0.0 }
+ \li \b { spread: 0.5 }
+ \li \b { spread: 1.0 }
+ \row
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \row
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \row
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \endtable
+ */
+ property real spread: 0.0
+
+ /*
+ This property defines the RGBA color value which is used for the glow.
+
+ By default, the property is set to \c "white".
+
+ \table
+ \header
+ \li Output examples with different color values
+ \li
+ \li
+ \row
+ \li \image RectangularGlow_color1.png
+ \li \image RectangularGlow_color2.png
+ \li \image RectangularGlow_color3.png
+ \row
+ \li \b { color: #ffffff }
+ \li \b { color: #55ff55 }
+ \li \b { color: #5555ff }
+ \row
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \row
+ \li \l spread: 0
+ \li \l spread: 0
+ \li \l spread: 0
+ \row
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \li \l cornerRadius: 25
+ \endtable
+ */
+ property color color: "white"
+
+ /*
+ This property defines the corner radius that is used to draw a glow with
+ rounded corners.
+
+ The value ranges from 0.0 to half of the effective width or height of
+ the glow, whichever is smaller. This can be calculated with: \c{
+ min(width, height) / 2.0 + glowRadius}
+
+ By default, the property is bound to glowRadius property. The glow
+ behaves as if the rectangle was blurred when adjusting the glowRadius
+ property.
+
+ \table
+ \header
+ \li Output examples with different cornerRadius values
+ \li
+ \li
+ \row
+ \li \image RectangularGlow_cornerRadius1.png
+ \li \image RectangularGlow_cornerRadius2.png
+ \li \image RectangularGlow_cornerRadius3.png
+ \row
+ \li \b { cornerRadius: 0 }
+ \li \b { cornerRadius: 25 }
+ \li \b { cornerRadius: 50 }
+ \row
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \li \l glowRadius: 20
+ \row
+ \li \l spread: 0
+ \li \l spread: 0
+ \li \l spread: 0
+ \row
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \li \l color: #ffffff
+ \endtable
+ */
+ property real cornerRadius: glowRadius
+
+ /*
+ This property allows the effect output pixels to be cached in order to
+ improve the rendering performance.
+
+ Every time the source or effect properties are changed, the pixels in
+ the cache must be updated. Memory consumption is increased, because an
+ extra buffer of memory is required for storing the effect output.
+
+ It is recommended to disable the cache when the source or the effect
+ properties are animated.
+
+ By default, the property is set to \c false.
+ */
+ property bool cached: false
+
+ ShaderEffectSource {
+ id: cacheItem
+ anchors.fill: shaderItem
+ visible: rootItem.cached
+ smooth: true
+ sourceItem: shaderItem
+ live: true
+ hideSource: visible
+ }
+
+ ShaderEffect {
+ id: shaderItem
+
+ x: (parent.width - width) / 2.0
+ y: (parent.height - height) / 2.0
+ width: parent.width + rootItem.glowRadius * 2 + cornerRadius * 2
+ height: parent.height + rootItem.glowRadius * 2 + cornerRadius * 2
+
+ function clampedCornerRadius() {
+ var maxCornerRadius = Math.min(rootItem.width, rootItem.height) / 2 + glowRadius;
+ return Math.max(0, Math.min(rootItem.cornerRadius, maxCornerRadius))
+ }
+
+ property color color: rootItem.color
+ property real inverseSpread: 1.0 - rootItem.spread
+ property real relativeSizeX: ((inverseSpread * inverseSpread) * rootItem.glowRadius + cornerRadius * 2.0) / width
+ property real relativeSizeY: relativeSizeX * (width / height)
+ property real spread: rootItem.spread / 2.0
+ property real cornerRadius: clampedCornerRadius()
+
+ fragmentShader: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Material/shaders/RectangularGlow.frag"
+ }
+}
diff --git a/src/imports/controls/material/RoundButton.qml b/src/imports/controls/material/RoundButton.qml
new file mode 100644
index 00000000..f6899dea
--- /dev/null
+++ b/src/imports/controls/material/RoundButton.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
+
+T.RoundButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
+
+ // external vertical padding is 6 (to increase touch area)
+ padding: 12
+
+ Material.elevation: flat ? control.down || control.hovered ? 2 : 0
+ : control.down ? 8 : 2
+ Material.background: flat ? "transparent" : undefined
+
+ contentItem: Text {
+ text: control.text
+ font: control.font
+ color: !control.enabled ? control.Material.hintTextColor :
+ control.flat && control.highlighted ? control.Material.accentColor :
+ control.highlighted ? control.Material.primaryHighlightedTextColor : control.Material.foreground
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ elide: Text.ElideRight
+ }
+
+ // TODO: Add a proper ripple/ink effect for mouse/touch input and focus state
+ background: Rectangle {
+ implicitWidth: 48
+ implicitHeight: 48
+
+ // external vertical padding is 6 (to increase touch area)
+ x: 6
+ y: 6
+ width: parent.width - 12
+ height: parent.height - 12
+ radius: control.radius
+ color: !control.enabled ? control.Material.buttonDisabledColor
+ : control.checked || control.highlighted ? control.Material.highlightedButtonColor : control.Material.buttonColor
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ radius: control.radius
+ visible: control.hovered || control.visualFocus
+ color: control.Material.rippleColor
+ }
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ radius: control.radius
+ visible: control.down
+ color: control.Material.rippleColor
+ }
+
+ Behavior on color {
+ ColorAnimation {
+ duration: 400
+ }
+ }
+
+ // The layer is disabled when the button color is transparent so that you can do
+ // Material.background: "transparent" and get a proper flat button without needing
+ // to set Material.elevation as well
+ layer.enabled: control.enabled && control.Material.buttonColor.a > 0
+ layer.effect: ElevationEffect {
+ elevation: control.Material.elevation
+ }
+ }
+}
diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml
index 84f2d33a..2874f125 100644
--- a/src/imports/controls/material/ScrollBar.qml
+++ b/src/imports/controls/material/ScrollBar.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.ScrollBar {
id: control
@@ -46,33 +46,43 @@ T.ScrollBar {
implicitHeight: Math.max(background ? background.implicitHeight : 0,
contentItem.implicitHeight + topPadding + bottomPadding)
- padding: 2
- topPadding: padding + (control.orientation === Qt.Horizontal ? 12 : 0)
- leftPadding: padding + (control.orientation === Qt.Vertical && !control.mirrored ? 12 : 0)
- rightPadding: padding + (control.orientation === Qt.Vertical && control.mirrored ? 12 : 0)
+ padding: 1
contentItem: Rectangle {
id: handle
- implicitWidth: 4
- implicitHeight: 4
+ implicitWidth: 13
+ implicitHeight: 13
- color: control.pressed ? control.Material.scrollBarPressedColor : control.Material.scrollBarColor
+ color: control.pressed ? control.Material.scrollBarPressedColor :
+ control.hovered ? control.Material.scrollBarHoveredColor : control.Material.scrollBarColor
visible: control.size < 1.0
opacity: 0.0
+ }
- states: State {
- name: "active"
- when: control.active
- PropertyChanges { target: handle; opacity: 0.75 }
- }
+ background: Rectangle {
+ implicitWidth: 16
+ implicitHeight: 16
+ color: "#0e000000"
+ opacity: 0.0
+ }
- transitions: Transition {
+ states: State {
+ name: "active"
+ when: control.active
+ }
+
+ transitions: [
+ Transition {
+ to: "active"
+ NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 1.0 }
+ },
+ Transition {
from: "active"
SequentialAnimation {
- PauseAnimation { duration: 450 }
- NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 }
+ PauseAnimation { duration: 2450 }
+ NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 0.0 }
}
}
- }
+ ]
}
diff --git a/src/imports/controls/material/ScrollIndicator.qml b/src/imports/controls/material/ScrollIndicator.qml
index b5f25d33..3b1dd2c3 100644
--- a/src/imports/controls/material/ScrollIndicator.qml
+++ b/src/imports/controls/material/ScrollIndicator.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.ScrollIndicator {
id: control
diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml
index 15c8edb2..d13797c5 100644
--- a/src/imports/controls/material/Slider.qml
+++ b/src/imports/controls/material/Slider.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.Slider {
id: control
@@ -55,6 +55,7 @@ T.Slider {
value: control.value
handleHasFocus: control.visualFocus
handlePressed: control.pressed
+ handleHovered: control.hovered
}
background: Rectangle {
@@ -64,7 +65,7 @@ T.Slider {
implicitHeight: horizontal ? 48 : 200
width: horizontal ? control.availableWidth : 1
height: horizontal ? 1 : control.availableHeight
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
scale: horizontal && control.mirrored ? -1 : 1
readonly property bool horizontal: control.orientation === Qt.Horizontal
diff --git a/src/imports/controls/material/SliderHandle.qml b/src/imports/controls/material/SliderHandle.qml
index 49f833d0..ba6260e9 100644
--- a/src/imports/controls/material/SliderHandle.qml
+++ b/src/imports/controls/material/SliderHandle.qml
@@ -34,8 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
Item {
id: root
@@ -45,6 +46,7 @@ Item {
property real value: 0
property bool handleHasFocus: false
property bool handlePressed: false
+ property bool handleHovered: false
readonly property int initialSize: 13
readonly property bool horizontal: control.orientation === Qt.Horizontal
readonly property var control: parent
@@ -65,10 +67,11 @@ Item {
}
Ripple {
- width: parent.width
- height: width
- control: root.control
- colored: true
- opacity: root.handleHasFocus && !root.handlePressed ? 1 : 0
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 22; height: 22
+ pressed: root.handlePressed
+ active: root.handlePressed || root.handleHasFocus || root.handleHovered
+ color: control.Material.rippleColor
}
}
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index e28815e8..110032be 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.SpinBox {
id: control
@@ -68,9 +68,9 @@ T.SpinBox {
text: control.textFromValue(control.value, control.locale)
font: control.font
- color: enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: enabled ? control.Material.foreground : control.Material.hintTextColor
selectionColor: control.Material.textSelectionColor
- selectedTextColor: control.Material.primaryTextColor
+ selectedTextColor: control.Material.foreground
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
cursorDelegate: Rectangle {
@@ -101,55 +101,67 @@ T.SpinBox {
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: Qt.ImhDigitsOnly
}
- up.indicator: PaddedRectangle {
+ up.indicator: Item {
x: control.mirrored ? 0 : parent.width - width
implicitWidth: 48
implicitHeight: 48
height: parent.height
width: height
- padding: control.spacing
- radius: 2
- color: Qt.tint(Qt.tint(control.Material.buttonColor,
- control.activeFocus ? control.Material.buttonHoverColor : "transparent"),
- control.up.pressed ? control.Material.buttonPressColor: "transparent")
+
+ Ripple {
+ clipRadius: 2
+ x: control.spacing
+ y: control.spacing
+ width: parent.width - 2 * control.spacing
+ height: parent.height - 2 * control.spacing
+ pressed: control.up.pressed
+ active: control.up.pressed || control.up.hovered || control.visualFocus
+ color: control.Material.rippleColor
+ }
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: Math.min(parent.width / 3, parent.width / 3)
height: 2
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: 2
height: Math.min(parent.width / 3, parent.width / 3)
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
}
- down.indicator: PaddedRectangle {
+ down.indicator: Item {
x: control.mirrored ? parent.width - width : 0
implicitWidth: 48
implicitHeight: 48
height: parent.height
width: height
- padding: control.spacing
- radius: 2
- color: Qt.tint(Qt.tint(control.Material.buttonColor,
- control.activeFocus ? control.Material.buttonHoverColor : "transparent"),
- control.down.pressed ? control.Material.buttonPressColor : "transparent")
+
+ Ripple {
+ clipRadius: 2
+ x: control.spacing
+ y: control.spacing
+ width: parent.width - 2 * control.spacing
+ height: parent.height - 2 * control.spacing
+ pressed: control.down.pressed
+ active: control.down.pressed || control.down.hovered || control.visualFocus
+ color: control.Material.rippleColor
+ }
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
width: parent.width / 3
height: 2
- color: enabled ? control.Material.primaryTextColor : control.Material.spinBoxDisabledIconColor
+ color: enabled ? control.Material.foreground : control.Material.spinBoxDisabledIconColor
}
}
diff --git a/src/imports/controls/material/StackView.qml b/src/imports/controls/material/StackView.qml
index 982a37cb..916e910f 100644
--- a/src/imports/controls/material/StackView.qml
+++ b/src/imports/controls/material/StackView.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.4
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.StackView {
id: control
diff --git a/src/imports/controls/material/SwipeDelegate.qml b/src/imports/controls/material/SwipeDelegate.qml
index dec2d12f..da54b0c3 100644
--- a/src/imports/controls/material/SwipeDelegate.qml
+++ b/src/imports/controls/material/SwipeDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.SwipeDelegate {
id: control
@@ -60,7 +60,7 @@ T.SwipeDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -83,10 +83,20 @@ T.SwipeDelegate {
Rectangle {
width: parent.width
height: parent.height
- visible: control.down || control.highlighted || control.visualFocus
- color: control.down ? control.Material.buttonPressColor :
- control.visualFocus || control.hovered ? control.Material.swipeDelegateHoverColor :
- control.Material.listHighlightColor
+ visible: control.highlighted
+ color: control.Material.listHighlightColor
+ }
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ enabled: control.swipe.position === 0
}
Behavior on x {
diff --git a/src/imports/controls/material/SwipeView.qml b/src/imports/controls/material/SwipeView.qml
index 38c12b6b..3ac373d5 100644
--- a/src/imports/controls/material/SwipeView.qml
+++ b/src/imports/controls/material/SwipeView.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
T.SwipeView {
id: control
@@ -47,6 +47,7 @@ T.SwipeView {
contentItem: ListView {
model: control.contentModel
+ interactive: control.interactive
currentIndex: control.currentIndex
spacing: control.spacing
diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml
index ca739e62..645dc55a 100644
--- a/src/imports/controls/material/Switch.qml
+++ b/src/imports/controls/material/Switch.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
+import QtQuick.Templates 2.1 as T
T.Switch {
id: control
@@ -56,6 +56,15 @@ T.Switch {
x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2
y: control.topPadding + (control.availableHeight - height) / 2
control: control
+
+ Ripple {
+ x: parent.handle.x + parent.handle.width / 2 - width / 2
+ y: parent.handle.y + parent.handle.height / 2 - height / 2
+ width: 28; height: 28
+ pressed: control.pressed
+ active: control.down || control.visualFocus || control.hovered
+ color: control.checked ? control.Material.highlightedRippleColor : control.Material.rippleColor
+ }
}
contentItem: Text {
@@ -64,7 +73,7 @@ T.Switch {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
diff --git a/src/imports/controls/material/SwitchDelegate.qml b/src/imports/controls/material/SwitchDelegate.qml
index 097f0acd..9fb18271 100644
--- a/src/imports/controls/material/SwitchDelegate.qml
+++ b/src/imports/controls/material/SwitchDelegate.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.SwitchDelegate {
id: control
@@ -66,7 +66,7 @@ T.SwitchDelegate {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
elide: Text.ElideRight
visible: control.text
horizontalAlignment: Text.AlignLeft
@@ -76,7 +76,17 @@ T.SwitchDelegate {
background: Rectangle {
implicitHeight: 48
- visible: control.down || control.highlighted
- color: control.down ? control.Material.buttonPressColor : control.Material.listHighlightColor
+ color: control.highlighted ? control.Material.listHighlightColor : "transparent"
+
+ Ripple {
+ width: parent.width
+ height: parent.height
+
+ clip: visible
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
+ }
}
}
diff --git a/src/imports/controls/material/SwitchIndicator.qml b/src/imports/controls/material/SwitchIndicator.qml
index 0d2163b2..c59e6ac2 100644
--- a/src/imports/controls/material/SwitchIndicator.qml
+++ b/src/imports/controls/material/SwitchIndicator.qml
@@ -34,29 +34,20 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
Item {
id: indicator
implicitWidth: 38
implicitHeight: 32
- property alias control: ripple.control
+ property Item control
+ property alias handle: handle
Material.elevation: 1
- Ripple {
- id: ripple
- x: handle.x + handle.width / 2 - width / 2
- y: handle.y + handle.height / 2 - height / 2
- width: handle.width
- height: width
- colored: control.checked
- opacity: control.pressed || control.visualFocus ? 1 : 0
- }
-
Rectangle {
width: parent.width
height: 14
diff --git a/src/imports/controls/material/TabBar.qml b/src/imports/controls/material/TabBar.qml
index 901e3328..1c3b5c0c 100644
--- a/src/imports/controls/material/TabBar.qml
+++ b/src/imports/controls/material/TabBar.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.TabBar {
id: control
diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml
index 535dfc02..a76df820 100644
--- a/src/imports/controls/material/TabButton.qml
+++ b/src/imports/controls/material/TabButton.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.TabButton {
id: control
@@ -53,12 +54,18 @@ T.TabButton {
text: control.text
font: control.font
elide: Text.ElideRight
- color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.primaryTextColor
+ color: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? control.Material.accentColor : control.Material.foreground
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- background: Item {
+ background: Ripple {
implicitHeight: 48
+
+ clip: true
+ pressed: control.pressed
+ anchor: control
+ active: control.down || control.visualFocus || control.hovered
+ color: control.Material.rippleColor
}
}
diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml
index 38502ed6..d454796a 100644
--- a/src/imports/controls/material/TextArea.qml
+++ b/src/imports/controls/material/TextArea.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.TextArea {
id: control
@@ -51,7 +51,7 @@ T.TextArea {
topPadding: 8
bottomPadding: 16
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
selectionColor: Material.accentColor
selectedTextColor: Material.primaryHighlightedTextColor
cursorDelegate: Rectangle {
diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml
index ab6f6187..8954dd26 100644
--- a/src/imports/controls/material/TextField.qml
+++ b/src/imports/controls/material/TextField.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.TextField {
id: control
@@ -51,7 +51,7 @@ T.TextField {
topPadding: 8
bottomPadding: 16
- color: enabled ? Material.primaryTextColor : Material.hintTextColor
+ color: enabled ? Material.foreground : Material.hintTextColor
selectionColor: Material.accentColor
selectedTextColor: Material.primaryHighlightedTextColor
verticalAlignment: TextInput.AlignVCenter
diff --git a/src/imports/controls/material/ToolBar.qml b/src/imports/controls/material/ToolBar.qml
index f0b50f73..38acf43e 100644
--- a/src/imports/controls/material/ToolBar.qml
+++ b/src/imports/controls/material/ToolBar.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Material.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.ToolBar {
id: control
@@ -52,8 +52,6 @@ T.ToolBar {
Material.foreground: Material.toolTextColor
- contentItem: Item { }
-
background: Rectangle {
implicitHeight: 48
color: control.Material.toolBarColor
diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml
index d8c945a7..78b15ac2 100644
--- a/src/imports/controls/material/ToolButton.qml
+++ b/src/imports/controls/material/ToolButton.qml
@@ -34,9 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Material.impl 2.1
T.ToolButton {
id: control
@@ -52,17 +53,27 @@ T.ToolButton {
contentItem: Text {
text: control.text
font: control.font
- color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
+ color: !control.enabled ? control.Material.hintTextColor :
+ control.checked || control.highlighted ? control.Material.accent : control.Material.foreground
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- background: Rectangle {
+ background: Ripple {
implicitWidth: 48
implicitHeight: 48
- color: control.down ? control.Material.buttonPressColor : control.Material.buttonHoverColor
- visible: control.enabled && (control.down || control.visualFocus || control.checked || control.highlighted)
+ readonly property bool square: control.contentItem.implicitWidth <= control.contentItem.implicitHeight
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ clip: !square
+ width: square ? parent.height / 2 : parent.width
+ height: square ? parent.height / 2 : parent.height
+ pressed: control.pressed
+ anchor: control
+ active: control.enabled && (control.down || control.visualFocus || control.hovered)
+ color: control.Material.rippleColor
}
}
diff --git a/src/imports/controls/material/ToolSeparator.qml b/src/imports/controls/material/ToolSeparator.qml
new file mode 100644
index 00000000..c241750a
--- /dev/null
+++ b/src/imports/controls/material/ToolSeparator.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
+
+T.ToolSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ leftPadding: vertical ? 12 : 5
+ rightPadding: vertical ? 12 : 5
+ topPadding: vertical ? 5 : 12
+ bottomPadding: vertical ? 5 : 12
+
+ //! [contentItem]
+ contentItem: Rectangle {
+ implicitWidth: vertical ? 1 : 38
+ implicitHeight: vertical ? 38 : 1
+ color: control.Material.hintTextColor
+ }
+ //! [contentItem]
+}
diff --git a/src/imports/controls/material/ToolTip.qml b/src/imports/controls/material/ToolTip.qml
index ab3b05d8..559b85da 100644
--- a/src/imports/controls/material/ToolTip.qml
+++ b/src/imports/controls/material/ToolTip.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.ToolTip {
id: control
@@ -72,7 +72,7 @@ T.ToolTip {
text: control.text
font: control.font
// TODO: wrapMode: Label.Wrap
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
}
background: Rectangle {
diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml
index 7e914319..a3be17b7 100644
--- a/src/imports/controls/material/Tumbler.qml
+++ b/src/imports/controls/material/Tumbler.qml
@@ -34,10 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Material 2.0
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Material 2.1
T.Tumbler {
id: control
@@ -47,29 +48,23 @@ T.Tumbler {
delegate: Text {
id: label
text: modelData
- color: control.Material.primaryTextColor
+ color: control.Material.foreground
font: control.font
opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- contentItem: PathView {
- id: pathView
+ contentItem: TumblerView {
+ id: tumblerView
model: control.model
delegate: control.delegate
- clip: true
- pathItemCount: control.visibleItemCount + 1
- preferredHighlightBegin: 0.5
- preferredHighlightEnd: 0.5
- dragMargin: width / 2
-
path: Path {
- startX: pathView.width / 2
- startY: -pathView.delegateHeight / 2
+ startX: tumblerView.width / 2
+ startY: -tumblerView.delegateHeight / 2
PathLine {
- x: pathView.width / 2
- y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
+ x: tumblerView.width / 2
+ y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
}
}
diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri
index d6247895..3170a695 100644
--- a/src/imports/controls/material/material.pri
+++ b/src/imports/controls/material/material.pri
@@ -1,10 +1,12 @@
HEADERS += \
+ $$PWD/qquickmaterialripple_p.h \
$$PWD/qquickmaterialstyle_p.h \
$$PWD/qquickmaterialtheme_p.h \
$$PWD/qquickmaterialprogressring_p.h \
$$PWD/qquickmaterialprogressstrip_p.h
SOURCES += \
+ $$PWD/qquickmaterialripple.cpp \
$$PWD/qquickmaterialstyle.cpp \
$$PWD/qquickmaterialtheme.cpp \
$$PWD/qquickmaterialprogressring.cpp \
@@ -20,6 +22,8 @@ QML_FILES += \
$$PWD/CheckIndicator.qml \
$$PWD/ComboBox.qml \
$$PWD/Dial.qml \
+ $$PWD/Dialog.qml \
+ $$PWD/DialogButtonBox.qml \
$$PWD/Drawer.qml \
$$PWD/ElevationEffect.qml \
$$PWD/Frame.qml \
@@ -28,6 +32,7 @@ QML_FILES += \
$$PWD/Label.qml \
$$PWD/Menu.qml \
$$PWD/MenuItem.qml \
+ $$PWD/MenuSeparator.qml \
$$PWD/Page.qml \
$$PWD/PageIndicator.qml \
$$PWD/Pane.qml \
@@ -37,7 +42,8 @@ QML_FILES += \
$$PWD/RadioDelegate.qml \
$$PWD/RadioIndicator.qml \
$$PWD/RangeSlider.qml \
- $$PWD/Ripple.qml \
+ $$PWD/RoundButton.qml \
+ $$PWD/RectangularGlow.qml \
$$PWD/ScrollBar.qml \
$$PWD/ScrollIndicator.qml \
$$PWD/Slider.qml \
@@ -55,5 +61,6 @@ QML_FILES += \
$$PWD/TextField.qml \
$$PWD/ToolBar.qml \
$$PWD/ToolButton.qml \
+ $$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
$$PWD/Tumbler.qml
diff --git a/src/imports/controls/material/material.pro b/src/imports/controls/material/material.pro
index 06499467..363e4861 100644
--- a/src/imports/controls/material/material.pro
+++ b/src/imports/controls/material/material.pro
@@ -1,6 +1,6 @@
TARGET = qtquickcontrols2materialstyleplugin
TARGETPATH = QtQuick/Controls.2/Material
-IMPORT_VERSION = 2.0
+IMPORT_VERSION = 2.1
QT += qml quick
QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private
diff --git a/src/imports/controls/material/qmldir b/src/imports/controls/material/qmldir
index 51dafa08..6125e67d 100644
--- a/src/imports/controls/material/qmldir
+++ b/src/imports/controls/material/qmldir
@@ -2,4 +2,3 @@ module QtQuick.Controls.Material
plugin qtquickcontrols2materialstyleplugin
classname QtQuickControls2MaterialStylePlugin
depends QtQuick.Controls 2.0
-depends QtGraphicalEffects 1.0
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index 8407c7c2..a3564c17 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.cpp
@@ -41,8 +41,8 @@
#include <QtCore/qset.h>
#include <QtGui/qpainter.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
-#include <QtQuick/qsgsimpletexturenode.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
#include <QtQuick/qquickwindow.h>
QT_BEGIN_NAMESPACE
@@ -79,18 +79,6 @@ private:
qreal m_devicePixelRatio;
QSGNode *m_containerNode;
QQuickWindow *m_window;
-};
-
-class QQuickMaterialRingTexture : public QSGSimpleTextureNode
-{
-public:
- QQuickMaterialRingTexture();
- ~QQuickMaterialRingTexture();
-
- QColor color() const;
- void setColor(QColor color);
-
-private:
QColor m_color;
};
@@ -106,14 +94,15 @@ QQuickMaterialProgressRing::~QQuickMaterialProgressRing()
QSGNode *QQuickMaterialProgressRing::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
{
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
-
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
- QQuickMaterialRingTexture *textureNode = static_cast<QQuickMaterialRingTexture*>(oldNode->firstChild());
+ QSGImageNode *textureNode = static_cast<QSGImageNode *>(oldNode->firstChild());
if (!textureNode) {
- textureNode = new QQuickMaterialRingTexture;
+ textureNode = window()->createImageNode();
textureNode->setOwnsTexture(true);
oldNode->appendChildNode(textureNode);
}
@@ -122,7 +111,6 @@ QSGNode *QQuickMaterialProgressRing::updatePaintNode(QSGNode *oldNode, QQuickIte
// so just use a blank image.
QImage blankImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
blankImage.fill(Qt::transparent);
- textureNode->setColor(m_color);
textureNode->setRect(boundingRect());
textureNode->setTexture(window()->createTextureFromImage(blankImage));
@@ -194,7 +182,7 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
if (!m_containerNode)
return;
- QSGSimpleRectNode *rectNode = static_cast<QSGSimpleRectNode*>(m_containerNode->firstChild());
+ QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(m_containerNode->firstChild());
if (!rectNode)
return;
@@ -209,8 +197,8 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
painter.setRenderHint(QPainter::Antialiasing);
QPen pen;
- QQuickMaterialRingTexture *textureNode = static_cast<QQuickMaterialRingTexture*>(rectNode->firstChild());
- pen.setColor(textureNode->color());
+ QSGImageNode *textureNode = static_cast<QSGImageNode *>(rectNode->firstChild());
+ pen.setColor(m_color);
pen.setWidth(4 * m_devicePixelRatio);
painter.setPen(pen);
@@ -266,24 +254,7 @@ void QQuickMaterialRingAnimatorJob::nodeWasDestroyed()
void QQuickMaterialRingAnimatorJob::afterNodeSync()
{
m_containerNode = QQuickItemPrivate::get(m_target)->childContainerNode();
-}
-
-QQuickMaterialRingTexture::QQuickMaterialRingTexture()
-{
-}
-
-QQuickMaterialRingTexture::~QQuickMaterialRingTexture()
-{
-}
-
-QColor QQuickMaterialRingTexture::color() const
-{
- return m_color;
-}
-
-void QQuickMaterialRingTexture::setColor(QColor color)
-{
- m_color = color;
+ m_color = static_cast<QQuickMaterialProgressRing *>(m_target.data())->color();
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip.cpp b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
index ce4d676e..542d312f 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
@@ -38,10 +38,11 @@
#include <QtCore/qmath.h>
#include <QtCore/qeasingcurve.h>
-#include <QtQuick/qsgsimplerectnode.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickanimatorjob_p.h>
#include <QtQuick/private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
QT_BEGIN_NAMESPACE
@@ -81,7 +82,7 @@ void QQuickMaterialProgressStripAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(m_node->firstChild());
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
Q_ASSERT(!geometryNode || geometryNode->type() == QSGNode::GeometryNodeType);
if (!geometryNode)
return;
@@ -128,7 +129,7 @@ void QQuickMaterialProgressStripAnimatorJob::moveNode(QSGTransformNode *transfor
matrix.translate(x, 0);
transformNode->setMatrix(matrix);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QRectF r = geometry;
@@ -211,9 +212,11 @@ QSGNode *QQuickMaterialProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePa
bounds.setHeight(implicitHeight());
bounds.moveTop((height() - bounds.height()) / 2.0);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(bounds, Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(bounds);
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(bounds);
const int count = m_indeterminate ? 2 : 1;
const qreal w = m_indeterminate ? 0 : m_progress * width();
@@ -225,14 +228,14 @@ QSGNode *QQuickMaterialProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePa
transformNode = new QSGTransformNode;
oldNode->appendChildNode(transformNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
transformNode->appendChildNode(rectNode);
}
Q_ASSERT(transformNode->type() == QSGNode::TransformNodeType);
static_cast<QSGTransformNode *>(transformNode)->setMatrix(QMatrix4x4());
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(rect);
diff --git a/src/imports/controls/material/qquickmaterialripple.cpp b/src/imports/controls/material/qquickmaterialripple.cpp
new file mode 100644
index 00000000..645b0289
--- /dev/null
+++ b/src/imports/controls/material/qquickmaterialripple.cpp
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickmaterialripple_p.h"
+
+#include <QtCore/qmath.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickanimator_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquickanimatorjob_p.h>
+#include <QtQuick/private/qsgadaptationlayer_p.h>
+#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
+#include <QtQuickTemplates2/private/qquickabstractbutton_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+ enum WavePhase { WaveEnter, WaveExit };
+}
+
+static const int RIPPLE_ENTER_DELAY = 80;
+static const int OPACITY_ENTER_DURATION_FAST = 120;
+static const int WAVE_OPACITY_DECAY_DURATION = 333;
+static const qreal WAVE_TOUCH_UP_ACCELERATION = 3400.0;
+static const qreal WAVE_TOUCH_DOWN_ACCELERATION = 1024.0;
+
+class QQuickMaterialRippleAnimatorJob : public QQuickAnimatorJob
+{
+public:
+ QQuickMaterialRippleAnimatorJob(WavePhase phase, const QPointF &anchor, const QRectF &bounds);
+
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
+
+private:
+ qreal m_diameter;
+ WavePhase m_phase;
+ QRectF m_bounds;
+ QPointF m_anchor;
+ QSGTransformNode *m_itemNode;
+ QSGOpacityNode *m_opacityNode;
+ QSGInternalRectangleNode *m_rectNode;
+};
+
+QQuickMaterialRippleAnimatorJob::QQuickMaterialRippleAnimatorJob(WavePhase phase, const QPointF &anchor, const QRectF &bounds)
+ : m_diameter(qSqrt(bounds.width() * bounds.width() + bounds.height() * bounds.height())),
+ m_phase(phase),
+ m_bounds(bounds),
+ m_anchor(anchor),
+ m_itemNode(nullptr),
+ m_opacityNode(nullptr),
+ m_rectNode(nullptr)
+{
+}
+
+void QQuickMaterialRippleAnimatorJob::initialize(QQuickAnimatorController *controller)
+{
+ QQuickAnimatorJob::initialize(controller);
+ afterNodeSync();
+}
+
+void QQuickMaterialRippleAnimatorJob::updateCurrentTime(int time)
+{
+ if (!m_itemNode || !m_rectNode)
+ return;
+
+ qreal duration = 0;
+ if (m_phase == WaveEnter)
+ duration = QQuickAnimatorJob::duration();
+ else
+ duration = 1000.0 * qSqrt((m_diameter - m_from) / 2.0 / (WAVE_TOUCH_UP_ACCELERATION + WAVE_TOUCH_DOWN_ACCELERATION));
+
+ qreal p = 1.0;
+ if (!qFuzzyIsNull(duration) && time < duration)
+ p = time / duration;
+
+ m_value = m_from + (m_to - m_from) * p;
+ p = m_value / m_diameter;
+
+ const qreal dx = (1.0 - p) * (m_anchor.x() - m_bounds.width() / 2);
+ const qreal dy = (1.0 - p) * (m_anchor.y() - m_bounds.height() / 2);
+
+ m_rectNode->setRect(QRectF(0, 0, m_value, m_value));
+ m_rectNode->setRadius(m_value / 2);
+ m_rectNode->update();
+
+ QMatrix4x4 m;
+ m.translate((m_bounds.width() - m_value) / 2 + dx,
+ (m_bounds.height() - m_value) / 2 + dy);
+ m_itemNode->setMatrix(m);
+
+ if (m_opacityNode) {
+ qreal opacity = 1.0;
+ if (m_phase == WaveExit)
+ opacity -= static_cast<qreal>(time) / WAVE_OPACITY_DECAY_DURATION;
+ m_opacityNode->setOpacity(opacity);
+ }
+}
+
+void QQuickMaterialRippleAnimatorJob::writeBack()
+{
+ if (m_target)
+ m_target->setSize(QSizeF(m_value, m_value));
+ if (m_phase == WaveExit)
+ m_target->deleteLater();
+}
+
+void QQuickMaterialRippleAnimatorJob::nodeWasDestroyed()
+{
+ m_itemNode = nullptr;
+ m_opacityNode = nullptr;
+ m_rectNode = nullptr;
+}
+
+void QQuickMaterialRippleAnimatorJob::afterNodeSync()
+{
+ m_itemNode = QQuickItemPrivate::get(m_target)->itemNode();
+ m_opacityNode = QQuickItemPrivate::get(m_target)->opacityNode();
+ m_rectNode = static_cast<QSGInternalRectangleNode *>(QQuickItemPrivate::get(m_target)->childContainerNode()->firstChild());
+}
+
+class QQuickMaterialRippleAnimator : public QQuickAnimator
+{
+public:
+ QQuickMaterialRippleAnimator(const QPointF &anchor, const QRectF &bounds, QObject *parent = nullptr);
+
+ WavePhase phase() const;
+ void setPhase(WavePhase phase);
+
+protected:
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
+
+private:
+ QPointF m_anchor;
+ QRectF m_bounds;
+ WavePhase m_phase;
+};
+
+QQuickMaterialRippleAnimator::QQuickMaterialRippleAnimator(const QPointF &anchor, const QRectF &bounds, QObject *parent)
+ : QQuickAnimator(parent), m_anchor(anchor), m_bounds(bounds), m_phase(WaveEnter)
+{
+}
+
+WavePhase QQuickMaterialRippleAnimator::phase() const
+{
+ return m_phase;
+}
+
+void QQuickMaterialRippleAnimator::setPhase(WavePhase phase)
+{
+ if (m_phase == phase)
+ return;
+
+ m_phase = phase;
+}
+
+QString QQuickMaterialRippleAnimator::propertyName() const
+{
+ return QString();
+}
+
+QQuickAnimatorJob *QQuickMaterialRippleAnimator::createJob() const
+{
+ return new QQuickMaterialRippleAnimatorJob(m_phase, m_anchor, m_bounds);
+}
+
+QQuickMaterialRipple::QQuickMaterialRipple(QQuickItem *parent)
+ : QQuickItem(parent), m_active(false), m_pressed(false), m_enterDelay(0), m_trigger(Press), m_clipRadius(0.0), m_anchor(nullptr), m_opacityAnimator(nullptr)
+{
+ setOpacity(0.0);
+ setFlag(ItemHasContents);
+}
+
+bool QQuickMaterialRipple::isActive() const
+{
+ return m_active;
+}
+
+void QQuickMaterialRipple::setActive(bool active)
+{
+ if (active == m_active)
+ return;
+
+ m_active = active;
+
+ if (!m_opacityAnimator) {
+ m_opacityAnimator = new QQuickOpacityAnimator(this);
+ m_opacityAnimator->setTargetItem(this);
+ }
+ m_opacityAnimator->setDuration(active ? OPACITY_ENTER_DURATION_FAST : WAVE_OPACITY_DECAY_DURATION);
+
+ const int time = m_opacityAnimator->currentTime();
+ m_opacityAnimator->stop();
+ m_opacityAnimator->setFrom(opacity());
+ m_opacityAnimator->setTo(active ? 1.0 : 0.0);
+ m_opacityAnimator->setCurrentTime(time);
+ m_opacityAnimator->start();
+}
+
+QColor QQuickMaterialRipple::color() const
+{
+ return m_color;
+}
+
+void QQuickMaterialRipple::setColor(const QColor &color)
+{
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+}
+
+qreal QQuickMaterialRipple::clipRadius() const
+{
+ return m_clipRadius;
+}
+
+void QQuickMaterialRipple::setClipRadius(qreal radius)
+{
+ if (qFuzzyCompare(m_clipRadius, radius))
+ return;
+
+ m_clipRadius = radius;
+ setClip(!qFuzzyIsNull(radius));
+ update();
+}
+
+bool QQuickMaterialRipple::isPressed() const
+{
+ return m_pressed;
+}
+
+void QQuickMaterialRipple::setPressed(bool pressed)
+{
+ if (pressed == m_pressed)
+ return;
+
+ m_pressed = pressed;
+
+ if (!isEnabled())
+ return;
+
+ if (pressed) {
+ if (m_trigger == Press)
+ prepareWave();
+ else
+ exitWave();
+ } else {
+ if (m_trigger == Release)
+ enterWave();
+ else
+ exitWave();
+ }
+}
+
+QQuickMaterialRipple::Trigger QQuickMaterialRipple::trigger() const
+{
+ return m_trigger;
+}
+
+void QQuickMaterialRipple::setTrigger(Trigger trigger)
+{
+ m_trigger = trigger;
+}
+
+QPointF QQuickMaterialRipple::anchorPoint() const
+{
+ const QRectF bounds = boundingRect();
+ const QPointF center = bounds.center();
+ if (!m_anchor)
+ return center;
+
+ QPointF anchorPoint = bounds.center();
+ if (QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(m_anchor))
+ anchorPoint = QQuickAbstractButtonPrivate::get(button)->pressPoint;
+ anchorPoint = mapFromItem(m_anchor, anchorPoint);
+
+ // calculate whether the anchor point is within the ripple circle bounds,
+ // that is, whether waves should start expanding from the anchor point
+ const qreal r = qSqrt(bounds.width() * bounds.width() + bounds.height() * bounds.height()) / 2;
+ if (QLineF(center, anchorPoint).length() < r)
+ return anchorPoint;
+
+ // if the anchor point is outside the ripple circle bounds, start expanding
+ // from the intersection point of the ripple circle and a line from its center
+ // to the the anchor point
+ const qreal p = qAtan2(anchorPoint.y() - center.y(), anchorPoint.x() - center.x());
+ return QPointF(center.x() + r * qCos(p), center.y() + r * qSin(p));
+}
+
+QQuickItem *QQuickMaterialRipple::anchor() const
+{
+ return m_anchor;
+}
+
+void QQuickMaterialRipple::setAnchor(QQuickItem *item)
+{
+ m_anchor = item;
+}
+
+void QQuickMaterialRipple::itemChange(ItemChange change, const ItemChangeData &data)
+{
+ QQuickItem::itemChange(change, data);
+
+ if (change == ItemChildRemovedChange) {
+ QQuickMaterialRippleAnimator *animator = data.item->findChild<QQuickMaterialRippleAnimator *>();
+ if (animator)
+ m_rippleAnimators.removeOne(animator);
+ }
+}
+
+QSGNode *QQuickMaterialRipple::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ QQuickItemPrivate *d = QQuickItemPrivate::get(this);
+ QQuickDefaultClipNode *clipNode = d->clipNode();
+ if (clipNode) {
+ // TODO: QTBUG-51894
+ // clipNode->setRadius(m_clipRadius);
+ clipNode->setRect(boundingRect());
+ clipNode->update();
+ }
+
+ const qreal w = width();
+ const qreal h = height();
+ const qreal sz = qSqrt(w * w + h * h);
+
+ QSGTransformNode *transformNode = static_cast<QSGTransformNode *>(oldNode);
+ if (!transformNode)
+ transformNode = new QSGTransformNode;
+
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(transformNode->firstChild());
+ if (!rectNode) {
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
+ rectNode->setAntialiasing(true);
+ transformNode->appendChildNode(rectNode);
+ }
+
+ QMatrix4x4 matrix;
+ if (qFuzzyIsNull(m_clipRadius)) {
+ matrix.translate((w - sz) / 2, (h - sz) / 2);
+ rectNode->setRect(QRectF(0, 0, sz, sz));
+ rectNode->setRadius(sz / 2);
+ } else {
+ rectNode->setRect(QRectF(0, 0, w, h));
+ rectNode->setRadius(m_clipRadius);
+ }
+ transformNode->setMatrix(matrix);
+ rectNode->setColor(m_color);
+ rectNode->update();
+
+ return transformNode;
+}
+
+void QQuickMaterialRipple::timerEvent(QTimerEvent *event)
+{
+ QQuickItem::timerEvent(event);
+
+ if (event->timerId() == m_enterDelay)
+ enterWave();
+}
+
+void QQuickMaterialRipple::prepareWave()
+{
+ if (m_enterDelay <= 0)
+ m_enterDelay = startTimer(RIPPLE_ENTER_DELAY);
+}
+
+void QQuickMaterialRipple::enterWave()
+{
+ if (m_enterDelay > 0) {
+ killTimer(m_enterDelay);
+ m_enterDelay = 0;
+ }
+
+ const qreal w = width();
+ const qreal h = height();
+ const qreal sz = qSqrt(w * w + h * h);
+
+ QQuickRectangle *wave = new QQuickRectangle(this);
+ wave->setPosition(QPointF((w - sz) / 2, (h - sz) / 2));
+ wave->setSize(QSizeF(sz, sz));
+ wave->setRadius(sz / 2);
+ wave->setColor(color());
+ wave->setOpacity(0.0);
+
+ QQuickMaterialRippleAnimator *animator = new QQuickMaterialRippleAnimator(anchorPoint(), boundingRect(), wave);
+ animator->setDuration(qRound(1000.0 * qSqrt(sz / 2.0 / WAVE_TOUCH_DOWN_ACCELERATION)));
+ animator->setTargetItem(wave);
+ animator->setTo(sz);
+ animator->start();
+ m_rippleAnimators += animator;
+}
+
+void QQuickMaterialRipple::exitWave()
+{
+ if (m_enterDelay > 0) {
+ killTimer(m_enterDelay);
+ m_enterDelay = 0;
+ }
+
+ for (QQuickMaterialRippleAnimator *animator : m_rippleAnimators) {
+ if (animator->phase() == WaveEnter) {
+ animator->stop(); // -> writeBack() -> setSize()
+ if (QQuickItem *wave = animator->targetItem())
+ animator->setFrom(wave->width());
+ animator->setDuration(WAVE_OPACITY_DECAY_DURATION);
+ animator->setPhase(WaveExit);
+ animator->restart();
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialripple_p.h b/src/imports/controls/material/qquickmaterialripple_p.h
new file mode 100644
index 00000000..0209ba41
--- /dev/null
+++ b/src/imports/controls/material/qquickmaterialripple_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKMATERIALRIPPLE_P_H
+#define QQUICKMATERIALRIPPLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/qquickitem.h>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickOpacityAnimator;
+class QQuickMaterialRippleAnimator;
+
+class QQuickMaterialRipple : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
+ Q_PROPERTY(qreal clipRadius READ clipRadius WRITE setClipRadius FINAL)
+ Q_PROPERTY(bool pressed READ isPressed WRITE setPressed FINAL)
+ Q_PROPERTY(bool active READ isActive WRITE setActive FINAL)
+ Q_PROPERTY(QQuickItem *anchor READ anchor WRITE setAnchor FINAL)
+ Q_PROPERTY(Trigger trigger READ trigger WRITE setTrigger FINAL)
+
+public:
+ QQuickMaterialRipple(QQuickItem *parent = nullptr);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ qreal clipRadius() const;
+ void setClipRadius(qreal radius);
+
+ bool isActive() const;
+ void setActive(bool active);
+
+ bool isPressed() const;
+ void setPressed(bool pressed);
+
+ enum Trigger { Press, Release };
+ Q_ENUM (Trigger)
+
+ Trigger trigger() const;
+ void setTrigger(Trigger trigger);
+
+ QPointF anchorPoint() const;
+
+ QQuickItem *anchor() const;
+ void setAnchor(QQuickItem *anchor);
+
+protected:
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
+ void timerEvent(QTimerEvent *event) override;
+
+ void prepareWave();
+ void enterWave();
+ void exitWave();
+
+private:
+ bool m_active;
+ bool m_pressed;
+ int m_enterDelay;
+ Trigger m_trigger;
+ qreal m_clipRadius;
+ QColor m_color;
+ QQuickItem *m_anchor;
+ QQuickOpacityAnimator *m_opacityAnimator;
+ QVector<QQuickMaterialRippleAnimator *> m_rippleAnimators;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickMaterialRipple)
+
+#endif // QQUICKMATERIALRIPPLE_P_H
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index 1c19bbd3..08203482 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -408,37 +408,24 @@ static const QRgb raisedButtonColorLight = 0xFFD6D7D7;
static const QRgb raisedButtonColorDark = 0x3FCCCCCC;
static const QRgb raisedButtonDisabledColorLight = dividerColorLight;
static const QRgb raisedButtonDisabledColorDark = dividerColorDark;
-static const QRgb flatButtonPressColorLight = 0x66999999;
-static const QRgb flatButtonPressColorDark = 0x3FCCCCCC;
-static const QRgb flatButtonFocusColorLight = 0x33CCCCCC;
-static const QRgb flatButtonFocusColorDark = 0x26CCCCCC;
-static const QRgb swipeDelegateColorLight = 0xFFD6D7D7;
-static const QRgb swipeDelegateColorDark = 0xFF525252;
-static const QRgb swipeDelegateHoverColorLight = 0xFFDFDFDF;
-static const QRgb swipeDelegateHoverColorDark = 0xFF5D5D5D;
-static const QRgb swipeDelegatePressColorLight = 0xFFCFCFCF;
-static const QRgb swipeDelegatePressColorDark = 0xFF484848;
-static const QRgb swipeDelegateDisabledColorLight = 0xFFEFEFEF;
-static const QRgb swipeDelegateDisabledColorDark = 0xFF7C7C7C;
static const QRgb frameColorLight = hintTextColorLight;
static const QRgb frameColorDark = hintTextColorDark;
static const QRgb switchUncheckedTrackColorLight = 0x42000000;
static const QRgb switchUncheckedTrackColorDark = 0x4CFFFFFF;
static const QRgb switchDisabledTrackColorLight = 0x1E000000;
static const QRgb switchDisabledTrackColorDark = 0x19FFFFFF;
-static const QRgb checkBoxUncheckedRippleColorLight = 0x10000000;
-static const QRgb checkBoxUncheckedRippleColorDark = 0x20FFFFFF;
+static const QRgb rippleColorLight = 0x10000000;
+static const QRgb rippleColorDark = 0x20FFFFFF;
static const QRgb spinBoxDisabledIconColorLight = 0xFFCCCCCC;
static const QRgb spinBoxDisabledIconColorDark = 0xFF666666;
-static QColor alphaBlend(const QColor &bg, const QColor &fg)
+extern bool qt_is_dark_system_theme();
+
+static QQuickMaterialStyle::Theme effectiveTheme(QQuickMaterialStyle::Theme theme)
{
- QColor result;
- result.setRedF(fg.redF() * fg.alphaF() + bg.redF() * (1.0 - fg.alphaF()));
- result.setGreenF(fg.greenF() * fg.alphaF() + bg.greenF() * (1.0 - fg.alphaF()));
- result.setBlueF(fg.blueF() * fg.alphaF() + bg.blueF() * (1.0 - fg.alphaF()));
- result.setAlphaF(bg.alphaF() + fg.alphaF() * (1.0 - bg.alphaF()));
- return result;
+ if (theme == QQuickMaterialStyle::System)
+ theme = qt_is_dark_system_theme() ? QQuickMaterialStyle::Dark : QQuickMaterialStyle::Light;
+ return theme;
}
QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : QQuickStyleAttached(parent),
@@ -475,6 +462,9 @@ QQuickMaterialStyle::Theme QQuickMaterialStyle::theme() const
void QQuickMaterialStyle::setTheme(Theme theme)
{
+ if (theme == System)
+ theme = qt_is_dark_system_theme() ? Dark : Light;
+
m_explicitTheme = true;
if (m_theme == theme)
return;
@@ -648,7 +638,13 @@ void QQuickMaterialStyle::resetAccent()
QVariant QQuickMaterialStyle::foreground() const
{
- return primaryTextColor();
+ if (!m_hasForeground)
+ return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
+ if (m_customForeground)
+ return QColor::fromRgba(m_foreground);
+ if (m_foreground > BlueGrey)
+ return QColor();
+ return QColor::fromRgba(colors[m_foreground][Shade500]);
}
void QQuickMaterialStyle::setForeground(const QVariant &var)
@@ -824,13 +820,7 @@ QColor QQuickMaterialStyle::backgroundColor() const
QColor QQuickMaterialStyle::primaryTextColor() const
{
- if (!m_hasForeground)
- return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
- if (m_customForeground)
- return QColor::fromRgba(m_foreground);
- if (m_foreground > BlueGrey)
- return QColor();
- return colors[m_foreground][Shade500];
+ return QColor::fromRgba(m_theme == Light ? primaryTextColorLight : primaryTextColorDark);
}
QColor QQuickMaterialStyle::primaryHighlightedTextColor() const
@@ -877,10 +867,9 @@ QColor QQuickMaterialStyle::iconDisabledColor() const
return QColor::fromRgba(m_theme == Light ? iconDisabledColorLight : iconDisabledColorDark);
}
-QColor QQuickMaterialStyle::buttonColor(bool highlighted, bool pressed, bool hover) const
+QColor QQuickMaterialStyle::buttonColor(bool highlighted) const
{
- Shade shade = pressed ? (m_theme == Light ? Shade700 : Shade100)
- : themeShade();
+ Shade shade = themeShade();
QColor color = Qt::transparent;
@@ -891,45 +880,14 @@ QColor QQuickMaterialStyle::buttonColor(bool highlighted, bool pressed, bool hov
} else if (elevation() > 0) {
color = QColor::fromRgba(m_theme == Light ? raisedButtonColorLight
: raisedButtonColorDark);
-
- if (pressed) {
- color = this->shade(color, shade);
- }
}
- if (color == Qt::transparent) {
- if (pressed) {
- return QColor::fromRgba(m_theme == Light ? flatButtonPressColorLight
- : flatButtonPressColorDark);
- } else if (hover) {
- return QColor::fromRgba(m_theme == Light ? flatButtonFocusColorLight
- : flatButtonFocusColorDark);
- } else {
- return color;
- }
- }
-
- if (pressed || hover) {
- // Add overlaying black shadow 12% opacity
- return alphaBlend(color, QColor::fromRgba(0x1F000000));
- } else {
- return color;
- }
+ return color;
}
QColor QQuickMaterialStyle::buttonColor() const
{
- return buttonColor(false, false, false);
-}
-
-QColor QQuickMaterialStyle::buttonHoverColor() const
-{
- return buttonColor(false, false, true);
-}
-
-QColor QQuickMaterialStyle::buttonPressColor() const
-{
- return buttonColor(false, true, false);
+ return buttonColor(false);
}
QColor QQuickMaterialStyle::buttonDisabledColor() const
@@ -944,37 +902,7 @@ QColor QQuickMaterialStyle::buttonDisabledColor() const
QColor QQuickMaterialStyle::highlightedButtonColor() const
{
- return buttonColor(true, false, false);
-}
-
-QColor QQuickMaterialStyle::highlightedButtonHoverColor() const
-{
- return buttonColor(true, false, true);
-}
-
-QColor QQuickMaterialStyle::highlightedButtonPressColor() const
-{
- return buttonColor(true, true, false);
-}
-
-QColor QQuickMaterialStyle::swipeDelegateColor() const
-{
- return QColor::fromRgba(m_theme == Light ? swipeDelegateColorLight : swipeDelegateColorDark);
-}
-
-QColor QQuickMaterialStyle::swipeDelegateHoverColor() const
-{
- return QColor::fromRgba(m_theme == Light ? swipeDelegateHoverColorLight : swipeDelegateHoverColorDark);
-}
-
-QColor QQuickMaterialStyle::swipeDelegatePressColor() const
-{
- return QColor::fromRgba(m_theme == Light ? swipeDelegatePressColorLight : swipeDelegatePressColorDark);
-}
-
-QColor QQuickMaterialStyle::swipeDelegateDisabledColor() const
-{
- return QColor::fromRgba(m_theme == Light ? swipeDelegateDisabledColorLight : swipeDelegateDisabledColorDark);
+ return buttonColor(true);
}
QColor QQuickMaterialStyle::frameColor() const
@@ -982,12 +910,12 @@ QColor QQuickMaterialStyle::frameColor() const
return QColor::fromRgba(m_theme == Light ? frameColorLight : frameColorDark);
}
-QColor QQuickMaterialStyle::checkBoxUncheckedRippleColor() const
+QColor QQuickMaterialStyle::rippleColor() const
{
- return QColor::fromRgba(m_theme == Light ? checkBoxUncheckedRippleColorLight : checkBoxUncheckedRippleColorDark);
+ return QColor::fromRgba(m_theme == Light ? rippleColorLight : rippleColorDark);
}
-QColor QQuickMaterialStyle::checkBoxCheckedRippleColor() const
+QColor QQuickMaterialStyle::highlightedRippleColor() const
{
QColor pressColor = accentColor();
pressColor.setAlpha(m_theme == Light ? 30 : 50);
@@ -1031,6 +959,11 @@ QColor QQuickMaterialStyle::scrollBarColor() const
return QColor::fromRgba(m_theme == Light ? 0x40000000 : 0x40FFFFFF);
}
+QColor QQuickMaterialStyle::scrollBarHoveredColor() const
+{
+ return QColor::fromRgba(m_theme == Light ? 0x60000000 : 0x60FFFFFF);
+}
+
QColor QQuickMaterialStyle::scrollBarPressedColor() const
{
return QColor::fromRgba(m_theme == Light ? 0x80000000 : 0x80FFFFFF);
@@ -1242,7 +1175,7 @@ void QQuickMaterialStyle::init()
QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_MATERIAL_THEME", settings, QStringLiteral("Theme"));
Theme themeEnum = toEnumValue<Theme>(themeValue, &ok);
if (ok)
- globalTheme = m_theme = themeEnum;
+ globalTheme = m_theme = effectiveTheme(themeEnum);
else if (!themeValue.isEmpty())
qWarning().nospace().noquote() << "Material: unknown theme value: " << themeValue;
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index af5638f1..78fef272 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -67,7 +67,7 @@ class QQuickMaterialStyle : public QQuickStyleAttached
Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryChanged FINAL) // TODO: remove?
Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL) // TODO: remove?
Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundChanged FINAL)
- Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY foregroundChanged FINAL) // TODO: rename to foregroundColor()?
+ Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor primaryHighlightedTextColor READ primaryHighlightedTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY paletteChanged FINAL)
@@ -77,19 +77,11 @@ class QQuickMaterialStyle : public QQuickStyleAttached
Q_PROPERTY(QColor iconColor READ iconColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor iconDisabledColor READ iconDisabledColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor buttonPressColor READ buttonPressColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor buttonDisabledColor READ buttonDisabledColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor highlightedButtonColor READ highlightedButtonColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor highlightedButtonHoverColor READ highlightedButtonHoverColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor highlightedButtonPressColor READ highlightedButtonPressColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor swipeDelegateColor READ swipeDelegateColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor swipeDelegateHoverColor READ swipeDelegateHoverColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor swipeDelegatePressColor READ swipeDelegatePressColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor swipeDelegateDisabledColor READ swipeDelegateDisabledColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor frameColor READ frameColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor checkBoxUncheckedRippleColor READ checkBoxUncheckedRippleColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor checkBoxCheckedRippleColor READ checkBoxCheckedRippleColor NOTIFY paletteChanged FINAL)
+ Q_PROPERTY(QColor rippleColor READ rippleColor NOTIFY paletteChanged FINAL)
+ Q_PROPERTY(QColor highlightedRippleColor READ highlightedRippleColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor switchUncheckedTrackColor READ switchUncheckedTrackColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor switchCheckedTrackColor READ switchCheckedTrackColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor switchUncheckedHandleColor READ switchUncheckedHandleColor NOTIFY paletteChanged FINAL)
@@ -97,6 +89,7 @@ class QQuickMaterialStyle : public QQuickStyleAttached
Q_PROPERTY(QColor switchDisabledTrackColor READ switchDisabledTrackColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor switchDisabledHandleColor READ switchDisabledHandleColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor scrollBarColor READ scrollBarColor NOTIFY paletteChanged FINAL)
+ Q_PROPERTY(QColor scrollBarHoveredColor READ scrollBarHoveredColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor dialogColor READ dialogColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor backgroundDimColor READ backgroundDimColor NOTIFY paletteChanged FINAL)
@@ -109,7 +102,8 @@ class QQuickMaterialStyle : public QQuickStyleAttached
public:
enum Theme {
Light,
- Dark
+ Dark,
+ System
};
enum Color {
@@ -206,20 +200,12 @@ public:
QColor iconColor() const;
QColor iconDisabledColor() const;
QColor buttonColor() const;
- QColor buttonHoverColor() const;
- QColor buttonPressColor() const;
QColor buttonDisabledColor() const;
QColor highlightedButtonColor() const;
- QColor highlightedButtonHoverColor() const;
- QColor highlightedButtonPressColor() const;
QColor highlightedButtonDisabledColor() const;
- QColor swipeDelegateColor() const;
- QColor swipeDelegateHoverColor() const;
- QColor swipeDelegatePressColor() const;
- QColor swipeDelegateDisabledColor() const;
QColor frameColor() const;
- QColor checkBoxUncheckedRippleColor() const;
- QColor checkBoxCheckedRippleColor() const;
+ QColor rippleColor() const;
+ QColor highlightedRippleColor() const;
QColor switchUncheckedTrackColor() const;
QColor switchCheckedTrackColor() const;
QColor switchUncheckedHandleColor() const;
@@ -227,6 +213,7 @@ public:
QColor switchDisabledTrackColor() const;
QColor switchDisabledHandleColor() const;
QColor scrollBarColor() const;
+ QColor scrollBarHoveredColor() const;
QColor scrollBarPressedColor() const;
QColor dialogColor() const;
QColor backgroundDimColor() const;
@@ -258,7 +245,7 @@ private:
QColor backgroundColor(Shade shade) const;
QColor accentColor(Shade shade) const;
- QColor buttonColor(bool highlighted, bool pressed, bool hover) const;
+ QColor buttonColor(bool highlighted) const;
Shade themeShade() const;
// These reflect whether a color value was explicitly set on the specific
diff --git a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
index ac11e95b..27d2c5a6 100644
--- a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
+++ b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
@@ -40,9 +40,11 @@
#include "qquickmaterialtheme_p.h"
#include "qquickmaterialprogressring_p.h"
#include "qquickmaterialprogressstrip_p.h"
+#include "qquickmaterialripple_p.h"
#include <QtQuickControls2/private/qquickstyleselector_p.h>
#include <QtQuickControls2/private/qquickpaddedrectangle_p.h>
+#include <QtQuickControls2/private/qquickcolorimageprovider_p.h>
static inline void initResources()
{
@@ -77,22 +79,27 @@ QtQuickControls2MaterialStylePlugin::QtQuickControls2MaterialStylePlugin(QObject
void QtQuickControls2MaterialStylePlugin::registerTypes(const char *uri)
{
qmlRegisterUncreatableType<QQuickMaterialStyle>(uri, 2, 0, "Material", tr("Material is an attached property"));
+ qmlRegisterRevision<QQuickMaterialStyle, 1>(uri, 2, 1);
}
void QtQuickControls2MaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
QQuickStylePlugin::initializeEngine(engine, uri);
+ engine->addImageProvider(name(), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/QtQuick/Controls.2/Material/images")));
+
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickPaddedRectangle>(import, 2, 0, "PaddedRectangle");
+ qmlRegisterRevision<QQuickPaddedRectangle, 1>(import, 2, 1);
qmlRegisterType<QQuickMaterialProgressRing>(import, 2, 0, "ProgressRing");
qmlRegisterType<QQuickMaterialProgressStrip>(import, 2, 0, "ProgressStrip");
qmlRegisterType<QQuickMaterialRingAnimator>(import, 2, 0, "RingAnimator");
+ qmlRegisterType<QQuickMaterialRipple>(import, 2, 0, "Ripple");
qmlRegisterType<QQuickMaterialStripAnimator>(import, 2, 0, "StripAnimator");
qmlRegisterType(typeUrl(QStringLiteral("BoxShadow.qml")), import, 2, 0, "BoxShadow");
qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 0, "CheckIndicator");
qmlRegisterType(typeUrl(QStringLiteral("ElevationEffect.qml")), import, 2, 0, "ElevationEffect");
- qmlRegisterType(typeUrl(QStringLiteral("Ripple.qml")), import, 2, 0, "Ripple");
+ qmlRegisterType(typeUrl(QStringLiteral("RectangularGlow.qml")), import, 2, 0, "RectangularGlow");
qmlRegisterType(typeUrl(QStringLiteral("SliderHandle.qml")), import, 2, 0, "SliderHandle");
qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator");
}
diff --git a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.qrc b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.qrc
index 47257ce4..e2cc90fa 100644
--- a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.qrc
+++ b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.qrc
@@ -8,5 +8,8 @@
<file>images/drop-indicator@2x.png</file>
<file>images/drop-indicator@3x.png</file>
<file>images/drop-indicator@4x.png</file>
+ <file>shaders/RectangularGlow.frag</file>
+ <file>shaders/+glslcore/RectangularGlow.frag</file>
+ <file>shaders/+hlsl/RectangularGlow.frag</file>
</qresource>
</RCC>
diff --git a/src/imports/controls/material/shaders/+glslcore/RectangularGlow.frag b/src/imports/controls/material/shaders/+glslcore/RectangularGlow.frag
new file mode 100644
index 00000000..432d86b5
--- /dev/null
+++ b/src/imports/controls/material/shaders/+glslcore/RectangularGlow.frag
@@ -0,0 +1,25 @@
+#version 150
+
+uniform float qt_Opacity;
+uniform float relativeSizeX;
+uniform float relativeSizeY;
+uniform float spread;
+uniform vec4 color;
+
+in vec2 qt_TexCoord0;
+out vec4 fragColor;
+
+float linearstep(float e0, float e1, float x)
+{
+ return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
+}
+
+void main()
+{
+ float alpha =
+ smoothstep(0.0, relativeSizeX, 0.5 - abs(0.5 - qt_TexCoord0.x)) *
+ smoothstep(0.0, relativeSizeY, 0.5 - abs(0.5 - qt_TexCoord0.y));
+
+ float spreadMultiplier = linearstep(spread, 1.0 - spread, alpha);
+ fragColor = color * qt_Opacity * spreadMultiplier * spreadMultiplier;
+}
diff --git a/src/imports/controls/material/shaders/+hlsl/RectangularGlow.frag b/src/imports/controls/material/shaders/+hlsl/RectangularGlow.frag
new file mode 100644
index 00000000..69d9f852
--- /dev/null
+++ b/src/imports/controls/material/shaders/+hlsl/RectangularGlow.frag
@@ -0,0 +1,21 @@
+cbuffer ConstantBuffer : register(b0)
+{
+ float4x4 qt_Matrix;
+ float qt_Opacity;
+ float relativeSizeX;
+ float relativeSizeY;
+ float spread;
+ float4 color;
+}
+
+float linearstep(float e0, float e1, float x) { return clamp((x - e0) / (e1 - e0), 0.0, 1.0); }
+
+float4 main(float4 position : SV_POSITION, float2 coord : TEXCOORD0) : SV_TARGET
+{
+ float alpha =
+ smoothstep(0.0, relativeSizeX, 0.5 - abs(0.5 - coord.x)) *
+ smoothstep(0.0, relativeSizeY, 0.5 - abs(0.5 - coord.y));
+
+ float spreadMultiplier = linearstep(spread, 1.0 - spread, alpha);
+ return color * qt_Opacity * spreadMultiplier * spreadMultiplier;
+}
diff --git a/src/imports/controls/material/shaders/RectangularGlow.frag b/src/imports/controls/material/shaders/RectangularGlow.frag
new file mode 100644
index 00000000..40bab580
--- /dev/null
+++ b/src/imports/controls/material/shaders/RectangularGlow.frag
@@ -0,0 +1,19 @@
+uniform highp float qt_Opacity;
+uniform mediump float relativeSizeX;
+uniform mediump float relativeSizeY;
+uniform mediump float spread;
+uniform lowp vec4 color;
+varying highp vec2 qt_TexCoord0;
+
+highp float linearstep(highp float e0, highp float e1, highp float x) {
+ return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
+}
+
+void main() {
+ lowp float alpha =
+ smoothstep(0.0, relativeSizeX, 0.5 - abs(0.5 - qt_TexCoord0.x)) *
+ smoothstep(0.0, relativeSizeY, 0.5 - abs(0.5 - qt_TexCoord0.y));
+
+ highp float spreadMultiplier = linearstep(spread, 1.0 - spread, alpha);
+ gl_FragColor = color * qt_Opacity * spreadMultiplier * spreadMultiplier;
+}
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index e661056c..de4e26f8 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -4,82 +4,14 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Controls 2.0 -merge ..\templates\plugins.qmltypes -dependencies dep.json'
+// 'qmlplugindump -nonrelocatable QtQuick.Controls 2.1 -merge ../templates/plugins.qmltypes -dependencies dependencies.json'
Module {
- dependencies: ["QtQuick.Templates 2.0", "QtQuick.Window 2.2", "QtQuick 2.7"]
- Component {
- name: "QQuickAbstractAnimation"
- prototype: "QObject"
- Enum {
- name: "Loops"
- values: {
- "Infinite": -2
- }
- }
- Property { name: "running"; type: "bool" }
- Property { name: "paused"; type: "bool" }
- Property { name: "alwaysRunToEnd"; type: "bool" }
- Property { name: "loops"; type: "int" }
- Signal { name: "started" }
- Signal { name: "stopped" }
- Signal {
- name: "runningChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "pausedChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "alwaysRunToEndChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "loopCountChanged"
- Parameter { type: "int" }
- }
- Method { name: "restart" }
- Method { name: "start" }
- Method { name: "pause" }
- Method { name: "resume" }
- Method { name: "stop" }
- Method { name: "complete" }
- }
- Component {
- name: "QQuickAnimator"
- prototype: "QQuickAbstractAnimation"
- exports: [
- "QtQuick.Controls.impl/BusyRingAnimator 2.0",
- "QtQuick.Controls.impl/ProgressStripAnimator 2.0"
- ]
- exportMetaObjectRevisions: [0, 0]
- Property { name: "target"; type: "QQuickItem"; isPointer: true }
- Property { name: "easing"; type: "QEasingCurve" }
- Property { name: "duration"; type: "int" }
- Property { name: "to"; type: "double" }
- Property { name: "from"; type: "double" }
- Signal {
- name: "targetItemChanged"
- Parameter { type: "QQuickItem"; isPointer: true }
- }
- Signal {
- name: "durationChanged"
- Parameter { name: "duration"; type: "int" }
- }
- Signal {
- name: "easingChanged"
- Parameter { name: "curve"; type: "QEasingCurve" }
- }
- Signal {
- name: "toChanged"
- Parameter { name: "to"; type: "double" }
- }
- Signal {
- name: "fromChanged"
- Parameter { name: "from"; type: "double" }
- }
- }
+ dependencies: [
+ "QtQuick 2.8",
+ "QtQuick.Templates 2.1",
+ "QtQuick.Window 2.2"
+ ]
Component {
name: "QQuickBusyIndicatorRing"
defaultProperty: "data"
@@ -88,26 +20,51 @@ Module {
exportMetaObjectRevisions: [0]
}
Component {
- name: "QQuickButtonGroup"
+ name: "QQuickDefaultStyle"
prototype: "QObject"
- exports: ["QtQuick.Controls/ButtonGroup 2.0"]
- exportMetaObjectRevisions: [0]
- attachedType: "QQuickButtonGroupAttached"
- Property { name: "checkedButton"; type: "QQuickAbstractButton"; isPointer: true }
- Property { name: "buttons"; type: "QQuickAbstractButton"; isList: true; isReadonly: true }
- Method {
- name: "addButton"
- Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
- }
- Method {
- name: "removeButton"
- Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
- }
- }
- Component {
- name: "QQuickButtonGroupAttached"
- prototype: "QObject"
- Property { name: "group"; type: "QQuickButtonGroup"; isPointer: true }
+ exports: ["QtQuick.Controls.impl/Default 2.1"]
+ isCreatable: false
+ isSingleton: true
+ exportMetaObjectRevisions: [0]
+ Property { name: "backgroundColor"; type: "QColor"; isReadonly: true }
+ Property { name: "overlayModalColor"; type: "QColor"; isReadonly: true }
+ Property { name: "overlayDimColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textDarkColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textLightColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textLinkColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textSelectionColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textDisabledColor"; type: "QColor"; isReadonly: true }
+ Property { name: "textDisabledLightColor"; type: "QColor"; isReadonly: true }
+ Property { name: "focusColor"; type: "QColor"; isReadonly: true }
+ Property { name: "focusLightColor"; type: "QColor"; isReadonly: true }
+ Property { name: "focusPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "buttonColor"; type: "QColor"; isReadonly: true }
+ Property { name: "buttonPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "buttonCheckedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "buttonCheckedPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "buttonCheckedFocusColor"; type: "QColor"; isReadonly: true }
+ Property { name: "toolButtonColor"; type: "QColor"; isReadonly: true }
+ Property { name: "tabButtonColor"; type: "QColor"; isReadonly: true }
+ Property { name: "tabButtonPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "tabButtonCheckedPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "delegateColor"; type: "QColor"; isReadonly: true }
+ Property { name: "delegatePressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "delegateFocusColor"; type: "QColor"; isReadonly: true }
+ Property { name: "indicatorPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "indicatorDisabledColor"; type: "QColor"; isReadonly: true }
+ Property { name: "indicatorFrameColor"; type: "QColor"; isReadonly: true }
+ Property { name: "indicatorFramePressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "indicatorFrameDisabledColor"; type: "QColor"; isReadonly: true }
+ Property { name: "frameDarkColor"; type: "QColor"; isReadonly: true }
+ Property { name: "frameLightColor"; type: "QColor"; isReadonly: true }
+ Property { name: "scrollBarColor"; type: "QColor"; isReadonly: true }
+ Property { name: "scrollBarPressedColor"; type: "QColor"; isReadonly: true }
+ Property { name: "progressBarColor"; type: "QColor"; isReadonly: true }
+ Property { name: "pageIndicatorColor"; type: "QColor"; isReadonly: true }
+ Property { name: "separatorColor"; type: "QColor"; isReadonly: true }
+ Property { name: "disabledDarkColor"; type: "QColor"; isReadonly: true }
+ Property { name: "disabledLightColor"; type: "QColor"; isReadonly: true }
}
Component {
name: "QQuickDialRing"
@@ -119,24 +76,6 @@ Module {
Property { name: "color"; type: "QColor" }
}
Component {
- name: "QQuickPaintedItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- Enum {
- name: "RenderTarget"
- values: {
- "Image": 0,
- "FramebufferObject": 1,
- "InvertedYFramebufferObject": 2
- }
- }
- Property { name: "contentsSize"; type: "QSize" }
- Property { name: "fillColor"; type: "QColor" }
- Property { name: "contentsScale"; type: "double" }
- Property { name: "renderTarget"; type: "RenderTarget" }
- Property { name: "textureSize"; type: "QSize" }
- }
- Component {
name: "QQuickProgressStrip"
defaultProperty: "data"
prototype: "QQuickItem"
@@ -146,6 +85,24 @@ Module {
Property { name: "progress"; type: "double" }
}
Component {
+ name: "QQuickTumblerView"
+ defaultProperty: "data"
+ prototype: "QQuickItem"
+ exports: ["QtQuick.Controls.impl/TumblerView 2.1"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "model"; type: "QVariant" }
+ Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
+ Property { name: "path"; type: "QQuickPath"; isPointer: true }
+ }
+ Component {
+ prototype: "QQuickAbstractButton"
+ name: "QtQuick.Controls/AbstractButton 2.0"
+ exports: ["QtQuick.Controls/AbstractButton 2.0"]
+ exportMetaObjectRevisions: [0]
+ isComposite: true
+ defaultProperty: "data"
+ }
+ Component {
prototype: "QQuickApplicationWindow"
name: "QtQuick.Controls/ApplicationWindow 2.0"
exports: ["QtQuick.Controls/ApplicationWindow 2.0"]
@@ -186,17 +143,13 @@ Module {
defaultProperty: "data"
}
Component {
- prototype: "QQuickItem"
+ prototype: "QQuickRectangle"
name: "QtQuick.Controls.impl/CheckIndicator 2.0"
exports: ["QtQuick.Controls.impl/CheckIndicator 2.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "control"; type: "QQuickItem"; isPointer: true }
- Property { name: "color"; type: "QColor" }
- Property { name: "gradient"; type: "QQuickGradient"; isPointer: true }
- Property { name: "border"; type: "QQuickPen"; isReadonly: true; isPointer: true }
- Property { name: "radius"; type: "double" }
}
Component {
prototype: "QQuickComboBox"
@@ -207,6 +160,22 @@ Module {
defaultProperty: "data"
}
Component {
+ prototype: "QQuickContainer"
+ name: "QtQuick.Controls/Container 2.0"
+ exports: ["QtQuick.Controls/Container 2.0"]
+ exportMetaObjectRevisions: [0]
+ isComposite: true
+ defaultProperty: "contentData"
+ }
+ Component {
+ prototype: "QQuickControl"
+ name: "QtQuick.Controls/Control 2.0"
+ exports: ["QtQuick.Controls/Control 2.0"]
+ exportMetaObjectRevisions: [0]
+ isComposite: true
+ defaultProperty: "data"
+ }
+ Component {
prototype: "QQuickDial"
name: "QtQuick.Controls/Dial 2.0"
exports: ["QtQuick.Controls/Dial 2.0"]
@@ -215,6 +184,22 @@ Module {
defaultProperty: "data"
}
Component {
+ prototype: "QQuickDialog"
+ name: "QtQuick.Controls/Dialog 2.1"
+ exports: ["QtQuick.Controls/Dialog 2.1"]
+ exportMetaObjectRevisions: [1]
+ isComposite: true
+ defaultProperty: "contentData"
+ }
+ Component {
+ prototype: "QQuickDialogButtonBox"
+ name: "QtQuick.Controls/DialogButtonBox 2.1"
+ exports: ["QtQuick.Controls/DialogButtonBox 2.1"]
+ exportMetaObjectRevisions: [1]
+ isComposite: true
+ defaultProperty: "contentData"
+ }
+ Component {
prototype: "QQuickDrawer"
name: "QtQuick.Controls/Drawer 2.0"
exports: ["QtQuick.Controls/Drawer 2.0"]
@@ -271,6 +256,14 @@ Module {
defaultProperty: "data"
}
Component {
+ prototype: "QQuickMenuSeparator"
+ name: "QtQuick.Controls/MenuSeparator 2.1"
+ exports: ["QtQuick.Controls/MenuSeparator 2.1"]
+ exportMetaObjectRevisions: [1]
+ isComposite: true
+ defaultProperty: "data"
+ }
+ Component {
prototype: "QQuickPage"
name: "QtQuick.Controls/Page 2.0"
exports: ["QtQuick.Controls/Page 2.0"]
@@ -327,17 +320,13 @@ Module {
defaultProperty: "data"
}
Component {
- prototype: "QQuickItem"
+ prototype: "QQuickRectangle"
name: "QtQuick.Controls.impl/RadioIndicator 2.0"
exports: ["QtQuick.Controls.impl/RadioIndicator 2.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
Property { name: "control"; type: "QQuickItem"; isPointer: true }
- Property { name: "color"; type: "QColor" }
- Property { name: "gradient"; type: "QQuickGradient"; isPointer: true }
- Property { name: "border"; type: "QQuickPen"; isReadonly: true; isPointer: true }
- Property { name: "radius"; type: "double" }
}
Component {
prototype: "QQuickRangeSlider"
@@ -348,6 +337,14 @@ Module {
defaultProperty: "data"
}
Component {
+ prototype: "QQuickRoundButton"
+ name: "QtQuick.Controls/RoundButton 2.1"
+ exports: ["QtQuick.Controls/RoundButton 2.1"]
+ exportMetaObjectRevisions: [1]
+ isComposite: true
+ defaultProperty: "data"
+ }
+ Component {
prototype: "QQuickScrollBar"
name: "QtQuick.Controls/ScrollBar 2.0"
exports: ["QtQuick.Controls/ScrollBar 2.0"]
@@ -477,6 +474,14 @@ Module {
defaultProperty: "data"
}
Component {
+ prototype: "QQuickToolSeparator"
+ name: "QtQuick.Controls/ToolSeparator 2.1"
+ exports: ["QtQuick.Controls/ToolSeparator 2.1"]
+ exportMetaObjectRevisions: [1]
+ isComposite: true
+ defaultProperty: "data"
+ }
+ Component {
prototype: "QQuickToolTip"
name: "QtQuick.Controls/ToolTip 2.0"
exports: ["QtQuick.Controls/ToolTip 2.0"]
@@ -492,6 +497,7 @@ Module {
isComposite: true
defaultProperty: "data"
}
+
Component {
name: "QQuickAbstractButton"
defaultProperty: "data"
@@ -502,6 +508,7 @@ Module {
Property { name: "down"; type: "bool" }
Property { name: "pressed"; type: "bool"; isReadonly: true }
Property { name: "checked"; type: "bool" }
+ Property { name: "checkable"; type: "bool" }
Property { name: "autoExclusive"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Signal { name: "pressed" }
@@ -553,12 +560,41 @@ Module {
prototype: "QQuickAbstractButton"
exports: ["QtQuick.Templates/Button 2.0"]
exportMetaObjectRevisions: [0]
- Property { name: "checkable"; type: "bool" }
Property { name: "autoRepeat"; type: "bool" }
Property { name: "highlighted"; type: "bool" }
Property { name: "flat"; type: "bool" }
}
Component {
+ name: "QQuickButtonGroup"
+ prototype: "QObject"
+ exports: [
+ "QtQuick.Templates/ButtonGroup 2.0",
+ "QtQuick.Templates/ButtonGroup 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
+ attachedType: "QQuickButtonGroupAttached"
+ Property { name: "checkedButton"; type: "QQuickAbstractButton"; isPointer: true }
+ Property { name: "buttons"; type: "QQuickAbstractButton"; isList: true; isReadonly: true }
+ Signal {
+ name: "clicked"
+ revision: 1
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "addButton"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "removeButton"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ }
+ Component {
+ name: "QQuickButtonGroupAttached"
+ prototype: "QObject"
+ Property { name: "group"; type: "QQuickButtonGroup"; isPointer: true }
+ }
+ Component {
name: "QQuickCheckBox"
defaultProperty: "data"
prototype: "QQuickAbstractButton"
@@ -580,11 +616,15 @@ Module {
name: "QQuickComboBox"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/ComboBox 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/ComboBox 2.0",
+ "QtQuick.Templates/ComboBox 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "model"; type: "QVariant" }
Property { name: "delegateModel"; type: "QQmlInstanceModel"; isReadonly: true; isPointer: true }
+ Property { name: "flat"; revision: 1; type: "bool" }
Property { name: "pressed"; type: "bool" }
Property { name: "highlightedIndex"; type: "int"; isReadonly: true }
Property { name: "currentIndex"; type: "int" }
@@ -594,6 +634,7 @@ Module {
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Property { name: "popup"; type: "QQuickPopup"; isPointer: true }
+ Signal { name: "flatChanged"; revision: 1 }
Signal {
name: "activated"
Parameter { name: "index"; type: "int" }
@@ -625,8 +666,11 @@ Module {
name: "QQuickContainer"
defaultProperty: "contentData"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Container 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Container 2.0",
+ "QtQuick.Templates/Container 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "contentModel"; type: "QVariant"; isReadonly: true }
Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true }
@@ -637,6 +681,8 @@ Module {
name: "setCurrentIndex"
Parameter { name: "index"; type: "int" }
}
+ Method { name: "incrementCurrentIndex"; revision: 1 }
+ Method { name: "decrementCurrentIndex"; revision: 1 }
Method {
name: "itemAt"
type: "QQuickItem*"
@@ -715,6 +761,58 @@ Module {
Method { name: "decrease" }
}
Component {
+ name: "QQuickDialog"
+ defaultProperty: "contentData"
+ prototype: "QQuickPopup"
+ exports: ["QtQuick.Templates/Dialog 2.1"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "title"; type: "string" }
+ Property { name: "header"; type: "QQuickItem"; isPointer: true }
+ Property { name: "footer"; type: "QQuickItem"; isPointer: true }
+ Property { name: "standardButtons"; type: "QPlatformDialogHelper::StandardButtons" }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Method { name: "accept" }
+ Method { name: "reject" }
+ }
+ Component {
+ name: "QQuickDialogButtonBox"
+ defaultProperty: "contentData"
+ prototype: "QQuickContainer"
+ exports: ["QtQuick.Templates/DialogButtonBox 2.1"]
+ exportMetaObjectRevisions: [0]
+ attachedType: "QQuickDialogButtonBoxAttached"
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
+ Property { name: "alignment"; type: "Qt::Alignment" }
+ Property { name: "standardButtons"; type: "QPlatformDialogHelper::StandardButtons" }
+ Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Signal { name: "helpRequested" }
+ Signal {
+ name: "clicked"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "standardButton"
+ type: "QQuickAbstractButton*"
+ Parameter { name: "button"; type: "QPlatformDialogHelper::StandardButton" }
+ }
+ }
+ Component {
+ name: "QQuickDialogButtonBoxAttached"
+ prototype: "QObject"
+ Property { name: "buttonBox"; type: "QQuickDialogButtonBox"; isReadonly: true; isPointer: true }
+ Property { name: "buttonRole"; type: "QPlatformDialogHelper::ButtonRole" }
+ }
+ Component {
name: "QQuickDrawer"
defaultProperty: "contentData"
prototype: "QQuickPopup"
@@ -741,15 +839,6 @@ Module {
Property { name: "label"; type: "QQuickItem"; isPointer: true }
}
Component {
- name: "QQuickImplicitSizeItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- Property { name: "implicitWidth"; type: "double"; isReadonly: true }
- Property { name: "implicitHeight"; type: "double"; isReadonly: true }
- Signal { name: "implicitWidthChanged2"; revision: 1 }
- Signal { name: "implicitHeightChanged2"; revision: 1 }
- }
- Component {
name: "QQuickItemDelegate"
defaultProperty: "data"
prototype: "QQuickAbstractButton"
@@ -805,16 +894,22 @@ Module {
prototype: "QQuickAbstractButton"
exports: ["QtQuick.Templates/MenuItem 2.0"]
exportMetaObjectRevisions: [0]
- Property { name: "checkable"; type: "bool" }
Property { name: "highlighted"; type: "bool" }
Signal { name: "triggered" }
}
Component {
+ name: "QQuickMenuSeparator"
+ defaultProperty: "data"
+ prototype: "QQuickControl"
+ exports: ["QtQuick.Templates/MenuSeparator 2.1"]
+ exportMetaObjectRevisions: [0]
+ }
+ Component {
name: "QQuickOverlay"
defaultProperty: "data"
prototype: "QQuickItem"
- Property { name: "modal"; type: "QQuickItem"; isPointer: true }
- Property { name: "modeless"; type: "QQuickItem"; isPointer: true }
+ Property { name: "modal"; type: "QQmlComponent"; isPointer: true }
+ Property { name: "modeless"; type: "QQmlComponent"; isPointer: true }
Signal { name: "pressed" }
Signal { name: "released" }
}
@@ -822,13 +917,17 @@ Module {
name: "QQuickPage"
defaultProperty: "contentData"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Page 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick.Templates/Page 2.0", "QtQuick.Templates/Page 2.1"]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "title"; type: "string" }
Property { name: "header"; type: "QQuickItem"; isPointer: true }
Property { name: "footer"; type: "QQuickItem"; isPointer: true }
+ Property { name: "contentWidth"; revision: 1; type: "double" }
+ Property { name: "contentHeight"; revision: 1; type: "double" }
Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "contentChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
+ Signal { name: "contentWidthChanged"; revision: 1 }
+ Signal { name: "contentHeightChanged"; revision: 1 }
}
Component {
name: "QQuickPageIndicator"
@@ -856,8 +955,11 @@ Module {
name: "QQuickPopup"
defaultProperty: "contentData"
prototype: "QObject"
- exports: ["QtQuick.Templates/Popup 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Popup 2.0",
+ "QtQuick.Templates/Popup 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "ClosePolicy"
values: {
@@ -894,6 +996,7 @@ Module {
Property { name: "contentHeight"; type: "double" }
Property { name: "availableWidth"; type: "double"; isReadonly: true }
Property { name: "availableHeight"; type: "double"; isReadonly: true }
+ Property { name: "spacing"; revision: 1; type: "double" }
Property { name: "margins"; type: "double" }
Property { name: "topMargin"; type: "double" }
Property { name: "leftMargin"; type: "double" }
@@ -923,6 +1026,7 @@ Module {
Property { name: "transformOrigin"; type: "TransformOrigin" }
Property { name: "enter"; type: "QQuickTransition"; isPointer: true }
Property { name: "exit"; type: "QQuickTransition"; isPointer: true }
+ Signal { name: "spacingChanged"; revision: 1 }
Signal {
name: "windowChanged"
Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
@@ -933,6 +1037,11 @@ Module {
Signal { name: "closed" }
Method { name: "open" }
Method { name: "close" }
+ Method {
+ name: "forceActiveFocus"
+ Parameter { name: "reason"; type: "Qt::FocusReason" }
+ }
+ Method { name: "forceActiveFocus" }
}
Component {
name: "QQuickProgressBar"
@@ -965,8 +1074,11 @@ Module {
name: "QQuickRangeSlider"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/RangeSlider 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/RangeSlider 2.0",
+ "QtQuick.Templates/RangeSlider 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "SnapMode"
values: {
@@ -996,21 +1108,18 @@ Module {
Property { name: "visualPosition"; type: "double"; isReadonly: true }
Property { name: "handle"; type: "QQuickItem"; isPointer: true }
Property { name: "pressed"; type: "bool" }
+ Property { name: "hovered"; revision: 1; type: "bool" }
+ Signal { name: "hoveredChanged"; revision: 1 }
Method { name: "increase" }
Method { name: "decrease" }
}
Component {
- name: "QQuickRootItem"
+ name: "QQuickRoundButton"
defaultProperty: "data"
- prototype: "QQuickItem"
- Method {
- name: "setWidth"
- Parameter { name: "w"; type: "int" }
- }
- Method {
- name: "setHeight"
- Parameter { name: "h"; type: "int" }
- }
+ prototype: "QQuickButton"
+ exports: ["QtQuick.Templates/RoundButton 2.1"]
+ exportMetaObjectRevisions: [1]
+ Property { name: "radius"; type: "double" }
}
Component {
name: "QQuickScrollBar"
@@ -1072,8 +1181,11 @@ Module {
name: "QQuickSlider"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Slider 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Slider 2.0",
+ "QtQuick.Templates/Slider 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "SnapMode"
values: {
@@ -1094,13 +1206,22 @@ Module {
Property { name: "handle"; type: "QQuickItem"; isPointer: true }
Method { name: "increase" }
Method { name: "decrease" }
+ Method {
+ name: "valueAt"
+ revision: 1
+ type: "double"
+ Parameter { name: "position"; type: "double" }
+ }
}
Component {
name: "QQuickSpinBox"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/SpinBox 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SpinBox 2.0",
+ "QtQuick.Templates/SpinBox 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "from"; type: "int" }
Property { name: "to"; type: "int" }
Property { name: "value"; type: "int" }
@@ -1118,7 +1239,9 @@ Module {
name: "QQuickSpinButton"
prototype: "QObject"
Property { name: "pressed"; type: "bool" }
+ Property { name: "hovered"; revision: 1; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
+ Signal { name: "hoveredChanged"; revision: 1 }
}
Component {
name: "QQuickStackAttached"
@@ -1126,13 +1249,21 @@ Module {
Property { name: "index"; type: "int"; isReadonly: true }
Property { name: "view"; type: "QQuickStackView"; isReadonly: true; isPointer: true }
Property { name: "status"; type: "QQuickStackView::Status"; isReadonly: true }
+ Signal { name: "activated" }
+ Signal { name: "activating" }
+ Signal { name: "deactivated" }
+ Signal { name: "deactivating" }
+ Signal { name: "removed" }
}
Component {
name: "QQuickStackView"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/StackView 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/StackView 2.0",
+ "QtQuick.Templates/StackView 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickStackAttached"
Enum {
name: "Status"
@@ -1153,8 +1284,11 @@ Module {
Enum {
name: "Operation"
values: {
- "Transition": 0,
- "Immediate": 1
+ "Transition": -1,
+ "Immediate": 0,
+ "PushTransition": 1,
+ "ReplaceTransition": 2,
+ "PopTransition": 3
}
}
Property { name: "busy"; type: "bool"; isReadonly: true }
@@ -1214,28 +1348,47 @@ Module {
Property { name: "leftItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "behindItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "rightItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
+ Signal { name: "completed"; revision: 1 }
+ Method { name: "close"; revision: 1 }
}
Component {
name: "QQuickSwipeDelegate"
defaultProperty: "data"
prototype: "QQuickItemDelegate"
- exports: ["QtQuick.Templates/SwipeDelegate 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SwipeDelegate 2.0",
+ "QtQuick.Templates/SwipeDelegate 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
+ attachedType: "QQuickSwipeDelegateAttached"
Property { name: "swipe"; type: "QQuickSwipe"; isReadonly: true; isPointer: true }
}
Component {
+ name: "QQuickSwipeDelegateAttached"
+ prototype: "QObject"
+ Property { name: "pressed"; type: "bool"; isReadonly: true }
+ Signal { name: "clicked" }
+ }
+ Component {
name: "QQuickSwipeView"
defaultProperty: "contentData"
prototype: "QQuickContainer"
- exports: ["QtQuick.Templates/SwipeView 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SwipeView 2.0",
+ "QtQuick.Templates/SwipeView 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickSwipeViewAttached"
+ Property { name: "interactive"; revision: 1; type: "bool" }
+ Signal { name: "interactiveChanged"; revision: 1 }
}
Component {
name: "QQuickSwipeViewAttached"
prototype: "QObject"
Property { name: "index"; type: "int"; isReadonly: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
+ Property { name: "isNextItem"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "isPreviousItem"; revision: 1; type: "bool"; isReadonly: true }
Property { name: "view"; type: "QQuickSwipeView"; isReadonly: true; isPointer: true }
}
Component {
@@ -1279,188 +1432,14 @@ Module {
exportMetaObjectRevisions: [0]
}
Component {
- name: "QQuickText"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4,
- "AlignJustify": 8
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "TextStyle"
- values: {
- "Normal": 0,
- "Outline": 1,
- "Raised": 2,
- "Sunken": 3
- }
- }
- Enum {
- name: "TextFormat"
- values: {
- "PlainText": 0,
- "RichText": 1,
- "AutoText": 2,
- "StyledText": 4
- }
- }
- Enum {
- name: "TextElideMode"
- values: {
- "ElideLeft": 0,
- "ElideRight": 1,
- "ElideMiddle": 2,
- "ElideNone": 3
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Enum {
- name: "LineHeightMode"
- values: {
- "ProportionalHeight": 0,
- "FixedHeight": 1
- }
- }
- Enum {
- name: "FontSizeMode"
- values: {
- "FixedSize": 0,
- "HorizontalFit": 1,
- "VerticalFit": 2,
- "Fit": 3
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "font"; type: "QFont" }
- Property { name: "color"; type: "QColor" }
- Property { name: "linkColor"; type: "QColor" }
- Property { name: "style"; type: "TextStyle" }
- Property { name: "styleColor"; type: "QColor" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "lineCount"; type: "int"; isReadonly: true }
- Property { name: "truncated"; type: "bool"; isReadonly: true }
- Property { name: "maximumLineCount"; type: "int" }
- Property { name: "textFormat"; type: "TextFormat" }
- Property { name: "elide"; type: "TextElideMode" }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "paintedWidth"; type: "double"; isReadonly: true }
- Property { name: "paintedHeight"; type: "double"; isReadonly: true }
- Property { name: "lineHeight"; type: "double" }
- Property { name: "lineHeightMode"; type: "LineHeightMode" }
- Property { name: "baseUrl"; type: "QUrl" }
- Property { name: "minimumPixelSize"; type: "int" }
- Property { name: "minimumPointSize"; type: "int" }
- Property { name: "fontSizeMode"; type: "FontSizeMode" }
- Property { name: "renderType"; type: "RenderType" }
- Property { name: "hoveredLink"; revision: 2; type: "string"; isReadonly: true }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Signal {
- name: "textChanged"
- Parameter { name: "text"; type: "string" }
- }
- Signal {
- name: "linkActivated"
- Parameter { name: "link"; type: "string" }
- }
- Signal {
- name: "linkHovered"
- revision: 2
- Parameter { name: "link"; type: "string" }
- }
- Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "styleChanged"
- Parameter { name: "style"; type: "QQuickText::TextStyle" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickText::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickText::VAlignment" }
- }
- Signal {
- name: "textFormatChanged"
- Parameter { name: "textFormat"; type: "QQuickText::TextFormat" }
- }
- Signal {
- name: "elideModeChanged"
- Parameter { name: "mode"; type: "QQuickText::TextElideMode" }
- }
- Signal { name: "contentSizeChanged" }
- Signal {
- name: "lineHeightChanged"
- Parameter { name: "lineHeight"; type: "double" }
- }
- Signal {
- name: "lineHeightModeChanged"
- Parameter { name: "mode"; type: "LineHeightMode" }
- }
- Signal {
- name: "lineLaidOut"
- Parameter { name: "line"; type: "QQuickTextLine"; isPointer: true }
- }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "doLayout" }
- Method {
- name: "linkAt"
- revision: 3
- type: "string"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- }
- Component {
name: "QQuickTextArea"
defaultProperty: "data"
prototype: "QQuickTextEdit"
- exports: ["QtQuick.Templates/TextArea 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/TextArea 2.0",
+ "QtQuick.Templates/TextArea 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickTextAreaAttached"
Property { name: "font"; type: "QFont" }
Property { name: "implicitWidth"; type: "double" }
@@ -1468,539 +1447,72 @@ Module {
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "placeholderText"; type: "string" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; revision: 1; type: "bool" }
Signal { name: "implicitWidthChanged3" }
Signal { name: "implicitHeightChanged3" }
+ Signal { name: "hoveredChanged"; revision: 1 }
+ Signal { name: "hoverEnabledChanged"; revision: 1 }
Signal {
name: "pressAndHold"
Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
- }
- Component {
- name: "QQuickTextAreaAttached"
- prototype: "QObject"
- Property { name: "flickable"; type: "QQuickTextArea"; isPointer: true }
- }
- Component {
- name: "QQuickTextEdit"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4,
- "AlignJustify": 8
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "TextFormat"
- values: {
- "PlainText": 0,
- "RichText": 1,
- "AutoText": 2
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "SelectionMode"
- values: {
- "SelectCharacters": 0,
- "SelectWords": 1
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "color"; type: "QColor" }
- Property { name: "selectionColor"; type: "QColor" }
- Property { name: "selectedTextColor"; type: "QColor" }
- Property { name: "font"; type: "QFont" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "lineCount"; type: "int"; isReadonly: true }
- Property { name: "length"; type: "int"; isReadonly: true }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "paintedWidth"; type: "double"; isReadonly: true }
- Property { name: "paintedHeight"; type: "double"; isReadonly: true }
- Property { name: "textFormat"; type: "TextFormat" }
- Property { name: "readOnly"; type: "bool" }
- Property { name: "cursorVisible"; type: "bool" }
- Property { name: "cursorPosition"; type: "int" }
- Property { name: "cursorRectangle"; type: "QRectF"; isReadonly: true }
- Property { name: "cursorDelegate"; type: "QQmlComponent"; isPointer: true }
- Property { name: "selectionStart"; type: "int"; isReadonly: true }
- Property { name: "selectionEnd"; type: "int"; isReadonly: true }
- Property { name: "selectedText"; type: "string"; isReadonly: true }
- Property { name: "activeFocusOnPress"; type: "bool" }
- Property { name: "persistentSelection"; type: "bool" }
- Property { name: "textMargin"; type: "double" }
- Property { name: "inputMethodHints"; type: "Qt::InputMethodHints" }
- Property { name: "selectByKeyboard"; revision: 1; type: "bool" }
- Property { name: "selectByMouse"; type: "bool" }
- Property { name: "mouseSelectionMode"; type: "SelectionMode" }
- Property { name: "canPaste"; type: "bool"; isReadonly: true }
- Property { name: "canUndo"; type: "bool"; isReadonly: true }
- Property { name: "canRedo"; type: "bool"; isReadonly: true }
- Property { name: "inputMethodComposing"; type: "bool"; isReadonly: true }
- Property { name: "baseUrl"; type: "QUrl" }
- Property { name: "renderType"; type: "RenderType" }
- Property {
- name: "textDocument"
- revision: 1
- type: "QQuickTextDocument"
- isReadonly: true
- isPointer: true
- }
- Property { name: "hoveredLink"; revision: 2; type: "string"; isReadonly: true }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
- Signal { name: "preeditTextChanged"; revision: 7 }
- Signal { name: "contentSizeChanged" }
- Signal {
- name: "colorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
- Signal {
- name: "selectionColorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
- Signal {
- name: "selectedTextColorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextEdit::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextEdit::VAlignment" }
- }
- Signal {
- name: "textFormatChanged"
- Parameter { name: "textFormat"; type: "QQuickTextEdit::TextFormat" }
- }
- Signal {
- name: "readOnlyChanged"
- Parameter { name: "isReadOnly"; type: "bool" }
- }
- Signal {
- name: "cursorVisibleChanged"
- Parameter { name: "isCursorVisible"; type: "bool" }
- }
- Signal {
- name: "activeFocusOnPressChanged"
- Parameter { name: "activeFocusOnPressed"; type: "bool" }
- }
- Signal {
- name: "persistentSelectionChanged"
- Parameter { name: "isPersistentSelection"; type: "bool" }
- }
- Signal {
- name: "textMarginChanged"
- Parameter { name: "textMargin"; type: "double" }
- }
- Signal {
- name: "selectByKeyboardChanged"
+ name: "pressed"
revision: 1
- Parameter { name: "selectByKeyboard"; type: "bool" }
- }
- Signal {
- name: "selectByMouseChanged"
- Parameter { name: "selectByMouse"; type: "bool" }
- }
- Signal {
- name: "mouseSelectionModeChanged"
- Parameter { name: "mode"; type: "QQuickTextEdit::SelectionMode" }
- }
- Signal {
- name: "linkActivated"
- Parameter { name: "link"; type: "string" }
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "linkHovered"
- revision: 2
- Parameter { name: "link"; type: "string" }
- }
- Signal { name: "editingFinished"; revision: 6 }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "selectAll" }
- Method { name: "selectWord" }
- Method {
- name: "select"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "deselect" }
- Method {
- name: "isRightToLeft"
- type: "bool"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "cut" }
- Method { name: "copy" }
- Method { name: "paste" }
- Method { name: "undo" }
- Method { name: "redo" }
- Method {
- name: "insert"
- Parameter { name: "position"; type: "int" }
- Parameter { name: "text"; type: "string" }
- }
- Method {
- name: "remove"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "append"
- revision: 2
- Parameter { name: "text"; type: "string" }
- }
- Method { name: "clear"; revision: 7 }
- Method {
- name: "inputMethodQuery"
- revision: 4
- type: "QVariant"
- Parameter { name: "query"; type: "Qt::InputMethodQuery" }
- Parameter { name: "argument"; type: "QVariant" }
- }
- Method {
- name: "positionToRectangle"
- type: "QRectF"
- Parameter { type: "int" }
- }
- Method {
- name: "positionAt"
- type: "int"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- Parameter { name: "mode"; type: "SelectionMode" }
- }
- Method {
- name: "getText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "getFormattedText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "linkAt"
- revision: 3
- type: "string"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
+ name: "released"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
}
Component {
+ name: "QQuickTextAreaAttached"
+ prototype: "QObject"
+ Property { name: "flickable"; type: "QQuickTextArea"; isPointer: true }
+ }
+ Component {
name: "QQuickTextField"
defaultProperty: "data"
prototype: "QQuickTextInput"
- exports: ["QtQuick.Templates/TextField 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/TextField 2.0",
+ "QtQuick.Templates/TextField 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "font"; type: "QFont" }
Property { name: "implicitWidth"; type: "double" }
Property { name: "implicitHeight"; type: "double" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "placeholderText"; type: "string" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; revision: 1; type: "bool" }
Signal { name: "implicitWidthChanged3" }
Signal { name: "implicitHeightChanged3" }
+ Signal { name: "hoveredChanged"; revision: 1 }
+ Signal { name: "hoverEnabledChanged"; revision: 1 }
Signal {
name: "pressAndHold"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- }
- Component {
- name: "QQuickTextInput"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "EchoMode"
- values: {
- "Normal": 0,
- "NoEcho": 1,
- "Password": 2,
- "PasswordEchoOnEdit": 3
- }
- }
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "SelectionMode"
- values: {
- "SelectCharacters": 0,
- "SelectWords": 1
- }
- }
- Enum {
- name: "CursorPosition"
- values: {
- "CursorBetweenCharacters": 0,
- "CursorOnCharacter": 1
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "length"; type: "int"; isReadonly: true }
- Property { name: "color"; type: "QColor" }
- Property { name: "selectionColor"; type: "QColor" }
- Property { name: "selectedTextColor"; type: "QColor" }
- Property { name: "font"; type: "QFont" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "readOnly"; type: "bool" }
- Property { name: "cursorVisible"; type: "bool" }
- Property { name: "cursorPosition"; type: "int" }
- Property { name: "cursorRectangle"; type: "QRectF"; isReadonly: true }
- Property { name: "cursorDelegate"; type: "QQmlComponent"; isPointer: true }
- Property { name: "selectionStart"; type: "int"; isReadonly: true }
- Property { name: "selectionEnd"; type: "int"; isReadonly: true }
- Property { name: "selectedText"; type: "string"; isReadonly: true }
- Property { name: "maximumLength"; type: "int" }
- Property { name: "validator"; type: "QValidator"; isPointer: true }
- Property { name: "inputMask"; type: "string" }
- Property { name: "inputMethodHints"; type: "Qt::InputMethodHints" }
- Property { name: "acceptableInput"; type: "bool"; isReadonly: true }
- Property { name: "echoMode"; type: "EchoMode" }
- Property { name: "activeFocusOnPress"; type: "bool" }
- Property { name: "passwordCharacter"; type: "string" }
- Property { name: "passwordMaskDelay"; revision: 3; type: "int" }
- Property { name: "displayText"; type: "string"; isReadonly: true }
- Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
- Property { name: "autoScroll"; type: "bool" }
- Property { name: "selectByMouse"; type: "bool" }
- Property { name: "mouseSelectionMode"; type: "SelectionMode" }
- Property { name: "persistentSelection"; type: "bool" }
- Property { name: "canPaste"; type: "bool"; isReadonly: true }
- Property { name: "canUndo"; type: "bool"; isReadonly: true }
- Property { name: "canRedo"; type: "bool"; isReadonly: true }
- Property { name: "inputMethodComposing"; type: "bool"; isReadonly: true }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "renderType"; type: "RenderType" }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Signal { name: "accepted" }
- Signal { name: "editingFinished"; revision: 2 }
- Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextInput::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextInput::VAlignment" }
- }
- Signal {
- name: "readOnlyChanged"
- Parameter { name: "isReadOnly"; type: "bool" }
- }
- Signal {
- name: "cursorVisibleChanged"
- Parameter { name: "isCursorVisible"; type: "bool" }
- }
- Signal {
- name: "maximumLengthChanged"
- Parameter { name: "maximumLength"; type: "int" }
- }
- Signal {
- name: "inputMaskChanged"
- Parameter { name: "inputMask"; type: "string" }
- }
- Signal {
- name: "echoModeChanged"
- Parameter { name: "echoMode"; type: "QQuickTextInput::EchoMode" }
- }
- Signal {
- name: "passwordMaskDelayChanged"
- revision: 3
- Parameter { name: "delay"; type: "int" }
- }
- Signal { name: "preeditTextChanged"; revision: 7 }
- Signal {
- name: "activeFocusOnPressChanged"
- Parameter { name: "activeFocusOnPress"; type: "bool" }
- }
- Signal {
- name: "autoScrollChanged"
- Parameter { name: "autoScroll"; type: "bool" }
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "selectByMouseChanged"
- Parameter { name: "selectByMouse"; type: "bool" }
+ name: "pressed"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "mouseSelectionModeChanged"
- Parameter { name: "mode"; type: "QQuickTextInput::SelectionMode" }
- }
- Signal { name: "contentSizeChanged" }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "selectAll" }
- Method { name: "selectWord" }
- Method {
- name: "select"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "deselect" }
- Method {
- name: "isRightToLeft"
- type: "bool"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "cut" }
- Method { name: "copy" }
- Method { name: "paste" }
- Method { name: "undo" }
- Method { name: "redo" }
- Method {
- name: "insert"
- Parameter { name: "position"; type: "int" }
- Parameter { name: "text"; type: "string" }
- }
- Method {
- name: "remove"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "ensureVisible"
- revision: 3
- Parameter { name: "position"; type: "int" }
- }
- Method { name: "clear"; revision: 7 }
- Method {
- name: "positionAt"
- Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
- }
- Method {
- name: "positionToRectangle"
- type: "QRectF"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- Parameter { name: "mode"; type: "SelectionMode" }
- }
- Method {
- name: "inputMethodQuery"
- revision: 3
- type: "QVariant"
- Parameter { name: "query"; type: "Qt::InputMethodQuery" }
- Parameter { name: "argument"; type: "QVariant" }
- }
- Method {
- name: "getText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
+ name: "released"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
}
Component {
name: "QQuickToolBar"
defaultProperty: "contentData"
- prototype: "QQuickFrame"
+ prototype: "QQuickPane"
exports: ["QtQuick.Templates/ToolBar 2.0"]
exportMetaObjectRevisions: [0]
Enum {
@@ -2020,6 +1532,16 @@ Module {
exportMetaObjectRevisions: [0]
}
Component {
+ name: "QQuickToolSeparator"
+ defaultProperty: "data"
+ prototype: "QQuickControl"
+ exports: ["QtQuick.Templates/ToolSeparator 2.1"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "orientation"; type: "Qt::Orientation" }
+ Property { name: "horizontal"; type: "bool"; isReadonly: true }
+ Property { name: "vertical"; type: "bool"; isReadonly: true }
+ }
+ Component {
name: "QQuickToolTip"
defaultProperty: "contentData"
prototype: "QQuickPopup"
@@ -2029,8 +1551,6 @@ Module {
Property { name: "delay"; type: "int" }
Property { name: "timeout"; type: "int" }
Property { name: "text"; type: "string" }
- Method { name: "open" }
- Method { name: "close" }
}
Component {
name: "QQuickToolTipAttached"
@@ -2055,8 +1575,11 @@ Module {
name: "QQuickTumbler"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Tumbler 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Tumbler 2.0",
+ "QtQuick.Templates/Tumbler 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickTumblerAttached"
Property { name: "model"; type: "QVariant" }
Property { name: "count"; type: "int"; isReadonly: true }
@@ -2064,6 +1587,8 @@ Module {
Property { name: "currentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "visibleItemCount"; type: "int" }
+ Property { name: "wrap"; revision: 1; type: "bool" }
+ Signal { name: "wrapChanged"; revision: 1 }
}
Component {
name: "QQuickTumblerAttached"
@@ -2071,240 +1596,4 @@ Module {
Property { name: "tumbler"; type: "QQuickTumbler"; isReadonly: true; isPointer: true }
Property { name: "displacement"; type: "double"; isReadonly: true }
}
-
- Component {
- name: "QQuickWindowQmlImpl"
- defaultProperty: "data"
- prototype: "QQuickWindow"
- exports: ["QtQuick.Window/Window 2.1", "QtQuick.Window/Window 2.2"]
- exportMetaObjectRevisions: [0, 1]
- attachedType: "QQuickWindowAttached"
- Property { name: "visible"; type: "bool" }
- Property { name: "visibility"; type: "Visibility" }
- Signal {
- name: "visibleChanged"
- Parameter { name: "arg"; type: "bool" }
- }
- Signal {
- name: "visibilityChanged"
- Parameter { name: "visibility"; type: "QWindow::Visibility" }
- }
- }
-
- Component {
- name: "QQuickWindow"
- defaultProperty: "data"
- prototype: "QWindow"
- exports: ["QtQuick.Window/Window 2.0"]
- exportMetaObjectRevisions: [0]
- Enum {
- name: "SceneGraphError"
- values: {
- "ContextNotAvailable": 1
- }
- }
- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "color"; type: "QColor" }
- Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
- Property {
- name: "activeFocusItem"
- revision: 1
- type: "QQuickItem"
- isReadonly: true
- isPointer: true
- }
- Signal { name: "frameSwapped" }
- Signal {
- name: "openglContextCreated"
- revision: 2
- Parameter { name: "context"; type: "QOpenGLContext"; isPointer: true }
- }
- Signal { name: "sceneGraphInitialized" }
- Signal { name: "sceneGraphInvalidated" }
- Signal { name: "beforeSynchronizing" }
- Signal { name: "afterSynchronizing"; revision: 2 }
- Signal { name: "beforeRendering" }
- Signal { name: "afterRendering" }
- Signal { name: "afterAnimating"; revision: 2 }
- Signal { name: "sceneGraphAboutToStop"; revision: 2 }
- Signal {
- name: "closing"
- revision: 1
- Parameter { name: "close"; type: "QQuickCloseEvent"; isPointer: true }
- }
- Signal {
- name: "colorChanged"
- Parameter { type: "QColor" }
- }
- Signal { name: "activeFocusItemChanged"; revision: 1 }
- Signal {
- name: "sceneGraphError"
- revision: 2
- Parameter { name: "error"; type: "QQuickWindow::SceneGraphError" }
- Parameter { name: "message"; type: "string" }
- }
- Method { name: "update" }
- Method { name: "releaseResources" }
- }
-
- Component {
- name: "QWindow"
- prototype: "QObject"
- Enum {
- name: "Visibility"
- values: {
- "Hidden": 0,
- "AutomaticVisibility": 1,
- "Windowed": 2,
- "Minimized": 3,
- "Maximized": 4,
- "FullScreen": 5
- }
- }
- Property { name: "title"; type: "string" }
- Property { name: "modality"; type: "Qt::WindowModality" }
- Property { name: "flags"; type: "Qt::WindowFlags" }
- Property { name: "x"; type: "int" }
- Property { name: "y"; type: "int" }
- Property { name: "width"; type: "int" }
- Property { name: "height"; type: "int" }
- Property { name: "minimumWidth"; type: "int" }
- Property { name: "minimumHeight"; type: "int" }
- Property { name: "maximumWidth"; type: "int" }
- Property { name: "maximumHeight"; type: "int" }
- Property { name: "visible"; type: "bool" }
- Property { name: "active"; revision: 1; type: "bool"; isReadonly: true }
- Property { name: "visibility"; revision: 1; type: "Visibility" }
- Property { name: "contentOrientation"; type: "Qt::ScreenOrientation" }
- Property { name: "opacity"; revision: 1; type: "double" }
- Signal {
- name: "screenChanged"
- Parameter { name: "screen"; type: "QScreen"; isPointer: true }
- }
- Signal {
- name: "modalityChanged"
- Parameter { name: "modality"; type: "Qt::WindowModality" }
- }
- Signal {
- name: "windowStateChanged"
- Parameter { name: "windowState"; type: "Qt::WindowState" }
- }
- Signal {
- name: "windowTitleChanged"
- revision: 2
- Parameter { name: "title"; type: "string" }
- }
- Signal {
- name: "xChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "yChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "widthChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "heightChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "minimumWidthChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "minimumHeightChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "maximumWidthChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "maximumHeightChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "visibleChanged"
- Parameter { name: "arg"; type: "bool" }
- }
- Signal {
- name: "visibilityChanged"
- revision: 1
- Parameter { name: "visibility"; type: "QWindow::Visibility" }
- }
- Signal { name: "activeChanged"; revision: 1 }
- Signal {
- name: "contentOrientationChanged"
- Parameter { name: "orientation"; type: "Qt::ScreenOrientation" }
- }
- Signal {
- name: "focusObjectChanged"
- Parameter { name: "object"; type: "QObject"; isPointer: true }
- }
- Signal {
- name: "opacityChanged"
- revision: 1
- Parameter { name: "opacity"; type: "double" }
- }
- Method { name: "requestActivate"; revision: 1 }
- Method {
- name: "setVisible"
- Parameter { name: "visible"; type: "bool" }
- }
- Method { name: "show" }
- Method { name: "hide" }
- Method { name: "showMinimized" }
- Method { name: "showMaximized" }
- Method { name: "showFullScreen" }
- Method { name: "showNormal" }
- Method { name: "close"; type: "bool" }
- Method { name: "raise" }
- Method { name: "lower" }
- Method {
- name: "setTitle"
- Parameter { type: "string" }
- }
- Method {
- name: "setX"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "setY"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "setWidth"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "setHeight"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "setMinimumWidth"
- Parameter { name: "w"; type: "int" }
- }
- Method {
- name: "setMinimumHeight"
- Parameter { name: "h"; type: "int" }
- }
- Method {
- name: "setMaximumWidth"
- Parameter { name: "w"; type: "int" }
- }
- Method {
- name: "setMaximumHeight"
- Parameter { name: "h"; type: "int" }
- }
- Method {
- name: "alert"
- revision: 1
- Parameter { name: "msec"; type: "int" }
- }
- Method { name: "requestUpdate"; revision: 3 }
- }
-
}
diff --git a/src/imports/controls/qquickbusyindicatorring.cpp b/src/imports/controls/qquickbusyindicatorring.cpp
index 4f9e9977..d8c035d2 100644
--- a/src/imports/controls/qquickbusyindicatorring.cpp
+++ b/src/imports/controls/qquickbusyindicatorring.cpp
@@ -39,8 +39,9 @@
#include <QtCore/qset.h>
#include <QtGui/qpainter.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
+#include <QtQuick/qsgnode.h>
#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -84,9 +85,11 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
{
QQuickItemPrivate *d = QQuickItemPrivate::get(this);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode *>(oldNode->firstChild());
if (!rootTransformNode) {
@@ -112,7 +115,7 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
QSGOpacityNode *opacityNode = new QSGOpacityNode;
transformNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
rectNode->setColor(color);
rectNode->setPenColor(color);
@@ -122,7 +125,7 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
QSGNode *opacityNode = transformNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QPointF pos = QPointF(sz / 2 - circleRadius, sz / 2 - circleRadius);
@@ -178,7 +181,7 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *rootRectNode = static_cast<QSGSimpleRectNode*>(m_node->firstChild());
+ QSGRectangleNode *rootRectNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
if (!rootRectNode)
return;
@@ -199,7 +202,7 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode*>(transformNode->firstChild());
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
const bool fill = (firstPhaseProgress > qreal(i) / circles) || (secondPhaseProgress > 0 && secondPhaseProgress < qreal(i) / circles);
diff --git a/src/imports/controls/qquickdefaultstyle.cpp b/src/imports/controls/qquickdefaultstyle.cpp
new file mode 100644
index 00000000..7dfedfb7
--- /dev/null
+++ b/src/imports/controls/qquickdefaultstyle.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickdefaultstyle_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QQuickDefaultStyle::QQuickDefaultStyle(QObject *parent) :
+ QObject(parent)
+{
+}
+
+QColor QQuickDefaultStyle::backgroundColor() const
+{
+ return QColor::fromRgba(0xFFFFFFFF);
+}
+
+QColor QQuickDefaultStyle::overlayModalColor() const
+{
+ return QColor::fromRgba(0x7F28282A);
+}
+
+QColor QQuickDefaultStyle::overlayDimColor() const
+{
+ return QColor::fromRgba(0x1F28282A);
+}
+
+QColor QQuickDefaultStyle::textColor() const
+{
+ return QColor::fromRgba(0xFF353637);
+}
+
+QColor QQuickDefaultStyle::textDarkColor() const
+{
+ return QColor::fromRgba(0xFF26282A);
+}
+
+QColor QQuickDefaultStyle::textLightColor() const
+{
+ return QColor::fromRgba(0xFFFFFFFF);
+}
+
+QColor QQuickDefaultStyle::textLinkColor() const
+{
+ return QColor::fromRgba(0xFF45A7D7);
+}
+
+QColor QQuickDefaultStyle::textSelectionColor() const
+{
+ return QColor::fromRgba(0xFFFDDD5C);
+}
+
+QColor QQuickDefaultStyle::textDisabledColor() const
+{
+ return QColor::fromRgba(0xFFBDBEBF);
+}
+
+QColor QQuickDefaultStyle::textDisabledLightColor() const
+{
+ return QColor::fromRgba(0xFFC2C2C2);
+}
+
+QColor QQuickDefaultStyle::focusColor() const
+{
+ return QColor::fromRgba(0xFF0066FF);
+}
+
+QColor QQuickDefaultStyle::focusLightColor() const
+{
+ return QColor::fromRgba(0xFFF0F6FF);
+}
+
+QColor QQuickDefaultStyle::focusPressedColor() const
+{
+ return QColor::fromRgba(0xFFCCE0FF);
+}
+
+QColor QQuickDefaultStyle::buttonColor() const
+{
+ return QColor::fromRgba(0xFFE0E0E0);
+}
+
+QColor QQuickDefaultStyle::buttonPressedColor() const
+{
+ return QColor::fromRgba(0xFFD0D0D0);
+}
+
+QColor QQuickDefaultStyle::buttonCheckedColor() const
+{
+ return QColor::fromRgba(0xFF353637);
+}
+
+QColor QQuickDefaultStyle::buttonCheckedPressedColor() const
+{
+ return QColor::fromRgba(0xFF585A5C);
+}
+
+QColor QQuickDefaultStyle::buttonCheckedFocusColor() const
+{
+ return QColor::fromRgba(0xFF599BFF);
+}
+
+QColor QQuickDefaultStyle::toolButtonColor() const
+{
+ return QColor::fromRgba(0x33333333);
+}
+
+QColor QQuickDefaultStyle::tabButtonColor() const
+{
+ return QColor::fromRgba(0xFF353637);
+}
+
+QColor QQuickDefaultStyle::tabButtonPressedColor() const
+{
+ return QColor::fromRgba(0xFF585A5C);
+}
+
+QColor QQuickDefaultStyle::tabButtonCheckedPressedColor() const
+{
+ return QColor::fromRgba(0xFFE4E4E4);
+}
+
+QColor QQuickDefaultStyle::delegateColor() const
+{
+ return QColor::fromRgba(0xFFEEEEEE);
+}
+
+QColor QQuickDefaultStyle::delegatePressedColor() const
+{
+ return QColor::fromRgba(0xFFBDBEBF);
+}
+
+QColor QQuickDefaultStyle::delegateFocusColor() const
+{
+ return QColor::fromRgba(0xFFE5EFFF);
+}
+
+QColor QQuickDefaultStyle::indicatorPressedColor() const
+{
+ return QColor::fromRgba(0xFFF6F6F6);
+}
+
+QColor QQuickDefaultStyle::indicatorDisabledColor() const
+{
+ return QColor::fromRgba(0xFFFDFDFD);
+}
+
+QColor QQuickDefaultStyle::indicatorFrameColor() const
+{
+ return QColor::fromRgba(0xFF909090);
+}
+
+QColor QQuickDefaultStyle::indicatorFramePressedColor() const
+{
+ return QColor::fromRgba(0xFF808080);
+}
+
+QColor QQuickDefaultStyle::indicatorFrameDisabledColor() const
+{
+ return QColor::fromRgba(0xFFD6D6D6);
+}
+
+QColor QQuickDefaultStyle::frameDarkColor() const
+{
+ return QColor::fromRgba(0xFF353637);
+}
+
+QColor QQuickDefaultStyle::frameLightColor() const
+{
+ return QColor::fromRgba(0xFFBDBEBF);
+}
+
+QColor QQuickDefaultStyle::scrollBarColor() const
+{
+ return QColor::fromRgba(0xFFBDBEBF);
+}
+
+QColor QQuickDefaultStyle::scrollBarPressedColor() const
+{
+ return QColor::fromRgba(0xFF28282A);
+}
+
+QColor QQuickDefaultStyle::progressBarColor() const
+{
+ return QColor::fromRgba(0xFFE4E4E4);
+}
+
+QColor QQuickDefaultStyle::pageIndicatorColor() const
+{
+ return QColor::fromRgba(0xFF28282A);
+}
+
+QColor QQuickDefaultStyle::separatorColor() const
+{
+ return QColor::fromRgba(0xFFCCCCCC);
+}
+
+QColor QQuickDefaultStyle::disabledDarkColor() const
+{
+ return QColor::fromRgba(0xFF353637);
+}
+
+QColor QQuickDefaultStyle::disabledLightColor() const
+{
+ return QColor::fromRgba(0xFFBDBEBF);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickdefaultstyle_p.h b/src/imports/controls/qquickdefaultstyle_p.h
new file mode 100644
index 00000000..854dc6c8
--- /dev/null
+++ b/src/imports/controls/qquickdefaultstyle_p.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDEFAULTSTYLE_P_H
+#define QQUICKDEFAULTSTYLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickDefaultStyle : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor CONSTANT FINAL)
+ Q_PROPERTY(QColor overlayModalColor READ overlayModalColor CONSTANT FINAL)
+ Q_PROPERTY(QColor overlayDimColor READ overlayDimColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textColor READ textColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textDarkColor READ textDarkColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textLightColor READ textLightColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textLinkColor READ textLinkColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textSelectionColor READ textSelectionColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textDisabledColor READ textDisabledColor CONSTANT FINAL)
+ Q_PROPERTY(QColor textDisabledLightColor READ textDisabledLightColor CONSTANT FINAL)
+ Q_PROPERTY(QColor focusColor READ focusColor CONSTANT FINAL)
+ Q_PROPERTY(QColor focusLightColor READ focusLightColor CONSTANT FINAL)
+ Q_PROPERTY(QColor focusPressedColor READ focusPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor buttonColor READ buttonColor CONSTANT FINAL)
+ Q_PROPERTY(QColor buttonPressedColor READ buttonPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor buttonCheckedColor READ buttonCheckedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor buttonCheckedPressedColor READ buttonCheckedPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor buttonCheckedFocusColor READ buttonCheckedFocusColor CONSTANT FINAL)
+ Q_PROPERTY(QColor toolButtonColor READ toolButtonColor CONSTANT FINAL)
+ Q_PROPERTY(QColor tabButtonColor READ tabButtonColor CONSTANT FINAL)
+ Q_PROPERTY(QColor tabButtonPressedColor READ tabButtonPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor tabButtonCheckedPressedColor READ tabButtonCheckedPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor delegateColor READ delegateColor CONSTANT FINAL)
+ Q_PROPERTY(QColor delegatePressedColor READ delegatePressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor delegateFocusColor READ delegateFocusColor CONSTANT FINAL)
+ Q_PROPERTY(QColor indicatorPressedColor READ indicatorPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor indicatorDisabledColor READ indicatorDisabledColor CONSTANT FINAL)
+ Q_PROPERTY(QColor indicatorFrameColor READ indicatorFrameColor CONSTANT FINAL)
+ Q_PROPERTY(QColor indicatorFramePressedColor READ indicatorFramePressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor indicatorFrameDisabledColor READ indicatorFrameDisabledColor CONSTANT FINAL)
+ Q_PROPERTY(QColor frameDarkColor READ frameDarkColor CONSTANT FINAL)
+ Q_PROPERTY(QColor frameLightColor READ frameLightColor CONSTANT FINAL)
+ Q_PROPERTY(QColor scrollBarColor READ scrollBarColor CONSTANT FINAL)
+ Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor CONSTANT FINAL)
+ Q_PROPERTY(QColor progressBarColor READ progressBarColor CONSTANT FINAL)
+ Q_PROPERTY(QColor pageIndicatorColor READ pageIndicatorColor CONSTANT FINAL)
+ Q_PROPERTY(QColor separatorColor READ separatorColor CONSTANT FINAL)
+ Q_PROPERTY(QColor disabledDarkColor READ disabledDarkColor CONSTANT FINAL)
+ Q_PROPERTY(QColor disabledLightColor READ disabledLightColor CONSTANT FINAL)
+
+public:
+ explicit QQuickDefaultStyle(QObject *parent = nullptr);
+
+ QColor backgroundColor() const;
+ QColor overlayModalColor() const;
+ QColor overlayDimColor() const;
+ QColor textColor() const;
+ QColor textDarkColor() const;
+ QColor textLightColor() const;
+ QColor textLinkColor() const;
+ QColor textSelectionColor() const;
+ QColor textDisabledColor() const;
+ QColor textDisabledLightColor() const;
+ QColor focusColor() const;
+ QColor focusLightColor() const;
+ QColor focusPressedColor() const;
+ QColor buttonColor() const;
+ QColor buttonPressedColor() const;
+ QColor buttonCheckedColor() const;
+ QColor buttonCheckedPressedColor() const;
+ QColor buttonCheckedFocusColor() const;
+ QColor toolButtonColor() const;
+ QColor tabButtonColor() const;
+ QColor tabButtonPressedColor() const;
+ QColor tabButtonCheckedPressedColor() const;
+ QColor delegateColor() const;
+ QColor delegatePressedColor() const;
+ QColor delegateFocusColor() const;
+ QColor indicatorPressedColor() const;
+ QColor indicatorDisabledColor() const;
+ QColor indicatorFrameColor() const;
+ QColor indicatorFramePressedColor() const;
+ QColor indicatorFrameDisabledColor() const;
+ QColor frameDarkColor() const;
+ QColor frameLightColor() const;
+ QColor scrollBarColor() const;
+ QColor scrollBarPressedColor() const;
+ QColor progressBarColor() const;
+ QColor pageIndicatorColor() const;
+ QColor separatorColor() const;
+ QColor disabledDarkColor() const;
+ QColor disabledLightColor() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKDEFAULTSTYLE_P_H
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
index 5b50a28d..33a21848 100644
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ b/src/imports/controls/qquickprogressstrip.cpp
@@ -37,7 +37,7 @@
#include "qquickprogressstrip_p.h"
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -129,9 +129,11 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
{
QQuickItemPrivate *d = QQuickItemPrivate::get(this);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode *>(oldNode->firstChild());
if (!rootTransformNode) {
@@ -155,9 +157,9 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
rootTransformNode->appendChildNode(transformNode);
}
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
if (!rectNode) {
- rectNode = d->sceneGraphContext()->createRectangleNode();
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setColor(color);
transformNode->appendChildNode(rectNode);
}
@@ -177,9 +179,9 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
rootTransformNode->removeAllChildNodes();
}
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(rootTransformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(rootTransformNode->firstChild());
if (!rectNode) {
- rectNode = d->sceneGraphContext()->createRectangleNode();
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setColor(color);
rootTransformNode->appendChildNode(rectNode);
}
@@ -233,7 +235,7 @@ void QQuickProgressAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *rootRectNode = static_cast<QSGSimpleRectNode*>(m_node->firstChild());
+ QSGRectangleNode *rootRectNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
if (!rootRectNode)
return;
Q_ASSERT(rootRectNode->type() == QSGNode::GeometryNodeType);
@@ -250,7 +252,7 @@ void QQuickProgressAnimatorJob::updateCurrentTime(int time)
const qreal pixelsPerSecond = rootRectNode->rect().width();
for (int i = 0; i < blocks; ++i) {
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QMatrix4x4 m;
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 8e41a58c..5b8868fe 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -36,12 +36,15 @@
#include <QtCore/private/qfileselector_p.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <QtQuickControls2/private/qquickstyle_p.h>
#include <QtQuickControls2/private/qquickstyleplugin_p.h>
#include <QtQuickControls2/private/qquickstyleselector_p.h>
#include <QtQuickControls2/private/qquickcolorimageprovider_p.h>
#include <QtQuickTemplates2/private/qquickbuttongroup_p.h>
+#include <QtQuickControls2/private/qquicktumblerview_p.h>
#include "qquickbusyindicatorring_p.h"
+#include "qquickdefaultstyle_p.h"
#include "qquickdialring_p.h"
#include "qquickprogressstrip_p.h"
@@ -73,20 +76,21 @@ QtQuickControls2Plugin::QtQuickControls2Plugin(QObject *parent) : QQuickStylePlu
void QtQuickControls2Plugin::registerTypes(const char *uri)
{
- qmlRegisterType<QQuickButtonGroup>(uri, 2, 0, "ButtonGroup");
- qmlRegisterType<QQuickButtonGroupAttached>();
-
- QQuickStyleSelector selector;
- selector.setBaseUrl(typeUrl());
-
+ QQuickStylePrivate::init(typeUrl());
const QString style = QQuickStyle::name();
if (!style.isEmpty())
QFileSelectorPrivate::addStatics(QStringList() << style.toLower());
+ QQuickStyleSelector selector;
+ selector.setBaseUrl(typeUrl());
+
+ // QtQuick.Controls 2.0 (Qt 5.7)
qmlRegisterType(selector.select(QStringLiteral("AbstractButton.qml")), uri, 2, 0, "AbstractButton");
qmlRegisterType(selector.select(QStringLiteral("ApplicationWindow.qml")), uri, 2, 0, "ApplicationWindow");
qmlRegisterType(selector.select(QStringLiteral("BusyIndicator.qml")), uri, 2, 0, "BusyIndicator");
qmlRegisterType(selector.select(QStringLiteral("Button.qml")), uri, 2, 0, "Button");
+ qmlRegisterType<QQuickButtonGroup>(uri, 2, 0, "ButtonGroup");
+ qmlRegisterType<QQuickButtonGroupAttached>();
qmlRegisterType(selector.select(QStringLiteral("CheckBox.qml")), uri, 2, 0, "CheckBox");
qmlRegisterType(selector.select(QStringLiteral("CheckDelegate.qml")), uri, 2, 0, "CheckDelegate");
qmlRegisterType(selector.select(QStringLiteral("ComboBox.qml")), uri, 2, 0, "ComboBox");
@@ -125,6 +129,21 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType(selector.select(QStringLiteral("ToolButton.qml")), uri, 2, 0, "ToolButton");
qmlRegisterType(selector.select(QStringLiteral("ToolTip.qml")), uri, 2, 0, "ToolTip");
qmlRegisterType(selector.select(QStringLiteral("Tumbler.qml")), uri, 2, 0, "Tumbler");
+
+ // QtQuick.Controls 2.1 (Qt 5.8)
+ qmlRegisterType<QQuickButtonGroup,1 >(uri, 2, 1, "ButtonGroup");
+ qmlRegisterType(selector.select(QStringLiteral("Dialog.qml")), uri, 2, 1, "Dialog");
+ qmlRegisterType(selector.select(QStringLiteral("DialogButtonBox.qml")), uri, 2, 1, "DialogButtonBox");
+ qmlRegisterType(selector.select(QStringLiteral("MenuSeparator.qml")), uri, 2, 1, "MenuSeparator");
+ qmlRegisterType(selector.select(QStringLiteral("RoundButton.qml")), uri, 2, 1, "RoundButton");
+ qmlRegisterType(selector.select(QStringLiteral("ToolSeparator.qml")), uri, 2, 1, "ToolSeparator");
+}
+
+static QObject *styleSingleton(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(scriptEngine);
+ return new QQuickDefaultStyle;
}
void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -139,6 +158,8 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur
qmlRegisterType<QQuickProgressStrip>(import, 2, 0, "ProgressStrip");
qmlRegisterType<QQuickProgressAnimator>(import, 2, 0, "ProgressStripAnimator");
qmlRegisterType<QQuickDialRing>(import, 2, 0, "DialRing");
+ qmlRegisterType<QQuickTumblerView>(import, 2, 1, "TumblerView");
+ qmlRegisterSingletonType<QQuickDefaultStyle>(import, 2, 1, "Default", styleSingleton);
qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 0, "CheckIndicator");
qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 0, "RadioIndicator");
diff --git a/src/imports/controls/universal/ApplicationWindow.qml b/src/imports/controls/universal/ApplicationWindow.qml
index 70bd403c..ba07021a 100644
--- a/src/imports/controls/universal/ApplicationWindow.qml
+++ b/src/imports/controls/universal/ApplicationWindow.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls.Universal.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls.Universal.impl 2.1
T.ApplicationWindow {
id: window
diff --git a/src/imports/controls/universal/BusyIndicator.qml b/src/imports/controls/universal/BusyIndicator.qml
index fe2186a7..514a233e 100644
--- a/src/imports/controls/universal/BusyIndicator.qml
+++ b/src/imports/controls/universal/BusyIndicator.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls.Universal.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls.Universal.impl 2.1
T.BusyIndicator {
id: control
diff --git a/src/imports/controls/universal/Button.qml b/src/imports/controls/universal/Button.qml
index 6954d31a..aa65e714 100644
--- a/src/imports/controls/universal/Button.qml
+++ b/src/imports/controls/universal/Button.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Button {
id: control
@@ -72,5 +72,14 @@ T.Button {
color: control.down ? control.Universal.baseMediumLowColor :
control.enabled && (control.highlighted || control.checked) ? control.Universal.accent :
control.Universal.baseLowColor
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ color: "transparent"
+ visible: control.hovered
+ border.width: 2 // ButtonBorderThemeThickness
+ border.color: control.Universal.baseMediumLowColor
+ }
}
}
diff --git a/src/imports/controls/universal/CheckBox.qml b/src/imports/controls/universal/CheckBox.qml
index a1c3ba6b..916348f9 100644
--- a/src/imports/controls/universal/CheckBox.qml
+++ b/src/imports/controls/universal/CheckBox.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls.Universal.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls.Universal.impl 2.1
T.CheckBox {
id: control
diff --git a/src/imports/controls/universal/CheckDelegate.qml b/src/imports/controls/universal/CheckDelegate.qml
index c0ca272e..42e7b10c 100644
--- a/src/imports/controls/universal/CheckDelegate.qml
+++ b/src/imports/controls/universal/CheckDelegate.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.CheckDelegate {
id: control
@@ -76,8 +76,9 @@ T.CheckDelegate {
}
background: Rectangle {
- visible: control.down || control.highlighted || control.visualFocus
- color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ visible: control.down || control.highlighted || control.visualFocus || control.hovered
+ color: control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
width: parent.width
height: parent.height
diff --git a/src/imports/controls/universal/CheckIndicator.qml b/src/imports/controls/universal/CheckIndicator.qml
index eeecf264..166cf184 100644
--- a/src/imports/controls/universal/CheckIndicator.qml
+++ b/src/imports/controls/universal/CheckIndicator.qml
@@ -34,16 +34,16 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
Rectangle {
implicitWidth: 20
implicitHeight: 20
color: !control.enabled ? "transparent" :
- control.down && control.checkState !== Qt.PartiallyChecked ? control.Universal.baseMediumColor :
+ control.down && !partiallyChecked ? control.Universal.baseMediumColor :
control.checkState === Qt.Checked ? control.Universal.accent : "transparent"
border.color: !control.enabled ? control.Universal.baseLowColor :
control.down ? control.Universal.baseMediumColor :
@@ -51,6 +51,7 @@ Rectangle {
border.width: 2 // CheckBoxBorderThemeThickness
property Item control
+ readonly property bool partiallyChecked: control.checkState === Qt.PartiallyChecked
Image {
x: (parent.width - width) / 2
@@ -65,11 +66,15 @@ Rectangle {
Rectangle {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
- width: parent.width / 2
- height: parent.height / 2
+ width: partiallyChecked ? parent.width / 2 : parent.width
+ height: partiallyChecked ? parent.height / 2 : parent.height
- visible: control.checkState === Qt.PartiallyChecked
- color: !control.enabled ? control.Universal.baseLowColor :
- control.down ? control.Universal.baseMediumColor : control.Universal.baseMediumHighColor
+ visible: !control.pressed && control.hovered || partiallyChecked
+ color: !partiallyChecked ? "transparent" :
+ !control.enabled ? control.Universal.baseLowColor :
+ control.down ? control.Universal.baseMediumColor :
+ control.hovered ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
+ border.width: partiallyChecked ? 0 : 2 // CheckBoxBorderThemeThickness
+ border.color: control.Universal.baseMediumLowColor
}
}
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml
index bb816fc1..2d768a1d 100644
--- a/src/imports/controls/universal/ComboBox.qml
+++ b/src/imports/controls/universal/ComboBox.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
+import QtQuick 2.8
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ComboBox {
id: control
@@ -60,6 +60,7 @@ T.ComboBox {
width: control.popup.width
text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
highlighted: control.highlightedIndex === index
+ hoverEnabled: control.hoverEnabled
}
indicator: Image {
@@ -88,11 +89,14 @@ T.ComboBox {
implicitWidth: 120
implicitHeight: 32
- border.width: 2 // ComboBoxBorderThemeThickness
+ border.width: control.flat ? 0 : 2 // ComboBoxBorderThemeThickness
border.color: !control.enabled ? control.Universal.baseLowColor :
- control.pressed || popup.visible ? control.Universal.baseMediumLowColor : control.Universal.baseMediumLowColor
+ control.pressed || popup.visible ? control.Universal.baseMediumLowColor :
+ control.hovered ? control.Universal.baseMediumColor : control.Universal.baseMediumLowColor
color: !control.enabled ? control.Universal.baseLowColor :
- control.pressed || popup.visible ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ control.pressed || popup.visible ? control.Universal.listMediumColor :
+ control.flat && control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
+ visible: !control.flat || control.pressed || control.hovered || control.visualFocus
Rectangle {
x: 2
diff --git a/src/imports/controls/universal/Dial.qml b/src/imports/controls/universal/Dial.qml
index 6781d387..9eaf69ba 100644
--- a/src/imports/controls/universal/Dial.qml
+++ b/src/imports/controls/universal/Dial.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Dial {
id: control
@@ -64,7 +64,8 @@ T.Dial {
radius: width / 2
color: !control.enabled ? control.Universal.baseLowColor :
- control.pressed ? control.Universal.baseMediumColor : control.Universal.baseMediumHighColor
+ control.pressed ? control.Universal.baseMediumColor :
+ control.hovered ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
transform: [
Translate {
diff --git a/src/imports/controls/universal/Dialog.qml b/src/imports/controls/universal/Dialog.qml
new file mode 100644
index 00000000..f805581c
--- /dev/null
+++ b/src/imports/controls/universal/Dialog.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Universal 2.1
+
+T.Dialog {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0,
+ contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0)
+ + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+
+ padding: 24
+ topPadding: 18
+ bottomPadding: 18
+
+ background: Rectangle {
+ color: control.Universal.chromeMediumLowColor
+ border.color: control.Universal.chromeHighColor
+ border.width: 1 // FlyoutBorderThemeThickness
+ }
+
+ header: Label {
+ text: control.title
+ visible: control.title
+ elide: Label.ElideRight
+ topPadding: 18
+ leftPadding: 24
+ rightPadding: 24
+ // TODO: QPlatformTheme::TitleBarFont
+ font.pixelSize: 20
+ background: Rectangle {
+ x: 1; y: 1 // // FlyoutBorderThemeThickness
+ color: control.Universal.chromeMediumLowColor
+ width: parent.width - 2
+ height: parent.height - 1
+ }
+ }
+
+ footer: DialogButtonBox {
+ visible: count > 0
+ }
+}
diff --git a/src/imports/controls/universal/DialogButtonBox.qml b/src/imports/controls/universal/DialogButtonBox.qml
new file mode 100644
index 00000000..043496d9
--- /dev/null
+++ b/src/imports/controls/universal/DialogButtonBox.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+
+T.DialogButtonBox {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ spacing: 4
+ padding: 24
+ topPadding: position === T.DialogButtonBox.Footer ? 6 : 24
+ bottomPadding: position === T.DialogButtonBox.Header ? 6 : 24
+ alignment: count === 1 ? Qt.AlignRight : undefined
+
+ delegate: Button {
+ width: control.count === 1 ? control.availableWidth / 2 : undefined
+ }
+
+ contentItem: ListView {
+ implicitWidth: contentWidth
+ implicitHeight: 32
+
+ model: control.contentModel
+ spacing: control.spacing
+ orientation: ListView.Horizontal
+ boundsBehavior: Flickable.StopAtBounds
+ snapMode: ListView.SnapToItem
+ }
+
+ background: Rectangle {
+ implicitHeight: 32
+ color: control.Universal.chromeMediumLowColor
+ x: 1; y: 1
+ width: parent.width - 2
+ height: parent.height - 2
+ }
+}
diff --git a/src/imports/controls/universal/Drawer.qml b/src/imports/controls/universal/Drawer.qml
index 84831323..09b3751d 100644
--- a/src/imports/controls/universal/Drawer.qml
+++ b/src/imports/controls/universal/Drawer.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Drawer {
id: control
@@ -57,8 +57,6 @@ T.Drawer {
enter: Transition { SmoothedAnimation { velocity: 5 } }
exit: Transition { SmoothedAnimation { velocity: 5 } }
- contentItem: Item { }
-
background: Rectangle {
color: control.Universal.chromeMediumLowColor
Rectangle {
diff --git a/src/imports/controls/universal/Frame.qml b/src/imports/controls/universal/Frame.qml
index d5b327c1..1c83f3fd 100644
--- a/src/imports/controls/universal/Frame.qml
+++ b/src/imports/controls/universal/Frame.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Frame {
id: control
@@ -49,8 +49,6 @@ T.Frame {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
color: "transparent"
border.color: control.Universal.chromeDisabledLowColor
diff --git a/src/imports/controls/universal/GroupBox.qml b/src/imports/controls/universal/GroupBox.qml
index c75c81a6..435a9755 100644
--- a/src/imports/controls/universal/GroupBox.qml
+++ b/src/imports/controls/universal/GroupBox.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.GroupBox {
id: control
@@ -53,8 +53,6 @@ T.GroupBox {
padding: 12
topPadding: padding + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0)
- contentItem: Item { }
-
label: Text {
x: control.leftPadding
width: control.availableWidth
diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml
index 6822d658..a8d55ba6 100644
--- a/src/imports/controls/universal/ItemDelegate.qml
+++ b/src/imports/controls/universal/ItemDelegate.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ItemDelegate {
id: control
@@ -70,8 +70,9 @@ T.ItemDelegate {
}
background: Rectangle {
- visible: control.down || control.highlighted || control.visualFocus
- color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ visible: control.down || control.highlighted || control.visualFocus || control.hovered
+ color: control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
width: parent.width
height: parent.height
diff --git a/src/imports/controls/universal/Label.qml b/src/imports/controls/universal/Label.qml
index 9b50f4f5..9e377f61 100644
--- a/src/imports/controls/universal/Label.qml
+++ b/src/imports/controls/universal/Label.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Label {
id: control
diff --git a/src/imports/controls/universal/Menu.qml b/src/imports/controls/universal/Menu.qml
index 5ee2c243..afae51f0 100644
--- a/src/imports/controls/universal/Menu.qml
+++ b/src/imports/controls/universal/Menu.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Menu {
id: control
diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml
index d8fdbcd0..380a5b0e 100644
--- a/src/imports/controls/universal/MenuItem.qml
+++ b/src/imports/controls/universal/MenuItem.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.MenuItem {
id: control
@@ -81,7 +81,8 @@ T.MenuItem {
implicitHeight: 40
color: !control.enabled ? control.Universal.baseLowColor :
- control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
x: 1; y: 1
diff --git a/src/imports/controls/universal/MenuSeparator.qml b/src/imports/controls/universal/MenuSeparator.qml
new file mode 100644
index 00000000..cd79c60f
--- /dev/null
+++ b/src/imports/controls/universal/MenuSeparator.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+
+T.MenuSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ padding: 12
+ topPadding: 9
+ bottomPadding: 10
+
+ contentItem: Rectangle {
+ implicitWidth: 188
+ implicitHeight: 1
+ color: control.Universal.baseMediumLowColor
+ }
+
+ background: Rectangle {
+ color: control.Universal.altMediumLowColor
+ }
+}
diff --git a/src/imports/controls/universal/Page.qml b/src/imports/controls/universal/Page.qml
index 3150715f..e8c7bd4a 100644
--- a/src/imports/controls/universal/Page.qml
+++ b/src/imports/controls/universal/Page.qml
@@ -34,14 +34,24 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Page {
id: control
- contentItem: Item { }
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ Math.max(contentWidth,
+ header && header.visible ? header.implicitWidth : 0,
+ footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentHeight + topPadding + bottomPadding
+ + (header && header.visible ? header.implicitHeight + spacing : 0)
+ + (footer && footer.visible ? footer.implicitHeight + spacing : 0))
+
+ contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
+ contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
background: Rectangle {
color: control.Universal.background
diff --git a/src/imports/controls/universal/PageIndicator.qml b/src/imports/controls/universal/PageIndicator.qml
index 0c4e3b80..817c89fb 100644
--- a/src/imports/controls/universal/PageIndicator.qml
+++ b/src/imports/controls/universal/PageIndicator.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.PageIndicator {
id: control
diff --git a/src/imports/controls/universal/Pane.qml b/src/imports/controls/universal/Pane.qml
index cd62b65c..903e501a 100644
--- a/src/imports/controls/universal/Pane.qml
+++ b/src/imports/controls/universal/Pane.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Pane {
id: control
@@ -49,8 +49,6 @@ T.Pane {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
color: control.Universal.background
}
diff --git a/src/imports/controls/universal/Popup.qml b/src/imports/controls/universal/Popup.qml
index 892db087..53178b71 100644
--- a/src/imports/controls/universal/Popup.qml
+++ b/src/imports/controls/universal/Popup.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Popup {
id: control
@@ -51,8 +51,6 @@ T.Popup {
padding: 12
- contentItem: Item { }
-
background: Rectangle {
color: control.Universal.chromeMediumLowColor
border.color: control.Universal.chromeHighColor
diff --git a/src/imports/controls/universal/ProgressBar.qml b/src/imports/controls/universal/ProgressBar.qml
index 66d1aeb8..cd314c27 100644
--- a/src/imports/controls/universal/ProgressBar.qml
+++ b/src/imports/controls/universal/ProgressBar.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls.Universal.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls.Universal.impl 2.1
T.ProgressBar {
id: control
diff --git a/src/imports/controls/universal/RadioButton.qml b/src/imports/controls/universal/RadioButton.qml
index b8986488..8f599e55 100644
--- a/src/imports/controls/universal/RadioButton.qml
+++ b/src/imports/controls/universal/RadioButton.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls.Universal.impl 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls.Universal.impl 2.1
T.RadioButton {
id: control
diff --git a/src/imports/controls/universal/RadioDelegate.qml b/src/imports/controls/universal/RadioDelegate.qml
index 09f86f15..14680cd6 100644
--- a/src/imports/controls/universal/RadioDelegate.qml
+++ b/src/imports/controls/universal/RadioDelegate.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.RadioDelegate {
id: control
@@ -78,8 +78,9 @@ T.RadioDelegate {
}
background: Rectangle {
- visible: control.down || control.highlighted || control.visualFocus
- color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ visible: control.down || control.highlighted || control.visualFocus || control.hovered
+ color: control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
width: parent.width
height: parent.height
diff --git a/src/imports/controls/universal/RadioIndicator.qml b/src/imports/controls/universal/RadioIndicator.qml
index 65790e6a..c745b04e 100644
--- a/src/imports/controls/universal/RadioIndicator.qml
+++ b/src/imports/controls/universal/RadioIndicator.qml
@@ -34,8 +34,8 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Controls.Universal 2.1
Rectangle {
implicitWidth: 20
@@ -45,7 +45,8 @@ Rectangle {
border.width: 2 // RadioButtonBorderThemeThickness
border.color: control.checked ? "transparent" :
!control.enabled ? control.Universal.baseLowColor :
- control.down ? control.Universal.baseMediumColor : control.Universal.baseMediumHighColor
+ control.down ? control.Universal.baseMediumColor :
+ control.hovered ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
property var control
@@ -72,6 +73,7 @@ Rectangle {
radius: width / 2
opacity: control.checked ? 1 : 0
color: !control.enabled ? control.Universal.baseLowColor :
- control.down ? control.Universal.baseMediumColor : control.Universal.baseMediumHighColor
+ control.down ? control.Universal.baseMediumColor :
+ control.hovered ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
}
}
diff --git a/src/imports/controls/universal/RangeSlider.qml b/src/imports/controls/universal/RangeSlider.qml
index ec2ff7c8..fec8bb18 100644
--- a/src/imports/controls/universal/RangeSlider.qml
+++ b/src/imports/controls/universal/RangeSlider.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.RangeSlider {
id: control
@@ -60,7 +60,9 @@ T.RangeSlider {
y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height))
radius: 4
- color: control.first.pressed ? control.Universal.chromeHighColor : control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
+ color: control.first.pressed ? control.Universal.chromeHighColor :
+ control.first.hovered ? control.Universal.chromeAltLowColor :
+ control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
}
second.handle: Rectangle {
@@ -73,7 +75,9 @@ T.RangeSlider {
y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height))
radius: 4
- color: control.second.pressed ? control.Universal.chromeHighColor : control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
+ color: control.second.pressed ? control.Universal.chromeHighColor :
+ control.second.hovered ? control.Universal.chromeAltLowColor :
+ control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
}
background: Item {
@@ -95,7 +99,8 @@ T.RangeSlider {
width: parent.horizontal ? parent.width : 2 // SliderBackgroundThemeHeight
height: !parent.horizontal ? parent.height : 2 // SliderBackgroundThemeHeight
- color: control.enabled ? control.Universal.baseMediumLowColor : control.Universal.chromeDisabledHighColor
+ color: control.hovered && !control.pressed ? control.Universal.baseMediumColor :
+ control.enabled ? control.Universal.baseMediumLowColor : control.Universal.chromeDisabledHighColor
}
Rectangle {
diff --git a/src/imports/controls/universal/RoundButton.qml b/src/imports/controls/universal/RoundButton.qml
new file mode 100644
index 00000000..9a50c0fe
--- /dev/null
+++ b/src/imports/controls/universal/RoundButton.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+
+T.RoundButton {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
+
+ padding: 8
+
+ property bool useSystemFocusVisuals: true
+
+ contentItem: Text {
+ text: control.text
+ font: control.font
+ elide: Text.ElideRight
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+
+ opacity: enabled ? 1.0 : 0.2
+ color: control.Universal.foreground
+ }
+
+ background: Rectangle {
+ implicitWidth: 32
+ implicitHeight: 32
+
+ radius: control.radius
+ visible: !control.flat || control.down || control.checked || control.highlighted
+ color: control.down ? control.Universal.baseMediumLowColor :
+ control.enabled && (control.highlighted || control.checked) ? control.Universal.accent :
+ control.Universal.baseLowColor
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ radius: control.radius
+ color: "transparent"
+ visible: control.hovered
+ border.width: 2 // ButtonBorderThemeThickness
+ border.color: control.Universal.baseMediumLowColor
+ }
+ }
+}
diff --git a/src/imports/controls/universal/ScrollBar.qml b/src/imports/controls/universal/ScrollBar.qml
index 1ac627a7..6d5c84fe 100644
--- a/src/imports/controls/universal/ScrollBar.qml
+++ b/src/imports/controls/universal/ScrollBar.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ScrollBar {
id: control
@@ -52,7 +52,8 @@ T.ScrollBar {
implicitWidth: 12
implicitHeight: 12
- color: control.pressed ? control.Universal.baseMediumColor : control.Universal.chromeHighColor
+ color: control.pressed ? control.Universal.baseMediumColor :
+ control.hovered ? control.Universal.baseMediumLowColor : control.Universal.chromeHighColor
visible: control.size < 1.0
opacity: 0.0
}
diff --git a/src/imports/controls/universal/ScrollIndicator.qml b/src/imports/controls/universal/ScrollIndicator.qml
index ce289ce3..f03bc819 100644
--- a/src/imports/controls/universal/ScrollIndicator.qml
+++ b/src/imports/controls/universal/ScrollIndicator.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ScrollIndicator {
id: control
diff --git a/src/imports/controls/universal/Slider.qml b/src/imports/controls/universal/Slider.qml
index baf91211..472f5455 100644
--- a/src/imports/controls/universal/Slider.qml
+++ b/src/imports/controls/universal/Slider.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Slider {
id: control
@@ -60,7 +60,9 @@ T.Slider {
y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))
radius: 4
- color: control.pressed ? control.Universal.chromeHighColor : control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
+ color: control.pressed ? control.Universal.chromeHighColor :
+ control.hovered ? control.Universal.chromeAltLowColor :
+ control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
}
background: Item {
@@ -82,7 +84,8 @@ T.Slider {
width: parent.horizontal ? parent.width : 2 // SliderTrackThemeHeight
height: !parent.horizontal ? parent.height : 2 // SliderTrackThemeHeight
- color: control.enabled ? control.Universal.baseMediumLowColor : control.Universal.chromeDisabledHighColor
+ color: control.hovered && !control.pressed ? control.Universal.baseMediumColor :
+ control.enabled ? control.Universal.baseMediumLowColor : control.Universal.chromeDisabledHighColor
}
Rectangle {
diff --git a/src/imports/controls/universal/SpinBox.qml b/src/imports/controls/universal/SpinBox.qml
index d3647114..40060038 100644
--- a/src/imports/controls/universal/SpinBox.qml
+++ b/src/imports/controls/universal/SpinBox.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.SpinBox {
id: control
@@ -79,7 +79,7 @@ T.SpinBox {
readOnly: !control.editable
validator: control.validator
- inputMethodHints: Qt.ImhFormattedNumbersOnly
+ inputMethodHints: Qt.ImhDigitsOnly
}
up.indicator: Item {
@@ -92,9 +92,11 @@ T.SpinBox {
x: 2; y: 4
width: parent.width - 4
height: parent.height - 8
- color: !control.up.pressed ? "transparent" :
- control.activeFocus ? control.Universal.accent
- : control.Universal.chromeDisabledLowColor
+ color: control.activeFocus ? control.Universal.accent :
+ control.up.pressed ? control.Universal.baseMediumLowColor :
+ control.up.hovered ? control.Universal.baseLowColor : "transparent"
+ visible: control.up.pressed || control.up.hovered
+ opacity: control.activeFocus && !control.up.pressed ? 0.4 : 1.0
}
Image {
@@ -118,9 +120,11 @@ T.SpinBox {
x: 2; y: 4
width: parent.width - 4
height: parent.height - 8
- color: !control.down.pressed ? "transparent" :
- control.activeFocus ? control.Universal.accent
- : control.Universal.chromeDisabledLowColor
+ color: control.activeFocus ? control.Universal.accent :
+ control.down.pressed ? control.Universal.baseMediumLowColor :
+ control.down.hovered ? control.Universal.baseLowColor : "transparent"
+ visible: control.down.pressed || control.down.hovered
+ opacity: control.activeFocus && !control.down.pressed ? 0.4 : 1.0
}
Image {
@@ -140,7 +144,8 @@ T.SpinBox {
border.width: 2 // TextControlBorderThemeThickness
border.color: !control.enabled ? control.Universal.baseLowColor :
- control.activeFocus ? control.Universal.accent : control.Universal.chromeDisabledLowColor
+ control.activeFocus ? control.Universal.accent :
+ control.hovered ? control.Universal.baseMediumColor : control.Universal.chromeDisabledLowColor
color: control.enabled ? control.Universal.background : control.Universal.baseLowColor
}
}
diff --git a/src/imports/controls/universal/StackView.qml b/src/imports/controls/universal/StackView.qml
index 4f37bb76..6e6d1b50 100644
--- a/src/imports/controls/universal/StackView.qml
+++ b/src/imports/controls/universal/StackView.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.StackView {
id: control
diff --git a/src/imports/controls/universal/SwipeDelegate.qml b/src/imports/controls/universal/SwipeDelegate.qml
index 82c1e744..bc82e40e 100644
--- a/src/imports/controls/universal/SwipeDelegate.qml
+++ b/src/imports/controls/universal/SwipeDelegate.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.SwipeDelegate {
id: control
@@ -84,7 +84,8 @@ T.SwipeDelegate {
Rectangle {
width: parent.width
height: parent.height
- color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ color: control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
width: parent.width
height: parent.height
diff --git a/src/imports/controls/universal/Switch.qml b/src/imports/controls/universal/Switch.qml
index b42361dc..2b0012d5 100644
--- a/src/imports/controls/universal/Switch.qml
+++ b/src/imports/controls/universal/Switch.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.Switch {
id: control
diff --git a/src/imports/controls/universal/SwitchDelegate.qml b/src/imports/controls/universal/SwitchDelegate.qml
index 558f5cfb..5e4a1c52 100644
--- a/src/imports/controls/universal/SwitchDelegate.qml
+++ b/src/imports/controls/universal/SwitchDelegate.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.SwitchDelegate {
id: control
@@ -76,8 +76,9 @@ T.SwitchDelegate {
}
background: Rectangle {
- visible: control.down || control.highlighted || control.visualFocus
- color: control.down ? control.Universal.listMediumColor : control.Universal.altMediumLowColor
+ visible: control.down || control.highlighted || control.visualFocus || control.hovered
+ color: control.down ? control.Universal.listMediumColor :
+ control.hovered ? control.Universal.listLowColor : control.Universal.altMediumLowColor
Rectangle {
width: parent.width
height: parent.height
diff --git a/src/imports/controls/universal/SwitchIndicator.qml b/src/imports/controls/universal/SwitchIndicator.qml
index b3d44d9e..0f68d26a 100644
--- a/src/imports/controls/universal/SwitchIndicator.qml
+++ b/src/imports/controls/universal/SwitchIndicator.qml
@@ -34,21 +34,28 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
-Rectangle {
+Item {
implicitWidth: 44
implicitHeight: 20
- radius: 10
- color: !control.enabled ? "transparent" :
- control.pressed ? control.Universal.baseMediumColor :
- control.checked ? control.Universal.accent : "transparent"
- border.color: !control.enabled ? control.Universal.baseLowColor :
- control.checked && !control.pressed ? control.Universal.accent : control.Universal.baseMediumColor
- border.width: 2
+ Rectangle {
+ width: parent.width
+ height: parent.height
+
+ radius: 10
+ color: !control.enabled ? "transparent" :
+ control.pressed ? control.Universal.baseMediumColor :
+ control.checked ? control.Universal.accent : "transparent"
+ border.color: !control.enabled ? control.Universal.baseLowColor :
+ control.checked && !control.pressed ? control.Universal.accent :
+ control.hovered && !control.checked && !control.pressed ? control.Universal.baseHighColor : control.Universal.baseMediumColor
+ opacity: control.hovered && control.checked && !control.pressed ? (control.Universal.theme === Universal.Light ? 0.7 : 0.9) : 1.0
+ border.width: 2
+ }
property Item control
@@ -58,7 +65,8 @@ Rectangle {
radius: 5
color: !control.enabled ? control.Universal.baseLowColor :
- control.pressed || control.checked ? control.Universal.chromeWhiteColor : control.Universal.baseMediumHighColor
+ control.pressed || control.checked ? control.Universal.chromeWhiteColor :
+ control.hovered && !control.checked ? control.Universal.baseHighColor : control.Universal.baseMediumHighColor
x: Math.max(5, Math.min(parent.width - width - 5,
control.visualPosition * parent.width - (width / 2)))
diff --git a/src/imports/controls/universal/TabBar.qml b/src/imports/controls/universal/TabBar.qml
index 7c2e83a6..a8d80fec 100644
--- a/src/imports/controls/universal/TabBar.qml
+++ b/src/imports/controls/universal/TabBar.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.7
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.TabBar {
id: control
diff --git a/src/imports/controls/universal/TabButton.qml b/src/imports/controls/universal/TabButton.qml
index d503c86a..04f04291 100644
--- a/src/imports/controls/universal/TabButton.qml
+++ b/src/imports/controls/universal/TabButton.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.TabButton {
id: control
@@ -56,7 +56,7 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- opacity: control.checked || control.down ? 1.0 : 0.2
- color: control.Universal.foreground
+ opacity: control.checked || control.down || control.hovered ? 1.0 : 0.2
+ color: control.hovered ? control.Universal.baseMediumHighColor : control.Universal.foreground
}
}
diff --git a/src/imports/controls/universal/TextArea.qml b/src/imports/controls/universal/TextArea.qml
index 43fd40f4..8d422a2c 100644
--- a/src/imports/controls/universal/TextArea.qml
+++ b/src/imports/controls/universal/TextArea.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.TextArea {
id: control
@@ -83,7 +83,8 @@ T.TextArea {
border.width: 2 // TextControlBorderThemeThickness
border.color: !control.enabled ? control.Universal.baseLowColor :
- control.activeFocus ? control.Universal.accent : control.Universal.chromeDisabledLowColor
+ control.activeFocus ? control.Universal.accent :
+ control.hovered ? control.Universal.baseMediumColor : control.Universal.chromeDisabledLowColor
color: control.enabled ? control.Universal.background : control.Universal.baseLowColor
}
}
diff --git a/src/imports/controls/universal/TextField.qml b/src/imports/controls/universal/TextField.qml
index bd496ecc..5723e484 100644
--- a/src/imports/controls/universal/TextField.qml
+++ b/src/imports/controls/universal/TextField.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.TextField {
id: control
@@ -84,7 +84,8 @@ T.TextField {
border.width: 2 // TextControlBorderThemeThickness
border.color: !control.enabled ? control.Universal.baseLowColor :
- control.activeFocus ? control.Universal.accent : control.Universal.chromeDisabledLowColor
+ control.activeFocus ? control.Universal.accent :
+ control.hovered ? control.Universal.baseMediumColor : control.Universal.chromeDisabledLowColor
color: control.enabled ? control.Universal.background : control.Universal.baseLowColor
}
}
diff --git a/src/imports/controls/universal/ToolBar.qml b/src/imports/controls/universal/ToolBar.qml
index 48e200c0..35f79806 100644
--- a/src/imports/controls/universal/ToolBar.qml
+++ b/src/imports/controls/universal/ToolBar.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ToolBar {
id: control
@@ -47,8 +47,6 @@ T.ToolBar {
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
- contentItem: Item { }
-
background: Rectangle {
implicitHeight: 48 // AppBarThemeCompactHeight
color: control.Universal.chromeMediumColor
diff --git a/src/imports/controls/universal/ToolButton.qml b/src/imports/controls/universal/ToolButton.qml
index cb87130d..4dad17f7 100644
--- a/src/imports/controls/universal/ToolButton.qml
+++ b/src/imports/controls/universal/ToolButton.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ToolButton {
id: control
@@ -66,7 +66,13 @@ T.ToolButton {
implicitWidth: 68
implicitHeight: 48 // AppBarThemeCompactHeight
- color: control.down ? control.Universal.listMediumColor :
- control.enabled && (control.highlighted || control.checked) ? control.Universal.accent : "transparent"
+ color: control.enabled && (control.highlighted || control.checked) ? control.Universal.accent : "transparent"
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ visible: control.down || control.hovered
+ color: control.down ? control.Universal.listMediumColor : control.Universal.listLowColor
+ }
}
}
diff --git a/src/imports/controls/universal/ToolSeparator.qml b/src/imports/controls/universal/ToolSeparator.qml
new file mode 100644
index 00000000..a4a5f18c
--- /dev/null
+++ b/src/imports/controls/universal/ToolSeparator.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+
+T.ToolSeparator {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
+
+ leftPadding: vertical ? 16 : 12
+ rightPadding: vertical ? 15 : 12
+ topPadding: vertical ? 12 : 16
+ bottomPadding: vertical ? 12 : 15
+
+ //! [contentItem]
+ contentItem: Rectangle {
+ implicitWidth: vertical ? 1 : 20
+ implicitHeight: vertical ? 20 : 1
+ color: control.Universal.baseMediumLowColor
+ }
+ //! [contentItem]
+}
diff --git a/src/imports/controls/universal/ToolTip.qml b/src/imports/controls/universal/ToolTip.qml
index 423e729d..bd3d54e7 100644
--- a/src/imports/controls/universal/ToolTip.qml
+++ b/src/imports/controls/universal/ToolTip.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
T.ToolTip {
id: control
diff --git a/src/imports/controls/universal/Tumbler.qml b/src/imports/controls/universal/Tumbler.qml
index 7b134b84..e7093d0a 100644
--- a/src/imports/controls/universal/Tumbler.qml
+++ b/src/imports/controls/universal/Tumbler.qml
@@ -34,10 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls.Universal 2.0
-import QtQuick.Controls 2.0
+import QtQuick 2.8
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls.Universal 2.1
+import QtQuick.Controls 2.1
+import QtQuick.Controls.impl 2.1
T.Tumbler {
id: control
@@ -54,22 +55,16 @@ T.Tumbler {
verticalAlignment: Text.AlignVCenter
}
- contentItem: PathView {
- id: pathView
+ contentItem: TumblerView {
+ id: tumblerView
model: control.model
delegate: control.delegate
- clip: true
- pathItemCount: control.visibleItemCount + 1
- preferredHighlightBegin: 0.5
- preferredHighlightEnd: 0.5
- dragMargin: width / 2
-
path: Path {
- startX: pathView.width / 2
- startY: -pathView.delegateHeight / 2
+ startX: tumblerView.width / 2
+ startY: -tumblerView.delegateHeight / 2
PathLine {
- x: pathView.width / 2
- y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
+ x: tumblerView.width / 2
+ y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
}
}
diff --git a/src/imports/controls/universal/qquickuniversalprogressring.cpp b/src/imports/controls/universal/qquickuniversalprogressring.cpp
index ac087c78..1d733fed 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressring.cpp
@@ -241,7 +241,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa
QSGOpacityNode *opacityNode = new QSGOpacityNode;
transformNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
opacityNode->appendChildNode(rectNode);
}
@@ -249,7 +249,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa
QSGNode *opacityNode = transformNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(rect);
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
index 16f394f1..32af5113 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
@@ -38,10 +38,10 @@
#include <QtCore/qmath.h>
#include <QtCore/qeasingcurve.h>
-#include <QtQuick/qsgsimplerectnode.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickanimatorjob_p.h>
#include <QtQuick/private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -106,7 +106,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(m_node->firstChild());
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
Q_ASSERT(!geometryNode || geometryNode->type() == QSGNode::GeometryNodeType);
if (!geometryNode)
return;
@@ -286,9 +286,9 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
if (!m_indeterminate)
bounds.setWidth(m_progress * bounds.width());
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(oldNode);
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(oldNode);
if (!geometryNode)
- geometryNode = new QSGSimpleRectNode(bounds, Qt::transparent);
+ geometryNode = window()->createRectangleNode();
geometryNode->setRect(bounds);
geometryNode->setColor(m_indeterminate ? Qt::transparent : m_color);
@@ -317,7 +317,7 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
QSGOpacityNode *opacityNode = new QSGOpacityNode;
ellipseNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
rectNode->setRadius(EllipseDiameter / 2);
opacityNode->appendChildNode(rectNode);
@@ -330,7 +330,7 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
QSGNode *opacityNode = ellipseNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(QRectF((EllipseCount - i - 1) * (EllipseDiameter + EllipseOffset), (height() - EllipseDiameter) / 2, EllipseDiameter, EllipseDiameter));
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp
index 2328f1a5..b33c27e8 100644
--- a/src/imports/controls/universal/qquickuniversalstyle.cpp
+++ b/src/imports/controls/universal/qquickuniversalstyle.cpp
@@ -132,6 +132,15 @@ static QRgb qquickuniversal_accent_color(QQuickUniversalStyle::Color accent)
return colors[accent];
}
+extern bool qt_is_dark_system_theme();
+
+static QQuickUniversalStyle::Theme qquickuniversal_effective_theme(QQuickUniversalStyle::Theme theme)
+{
+ if (theme == QQuickUniversalStyle::System)
+ theme = qt_is_dark_system_theme() ? QQuickUniversalStyle::Dark : QQuickUniversalStyle::Light;
+ return theme;
+}
+
// If no value was inherited from a parent or explicitly set, the "global" values are used.
// The initial, default values of the globals are hard-coded here, but the environment
// variables and .conf file override them if specified.
@@ -164,6 +173,7 @@ QQuickUniversalStyle::Theme QQuickUniversalStyle::theme() const
void QQuickUniversalStyle::setTheme(Theme theme)
{
+ theme = qquickuniversal_effective_theme(theme);
m_explicitTheme = true;
if (m_theme == theme)
return;
@@ -536,7 +546,7 @@ void QQuickUniversalStyle::init()
QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_THEME", settings, QStringLiteral("Theme"));
Theme themeEnum = toEnumValue<Theme>(themeValue, &ok);
if (ok)
- GlobalTheme = m_theme = themeEnum;
+ GlobalTheme = m_theme = qquickuniversal_effective_theme(themeEnum);
else if (!themeValue.isEmpty())
qWarning().nospace().noquote() << "Universal: unknown theme value: " << themeValue;
diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h
index bf0a84d8..0d3a6dab 100644
--- a/src/imports/controls/universal/qquickuniversalstyle_p.h
+++ b/src/imports/controls/universal/qquickuniversalstyle_p.h
@@ -93,7 +93,7 @@ public:
static QQuickUniversalStyle *qmlAttachedProperties(QObject *object);
- enum Theme { Light, Dark };
+ enum Theme { Light, Dark, System };
Q_ENUM(Theme)
Theme theme() const;
diff --git a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
index ddad6548..394e9162 100644
--- a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
@@ -77,6 +77,7 @@ QtQuickControls2UniversalStylePlugin::QtQuickControls2UniversalStylePlugin(QObje
void QtQuickControls2UniversalStylePlugin::registerTypes(const char *uri)
{
qmlRegisterUncreatableType<QQuickUniversalStyle>(uri, 2, 0, "Universal", tr("Universal is an attached property"));
+ qmlRegisterRevision<QQuickUniversalStyle, 1>(uri, 2, 1);
}
void QtQuickControls2UniversalStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -87,6 +88,7 @@ void QtQuickControls2UniversalStylePlugin::initializeEngine(QQmlEngine *engine,
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickUniversalFocusRectangle>(import, 2, 0, "FocusRectangle");
+ qmlRegisterRevision<QQuickUniversalFocusRectangle, 1>(import, 2, 1);
qmlRegisterType<QQuickUniversalProgressRing>(import, 2, 0, "ProgressRing");
qmlRegisterType<QQuickUniversalProgressRingAnimator>(import, 2, 0, "ProgressRingAnimator");
qmlRegisterType<QQuickUniversalProgressStrip>(import, 2, 0, "ProgressStrip");
diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri
index 61b6912a..3697a2a6 100644
--- a/src/imports/controls/universal/universal.pri
+++ b/src/imports/controls/universal/universal.pri
@@ -7,6 +7,8 @@ QML_FILES += \
$$PWD/CheckIndicator.qml \
$$PWD/ComboBox.qml \
$$PWD/Dial.qml \
+ $$PWD/Dialog.qml \
+ $$PWD/DialogButtonBox.qml \
$$PWD/Drawer.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
@@ -14,6 +16,7 @@ QML_FILES += \
$$PWD/Label.qml \
$$PWD/Menu.qml \
$$PWD/MenuItem.qml \
+ $$PWD/MenuSeparator.qml \
$$PWD/Page.qml \
$$PWD/PageIndicator.qml \
$$PWD/Pane.qml \
@@ -23,6 +26,7 @@ QML_FILES += \
$$PWD/RadioDelegate.qml \
$$PWD/RadioIndicator.qml \
$$PWD/RangeSlider.qml \
+ $$PWD/RoundButton.qml \
$$PWD/ScrollBar.qml \
$$PWD/ScrollIndicator.qml \
$$PWD/Slider.qml \
@@ -38,6 +42,7 @@ QML_FILES += \
$$PWD/TextField.qml \
$$PWD/ToolBar.qml \
$$PWD/ToolButton.qml \
+ $$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
$$PWD/Tumbler.qml
diff --git a/src/imports/controls/universal/universal.pro b/src/imports/controls/universal/universal.pro
index f10f21b0..c3835016 100644
--- a/src/imports/controls/universal/universal.pro
+++ b/src/imports/controls/universal/universal.pro
@@ -1,6 +1,6 @@
TARGET = qtquickcontrols2universalstyleplugin
TARGETPATH = QtQuick/Controls.2/Universal
-IMPORT_VERSION = 2.0
+IMPORT_VERSION = 2.1
QT += qml quick
QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 3227cb99..e1da66c9 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \
controls \
calendar \
+ platform \
templates
SUBDIRS += \
diff --git a/src/imports/platform/doc/images/qtlabsplatform-colordialog-gtk.png b/src/imports/platform/doc/images/qtlabsplatform-colordialog-gtk.png
new file mode 100644
index 00000000..e0785a05
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-colordialog-gtk.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-filedialog-gtk.png b/src/imports/platform/doc/images/qtlabsplatform-filedialog-gtk.png
new file mode 100644
index 00000000..3bc963d0
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-filedialog-gtk.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-folderdialog-gtk.png b/src/imports/platform/doc/images/qtlabsplatform-folderdialog-gtk.png
new file mode 100644
index 00000000..ea4d929d
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-folderdialog-gtk.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-fontdialog-gtk.png b/src/imports/platform/doc/images/qtlabsplatform-fontdialog-gtk.png
new file mode 100644
index 00000000..9f3dc2e7
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-fontdialog-gtk.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-menu.png b/src/imports/platform/doc/images/qtlabsplatform-menu.png
new file mode 100644
index 00000000..120d263b
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-menu.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-menubar.png b/src/imports/platform/doc/images/qtlabsplatform-menubar.png
new file mode 100644
index 00000000..685d03b3
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-menubar.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-messagedialog-android.png b/src/imports/platform/doc/images/qtlabsplatform-messagedialog-android.png
new file mode 100644
index 00000000..a1de1806
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-messagedialog-android.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png b/src/imports/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png
new file mode 100644
index 00000000..7062ed90
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-messagedialog-informative-android.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png
new file mode 100644
index 00000000..0d0ecfab
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-menu.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-message.png b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-message.png
new file mode 100644
index 00000000..d929ca97
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon-message.png
Binary files differ
diff --git a/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon.png b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon.png
new file mode 100644
index 00000000..58c40d73
--- /dev/null
+++ b/src/imports/platform/doc/images/qtlabsplatform-systemtrayicon.png
Binary files differ
diff --git a/src/imports/platform/doc/qtlabsplatform.qdocconf b/src/imports/platform/doc/qtlabsplatform.qdocconf
new file mode 100644
index 00000000..e78a9644
--- /dev/null
+++ b/src/imports/platform/doc/qtlabsplatform.qdocconf
@@ -0,0 +1,37 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+
+project = QtLabsPlatform
+description = Qt Labs Platform Reference Documentation
+version = $QT_VERSION
+
+qhp.projects = QtLabsPlatform
+
+qhp.QtLabsPlatform.file = qtlabsplatform.qhp
+qhp.QtLabsPlatform.namespace = org.qt-project.qtlabsplatform.$QT_VERSION_TAG
+qhp.QtLabsPlatform.virtualFolder = qtlabsplatform
+qhp.QtLabsPlatform.indexTitle = Qt Labs Platform
+qhp.QtLabsPlatform.indexRoot =
+
+qhp.QtLabsPlatform.filterAttributes = qtlabsplatform $QT_VERSION qtrefdoc
+qhp.QtLabsPlatform.customFilters.Qt.name = QtLabsPlatform $QT_VERSION
+qhp.QtLabsPlatform.customFilters.Qt.filterAttributes = qtlabsplatform $QT_VERSION
+
+qhp.QtLabsPlatform.subprojects = qmltypes
+qhp.QtLabsPlatform.subprojects.qmltypes.title = QML Types
+qhp.QtLabsPlatform.subprojects.qmltypes.indexTitle = Qt Labs Platform QML Types
+qhp.QtLabsPlatform.subprojects.qmltypes.selectors = qmlclass
+qhp.QtLabsPlatform.subprojects.qmltypes.sortPages = true
+
+depends = qtcore qtgui qtdoc qtqml qtquick qtquickcontrols2 qtwidgets
+
+headerdirs += ../
+sourcedirs += ../
+
+imagedirs += images
+
+navigation.landingpage = "Qt Labs Platform"
+navigation.qmltypespage = "Qt Labs Platform QML Types"
+
+tagfile = qtlabsplatform.tags
+
+macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}"
diff --git a/src/imports/platform/doc/src/includes/widgets.qdocinc b/src/imports/platform/doc/src/includes/widgets.qdocinc
new file mode 100644
index 00000000..c89c3ca0
--- /dev/null
+++ b/src/imports/platform/doc/src/includes/widgets.qdocinc
@@ -0,0 +1,29 @@
+//! [1]
+The Qt Labs Platform module uses Qt Widgets as a fallback on platforms that
+do not have a native implementation available. Therefore, applications that
+use types from the Qt Labs Platform module should link to QtWidgets and use
+\l QApplication instead of \l QGuiApplication.
+
+To link against the QtWidgets library, add the following to your qmake project
+file:
+
+\code
+QT += widgets
+\endcode
+
+Create an instance of \l QApplication in \c main():
+
+\code
+#include <QApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QApplication app(argc, argv);
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ return app.exec();
+}
+\endcode
+//! [1]
diff --git a/src/imports/platform/doc/src/qtlabsplatform-index.qdoc b/src/imports/platform/doc/src/qtlabsplatform-index.qdoc
new file mode 100644
index 00000000..aec2a923
--- /dev/null
+++ b/src/imports/platform/doc/src/qtlabsplatform-index.qdoc
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtlabsplatform-index.html
+ \title Qt Labs Platform
+
+ \brief The experimental Qt Labs Platform module provides QML types for
+ native platform extensions.
+
+ The experimental Qt Labs Platform module provides QML types for native
+ platform extensions. The module was introduced in Qt 5.8.
+
+ \section1 QML Types
+
+ \generatelist {qmltypesbymodule Qt.labs.platform}
+
+ \labs
+
+ \section1 Related Information
+
+ \list
+ \li \l{Qt Quick}
+ \li \l{Qt Quick Controls 2}
+ \endlist
+*/
diff --git a/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc
new file mode 100644
index 00000000..470b93c4
--- /dev/null
+++ b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule Qt.labs.platform 1.0
+ \title Qt Labs Platform QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for native platform extensions.
+
+ The experimental \l{Qt Labs Platform} module provides QML types for native
+ platform extensions. These QML types work in conjunction with \l{Qt Quick}
+ and \l{Qt Quick Controls 2}.
+
+ The QML types can be imported into your application using the
+ following import statement in your .qml file:
+
+ \badcode
+ import Qt.labs.platform 1.0
+ \endcode
+
+ \section1 QML Types
+
+ \generatelist {qmltypesbymodule Qt.labs.platform}
+
+ \labs
+
+ \section1 Related Information
+
+ \list
+ \li \l {Qt Quick Controls 2 QML Types}
+ \endlist
+
+ \noautolist
+*/
diff --git a/src/imports/platform/platform.pri b/src/imports/platform/platform.pri
new file mode 100644
index 00000000..1e300251
--- /dev/null
+++ b/src/imports/platform/platform.pri
@@ -0,0 +1,31 @@
+HEADERS += \
+ $$PWD/qquickplatformcolordialog_p.h \
+ $$PWD/qquickplatformdialog_p.h \
+ $$PWD/qquickplatformfiledialog_p.h \
+ $$PWD/qquickplatformfolderdialog_p.h \
+ $$PWD/qquickplatformfontdialog_p.h \
+ $$PWD/qquickplatformiconloader_p.h \
+ $$PWD/qquickplatformmenu_p.h \
+ $$PWD/qquickplatformmenubar_p.h \
+ $$PWD/qquickplatformmenuitem_p.h \
+ $$PWD/qquickplatformmenuitemgroup_p.h \
+ $$PWD/qquickplatformmenuseparator_p.h \
+ $$PWD/qquickplatformmessagedialog_p.h \
+ $$PWD/qquickplatformstandardpaths_p.h \
+ $$PWD/qquickplatformsystemtrayicon_p.h
+
+SOURCES += \
+ $$PWD/qquickplatformcolordialog.cpp \
+ $$PWD/qquickplatformdialog.cpp \
+ $$PWD/qquickplatformfiledialog.cpp \
+ $$PWD/qquickplatformfolderdialog.cpp \
+ $$PWD/qquickplatformfontdialog.cpp \
+ $$PWD/qquickplatformiconloader.cpp \
+ $$PWD/qquickplatformmenu.cpp \
+ $$PWD/qquickplatformmenubar.cpp \
+ $$PWD/qquickplatformmenuitem.cpp \
+ $$PWD/qquickplatformmenuitemgroup.cpp \
+ $$PWD/qquickplatformmenuseparator.cpp \
+ $$PWD/qquickplatformmessagedialog.cpp \
+ $$PWD/qquickplatformstandardpaths.cpp \
+ $$PWD/qquickplatformsystemtrayicon.cpp
diff --git a/src/imports/platform/platform.pro b/src/imports/platform/platform.pro
new file mode 100644
index 00000000..043b0172
--- /dev/null
+++ b/src/imports/platform/platform.pro
@@ -0,0 +1,22 @@
+TARGET = qtlabsplatformplugin
+TARGETPATH = Qt/labs/platform
+IMPORT_VERSION = 1.0
+
+QT += qml quick
+QT_PRIVATE += core-private gui-private qml-private quick-private
+
+DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
+
+QMAKE_DOCS = $$PWD/doc/qtlabsplatform.qdocconf
+
+OTHER_FILES += \
+ qmldir
+
+SOURCES += \
+ $$PWD/qtlabsplatformplugin.cpp
+
+include(platform.pri)
+qtHaveModule(widgets): include(widgets/widgets.pri)
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/imports/platform/plugins.qmltypes b/src/imports/platform/plugins.qmltypes
new file mode 100644
index 00000000..6913405b
--- /dev/null
+++ b/src/imports/platform/plugins.qmltypes
@@ -0,0 +1,460 @@
+import QtQuick.tooling 1.2
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated by:
+// 'qmlplugindump -nonrelocatable Qt.labs.platform 1.0'
+
+Module {
+ dependencies: ["QtQuick 2.8"]
+ Component {
+ name: "QPlatformDialogHelper"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/StandardButton 1.0"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "StandardButtons"
+ values: {
+ "NoButton": 0,
+ "Ok": 1024,
+ "Save": 2048,
+ "SaveAll": 4096,
+ "Open": 8192,
+ "Yes": 16384,
+ "YesToAll": 32768,
+ "No": 65536,
+ "NoToAll": 131072,
+ "Abort": 262144,
+ "Retry": 524288,
+ "Ignore": 1048576,
+ "Close": 2097152,
+ "Cancel": 4194304,
+ "Discard": 8388608,
+ "Help": 16777216,
+ "Apply": 33554432,
+ "Reset": 67108864,
+ "RestoreDefaults": 134217728,
+ "FirstButton": 1024,
+ "LastButton": 134217728,
+ "LowestBit": 10,
+ "HighestBit": 27
+ }
+ }
+ Enum {
+ name: "ButtonRole"
+ values: {
+ "InvalidRole": -1,
+ "AcceptRole": 0,
+ "RejectRole": 1,
+ "DestructiveRole": 2,
+ "ActionRole": 3,
+ "HelpRole": 4,
+ "YesRole": 5,
+ "NoRole": 6,
+ "ResetRole": 7,
+ "ApplyRole": 8,
+ "NRoles": 9,
+ "RoleMask": 268435455,
+ "AlternateRole": 268435456,
+ "Stretch": 536870912,
+ "Reverse": 1073741824,
+ "EOL": -1
+ }
+ }
+ Signal { name: "accept" }
+ Signal { name: "reject" }
+ }
+ Component {
+ name: "QQuickPlatformColorDialog"
+ defaultProperty: "data"
+ prototype: "QQuickPlatformDialog"
+ exports: ["Qt.labs.platform/ColorDialog 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "color"; type: "QColor" }
+ Property { name: "currentColor"; type: "QColor" }
+ Property { name: "options"; type: "QColorDialogOptions::ColorDialogOptions" }
+ }
+ Component {
+ name: "QQuickPlatformDialog"
+ defaultProperty: "data"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/Dialog 1.0"]
+ isCreatable: false
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "StandardCode"
+ values: {
+ "Rejected": 0,
+ "Accepted": 1
+ }
+ }
+ Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
+ Property { name: "parentWindow"; type: "QWindow"; isPointer: true }
+ Property { name: "title"; type: "string" }
+ Property { name: "flags"; type: "Qt::WindowFlags" }
+ Property { name: "modality"; type: "Qt::WindowModality" }
+ Property { name: "visible"; type: "bool" }
+ Property { name: "result"; type: "int" }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Method { name: "open" }
+ Method { name: "close" }
+ Method { name: "accept" }
+ Method { name: "reject" }
+ Method {
+ name: "done"
+ Parameter { name: "result"; type: "int" }
+ }
+ }
+ Component {
+ name: "QQuickPlatformFileDialog"
+ defaultProperty: "data"
+ prototype: "QQuickPlatformDialog"
+ exports: ["Qt.labs.platform/FileDialog 1.0"]
+ exportMetaObjectRevisions: [0]
+ Enum {
+ name: "FileMode"
+ values: {
+ "OpenFile": 0,
+ "OpenFiles": 1,
+ "SaveFile": 2
+ }
+ }
+ Property { name: "fileMode"; type: "FileMode" }
+ Property { name: "file"; type: "QUrl" }
+ Property { name: "files"; type: "QList<QUrl>" }
+ Property { name: "currentFile"; type: "QUrl" }
+ Property { name: "currentFiles"; type: "QList<QUrl>" }
+ Property { name: "folder"; type: "QUrl" }
+ Property { name: "options"; type: "QFileDialogOptions::FileDialogOptions" }
+ Property { name: "nameFilters"; type: "QStringList" }
+ Property {
+ name: "selectedNameFilter"
+ type: "QQuickPlatformFileNameFilter"
+ isReadonly: true
+ isPointer: true
+ }
+ Property { name: "defaultSuffix"; type: "string" }
+ Property { name: "acceptLabel"; type: "string" }
+ Property { name: "rejectLabel"; type: "string" }
+ }
+ Component {
+ name: "QQuickPlatformFileNameFilter"
+ prototype: "QObject"
+ Property { name: "index"; type: "int" }
+ Property { name: "name"; type: "string"; isReadonly: true }
+ Property { name: "extensions"; type: "QStringList"; isReadonly: true }
+ Signal {
+ name: "indexChanged"
+ Parameter { name: "index"; type: "int" }
+ }
+ Signal {
+ name: "nameChanged"
+ Parameter { name: "name"; type: "string" }
+ }
+ Signal {
+ name: "extensionsChanged"
+ Parameter { name: "extensions"; type: "QStringList" }
+ }
+ }
+ Component {
+ name: "QQuickPlatformFolderDialog"
+ defaultProperty: "data"
+ prototype: "QQuickPlatformDialog"
+ exports: ["Qt.labs.platform/FolderDialog 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "folder"; type: "QUrl" }
+ Property { name: "currentFolder"; type: "QUrl" }
+ Property { name: "options"; type: "QFileDialogOptions::FileDialogOptions" }
+ Property { name: "acceptLabel"; type: "string" }
+ Property { name: "rejectLabel"; type: "string" }
+ }
+ Component {
+ name: "QQuickPlatformFontDialog"
+ defaultProperty: "data"
+ prototype: "QQuickPlatformDialog"
+ exports: ["Qt.labs.platform/FontDialog 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "font"; type: "QFont" }
+ Property { name: "currentFont"; type: "QFont" }
+ Property { name: "options"; type: "QFontDialogOptions::FontDialogOptions" }
+ }
+ Component {
+ name: "QQuickPlatformMenu"
+ defaultProperty: "data"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/Menu 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
+ Property { name: "items"; type: "QQuickPlatformMenuItem"; isList: true; isReadonly: true }
+ Property { name: "menuBar"; type: "QQuickPlatformMenuBar"; isReadonly: true; isPointer: true }
+ Property { name: "parentMenu"; type: "QQuickPlatformMenu"; isReadonly: true; isPointer: true }
+ Property {
+ name: "systemTrayIcon"
+ type: "QQuickPlatformSystemTrayIcon"
+ isReadonly: true
+ isPointer: true
+ }
+ Property { name: "menuItem"; type: "QQuickPlatformMenuItem"; isReadonly: true; isPointer: true }
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "visible"; type: "bool" }
+ Property { name: "minimumWidth"; type: "int" }
+ Property { name: "type"; type: "QPlatformMenu::MenuType" }
+ Property { name: "title"; type: "string" }
+ Property { name: "iconSource"; type: "QUrl" }
+ Property { name: "iconName"; type: "string" }
+ Property { name: "font"; type: "QFont" }
+ Signal { name: "aboutToShow" }
+ Signal { name: "aboutToHide" }
+ Method {
+ name: "open"
+ Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
+ }
+ Method { name: "close" }
+ Method {
+ name: "addItem"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method {
+ name: "insertItem"
+ Parameter { name: "index"; type: "int" }
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method {
+ name: "removeItem"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method {
+ name: "addMenu"
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method {
+ name: "insertMenu"
+ Parameter { name: "index"; type: "int" }
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method {
+ name: "removeMenu"
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method { name: "clear" }
+ }
+ Component {
+ name: "QQuickPlatformMenuBar"
+ defaultProperty: "data"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/MenuBar 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
+ Property { name: "menus"; type: "QQuickPlatformMenu"; isList: true; isReadonly: true }
+ Property { name: "window"; type: "QWindow"; isPointer: true }
+ Method {
+ name: "addMenu"
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method {
+ name: "insertMenu"
+ Parameter { name: "index"; type: "int" }
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method {
+ name: "removeMenu"
+ Parameter { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ }
+ Method { name: "clear" }
+ }
+ Component {
+ name: "QQuickPlatformMenuItem"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/MenuItem 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "menu"; type: "QQuickPlatformMenu"; isReadonly: true; isPointer: true }
+ Property { name: "subMenu"; type: "QQuickPlatformMenu"; isReadonly: true; isPointer: true }
+ Property { name: "group"; type: "QQuickPlatformMenuItemGroup"; isPointer: true }
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "visible"; type: "bool" }
+ Property { name: "separator"; type: "bool" }
+ Property { name: "checkable"; type: "bool" }
+ Property { name: "checked"; type: "bool" }
+ Property { name: "role"; type: "QPlatformMenuItem::MenuRole" }
+ Property { name: "text"; type: "string" }
+ Property { name: "iconSource"; type: "QUrl" }
+ Property { name: "iconName"; type: "string" }
+ Property { name: "shortcut"; type: "QVariant" }
+ Property { name: "font"; type: "QFont" }
+ Signal { name: "triggered" }
+ Signal { name: "hovered" }
+ Method { name: "toggle" }
+ }
+ Component {
+ name: "QQuickPlatformMenuItemGroup"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/MenuItemGroup 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "visible"; type: "bool" }
+ Property { name: "exclusive"; type: "bool" }
+ Property { name: "checkedItem"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ Property { name: "items"; type: "QQuickPlatformMenuItem"; isList: true; isReadonly: true }
+ Signal {
+ name: "triggered"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Signal {
+ name: "hovered"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method {
+ name: "addItem"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method {
+ name: "removeItem"
+ Parameter { name: "item"; type: "QQuickPlatformMenuItem"; isPointer: true }
+ }
+ Method { name: "clear" }
+ }
+ Component {
+ name: "QQuickPlatformMenuSeparator"
+ prototype: "QQuickPlatformMenuItem"
+ exports: ["Qt.labs.platform/MenuSeparator 1.0"]
+ exportMetaObjectRevisions: [0]
+ }
+ Component {
+ name: "QQuickPlatformMessageDialog"
+ defaultProperty: "data"
+ prototype: "QQuickPlatformDialog"
+ exports: ["Qt.labs.platform/MessageDialog 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "text"; type: "string" }
+ Property { name: "informativeText"; type: "string" }
+ Property { name: "detailedText"; type: "string" }
+ Property { name: "buttons"; type: "QPlatformDialogHelper::StandardButtons" }
+ Signal {
+ name: "clicked"
+ Parameter { name: "button"; type: "QPlatformDialogHelper::StandardButton" }
+ }
+ Signal { name: "okClicked" }
+ Signal { name: "saveClicked" }
+ Signal { name: "saveAllClicked" }
+ Signal { name: "openClicked" }
+ Signal { name: "yesClicked" }
+ Signal { name: "yesToAllClicked" }
+ Signal { name: "noClicked" }
+ Signal { name: "noToAllClicked" }
+ Signal { name: "abortClicked" }
+ Signal { name: "retryClicked" }
+ Signal { name: "ignoreClicked" }
+ Signal { name: "closeClicked" }
+ Signal { name: "cancelClicked" }
+ Signal { name: "discardClicked" }
+ Signal { name: "helpClicked" }
+ Signal { name: "applyClicked" }
+ Signal { name: "resetClicked" }
+ Signal { name: "restoreDefaultsClicked" }
+ }
+ Component {
+ name: "QQuickPlatformStandardPaths"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/StandardPaths 1.0"]
+ isCreatable: false
+ isSingleton: true
+ exportMetaObjectRevisions: [0]
+ Method {
+ name: "displayName"
+ type: "string"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ }
+ Method {
+ name: "findExecutable"
+ type: "QUrl"
+ Parameter { name: "executableName"; type: "string" }
+ Parameter { name: "paths"; type: "QStringList" }
+ }
+ Method {
+ name: "findExecutable"
+ type: "QUrl"
+ Parameter { name: "executableName"; type: "string" }
+ }
+ Method {
+ name: "locate"
+ type: "QUrl"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ Parameter { name: "fileName"; type: "string" }
+ Parameter { name: "options"; type: "QStandardPaths::LocateOptions" }
+ }
+ Method {
+ name: "locate"
+ type: "QUrl"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ Parameter { name: "fileName"; type: "string" }
+ }
+ Method {
+ name: "locateAll"
+ type: "QList<QUrl>"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ Parameter { name: "fileName"; type: "string" }
+ Parameter { name: "options"; type: "QStandardPaths::LocateOptions" }
+ }
+ Method {
+ name: "locateAll"
+ type: "QList<QUrl>"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ Parameter { name: "fileName"; type: "string" }
+ }
+ Method {
+ name: "setTestModeEnabled"
+ Parameter { name: "testMode"; type: "bool" }
+ }
+ Method {
+ name: "standardLocations"
+ type: "QList<QUrl>"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ }
+ Method {
+ name: "writableLocation"
+ type: "QUrl"
+ Parameter { name: "type"; type: "QStandardPaths::StandardLocation" }
+ }
+ }
+ Component {
+ name: "QQuickPlatformSystemTrayIcon"
+ prototype: "QObject"
+ exports: ["Qt.labs.platform/SystemTrayIcon 1.0"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "available"; type: "bool"; isReadonly: true }
+ Property { name: "supportsMessages"; type: "bool"; isReadonly: true }
+ Property { name: "visible"; type: "bool" }
+ Property { name: "iconSource"; type: "QUrl" }
+ Property { name: "iconName"; type: "string" }
+ Property { name: "tooltip"; type: "string" }
+ Property { name: "menu"; type: "QQuickPlatformMenu"; isPointer: true }
+ Signal {
+ name: "activated"
+ Parameter { name: "reason"; type: "QPlatformSystemTrayIcon::ActivationReason" }
+ }
+ Signal { name: "messageClicked" }
+ Method { name: "show" }
+ Method { name: "hide" }
+ Method {
+ name: "showMessage"
+ Parameter { name: "title"; type: "string" }
+ Parameter { name: "message"; type: "string" }
+ Parameter { name: "iconType"; type: "QPlatformSystemTrayIcon::MessageIcon" }
+ Parameter { name: "msecs"; type: "int" }
+ }
+ Method {
+ name: "showMessage"
+ Parameter { name: "title"; type: "string" }
+ Parameter { name: "message"; type: "string" }
+ Parameter { name: "iconType"; type: "QPlatformSystemTrayIcon::MessageIcon" }
+ }
+ Method {
+ name: "showMessage"
+ Parameter { name: "title"; type: "string" }
+ Parameter { name: "message"; type: "string" }
+ }
+ }
+}
diff --git a/src/imports/platform/qmldir b/src/imports/platform/qmldir
new file mode 100644
index 00000000..9653b7d3
--- /dev/null
+++ b/src/imports/platform/qmldir
@@ -0,0 +1,3 @@
+module Qt.labs.platform
+plugin qtlabsplatformplugin
+classname QtLabsPlatformPlugin
diff --git a/src/imports/platform/qquickplatformcolordialog.cpp b/src/imports/platform/qquickplatformcolordialog.cpp
new file mode 100644
index 00000000..36bb7d69
--- /dev/null
+++ b/src/imports/platform/qquickplatformcolordialog.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformcolordialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype ColorDialog
+ \inherits Dialog
+ \instantiates QQuickPlatformColorDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native color dialog.
+
+ The ColorDialog type provides a QML API for native platform color dialogs.
+
+ \image qtlabsplatform-colordialog-gtk.png
+
+ To show a color dialog, construct an instance of ColorDialog, set the
+ desired properties, and call \l {Dialog::}{open()}. The \l currentColor
+ property can be used to determine the currently selected color in the
+ dialog. The \l color property is updated only after the final selection
+ has been made by accepting the dialog.
+
+ \code
+ MenuItem {
+ text: "Color"
+ onTriggered: colorDialog.open()
+ }
+
+ ColorDialog {
+ id: colorDialog
+ currentColor: document.color
+ }
+
+ MyDocument {
+ id: document
+ color: colorDialog.color
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native platform color dialog is currently available on the following platforms:
+
+ \list
+ \li macOS
+ \li Linux (when running with the GTK+ platform theme)
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+*/
+
+QQuickPlatformColorDialog::QQuickPlatformColorDialog(QObject *parent)
+ : QQuickPlatformDialog(QPlatformTheme::ColorDialog, parent),
+ m_options(QColorDialogOptions::create())
+{
+}
+
+/*!
+ \qmlproperty color Qt.labs.platform::ColorDialog::color
+
+ This property holds the final accepted color.
+
+ Unlike the \l currentColor property, the \c color property is not updated
+ while the user is selecting colors in the dialog, but only after the final
+ selection has been made. That is, when the user has clicked \uicontrol OK
+ to accept a color. Alternatively, the \l {Dialog::}{accepted()} signal
+ can be handled to get the final selection.
+
+ \sa currentColor, {Dialog::}{accepted()}
+*/
+QColor QQuickPlatformColorDialog::color() const
+{
+ return m_color;
+}
+
+void QQuickPlatformColorDialog::setColor(const QColor &color)
+{
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ setCurrentColor(color);
+ emit colorChanged();
+}
+
+/*!
+ \qmlproperty color Qt.labs.platform::ColorDialog::currentColor
+
+ This property holds the currently selected color in the dialog.
+
+ Unlike the \l color property, the \c currentColor property is updated
+ while the user is selecting colors in the dialog, even before the final
+ selection has been made.
+
+ \sa color
+*/
+QColor QQuickPlatformColorDialog::currentColor() const
+{
+ if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(handle()))
+ return colorDialog->currentColor();
+ return m_currentColor;
+}
+
+void QQuickPlatformColorDialog::setCurrentColor(const QColor &color)
+{
+ if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(handle()))
+ colorDialog->setCurrentColor(color);
+ m_currentColor = color;
+}
+
+/*!
+ \qmlproperty flags Qt.labs.platform::ColorDialog::options
+
+ This property holds the various options that affect the look and feel of the dialog.
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the dialog is
+ visible is not guaranteed to have an immediate effect on the dialog (depending on
+ the option and on the platform).
+
+ Available options:
+ \value ColorDialog.ShowAlphaChannel Allow the user to select the alpha component of a color.
+ \value ColorDialog.NoButtons Don't display \uicontrol OK and \uicontrol Cancel buttons (useful for "live dialogs").
+*/
+QColorDialogOptions::ColorDialogOptions QQuickPlatformColorDialog::options() const
+{
+ return m_options->options();
+}
+
+void QQuickPlatformColorDialog::setOptions(QColorDialogOptions::ColorDialogOptions options)
+{
+ if (options == m_options->options())
+ return;
+
+ m_options->setOptions(options);
+ emit optionsChanged();
+}
+
+bool QQuickPlatformColorDialog::useNativeDialog() const
+{
+ return QQuickPlatformDialog::useNativeDialog()
+ && !m_options->testOption(QColorDialogOptions::DontUseNativeDialog);
+}
+
+void QQuickPlatformColorDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(dialog)) {
+ connect(colorDialog, &QPlatformColorDialogHelper::currentColorChanged, this, &QQuickPlatformColorDialog::currentColorChanged);
+ colorDialog->setOptions(m_options);
+ }
+}
+
+void QQuickPlatformColorDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ m_options->setWindowTitle(title());
+ if (QPlatformColorDialogHelper *colorDialog = qobject_cast<QPlatformColorDialogHelper *>(dialog))
+ colorDialog->setOptions(m_options);
+}
+
+void QQuickPlatformColorDialog::accept()
+{
+ setColor(currentColor());
+ QQuickPlatformDialog::accept();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformcolordialog_p.h b/src/imports/platform/qquickplatformcolordialog_p.h
new file mode 100644
index 00000000..33d6f0e8
--- /dev/null
+++ b/src/imports/platform/qquickplatformcolordialog_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMCOLORDIALOG_P_H
+#define QQUICKPLATFORMCOLORDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformdialog_p.h"
+#include <QtGui/qcolor.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformColorDialog : public QQuickPlatformDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
+ Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor NOTIFY currentColorChanged FINAL)
+ Q_PROPERTY(QColorDialogOptions::ColorDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL)
+ Q_FLAGS(QColorDialogOptions::ColorDialogOptions)
+
+public:
+ explicit QQuickPlatformColorDialog(QObject *parent = nullptr);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ QColor currentColor() const;
+ void setCurrentColor(const QColor &color);
+
+ QColorDialogOptions::ColorDialogOptions options() const;
+ void setOptions(QColorDialogOptions::ColorDialogOptions options);
+
+Q_SIGNALS:
+ void colorChanged();
+ void currentColorChanged();
+ void optionsChanged();
+
+protected:
+ bool useNativeDialog() const override;
+ void onCreate(QPlatformDialogHelper *dialog) override;
+ void onShow(QPlatformDialogHelper *dialog) override;
+ void accept() override;
+
+private:
+ QColor m_color;
+ QColor m_currentColor; // TODO: QColorDialogOptions::initialColor
+ QSharedPointer<QColorDialogOptions> m_options;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformColorDialog)
+
+#endif // QQUICKPLATFORMCOLORDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformdialog.cpp b/src/imports/platform/qquickplatformdialog.cpp
new file mode 100644
index 00000000..95bc6426
--- /dev/null
+++ b/src/imports/platform/qquickplatformdialog.cpp
@@ -0,0 +1,409 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformdialog_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickwindow.h>
+
+#include "widgets/qwidgetplatform_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Dialog
+ \inherits QtObject
+ \instantiates QQuickPlatformDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief The base class of native dialogs.
+
+ The Dialog type provides common QML API for native platform dialogs.
+
+ To show a native dialog, construct an instance of one of the concrete
+ Dialog implementations, set the desired properties, and call \l open().
+ Dialog emits \l accepted() or \l rejected() when the user is done with
+ the dialog.
+
+ \labs
+*/
+
+/*!
+ \qmlsignal void Qt.labs.platform::Dialog::accepted()
+
+ This signal is emitted when the dialog has been accepted either
+ interactively or by calling \l accept().
+
+ \note This signal is \e not emitted when closing the dialog with \l close().
+
+ \sa rejected()
+*/
+
+/*!
+ \qmlsignal void Qt.labs.platform::Dialog::rejected()
+
+ This signal is emitted when the dialog has been rejected either
+ interactively or by calling \l reject().
+
+ \note This signal is \e not emitted when closing the dialog with \l close().
+
+ \sa accepted()
+*/
+
+Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformDialogs)
+
+QQuickPlatformDialog::QQuickPlatformDialog(QPlatformTheme::DialogType type, QObject *parent)
+ : QObject(parent),
+ m_visible(false),
+ m_complete(false),
+ m_result(0),
+ m_parentWindow(nullptr),
+ m_flags(Qt::Dialog),
+ m_modality(Qt::WindowModal),
+ m_type(type),
+ m_handle(nullptr)
+{
+}
+
+QQuickPlatformDialog::~QQuickPlatformDialog()
+{
+ destroy();
+}
+
+QPlatformDialogHelper *QQuickPlatformDialog::handle() const
+{
+ return m_handle;
+}
+
+/*!
+ \default
+ \qmlproperty list<Object> Qt.labs.platform::Dialog::data
+
+ This default property holds the list of all objects declared as children of
+ the dialog.
+*/
+QQmlListProperty<QObject> QQuickPlatformDialog::data()
+{
+ return QQmlListProperty<QObject>(this, m_data);
+}
+
+/*!
+ \qmlproperty Window Qt.labs.platform::Dialog::parentWindow
+
+ This property holds the parent window of the dialog.
+
+ Unless explicitly set, the window is automatically resolved by iterating
+ the QML parent objects until a \l Window or an \l Item that has a window
+ is found.
+*/
+QWindow *QQuickPlatformDialog::parentWindow() const
+{
+ return m_parentWindow;
+}
+
+void QQuickPlatformDialog::setParentWindow(QWindow *window)
+{
+ if (m_parentWindow == window)
+ return;
+
+ m_parentWindow = window;
+ emit parentWindowChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::Dialog::title
+
+ This property holds the title of the dialog.
+*/
+QString QQuickPlatformDialog::title() const
+{
+ return m_title;
+}
+
+void QQuickPlatformDialog::setTitle(const QString &title)
+{
+ if (m_title == title)
+ return;
+
+ m_title = title;
+ emit titleChanged();
+}
+
+/*!
+ \qmlproperty Qt::WindowFlags Qt.labs.platform::Dialog::flags
+
+ This property holds the window flags of the dialog. The default value is \c Qt.Dialog.
+*/
+Qt::WindowFlags QQuickPlatformDialog::flags() const
+{
+ return m_flags;
+}
+
+void QQuickPlatformDialog::setFlags(Qt::WindowFlags flags)
+{
+ if (m_flags == flags)
+ return;
+
+ m_flags = flags;
+ emit flagsChanged();
+}
+
+/*!
+ \qmlproperty Qt::WindowModality Qt.labs.platform::Dialog::modality
+
+ This property holds the modality of the dialog. The default value is \c Qt.WindowModal.
+
+ Available values:
+ \value Qt.NonModal The dialog is not modal and does not block input to other windows.
+ \value Qt.WindowModal The dialog is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows.
+ \value Qt.ApplicationModal The dialog is modal to the application and blocks input to all windows.
+*/
+Qt::WindowModality QQuickPlatformDialog::modality() const
+{
+ return m_modality;
+}
+
+void QQuickPlatformDialog::setModality(Qt::WindowModality modality)
+{
+ if (m_modality == modality)
+ return;
+
+ m_modality = modality;
+ emit modalityChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::Dialog::visible
+
+ This property holds the visibility of the dialog. The default value is \c false.
+
+ \sa open(), close()
+*/
+bool QQuickPlatformDialog::isVisible() const
+{
+ return m_handle && m_visible;
+}
+
+void QQuickPlatformDialog::setVisible(bool visible)
+{
+ if (visible)
+ open();
+ else
+ close();
+}
+
+/*!
+ \qmlproperty int Qt.labs.platform::Dialog::result
+
+ This property holds the result code.
+
+ Standard result codes:
+ \value Dialog.Accepted
+ \value Dialog.Rejected
+
+ \note MessageDialog sets the result to the value of the clicked standard
+ button instead of using the standard result codes.
+*/
+int QQuickPlatformDialog::result() const
+{
+ return m_result;
+}
+
+void QQuickPlatformDialog::setResult(int result)
+{
+ if (m_result == result)
+ return;
+
+ m_result = result;
+ emit resultChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Dialog::open()
+
+ Opens the dialog.
+
+ \sa visible, close()
+*/
+void QQuickPlatformDialog::open()
+{
+ if (m_visible || !create())
+ return;
+
+ onShow(m_handle);
+ m_visible = m_handle->show(m_flags, m_modality, m_parentWindow);
+ if (m_visible)
+ emit visibleChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Dialog::close()
+
+ Closes the dialog.
+
+ \sa visible, open()
+*/
+void QQuickPlatformDialog::close()
+{
+ if (!m_handle || !m_visible)
+ return;
+
+ onHide(m_handle);
+ m_handle->hide();
+ m_visible = false;
+ emit visibleChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Dialog::accept()
+
+ Closes the dialog and emits the \l accepted() signal.
+
+ \sa reject()
+*/
+void QQuickPlatformDialog::accept()
+{
+ done(Accepted);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Dialog::reject()
+
+ Closes the dialog and emits the \l rejected() signal.
+
+ \sa accept()
+*/
+void QQuickPlatformDialog::reject()
+{
+ done(Rejected);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Dialog::done(int result)
+
+ Closes the dialog and sets the \a result.
+
+ \sa accept(), reject(), result
+*/
+void QQuickPlatformDialog::done(int result)
+{
+ close();
+ setResult(result);
+
+ if (result == Accepted)
+ emit accepted();
+ else if (result == Rejected)
+ emit rejected();
+}
+
+void QQuickPlatformDialog::classBegin()
+{
+}
+
+void QQuickPlatformDialog::componentComplete()
+{
+ m_complete = true;
+ if (!m_parentWindow)
+ setParentWindow(findParentWindow());
+}
+
+static const char *qmlTypeName(const QObject *object)
+{
+ return object->metaObject()->className() + qstrlen("QQuickPlatform");
+}
+
+bool QQuickPlatformDialog::create()
+{
+ if (!m_handle) {
+ if (useNativeDialog())
+ m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(m_type);
+ if (!m_handle)
+ m_handle = QWidgetPlatform::createDialog(m_type, this);
+ qCDebug(qtLabsPlatformDialogs) << qmlTypeName(this) << "->" << m_handle;
+ if (m_handle) {
+ onCreate(m_handle);
+ connect(m_handle, &QPlatformDialogHelper::accept, this, &QQuickPlatformDialog::accept);
+ connect(m_handle, &QPlatformDialogHelper::reject, this, &QQuickPlatformDialog::reject);
+ }
+ }
+ return m_handle;
+}
+
+void QQuickPlatformDialog::destroy()
+{
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+bool QQuickPlatformDialog::useNativeDialog() const
+{
+ return !QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)
+ && QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(m_type);
+}
+
+void QQuickPlatformDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ Q_UNUSED(dialog);
+}
+
+void QQuickPlatformDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ Q_UNUSED(dialog);
+}
+
+void QQuickPlatformDialog::onHide(QPlatformDialogHelper *dialog)
+{
+ Q_UNUSED(dialog);
+}
+
+QWindow *QQuickPlatformDialog::findParentWindow() const
+{
+ QObject *obj = parent();
+ while (obj) {
+ QWindow *window = qobject_cast<QWindow *>(obj);
+ if (window)
+ return window;
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (item && item->window())
+ return item->window();
+ obj = obj->parent();
+ }
+ return nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformdialog_p.h b/src/imports/platform/qquickplatformdialog_p.h
new file mode 100644
index 00000000..a9797c1d
--- /dev/null
+++ b/src/imports/platform/qquickplatformdialog_p.h
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMDIALOG_P_H
+#define QQUICKPLATFORMDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmllist.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+class QPlatformDialogHelper;
+
+class QQuickPlatformDialog : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL)
+ Q_PROPERTY(QWindow *parentWindow READ parentWindow WRITE setParentWindow NOTIFY parentWindowChanged FINAL)
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
+ Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL)
+ Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged FINAL)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(int result READ result WRITE setResult NOTIFY resultChanged FINAL)
+ Q_CLASSINFO("DefaultProperty", "data")
+ Q_ENUMS(StandardCode)
+
+public:
+ explicit QQuickPlatformDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr);
+ ~QQuickPlatformDialog();
+
+ QPlatformDialogHelper *handle() const;
+
+ QQmlListProperty<QObject> data();
+
+ QWindow *parentWindow() const;
+ void setParentWindow(QWindow *window);
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ Qt::WindowFlags flags() const;
+ void setFlags(Qt::WindowFlags flags);
+
+ Qt::WindowModality modality() const;
+ void setModality(Qt::WindowModality modality);
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
+ enum StandardCode { Rejected, Accepted };
+
+ int result() const;
+ void setResult(int result);
+
+public Q_SLOTS:
+ void open();
+ void close();
+ virtual void accept();
+ virtual void reject();
+ virtual void done(int result);
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+ void parentWindowChanged();
+ void titleChanged();
+ void flagsChanged();
+ void modalityChanged();
+ void visibleChanged();
+ void resultChanged();
+
+protected:
+ void classBegin() override;
+ void componentComplete() override;
+
+ bool create();
+ void destroy();
+
+ virtual bool useNativeDialog() const;
+ virtual void onCreate(QPlatformDialogHelper *dialog);
+ virtual void onShow(QPlatformDialogHelper *dialog);
+ virtual void onHide(QPlatformDialogHelper *dialog);
+
+ QWindow *findParentWindow() const;
+
+private:
+ bool m_visible;
+ bool m_complete;
+ int m_result;
+ QWindow *m_parentWindow;
+ QString m_title;
+ Qt::WindowFlags m_flags;
+ Qt::WindowModality m_modality;
+ QPlatformTheme::DialogType m_type;
+ QList<QObject *> m_data;
+ QPlatformDialogHelper *m_handle;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformDialog)
+
+#endif // QQUICKPLATFORMDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformfiledialog.cpp b/src/imports/platform/qquickplatformfiledialog.cpp
new file mode 100644
index 00000000..6a0f4e13
--- /dev/null
+++ b/src/imports/platform/qquickplatformfiledialog.cpp
@@ -0,0 +1,660 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformfiledialog_p.h"
+
+#include <QtCore/qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype FileDialog
+ \inherits Dialog
+ \instantiates QQuickPlatformFileDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native file dialog.
+
+ The FileDialog type provides a QML API for native platform file dialogs.
+
+ \image qtlabsplatform-filedialog-gtk.png
+
+ To show a file dialog, construct an instance of FileDialog, set the
+ desired properties, and call \l {Dialog::}{open()}. The \l currentFile
+ or \l currentFiles properties can be used to determine the currently
+ selected file(s) in the dialog. The \l file and \l files properties
+ are updated only after the final selection has been made by accepting
+ the dialog.
+
+ \code
+ MenuItem {
+ text: "Open..."
+ onTriggered: fileDialog.open()
+ }
+
+ FileDialog {
+ id: fileDialog
+ currentFile: document.source
+ folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
+ }
+
+ MyDocument {
+ id: document
+ source: fileDialog.file
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native platform file dialog is currently available on the following platforms:
+
+ \list
+ \li iOS
+ \li Linux (when running with the GTK+ platform theme)
+ \li macOS
+ \li Windows
+ \li WinRT
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+
+ \sa FolderDialog, StandardPaths
+*/
+
+QQuickPlatformFileDialog::QQuickPlatformFileDialog(QObject *parent)
+ : QQuickPlatformDialog(QPlatformTheme::FileDialog, parent),
+ m_fileMode(OpenFile),
+ m_options(QFileDialogOptions::create()),
+ m_selectedNameFilter(nullptr)
+{
+ m_options->setFileMode(QFileDialogOptions::ExistingFile);
+ m_options->setAcceptMode(QFileDialogOptions::AcceptOpen);
+}
+
+/*!
+ \qmlproperty enumeration Qt.labs.platform::FileDialog::fileMode
+
+ This property holds the mode of the dialog.
+
+ Available values:
+ \value FileDialog.OpenFile The dialog is used to select an existing file (default).
+ \value FileDialog.OpenFiles The dialog is used to select multiple existing files.
+ \value FileDialog.SaveFile The dialog is used to select any file. The file does not have to exist.
+*/
+QQuickPlatformFileDialog::FileMode QQuickPlatformFileDialog::fileMode() const
+{
+ return m_fileMode;
+}
+
+void QQuickPlatformFileDialog::setFileMode(FileMode mode)
+{
+ if (mode == m_fileMode)
+ return;
+
+ switch (mode) {
+ case OpenFile:
+ m_options->setFileMode(QFileDialogOptions::ExistingFile);
+ m_options->setAcceptMode(QFileDialogOptions::AcceptOpen);
+ break;
+ case OpenFiles:
+ m_options->setFileMode(QFileDialogOptions::ExistingFiles);
+ m_options->setAcceptMode(QFileDialogOptions::AcceptOpen);
+ break;
+ case SaveFile:
+ m_options->setFileMode(QFileDialogOptions::AnyFile);
+ m_options->setAcceptMode(QFileDialogOptions::AcceptSave);
+ break;
+ default:
+ break;
+ }
+
+ m_fileMode = mode;
+ emit fileModeChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::FileDialog::file
+
+ This property holds the final accepted file.
+
+ Unlike the \l currentFile property, the \c file property is not updated
+ while the user is selecting files in the dialog, but only after the final
+ selection has been made. That is, when the user has clicked \uicontrol OK
+ to accept a file. Alternatively, the \l {Dialog::}{accepted()} signal
+ can be handled to get the final selection.
+
+ \sa currentFile, {Dialog::}{accepted()}
+*/
+QUrl QQuickPlatformFileDialog::file() const
+{
+ return addDefaultSuffix(m_files.value(0));
+}
+
+void QQuickPlatformFileDialog::setFile(const QUrl &file)
+{
+ setFiles(QList<QUrl>() << file);
+}
+
+/*!
+ \qmlproperty list<url> Qt.labs.platform::FileDialog::files
+
+ This property holds the final accepted files.
+
+ Unlike the \l currentFiles property, the \c files property is not updated
+ while the user is selecting files in the dialog, but only after the final
+ selection has been made. That is, when the user has clicked \uicontrol OK
+ to accept files. Alternatively, the \l {Dialog::}{accepted()} signal
+ can be handled to get the final selection.
+
+ \sa currentFiles, {Dialog::}{accepted()}
+*/
+QList<QUrl> QQuickPlatformFileDialog::files() const
+{
+ return addDefaultSuffixes(m_files);
+}
+
+void QQuickPlatformFileDialog::setFiles(const QList<QUrl> &files)
+{
+ if (m_files == files)
+ return;
+
+ bool firstChanged = m_files.value(0) != files.value(0);
+ m_files = files;
+ if (firstChanged)
+ emit fileChanged();
+ emit filesChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::FileDialog::currentFile
+
+ This property holds the currently selected file in the dialog.
+
+ Unlike the \l file property, the \c currentFile property is updated
+ while the user is selecting files in the dialog, even before the final
+ selection has been made.
+
+ \sa file, currentFiles
+*/
+QUrl QQuickPlatformFileDialog::currentFile() const
+{
+ return currentFiles().value(0);
+}
+
+void QQuickPlatformFileDialog::setCurrentFile(const QUrl &file)
+{
+ setCurrentFiles(QList<QUrl>() << file);
+}
+
+/*!
+ \qmlproperty list<url> Qt.labs.platform::FileDialog::currentFiles
+
+ This property holds the currently selected files in the dialog.
+
+ Unlike the \l files property, the \c currentFiles property is updated
+ while the user is selecting files in the dialog, even before the final
+ selection has been made.
+
+ \sa files, currentFile
+*/
+QList<QUrl> QQuickPlatformFileDialog::currentFiles() const
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ return fileDialog->selectedFiles();
+ return m_options->initiallySelectedFiles();
+}
+
+void QQuickPlatformFileDialog::setCurrentFiles(const QList<QUrl> &files)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle())) {
+ for (const QUrl &file : files)
+ fileDialog->selectFile(file);
+ }
+ m_options->setInitiallySelectedFiles(files);
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::FileDialog::folder
+
+ This property holds the folder where files are selected.
+ For selecting a folder, use FolderDialog instead.
+
+ \sa FolderDialog
+*/
+QUrl QQuickPlatformFileDialog::folder() const
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ return fileDialog->directory();
+ return m_options->initialDirectory();
+}
+
+void QQuickPlatformFileDialog::setFolder(const QUrl &folder)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ fileDialog->setDirectory(folder);
+ m_options->setInitialDirectory(folder);
+}
+
+/*!
+ \qmlproperty flags Qt.labs.platform::FileDialog::options
+
+ This property holds the various options that affect the look and feel of the dialog.
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the dialog is
+ visible is not guaranteed to have an immediate effect on the dialog (depending on
+ the option and on the platform).
+
+ Available options:
+ \value FileDialog.DontResolveSymlinks Don't resolve symlinks in the file dialog. By default symlinks are resolved.
+ \value FileDialog.DontConfirmOverwrite Don't ask for confirmation if an existing file is selected. By default confirmation is requested.
+ \value FileDialog.ReadOnly Indicates that the dialog doesn't allow creating directories.
+ \value FileDialog.HideNameFilterDetails Indicates if the file name filter details are hidden or not.
+*/
+QFileDialogOptions::FileDialogOptions QQuickPlatformFileDialog::options() const
+{
+ return m_options->options();
+}
+
+void QQuickPlatformFileDialog::setOptions(QFileDialogOptions::FileDialogOptions options)
+{
+ if (options == m_options->options())
+ return;
+
+ m_options->setOptions(options);
+ emit optionsChanged();
+}
+
+void QQuickPlatformFileDialog::resetOptions()
+{
+ setOptions(0);
+}
+
+/*!
+ \qmlproperty list<string> Qt.labs.platform::FileDialog::nameFilters
+
+ This property holds the filters that restrict the types of files that
+ can be selected.
+
+ \code
+ FileDialog {
+ nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)"]
+ }
+ \endcode
+
+ \note \b{*.*} is not a portable filter, because the historical assumption
+ that the file extension determines the file type is not consistent on every
+ operating system. It is possible to have a file with no dot in its name (for
+ example, \c Makefile). In a native Windows file dialog, \b{*.*} will match
+ such files, while in other types of file dialogs it may not. So it is better
+ to use \b{*} if you mean to select any file.
+
+ \sa selectedNameFilter
+*/
+QStringList QQuickPlatformFileDialog::nameFilters() const
+{
+ return m_options->nameFilters();
+}
+
+void QQuickPlatformFileDialog::setNameFilters(const QStringList &filters)
+{
+ if (filters == m_options->nameFilters())
+ return;
+
+ m_options->setNameFilters(filters);
+ if (m_selectedNameFilter) {
+ int index = m_selectedNameFilter->index();
+ if (index < 0 || index >= filters.count())
+ index = 0;
+ m_selectedNameFilter->update(filters.value(index));
+ }
+ emit nameFiltersChanged();
+}
+
+void QQuickPlatformFileDialog::resetNameFilters()
+{
+ setNameFilters(QStringList());
+}
+
+/*!
+ \qmlpropertygroup Qt.labs.platform::FileDialog::selectedNameFilter
+ \qmlproperty int Qt.labs.platform::FileDialog::selectedNameFilter.index
+ \qmlproperty string Qt.labs.platform::FileDialog::selectedNameFilter.name
+ \qmlproperty list<string> Qt.labs.platform::FileDialog::selectedNameFilter.extensions
+
+ These properties hold the currently selected name filter.
+
+ \table
+ \header
+ \li Name
+ \li Description
+ \row
+ \li \b index : int
+ \li This property determines which \l {nameFilters}{name filter} is selected.
+ The specified filter is selected when the dialog is opened. The value is
+ updated when the user selects another filter.
+ \row
+ \li [read-only] \b name : string
+ \li This property holds the name of the selected filter. In the
+ example below, the name of the first filter is \c {"Text files"}
+ and the second is \c {"HTML files"}.
+ \row
+ \li [read-only] \b extensions : list<string>
+ \li This property holds the list of extensions of the selected filter.
+ In the example below, the list of extensions of the first filter is
+ \c {["txt"]} and the second is \c {["html", "htm"]}.
+ \endtable
+
+ \code
+ FileDialog {
+ id: fileDialog
+ selectedNameFilter.index: 1
+ nameFilters: ["Text files (*.txt)", "HTML files (*.html *.htm)"]
+ }
+
+ MyDocument {
+ id: document
+ fileType: fileDialog.selectedNameFilter.extensions[0]
+ }
+ \endcode
+
+ \sa nameFilters
+*/
+QQuickPlatformFileNameFilter *QQuickPlatformFileDialog::selectedNameFilter() const
+{
+ if (!m_selectedNameFilter) {
+ QQuickPlatformFileDialog *that = const_cast<QQuickPlatformFileDialog *>(this);
+ m_selectedNameFilter = new QQuickPlatformFileNameFilter(that);
+ m_selectedNameFilter->setOptions(m_options);
+ }
+ return m_selectedNameFilter;
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::FileDialog::defaultSuffix
+
+ This property holds a suffix that is added to selected files that have
+ no suffix specified. The suffix is typically used to indicate the file
+ type (e.g. "txt" indicates a text file).
+
+ If the first character is a dot ('.'), it is removed.
+*/
+QString QQuickPlatformFileDialog::defaultSuffix() const
+{
+ return m_options->defaultSuffix();
+}
+
+void QQuickPlatformFileDialog::setDefaultSuffix(const QString &suffix)
+{
+ if (suffix == m_options->defaultSuffix())
+ return;
+
+ m_options->setDefaultSuffix(suffix);
+ emit defaultSuffixChanged();
+}
+
+void QQuickPlatformFileDialog::resetDefaultSuffix()
+{
+ setDefaultSuffix(QString());
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::FileDialog::acceptLabel
+
+ This property holds the label text shown on the button that accepts the dialog.
+
+ When set to an empty string, the default label of the underlying platform is used.
+ The default label is typically \uicontrol Open or \uicontrol Save depending on which
+ \l fileMode the dialog is used in.
+
+ The default value is an empty string.
+
+ \sa rejectLabel
+*/
+QString QQuickPlatformFileDialog::acceptLabel() const
+{
+ return m_options->labelText(QFileDialogOptions::Accept);
+}
+
+void QQuickPlatformFileDialog::setAcceptLabel(const QString &label)
+{
+ if (label == m_options->labelText(QFileDialogOptions::Accept))
+ return;
+
+ m_options->setLabelText(QFileDialogOptions::Accept, label);
+ emit acceptLabelChanged();
+}
+
+void QQuickPlatformFileDialog::resetAcceptLabel()
+{
+ setAcceptLabel(QString());
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::FileDialog::rejectLabel
+
+ This property holds the label text shown on the button that rejects the dialog.
+
+ When set to an empty string, the default label of the underlying platform is used.
+ The default label is typically \uicontrol Cancel.
+
+ The default value is an empty string.
+
+ \sa acceptLabel
+*/
+QString QQuickPlatformFileDialog::rejectLabel() const
+{
+ return m_options->labelText(QFileDialogOptions::Reject);
+}
+
+void QQuickPlatformFileDialog::setRejectLabel(const QString &label)
+{
+ if (label == m_options->labelText(QFileDialogOptions::Reject))
+ return;
+
+ m_options->setLabelText(QFileDialogOptions::Reject, label);
+ emit rejectLabelChanged();
+}
+
+void QQuickPlatformFileDialog::resetRejectLabel()
+{
+ setRejectLabel(QString());
+}
+
+bool QQuickPlatformFileDialog::useNativeDialog() const
+{
+ return QQuickPlatformDialog::useNativeDialog()
+ && !m_options->testOption(QFileDialogOptions::DontUseNativeDialog);
+}
+
+void QQuickPlatformFileDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) {
+ // TODO: emit currentFileChanged only when the first entry in currentFiles changes
+ connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickPlatformFileDialog::currentFileChanged);
+ connect(fileDialog, &QPlatformFileDialogHelper::currentChanged, this, &QQuickPlatformFileDialog::currentFilesChanged);
+ connect(fileDialog, &QPlatformFileDialogHelper::directoryEntered, this, &QQuickPlatformFileDialog::folderChanged);
+ fileDialog->setOptions(m_options);
+ }
+}
+
+void QQuickPlatformFileDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ m_options->setWindowTitle(title());
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) {
+ fileDialog->setOptions(m_options);
+ if (m_selectedNameFilter) {
+ const int index = m_selectedNameFilter->index();
+ const QString filter = m_options->nameFilters().value(index);
+ m_options->setInitiallySelectedNameFilter(filter);
+ fileDialog->selectNameFilter(filter);
+ connect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickPlatformFileNameFilter::update);
+ }
+ }
+}
+
+void QQuickPlatformFileDialog::onHide(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) {
+ if (m_selectedNameFilter)
+ disconnect(fileDialog, &QPlatformFileDialogHelper::filterSelected, m_selectedNameFilter, &QQuickPlatformFileNameFilter::update);
+ }
+}
+
+void QQuickPlatformFileDialog::accept()
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ setFiles(fileDialog->selectedFiles());
+ QQuickPlatformDialog::accept();
+}
+
+QUrl QQuickPlatformFileDialog::addDefaultSuffix(const QUrl &file) const
+{
+ QUrl url = file;
+ const QString path = url.path();
+ const QString suffix = m_options->defaultSuffix();
+ if (!suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) && path.lastIndexOf(QLatin1Char('.')) == -1)
+ url.setPath(path + QLatin1Char('.') + suffix);
+ return url;
+}
+
+QList<QUrl> QQuickPlatformFileDialog::addDefaultSuffixes(const QList<QUrl> &files) const
+{
+ QList<QUrl> urls;
+ urls.reserve(files.size());
+ for (const QUrl &file : files)
+ urls += addDefaultSuffix(file);
+ return urls;
+}
+
+QQuickPlatformFileNameFilter::QQuickPlatformFileNameFilter(QObject *parent)
+ : QObject(parent), m_index(-1)
+{
+}
+
+int QQuickPlatformFileNameFilter::index() const
+{
+ return m_index;
+}
+
+void QQuickPlatformFileNameFilter::setIndex(int index)
+{
+ if (m_index == index)
+ return;
+
+ m_index = index;
+ emit indexChanged(index);
+}
+
+QString QQuickPlatformFileNameFilter::name() const
+{
+ return m_name;
+}
+
+QStringList QQuickPlatformFileNameFilter::extensions() const
+{
+ return m_extensions;
+}
+
+QSharedPointer<QFileDialogOptions> QQuickPlatformFileNameFilter::options() const
+{
+ return m_options;
+}
+
+void QQuickPlatformFileNameFilter::setOptions(const QSharedPointer<QFileDialogOptions> &options)
+{
+ m_options = options;
+}
+
+static QString extractName(const QString &filter)
+{
+ return filter.left(filter.indexOf(QLatin1Char('(')) - 1);
+}
+
+static QString extractExtension(const QString &filter)
+{
+ return filter.mid(filter.indexOf(QLatin1Char('.')) + 1);
+}
+
+static QStringList extractExtensions(const QString &filter)
+{
+ QStringList extensions;
+ const int from = filter.indexOf(QLatin1Char('('));
+ const int to = filter.lastIndexOf(QLatin1Char(')')) - 1;
+ if (from >= 0 && from < to) {
+ const QStringRef ref = filter.midRef(from + 1, to - from);
+ const QVector<QStringRef> exts = ref.split(QLatin1Char(' '), QString::SkipEmptyParts);
+ for (const QStringRef &ref : exts)
+ extensions += extractExtension(ref.toString());
+ }
+
+ return extensions;
+}
+
+void QQuickPlatformFileNameFilter::update(const QString &filter)
+{
+ const QStringList filters = nameFilters();
+
+ const int oldIndex = m_index;
+ const QString oldName = m_name;
+ const QStringList oldExtensions = m_extensions;
+
+ m_index = filters.indexOf(filter);
+ m_name = extractName(filter);
+ m_extensions = extractExtensions(filter);
+
+ if (oldIndex != m_index)
+ emit indexChanged(m_index);
+ if (oldName != m_name)
+ emit nameChanged(m_name);
+ if (oldExtensions != m_extensions)
+ emit extensionsChanged(m_extensions);
+}
+
+QStringList QQuickPlatformFileNameFilter::nameFilters() const
+{
+ return m_options ? m_options->nameFilters() : QStringList();
+}
+
+QString QQuickPlatformFileNameFilter::nameFilter(int index) const
+{
+ return m_options ? m_options->nameFilters().value(index) : QString();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformfiledialog_p.h b/src/imports/platform/qquickplatformfiledialog_p.h
new file mode 100644
index 00000000..51f88d46
--- /dev/null
+++ b/src/imports/platform/qquickplatformfiledialog_p.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMFILEDIALOG_P_H
+#define QQUICKPLATFORMFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformdialog_p.h"
+#include <QtCore/qurl.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformFileNameFilter;
+
+class QQuickPlatformFileDialog : public QQuickPlatformDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL)
+ Q_PROPERTY(QUrl file READ file WRITE setFile NOTIFY fileChanged FINAL)
+ Q_PROPERTY(QList<QUrl> files READ files WRITE setFiles NOTIFY filesChanged FINAL)
+ Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL)
+ Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL)
+ Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL)
+ Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL)
+ Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL)
+ Q_PROPERTY(QQuickPlatformFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
+ Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL)
+ Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL)
+ Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL)
+ Q_FLAGS(QFileDialogOptions::FileDialogOptions)
+
+public:
+ explicit QQuickPlatformFileDialog(QObject *parent = nullptr);
+
+ enum FileMode {
+ OpenFile,
+ OpenFiles,
+ SaveFile
+ };
+ Q_ENUM(FileMode)
+
+ FileMode fileMode() const;
+ void setFileMode(FileMode fileMode);
+
+ QUrl file() const;
+ void setFile(const QUrl &file);
+
+ QList<QUrl> files() const;
+ void setFiles(const QList<QUrl> &files);
+
+ QUrl currentFile() const;
+ void setCurrentFile(const QUrl &file);
+
+ QList<QUrl> currentFiles() const;
+ void setCurrentFiles(const QList<QUrl> &files);
+
+ QUrl folder() const;
+ void setFolder(const QUrl &folder);
+
+ QFileDialogOptions::FileDialogOptions options() const;
+ void setOptions(QFileDialogOptions::FileDialogOptions options);
+ void resetOptions();
+
+ QStringList nameFilters() const;
+ void setNameFilters(const QStringList &filters);
+ void resetNameFilters();
+
+ QQuickPlatformFileNameFilter *selectedNameFilter() const;
+
+ QString defaultSuffix() const;
+ void setDefaultSuffix(const QString &suffix);
+ void resetDefaultSuffix();
+
+ QString acceptLabel() const;
+ void setAcceptLabel(const QString &label);
+ void resetAcceptLabel();
+
+ QString rejectLabel() const;
+ void setRejectLabel(const QString &label);
+ void resetRejectLabel();
+
+Q_SIGNALS:
+ void fileModeChanged();
+ void fileChanged();
+ void filesChanged();
+ void currentFileChanged();
+ void currentFilesChanged();
+ void folderChanged();
+ void optionsChanged();
+ void nameFiltersChanged();
+ void defaultSuffixChanged();
+ void acceptLabelChanged();
+ void rejectLabelChanged();
+
+protected:
+ bool useNativeDialog() const override;
+ void onCreate(QPlatformDialogHelper *dialog) override;
+ void onShow(QPlatformDialogHelper *dialog) override;
+ void onHide(QPlatformDialogHelper *dialog) override;
+ void accept() override;
+
+private:
+ QUrl addDefaultSuffix(const QUrl &file) const;
+ QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const;
+
+ FileMode m_fileMode;
+ QList<QUrl> m_files;
+ QSharedPointer<QFileDialogOptions> m_options;
+ mutable QQuickPlatformFileNameFilter *m_selectedNameFilter;
+};
+
+class QQuickPlatformFileNameFilter : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL)
+ Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL)
+ Q_PROPERTY(QStringList extensions READ extensions NOTIFY extensionsChanged FINAL)
+
+public:
+ explicit QQuickPlatformFileNameFilter(QObject *parent = nullptr);
+
+ int index() const;
+ void setIndex(int index);
+
+ QString name() const;
+ QStringList extensions() const;
+
+ QSharedPointer<QFileDialogOptions> options() const;
+ void setOptions(const QSharedPointer<QFileDialogOptions> &options);
+
+ void update(const QString &filter);
+
+Q_SIGNALS:
+ void indexChanged(int index);
+ void nameChanged(const QString &name);
+ void extensionsChanged(const QStringList &extensions);
+
+private:
+ QStringList nameFilters() const;
+ QString nameFilter(int index) const;
+
+ int m_index;
+ QString m_name;
+ QStringList m_extensions;
+ QSharedPointer<QFileDialogOptions> m_options;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformFileDialog)
+
+#endif // QQUICKPLATFORMFILEDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformfolderdialog.cpp b/src/imports/platform/qquickplatformfolderdialog.cpp
new file mode 100644
index 00000000..c56658c4
--- /dev/null
+++ b/src/imports/platform/qquickplatformfolderdialog.cpp
@@ -0,0 +1,281 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformfolderdialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype FolderDialog
+ \inherits Dialog
+ \instantiates QQuickPlatformFolderDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native folder dialog.
+
+ The FolderDialog type provides a QML API for native platform folder dialogs.
+
+ \image qtlabsplatform-folderdialog-gtk.png
+
+ To show a folder dialog, construct an instance of FolderDialog, set the
+ desired properties, and call \l {Dialog::}{open()}. The \l currentFolder
+ property can be used to determine the currently selected folder in the
+ dialog. The \l folder property is updated only after the final selection
+ has been made by accepting the dialog.
+
+ \code
+ MenuItem {
+ text: "Open..."
+ onTriggered: folderDialog.open()
+ }
+
+ FolderDialog {
+ id: folderDialog
+ currentFolder: viewer.folder
+ folder: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
+ }
+
+ MyViewer {
+ id: viewer
+ folder: folderDialog.folder
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native platform folder dialog is currently available on the following platforms:
+
+ \list
+ \li iOS
+ \li Linux (when running with the GTK+ platform theme)
+ \li macOS
+ \li Windows
+ \li WinRT
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+
+ \sa FileDialog, StandardPaths
+*/
+
+QQuickPlatformFolderDialog::QQuickPlatformFolderDialog(QObject *parent)
+ : QQuickPlatformDialog(QPlatformTheme::FileDialog, parent),
+ m_options(QFileDialogOptions::create())
+{
+ m_options->setFileMode(QFileDialogOptions::Directory);
+ m_options->setAcceptMode(QFileDialogOptions::AcceptOpen);
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::FolderDialog::folder
+
+ This property holds the final accepted folder.
+
+ Unlike the \l currentFolder property, the \c folder property is not updated
+ while the user is selecting folders in the dialog, but only after the final
+ selection has been made. That is, when the user has clicked \uicontrol OK
+ to accept a folder. Alternatively, the \l {Dialog::}{accepted()} signal
+ can be handled to get the final selection.
+
+ \sa currentFolder, {Dialog::}{accepted()}
+*/
+QUrl QQuickPlatformFolderDialog::folder() const
+{
+ return m_folder;
+}
+
+void QQuickPlatformFolderDialog::setFolder(const QUrl &folder)
+{
+ if (m_folder == folder)
+ return;
+
+ m_folder = folder;
+ setCurrentFolder(folder);
+ emit folderChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::FolderDialog::currentFolder
+
+ This property holds the currently selected folder in the dialog.
+
+ Unlike the \l folder property, the \c currentFolder property is updated
+ while the user is selecting folders in the dialog, even before the final
+ selection has been made.
+
+ \sa folder
+*/
+QUrl QQuickPlatformFolderDialog::currentFolder() const
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ return fileDialog->directory();
+ return m_options->initialDirectory();
+}
+
+void QQuickPlatformFolderDialog::setCurrentFolder(const QUrl &folder)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(handle()))
+ fileDialog->setDirectory(folder);
+ m_options->setInitialDirectory(folder);
+}
+
+/*!
+ \qmlproperty flags Qt.labs.platform::FolderDialog::options
+
+ This property holds the various options that affect the look and feel of the dialog.
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the dialog is
+ visible is not guaranteed to have an immediate effect on the dialog (depending on
+ the option and on the platform).
+
+ Available options:
+ \value FolderDialog.ShowDirsOnly Only show directories in the folder dialog. By default both folders and directories are shown.
+ \value FolderDialog.DontResolveSymlinks Don't resolve symlinks in the folder dialog. By default symlinks are resolved.
+ \value FolderDialog.ReadOnly Indicates that the dialog doesn't allow creating directories.
+*/
+QFileDialogOptions::FileDialogOptions QQuickPlatformFolderDialog::options() const
+{
+ return m_options->options();
+}
+
+void QQuickPlatformFolderDialog::setOptions(QFileDialogOptions::FileDialogOptions options)
+{
+ if (options == m_options->options())
+ return;
+
+ m_options->setOptions(options);
+ emit optionsChanged();
+}
+
+void QQuickPlatformFolderDialog::resetOptions()
+{
+ setOptions(0);
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::FolderDialog::acceptLabel
+
+ This property holds the label text shown on the button that accepts the dialog.
+
+ When set to an empty string, the default label of the underlying platform is used.
+ The default label is typically \uicontrol Open.
+
+ The default value is an empty string.
+
+ \sa rejectLabel
+*/
+QString QQuickPlatformFolderDialog::acceptLabel() const
+{
+ return m_options->labelText(QFileDialogOptions::Accept);
+}
+
+void QQuickPlatformFolderDialog::setAcceptLabel(const QString &label)
+{
+ if (label == m_options->labelText(QFileDialogOptions::Accept))
+ return;
+
+ m_options->setLabelText(QFileDialogOptions::Accept, label);
+ emit acceptLabelChanged();
+}
+
+void QQuickPlatformFolderDialog::resetAcceptLabel()
+{
+ setAcceptLabel(QString());
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::FolderDialog::rejectLabel
+
+ This property holds the label text shown on the button that rejects the dialog.
+
+ When set to an empty string, the default label of the underlying platform is used.
+ The default label is typically \uicontrol Cancel.
+
+ The default value is an empty string.
+
+ \sa acceptLabel
+*/
+QString QQuickPlatformFolderDialog::rejectLabel() const
+{
+ return m_options->labelText(QFileDialogOptions::Reject);
+}
+
+void QQuickPlatformFolderDialog::setRejectLabel(const QString &label)
+{
+ if (label == m_options->labelText(QFileDialogOptions::Reject))
+ return;
+
+ m_options->setLabelText(QFileDialogOptions::Reject, label);
+ emit rejectLabelChanged();
+}
+
+void QQuickPlatformFolderDialog::resetRejectLabel()
+{
+ setRejectLabel(QString());
+}
+
+bool QQuickPlatformFolderDialog::useNativeDialog() const
+{
+ return QQuickPlatformDialog::useNativeDialog()
+ && !m_options->testOption(QFileDialogOptions::DontUseNativeDialog);
+}
+
+void QQuickPlatformFolderDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog)) {
+ connect(fileDialog, &QPlatformFileDialogHelper::directoryEntered, this, &QQuickPlatformFolderDialog::currentFolderChanged);
+ fileDialog->setOptions(m_options);
+ }
+}
+
+void QQuickPlatformFolderDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ m_options->setWindowTitle(title());
+ if (QPlatformFileDialogHelper *fileDialog = qobject_cast<QPlatformFileDialogHelper *>(dialog))
+ fileDialog->setOptions(m_options);
+}
+
+void QQuickPlatformFolderDialog::accept()
+{
+ setFolder(currentFolder());
+ QQuickPlatformDialog::accept();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformfolderdialog_p.h b/src/imports/platform/qquickplatformfolderdialog_p.h
new file mode 100644
index 00000000..d9ecd1fb
--- /dev/null
+++ b/src/imports/platform/qquickplatformfolderdialog_p.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMFOLDERDIALOG_P_H
+#define QQUICKPLATFORMFOLDERDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This folder is not part of the Qt API. It exists purely as an
+// implementation detail. This header folder may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformdialog_p.h"
+#include <QtCore/qurl.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformFolderDialog : public QQuickPlatformDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged FINAL)
+ Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
+ Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL)
+ Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL)
+ Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL)
+ Q_FLAGS(QFileDialogOptions::FileDialogOptions)
+
+public:
+ explicit QQuickPlatformFolderDialog(QObject *parent = nullptr);
+
+ QUrl folder() const;
+ void setFolder(const QUrl &folder);
+
+ QUrl currentFolder() const;
+ void setCurrentFolder(const QUrl &folder);
+
+ QFileDialogOptions::FileDialogOptions options() const;
+ void setOptions(QFileDialogOptions::FileDialogOptions options);
+ void resetOptions();
+
+ QString acceptLabel() const;
+ void setAcceptLabel(const QString &label);
+ void resetAcceptLabel();
+
+ QString rejectLabel() const;
+ void setRejectLabel(const QString &label);
+ void resetRejectLabel();
+
+Q_SIGNALS:
+ void folderChanged();
+ void currentFolderChanged();
+ void optionsChanged();
+ void acceptLabelChanged();
+ void rejectLabelChanged();
+
+protected:
+ bool useNativeDialog() const override;
+ void onCreate(QPlatformDialogHelper *dialog) override;
+ void onShow(QPlatformDialogHelper *dialog) override;
+ void accept() override;
+
+private:
+ QUrl m_folder;
+ QSharedPointer<QFileDialogOptions> m_options;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformFolderDialog)
+
+#endif // QQUICKPLATFORMFOLDERDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformfontdialog.cpp b/src/imports/platform/qquickplatformfontdialog.cpp
new file mode 100644
index 00000000..edefe645
--- /dev/null
+++ b/src/imports/platform/qquickplatformfontdialog.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformfontdialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype FontDialog
+ \inherits Dialog
+ \instantiates QQuickPlatformFontDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native font dialog.
+
+ The FontDialog type provides a QML API for native platform font dialogs.
+
+ \image qtlabsplatform-fontdialog-gtk.png
+
+ To show a font dialog, construct an instance of FontDialog, set the
+ desired properties, and call \l {Dialog::}{open()}. The \l currentFont
+ property can be used to determine the currently selected font in the
+ dialog. The \l font property is updated only after the final selection
+ has been made by accepting the dialog.
+
+ \code
+ MenuItem {
+ text: "Font"
+ onTriggered: fontDialog.open()
+ }
+
+ FontDialog {
+ id: fontDialog
+ currentFont.family: document.font
+ }
+
+ MyDocument {
+ id: document
+ font: fontDialog.font
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native platform font dialog is currently available on the following platforms:
+
+ \list
+ \li macOS
+ \li Linux (when running with the GTK+ platform theme)
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+*/
+
+QQuickPlatformFontDialog::QQuickPlatformFontDialog(QObject *parent)
+ : QQuickPlatformDialog(QPlatformTheme::FontDialog, parent),
+ m_options(QFontDialogOptions::create())
+{
+}
+
+/*!
+ \qmlproperty font Qt.labs.platform::FontDialog::font
+
+ This property holds the final accepted font.
+
+ Unlike the \l currentFont property, the \c font property is not updated
+ while the user is selecting fonts in the dialog, but only after the final
+ selection has been made. That is, when the user has clicked \uicontrol OK
+ to accept a font. Alternatively, the \l {Dialog::}{accepted()} signal
+ can be handled to get the final selection.
+
+ \sa currentFont, {Dialog::}{accepted()}
+*/
+QFont QQuickPlatformFontDialog::font() const
+{
+ return m_font;
+}
+
+void QQuickPlatformFontDialog::setFont(const QFont &font)
+{
+ if (m_font == font)
+ return;
+
+ m_font = font;
+ setCurrentFont(font);
+ emit fontChanged();
+}
+
+/*!
+ \qmlproperty font Qt.labs.platform::FontDialog::currentFont
+
+ This property holds the currently selected font in the dialog.
+
+ Unlike the \l font property, the \c currentFont property is updated
+ while the user is selecting fonts in the dialog, even before the final
+ selection has been made.
+
+ \sa font
+*/
+QFont QQuickPlatformFontDialog::currentFont() const
+{
+ if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle()))
+ return fontDialog->currentFont();
+ return m_currentFont;
+}
+
+void QQuickPlatformFontDialog::setCurrentFont(const QFont &font)
+{
+ if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(handle()))
+ fontDialog->setCurrentFont(font);
+ m_currentFont = font;
+}
+
+/*!
+ \qmlproperty flags Qt.labs.platform::FontDialog::options
+
+ This property holds the various options that affect the look and feel of the dialog.
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the dialog is
+ visible is not guaranteed to have an immediate effect on the dialog (depending on
+ the option and on the platform).
+
+ Available options:
+ \value FontDialog.ScalableFonts Show scalable fonts.
+ \value FontDialog.NonScalableFonts Show non-scalable fonts.
+ \value FontDialog.MonospacedFonts Show monospaced fonts.
+ \value FontDialog.ProportionalFonts Show proportional fonts.
+ \value FontDialog.NoButtons Don't display \uicontrol OK and \uicontrol Cancel buttons (useful for "live dialogs").
+*/
+QFontDialogOptions::FontDialogOptions QQuickPlatformFontDialog::options() const
+{
+ return m_options->options();
+}
+
+void QQuickPlatformFontDialog::setOptions(QFontDialogOptions::FontDialogOptions options)
+{
+ if (options == m_options->options())
+ return;
+
+ m_options->setOptions(options);
+ emit optionsChanged();
+}
+
+bool QQuickPlatformFontDialog::useNativeDialog() const
+{
+ return QQuickPlatformDialog::useNativeDialog()
+ && !m_options->testOption(QFontDialogOptions::DontUseNativeDialog);
+}
+
+void QQuickPlatformFontDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog)) {
+ connect(fontDialog, &QPlatformFontDialogHelper::currentFontChanged, this, &QQuickPlatformFontDialog::currentFontChanged);
+ fontDialog->setOptions(m_options);
+ }
+}
+
+void QQuickPlatformFontDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ m_options->setWindowTitle(title());
+ if (QPlatformFontDialogHelper *fontDialog = qobject_cast<QPlatformFontDialogHelper *>(dialog))
+ fontDialog->setOptions(m_options);
+}
+
+void QQuickPlatformFontDialog::accept()
+{
+ setFont(currentFont());
+ QQuickPlatformDialog::accept();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformfontdialog_p.h b/src/imports/platform/qquickplatformfontdialog_p.h
new file mode 100644
index 00000000..c0704610
--- /dev/null
+++ b/src/imports/platform/qquickplatformfontdialog_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMFONTDIALOG_P_H
+#define QQUICKPLATFORMFONTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformdialog_p.h"
+#include <QtGui/qfont.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformFontDialog : public QQuickPlatformDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
+ Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged FINAL)
+ Q_PROPERTY(QFontDialogOptions::FontDialogOptions options READ options WRITE setOptions NOTIFY optionsChanged FINAL)
+ Q_FLAGS(QFontDialogOptions::FontDialogOptions)
+
+public:
+ explicit QQuickPlatformFontDialog(QObject *parent = nullptr);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QFont currentFont() const;
+ void setCurrentFont(const QFont &font);
+
+ QFontDialogOptions::FontDialogOptions options() const;
+ void setOptions(QFontDialogOptions::FontDialogOptions options);
+
+Q_SIGNALS:
+ void fontChanged();
+ void currentFontChanged();
+ void optionsChanged();
+
+protected:
+ bool useNativeDialog() const override;
+ void onCreate(QPlatformDialogHelper *dialog) override;
+ void onShow(QPlatformDialogHelper *dialog) override;
+ void accept() override;
+
+private:
+ QFont m_font;
+ QFont m_currentFont; // TODO: QFontDialogOptions::initialFont
+ QSharedPointer<QFontDialogOptions> m_options;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformFontDialog)
+
+#endif // QQUICKPLATFORMFONTDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformiconloader.cpp b/src/imports/platform/qquickplatformiconloader.cpp
new file mode 100644
index 00000000..08df44d9
--- /dev/null
+++ b/src/imports/platform/qquickplatformiconloader.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformiconloader_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qmetaobject.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickPlatformIconLoader::QQuickPlatformIconLoader(int slot, QObject *parent)
+ : m_parent(parent),
+ m_slot(slot),
+ m_enabled(false)
+{
+ Q_ASSERT(slot != -1 && parent);
+}
+
+bool QQuickPlatformIconLoader::isEnabled() const
+{
+ return m_enabled;
+}
+
+void QQuickPlatformIconLoader::setEnabled(bool enabled)
+{
+ m_enabled = enabled;
+ if (m_enabled)
+ loadIcon();
+}
+
+QIcon QQuickPlatformIconLoader::icon() const
+{
+ QIcon fallback = QPixmap::fromImage(image());
+ return QIcon::fromTheme(m_iconName, fallback);
+}
+
+QUrl QQuickPlatformIconLoader::iconSource() const
+{
+ return m_iconSource;
+}
+
+void QQuickPlatformIconLoader::setIconSource(const QUrl& source)
+{
+ m_iconSource = source;
+ if (m_enabled)
+ loadIcon();
+}
+
+QString QQuickPlatformIconLoader::iconName() const
+{
+ return m_iconName;
+}
+
+void QQuickPlatformIconLoader::setIconName(const QString& name)
+{
+ m_iconName = name;
+ if (m_enabled)
+ loadIcon();
+}
+
+void QQuickPlatformIconLoader::loadIcon()
+{
+ if (m_iconSource.isEmpty()) {
+ clear(m_parent);
+ } else {
+ load(qmlEngine(m_parent), m_iconSource);
+ if (m_slot != -1 && isLoading()) {
+ connectFinished(m_parent, m_slot);
+ m_slot = -1;
+ }
+ }
+
+ if (!isLoading())
+ m_parent->metaObject()->method(m_slot).invoke(m_parent);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformiconloader_p.h b/src/imports/platform/qquickplatformiconloader_p.h
new file mode 100644
index 00000000..5ddb625f
--- /dev/null
+++ b/src/imports/platform/qquickplatformiconloader_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMICONLOADER_P_H
+#define QQUICKPLATFORMICONLOADER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qurl.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qicon.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+
+class QQuickPlatformIconLoader : public QQuickPixmap
+{
+public:
+ QQuickPlatformIconLoader(int slot, QObject *parent);
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ QIcon icon() const;
+
+ QUrl iconSource() const;
+ void setIconSource(const QUrl &source);
+
+ QString iconName() const;
+ void setIconName(const QString &name);
+
+private:
+ void loadIcon();
+
+ QObject *m_parent;
+ int m_slot;
+ bool m_enabled;
+ QIcon m_icon;
+ QUrl m_iconSource;
+ QString m_iconName;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPLATFORMICONLOADER_P_H
diff --git a/src/imports/platform/qquickplatformmenu.cpp b/src/imports/platform/qquickplatformmenu.cpp
new file mode 100644
index 00000000..17d3b2ce
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenu.cpp
@@ -0,0 +1,835 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmenu_p.h"
+#include "qquickplatformmenubar_p.h"
+#include "qquickplatformmenuitem_p.h"
+#include "qquickplatformiconloader_p.h"
+#include "qquickplatformsystemtrayicon_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtGui/qicon.h>
+#include <QtGui/qcursor.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qv4scopedvalue_p.h>
+#include <QtQml/private/qv4qobjectwrapper_p.h>
+#include <QtQuick/qquickrendercontrol.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qquickitem.h>
+
+#include "widgets/qwidgetplatform_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Menu
+ \inherits QtObject
+ \instantiates QQuickPlatformMenu
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native menu.
+
+ The Menu type provides a QML API for native platform menu popups.
+
+ \image qtlabsplatform-menu.png
+
+ Menu can be used in a \l MenuBar, or as a stand-alone context menu.
+ The following example shows how to open a context menu on right mouse
+ click:
+
+ \code
+ MouseArea {
+ anchors.fill: parent
+ acceptedButtons: Qt.RightButton
+ onClicked: zoomMenu.open()
+ }
+
+ Menu {
+ id: zoomMenu
+
+ MenuItem {
+ text: qsTr("Zoom In")
+ shortcut: StandardKey.ZoomIn
+ onTriggered: zoomIn()
+ }
+
+ MenuItem {
+ text: qsTr("Zoom Out")
+ shortcut: StandardKey.ZoomOut
+ onTriggered: zoomOut()
+ }
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native platform menu is currently available on the following platforms:
+
+ \list
+ \li macOS
+ \li iOS
+ \li Android
+ \li Linux (only available as a stand-alone context menu when running with the GTK+ platform theme)
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+
+ \sa MenuItem, MenuSeparator, MenuBar
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::Menu::aboutToShow()
+
+ This signal is emitted when the menu is about to be shown to the user.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::Menu::aboutToHide()
+
+ This signal is emitted when the menu is about to be hidden from the user.
+*/
+
+Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformMenus)
+
+QQuickPlatformMenu::QQuickPlatformMenu(QObject *parent)
+ : QObject(parent),
+ m_complete(false),
+ m_enabled(true),
+ m_visible(true),
+ m_minimumWidth(-1),
+ m_type(QPlatformMenu::DefaultMenu),
+ m_menuBar(nullptr),
+ m_parentMenu(nullptr),
+ m_systemTrayIcon(nullptr),
+ m_menuItem(nullptr),
+ m_iconLoader(nullptr),
+ m_handle(nullptr)
+{
+}
+
+QQuickPlatformMenu::~QQuickPlatformMenu()
+{
+ if (m_menuBar)
+ m_menuBar->removeMenu(this);
+ if (m_parentMenu)
+ m_parentMenu->removeMenu(this);
+ for (QQuickPlatformMenuItem *item : m_items) {
+ if (QQuickPlatformMenu *subMenu = item->subMenu())
+ subMenu->setParentMenu(nullptr);
+ item->setMenu(nullptr);
+ }
+ delete m_iconLoader;
+ m_iconLoader = nullptr;
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+QPlatformMenu *QQuickPlatformMenu::handle() const
+{
+ return m_handle;
+}
+
+QPlatformMenu * QQuickPlatformMenu::create()
+{
+ if (!m_handle) {
+ if (m_menuBar && m_menuBar->handle())
+ m_handle = m_menuBar->handle()->createMenu();
+ else if (m_parentMenu && m_parentMenu->handle())
+ m_handle = m_parentMenu->handle()->createSubMenu();
+ else if (m_systemTrayIcon && m_systemTrayIcon->handle())
+ m_handle = m_systemTrayIcon->handle()->createMenu();
+
+ // TODO: implement ^
+ // - QCocoaMenuBar::createMenu()
+ // - QCocoaMenu::createSubMenu()
+ // - QCocoaSystemTrayIcon::createMenu()
+ if (!m_handle)
+ m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
+
+ if (!m_handle)
+ m_handle = QWidgetPlatform::createMenu();
+
+ qCDebug(qtLabsPlatformMenus) << "Menu ->" << m_handle;
+
+ if (m_handle) {
+ connect(m_handle, &QPlatformMenu::aboutToShow, this, &QQuickPlatformMenu::aboutToShow);
+ connect(m_handle, &QPlatformMenu::aboutToHide, this, &QQuickPlatformMenu::aboutToHide);
+
+ for (QQuickPlatformMenuItem *item : m_items)
+ m_handle->insertMenuItem(item->create(), nullptr);
+
+ if (m_menuItem) {
+ if (QPlatformMenuItem *handle = m_menuItem->create())
+ handle->setMenu(m_handle);
+ }
+ }
+ }
+ return m_handle;
+}
+
+void QQuickPlatformMenu::destroy()
+{
+ if (!m_handle)
+ return;
+
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+void QQuickPlatformMenu::sync()
+{
+ if (!m_complete || !create())
+ return;
+
+ m_handle->setText(m_title);
+ m_handle->setEnabled(m_enabled);
+ m_handle->setVisible(m_visible);
+ m_handle->setMinimumWidth(m_minimumWidth);
+ m_handle->setMenuType(m_type);
+ m_handle->setFont(m_font);
+
+ if (m_menuBar && m_menuBar->handle())
+ m_menuBar->handle()->syncMenu(m_handle);
+ else if (m_systemTrayIcon && m_systemTrayIcon->handle())
+ m_systemTrayIcon->handle()->updateMenu(m_handle);
+
+ for (QQuickPlatformMenuItem *item : m_items)
+ item->sync();
+}
+
+/*!
+ \default
+ \qmlproperty list<Object> Qt.labs.platform::Menu::data
+
+ This default property holds the list of all objects declared as children of
+ the menu. The data property includes objects that are not \l MenuItem instances,
+ such as \l Timer and \l QtObject.
+
+ \sa items
+*/
+QQmlListProperty<QObject> QQuickPlatformMenu::data()
+{
+ return QQmlListProperty<QObject>(this, nullptr, data_append, data_count, data_at, data_clear);
+}
+
+/*!
+ \qmlproperty list<MenuItem> Qt.labs.platform::Menu::items
+
+ This property holds the list of items in the menu.
+*/
+QQmlListProperty<QQuickPlatformMenuItem> QQuickPlatformMenu::items()
+{
+ return QQmlListProperty<QQuickPlatformMenuItem>(this, nullptr, items_append, items_count, items_at, items_clear);
+}
+
+/*!
+ \readonly
+ \qmlproperty MenuBar Qt.labs.platform::Menu::menuBar
+
+ This property holds the menubar that the menu belongs to, or \c null if the
+ menu is not in a menubar.
+*/
+QQuickPlatformMenuBar *QQuickPlatformMenu::menuBar() const
+{
+ return m_menuBar;
+}
+
+void QQuickPlatformMenu::setMenuBar(QQuickPlatformMenuBar *menuBar)
+{
+ if (m_menuBar == menuBar)
+ return;
+
+ m_menuBar = menuBar;
+ destroy();
+ emit menuBarChanged();
+}
+
+/*!
+ \readonly
+ \qmlproperty Menu Qt.labs.platform::Menu::parentMenu
+
+ This property holds the parent menu that the menu belongs to, or \c null if the
+ menu is not a sub-menu.
+*/
+QQuickPlatformMenu *QQuickPlatformMenu::parentMenu() const
+{
+ return m_parentMenu;
+}
+
+void QQuickPlatformMenu::setParentMenu(QQuickPlatformMenu *menu)
+{
+ if (m_parentMenu == menu)
+ return;
+
+ m_parentMenu = menu;
+ destroy();
+ emit parentMenuChanged();
+}
+
+/*!
+ \readonly
+ \qmlproperty SystemTrayIcon Qt.labs.platform::Menu::systemTrayIcon
+
+ This property holds the system tray icon that the menu belongs to, or \c null
+ if the menu is not in a system tray icon.
+*/
+QQuickPlatformSystemTrayIcon *QQuickPlatformMenu::systemTrayIcon() const
+{
+ return m_systemTrayIcon;
+}
+
+void QQuickPlatformMenu::setSystemTrayIcon(QQuickPlatformSystemTrayIcon *icon)
+{
+ if (m_systemTrayIcon == icon)
+ return;
+
+ m_systemTrayIcon = icon;
+ destroy();
+ emit systemTrayIconChanged();
+}
+
+/*!
+ \readonly
+ \qmlproperty MenuItem Qt.labs.platform::Menu::menuItem
+
+ This property holds the item that presents the menu (in a parent menu).
+*/
+QQuickPlatformMenuItem *QQuickPlatformMenu::menuItem() const
+{
+ if (!m_menuItem) {
+ QQuickPlatformMenu *that = const_cast<QQuickPlatformMenu *>(this);
+ m_menuItem = new QQuickPlatformMenuItem(that);
+ m_menuItem->setSubMenu(that);
+ m_menuItem->setText(m_title);
+ m_menuItem->setIconName(iconName());
+ m_menuItem->setIconSource(iconSource());
+ m_menuItem->setVisible(m_visible);
+ m_menuItem->setEnabled(m_enabled);
+ m_menuItem->componentComplete();
+ }
+ return m_menuItem;
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::Menu::enabled
+
+ This property holds whether the menu is enabled. The default value is \c true.
+*/
+bool QQuickPlatformMenu::isEnabled() const
+{
+ return m_enabled;
+}
+
+void QQuickPlatformMenu::setEnabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+
+ if (m_menuItem)
+ m_menuItem->setEnabled(enabled);
+
+ m_enabled = enabled;
+ sync();
+ emit enabledChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::Menu::visible
+
+ This property holds whether the menu is visible. The default value is \c true.
+*/
+bool QQuickPlatformMenu::isVisible() const
+{
+ return m_visible;
+}
+
+void QQuickPlatformMenu::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ if (m_menuItem)
+ m_menuItem->setVisible(visible);
+
+ m_visible = visible;
+ sync();
+ emit visibleChanged();
+}
+
+/*!
+ \qmlproperty int Qt.labs.platform::Menu::minimumWidth
+
+ This property holds the minimum width of the menu. The default value is \c -1 (no minimum width).
+*/
+int QQuickPlatformMenu::minimumWidth() const
+{
+ return m_minimumWidth;
+}
+
+void QQuickPlatformMenu::setMinimumWidth(int width)
+{
+ if (m_minimumWidth == width)
+ return;
+
+ m_minimumWidth = width;
+ sync();
+ emit minimumWidthChanged();
+}
+
+/*!
+ \qmlproperty enumeration Qt.labs.platform::Menu::type
+
+ This property holds the type of the menu.
+
+ Available values:
+ \value Menu.DefaultMenu A normal menu (default).
+ \value Menu.EditMenu An edit menu with pre-populated cut, copy and paste items.
+*/
+QPlatformMenu::MenuType QQuickPlatformMenu::type() const
+{
+ return m_type;
+}
+
+void QQuickPlatformMenu::setType(QPlatformMenu::MenuType type)
+{
+ if (m_type == type)
+ return;
+
+ m_type = type;
+ sync();
+ emit typeChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::Menu::title
+
+ This property holds the menu's title.
+*/
+QString QQuickPlatformMenu::title() const
+{
+ return m_title;
+}
+
+void QQuickPlatformMenu::setTitle(const QString &title)
+{
+ if (m_title == title)
+ return;
+
+ m_title = title;
+ sync();
+ emit titleChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::Menu::iconSource
+
+ This property holds the url of the menu's icon.
+
+ \sa iconName
+*/
+QUrl QQuickPlatformMenu::iconSource() const
+{
+ if (!m_iconLoader)
+ return QUrl();
+
+ return m_iconLoader->iconSource();
+}
+
+void QQuickPlatformMenu::setIconSource(const QUrl& source)
+{
+ if (source == iconSource())
+ return;
+
+ if (m_menuItem)
+ m_menuItem->setIconSource(source);
+
+ iconLoader()->setIconSource(source);
+ emit iconSourceChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::Menu::iconName
+
+ This property holds the theme name of the menu's icon.
+
+ \sa iconSource, QIcon::fromTheme()
+*/
+QString QQuickPlatformMenu::iconName() const
+{
+ if (!m_iconLoader)
+ return QString();
+
+ return m_iconLoader->iconName();
+}
+
+void QQuickPlatformMenu::setIconName(const QString& name)
+{
+ if (name == iconName())
+ return;
+
+ if (m_menuItem)
+ m_menuItem->setIconName(name);
+
+ iconLoader()->setIconName(name);
+ emit iconNameChanged();
+}
+
+/*!
+ \qmlproperty font Qt.labs.platform::Menu::font
+
+ This property holds the menu's font.
+
+ \sa text
+*/
+QFont QQuickPlatformMenu::font() const
+{
+ return m_font;
+}
+
+void QQuickPlatformMenu::setFont(const QFont& font)
+{
+ if (m_font == font)
+ return;
+
+ m_font = font;
+ sync();
+ emit fontChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::addItem(MenuItem item)
+
+ Adds an \a item to the end of the menu.
+*/
+void QQuickPlatformMenu::addItem(QQuickPlatformMenuItem *item)
+{
+ insertItem(m_items.count(), item);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::insertItem(int index, MenuItem item)
+
+ Inserts an \a item at the specified \a index in the menu.
+*/
+void QQuickPlatformMenu::insertItem(int index, QQuickPlatformMenuItem *item)
+{
+ if (!item || m_items.contains(item))
+ return;
+
+ m_items.insert(index, item);
+ m_data.append(item);
+ item->setMenu(this);
+ if (m_handle && item->create()) {
+ QQuickPlatformMenuItem *before = m_items.value(index + 1);
+ m_handle->insertMenuItem(item->handle(), before ? before->create() : nullptr);
+ }
+ sync();
+ emit itemsChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::removeItem(MenuItem item)
+
+ Removes an \a item from the menu.
+*/
+void QQuickPlatformMenu::removeItem(QQuickPlatformMenuItem *item)
+{
+ if (!item || !m_items.removeOne(item))
+ return;
+
+ m_data.removeOne(item);
+ if (m_handle)
+ m_handle->removeMenuItem(item->handle());
+ item->setMenu(nullptr);
+ sync();
+ emit itemsChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::addMenu(Menu submenu)
+
+ Adds a \a submenu to the end of the menu.
+*/
+void QQuickPlatformMenu::addMenu(QQuickPlatformMenu *menu)
+{
+ insertMenu(m_items.count(), menu);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::insertMenu(int index, Menu submenu)
+
+ Inserts a \a submenu at the specified \a index in the menu.
+*/
+void QQuickPlatformMenu::insertMenu(int index, QQuickPlatformMenu *menu)
+{
+ if (!menu)
+ return;
+
+ menu->setParentMenu(this);
+ insertItem(index, menu->menuItem());
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::removeMenu(Menu submenu)
+
+ Removes a \a submenu from the menu.
+*/
+void QQuickPlatformMenu::removeMenu(QQuickPlatformMenu *menu)
+{
+ if (!menu)
+ return;
+
+ menu->setParentMenu(nullptr);
+ removeItem(menu->menuItem());
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::clear()
+
+ Removes all items from the menu.
+*/
+void QQuickPlatformMenu::clear()
+{
+ if (m_items.isEmpty())
+ return;
+
+ for (QQuickPlatformMenuItem *item : m_items) {
+ m_data.removeOne(item);
+ if (m_handle)
+ m_handle->removeMenuItem(item->handle());
+ item->setMenu(nullptr);
+ delete item;
+ }
+
+ m_items.clear();
+ sync();
+ emit itemsChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::open(MenuItem item)
+
+ Opens the menu at the current mouse position, optionally aligned to a menu \a item.
+*/
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::open(Item target, MenuItem item)
+
+ Opens the menu at the specified \a target item, optionally aligned to a menu \a item.
+*/
+void QQuickPlatformMenu::open(QQmlV4Function *args)
+{
+ if (!m_handle)
+ return;
+
+ if (args->length() > 2) {
+ args->v4engine()->throwTypeError();
+ return;
+ }
+
+ QV4::ExecutionEngine *v4 = args->v4engine();
+ QV4::Scope scope(v4);
+
+ QQuickItem *targetItem = nullptr;
+ if (args->length() > 0) {
+ QV4::ScopedValue value(scope, (*args)[0]);
+ QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
+ if (object)
+ targetItem = qobject_cast<QQuickItem *>(object->object());
+ }
+
+ QQuickPlatformMenuItem *menuItem = nullptr;
+ if (args->length() > 1) {
+ QV4::ScopedValue value(scope, (*args)[1]);
+ QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
+ if (object)
+ menuItem = qobject_cast<QQuickPlatformMenuItem *>(object->object());
+ }
+
+ QPoint offset;
+ QWindow *window = findWindow(targetItem, &offset);
+
+ QRect targetRect;
+ if (targetItem) {
+ QRectF sceneBounds = targetItem->mapRectToScene(targetItem->boundingRect());
+ targetRect = sceneBounds.toAlignedRect().translated(offset);
+ } else {
+#ifndef QT_NO_CURSOR
+ QPoint pos = QCursor::pos();
+ if (window)
+ pos = window->mapFromGlobal(pos);
+ targetRect.moveTo(pos);
+#endif
+ }
+
+ m_handle->showPopup(window, targetRect, menuItem ? menuItem->handle() : nullptr);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::Menu::close()
+
+ Closes the menu.
+*/
+void QQuickPlatformMenu::close()
+{
+ if (m_handle)
+ m_handle->dismiss();
+}
+
+void QQuickPlatformMenu::classBegin()
+{
+}
+
+void QQuickPlatformMenu::componentComplete()
+{
+ m_complete = true;
+ if (m_handle && m_iconLoader)
+ m_iconLoader->setEnabled(true);
+ sync();
+}
+
+QQuickPlatformIconLoader *QQuickPlatformMenu::iconLoader() const
+{
+ if (!m_iconLoader) {
+ QQuickPlatformMenu *that = const_cast<QQuickPlatformMenu *>(this);
+ static int slot = staticMetaObject.indexOfSlot("updateIcon()");
+ m_iconLoader = new QQuickPlatformIconLoader(slot, that);
+ m_iconLoader->setEnabled(m_complete);
+ }
+ return m_iconLoader;
+}
+
+static QWindow *effectiveWindow(QWindow *window, QPoint *offset)
+{
+ QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window);
+ if (quickWindow) {
+ QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, offset);
+ if (renderWindow)
+ return renderWindow;
+ }
+ return window;
+}
+
+QWindow *QQuickPlatformMenu::findWindow(QQuickItem *target, QPoint *offset) const
+{
+ if (target)
+ return effectiveWindow(target->window(), offset);
+
+ if (m_menuBar && m_menuBar->window())
+ return effectiveWindow(m_menuBar->window(), offset);
+
+ QObject *obj = parent();
+ while (obj) {
+ QWindow *window = qobject_cast<QWindow *>(obj);
+ if (window)
+ return effectiveWindow(window, offset);
+
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (item && item->window())
+ return effectiveWindow(item->window(), offset);
+
+ obj = obj->parent();
+ }
+ return nullptr;
+}
+
+void QQuickPlatformMenu::data_append(QQmlListProperty<QObject> *property, QObject *object)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ if (QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem *>(object))
+ menu->addItem(item);
+ else if (QQuickPlatformMenu *subMenu = qobject_cast<QQuickPlatformMenu *>(object))
+ menu->addMenu(subMenu);
+ else
+ menu->m_data.append(object);
+}
+
+int QQuickPlatformMenu::data_count(QQmlListProperty<QObject> *property)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ return menu->m_data.count();
+}
+
+QObject *QQuickPlatformMenu::data_at(QQmlListProperty<QObject> *property, int index)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ return menu->m_data.value(index);
+}
+
+void QQuickPlatformMenu::data_clear(QQmlListProperty<QObject> *property)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ menu->m_data.clear();
+}
+
+void QQuickPlatformMenu::items_append(QQmlListProperty<QQuickPlatformMenuItem> *property, QQuickPlatformMenuItem *item)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ menu->addItem(item);
+}
+
+int QQuickPlatformMenu::items_count(QQmlListProperty<QQuickPlatformMenuItem> *property)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ return menu->m_items.count();
+}
+
+QQuickPlatformMenuItem *QQuickPlatformMenu::items_at(QQmlListProperty<QQuickPlatformMenuItem> *property, int index)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ return menu->m_items.value(index);
+}
+
+void QQuickPlatformMenu::items_clear(QQmlListProperty<QQuickPlatformMenuItem> *property)
+{
+ QQuickPlatformMenu *menu = static_cast<QQuickPlatformMenu *>(property->object);
+ menu->clear();
+}
+
+void QQuickPlatformMenu::updateIcon()
+{
+ if (!m_handle || !m_iconLoader)
+ return;
+
+ m_handle->setIcon(m_iconLoader->icon());
+ sync();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenu_p.h b/src/imports/platform/qquickplatformmenu_p.h
new file mode 100644
index 00000000..587fae99
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenu_p.h
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMENU_P_H
+#define QQUICKPLATFORMMENU_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmllist.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QIcon;
+class QWindow;
+class QQuickItem;
+class QPlatformMenu;
+class QQmlV4Function;
+class QQuickPlatformMenuBar;
+class QQuickPlatformMenuItem;
+class QQuickPlatformIconLoader;
+class QQuickPlatformSystemTrayIcon;
+
+class QQuickPlatformMenu : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenuBar *menuBar READ menuBar NOTIFY menuBarChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenu *parentMenu READ parentMenu NOTIFY parentMenuChanged FINAL)
+ Q_PROPERTY(QQuickPlatformSystemTrayIcon *systemTrayIcon READ systemTrayIcon NOTIFY systemTrayIconChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenuItem *menuItem READ menuItem CONSTANT FINAL)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged FINAL)
+ Q_PROPERTY(QPlatformMenu::MenuType type READ type WRITE setType NOTIFY typeChanged FINAL)
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged FINAL)
+ Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged FINAL)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
+ Q_ENUMS(QPlatformMenu::MenuType)
+ Q_CLASSINFO("DefaultProperty", "data")
+
+public:
+ explicit QQuickPlatformMenu(QObject *parent = nullptr);
+ ~QQuickPlatformMenu();
+
+ QPlatformMenu *handle() const;
+ QPlatformMenu *create();
+ void destroy();
+ void sync();
+
+ QQmlListProperty<QObject> data();
+ QQmlListProperty<QQuickPlatformMenuItem> items();
+
+ QQuickPlatformMenuBar *menuBar() const;
+ void setMenuBar(QQuickPlatformMenuBar *menuBar);
+
+ QQuickPlatformMenu *parentMenu() const;
+ void setParentMenu(QQuickPlatformMenu *menu);
+
+ QQuickPlatformSystemTrayIcon *systemTrayIcon() const;
+ void setSystemTrayIcon(QQuickPlatformSystemTrayIcon *icon);
+
+ QQuickPlatformMenuItem *menuItem() const;
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
+ int minimumWidth() const;
+ void setMinimumWidth(int width);
+
+ QPlatformMenu::MenuType type() const;
+ void setType(QPlatformMenu::MenuType type);
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ QUrl iconSource() const;
+ void setIconSource(const QUrl &source);
+
+ QString iconName() const;
+ void setIconName(const QString &name);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ Q_INVOKABLE void addItem(QQuickPlatformMenuItem *item);
+ Q_INVOKABLE void insertItem(int index, QQuickPlatformMenuItem *item);
+ Q_INVOKABLE void removeItem(QQuickPlatformMenuItem *item);
+
+ Q_INVOKABLE void addMenu(QQuickPlatformMenu *menu);
+ Q_INVOKABLE void insertMenu(int index, QQuickPlatformMenu *menu);
+ Q_INVOKABLE void removeMenu(QQuickPlatformMenu *menu);
+
+ Q_INVOKABLE void clear();
+
+public Q_SLOTS:
+ void open(QQmlV4Function *args);
+ void close();
+
+Q_SIGNALS:
+ void aboutToShow();
+ void aboutToHide();
+
+ void itemsChanged();
+ void menuBarChanged();
+ void parentMenuChanged();
+ void systemTrayIconChanged();
+ void titleChanged();
+ void iconSourceChanged();
+ void iconNameChanged();
+ void enabledChanged();
+ void visibleChanged();
+ void minimumWidthChanged();
+ void fontChanged();
+ void typeChanged();
+
+protected:
+ void classBegin() override;
+ void componentComplete() override;
+
+ QQuickPlatformIconLoader *iconLoader() const;
+
+ QWindow *findWindow(QQuickItem *target, QPoint *offset) const;
+
+ static void data_append(QQmlListProperty<QObject> *property, QObject *object);
+ static int data_count(QQmlListProperty<QObject> *property);
+ static QObject *data_at(QQmlListProperty<QObject> *property, int index);
+ static void data_clear(QQmlListProperty<QObject> *property);
+
+ static void items_append(QQmlListProperty<QQuickPlatformMenuItem> *property, QQuickPlatformMenuItem *item);
+ static int items_count(QQmlListProperty<QQuickPlatformMenuItem> *property);
+ static QQuickPlatformMenuItem *items_at(QQmlListProperty<QQuickPlatformMenuItem> *property, int index);
+ static void items_clear(QQmlListProperty<QQuickPlatformMenuItem> *property);
+
+private Q_SLOTS:
+ void updateIcon();
+
+private:
+ bool m_complete;
+ bool m_enabled;
+ bool m_visible;
+ int m_minimumWidth;
+ QPlatformMenu::MenuType m_type;
+ QString m_title;
+ QFont m_font;
+ QList<QObject *> m_data;
+ QList<QQuickPlatformMenuItem *> m_items;
+ QQuickPlatformMenuBar *m_menuBar;
+ QQuickPlatformMenu *m_parentMenu;
+ QQuickPlatformSystemTrayIcon *m_systemTrayIcon;
+ mutable QQuickPlatformMenuItem *m_menuItem;
+ mutable QQuickPlatformIconLoader *m_iconLoader;
+ QPlatformMenu *m_handle;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenu)
+
+#endif // QQUICKPLATFORMMENU_P_H
diff --git a/src/imports/platform/qquickplatformmenubar.cpp b/src/imports/platform/qquickplatformmenubar.cpp
new file mode 100644
index 00000000..00630a84
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenubar.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmenubar_p.h"
+#include "qquickplatformmenu_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuBar
+ \inherits QtObject
+ \instantiates QQuickPlatformMenuBar
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native menubar.
+
+ The MenuBar type provides a QML API for native platform menubars.
+
+ \image qtlabsplatform-menubar.png
+
+ A menubar consists of a list of drop-down menus.
+
+ \code
+ MenuBar {
+ id: menuBar
+
+ Menu {
+ id: fileMenu
+ title: qsTr("File")
+ // ...
+ }
+
+ Menu {
+ id: editMenu
+ title: qsTr("&Edit")
+ // ...
+ }
+
+ Menu {
+ id: viewMenu
+ title: qsTr("&View")
+ // ...
+ }
+
+ Menu {
+ id: helpMenu
+ title: qsTr("&Help")
+ // ...
+ }
+ }
+ \endcode
+
+ MenuBar is currently available on the following platforms:
+
+ \list
+ \li macOS
+ \li Android
+ \li Linux (only available on desktop environments that provide a global D-Bus menu bar)
+ \endlist
+
+ \labs
+
+ \sa Menu
+*/
+
+Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformMenus)
+
+QQuickPlatformMenuBar::QQuickPlatformMenuBar(QObject *parent)
+ : QObject(parent),
+ m_complete(false),
+ m_window(nullptr),
+ m_handle(nullptr)
+{
+ m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
+ qCDebug(qtLabsPlatformMenus) << "MenuBar ->" << m_handle;
+}
+
+QQuickPlatformMenuBar::~QQuickPlatformMenuBar()
+{
+ for (QQuickPlatformMenu *menu : m_menus)
+ menu->setMenuBar(nullptr);
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+QPlatformMenuBar *QQuickPlatformMenuBar::handle() const
+{
+ return m_handle;
+}
+
+/*!
+ \default
+ \qmlproperty list<Object> Qt.labs.platform::MenuBar::data
+
+ This default property holds the list of all objects declared as children of
+ the menubar. The data property includes objects that are not \l Menu instances,
+ such as \l Timer and \l QtObject.
+
+ \sa menus
+*/
+QQmlListProperty<QObject> QQuickPlatformMenuBar::data()
+{
+ return QQmlListProperty<QObject>(this, nullptr, data_append, data_count, data_at, data_clear);
+}
+
+/*!
+ \qmlproperty list<Menu> Qt.labs.platform::MenuBar::menus
+
+ This property holds the list of menus in the menubar.
+*/
+QQmlListProperty<QQuickPlatformMenu> QQuickPlatformMenuBar::menus()
+{
+ return QQmlListProperty<QQuickPlatformMenu>(this, nullptr, menus_append, menus_count, menus_at, menus_clear);
+}
+
+/*!
+ \qmlproperty Window Qt.labs.platform::MenuBar::window
+
+ This property holds the menubar's window.
+
+ Unless explicitly set, the window is automatically resolved by iterating
+ the QML parent objects until a \l Window or an \l Item that has a window
+ is found.
+*/
+QWindow *QQuickPlatformMenuBar::window() const
+{
+ return m_window;
+}
+
+void QQuickPlatformMenuBar::setWindow(QWindow *window)
+{
+ if (m_window == window)
+ return;
+
+ if (m_handle)
+ m_handle->handleReparent(window);
+
+ m_window = window;
+ emit windowChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuBar::addMenu(Menu menu)
+
+ Adds a \a menu to end of the menubar.
+*/
+void QQuickPlatformMenuBar::addMenu(QQuickPlatformMenu *menu)
+{
+ insertMenu(m_menus.count(), menu);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuBar::insertMenu(int index, Menu menu)
+
+ Inserts a \a menu at the specified \a index in the menubar.
+*/
+void QQuickPlatformMenuBar::insertMenu(int index, QQuickPlatformMenu *menu)
+{
+ if (!menu || m_menus.contains(menu))
+ return;
+
+ QQuickPlatformMenu *before = m_menus.value(index);
+ m_menus.insert(index, menu);
+ m_data.append(menu);
+ menu->setMenuBar(this);
+ if (m_handle)
+ m_handle->insertMenu(menu->create(), before ? before->handle() : nullptr);
+ emit menusChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuBar::removeMenu(Menu menu)
+
+ Removes a \a menu from the menubar.
+*/
+void QQuickPlatformMenuBar::removeMenu(QQuickPlatformMenu *menu)
+{
+ if (!menu || !m_menus.removeOne(menu))
+ return;
+
+ m_data.removeOne(menu);
+ if (m_handle)
+ m_handle->removeMenu(menu->handle());
+ menu->setMenuBar(nullptr);
+ emit menusChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuBar::clear()
+
+ Removes all menus from the menubar.
+*/
+void QQuickPlatformMenuBar::clear()
+{
+ if (m_menus.isEmpty())
+ return;
+
+ for (QQuickPlatformMenu *menu : m_menus) {
+ m_data.removeOne(menu);
+ if (m_handle)
+ m_handle->removeMenu(menu->handle());
+ menu->setMenuBar(nullptr);
+ delete menu;
+ }
+
+ m_menus.clear();
+ emit menusChanged();
+}
+
+void QQuickPlatformMenuBar::classBegin()
+{
+}
+
+void QQuickPlatformMenuBar::componentComplete()
+{
+ m_complete = true;
+ for (QQuickPlatformMenu *menu : m_menus)
+ menu->sync();
+ if (!m_window)
+ setWindow(findWindow());
+}
+
+QWindow *QQuickPlatformMenuBar::findWindow() const
+{
+ QObject *obj = parent();
+ while (obj) {
+ QWindow *window = qobject_cast<QWindow *>(obj);
+ if (window)
+ return window;
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (item && item->window())
+ return item->window();
+ obj = obj->parent();
+ }
+ return nullptr;
+}
+
+void QQuickPlatformMenuBar::data_append(QQmlListProperty<QObject> *property, QObject *object)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ QQuickPlatformMenu *menu = qobject_cast<QQuickPlatformMenu *>(object);
+ if (menu)
+ menuBar->addMenu(menu);
+ else
+ menuBar->m_data.append(object);
+}
+
+int QQuickPlatformMenuBar::data_count(QQmlListProperty<QObject> *property)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ return menuBar->m_data.count();
+}
+
+QObject *QQuickPlatformMenuBar::data_at(QQmlListProperty<QObject> *property, int index)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ return menuBar->m_data.value(index);
+}
+
+void QQuickPlatformMenuBar::data_clear(QQmlListProperty<QObject> *property)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ menuBar->m_data.clear();
+}
+
+void QQuickPlatformMenuBar::menus_append(QQmlListProperty<QQuickPlatformMenu> *property, QQuickPlatformMenu *menu)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ menuBar->addMenu(menu);
+}
+
+int QQuickPlatformMenuBar::menus_count(QQmlListProperty<QQuickPlatformMenu> *property)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ return menuBar->m_menus.count();
+}
+
+QQuickPlatformMenu *QQuickPlatformMenuBar::menus_at(QQmlListProperty<QQuickPlatformMenu> *property, int index)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ return menuBar->m_menus.value(index);
+}
+
+void QQuickPlatformMenuBar::menus_clear(QQmlListProperty<QQuickPlatformMenu> *property)
+{
+ QQuickPlatformMenuBar *menuBar = static_cast<QQuickPlatformMenuBar *>(property->object);
+ menuBar->clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenubar_p.h b/src/imports/platform/qquickplatformmenubar_p.h
new file mode 100644
index 00000000..059acfe6
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenubar_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMENUBAR_P_H
+#define QQUICKPLATFORMMENUBAR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmllist.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindow;
+class QPlatformMenuBar;
+class QQuickPlatformMenu;
+
+class QQuickPlatformMenuBar : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QQmlListProperty<QObject> data READ data FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickPlatformMenu> menus READ menus NOTIFY menusChanged FINAL)
+ Q_PROPERTY(QWindow *window READ window WRITE setWindow NOTIFY windowChanged FINAL)
+ Q_CLASSINFO("DefaultProperty", "data")
+
+public:
+ explicit QQuickPlatformMenuBar(QObject *parent = nullptr);
+ ~QQuickPlatformMenuBar();
+
+ QPlatformMenuBar *handle() const;
+
+ QQmlListProperty<QObject> data();
+ QQmlListProperty<QQuickPlatformMenu> menus();
+
+ QWindow *window() const;
+ void setWindow(QWindow *window);
+
+ Q_INVOKABLE void addMenu(QQuickPlatformMenu *menu);
+ Q_INVOKABLE void insertMenu(int index, QQuickPlatformMenu *menu);
+ Q_INVOKABLE void removeMenu(QQuickPlatformMenu *menu);
+ Q_INVOKABLE void clear();
+
+Q_SIGNALS:
+ void menusChanged();
+ void windowChanged();
+
+protected:
+ void classBegin() override;
+ void componentComplete() override;
+
+ QWindow *findWindow() const;
+
+ static void data_append(QQmlListProperty<QObject> *property, QObject *object);
+ static int data_count(QQmlListProperty<QObject> *property);
+ static QObject *data_at(QQmlListProperty<QObject> *property, int index);
+ static void data_clear(QQmlListProperty<QObject> *property);
+
+ static void menus_append(QQmlListProperty<QQuickPlatformMenu> *property, QQuickPlatformMenu *menu);
+ static int menus_count(QQmlListProperty<QQuickPlatformMenu> *property);
+ static QQuickPlatformMenu *menus_at(QQmlListProperty<QQuickPlatformMenu> *property, int index);
+ static void menus_clear(QQmlListProperty<QQuickPlatformMenu> *property);
+
+private:
+ bool m_complete;
+ QWindow *m_window;
+ QList<QObject *> m_data;
+ QList<QQuickPlatformMenu *> m_menus;
+ QPlatformMenuBar *m_handle;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenuBar)
+
+#endif // QQUICKPLATFORMMENUBAR_P_H
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
new file mode 100644
index 00000000..9f261d24
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -0,0 +1,612 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmenuitem_p.h"
+#include "qquickplatformmenu_p.h"
+#include "qquickplatformmenuitemgroup_p.h"
+#include "qquickplatformiconloader_p.h"
+
+#include <QtGui/qicon.h>
+#include <QtGui/qkeysequence.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/private/qguiapplication_p.h>
+
+#include "widgets/qwidgetplatform_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuItem
+ \inherits QtObject
+ \instantiates QQuickPlatformMenuItem
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native menu item.
+
+ The MenuItem type provides a QML API for native platform menu items.
+
+ \image qtlabsplatform-menu.png
+
+ A menu item consists of an \l {iconSource}{icon}, \l text, and \l shortcut.
+
+ \code
+ Menu {
+ id: zoomMenu
+
+ MenuItem {
+ text: qsTr("Zoom In")
+ shortcut: StandardKey.ZoomIn
+ onTriggered: zoomIn()
+ }
+
+ MenuItem {
+ text: qsTr("Zoom Out")
+ shortcut: StandardKey.ZoomOut
+ onTriggered: zoomOut()
+ }
+ }
+ \endcode
+
+ \labs
+
+ \sa Menu, MenuItemGroup
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MenuItem::triggered()
+
+ This signal is emitted when the menu item is triggered by the user.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MenuItem::hovered()
+
+ This signal is emitted when the menu item is hovered by the user.
+*/
+
+QQuickPlatformMenuItem::QQuickPlatformMenuItem(QObject *parent)
+ : QObject(parent),
+ m_complete(false),
+ m_enabled(true),
+ m_visible(true),
+ m_separator(false),
+ m_checkable(false),
+ m_checked(false),
+ m_role(QPlatformMenuItem::TextHeuristicRole),
+ m_menu(nullptr),
+ m_subMenu(nullptr),
+ m_group(nullptr),
+ m_iconLoader(nullptr),
+ m_handle(nullptr)
+{
+}
+
+QQuickPlatformMenuItem::~QQuickPlatformMenuItem()
+{
+ if (m_menu)
+ m_menu->removeItem(this);
+ if (m_group)
+ m_group->removeItem(this);
+ delete m_iconLoader;
+ m_iconLoader = nullptr;
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+QPlatformMenuItem *QQuickPlatformMenuItem::handle() const
+{
+ return m_handle;
+}
+
+QPlatformMenuItem *QQuickPlatformMenuItem::create()
+{
+ if (!m_handle && m_menu && m_menu->handle()) {
+ m_handle = m_menu->handle()->createMenuItem();
+
+ // TODO: implement QCocoaMenu::createMenuItem()
+ if (!m_handle)
+ m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
+
+ if (!m_handle)
+ m_handle = QWidgetPlatform::createMenuItem();
+
+ if (m_handle) {
+ connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::triggered);
+ connect(m_handle, &QPlatformMenuItem::hovered, this, &QQuickPlatformMenuItem::hovered);
+ if (m_checkable)
+ connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
+ }
+ }
+ return m_handle;
+}
+
+void QQuickPlatformMenuItem::sync()
+{
+ if (!m_complete || !create())
+ return;
+
+ m_handle->setEnabled(isEnabled());
+ m_handle->setVisible(isVisible());
+ m_handle->setIsSeparator(m_separator);
+ m_handle->setCheckable(m_checkable);
+ m_handle->setChecked(m_checked);
+ m_handle->setRole(m_role);
+ m_handle->setText(m_text);
+ m_handle->setFont(m_font);
+ m_handle->setHasExclusiveGroup(m_group && m_group->isExclusive());
+ if (m_subMenu && m_subMenu->handle())
+ m_handle->setMenu(m_subMenu->handle());
+
+ QKeySequence sequence;
+ if (m_shortcut.type() == QVariant::Int)
+ sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt()));
+ else
+ sequence = QKeySequence::fromString(m_shortcut.toString());
+ m_handle->setShortcut(sequence.toString());
+
+ if (m_menu && m_menu->handle())
+ m_menu->handle()->syncMenuItem(m_handle);
+}
+
+/*!
+ \readonly
+ \qmlproperty Menu Qt.labs.platform::MenuItem::menu
+
+ This property holds the menu that the item belongs to, or \c null if the
+ item is not in a menu.
+*/
+QQuickPlatformMenu *QQuickPlatformMenuItem::menu() const
+{
+ return m_menu;
+}
+
+void QQuickPlatformMenuItem::setMenu(QQuickPlatformMenu *menu)
+{
+ if (m_menu == menu)
+ return;
+
+ m_menu = menu;
+ emit menuChanged();
+}
+
+/*!
+ \readonly
+ \qmlproperty Menu Qt.labs.platform::MenuItem::subMenu
+
+ This property holds the sub-menu that the item contains, or \c null if
+ the item is not a sub-menu item.
+*/
+QQuickPlatformMenu *QQuickPlatformMenuItem::subMenu() const
+{
+ return m_subMenu;
+}
+
+void QQuickPlatformMenuItem::setSubMenu(QQuickPlatformMenu *menu)
+{
+ if (m_subMenu == menu)
+ return;
+
+ m_subMenu = menu;
+ sync();
+ emit subMenuChanged();
+}
+
+/*!
+ \qmlproperty MenuItemGroup Qt.labs.platform::MenuItem::group
+
+ This property holds the group that the item belongs to, or \c null if the
+ item is not in a group.
+*/
+QQuickPlatformMenuItemGroup *QQuickPlatformMenuItem::group() const
+{
+ return m_group;
+}
+
+void QQuickPlatformMenuItem::setGroup(QQuickPlatformMenuItemGroup *group)
+{
+ if (m_group == group)
+ return;
+
+ bool wasEnabled = isEnabled();
+ bool wasVisible = isVisible();
+
+ if (group)
+ group->addItem(this);
+
+ m_group = group;
+ sync();
+ emit groupChanged();
+
+ if (isEnabled() != wasEnabled)
+ emit enabledChanged();
+ if (isVisible() != wasVisible)
+ emit visibleChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItem::enabled
+
+ This property holds whether the item is enabled. The default value is \c true.
+
+ Disabled items cannot be triggered by the user. They do not disappear from menus,
+ but they are displayed in a way which indicates that they are unavailable. For
+ example, they might be displayed using only shades of gray.
+
+ When an item is disabled, it is not possible to trigger it through its \l shortcut.
+*/
+bool QQuickPlatformMenuItem::isEnabled() const
+{
+ return m_enabled && (!m_group || m_group->isEnabled());
+}
+
+void QQuickPlatformMenuItem::setEnabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+
+ bool wasEnabled = isEnabled();
+ m_enabled = enabled;
+ sync();
+ if (isEnabled() != wasEnabled)
+ emit enabledChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItem::visible
+
+ This property holds whether the item is visible. The default value is \c true.
+*/
+bool QQuickPlatformMenuItem::isVisible() const
+{
+ return m_visible && (!m_group || m_group->isVisible());
+}
+
+void QQuickPlatformMenuItem::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ bool wasVisible = isVisible();
+ m_visible = visible;
+ sync();
+ if (isVisible() != wasVisible)
+ emit visibleChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItem::separator
+
+ This property holds whether the item is a separator line. The default value
+ is \c false.
+
+ \sa MenuSeparator
+*/
+bool QQuickPlatformMenuItem::isSeparator() const
+{
+ return m_separator;
+}
+
+void QQuickPlatformMenuItem::setSeparator(bool separator)
+{
+ if (m_separator == separator)
+ return;
+
+ m_separator = separator;
+ sync();
+ emit separatorChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItem::checkable
+
+ This property holds whether the item is checkable.
+
+ A checkable menu item has an on/off state. For example, in a word processor,
+ a "Bold" menu item may be either on or off. A menu item that is not checkable
+ is a command item that is simply executed, e.g. file save.
+
+ The default value is \c false.
+
+ \sa checked, MenuItemGroup
+*/
+bool QQuickPlatformMenuItem::isCheckable() const
+{
+ return m_checkable;
+}
+
+void QQuickPlatformMenuItem::setCheckable(bool checkable)
+{
+ if (m_checkable == checkable)
+ return;
+
+ if (m_handle) {
+ if (checkable)
+ connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
+ else
+ disconnect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
+ }
+
+ m_checkable = checkable;
+ sync();
+ emit checkableChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItem::checked
+
+ This property holds whether the item is checked (on) or unchecked (off).
+ The default value is \c false.
+
+ \sa checkable, MenuItemGroup
+*/
+bool QQuickPlatformMenuItem::isChecked() const
+{
+ return m_checked;
+}
+
+void QQuickPlatformMenuItem::setChecked(bool checked)
+{
+ if (m_checked == checked)
+ return;
+
+ if (checked && !m_checkable)
+ setCheckable(true);
+
+ m_checked = checked;
+ sync();
+ emit checkedChanged();
+}
+
+/*!
+ \qmlproperty enumeration Qt.labs.platform::MenuItem::role
+
+ This property holds the role of the item. The role determines whether
+ the item should be placed into the application menu on macOS.
+
+ Available values:
+ \value MenuItem.NoRole The item should not be put into the application menu
+ \value MenuItem.TextHeuristicRole The item should be put in the application menu based on the action's text (default)
+ \value MenuItem.ApplicationSpecificRole The item should be put in the application menu with an application-specific role
+ \value MenuItem.AboutQtRole The item handles the "About Qt" menu item.
+ \value MenuItem.AboutRole The item should be placed where the "About" menu item is in the application menu. The text of
+ the menu item will be set to "About <application name>". The application name is fetched from the
+ \c{Info.plist} file in the application's bundle (See \l{Qt for OS X - Deployment}).
+ \value MenuItem.PreferencesRole The item should be placed where the "Preferences..." menu item is in the application menu.
+ \value MenuItem.QuitRole The item should be placed where the Quit menu item is in the application menu.
+
+ Specifying the role only has effect on items that are in the immediate
+ menus of a menubar, not in the submenus of those menus. For example, if
+ you have a "File" menu in your menubar and the "File" menu has a submenu,
+ specifying a role for the items in that submenu has no effect. They will
+ never be moved to the application menu.
+*/
+QPlatformMenuItem::MenuRole QQuickPlatformMenuItem::role() const
+{
+ return m_role;
+}
+
+void QQuickPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
+{
+ if (m_role == role)
+ return;
+
+ m_role = role;
+ sync();
+ emit roleChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::MenuItem::text
+
+ This property holds the menu item's text.
+*/
+QString QQuickPlatformMenuItem::text() const
+{
+ return m_text;
+}
+
+void QQuickPlatformMenuItem::setText(const QString &text)
+{
+ if (m_text == text)
+ return;
+
+ m_text = text;
+ sync();
+ emit textChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::MenuItem::iconSource
+
+ This property holds the url of the menu item's icon.
+
+ \code
+ MenuItem {
+ iconName: "edit-undo"
+ iconSource: "qrc:/images/undo.png"
+ }
+ \endcode
+
+ \sa iconName
+*/
+QUrl QQuickPlatformMenuItem::iconSource() const
+{
+ if (!m_iconLoader)
+ return QUrl();
+
+ return m_iconLoader->iconSource();
+}
+
+void QQuickPlatformMenuItem::setIconSource(const QUrl& source)
+{
+ if (source == iconSource())
+ return;
+
+ iconLoader()->setIconSource(source);
+ emit iconSourceChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::MenuItem::iconName
+
+ This property holds the theme name of the menu item's icon.
+
+ \code
+ MenuItem {
+ iconName: "edit-undo"
+ iconSource: "qrc:/images/undo.png"
+ }
+ \endcode
+
+ \sa iconSource, QIcon::fromTheme()
+*/
+QString QQuickPlatformMenuItem::iconName() const
+{
+ if (!m_iconLoader)
+ return QString();
+
+ return m_iconLoader->iconName();
+}
+
+void QQuickPlatformMenuItem::setIconName(const QString& name)
+{
+ if (name == iconName())
+ return;
+
+ iconLoader()->setIconName(name);
+ emit iconNameChanged();
+}
+
+/*!
+ \qmlproperty keysequence Qt.labs.platform::MenuItem::shortcut
+
+ This property holds the menu item's shortcut.
+
+ The shortcut key sequence can be set to one of the
+ \l{QKeySequence::StandardKey}{standard keyboard shortcuts}, or it can be
+ specified by a string containing a sequence of up to four key presses
+ that are needed to \l{triggered}{trigger} the shortcut.
+
+ The default value is an empty key sequence.
+
+ \code
+ MenuItem {
+ shortcut: "Ctrl+E,Ctrl+W"
+ onTriggered: edit.wrapMode = TextEdit.Wrap
+ }
+ \endcode
+*/
+QVariant QQuickPlatformMenuItem::shortcut() const
+{
+ return m_shortcut;
+}
+
+void QQuickPlatformMenuItem::setShortcut(const QVariant& shortcut)
+{
+ if (m_shortcut == shortcut)
+ return;
+
+ m_shortcut = shortcut;
+ sync();
+ emit shortcutChanged();
+}
+
+/*!
+ \qmlproperty font Qt.labs.platform::MenuItem::font
+
+ This property holds the menu item's font.
+
+ \sa text
+*/
+QFont QQuickPlatformMenuItem::font() const
+{
+ return m_font;
+}
+
+void QQuickPlatformMenuItem::setFont(const QFont& font)
+{
+ if (m_font == font)
+ return;
+
+ m_font = font;
+ sync();
+ emit fontChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuItem::toggle()
+
+ Toggles the \l checked state to its opposite state.
+*/
+void QQuickPlatformMenuItem::toggle()
+{
+ if (m_checkable)
+ setChecked(!m_checked);
+}
+
+void QQuickPlatformMenuItem::classBegin()
+{
+}
+
+void QQuickPlatformMenuItem::componentComplete()
+{
+ if (m_handle && m_iconLoader)
+ m_iconLoader->setEnabled(true);
+ m_complete = true;
+ sync();
+}
+
+QQuickPlatformIconLoader *QQuickPlatformMenuItem::iconLoader() const
+{
+ if (!m_iconLoader) {
+ QQuickPlatformMenuItem *that = const_cast<QQuickPlatformMenuItem *>(this);
+ static int slot = staticMetaObject.indexOfSlot("updateIcon()");
+ m_iconLoader = new QQuickPlatformIconLoader(slot, that);
+ m_iconLoader->setEnabled(m_complete);
+ }
+ return m_iconLoader;
+}
+
+void QQuickPlatformMenuItem::updateIcon()
+{
+ if (!m_handle || !m_iconLoader)
+ return;
+
+ m_handle->setIcon(m_iconLoader->icon());
+ sync();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenuitem_p.h b/src/imports/platform/qquickplatformmenuitem_p.h
new file mode 100644
index 00000000..48a5603e
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuitem_p.h
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMENUITEM_P_H
+#define QQUICKPLATFORMMENUITEM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformMenuItem;
+class QQuickPlatformMenu;
+class QQuickPlatformIconLoader;
+class QQuickPlatformMenuItemGroup;
+
+class QQuickPlatformMenuItem : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(QQuickPlatformMenu *menu READ menu NOTIFY menuChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenu *subMenu READ subMenu NOTIFY subMenuChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenuItemGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(bool separator READ isSeparator WRITE setSeparator NOTIFY separatorChanged FINAL)
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL)
+ Q_PROPERTY(QPlatformMenuItem::MenuRole role READ role WRITE setRole NOTIFY roleChanged FINAL)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged FINAL)
+ Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged FINAL)
+ Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
+ Q_ENUMS(QPlatformMenuItem::MenuRole)
+
+public:
+ explicit QQuickPlatformMenuItem(QObject *parent = nullptr);
+ ~QQuickPlatformMenuItem();
+
+ QPlatformMenuItem *handle() const;
+ QPlatformMenuItem *create();
+ void sync();
+
+ QQuickPlatformMenu *menu() const;
+ void setMenu(QQuickPlatformMenu* menu);
+
+ QQuickPlatformMenu *subMenu() const;
+ void setSubMenu(QQuickPlatformMenu *menu);
+
+ QQuickPlatformMenuItemGroup *group() const;
+ void setGroup(QQuickPlatformMenuItemGroup *group);
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
+ bool isSeparator() const;
+ void setSeparator(bool separator);
+
+ bool isCheckable() const;
+ void setCheckable(bool checkable);
+
+ bool isChecked() const;
+ void setChecked(bool checked);
+
+ QPlatformMenuItem::MenuRole role() const;
+ void setRole(QPlatformMenuItem::MenuRole role);
+
+ QString text() const;
+ void setText(const QString &text);
+
+ QUrl iconSource() const;
+ void setIconSource(const QUrl &source);
+
+ QString iconName() const;
+ void setIconName(const QString &name);
+
+ QVariant shortcut() const;
+ void setShortcut(const QVariant& shortcut);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+public Q_SLOTS:
+ void toggle();
+
+Q_SIGNALS:
+ void triggered();
+ void hovered();
+
+ void menuChanged();
+ void subMenuChanged();
+ void groupChanged();
+ void enabledChanged();
+ void visibleChanged();
+ void separatorChanged();
+ void checkableChanged();
+ void checkedChanged();
+ void roleChanged();
+ void textChanged();
+ void iconSourceChanged();
+ void iconNameChanged();
+ void shortcutChanged();
+ void fontChanged();
+
+protected:
+ void classBegin() override;
+ void componentComplete() override;
+
+ QQuickPlatformIconLoader *iconLoader() const;
+
+private Q_SLOTS:
+ void updateIcon();
+
+private:
+ bool m_complete;
+ bool m_enabled;
+ bool m_visible;
+ bool m_separator;
+ bool m_checkable;
+ bool m_checked;
+ QPlatformMenuItem::MenuRole m_role;
+ QString m_text;
+ QVariant m_shortcut;
+ QFont m_font;
+ QQuickPlatformMenu *m_menu;
+ QQuickPlatformMenu *m_subMenu;
+ QQuickPlatformMenuItemGroup *m_group;
+ mutable QQuickPlatformIconLoader *m_iconLoader;
+ QPlatformMenuItem *m_handle;
+
+ friend class QQuickPlatformMenu;
+ friend class QQuickPlatformMenuItemGroup;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenuItem)
+
+#endif // QQUICKPLATFORMMENUITEM_P_H
diff --git a/src/imports/platform/qquickplatformmenuitemgroup.cpp b/src/imports/platform/qquickplatformmenuitemgroup.cpp
new file mode 100644
index 00000000..1f4dda3c
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuitemgroup.cpp
@@ -0,0 +1,390 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Templates module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmenuitemgroup_p.h"
+#include "qquickplatformmenuitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuItemGroup
+ \inherits QtObject
+ \instantiates QQuickPlatformMenuItemGroup
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A group for managing native menu items.
+
+ The MenuItemGroup groups native menu items together.
+
+ MenuItemGroup is exclusive by default. In an exclusive menu item
+ group, only one item can be checked at any time; checking another
+ item automatically unchecks the previously checked one. MenuItemGroup
+ can be configured as non-exclusive, which is particularly useful for
+ showing, hiding, enabling and disabling items together as a group.
+
+ The most straight-forward way to use MenuItemGroup is to assign
+ a list of items.
+
+ \code
+ Menu {
+ id: verticalMenu
+ title: qsTr("Vertical")
+
+ MenuItemGroup {
+ id: verticalGroup
+ items: verticalMenu.items
+ }
+
+ MenuItem { text: qsTr("Top"); checkable: true }
+ MenuItem { text: qsTr("Center"); checked: true }
+ MenuItem { text: qsTr("Bottom"); checkable: true }
+ }
+ \endcode
+
+ The same menu may sometimes contain items that should not be included
+ in the same exclusive group. Such cases are best handled using the
+ \l {MenuItem::group}{group} property.
+
+ \code
+ Menu {
+ id: horizontalMenu
+ title: qsTr("Horizontal")
+
+ MenuItemGroup {
+ id: horizontalGroup
+ }
+
+ MenuItem {
+ checked: true
+ text: qsTr("Left")
+ group: horizontalGroup
+ }
+ MenuItem {
+ checkable: true
+ text: qsTr("Center")
+ group: horizontalGroup
+ }
+ MenuItem {
+ text: qsTr("Right")
+ checkable: true
+ group: horizontalGroup
+ }
+
+ MenuItem { separator: true }
+ MenuItem { text: qsTr("Justify"); checkable: true }
+ MenuItem { text: qsTr("Absolute"); checkable: true }
+ }
+ \endcode
+
+ More advanced use cases can be handled using the addItem() and
+ removeItem() methods.
+
+ \labs
+
+ \sa MenuItem
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MenuItemGroup::triggered(MenuItem item)
+
+ This signal is emitted when an \a item in the group is triggered by the user.
+
+ \sa MenuItem::triggered()
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MenuItemGroup::hovered(MenuItem item)
+
+ This signal is emitted when an \a item in the group is hovered by the user.
+
+ \sa MenuItem::hovered()
+*/
+
+QQuickPlatformMenuItemGroup::QQuickPlatformMenuItemGroup(QObject *parent)
+ : QObject(parent), m_enabled(true), m_visible(true), m_exclusive(true), m_checkedItem(nullptr)
+{
+}
+
+QQuickPlatformMenuItemGroup::~QQuickPlatformMenuItemGroup()
+{
+ clear();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItemGroup::enabled
+
+ This property holds whether the group is enabled. The default value is \c true.
+
+ The enabled state of the group affects the enabled state of each item in the group,
+ except that explicitly disabled items are not enabled even if the group is enabled.
+*/
+bool QQuickPlatformMenuItemGroup::isEnabled() const
+{
+ return m_enabled;
+}
+
+void QQuickPlatformMenuItemGroup::setEnabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+
+ m_enabled = enabled;
+ emit enabledChanged();
+
+ for (QQuickPlatformMenuItem *item : m_items) {
+ if (item->m_enabled) {
+ item->sync();
+ emit item->enabledChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItemGroup::visible
+
+ This property holds whether the group is visible. The default value is \c true.
+
+ The visibility of the group affects the visibility of each item in the group,
+ except that explicitly hidden items are not visible even if the group is visible.
+*/
+bool QQuickPlatformMenuItemGroup::isVisible() const
+{
+ return m_visible;
+}
+
+void QQuickPlatformMenuItemGroup::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ m_visible = visible;
+ emit visibleChanged();
+
+ for (QQuickPlatformMenuItem *item : m_items) {
+ if (item->m_visible) {
+ item->sync();
+ emit item->visibleChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::MenuItemGroup::exclusive
+
+ This property holds whether the group is exclusive. The default value is \c true.
+
+ In an exclusive menu item group, only one item can be checked at any time;
+ checking another item automatically unchecks the previously checked one.
+*/
+bool QQuickPlatformMenuItemGroup::isExclusive() const
+{
+ return m_exclusive;
+}
+
+void QQuickPlatformMenuItemGroup::setExclusive(bool exclusive)
+{
+ if (m_exclusive == exclusive)
+ return;
+
+ m_exclusive = exclusive;
+ emit exclusiveChanged();
+
+ for (QQuickPlatformMenuItem *item : m_items)
+ item->sync();
+}
+
+/*!
+ \qmlproperty MenuItem Qt.labs.platform::MenuItemGroup::checkedItem
+
+ This property holds the currently checked item in the group, or \c null if no item is checked.
+*/
+QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::checkedItem() const
+{
+ return m_checkedItem;
+}
+
+void QQuickPlatformMenuItemGroup::setCheckedItem(QQuickPlatformMenuItem *item)
+{
+ if (m_checkedItem == item)
+ return;
+
+ if (m_checkedItem)
+ m_checkedItem->setChecked(false);
+
+ m_checkedItem = item;
+ emit checkedItemChanged();
+
+ if (item)
+ item->setChecked(true);
+}
+
+/*!
+ \qmlproperty list<MenuItem> Qt.labs.platform::MenuItemGroup::items
+
+ This property holds the list of items in the group.
+*/
+QQmlListProperty<QQuickPlatformMenuItem> QQuickPlatformMenuItemGroup::items()
+{
+ return QQmlListProperty<QQuickPlatformMenuItem>(this, nullptr, items_append, items_count, items_at, items_clear);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuItemGroup::addItem(MenuItem item)
+
+ Adds an \a item to the group.
+*/
+void QQuickPlatformMenuItemGroup::addItem(QQuickPlatformMenuItem *item)
+{
+ if (!item || m_items.contains(item))
+ return;
+
+ m_items.append(item);
+ item->setGroup(this);
+
+ connect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent);
+ connect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem);
+ connect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem);
+
+ if (m_exclusive && item->isChecked())
+ setCheckedItem(item);
+
+ emit itemsChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuItemGroup::removeItem(MenuItem item)
+
+ Removes an \a item from the group.
+*/
+void QQuickPlatformMenuItemGroup::removeItem(QQuickPlatformMenuItem *item)
+{
+ if (!item || !m_items.contains(item))
+ return;
+
+ m_items.removeOne(item);
+ item->setGroup(nullptr);
+
+ disconnect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent);
+ disconnect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem);
+ disconnect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem);
+
+ if (m_checkedItem == item)
+ setCheckedItem(nullptr);
+
+ emit itemsChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::MenuItemGroup::clear()
+
+ Removes all items from the group.
+*/
+void QQuickPlatformMenuItemGroup::clear()
+{
+ if (m_items.isEmpty())
+ return;
+
+ for (QQuickPlatformMenuItem *item : m_items) {
+ item->setGroup(nullptr);
+ disconnect(item, &QQuickPlatformMenuItem::checkedChanged, this, &QQuickPlatformMenuItemGroup::updateCurrent);
+ disconnect(item, &QQuickPlatformMenuItem::triggered, this, &QQuickPlatformMenuItemGroup::activateItem);
+ disconnect(item, &QQuickPlatformMenuItem::hovered, this, &QQuickPlatformMenuItemGroup::hoverItem);
+ }
+
+ setCheckedItem(nullptr);
+
+ m_items.clear();
+ emit itemsChanged();
+}
+
+QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::findCurrent() const
+{
+ for (QQuickPlatformMenuItem *item : m_items) {
+ if (item->isChecked())
+ return item;
+ }
+ return nullptr;
+}
+
+void QQuickPlatformMenuItemGroup::updateCurrent()
+{
+ if (!m_exclusive)
+ return;
+
+ QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender());
+ if (item && item->isChecked())
+ setCheckedItem(item);
+}
+
+void QQuickPlatformMenuItemGroup::activateItem()
+{
+ QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender());
+ if (item)
+ emit triggered(item);
+}
+
+void QQuickPlatformMenuItemGroup::hoverItem()
+{
+ QQuickPlatformMenuItem *item = qobject_cast<QQuickPlatformMenuItem*>(sender());
+ if (item)
+ emit hovered(item);
+}
+
+void QQuickPlatformMenuItemGroup::items_append(QQmlListProperty<QQuickPlatformMenuItem> *prop, QQuickPlatformMenuItem *item)
+{
+ QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object);
+ group->addItem(item);
+}
+
+int QQuickPlatformMenuItemGroup::items_count(QQmlListProperty<QQuickPlatformMenuItem> *prop)
+{
+ QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object);
+ return group->m_items.count();
+}
+
+QQuickPlatformMenuItem *QQuickPlatformMenuItemGroup::items_at(QQmlListProperty<QQuickPlatformMenuItem> *prop, int index)
+{
+ QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object);
+ return group->m_items.value(index);
+}
+
+void QQuickPlatformMenuItemGroup::items_clear(QQmlListProperty<QQuickPlatformMenuItem> *prop)
+{
+ QQuickPlatformMenuItemGroup *group = static_cast<QQuickPlatformMenuItemGroup *>(prop->object);
+ group->clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenuitemgroup_p.h b/src/imports/platform/qquickplatformmenuitemgroup_p.h
new file mode 100644
index 00000000..f5797eff
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuitemgroup_p.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Templates module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMENUITEMGROUP_P_H
+#define QQUICKPLATFORMMENUITEMGROUP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qvector.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformMenuItem;
+class QQuickPlatformMenuItemGroupPrivate;
+
+class QQuickPlatformMenuItemGroup : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenuItem *checkedItem READ checkedItem WRITE setCheckedItem NOTIFY checkedItemChanged FINAL)
+ Q_PROPERTY(QQmlListProperty<QQuickPlatformMenuItem> items READ items NOTIFY itemsChanged FINAL)
+
+public:
+ explicit QQuickPlatformMenuItemGroup(QObject *parent = nullptr);
+ ~QQuickPlatformMenuItemGroup();
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
+ bool isExclusive() const;
+ void setExclusive(bool exclusive);
+
+ QQuickPlatformMenuItem *checkedItem() const;
+ void setCheckedItem(QQuickPlatformMenuItem *item);
+
+ QQmlListProperty<QQuickPlatformMenuItem> items();
+
+ Q_INVOKABLE void addItem(QQuickPlatformMenuItem *item);
+ Q_INVOKABLE void removeItem(QQuickPlatformMenuItem *item);
+ Q_INVOKABLE void clear();
+
+Q_SIGNALS:
+ void triggered(QQuickPlatformMenuItem *item);
+ void hovered(QQuickPlatformMenuItem *item);
+
+ void enabledChanged();
+ void visibleChanged();
+ void exclusiveChanged();
+ void checkedItemChanged();
+ void itemsChanged();
+
+private:
+ QQuickPlatformMenuItem *findCurrent() const;
+ void updateCurrent();
+ void activateItem();
+ void hoverItem();
+
+ static void items_append(QQmlListProperty<QQuickPlatformMenuItem> *prop, QQuickPlatformMenuItem *obj);
+ static int items_count(QQmlListProperty<QQuickPlatformMenuItem> *prop);
+ static QQuickPlatformMenuItem *items_at(QQmlListProperty<QQuickPlatformMenuItem> *prop, int index);
+ static void items_clear(QQmlListProperty<QQuickPlatformMenuItem> *prop);
+
+ bool m_enabled;
+ bool m_visible;
+ bool m_exclusive;
+ QQuickPlatformMenuItem *m_checkedItem;
+ QVector<QQuickPlatformMenuItem*> m_items;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenuItemGroup)
+
+#endif // QQUICKPLATFORMMENUITEMGROUP_P_H
diff --git a/src/imports/platform/qquickplatformmenuseparator.cpp b/src/imports/platform/qquickplatformmenuseparator.cpp
new file mode 100644
index 00000000..908ea075
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuseparator.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmenuseparator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuSeparator
+ \inherits MenuItem
+ \instantiates QQuickPlatformMenuSeparator
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native menu separator.
+
+ The MenuSeparator type is provided for convenience. It is a MenuItem
+ that has the \l {MenuItem::}{separator} property set to \c true by default.
+
+ \image qtlabsplatform-menubar.png
+
+ \labs
+
+ \sa Menu, MenuItem
+*/
+
+QQuickPlatformMenuSeparator::QQuickPlatformMenuSeparator(QObject *parent)
+ : QQuickPlatformMenuItem(parent)
+{
+ setSeparator(true);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmenuseparator_p.h b/src/imports/platform/qquickplatformmenuseparator_p.h
new file mode 100644
index 00000000..ce5ed391
--- /dev/null
+++ b/src/imports/platform/qquickplatformmenuseparator_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMENUSEPARATOR_P_H
+#define QQUICKPLATFORMMENUSEPARATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformmenuitem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformMenuSeparator : public QQuickPlatformMenuItem
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickPlatformMenuSeparator(QObject *parent = nullptr);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMenuSeparator)
+
+#endif // QQUICKPLATFORMMENUSEPARATOR_P_H
diff --git a/src/imports/platform/qquickplatformmessagedialog.cpp b/src/imports/platform/qquickplatformmessagedialog.cpp
new file mode 100644
index 00000000..20216e9b
--- /dev/null
+++ b/src/imports/platform/qquickplatformmessagedialog.cpp
@@ -0,0 +1,383 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformmessagedialog_p.h"
+
+#include <QtQml/qqmlinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MessageDialog
+ \inherits Dialog
+ \instantiates QQuickPlatformMessageDialog
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A native message dialog.
+
+ The MessageDialog type provides a QML API for native platform message dialogs.
+
+ \image qtlabsplatform-messagedialog-android.png
+
+ A message dialog is used to inform the user, or ask the user a question.
+ A message dialog displays a primary \l text to alert the user to a situation,
+ an \l {informativeText}{informative text} to further explain the alert or to
+ ask the user a question, and an optional \l {detailedText}{detailed text} to
+ provide even more data if the user requests it. A message box can also display
+ a configurable set of \l buttons for accepting a user response.
+
+ To show a message dialog, construct an instance of MessageDialog, set the
+ desired properties, and call \l {Dialog::}{open()}.
+
+ \code
+ MessageDialog {
+ buttons: MessageDialog.Ok
+ text: "The document has been modified."
+ }
+ \endcode
+
+ The user must click the \uicontrol OK button to dismiss the message dialog.
+ A modal message dialog blocks the rest of the GUI until the message is
+ dismissed.
+
+ A more elaborate approach than just alerting the user to an event is to
+ also ask the user what to do about it. Store the question in the
+ \l {informativeText}{informative text} property, and specify the \l buttons
+ property to the set of buttons you want as the set of user responses. The
+ buttons are specified by combining values using the bitwise OR operator. The
+ display order for the buttons is platform dependent.
+
+ \code
+ MessageDialog {
+ text: "The document has been modified."
+ informativeText: "Do you want to save your changes?"
+ buttons: MessageDialog.Ok | MessageDialog.Cancel
+
+ onAccepted: document.save()
+ }
+ \endcode
+
+ \image qtlabsplatform-messagedialog-informative-android.png
+
+ The \l clicked() signal passes the information of which button was clicked.
+
+ A native platform message dialog is currently available on the following platforms:
+
+ \list
+ \li iOS
+ \li Android
+ \li WinRT
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::clicked(button)
+
+ This signal is emitted when a dialog \a button is clicked.
+
+ \sa buttons
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::okClicked()
+
+ This signal is emitted when \uicontrol Ok is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::saveClicked()
+
+ This signal is emitted when \uicontrol Save is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::saveAllClicked()
+
+ This signal is emitted when \uicontrol {Save All} is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::openClicked()
+
+ This signal is emitted when \uicontrol Open is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::yesClicked()
+
+ This signal is emitted when \uicontrol Yes is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::yesToAllClicked()
+
+ This signal is emitted when \uicontrol {Yes To All} is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::noClicked()
+
+ This signal is emitted when \uicontrol No is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::noToAllClicked()
+
+ This signal is emitted when \uicontrol {No To All} is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::abortClicked()
+
+ This signal is emitted when \uicontrol Abort is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::retryClicked()
+
+ This signal is emitted when \uicontrol Retry is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::ignoreClicked()
+
+ This signal is emitted when \uicontrol Ignore is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::closeClicked()
+
+ This signal is emitted when \uicontrol Close is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::cancelClicked()
+
+ This signal is emitted when \uicontrol Cancel is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::discardClicked()
+
+ This signal is emitted when \uicontrol Discard is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::helpClicked()
+
+ This signal is emitted when \uicontrol Help is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::applyClicked()
+
+ This signal is emitted when \uicontrol Apply is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::resetClicked()
+
+ This signal is emitted when \uicontrol Reset is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::MessageDialog::restoreDefaultsClicked()
+
+ This signal is emitted when \uicontrol {Restore Defaults} is clicked.
+*/
+
+QQuickPlatformMessageDialog::QQuickPlatformMessageDialog(QObject *parent)
+ : QQuickPlatformDialog(QPlatformTheme::MessageDialog, parent),
+ m_options(QMessageDialogOptions::create())
+{
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::MessageDialog::text
+
+ This property holds the text to be displayed on the message dialog.
+
+ \sa informativeText, detailedText
+*/
+QString QQuickPlatformMessageDialog::text() const
+{
+ return m_options->text();
+}
+
+void QQuickPlatformMessageDialog::setText(const QString &text)
+{
+ if (m_options->text() == text)
+ return;
+
+ m_options->setText(text);
+ emit textChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::MessageDialog::informativeText
+
+ This property holds the informative text that provides a fuller description for the message.
+
+ Informative text can be used to expand upon the \l text to give more information to the user.
+
+ \sa text, detailedText
+*/
+QString QQuickPlatformMessageDialog::informativeText() const
+{
+ return m_options->informativeText();
+}
+
+void QQuickPlatformMessageDialog::setInformativeText(const QString &text)
+{
+ if (m_options->informativeText() == text)
+ return;
+
+ m_options->setInformativeText(text);
+ emit informativeTextChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::MessageDialog::detailedText
+
+ This property holds the text to be displayed in the details area.
+
+ \sa text, informativeText
+*/
+QString QQuickPlatformMessageDialog::detailedText() const
+{
+ return m_options->detailedText();
+}
+
+void QQuickPlatformMessageDialog::setDetailedText(const QString &text)
+{
+ if (m_options->detailedText() == text)
+ return;
+
+ m_options->setDetailedText(text);
+ emit detailedTextChanged();
+}
+
+/*!
+ \qmlproperty flags Qt.labs.platform::MessageDialog::buttons
+
+ This property holds a combination of buttons that are used by the message dialog.
+ The default value is \c MessageDialog.NoButton.
+
+ Possible flags:
+ \value MessageDialog.Ok An "OK" button defined with the \c AcceptRole.
+ \value MessageDialog.Open An "Open" button defined with the \c AcceptRole.
+ \value MessageDialog.Save A "Save" button defined with the \c AcceptRole.
+ \value MessageDialog.Cancel A "Cancel" button defined with the \c RejectRole.
+ \value MessageDialog.Close A "Close" button defined with the \c RejectRole.
+ \value MessageDialog.Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the \c DestructiveRole.
+ \value MessageDialog.Apply An "Apply" button defined with the \c ApplyRole.
+ \value MessageDialog.Reset A "Reset" button defined with the \c ResetRole.
+ \value MessageDialog.RestoreDefaults A "Restore Defaults" button defined with the \c ResetRole.
+ \value MessageDialog.Help A "Help" button defined with the \c HelpRole.
+ \value MessageDialog.SaveAll A "Save All" button defined with the \c AcceptRole.
+ \value MessageDialog.Yes A "Yes" button defined with the \c YesRole.
+ \value MessageDialog.YesToAll A "Yes to All" button defined with the \c YesRole.
+ \value MessageDialog.No A "No" button defined with the \c NoRole.
+ \value MessageDialog.NoToAll A "No to All" button defined with the \c NoRole.
+ \value MessageDialog.Abort An "Abort" button defined with the \c RejectRole.
+ \value MessageDialog.Retry A "Retry" button defined with the \c AcceptRole.
+ \value MessageDialog.Ignore An "Ignore" button defined with the \c AcceptRole.
+ \value MessageDialog.NoButton The dialog has no buttons.
+
+ \sa clicked()
+*/
+QPlatformDialogHelper::StandardButtons QQuickPlatformMessageDialog::buttons() const
+{
+ return m_options->standardButtons();
+}
+
+void QQuickPlatformMessageDialog::setButtons(QPlatformDialogHelper::StandardButtons buttons)
+{
+ if (m_options->standardButtons() == buttons)
+ return;
+
+ m_options->setStandardButtons(buttons);
+ emit buttonsChanged();
+}
+
+void QQuickPlatformMessageDialog::onCreate(QPlatformDialogHelper *dialog)
+{
+ if (QPlatformMessageDialogHelper *messageDialog = qobject_cast<QPlatformMessageDialogHelper *>(dialog)) {
+ connect(messageDialog, &QPlatformMessageDialogHelper::clicked, this, &QQuickPlatformMessageDialog::handleClick);
+ messageDialog->setOptions(m_options);
+ }
+}
+
+void QQuickPlatformMessageDialog::onShow(QPlatformDialogHelper *dialog)
+{
+ m_options->setWindowTitle(title());
+ if (QPlatformMessageDialogHelper *messageDialog = qobject_cast<QPlatformMessageDialogHelper *>(dialog))
+ messageDialog->setOptions(m_options);
+}
+
+void QQuickPlatformMessageDialog::handleClick(QPlatformDialogHelper::StandardButton button)
+{
+ done(button);
+ emit clicked(button);
+
+ switch (button) {
+ case QPlatformDialogHelper::Ok: emit okClicked(); break;
+ case QPlatformDialogHelper::Save: emit saveClicked(); break;
+ case QPlatformDialogHelper::SaveAll: emit saveAllClicked(); break;
+ case QPlatformDialogHelper::Open: emit openClicked(); break;
+ case QPlatformDialogHelper::Yes: emit yesClicked(); break;
+ case QPlatformDialogHelper::YesToAll: emit yesToAllClicked(); break;
+ case QPlatformDialogHelper::No: emit noClicked(); break;
+ case QPlatformDialogHelper::NoToAll: emit noToAllClicked(); break;
+ case QPlatformDialogHelper::Abort: emit abortClicked(); break;
+ case QPlatformDialogHelper::Retry: emit retryClicked(); break;
+ case QPlatformDialogHelper::Ignore: emit ignoreClicked(); break;
+ case QPlatformDialogHelper::Close: emit closeClicked(); break;
+ case QPlatformDialogHelper::Cancel: emit cancelClicked(); break;
+ case QPlatformDialogHelper::Discard: emit discardClicked(); break;
+ case QPlatformDialogHelper::Help: emit helpClicked(); break;
+ case QPlatformDialogHelper::Apply: emit applyClicked(); break;
+ case QPlatformDialogHelper::Reset: emit resetClicked(); break;
+ case QPlatformDialogHelper::RestoreDefaults: emit restoreDefaultsClicked(); break;
+ default: qmlInfo(this) << "unknown button" << button; break;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformmessagedialog_p.h b/src/imports/platform/qquickplatformmessagedialog_p.h
new file mode 100644
index 00000000..e8355932
--- /dev/null
+++ b/src/imports/platform/qquickplatformmessagedialog_p.h
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMMESSAGEDIALOG_P_H
+#define QQUICKPLATFORMMESSAGEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickplatformdialog_p.h"
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformMessageDialog : public QQuickPlatformDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
+ Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged FINAL)
+ Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged FINAL)
+ Q_PROPERTY(QPlatformDialogHelper::StandardButtons buttons READ buttons WRITE setButtons NOTIFY buttonsChanged FINAL)
+ Q_FLAGS(QPlatformDialogHelper::StandardButtons)
+
+public:
+ explicit QQuickPlatformMessageDialog(QObject *parent = nullptr);
+
+ QString text() const;
+ void setText(const QString &text);
+
+ QString informativeText() const;
+ void setInformativeText(const QString &text);
+
+ QString detailedText() const;
+ void setDetailedText(const QString &text);
+
+ QPlatformDialogHelper::StandardButtons buttons() const;
+ void setButtons(QPlatformDialogHelper::StandardButtons buttons);
+
+Q_SIGNALS:
+ void textChanged();
+ void informativeTextChanged();
+ void detailedTextChanged();
+ void buttonsChanged();
+ void clicked(QPlatformDialogHelper::StandardButton button);
+
+ void okClicked();
+ void saveClicked();
+ void saveAllClicked();
+ void openClicked();
+ void yesClicked();
+ void yesToAllClicked();
+ void noClicked();
+ void noToAllClicked();
+ void abortClicked();
+ void retryClicked();
+ void ignoreClicked();
+ void closeClicked();
+ void cancelClicked();
+ void discardClicked();
+ void helpClicked();
+ void applyClicked();
+ void resetClicked();
+ void restoreDefaultsClicked();
+
+protected:
+ void onCreate(QPlatformDialogHelper *dialog) override;
+ void onShow(QPlatformDialogHelper *dialog) override;
+
+private Q_SLOTS:
+ void handleClick(QPlatformDialogHelper::StandardButton button);
+
+private:
+ QSharedPointer<QMessageDialogOptions> m_options;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformMessageDialog)
+
+#endif // QQUICKPLATFORMMESSAGEDIALOG_P_H
diff --git a/src/imports/platform/qquickplatformstandardpaths.cpp b/src/imports/platform/qquickplatformstandardpaths.cpp
new file mode 100644
index 00000000..004d3c86
--- /dev/null
+++ b/src/imports/platform/qquickplatformstandardpaths.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformstandardpaths_p.h"
+
+#include <QtQml/qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype StandardPaths
+ \inherits QtObject
+ \instantiates QQuickPlatformStandardPaths
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief Provides access to the standard system paths.
+
+ The StandardPaths singleton type provides methods for querying the standard
+ system paths. The standard paths are mostly useful in conjunction with the
+ FileDialog and FolderDialog types.
+
+ \qml
+ FileDialog {
+ folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
+ }
+ \endqml
+
+ \labs
+
+ \sa FileDialog, FolderDialog, QStandardPaths
+*/
+
+static QList<QUrl> toUrlList(const QStringList &paths)
+{
+ QList<QUrl> urls;
+ urls.reserve(paths.size());
+ for (const QString &path : paths)
+ urls += QUrl::fromLocalFile(path);
+ return urls;
+}
+
+QQuickPlatformStandardPaths::QQuickPlatformStandardPaths(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QObject *QQuickPlatformStandardPaths::create(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(scriptEngine);
+ return new QQuickPlatformStandardPaths(engine);
+}
+
+/*!
+ \qmlmethod string Qt.labs.platform::StandardPaths::displayName(StandardLocation type)
+
+ \sa QStandardPaths::displayName()
+*/
+QString QQuickPlatformStandardPaths::displayName(QStandardPaths::StandardLocation type)
+{
+ return QStandardPaths::displayName(type);
+}
+
+/*!
+ \qmlmethod url Qt.labs.platform::StandardPaths::findExecutable(string executableName, list<string> paths)
+
+ \sa QStandardPaths::findExecutable()
+*/
+QUrl QQuickPlatformStandardPaths::findExecutable(const QString &executableName, const QStringList &paths)
+{
+ return QUrl::fromLocalFile(QStandardPaths::findExecutable(executableName, paths));
+}
+
+/*!
+ \qmlmethod url Qt.labs.platform::StandardPaths::locate(StandardLocation type, string fileName, LocateOptions options = LocateFile)
+
+ \sa QStandardPaths::locate()
+*/
+QUrl QQuickPlatformStandardPaths::locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
+{
+ return QUrl::fromLocalFile(QStandardPaths::locate(type, fileName, options));
+}
+
+/*!
+ \qmlmethod list<url> Qt.labs.platform::StandardPaths::locateAll(StandardLocation type, string fileName, LocateOptions options = LocateFile)
+
+ \sa QStandardPaths::locateAll()
+*/
+QList<QUrl> QQuickPlatformStandardPaths::locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
+{
+ return toUrlList(QStandardPaths::locateAll(type, fileName, options));
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::StandardPaths::setTestModeEnabled(bool testMode)
+
+ \sa QStandardPaths::setTestModeEnabled()
+*/
+void QQuickPlatformStandardPaths::setTestModeEnabled(bool testMode)
+{
+ QStandardPaths::setTestModeEnabled(testMode);
+}
+
+/*!
+ \qmlmethod list<url> Qt.labs.platform::StandardPaths::standardLocations(StandardLocation type)
+
+ \sa QStandardPaths::standardLocations()
+*/
+QList<QUrl> QQuickPlatformStandardPaths::standardLocations(QStandardPaths::StandardLocation type)
+{
+ return toUrlList(QStandardPaths::standardLocations(type));
+}
+
+/*!
+ \qmlmethod url Qt.labs.platform::StandardPaths::writableLocation(StandardLocation type)
+
+ \sa QStandardPaths::writableLocation()
+*/
+QUrl QQuickPlatformStandardPaths::writableLocation(QStandardPaths::StandardLocation type)
+{
+ return QUrl::fromLocalFile(QStandardPaths::writableLocation(type));
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformstandardpaths_p.h b/src/imports/platform/qquickplatformstandardpaths_p.h
new file mode 100644
index 00000000..b6504e70
--- /dev/null
+++ b/src/imports/platform/qquickplatformstandardpaths_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMSTANDARDPATHS_P_H
+#define QQUICKPLATFORMSTANDARDPATHS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstandardpaths.h>
+#include <QtCore/qurl.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlEngine;
+class QJSEngine;
+
+class QQuickPlatformStandardPaths : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(QStandardPaths::StandardLocation QStandardPaths::LocateOptions)
+
+public:
+ explicit QQuickPlatformStandardPaths(QObject *parent = nullptr);
+
+ static QObject *create(QQmlEngine *engine, QJSEngine *scriptEngine);
+
+ Q_INVOKABLE static QString displayName(QStandardPaths::StandardLocation type);
+ Q_INVOKABLE static QUrl findExecutable(const QString &executableName, const QStringList &paths = QStringList());
+ Q_INVOKABLE static QUrl locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
+ Q_INVOKABLE static QList<QUrl> locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options = QStandardPaths::LocateFile);
+ Q_INVOKABLE static void setTestModeEnabled(bool testMode);
+ Q_INVOKABLE static QList<QUrl> standardLocations(QStandardPaths::StandardLocation type);
+ Q_INVOKABLE static QUrl writableLocation(QStandardPaths::StandardLocation type);
+
+private:
+ Q_DISABLE_COPY(QQuickPlatformStandardPaths)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformStandardPaths)
+
+#endif // QQUICKPLATFORMSTANDARDPATHS_P_H
diff --git a/src/imports/platform/qquickplatformsystemtrayicon.cpp b/src/imports/platform/qquickplatformsystemtrayicon.cpp
new file mode 100644
index 00000000..70393c41
--- /dev/null
+++ b/src/imports/platform/qquickplatformsystemtrayicon.cpp
@@ -0,0 +1,441 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformsystemtrayicon_p.h"
+#include "qquickplatformmenu_p.h"
+#include "qquickplatformiconloader_p.h"
+
+#include <QtCore/qloggingcategory.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/private/qguiapplication_p.h>
+
+#include "widgets/qwidgetplatform_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype SystemTrayIcon
+ \inherits QtObject
+ \instantiates QQuickPlatformSystemTrayIcon
+ \inqmlmodule Qt.labs.platform
+ \since 5.8
+ \brief A system tray icon.
+
+ The SystemTrayIcon type provides an icon for an application in the system tray.
+
+ Many desktop platforms provide a special system tray or notification area,
+ where applications can display icons and notification messages.
+
+ \image qtlabsplatform-systemtrayicon.png
+
+ The following example shows how to create a system tray icon, and how to make
+ use of the \l activated() signal:
+
+ \code
+ SystemTrayIcon {
+ visible: true
+ iconSource: "qrc:/images/tray-icon.png"
+
+ onActivated: {
+ window.show()
+ window.raise()
+ window.requestActivate()
+ }
+ }
+ \endcode
+
+ \section2 Tray menu
+
+ SystemTrayIcon can have a menu that opens when the icon is activated.
+
+ \image qtlabsplatform-systemtrayicon-menu.png
+
+ The following example illustrates how to assign a \l Menu to a system tray icon:
+
+ \code
+ SystemTrayIcon {
+ visible: true
+ iconSource: "qrc:/images/tray-icon.png"
+
+ menu: Menu {
+ MenuItem {
+ text: qsTr("Quit")
+ onActivated: Qt.quit()
+ }
+ }
+ }
+ \endcode
+
+ \section2 Notification messages
+
+ SystemTrayIcon can display notification messages.
+
+ \image qtlabsplatform-systemtrayicon-message.png
+
+ The following example presents how to show a notification message using
+ \l showMessage(), and how to make use of the \l messageClicked() signal:
+
+ \code
+ SystemTrayIcon {
+ visible: true
+ iconSource: "qrc:/images/tray-icon.png"
+
+ onMessageClicked: console.log("Message clicked")
+ Component.onCompleted: showMessage("Message title", "Something important came up. Click this to know more.")
+ }
+ \endcode
+
+ \section2 Availability
+
+ A native system tray icon is currently \l available on the following platforms:
+
+ \list
+ \li All window managers and independent tray implementations for X11 that implement the
+ \l{http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html}
+ {freedesktop.org XEmbed system tray specification}.
+ \li All desktop environments that implement the
+ \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem}
+ {freedesktop.org D-Bus StatusNotifierItem specification}, including recent versions of KDE and Unity.
+ \li All supported versions of macOS. Note that the Growl notification system must be installed
+ for showMessage() to display messages on OS X prior to 10.8 (Mountain Lion).
+ \endlist
+
+ \input includes/widgets.qdocinc 1
+
+ \labs
+
+ \sa Menu
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::SystemTrayIcon::activated(ActivationReason reason)
+
+ This signal is emitted when the system tray icon is activated by the user. The
+ \a reason argument specifies how the system tray icon was activated.
+
+ Available reasons:
+
+ \value SystemTrayIcon.Unknown Unknown reason
+ \value SystemTrayIcon.Context The context menu for the system tray icon was requested
+ \value SystemTrayIcon.DoubleClick The system tray icon was double clicked
+ \value SystemTrayIcon.Trigger The system tray icon was clicked
+ \value SystemTrayIcon.MiddleClick The system tray icon was clicked with the middle mouse button
+*/
+
+/*!
+ \qmlsignal Qt.labs.platform::SystemTrayIcon::messageClicked()
+
+ This signal is emitted when a notification message is clicked by the user.
+
+ \sa showMessage()
+*/
+
+Q_DECLARE_LOGGING_CATEGORY(qtLabsPlatformTray)
+
+QQuickPlatformSystemTrayIcon::QQuickPlatformSystemTrayIcon(QObject *parent)
+ : QObject(parent),
+ m_complete(false),
+ m_visible(false),
+ m_menu(nullptr),
+ m_iconLoader(nullptr),
+ m_handle(nullptr)
+{
+ m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon();
+ if (!m_handle)
+ m_handle = QWidgetPlatform::createSystemTrayIcon(this);
+ qCDebug(qtLabsPlatformTray) << "SystemTrayIcon ->" << m_handle;
+
+ if (m_handle) {
+ connect(m_handle, &QPlatformSystemTrayIcon::activated, this, &QQuickPlatformSystemTrayIcon::activated);
+ connect(m_handle, &QPlatformSystemTrayIcon::messageClicked, this, &QQuickPlatformSystemTrayIcon::messageClicked);
+ }
+}
+
+QQuickPlatformSystemTrayIcon::~QQuickPlatformSystemTrayIcon()
+{
+ if (m_menu)
+ m_menu->setSystemTrayIcon(nullptr);
+ cleanup();
+ delete m_iconLoader;
+ m_iconLoader = nullptr;
+ delete m_handle;
+ m_handle = nullptr;
+}
+
+QPlatformSystemTrayIcon *QQuickPlatformSystemTrayIcon::handle() const
+{
+ return m_handle;
+}
+
+/*!
+ \readonly
+ \qmlproperty bool Qt.labs.platform::SystemTrayIcon::available
+
+ This property holds whether the system tray is available.
+*/
+bool QQuickPlatformSystemTrayIcon::isAvailable() const
+{
+ return m_handle && m_handle->isSystemTrayAvailable();
+}
+
+/*!
+ \readonly
+ \qmlproperty bool Qt.labs.platform::SystemTrayIcon::supportsMessages
+
+ This property holds whether the system tray icon supports notification messages.
+
+ \sa showMessage()
+*/
+bool QQuickPlatformSystemTrayIcon::supportsMessages() const
+{
+ return m_handle && m_handle->supportsMessages();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.platform::SystemTrayIcon::visible
+
+ This property holds whether the system tray icon is visible.
+
+ The default value is \c false.
+*/
+bool QQuickPlatformSystemTrayIcon::isVisible() const
+{
+ return m_visible;
+}
+
+void QQuickPlatformSystemTrayIcon::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ if (m_handle && m_complete) {
+ if (visible)
+ init();
+ else
+ cleanup();
+ }
+
+ m_visible = visible;
+ emit visibleChanged();
+}
+
+/*!
+ \qmlproperty url Qt.labs.platform::SystemTrayIcon::iconSource
+
+ This property holds the url of the system tray icon.
+
+ \sa iconName
+*/
+QUrl QQuickPlatformSystemTrayIcon::iconSource() const
+{
+ if (!m_iconLoader)
+ return QUrl();
+
+ return m_iconLoader->iconSource();
+}
+
+void QQuickPlatformSystemTrayIcon::setIconSource(const QUrl& source)
+{
+ if (source == iconSource())
+ return;
+
+ iconLoader()->setIconSource(source);
+ emit iconSourceChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::SystemTrayIcon::iconName
+
+ This property holds the theme name of the system tray icon.
+
+ \sa iconSource, QIcon::fromTheme()
+*/
+QString QQuickPlatformSystemTrayIcon::iconName() const
+{
+ if (!m_iconLoader)
+ return QString();
+
+ return m_iconLoader->iconName();
+}
+
+void QQuickPlatformSystemTrayIcon::setIconName(const QString& name)
+{
+ if (name == iconName())
+ return;
+
+ iconLoader()->setIconName(name);
+ emit iconNameChanged();
+}
+
+/*!
+ \qmlproperty string Qt.labs.platform::SystemTrayIcon::tooltip
+
+ This property holds the tooltip of the system tray icon.
+*/
+QString QQuickPlatformSystemTrayIcon::tooltip() const
+{
+ return m_tooltip;
+}
+
+void QQuickPlatformSystemTrayIcon::setTooltip(const QString &tooltip)
+{
+ if (m_tooltip == tooltip)
+ return;
+
+ if (m_handle && m_complete)
+ m_handle->updateToolTip(tooltip);
+
+ m_tooltip = tooltip;
+ emit tooltipChanged();
+}
+
+/*!
+ \qmlproperty Menu Qt.labs.platform::SystemTrayIcon::menu
+
+ This property holds a menu for the system tray icon.
+*/
+QQuickPlatformMenu *QQuickPlatformSystemTrayIcon::menu() const
+{
+ return m_menu;
+}
+
+void QQuickPlatformSystemTrayIcon::setMenu(QQuickPlatformMenu *menu)
+{
+ if (m_menu == menu)
+ return;
+
+ if (m_menu)
+ m_menu->setSystemTrayIcon(nullptr);
+ if (menu) {
+ menu->setSystemTrayIcon(this);
+ if (m_handle && m_complete && menu->create())
+ m_handle->updateMenu(menu->handle());
+ }
+
+ m_menu = menu;
+ emit menuChanged();
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::SystemTrayIcon::show()
+
+ Shows the system tray icon.
+*/
+void QQuickPlatformSystemTrayIcon::show()
+{
+ setVisible(true);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::SystemTrayIcon::hide()
+
+ Hides the system tray icon.
+*/
+void QQuickPlatformSystemTrayIcon::hide()
+{
+ setVisible(false);
+}
+
+/*!
+ \qmlmethod void Qt.labs.platform::SystemTrayIcon::showMessage(string title, string message, MessageIcon icon, int msecs)
+
+ Shows a system tray message with the given \a title, \a message and \a icon
+ for the time specified in \a msecs.
+
+ \note System tray messages are dependent on the system configuration and user preferences,
+ and may not appear at all. Therefore, it should not be relied upon as the sole means for providing
+ critical information.
+
+ \sa supportsMessages, messageClicked()
+*/
+void QQuickPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, QPlatformSystemTrayIcon::MessageIcon icon, int msecs)
+{
+ if (m_handle)
+ m_handle->showMessage(title, msg, QIcon(), icon, msecs);
+}
+
+void QQuickPlatformSystemTrayIcon::init()
+{
+ if (!m_handle)
+ return;
+
+ m_handle->init();
+ if (m_menu && m_menu->create())
+ m_handle->updateMenu(m_menu->handle());
+ m_handle->updateToolTip(m_tooltip);
+ if (m_iconLoader)
+ m_iconLoader->setEnabled(true);
+}
+
+void QQuickPlatformSystemTrayIcon::cleanup()
+{
+ if (m_handle)
+ m_handle->cleanup();
+ if (m_iconLoader)
+ m_iconLoader->setEnabled(false);
+}
+
+void QQuickPlatformSystemTrayIcon::classBegin()
+{
+}
+
+void QQuickPlatformSystemTrayIcon::componentComplete()
+{
+ m_complete = true;
+ if (m_visible)
+ init();
+}
+
+QQuickPlatformIconLoader *QQuickPlatformSystemTrayIcon::iconLoader() const
+{
+ if (!m_iconLoader) {
+ QQuickPlatformSystemTrayIcon *that = const_cast<QQuickPlatformSystemTrayIcon *>(this);
+ static int slot = staticMetaObject.indexOfSlot("updateIcon()");
+ m_iconLoader = new QQuickPlatformIconLoader(slot, that);
+ m_iconLoader->setEnabled(m_complete);
+ }
+ return m_iconLoader;
+}
+
+void QQuickPlatformSystemTrayIcon::updateIcon()
+{
+ if (!m_handle || !m_iconLoader)
+ return;
+
+ m_handle->updateIcon(m_iconLoader->icon());
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformsystemtrayicon_p.h b/src/imports/platform/qquickplatformsystemtrayicon_p.h
new file mode 100644
index 00000000..12597c72
--- /dev/null
+++ b/src/imports/platform/qquickplatformsystemtrayicon_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMSYSTEMTRAYICON_P_H
+#define QQUICKPLATFORMSYSTEMTRAYICON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qurl.h>
+#include <QtGui/qpa/qplatformsystemtrayicon.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformMenu;
+class QQuickPlatformIconLoader;
+
+class QQuickPlatformSystemTrayIcon : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+ Q_PROPERTY(bool available READ isAvailable CONSTANT FINAL)
+ Q_PROPERTY(bool supportsMessages READ supportsMessages CONSTANT FINAL)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged FINAL)
+ Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged FINAL)
+ Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged FINAL)
+ Q_PROPERTY(QQuickPlatformMenu *menu READ menu WRITE setMenu NOTIFY menuChanged FINAL)
+ Q_ENUMS(QPlatformSystemTrayIcon::ActivationReason QPlatformSystemTrayIcon::MessageIcon)
+
+public:
+ explicit QQuickPlatformSystemTrayIcon(QObject *parent = nullptr);
+ ~QQuickPlatformSystemTrayIcon();
+
+ QPlatformSystemTrayIcon *handle() const;
+
+ bool isAvailable() const;
+ bool supportsMessages() const;
+
+ bool isVisible() const;
+ void setVisible(bool visible);
+
+ QUrl iconSource() const;
+ void setIconSource(const QUrl &source);
+
+ QString iconName() const;
+ void setIconName(const QString &name);
+
+ QString tooltip() const;
+ void setTooltip(const QString &tooltip);
+
+ QQuickPlatformMenu *menu() const;
+ void setMenu(QQuickPlatformMenu *menu);
+
+public Q_SLOTS:
+ void show();
+ void hide();
+
+ void showMessage(const QString &title, const QString &message,
+ QPlatformSystemTrayIcon::MessageIcon iconType = QPlatformSystemTrayIcon::Information, int msecs = 10000);
+
+Q_SIGNALS:
+ void activated(QPlatformSystemTrayIcon::ActivationReason reason);
+ void messageClicked();
+ void visibleChanged();
+ void iconSourceChanged();
+ void iconNameChanged();
+ void tooltipChanged();
+ void menuChanged();
+
+protected:
+ void init();
+ void cleanup();
+
+ void classBegin() override;
+ void componentComplete() override;
+
+ QQuickPlatformIconLoader *iconLoader() const;
+
+private Q_SLOTS:
+ void updateIcon();
+
+private:
+ bool m_complete;
+ bool m_visible;
+ QString m_tooltip;
+ QQuickPlatformMenu *m_menu;
+ mutable QQuickPlatformIconLoader *m_iconLoader;
+ QPlatformSystemTrayIcon *m_handle;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformSystemTrayIcon)
+
+#endif // QQUICKPLATFORMSYSTEMTRAYICON_P_H
diff --git a/src/imports/platform/qtlabsplatformplugin.cpp b/src/imports/platform/qtlabsplatformplugin.cpp
new file mode 100644
index 00000000..f73b04e8
--- /dev/null
+++ b/src/imports/platform/qtlabsplatformplugin.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Templates module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QtCore/qloggingcategory.h>
+
+#include "qquickplatformdialog_p.h"
+#include "qquickplatformcolordialog_p.h"
+#include "qquickplatformfiledialog_p.h"
+#include "qquickplatformfolderdialog_p.h"
+#include "qquickplatformfontdialog_p.h"
+#include "qquickplatformmessagedialog_p.h"
+
+#include "qquickplatformmenu_p.h"
+#include "qquickplatformmenubar_p.h"
+#include "qquickplatformmenuitem_p.h"
+#include "qquickplatformmenuitemgroup_p.h"
+#include "qquickplatformmenuseparator_p.h"
+
+#include "qquickplatformstandardpaths_p.h"
+
+#include "qquickplatformsystemtrayicon_p.h"
+
+Q_DECLARE_METATYPE(QStandardPaths::StandardLocation)
+Q_DECLARE_METATYPE(QStandardPaths::LocateOptions)
+
+static inline void initResources()
+{
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_platform);
+#endif
+}
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(qtLabsPlatformDialogs, "qt.labs.platform.dialogs")
+Q_LOGGING_CATEGORY(qtLabsPlatformMenus, "qt.labs.platform.menus")
+Q_LOGGING_CATEGORY(qtLabsPlatformTray, "qt.labs.platform.tray")
+
+class QtLabsPlatformPlugin: public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
+
+public:
+ QtLabsPlatformPlugin(QObject *parent = nullptr);
+ void registerTypes(const char *uri) override;
+};
+
+QtLabsPlatformPlugin::QtLabsPlatformPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
+void QtLabsPlatformPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterUncreatableType<QQuickPlatformDialog>(uri, 1, 0, "Dialog", QQuickPlatformDialog::tr("Dialog is an abstract base class"));
+ qmlRegisterType<QQuickPlatformColorDialog>(uri, 1, 0, "ColorDialog");
+ qmlRegisterType<QQuickPlatformFileDialog>(uri, 1, 0, "FileDialog");
+ qmlRegisterType<QQuickPlatformFileNameFilter>();
+ qmlRegisterType<QQuickPlatformFolderDialog>(uri, 1, 0, "FolderDialog");
+ qmlRegisterType<QQuickPlatformFontDialog>(uri, 1, 0, "FontDialog");
+ qmlRegisterType<QQuickPlatformMessageDialog>(uri, 1, 0, "MessageDialog");
+
+ qmlRegisterType<QQuickPlatformMenu>(uri, 1, 0, "Menu");
+ qmlRegisterType<QQuickPlatformMenuBar>(uri, 1, 0, "MenuBar");
+ qmlRegisterType<QQuickPlatformMenuItem>(uri, 1, 0, "MenuItem");
+ qmlRegisterType<QQuickPlatformMenuItemGroup>(uri, 1, 0, "MenuItemGroup");
+ qmlRegisterType<QQuickPlatformMenuSeparator>(uri, 1, 0, "MenuSeparator");
+
+ qmlRegisterUncreatableType<QPlatformDialogHelper>(uri, 1, 0, "StandardButton", QQuickPlatformDialog::tr("Cannot create an instance of StandardButton"));
+ qmlRegisterSingletonType<QQuickPlatformStandardPaths>(uri, 1, 0, "StandardPaths", QQuickPlatformStandardPaths::create);
+ qRegisterMetaType<QStandardPaths::StandardLocation>();
+ qRegisterMetaType<QStandardPaths::LocateOptions>();
+
+ qmlRegisterType<QQuickPlatformSystemTrayIcon>(uri, 1, 0, "SystemTrayIcon");
+}
+
+QT_END_NAMESPACE
+
+#include "qtlabsplatformplugin.moc"
diff --git a/src/imports/platform/widgets/qwidgetplatform_p.h b/src/imports/platform/widgets/qwidgetplatform_p.h
new file mode 100644
index 00000000..06dcc9d3
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatform_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORM_P_H
+#define QWIDGETPLATFORM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+#include <QtGui/qpa/qplatformsystemtrayicon.h>
+#include <QtGui/qpa/qplatformmenu.h>
+
+#ifdef QT_WIDGETS_LIB
+#include "qwidgetplatformcolordialog_p.h"
+#include "qwidgetplatformfiledialog_p.h"
+#include "qwidgetplatformfontdialog_p.h"
+#include "qwidgetplatformmessagedialog_p.h"
+#include "qwidgetplatformmenu_p.h"
+#include "qwidgetplatformmenuitem_p.h"
+#include "qwidgetplatformsystemtrayicon_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_WIDGETS_LIB
+typedef QPlatformMenu QWidgetPlatformMenu;
+typedef QPlatformMenuItem QWidgetPlatformMenuItem;
+typedef QPlatformColorDialogHelper QWidgetPlatformColorDialog;
+typedef QPlatformFileDialogHelper QWidgetPlatformFileDialog;
+typedef QPlatformFontDialogHelper QWidgetPlatformFontDialog;
+typedef QPlatformMessageDialogHelper QWidgetPlatformMessageDialog;
+typedef QPlatformSystemTrayIcon QWidgetPlatformSystemTrayIcon;
+#endif
+
+namespace QWidgetPlatform
+{
+ static inline bool isAvailable(const char *type)
+ {
+ if (!qApp->inherits("QApplication")) {
+ qCritical("\nERROR: No native %s implementation available."
+ "\nQt Labs Platform requires Qt Widgets on this setup."
+ "\nAdd 'QT += widgets' to .pro and create QApplication in main().\n", type);
+ return false;
+ }
+ return true;
+ }
+
+ template<typename T>
+ static inline T *createWidget(const char *name, QObject *parent)
+ {
+ static bool available = isAvailable(name);
+#ifdef QT_WIDGETS_LIB
+ if (available)
+ return new T(parent);
+#else
+ Q_UNUSED(parent)
+ Q_UNUSED(available)
+#endif
+ return nullptr;
+ }
+
+ static inline QPlatformMenu *createMenu(QObject *parent = nullptr) { return createWidget<QWidgetPlatformMenu>("Menu", parent); }
+ static inline QPlatformMenuItem *createMenuItem(QObject *parent = nullptr) { return createWidget<QWidgetPlatformMenuItem>("MenuItem", parent); }
+ static inline QPlatformSystemTrayIcon *createSystemTrayIcon(QObject *parent = nullptr) { return createWidget<QWidgetPlatformSystemTrayIcon>("SystemTrayIcon", parent); }
+ static inline QPlatformDialogHelper *createDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr)
+ {
+ switch (type) {
+ case QPlatformTheme::ColorDialog: return createWidget<QWidgetPlatformColorDialog>("ColorDialog", parent);
+ case QPlatformTheme::FileDialog: return createWidget<QWidgetPlatformFileDialog>("FileDialog", parent);
+ case QPlatformTheme::FontDialog: return createWidget<QWidgetPlatformFontDialog>("FontDialog", parent);
+ case QPlatformTheme::MessageDialog: return createWidget<QWidgetPlatformMessageDialog>("MessageDialog", parent);
+ default: Q_UNREACHABLE(); break;
+ return nullptr;
+ }
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORM_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformcolordialog.cpp b/src/imports/platform/widgets/qwidgetplatformcolordialog.cpp
new file mode 100644
index 00000000..69a76eb2
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformcolordialog.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformcolordialog_p.h"
+#include "qwidgetplatformdialog_p.h"
+
+#include <QtWidgets/qcolordialog.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformColorDialog::QWidgetPlatformColorDialog(QObject *parent)
+ : m_dialog(new QColorDialog)
+{
+ setParent(parent);
+
+ connect(m_dialog.data(), &QColorDialog::accepted, this, &QPlatformDialogHelper::accept);
+ connect(m_dialog.data(), &QColorDialog::rejected, this, &QPlatformDialogHelper::reject);
+ connect(m_dialog.data(), &QColorDialog::currentColorChanged, this, &QPlatformColorDialogHelper::currentColorChanged);
+}
+
+QWidgetPlatformColorDialog::~QWidgetPlatformColorDialog()
+{
+}
+
+QColor QWidgetPlatformColorDialog::currentColor() const
+{
+ return m_dialog->currentColor();
+}
+
+void QWidgetPlatformColorDialog::setCurrentColor(const QColor &color)
+{
+ m_dialog->setCurrentColor(color);
+}
+
+void QWidgetPlatformColorDialog::exec()
+{
+ m_dialog->exec();
+}
+
+bool QWidgetPlatformColorDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ QSharedPointer<QColorDialogOptions> options = QPlatformColorDialogHelper::options();
+ m_dialog->setWindowTitle(options->windowTitle());
+ m_dialog->setOptions(static_cast<QColorDialog::ColorDialogOptions>(int(options->options())) | QColorDialog::DontUseNativeDialog);
+
+ return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent);
+}
+
+void QWidgetPlatformColorDialog::hide()
+{
+ m_dialog->hide();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformcolordialog_p.h b/src/imports/platform/widgets/qwidgetplatformcolordialog_p.h
new file mode 100644
index 00000000..14bbcd1f
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformcolordialog_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMCOLORDIALOG_P_H
+#define QWIDGETPLATFORMCOLORDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QColorDialog;
+
+class QWidgetPlatformColorDialog : public QPlatformColorDialogHelper
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformColorDialog(QObject *parent = nullptr);
+ ~QWidgetPlatformColorDialog();
+
+ QColor currentColor() const override;
+ void setCurrentColor(const QColor &color) override;
+
+ void exec() override;
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override;
+ void hide() override;
+
+private:
+ QScopedPointer<QColorDialog> m_dialog;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMCOLORDIALOG_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformdialog.cpp b/src/imports/platform/widgets/qwidgetplatformdialog.cpp
new file mode 100644
index 00000000..ebca7ea8
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformdialog.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformdialog_p.h"
+
+#include <QtGui/qwindow.h>
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QWidgetPlatformDialog::show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ dialog->setWindowFlags(flags);
+ dialog->setWindowModality(modality);
+
+ dialog->createWinId();
+ QWindow *handle = dialog->windowHandle();
+ Q_ASSERT(handle);
+ handle->setTransientParent(const_cast<QWindow *>(parent));
+
+ dialog->show();
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformdialog_p.h b/src/imports/platform/widgets/qwidgetplatformdialog_p.h
new file mode 100644
index 00000000..efc99b85
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformdialog_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMDIALOG_P_H
+#define QWIDGETPLATFORMDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDialog;
+class QWindow;
+
+class QWidgetPlatformDialog
+{
+public:
+ static bool show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMDIALOG_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformfiledialog.cpp b/src/imports/platform/widgets/qwidgetplatformfiledialog.cpp
new file mode 100644
index 00000000..772443a5
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformfiledialog.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformfiledialog_p.h"
+#include "qwidgetplatformdialog_p.h"
+
+#include <QtWidgets/qfiledialog.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformFileDialog::QWidgetPlatformFileDialog(QObject *parent)
+ : m_dialog(new QFileDialog)
+{
+ setParent(parent);
+
+ connect(m_dialog.data(), &QDialog::accepted, this, &QPlatformDialogHelper::accept);
+ connect(m_dialog.data(), &QDialog::rejected, this, &QPlatformDialogHelper::reject);
+
+ connect(m_dialog.data(), &QFileDialog::fileSelected, [this](const QString &file) {
+ emit fileSelected(QUrl::fromLocalFile(file));
+ });
+ connect(m_dialog.data(), &QFileDialog::filesSelected, [this](const QList<QString> &files) {
+ QList<QUrl> urls;
+ urls.reserve(files.count());
+ for (const QString &file : files)
+ urls += QUrl::fromLocalFile(file);
+ emit filesSelected(urls);
+ });
+ connect(m_dialog.data(), &QFileDialog::currentChanged, [this](const QString &path) {
+ emit currentChanged(QUrl::fromLocalFile(path));
+ });
+ connect(m_dialog.data(), &QFileDialog::directoryEntered, this, &QWidgetPlatformFileDialog::directoryEntered);
+ connect(m_dialog.data(), &QFileDialog::filterSelected, this, &QWidgetPlatformFileDialog::filterSelected);
+}
+
+QWidgetPlatformFileDialog::~QWidgetPlatformFileDialog()
+{
+}
+
+bool QWidgetPlatformFileDialog::defaultNameFilterDisables() const
+{
+ return false; // TODO: ?
+}
+
+void QWidgetPlatformFileDialog::setDirectory(const QUrl &directory)
+{
+ m_dialog->setDirectory(directory.toLocalFile());
+}
+
+QUrl QWidgetPlatformFileDialog::directory() const
+{
+ return m_dialog->directoryUrl();
+}
+
+void QWidgetPlatformFileDialog::selectFile(const QUrl &filename)
+{
+ m_dialog->selectUrl(filename);
+}
+
+QList<QUrl> QWidgetPlatformFileDialog::selectedFiles() const
+{
+ return m_dialog->selectedUrls();
+}
+
+void QWidgetPlatformFileDialog::setFilter()
+{
+ // TODO: ?
+}
+
+void QWidgetPlatformFileDialog::selectNameFilter(const QString &filter)
+{
+ m_dialog->selectNameFilter(filter);
+}
+
+QString QWidgetPlatformFileDialog::selectedNameFilter() const
+{
+ return m_dialog->selectedNameFilter();
+}
+
+void QWidgetPlatformFileDialog::exec()
+{
+ m_dialog->exec();
+}
+
+bool QWidgetPlatformFileDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ QSharedPointer<QFileDialogOptions> options = QPlatformFileDialogHelper::options();
+ m_dialog->setWindowTitle(options->windowTitle());
+ m_dialog->setAcceptMode(static_cast<QFileDialog::AcceptMode>(options->acceptMode()));
+ m_dialog->setFileMode(static_cast<QFileDialog::FileMode>(options->fileMode()));
+ m_dialog->setOptions(static_cast<QFileDialog::Options>(int(options->options())) | QFileDialog::DontUseNativeDialog);
+ m_dialog->setNameFilters(options->nameFilters());
+ m_dialog->setDefaultSuffix(options->defaultSuffix());
+ if (options->isLabelExplicitlySet(QFileDialogOptions::Accept))
+ m_dialog->setLabelText(QFileDialog::Accept, options->labelText(QFileDialogOptions::Accept));
+ if (options->isLabelExplicitlySet(QFileDialogOptions::Reject))
+ m_dialog->setLabelText(QFileDialog::Reject, options->labelText(QFileDialogOptions::Reject));
+
+ return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent);
+}
+
+void QWidgetPlatformFileDialog::hide()
+{
+ m_dialog->hide();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformfiledialog_p.h b/src/imports/platform/widgets/qwidgetplatformfiledialog_p.h
new file mode 100644
index 00000000..743bc571
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformfiledialog_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMFILEDIALOG_P_H
+#define QWIDGETPLATFORMFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QFileDialog;
+
+class QWidgetPlatformFileDialog : public QPlatformFileDialogHelper
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformFileDialog(QObject *parent = nullptr);
+ ~QWidgetPlatformFileDialog();
+
+ bool defaultNameFilterDisables() const override;
+ void setDirectory(const QUrl &directory) override;
+ QUrl directory() const override;
+ void selectFile(const QUrl &filename) override;
+ QList<QUrl> selectedFiles() const override;
+ void setFilter() override;
+ void selectNameFilter(const QString &filter) override;
+ QString selectedNameFilter() const override;
+
+ void exec() override;
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override;
+ void hide() override;
+
+private:
+ QScopedPointer<QFileDialog> m_dialog;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMFILEDIALOG_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformfontdialog.cpp b/src/imports/platform/widgets/qwidgetplatformfontdialog.cpp
new file mode 100644
index 00000000..d2b6c539
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformfontdialog.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformfontdialog_p.h"
+#include "qwidgetplatformdialog_p.h"
+
+#include <QtWidgets/qfontdialog.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformFontDialog::QWidgetPlatformFontDialog(QObject *parent)
+ : m_dialog(new QFontDialog)
+{
+ setParent(parent);
+
+ connect(m_dialog.data(), &QFontDialog::accepted, this, &QPlatformDialogHelper::accept);
+ connect(m_dialog.data(), &QFontDialog::rejected, this, &QPlatformDialogHelper::reject);
+ connect(m_dialog.data(), &QFontDialog::currentFontChanged, this, &QPlatformFontDialogHelper::currentFontChanged);
+}
+
+QWidgetPlatformFontDialog::~QWidgetPlatformFontDialog()
+{
+}
+
+QFont QWidgetPlatformFontDialog::currentFont() const
+{
+ return m_dialog->currentFont();
+}
+
+void QWidgetPlatformFontDialog::setCurrentFont(const QFont &font)
+{
+ m_dialog->setCurrentFont(font);
+}
+
+void QWidgetPlatformFontDialog::exec()
+{
+ m_dialog->exec();
+}
+
+bool QWidgetPlatformFontDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ QSharedPointer<QFontDialogOptions> options = QPlatformFontDialogHelper::options();
+ m_dialog->setWindowTitle(options->windowTitle());
+ m_dialog->setOptions(static_cast<QFontDialog::FontDialogOptions>(int(options->options())) | QFontDialog::DontUseNativeDialog);
+
+ return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent);
+}
+
+void QWidgetPlatformFontDialog::hide()
+{
+ m_dialog->hide();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformfontdialog_p.h b/src/imports/platform/widgets/qwidgetplatformfontdialog_p.h
new file mode 100644
index 00000000..97d5463d
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformfontdialog_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMFONTDIALOG_P_H
+#define QWIDGETPLATFORMFONTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QFontDialog;
+
+class QWidgetPlatformFontDialog : public QPlatformFontDialogHelper
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformFontDialog(QObject *parent = nullptr);
+ ~QWidgetPlatformFontDialog();
+
+ QFont currentFont() const override;
+ void setCurrentFont(const QFont &font) override;
+
+ void exec() override;
+ bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override;
+ void hide() override;
+
+private:
+ QScopedPointer<QFontDialog> m_dialog;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMFONTDIALOG_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/src/imports/platform/widgets/qwidgetplatformmenu.cpp
new file mode 100644
index 00000000..d9ecb16f
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmenu.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformmenu_p.h"
+#include "qwidgetplatformmenuitem_p.h"
+
+#include <QtGui/qwindow.h>
+#include <QtWidgets/qmenu.h>
+#include <QtWidgets/qaction.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformMenu::QWidgetPlatformMenu(QObject *parent)
+ : m_menu(new QMenu)
+{
+ setParent(parent);
+
+ connect(m_menu.data(), &QMenu::aboutToShow, this, &QPlatformMenu::aboutToShow);
+ connect(m_menu.data(), &QMenu::aboutToHide, this, &QPlatformMenu::aboutToHide);
+}
+
+QWidgetPlatformMenu::~QWidgetPlatformMenu()
+{
+}
+
+QMenu *QWidgetPlatformMenu::menu() const
+{
+ return m_menu.data();
+}
+
+void QWidgetPlatformMenu::insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before)
+{
+ QWidgetPlatformMenuItem *widgetItem = qobject_cast<QWidgetPlatformMenuItem *>(item);
+ if (!widgetItem)
+ return;
+
+ QWidgetPlatformMenuItem *widgetBefore = qobject_cast<QWidgetPlatformMenuItem *>(before);
+ m_menu->insertAction(widgetBefore ? widgetBefore->action() : nullptr, widgetItem->action());
+}
+
+void QWidgetPlatformMenu::removeMenuItem(QPlatformMenuItem *item)
+{
+ QWidgetPlatformMenuItem *widgetItem = qobject_cast<QWidgetPlatformMenuItem *>(item);
+ if (!widgetItem)
+ return;
+
+ m_menu->removeAction(widgetItem->action());
+}
+
+void QWidgetPlatformMenu::syncMenuItem(QPlatformMenuItem *item)
+{
+ Q_UNUSED(item);
+}
+
+void QWidgetPlatformMenu::syncSeparatorsCollapsible(bool enable)
+{
+ Q_UNUSED(enable);
+}
+
+quintptr QWidgetPlatformMenu::tag() const
+{
+ return 0;
+}
+
+void QWidgetPlatformMenu::setTag(quintptr tag)
+{
+ Q_UNUSED(tag);
+}
+
+void QWidgetPlatformMenu::setText(const QString &text)
+{
+ m_menu->setTitle(text);
+}
+
+void QWidgetPlatformMenu::setIcon(const QIcon &icon)
+{
+ m_menu->setIcon(icon);
+}
+
+void QWidgetPlatformMenu::setEnabled(bool enabled)
+{
+ m_menu->menuAction()->setEnabled(enabled);
+}
+
+bool QWidgetPlatformMenu::isEnabled() const
+{
+ return m_menu->menuAction()->isEnabled();
+}
+
+void QWidgetPlatformMenu::setVisible(bool visible)
+{
+ m_menu->menuAction()->setVisible(visible);
+}
+
+void QWidgetPlatformMenu::setMinimumWidth(int width)
+{
+ if (width > 0)
+ m_menu->setMinimumWidth(width);
+}
+
+void QWidgetPlatformMenu::setFont(const QFont &font)
+{
+ m_menu->setFont(font);
+}
+
+void QWidgetPlatformMenu::setMenuType(MenuType type)
+{
+ Q_UNUSED(type);
+}
+
+void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item)
+{
+ m_menu->createWinId();
+ QWindow *handle = m_menu->windowHandle();
+ Q_ASSERT(handle);
+ handle->setTransientParent(const_cast<QWindow *>(window));
+
+ QPoint targetPos = targetRect.bottomLeft();
+ if (window)
+ targetPos = window->mapToGlobal(targetPos);
+
+ const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+ m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+}
+
+void QWidgetPlatformMenu::dismiss()
+{
+ m_menu->close();
+}
+
+QPlatformMenuItem *QWidgetPlatformMenu::menuItemAt(int position) const
+{
+ Q_UNUSED(position);
+ return nullptr;
+}
+
+QPlatformMenuItem *QWidgetPlatformMenu::menuItemForTag(quintptr tag) const
+{
+ Q_UNUSED(tag);
+ return nullptr;
+}
+
+QPlatformMenuItem *QWidgetPlatformMenu::createMenuItem() const
+{
+ return nullptr;
+}
+
+QPlatformMenu *QWidgetPlatformMenu::createSubMenu() const
+{
+ return nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformmenu_p.h b/src/imports/platform/widgets/qwidgetplatformmenu_p.h
new file mode 100644
index 00000000..56ea7a45
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmenu_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMMENU_P_H
+#define QWIDGETPLATFORMMENU_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformmenu.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMenu;
+
+class QWidgetPlatformMenu : public QPlatformMenu
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformMenu(QObject *parent = nullptr);
+ ~QWidgetPlatformMenu();
+
+ QMenu *menu() const;
+
+ void insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) override;
+ void removeMenuItem(QPlatformMenuItem *item) override;
+ void syncMenuItem(QPlatformMenuItem *item) override;
+ void syncSeparatorsCollapsible(bool enable) override;
+
+ quintptr tag()const override;
+ void setTag(quintptr tag) override;
+
+ void setText(const QString &text) override;
+ void setIcon(const QIcon &icon) override;
+ void setEnabled(bool enabled) override;
+ bool isEnabled() const override;
+ void setVisible(bool visible) override;
+ void setMinimumWidth(int width) override;
+ void setFont(const QFont &font) override;
+ void setMenuType(MenuType type) override;
+
+ void showPopup(const QWindow *window, const QRect &targetRect, const QPlatformMenuItem *item) override;
+ void dismiss() override;
+
+ QPlatformMenuItem *menuItemAt(int position) const override;
+ QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
+
+ QPlatformMenuItem *createMenuItem() const override;
+ QPlatformMenu *createSubMenu() const override;
+
+private:
+ QScopedPointer<QMenu> m_menu;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMMENU_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformmenuitem.cpp b/src/imports/platform/widgets/qwidgetplatformmenuitem.cpp
new file mode 100644
index 00000000..4d168f7a
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmenuitem.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformmenuitem_p.h"
+
+#include <QtWidgets/qmenu.h>
+#include <QtWidgets/qaction.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformMenuItem::QWidgetPlatformMenuItem(QObject *parent)
+ : m_action(new QAction)
+{
+ setParent(parent);
+ connect(m_action.data(), &QAction::hovered, this, &QPlatformMenuItem::hovered);
+ connect(m_action.data(), &QAction::triggered, this, &QPlatformMenuItem::activated);
+}
+
+QWidgetPlatformMenuItem::~QWidgetPlatformMenuItem()
+{
+}
+
+QAction *QWidgetPlatformMenuItem::action() const
+{
+ return m_action.data();
+}
+
+quintptr QWidgetPlatformMenuItem::tag() const
+{
+ return 0;
+}
+
+void QWidgetPlatformMenuItem::setTag(quintptr tag)
+{
+ Q_UNUSED(tag);
+}
+
+void QWidgetPlatformMenuItem::setText(const QString &text)
+{
+ m_action->setText(text);
+}
+
+void QWidgetPlatformMenuItem::setIcon(const QIcon &icon)
+{
+ m_action->setIcon(icon);
+}
+
+void QWidgetPlatformMenuItem::setMenu(QPlatformMenu *menu)
+{
+ m_action->setMenu(qobject_cast<QMenu *>(menu));
+}
+
+void QWidgetPlatformMenuItem::setVisible(bool visible)
+{
+ m_action->setVisible(visible);
+}
+
+void QWidgetPlatformMenuItem::setIsSeparator(bool separator)
+{
+ m_action->setSeparator(separator);
+}
+
+void QWidgetPlatformMenuItem::setFont(const QFont &font)
+{
+ m_action->setFont(font);
+}
+
+void QWidgetPlatformMenuItem::setRole(MenuRole role)
+{
+ m_action->setMenuRole(static_cast<QAction::MenuRole>(role));
+}
+
+void QWidgetPlatformMenuItem::setCheckable(bool checkable)
+{
+ m_action->setCheckable(checkable);
+}
+
+void QWidgetPlatformMenuItem::setChecked(bool checked)
+{
+ m_action->setChecked(checked);
+}
+
+void QWidgetPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
+{
+ m_action->setShortcut(shortcut);
+}
+
+void QWidgetPlatformMenuItem::setEnabled(bool enabled)
+{
+ m_action->setEnabled(enabled);
+}
+
+void QWidgetPlatformMenuItem::setIconSize(int size)
+{
+ Q_UNUSED(size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformmenuitem_p.h b/src/imports/platform/widgets/qwidgetplatformmenuitem_p.h
new file mode 100644
index 00000000..d1a08187
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmenuitem_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMMENUITEM_P_H
+#define QWIDGETPLATFORMMENUITEM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformmenu.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAction;
+
+class QWidgetPlatformMenuItem : public QPlatformMenuItem
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformMenuItem(QObject *parent = nullptr);
+ ~QWidgetPlatformMenuItem();
+
+ QAction *action() const;
+
+ quintptr tag()const override;
+ void setTag(quintptr tag) override;
+
+ void setText(const QString &text) override;
+ void setIcon(const QIcon &icon) override;
+ void setMenu(QPlatformMenu *menu) override;
+ void setVisible(bool visible) override;
+ void setIsSeparator(bool separator) override;
+ void setFont(const QFont &font) override;
+ void setRole(MenuRole role) override;
+ void setCheckable(bool checkable) override;
+ void setChecked(bool checked) override;
+ void setShortcut(const QKeySequence& shortcut) override;
+ void setEnabled(bool enabled) override;
+ void setIconSize(int size) override;
+
+private:
+ QScopedPointer<QAction> m_action;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMMENUITEM_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformmessagedialog.cpp b/src/imports/platform/widgets/qwidgetplatformmessagedialog.cpp
new file mode 100644
index 00000000..b546e534
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmessagedialog.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformmessagedialog_p.h"
+#include "qwidgetplatformdialog_p.h"
+
+#include <QtWidgets/qmessagebox.h>
+#include <QtWidgets/qabstractbutton.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformMessageDialog::QWidgetPlatformMessageDialog(QObject *parent)
+ : m_dialog(new QMessageBox)
+{
+ setParent(parent);
+
+ connect(m_dialog.data(), &QMessageBox::accepted, this, &QPlatformDialogHelper::accept);
+ connect(m_dialog.data(), &QMessageBox::rejected, this, &QPlatformDialogHelper::reject);
+ connect(m_dialog.data(), &QMessageBox::buttonClicked, [this](QAbstractButton *button) {
+ QMessageBox::ButtonRole role = m_dialog->buttonRole(button);
+ QMessageBox::StandardButton standardButton = m_dialog->standardButton(button);
+ emit clicked(static_cast<StandardButton>(standardButton), static_cast<ButtonRole>(role));
+ });
+}
+
+QWidgetPlatformMessageDialog::~QWidgetPlatformMessageDialog()
+{
+}
+void QWidgetPlatformMessageDialog::exec()
+{
+ m_dialog->exec();
+}
+
+bool QWidgetPlatformMessageDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
+{
+ QSharedPointer<QMessageDialogOptions> options = QPlatformMessageDialogHelper::options();
+ m_dialog->setWindowTitle(options->windowTitle());
+ m_dialog->setIcon(static_cast<QMessageBox::Icon>(options->icon()));
+ m_dialog->setText(options->text());
+ m_dialog->setInformativeText(options->informativeText());
+ m_dialog->setDetailedText(options->detailedText());
+ m_dialog->setStandardButtons(static_cast<QMessageBox::StandardButtons>(int(options->standardButtons())));
+
+ return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent);
+}
+
+void QWidgetPlatformMessageDialog::hide()
+{
+ m_dialog->hide();
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformmessagedialog_p.h b/src/imports/platform/widgets/qwidgetplatformmessagedialog_p.h
new file mode 100644
index 00000000..319bb34d
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformmessagedialog_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMMESSAGEDIALOG_P_H
+#define QWIDGETPLATFORMMESSAGEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMessageBox;
+
+class QWidgetPlatformMessageDialog : public QPlatformMessageDialogHelper
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformMessageDialog(QObject *parent = nullptr);
+ ~QWidgetPlatformMessageDialog();
+
+ void exec() override;
+ bool show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) override;
+ void hide() override;
+
+private:
+ QScopedPointer<QMessageBox> m_dialog;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMMESSAGEDIALOG_P_H
diff --git a/src/imports/platform/widgets/qwidgetplatformsystemtrayicon.cpp b/src/imports/platform/widgets/qwidgetplatformsystemtrayicon.cpp
new file mode 100644
index 00000000..cfee02aa
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformsystemtrayicon.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetplatformsystemtrayicon_p.h"
+#include "qwidgetplatformmenu_p.h"
+
+#include <QtWidgets/qsystemtrayicon.h>
+
+QT_BEGIN_NAMESPACE
+
+QWidgetPlatformSystemTrayIcon::QWidgetPlatformSystemTrayIcon(QObject *parent)
+ : m_systray(new QSystemTrayIcon)
+{
+ setParent(parent);
+
+ connect(m_systray.data(), &QSystemTrayIcon::messageClicked, this, &QPlatformSystemTrayIcon::messageClicked);
+ connect(m_systray.data(), &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
+ emit activated(static_cast<ActivationReason>(reason));
+ });
+}
+
+QWidgetPlatformSystemTrayIcon::~QWidgetPlatformSystemTrayIcon()
+{
+}
+
+void QWidgetPlatformSystemTrayIcon::init()
+{
+ m_systray->show();
+}
+
+void QWidgetPlatformSystemTrayIcon::cleanup()
+{
+ m_systray->hide();
+}
+
+void QWidgetPlatformSystemTrayIcon::updateIcon(const QIcon &icon)
+{
+ m_systray->setIcon(icon);
+}
+
+void QWidgetPlatformSystemTrayIcon::updateToolTip(const QString &tooltip)
+{
+ m_systray->setToolTip(tooltip);
+}
+
+void QWidgetPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu)
+{
+ QWidgetPlatformMenu *widgetMenu = qobject_cast<QWidgetPlatformMenu *>(menu);
+ if (!widgetMenu)
+ return;
+
+ m_systray->setContextMenu(widgetMenu->menu());
+}
+
+QRect QWidgetPlatformSystemTrayIcon::geometry() const
+{
+ return m_systray->geometry();
+}
+
+void QWidgetPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs)
+{
+ Q_UNUSED(icon);
+ m_systray->showMessage(title, msg, static_cast<QSystemTrayIcon::MessageIcon>(iconType), msecs);
+}
+
+bool QWidgetPlatformSystemTrayIcon::isSystemTrayAvailable() const
+{
+ return QSystemTrayIcon::isSystemTrayAvailable();
+}
+
+bool QWidgetPlatformSystemTrayIcon::supportsMessages() const
+{
+ return QSystemTrayIcon::supportsMessages();
+}
+
+QPlatformMenu *QWidgetPlatformSystemTrayIcon::createMenu() const
+{
+ return new QWidgetPlatformMenu;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/widgets/qwidgetplatformsystemtrayicon_p.h b/src/imports/platform/widgets/qwidgetplatformsystemtrayicon_p.h
new file mode 100644
index 00000000..f48430a4
--- /dev/null
+++ b/src/imports/platform/widgets/qwidgetplatformsystemtrayicon_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETPLATFORMSYSTEMTRAYICON_P_H
+#define QWIDGETPLATFORMSYSTEMTRAYICON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qpa/qplatformsystemtrayicon.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSystemTrayIcon;
+
+class QWidgetPlatformSystemTrayIcon : public QPlatformSystemTrayIcon
+{
+ Q_OBJECT
+
+public:
+ explicit QWidgetPlatformSystemTrayIcon(QObject *parent = nullptr);
+ ~QWidgetPlatformSystemTrayIcon();
+
+ void init() override;
+ void cleanup() override;
+ void updateIcon(const QIcon &icon) override;
+ void updateToolTip(const QString &tooltip) override;
+ void updateMenu(QPlatformMenu *menu) override;
+ QRect geometry() const override;
+ void showMessage(const QString &title, const QString &msg,
+ const QIcon &icon, MessageIcon iconType, int msecs) override;
+
+ bool isSystemTrayAvailable() const override;
+ bool supportsMessages() const override;
+
+ QPlatformMenu *createMenu() const override;
+
+private:
+ QScopedPointer<QSystemTrayIcon> m_systray;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWIDGETPLATFORMSYSTEMTRAYICON_P_H
diff --git a/src/imports/platform/widgets/widgets.pri b/src/imports/platform/widgets/widgets.pri
new file mode 100644
index 00000000..c904e924
--- /dev/null
+++ b/src/imports/platform/widgets/widgets.pri
@@ -0,0 +1,23 @@
+QT += widgets
+DEPENDPATH += $$PWD
+
+HEADERS += \
+ $$PWD/qwidgetplatform_p.h \
+ $$PWD/qwidgetplatformcolordialog_p.h \
+ $$PWD/qwidgetplatformdialog_p.h \
+ $$PWD/qwidgetplatformfiledialog_p.h \
+ $$PWD/qwidgetplatformfontdialog_p.h \
+ $$PWD/qwidgetplatformmenu_p.h \
+ $$PWD/qwidgetplatformmenuitem_p.h \
+ $$PWD/qwidgetplatformmessagedialog_p.h \
+ $$PWD/qwidgetplatformsystemtrayicon_p.h
+
+SOURCES += \
+ $$PWD/qwidgetplatformcolordialog.cpp \
+ $$PWD/qwidgetplatformdialog.cpp \
+ $$PWD/qwidgetplatformfiledialog.cpp \
+ $$PWD/qwidgetplatformfontdialog.cpp \
+ $$PWD/qwidgetplatformmenu.cpp \
+ $$PWD/qwidgetplatformmenuitem.cpp \
+ $$PWD/qwidgetplatformmessagedialog.cpp \
+ $$PWD/qwidgetplatformsystemtrayicon.cpp
diff --git a/src/imports/templates/dependencies.json b/src/imports/templates/dependencies.json
new file mode 100644
index 00000000..26ce7c00
--- /dev/null
+++ b/src/imports/templates/dependencies.json
@@ -0,0 +1,12 @@
+[
+ {
+ "name": "QtQuick",
+ "type": "module",
+ "version": "2.8"
+ },
+ {
+ "name": "QtQuick.Window",
+ "type": "module",
+ "version": "2.2"
+ }
+]
diff --git a/src/imports/controls/doc/src/templates/qtquicktemplates2-index.qdoc b/src/imports/templates/doc/src/qtquicktemplates2-index.qdoc
index 2e22196b..2e22196b 100644
--- a/src/imports/controls/doc/src/templates/qtquicktemplates2-index.qdoc
+++ b/src/imports/templates/doc/src/qtquicktemplates2-index.qdoc
diff --git a/src/imports/controls/doc/src/templates/qtquicktemplates2.qdoc b/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc
index 1ddfe763..977616bd 100644
--- a/src/imports/controls/doc/src/templates/qtquicktemplates2.qdoc
+++ b/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc
@@ -38,7 +38,7 @@
\c .qml file:
\badcode
- import QtQuick.Templates 2.0 as T
+ import QtQuick.Templates 2.1 as T
\endcode
For the sake of clarity, there is a one-to-one mapping between the types
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index 75a11a6e..6b644437 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -4,10 +4,10 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtQuick.Templates 2.0'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.Templates 2.1'
Module {
- dependencies: ["QtQuick.Window 2.2"]
+ dependencies: ["QtQuick 2.8", "QtQuick.Window 2.2"]
Component {
name: "QQuickAbstractButton"
defaultProperty: "data"
@@ -18,6 +18,7 @@ Module {
Property { name: "down"; type: "bool" }
Property { name: "pressed"; type: "bool"; isReadonly: true }
Property { name: "checked"; type: "bool" }
+ Property { name: "checkable"; type: "bool" }
Property { name: "autoExclusive"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Signal { name: "pressed" }
@@ -69,12 +70,41 @@ Module {
prototype: "QQuickAbstractButton"
exports: ["QtQuick.Templates/Button 2.0"]
exportMetaObjectRevisions: [0]
- Property { name: "checkable"; type: "bool" }
Property { name: "autoRepeat"; type: "bool" }
Property { name: "highlighted"; type: "bool" }
Property { name: "flat"; type: "bool" }
}
Component {
+ name: "QQuickButtonGroup"
+ prototype: "QObject"
+ exports: [
+ "QtQuick.Templates/ButtonGroup 2.0",
+ "QtQuick.Templates/ButtonGroup 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
+ attachedType: "QQuickButtonGroupAttached"
+ Property { name: "checkedButton"; type: "QQuickAbstractButton"; isPointer: true }
+ Property { name: "buttons"; type: "QQuickAbstractButton"; isList: true; isReadonly: true }
+ Signal {
+ name: "clicked"
+ revision: 1
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "addButton"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "removeButton"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ }
+ Component {
+ name: "QQuickButtonGroupAttached"
+ prototype: "QObject"
+ Property { name: "group"; type: "QQuickButtonGroup"; isPointer: true }
+ }
+ Component {
name: "QQuickCheckBox"
defaultProperty: "data"
prototype: "QQuickAbstractButton"
@@ -96,11 +126,15 @@ Module {
name: "QQuickComboBox"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/ComboBox 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/ComboBox 2.0",
+ "QtQuick.Templates/ComboBox 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "model"; type: "QVariant" }
Property { name: "delegateModel"; type: "QQmlInstanceModel"; isReadonly: true; isPointer: true }
+ Property { name: "flat"; revision: 1; type: "bool" }
Property { name: "pressed"; type: "bool" }
Property { name: "highlightedIndex"; type: "int"; isReadonly: true }
Property { name: "currentIndex"; type: "int" }
@@ -110,6 +144,7 @@ Module {
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Property { name: "popup"; type: "QQuickPopup"; isPointer: true }
+ Signal { name: "flatChanged"; revision: 1 }
Signal {
name: "activated"
Parameter { name: "index"; type: "int" }
@@ -141,8 +176,11 @@ Module {
name: "QQuickContainer"
defaultProperty: "contentData"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Container 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Container 2.0",
+ "QtQuick.Templates/Container 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "count"; type: "int"; isReadonly: true }
Property { name: "contentModel"; type: "QVariant"; isReadonly: true }
Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true }
@@ -153,6 +191,8 @@ Module {
name: "setCurrentIndex"
Parameter { name: "index"; type: "int" }
}
+ Method { name: "incrementCurrentIndex"; revision: 1 }
+ Method { name: "decrementCurrentIndex"; revision: 1 }
Method {
name: "itemAt"
type: "QQuickItem*"
@@ -231,6 +271,58 @@ Module {
Method { name: "decrease" }
}
Component {
+ name: "QQuickDialog"
+ defaultProperty: "contentData"
+ prototype: "QQuickPopup"
+ exports: ["QtQuick.Templates/Dialog 2.1"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "title"; type: "string" }
+ Property { name: "header"; type: "QQuickItem"; isPointer: true }
+ Property { name: "footer"; type: "QQuickItem"; isPointer: true }
+ Property { name: "standardButtons"; type: "QPlatformDialogHelper::StandardButtons" }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Method { name: "accept" }
+ Method { name: "reject" }
+ }
+ Component {
+ name: "QQuickDialogButtonBox"
+ defaultProperty: "contentData"
+ prototype: "QQuickContainer"
+ exports: ["QtQuick.Templates/DialogButtonBox 2.1"]
+ exportMetaObjectRevisions: [0]
+ attachedType: "QQuickDialogButtonBoxAttached"
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
+ Property { name: "alignment"; type: "Qt::Alignment" }
+ Property { name: "standardButtons"; type: "QPlatformDialogHelper::StandardButtons" }
+ Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Signal { name: "helpRequested" }
+ Signal {
+ name: "clicked"
+ Parameter { name: "button"; type: "QQuickAbstractButton"; isPointer: true }
+ }
+ Method {
+ name: "standardButton"
+ type: "QQuickAbstractButton*"
+ Parameter { name: "button"; type: "QPlatformDialogHelper::StandardButton" }
+ }
+ }
+ Component {
+ name: "QQuickDialogButtonBoxAttached"
+ prototype: "QObject"
+ Property { name: "buttonBox"; type: "QQuickDialogButtonBox"; isReadonly: true; isPointer: true }
+ Property { name: "buttonRole"; type: "QPlatformDialogHelper::ButtonRole" }
+ }
+ Component {
name: "QQuickDrawer"
defaultProperty: "contentData"
prototype: "QQuickPopup"
@@ -257,181 +349,6 @@ Module {
Property { name: "label"; type: "QQuickItem"; isPointer: true }
}
Component {
- name: "QQuickImplicitSizeItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- Property { name: "implicitWidth"; type: "double"; isReadonly: true }
- Property { name: "implicitHeight"; type: "double"; isReadonly: true }
- Signal { name: "implicitWidthChanged2"; revision: 1 }
- Signal { name: "implicitHeightChanged2"; revision: 1 }
- }
- Component {
- name: "QQuickItem"
- defaultProperty: "data"
- prototype: "QObject"
- Enum {
- name: "TransformOrigin"
- values: {
- "TopLeft": 0,
- "Top": 1,
- "TopRight": 2,
- "Left": 3,
- "Center": 4,
- "Right": 5,
- "BottomLeft": 6,
- "Bottom": 7,
- "BottomRight": 8
- }
- }
- Property { name: "parent"; type: "QQuickItem"; isPointer: true }
- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
- Property { name: "x"; type: "double" }
- Property { name: "y"; type: "double" }
- Property { name: "z"; type: "double" }
- Property { name: "width"; type: "double" }
- Property { name: "height"; type: "double" }
- Property { name: "opacity"; type: "double" }
- Property { name: "enabled"; type: "bool" }
- Property { name: "visible"; type: "bool" }
- Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
- Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true }
- Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true }
- Property { name: "state"; type: "string" }
- Property { name: "childrenRect"; type: "QRectF"; isReadonly: true }
- Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true }
- Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "baselineOffset"; type: "double" }
- Property { name: "clip"; type: "bool" }
- Property { name: "focus"; type: "bool" }
- Property { name: "activeFocus"; type: "bool"; isReadonly: true }
- Property { name: "activeFocusOnTab"; revision: 1; type: "bool" }
- Property { name: "rotation"; type: "double" }
- Property { name: "scale"; type: "double" }
- Property { name: "transformOrigin"; type: "TransformOrigin" }
- Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true }
- Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true }
- Property { name: "smooth"; type: "bool" }
- Property { name: "antialiasing"; type: "bool" }
- Property { name: "implicitWidth"; type: "double" }
- Property { name: "implicitHeight"; type: "double" }
- Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true }
- Signal {
- name: "childrenRectChanged"
- Parameter { type: "QRectF" }
- }
- Signal {
- name: "baselineOffsetChanged"
- Parameter { type: "double" }
- }
- Signal {
- name: "stateChanged"
- Parameter { type: "string" }
- }
- Signal {
- name: "focusChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "activeFocusChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "activeFocusOnTabChanged"
- revision: 1
- Parameter { type: "bool" }
- }
- Signal {
- name: "parentChanged"
- Parameter { type: "QQuickItem"; isPointer: true }
- }
- Signal {
- name: "transformOriginChanged"
- Parameter { type: "TransformOrigin" }
- }
- Signal {
- name: "smoothChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "antialiasingChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "clipChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "windowChanged"
- revision: 1
- Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
- }
- Method { name: "update" }
- Method {
- name: "grabToImage"
- revision: 2
- type: "bool"
- Parameter { name: "callback"; type: "QJSValue" }
- Parameter { name: "targetSize"; type: "QSize" }
- }
- Method {
- name: "grabToImage"
- revision: 2
- type: "bool"
- Parameter { name: "callback"; type: "QJSValue" }
- }
- Method {
- name: "contains"
- type: "bool"
- Parameter { name: "point"; type: "QPointF" }
- }
- Method {
- name: "mapToGlobal"
- revision: 7
- type: "QPointF"
- Parameter { name: "point"; type: "QPointF" }
- }
- Method {
- name: "mapFromGlobal"
- revision: 7
- type: "QPointF"
- Parameter { name: "point"; type: "QPointF" }
- }
- Method {
- name: "mapFromItem"
- Parameter { type: "QQmlV4Function"; isPointer: true }
- }
- Method {
- name: "mapToItem"
- Parameter { type: "QQmlV4Function"; isPointer: true }
- }
- Method { name: "forceActiveFocus" }
- Method {
- name: "forceActiveFocus"
- Parameter { name: "reason"; type: "Qt::FocusReason" }
- }
- Method {
- name: "nextItemInFocusChain"
- revision: 1
- type: "QQuickItem*"
- Parameter { name: "forward"; type: "bool" }
- }
- Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" }
- Method {
- name: "childAt"
- type: "QQuickItem*"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- }
- Component {
name: "QQuickItemDelegate"
defaultProperty: "data"
prototype: "QQuickAbstractButton"
@@ -487,16 +404,22 @@ Module {
prototype: "QQuickAbstractButton"
exports: ["QtQuick.Templates/MenuItem 2.0"]
exportMetaObjectRevisions: [0]
- Property { name: "checkable"; type: "bool" }
Property { name: "highlighted"; type: "bool" }
Signal { name: "triggered" }
}
Component {
+ name: "QQuickMenuSeparator"
+ defaultProperty: "data"
+ prototype: "QQuickControl"
+ exports: ["QtQuick.Templates/MenuSeparator 2.1"]
+ exportMetaObjectRevisions: [0]
+ }
+ Component {
name: "QQuickOverlay"
defaultProperty: "data"
prototype: "QQuickItem"
- Property { name: "modal"; type: "QQuickItem"; isPointer: true }
- Property { name: "modeless"; type: "QQuickItem"; isPointer: true }
+ Property { name: "modal"; type: "QQmlComponent"; isPointer: true }
+ Property { name: "modeless"; type: "QQmlComponent"; isPointer: true }
Signal { name: "pressed" }
Signal { name: "released" }
}
@@ -504,13 +427,17 @@ Module {
name: "QQuickPage"
defaultProperty: "contentData"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Page 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: ["QtQuick.Templates/Page 2.0", "QtQuick.Templates/Page 2.1"]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "title"; type: "string" }
Property { name: "header"; type: "QQuickItem"; isPointer: true }
Property { name: "footer"; type: "QQuickItem"; isPointer: true }
+ Property { name: "contentWidth"; revision: 1; type: "double" }
+ Property { name: "contentHeight"; revision: 1; type: "double" }
Property { name: "contentData"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "contentChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
+ Signal { name: "contentWidthChanged"; revision: 1 }
+ Signal { name: "contentHeightChanged"; revision: 1 }
}
Component {
name: "QQuickPageIndicator"
@@ -538,8 +465,11 @@ Module {
name: "QQuickPopup"
defaultProperty: "contentData"
prototype: "QObject"
- exports: ["QtQuick.Templates/Popup 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Popup 2.0",
+ "QtQuick.Templates/Popup 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "ClosePolicy"
values: {
@@ -576,6 +506,7 @@ Module {
Property { name: "contentHeight"; type: "double" }
Property { name: "availableWidth"; type: "double"; isReadonly: true }
Property { name: "availableHeight"; type: "double"; isReadonly: true }
+ Property { name: "spacing"; revision: 1; type: "double" }
Property { name: "margins"; type: "double" }
Property { name: "topMargin"; type: "double" }
Property { name: "leftMargin"; type: "double" }
@@ -605,6 +536,7 @@ Module {
Property { name: "transformOrigin"; type: "TransformOrigin" }
Property { name: "enter"; type: "QQuickTransition"; isPointer: true }
Property { name: "exit"; type: "QQuickTransition"; isPointer: true }
+ Signal { name: "spacingChanged"; revision: 1 }
Signal {
name: "windowChanged"
Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
@@ -615,6 +547,11 @@ Module {
Signal { name: "closed" }
Method { name: "open" }
Method { name: "close" }
+ Method {
+ name: "forceActiveFocus"
+ Parameter { name: "reason"; type: "Qt::FocusReason" }
+ }
+ Method { name: "forceActiveFocus" }
}
Component {
name: "QQuickProgressBar"
@@ -647,8 +584,11 @@ Module {
name: "QQuickRangeSlider"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/RangeSlider 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/RangeSlider 2.0",
+ "QtQuick.Templates/RangeSlider 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "SnapMode"
values: {
@@ -678,21 +618,18 @@ Module {
Property { name: "visualPosition"; type: "double"; isReadonly: true }
Property { name: "handle"; type: "QQuickItem"; isPointer: true }
Property { name: "pressed"; type: "bool" }
+ Property { name: "hovered"; revision: 1; type: "bool" }
+ Signal { name: "hoveredChanged"; revision: 1 }
Method { name: "increase" }
Method { name: "decrease" }
}
Component {
- name: "QQuickRootItem"
+ name: "QQuickRoundButton"
defaultProperty: "data"
- prototype: "QQuickItem"
- Method {
- name: "setWidth"
- Parameter { name: "w"; type: "int" }
- }
- Method {
- name: "setHeight"
- Parameter { name: "h"; type: "int" }
- }
+ prototype: "QQuickButton"
+ exports: ["QtQuick.Templates/RoundButton 2.1"]
+ exportMetaObjectRevisions: [1]
+ Property { name: "radius"; type: "double" }
}
Component {
name: "QQuickScrollBar"
@@ -754,8 +691,11 @@ Module {
name: "QQuickSlider"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Slider 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Slider 2.0",
+ "QtQuick.Templates/Slider 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Enum {
name: "SnapMode"
values: {
@@ -776,13 +716,22 @@ Module {
Property { name: "handle"; type: "QQuickItem"; isPointer: true }
Method { name: "increase" }
Method { name: "decrease" }
+ Method {
+ name: "valueAt"
+ revision: 1
+ type: "double"
+ Parameter { name: "position"; type: "double" }
+ }
}
Component {
name: "QQuickSpinBox"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/SpinBox 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SpinBox 2.0",
+ "QtQuick.Templates/SpinBox 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "from"; type: "int" }
Property { name: "to"; type: "int" }
Property { name: "value"; type: "int" }
@@ -800,7 +749,9 @@ Module {
name: "QQuickSpinButton"
prototype: "QObject"
Property { name: "pressed"; type: "bool" }
+ Property { name: "hovered"; revision: 1; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
+ Signal { name: "hoveredChanged"; revision: 1 }
}
Component {
name: "QQuickStackAttached"
@@ -808,13 +759,21 @@ Module {
Property { name: "index"; type: "int"; isReadonly: true }
Property { name: "view"; type: "QQuickStackView"; isReadonly: true; isPointer: true }
Property { name: "status"; type: "QQuickStackView::Status"; isReadonly: true }
+ Signal { name: "activated" }
+ Signal { name: "activating" }
+ Signal { name: "deactivated" }
+ Signal { name: "deactivating" }
+ Signal { name: "removed" }
}
Component {
name: "QQuickStackView"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/StackView 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/StackView 2.0",
+ "QtQuick.Templates/StackView 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickStackAttached"
Enum {
name: "Status"
@@ -835,8 +794,11 @@ Module {
Enum {
name: "Operation"
values: {
- "Transition": 0,
- "Immediate": 1
+ "Transition": -1,
+ "Immediate": 0,
+ "PushTransition": 1,
+ "ReplaceTransition": 2,
+ "PopTransition": 3
}
}
Property { name: "busy"; type: "bool"; isReadonly: true }
@@ -896,28 +858,47 @@ Module {
Property { name: "leftItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "behindItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "rightItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
+ Signal { name: "completed"; revision: 1 }
+ Method { name: "close"; revision: 1 }
}
Component {
name: "QQuickSwipeDelegate"
defaultProperty: "data"
prototype: "QQuickItemDelegate"
- exports: ["QtQuick.Templates/SwipeDelegate 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SwipeDelegate 2.0",
+ "QtQuick.Templates/SwipeDelegate 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
+ attachedType: "QQuickSwipeDelegateAttached"
Property { name: "swipe"; type: "QQuickSwipe"; isReadonly: true; isPointer: true }
}
Component {
+ name: "QQuickSwipeDelegateAttached"
+ prototype: "QObject"
+ Property { name: "pressed"; type: "bool"; isReadonly: true }
+ Signal { name: "clicked" }
+ }
+ Component {
name: "QQuickSwipeView"
defaultProperty: "contentData"
prototype: "QQuickContainer"
- exports: ["QtQuick.Templates/SwipeView 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/SwipeView 2.0",
+ "QtQuick.Templates/SwipeView 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickSwipeViewAttached"
+ Property { name: "interactive"; revision: 1; type: "bool" }
+ Signal { name: "interactiveChanged"; revision: 1 }
}
Component {
name: "QQuickSwipeViewAttached"
prototype: "QObject"
Property { name: "index"; type: "int"; isReadonly: true }
Property { name: "isCurrentItem"; type: "bool"; isReadonly: true }
+ Property { name: "isNextItem"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "isPreviousItem"; revision: 1; type: "bool"; isReadonly: true }
Property { name: "view"; type: "QQuickSwipeView"; isReadonly: true; isPointer: true }
}
Component {
@@ -961,188 +942,14 @@ Module {
exportMetaObjectRevisions: [0]
}
Component {
- name: "QQuickText"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4,
- "AlignJustify": 8
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "TextStyle"
- values: {
- "Normal": 0,
- "Outline": 1,
- "Raised": 2,
- "Sunken": 3
- }
- }
- Enum {
- name: "TextFormat"
- values: {
- "PlainText": 0,
- "RichText": 1,
- "AutoText": 2,
- "StyledText": 4
- }
- }
- Enum {
- name: "TextElideMode"
- values: {
- "ElideLeft": 0,
- "ElideRight": 1,
- "ElideMiddle": 2,
- "ElideNone": 3
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Enum {
- name: "LineHeightMode"
- values: {
- "ProportionalHeight": 0,
- "FixedHeight": 1
- }
- }
- Enum {
- name: "FontSizeMode"
- values: {
- "FixedSize": 0,
- "HorizontalFit": 1,
- "VerticalFit": 2,
- "Fit": 3
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "font"; type: "QFont" }
- Property { name: "color"; type: "QColor" }
- Property { name: "linkColor"; type: "QColor" }
- Property { name: "style"; type: "TextStyle" }
- Property { name: "styleColor"; type: "QColor" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "lineCount"; type: "int"; isReadonly: true }
- Property { name: "truncated"; type: "bool"; isReadonly: true }
- Property { name: "maximumLineCount"; type: "int" }
- Property { name: "textFormat"; type: "TextFormat" }
- Property { name: "elide"; type: "TextElideMode" }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "paintedWidth"; type: "double"; isReadonly: true }
- Property { name: "paintedHeight"; type: "double"; isReadonly: true }
- Property { name: "lineHeight"; type: "double" }
- Property { name: "lineHeightMode"; type: "LineHeightMode" }
- Property { name: "baseUrl"; type: "QUrl" }
- Property { name: "minimumPixelSize"; type: "int" }
- Property { name: "minimumPointSize"; type: "int" }
- Property { name: "fontSizeMode"; type: "FontSizeMode" }
- Property { name: "renderType"; type: "RenderType" }
- Property { name: "hoveredLink"; revision: 2; type: "string"; isReadonly: true }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Signal {
- name: "textChanged"
- Parameter { name: "text"; type: "string" }
- }
- Signal {
- name: "linkActivated"
- Parameter { name: "link"; type: "string" }
- }
- Signal {
- name: "linkHovered"
- revision: 2
- Parameter { name: "link"; type: "string" }
- }
- Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "styleChanged"
- Parameter { name: "style"; type: "QQuickText::TextStyle" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickText::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickText::VAlignment" }
- }
- Signal {
- name: "textFormatChanged"
- Parameter { name: "textFormat"; type: "QQuickText::TextFormat" }
- }
- Signal {
- name: "elideModeChanged"
- Parameter { name: "mode"; type: "QQuickText::TextElideMode" }
- }
- Signal { name: "contentSizeChanged" }
- Signal {
- name: "lineHeightChanged"
- Parameter { name: "lineHeight"; type: "double" }
- }
- Signal {
- name: "lineHeightModeChanged"
- Parameter { name: "mode"; type: "LineHeightMode" }
- }
- Signal {
- name: "lineLaidOut"
- Parameter { name: "line"; type: "QQuickTextLine"; isPointer: true }
- }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "doLayout" }
- Method {
- name: "linkAt"
- revision: 3
- type: "string"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- }
- Component {
name: "QQuickTextArea"
defaultProperty: "data"
prototype: "QQuickTextEdit"
- exports: ["QtQuick.Templates/TextArea 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/TextArea 2.0",
+ "QtQuick.Templates/TextArea 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickTextAreaAttached"
Property { name: "font"; type: "QFont" }
Property { name: "implicitWidth"; type: "double" }
@@ -1150,539 +957,72 @@ Module {
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "placeholderText"; type: "string" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; revision: 1; type: "bool" }
Signal { name: "implicitWidthChanged3" }
Signal { name: "implicitHeightChanged3" }
+ Signal { name: "hoveredChanged"; revision: 1 }
+ Signal { name: "hoverEnabledChanged"; revision: 1 }
Signal {
name: "pressAndHold"
Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
- }
- Component {
- name: "QQuickTextAreaAttached"
- prototype: "QObject"
- Property { name: "flickable"; type: "QQuickTextArea"; isPointer: true }
- }
- Component {
- name: "QQuickTextEdit"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4,
- "AlignJustify": 8
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "TextFormat"
- values: {
- "PlainText": 0,
- "RichText": 1,
- "AutoText": 2
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "SelectionMode"
- values: {
- "SelectCharacters": 0,
- "SelectWords": 1
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "color"; type: "QColor" }
- Property { name: "selectionColor"; type: "QColor" }
- Property { name: "selectedTextColor"; type: "QColor" }
- Property { name: "font"; type: "QFont" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "lineCount"; type: "int"; isReadonly: true }
- Property { name: "length"; type: "int"; isReadonly: true }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "paintedWidth"; type: "double"; isReadonly: true }
- Property { name: "paintedHeight"; type: "double"; isReadonly: true }
- Property { name: "textFormat"; type: "TextFormat" }
- Property { name: "readOnly"; type: "bool" }
- Property { name: "cursorVisible"; type: "bool" }
- Property { name: "cursorPosition"; type: "int" }
- Property { name: "cursorRectangle"; type: "QRectF"; isReadonly: true }
- Property { name: "cursorDelegate"; type: "QQmlComponent"; isPointer: true }
- Property { name: "selectionStart"; type: "int"; isReadonly: true }
- Property { name: "selectionEnd"; type: "int"; isReadonly: true }
- Property { name: "selectedText"; type: "string"; isReadonly: true }
- Property { name: "activeFocusOnPress"; type: "bool" }
- Property { name: "persistentSelection"; type: "bool" }
- Property { name: "textMargin"; type: "double" }
- Property { name: "inputMethodHints"; type: "Qt::InputMethodHints" }
- Property { name: "selectByKeyboard"; revision: 1; type: "bool" }
- Property { name: "selectByMouse"; type: "bool" }
- Property { name: "mouseSelectionMode"; type: "SelectionMode" }
- Property { name: "canPaste"; type: "bool"; isReadonly: true }
- Property { name: "canUndo"; type: "bool"; isReadonly: true }
- Property { name: "canRedo"; type: "bool"; isReadonly: true }
- Property { name: "inputMethodComposing"; type: "bool"; isReadonly: true }
- Property { name: "baseUrl"; type: "QUrl" }
- Property { name: "renderType"; type: "RenderType" }
- Property {
- name: "textDocument"
- revision: 1
- type: "QQuickTextDocument"
- isReadonly: true
- isPointer: true
- }
- Property { name: "hoveredLink"; revision: 2; type: "string"; isReadonly: true }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
- Signal { name: "preeditTextChanged"; revision: 7 }
- Signal { name: "contentSizeChanged" }
Signal {
- name: "colorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
- Signal {
- name: "selectionColorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
- Signal {
- name: "selectedTextColorChanged"
- Parameter { name: "color"; type: "QColor" }
- }
- Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextEdit::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextEdit::VAlignment" }
- }
- Signal {
- name: "textFormatChanged"
- Parameter { name: "textFormat"; type: "QQuickTextEdit::TextFormat" }
- }
- Signal {
- name: "readOnlyChanged"
- Parameter { name: "isReadOnly"; type: "bool" }
- }
- Signal {
- name: "cursorVisibleChanged"
- Parameter { name: "isCursorVisible"; type: "bool" }
- }
- Signal {
- name: "activeFocusOnPressChanged"
- Parameter { name: "activeFocusOnPressed"; type: "bool" }
- }
- Signal {
- name: "persistentSelectionChanged"
- Parameter { name: "isPersistentSelection"; type: "bool" }
- }
- Signal {
- name: "textMarginChanged"
- Parameter { name: "textMargin"; type: "double" }
- }
- Signal {
- name: "selectByKeyboardChanged"
+ name: "pressed"
revision: 1
- Parameter { name: "selectByKeyboard"; type: "bool" }
- }
- Signal {
- name: "selectByMouseChanged"
- Parameter { name: "selectByMouse"; type: "bool" }
- }
- Signal {
- name: "mouseSelectionModeChanged"
- Parameter { name: "mode"; type: "QQuickTextEdit::SelectionMode" }
- }
- Signal {
- name: "linkActivated"
- Parameter { name: "link"; type: "string" }
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "linkHovered"
- revision: 2
- Parameter { name: "link"; type: "string" }
- }
- Signal { name: "editingFinished"; revision: 6 }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "selectAll" }
- Method { name: "selectWord" }
- Method {
- name: "select"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "deselect" }
- Method {
- name: "isRightToLeft"
- type: "bool"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "cut" }
- Method { name: "copy" }
- Method { name: "paste" }
- Method { name: "undo" }
- Method { name: "redo" }
- Method {
- name: "insert"
- Parameter { name: "position"; type: "int" }
- Parameter { name: "text"; type: "string" }
- }
- Method {
- name: "remove"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "append"
- revision: 2
- Parameter { name: "text"; type: "string" }
- }
- Method { name: "clear"; revision: 7 }
- Method {
- name: "inputMethodQuery"
- revision: 4
- type: "QVariant"
- Parameter { name: "query"; type: "Qt::InputMethodQuery" }
- Parameter { name: "argument"; type: "QVariant" }
- }
- Method {
- name: "positionToRectangle"
- type: "QRectF"
- Parameter { type: "int" }
- }
- Method {
- name: "positionAt"
- type: "int"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- Parameter { name: "mode"; type: "SelectionMode" }
- }
- Method {
- name: "getText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "getFormattedText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "linkAt"
- revision: 3
- type: "string"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
+ name: "released"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
}
Component {
+ name: "QQuickTextAreaAttached"
+ prototype: "QObject"
+ Property { name: "flickable"; type: "QQuickTextArea"; isPointer: true }
+ }
+ Component {
name: "QQuickTextField"
defaultProperty: "data"
prototype: "QQuickTextInput"
- exports: ["QtQuick.Templates/TextField 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/TextField 2.0",
+ "QtQuick.Templates/TextField 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
Property { name: "font"; type: "QFont" }
Property { name: "implicitWidth"; type: "double" }
Property { name: "implicitHeight"; type: "double" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "placeholderText"; type: "string" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; revision: 1; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; revision: 1; type: "bool" }
Signal { name: "implicitWidthChanged3" }
Signal { name: "implicitHeightChanged3" }
+ Signal { name: "hoveredChanged"; revision: 1 }
+ Signal { name: "hoverEnabledChanged"; revision: 1 }
Signal {
name: "pressAndHold"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- }
- Component {
- name: "QQuickTextInput"
- defaultProperty: "data"
- prototype: "QQuickImplicitSizeItem"
- Enum {
- name: "EchoMode"
- values: {
- "Normal": 0,
- "NoEcho": 1,
- "Password": 2,
- "PasswordEchoOnEdit": 3
- }
- }
- Enum {
- name: "HAlignment"
- values: {
- "AlignLeft": 1,
- "AlignRight": 2,
- "AlignHCenter": 4
- }
- }
- Enum {
- name: "VAlignment"
- values: {
- "AlignTop": 32,
- "AlignBottom": 64,
- "AlignVCenter": 128
- }
- }
- Enum {
- name: "WrapMode"
- values: {
- "NoWrap": 0,
- "WordWrap": 1,
- "WrapAnywhere": 3,
- "WrapAtWordBoundaryOrAnywhere": 4,
- "Wrap": 4
- }
- }
- Enum {
- name: "SelectionMode"
- values: {
- "SelectCharacters": 0,
- "SelectWords": 1
- }
- }
- Enum {
- name: "CursorPosition"
- values: {
- "CursorBetweenCharacters": 0,
- "CursorOnCharacter": 1
- }
- }
- Enum {
- name: "RenderType"
- values: {
- "QtRendering": 0,
- "NativeRendering": 1
- }
- }
- Property { name: "text"; type: "string" }
- Property { name: "length"; type: "int"; isReadonly: true }
- Property { name: "color"; type: "QColor" }
- Property { name: "selectionColor"; type: "QColor" }
- Property { name: "selectedTextColor"; type: "QColor" }
- Property { name: "font"; type: "QFont" }
- Property { name: "horizontalAlignment"; type: "HAlignment" }
- Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true }
- Property { name: "verticalAlignment"; type: "VAlignment" }
- Property { name: "wrapMode"; type: "WrapMode" }
- Property { name: "readOnly"; type: "bool" }
- Property { name: "cursorVisible"; type: "bool" }
- Property { name: "cursorPosition"; type: "int" }
- Property { name: "cursorRectangle"; type: "QRectF"; isReadonly: true }
- Property { name: "cursorDelegate"; type: "QQmlComponent"; isPointer: true }
- Property { name: "selectionStart"; type: "int"; isReadonly: true }
- Property { name: "selectionEnd"; type: "int"; isReadonly: true }
- Property { name: "selectedText"; type: "string"; isReadonly: true }
- Property { name: "maximumLength"; type: "int" }
- Property { name: "validator"; type: "QValidator"; isPointer: true }
- Property { name: "inputMask"; type: "string" }
- Property { name: "inputMethodHints"; type: "Qt::InputMethodHints" }
- Property { name: "acceptableInput"; type: "bool"; isReadonly: true }
- Property { name: "echoMode"; type: "EchoMode" }
- Property { name: "activeFocusOnPress"; type: "bool" }
- Property { name: "passwordCharacter"; type: "string" }
- Property { name: "passwordMaskDelay"; revision: 3; type: "int" }
- Property { name: "displayText"; type: "string"; isReadonly: true }
- Property { name: "preeditText"; revision: 7; type: "string"; isReadonly: true }
- Property { name: "autoScroll"; type: "bool" }
- Property { name: "selectByMouse"; type: "bool" }
- Property { name: "mouseSelectionMode"; type: "SelectionMode" }
- Property { name: "persistentSelection"; type: "bool" }
- Property { name: "canPaste"; type: "bool"; isReadonly: true }
- Property { name: "canUndo"; type: "bool"; isReadonly: true }
- Property { name: "canRedo"; type: "bool"; isReadonly: true }
- Property { name: "inputMethodComposing"; type: "bool"; isReadonly: true }
- Property { name: "contentWidth"; type: "double"; isReadonly: true }
- Property { name: "contentHeight"; type: "double"; isReadonly: true }
- Property { name: "renderType"; type: "RenderType" }
- Property { name: "padding"; revision: 6; type: "double" }
- Property { name: "topPadding"; revision: 6; type: "double" }
- Property { name: "leftPadding"; revision: 6; type: "double" }
- Property { name: "rightPadding"; revision: 6; type: "double" }
- Property { name: "bottomPadding"; revision: 6; type: "double" }
- Signal { name: "accepted" }
- Signal { name: "editingFinished"; revision: 2 }
- Signal {
- name: "fontChanged"
- Parameter { name: "font"; type: "QFont" }
- }
- Signal {
- name: "horizontalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextInput::HAlignment" }
- }
- Signal {
- name: "verticalAlignmentChanged"
- Parameter { name: "alignment"; type: "QQuickTextInput::VAlignment" }
- }
- Signal {
- name: "readOnlyChanged"
- Parameter { name: "isReadOnly"; type: "bool" }
- }
- Signal {
- name: "cursorVisibleChanged"
- Parameter { name: "isCursorVisible"; type: "bool" }
- }
- Signal {
- name: "maximumLengthChanged"
- Parameter { name: "maximumLength"; type: "int" }
- }
- Signal {
- name: "inputMaskChanged"
- Parameter { name: "inputMask"; type: "string" }
- }
- Signal {
- name: "echoModeChanged"
- Parameter { name: "echoMode"; type: "QQuickTextInput::EchoMode" }
- }
- Signal {
- name: "passwordMaskDelayChanged"
- revision: 3
- Parameter { name: "delay"; type: "int" }
- }
- Signal { name: "preeditTextChanged"; revision: 7 }
- Signal {
- name: "activeFocusOnPressChanged"
- Parameter { name: "activeFocusOnPress"; type: "bool" }
- }
- Signal {
- name: "autoScrollChanged"
- Parameter { name: "autoScroll"; type: "bool" }
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "selectByMouseChanged"
- Parameter { name: "selectByMouse"; type: "bool" }
+ name: "pressed"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
Signal {
- name: "mouseSelectionModeChanged"
- Parameter { name: "mode"; type: "QQuickTextInput::SelectionMode" }
- }
- Signal { name: "contentSizeChanged" }
- Signal { name: "paddingChanged"; revision: 6 }
- Signal { name: "topPaddingChanged"; revision: 6 }
- Signal { name: "leftPaddingChanged"; revision: 6 }
- Signal { name: "rightPaddingChanged"; revision: 6 }
- Signal { name: "bottomPaddingChanged"; revision: 6 }
- Method { name: "selectAll" }
- Method { name: "selectWord" }
- Method {
- name: "select"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "deselect" }
- Method {
- name: "isRightToLeft"
- type: "bool"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method { name: "cut" }
- Method { name: "copy" }
- Method { name: "paste" }
- Method { name: "undo" }
- Method { name: "redo" }
- Method {
- name: "insert"
- Parameter { name: "position"; type: "int" }
- Parameter { name: "text"; type: "string" }
- }
- Method {
- name: "remove"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
- }
- Method {
- name: "ensureVisible"
- revision: 3
- Parameter { name: "position"; type: "int" }
- }
- Method { name: "clear"; revision: 7 }
- Method {
- name: "positionAt"
- Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
- }
- Method {
- name: "positionToRectangle"
- type: "QRectF"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- }
- Method {
- name: "moveCursorSelection"
- Parameter { name: "pos"; type: "int" }
- Parameter { name: "mode"; type: "SelectionMode" }
- }
- Method {
- name: "inputMethodQuery"
- revision: 3
- type: "QVariant"
- Parameter { name: "query"; type: "Qt::InputMethodQuery" }
- Parameter { name: "argument"; type: "QVariant" }
- }
- Method {
- name: "getText"
- type: "string"
- Parameter { name: "start"; type: "int" }
- Parameter { name: "end"; type: "int" }
+ name: "released"
+ revision: 1
+ Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
}
}
Component {
name: "QQuickToolBar"
defaultProperty: "contentData"
- prototype: "QQuickFrame"
+ prototype: "QQuickPane"
exports: ["QtQuick.Templates/ToolBar 2.0"]
exportMetaObjectRevisions: [0]
Enum {
@@ -1702,6 +1042,16 @@ Module {
exportMetaObjectRevisions: [0]
}
Component {
+ name: "QQuickToolSeparator"
+ defaultProperty: "data"
+ prototype: "QQuickControl"
+ exports: ["QtQuick.Templates/ToolSeparator 2.1"]
+ exportMetaObjectRevisions: [0]
+ Property { name: "orientation"; type: "Qt::Orientation" }
+ Property { name: "horizontal"; type: "bool"; isReadonly: true }
+ Property { name: "vertical"; type: "bool"; isReadonly: true }
+ }
+ Component {
name: "QQuickToolTip"
defaultProperty: "contentData"
prototype: "QQuickPopup"
@@ -1711,8 +1061,6 @@ Module {
Property { name: "delay"; type: "int" }
Property { name: "timeout"; type: "int" }
Property { name: "text"; type: "string" }
- Method { name: "open" }
- Method { name: "close" }
}
Component {
name: "QQuickToolTipAttached"
@@ -1737,8 +1085,11 @@ Module {
name: "QQuickTumbler"
defaultProperty: "data"
prototype: "QQuickControl"
- exports: ["QtQuick.Templates/Tumbler 2.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtQuick.Templates/Tumbler 2.0",
+ "QtQuick.Templates/Tumbler 2.1"
+ ]
+ exportMetaObjectRevisions: [0, 1]
attachedType: "QQuickTumblerAttached"
Property { name: "model"; type: "QVariant" }
Property { name: "count"; type: "int"; isReadonly: true }
@@ -1746,6 +1097,8 @@ Module {
Property { name: "currentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "delegate"; type: "QQmlComponent"; isPointer: true }
Property { name: "visibleItemCount"; type: "int" }
+ Property { name: "wrap"; revision: 1; type: "bool" }
+ Signal { name: "wrapChanged"; revision: 1 }
}
Component {
name: "QQuickTumblerAttached"
diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp
index e93b80c7..8c0e8bcc 100644
--- a/src/imports/templates/qtquicktemplates2plugin.cpp
+++ b/src/imports/templates/qtquicktemplates2plugin.cpp
@@ -47,6 +47,8 @@
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickcontainer_p.h>
#include <QtQuickTemplates2/private/qquickdial_p.h>
+#include <QtQuickTemplates2/private/qquickdialog_p.h>
+#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>
#include <QtQuickTemplates2/private/qquickdrawer_p.h>
#include <QtQuickTemplates2/private/qquickframe_p.h>
#include <QtQuickTemplates2/private/qquickgroupbox_p.h>
@@ -54,6 +56,7 @@
#include <QtQuickTemplates2/private/qquicklabel_p.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
+#include <QtQuickTemplates2/private/qquickmenuseparator_p.h>
#include <QtQuickTemplates2/private/qquickoverlay_p.h>
#include <QtQuickTemplates2/private/qquickpage_p.h>
#include <QtQuickTemplates2/private/qquickpageindicator_p.h>
@@ -63,6 +66,7 @@
#include <QtQuickTemplates2/private/qquickradiobutton_p.h>
#include <QtQuickTemplates2/private/qquickradiodelegate_p.h>
#include <QtQuickTemplates2/private/qquickrangeslider_p.h>
+#include <QtQuickTemplates2/private/qquickroundbutton_p.h>
#include <QtQuickTemplates2/private/qquickscrollbar_p.h>
#include <QtQuickTemplates2/private/qquickscrollindicator_p.h>
#include <QtQuickTemplates2/private/qquickshortcutcontext_p_p.h>
@@ -80,6 +84,7 @@
#include <QtQuickTemplates2/private/qquicktextfield_p.h>
#include <QtQuickTemplates2/private/qquicktoolbar_p.h>
#include <QtQuickTemplates2/private/qquicktoolbutton_p.h>
+#include <QtQuickTemplates2/private/qquicktoolseparator_p.h>
#include <QtQuickTemplates2/private/qquicktooltip_p.h>
#include <QtQuickTemplates2/private/qquicktumbler_p.h>
@@ -127,6 +132,7 @@ QtQuickTemplates2Plugin::~QtQuickTemplates2Plugin()
void QtQuickTemplates2Plugin::registerTypes(const char *uri)
{
+ // QtQuick.Templates 2.0 (Qt 5.7)
qmlRegisterType<QQuickAbstractButton>(uri, 2, 0, "AbstractButton");
qmlRegisterType<QQuickApplicationWindow>(uri, 2, 0, "ApplicationWindow");
qmlRegisterType<QQuickApplicationWindowAttached>();
@@ -191,6 +197,28 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri)
qmlRegisterRevision<QQuickText, 6>(uri, 2, 0);
qmlRegisterRevision<QQuickTextInput, 7>(uri, 2, 0);
qmlRegisterRevision<QQuickTextEdit, 7>(uri, 2, 0);
+
+ // QtQuick.Templates 2.1 (Qt 5.8)
+ qmlRegisterType<QQuickButtonGroup, 1>(uri, 2, 1, "ButtonGroup");
+ qmlRegisterType<QQuickComboBox, 1>(uri, 2, 1, "ComboBox");
+ qmlRegisterType<QQuickContainer, 1>(uri, 2, 1, "Container");
+ qmlRegisterType<QQuickDialog>(uri, 2, 1, "Dialog");
+ qmlRegisterType<QQuickDialogButtonBox>(uri, 2, 1, "DialogButtonBox");
+ qmlRegisterType<QQuickDialogButtonBoxAttached>();
+ qmlRegisterType<QQuickMenuSeparator>(uri, 2, 1, "MenuSeparator");
+ qmlRegisterType<QQuickPage, 1>(uri, 2, 1, "Page");
+ qmlRegisterType<QQuickPopup, 1>(uri, 2, 1, "Popup");
+ qmlRegisterType<QQuickRangeSlider, 1>(uri, 2, 1, "RangeSlider");
+ qmlRegisterType<QQuickRoundButton, 1>(uri, 2, 1, "RoundButton");
+ qmlRegisterType<QQuickSlider, 1>(uri, 2, 1, "Slider");
+ qmlRegisterType<QQuickSpinBox, 1>(uri, 2, 1, "SpinBox");
+ qmlRegisterType<QQuickStackView, 1>(uri, 2, 1, "StackView");
+ qmlRegisterType<QQuickSwipeDelegate, 1>(uri, 2, 1, "SwipeDelegate");
+ qmlRegisterType<QQuickSwipeView, 1>(uri, 2, 1, "SwipeView");
+ qmlRegisterType<QQuickTextArea, 1>(uri, 2, 1, "TextArea");
+ qmlRegisterType<QQuickTextField, 1>(uri, 2, 1, "TextField");
+ qmlRegisterType<QQuickToolSeparator>(uri, 2, 1, "ToolSeparator");
+ qmlRegisterType<QQuickTumbler, 1>(uri, 2, 1, "Tumbler");
}
QT_END_NAMESPACE
diff --git a/src/imports/templates/templates.pro b/src/imports/templates/templates.pro
index 8785734a..3640f6d1 100644
--- a/src/imports/templates/templates.pro
+++ b/src/imports/templates/templates.pro
@@ -1,6 +1,6 @@
TARGET = qtquicktemplates2plugin
TARGETPATH = QtQuick/Templates.2
-IMPORT_VERSION = 2.0
+IMPORT_VERSION = 2.1
QT += qml quick
QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2-private
diff --git a/src/quickcontrols2/qquickpaddedrectangle.cpp b/src/quickcontrols2/qquickpaddedrectangle.cpp
index 08d74dc6..28423f51 100644
--- a/src/quickcontrols2/qquickpaddedrectangle.cpp
+++ b/src/quickcontrols2/qquickpaddedrectangle.cpp
@@ -184,7 +184,7 @@ QSGNode *QQuickPaddedRectangle::updatePaintNode(QSGNode *node, UpdatePaintNodeDa
if (!transformNode)
transformNode = new QSGTransformNode;
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(QQuickRectangle::updatePaintNode(transformNode->firstChild(), data));
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(QQuickRectangle::updatePaintNode(transformNode->firstChild(), data));
if (rectNode) {
if (!transformNode->firstChild())
diff --git a/src/quickcontrols2/qquickproxytheme.cpp b/src/quickcontrols2/qquickproxytheme.cpp
index da4f2a2e..3791bb06 100644
--- a/src/quickcontrols2/qquickproxytheme.cpp
+++ b/src/quickcontrols2/qquickproxytheme.cpp
@@ -137,11 +137,11 @@ QPixmap QQuickProxyTheme::standardPixmap(QPlatformTheme::StandardPixmap sp, cons
return QPlatformTheme::standardPixmap(sp, size);
}
-QPixmap QQuickProxyTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, QPlatformTheme::IconOptions iconOptions) const
+QIcon QQuickProxyTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
{
if (m_theme)
- return m_theme->fileIconPixmap(fileInfo, size, iconOptions);
- return QPlatformTheme::fileIconPixmap(fileInfo, size, iconOptions);
+ return m_theme->fileIcon(fileInfo, iconOptions);
+ return QPlatformTheme::fileIcon(fileInfo, iconOptions);
}
QIconEngine *QQuickProxyTheme::createIconEngine(const QString &iconName) const
diff --git a/src/quickcontrols2/qquickproxytheme_p.h b/src/quickcontrols2/qquickproxytheme_p.h
index c94417dc..c2cec4f7 100644
--- a/src/quickcontrols2/qquickproxytheme_p.h
+++ b/src/quickcontrols2/qquickproxytheme_p.h
@@ -80,8 +80,7 @@ public:
QVariant themeHint(ThemeHint hint) const override;
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override;
- QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions = 0) const override;
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = 0) const override;
QIconEngine *createIconEngine(const QString &iconName) const override;
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp
index 143f599a..3ad7c074 100644
--- a/src/quickcontrols2/qquickstyle.cpp
+++ b/src/quickcontrols2/qquickstyle.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquickstyle.h"
+#include "qquickstyle_p.h"
#include "qquickstyleattached_p.h"
#include <QtCore/qdir.h>
@@ -80,6 +81,19 @@ QT_BEGIN_NAMESPACE
Qt Quick Controls 2. It is not possible to change the style after the QML
types have been registered.
+ The style can also be specified as a path to a custom style, such as
+ \c ":/mystyle". See \l {Creating a Custom Style} for more details about
+ building custom styles. Custom styles do not need to implement all controls.
+ By default, the styling system uses the \l {Default style} as a fallback
+ for controls that a custom style does not provide. It is possible to
+ specify a different fallback style to customize or extend one of the
+ built-in styles.
+
+ \code
+ QQuickStyle::setStyle(":/mystyle");
+ QQuickStyle::setFallbackStyle("Material");
+ \endcode
+
\sa {Styling Qt Quick Controls 2}
*/
@@ -102,7 +116,7 @@ static QStringList defaultImportPathList()
struct QQuickStyleSpec
{
- QQuickStyleSpec() : resolved(false) { }
+ QQuickStyleSpec() : custom(false), resolved(false) { }
QString name()
{
@@ -128,54 +142,155 @@ struct QQuickStyleSpec
resolve();
}
- void resolve()
+ void setFallbackStyle(const QString &fallback, const QByteArray &method)
+ {
+ fallbackStyle = fallback;
+ fallbackMethod = method;
+ }
+
+ static QString findStyle(const QString &path, const QString &name)
+ {
+ QDir dir(path);
+ if (!dir.exists())
+ return QString();
+
+ if (name.isEmpty())
+ return dir.absolutePath() + QLatin1Char('/');
+
+ const QStringList entries = dir.entryList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
+ for (const QString &entry : entries) {
+ if (entry.compare(name, Qt::CaseInsensitive) == 0)
+ return dir.absoluteFilePath(entry);
+ }
+
+ return QString();
+ }
+
+ void resolve(const QUrl &baseUrl = QUrl())
{
if (style.isEmpty())
style = QGuiApplicationPrivate::styleOverride;
if (style.isEmpty())
style = QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_STYLE"));
- if (style.isEmpty()) {
+ if (fallbackStyle.isEmpty())
+ setFallbackStyle(QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE")), "QT_QUICK_CONTROLS_FALLBACK_STYLE");
+ if (style.isEmpty() || fallbackStyle.isEmpty()) {
QSharedPointer<QSettings> settings = QQuickStyleAttached::settings(QStringLiteral("Controls"));
- if (settings)
- style = settings->value(QStringLiteral("Style")).toString();
+ if (settings) {
+ if (style.isEmpty())
+ style = settings->value(QStringLiteral("Style")).toString();
+ if (fallbackStyle.isEmpty())
+ setFallbackStyle(settings->value(QStringLiteral("FallbackStyle")).toString(), ":/qtquickcontrols2.conf");
+ }
+ }
+
+ // resolve a path relative to the config
+ QString configPath = QFileInfo(resolveConfigFilePath()).path();
+ QString stylePath = findStyle(configPath, style);
+ if (!stylePath.isEmpty()) {
+ style = stylePath;
+ resolved = true;
+ }
+
+ custom = style.contains(QLatin1Char('/'));
+
+ if (baseUrl.isValid()) {
+ QString path = QQmlFile::urlToLocalFileOrQrc(baseUrl);
+ QString stylePath = findStyle(path, style);
+ if (!stylePath.isEmpty()) {
+ style = stylePath;
+ resolved = true;
+ }
}
if (QGuiApplication::instance()) {
- if (!style.contains(QLatin1Char('/'))) {
+ if (!custom) {
const QString targetPath = QStringLiteral("QtQuick/Controls.2");
const QStringList importPaths = defaultImportPathList();
for (const QString &importPath : importPaths) {
- QDir importDir(importPath);
- if (importDir.cd(targetPath)) {
- if (style.isEmpty()) {
- style = importDir.absolutePath() + QLatin1Char('/');
- resolved = true;
- break;
- }
- const QStringList entries = importDir.entryList(QStringList(), QDir::Dirs | QDir::NoDotAndDotDot);
- for (const QString &entry : entries) {
- if (entry.compare(style, Qt::CaseInsensitive) == 0) {
- style = importDir.absoluteFilePath(entry);
- resolved = true;
- break;
- }
- }
- }
- if (resolved)
+ QString stylePath = findStyle(importPath + QLatin1Char('/') + targetPath, style);
+ if (!stylePath.isEmpty()) {
+ style = stylePath;
+ resolved = true;
break;
+ }
}
}
resolved = true;
}
}
+ void reset()
+ {
+ custom = false;
+ resolved = false;
+ style.clear();
+ fallbackStyle.clear();
+ fallbackMethod.clear();
+ }
+
+ QString resolveConfigFilePath()
+ {
+ if (configFilePath.isEmpty()) {
+ configFilePath = QFile::decodeName(qgetenv("QT_QUICK_CONTROLS_CONF"));
+ if (!QFile::exists(configFilePath)) {
+ if (!configFilePath.isEmpty())
+ qWarning("QT_QUICK_CONTROLS_CONF=%s: No such file", qPrintable(configFilePath));
+
+ configFilePath = QStringLiteral(":/qtquickcontrols2.conf");
+ }
+ }
+ return configFilePath;
+ }
+
+ bool custom;
bool resolved;
QString style;
+ QString fallbackStyle;
+ QByteArray fallbackMethod;
+ QString configFilePath;
};
Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec)
+QString QQuickStylePrivate::fallbackStyle()
+{
+ return styleSpec()->fallbackStyle;
+}
+
+bool QQuickStylePrivate::isCustomStyle()
+{
+ return styleSpec()->custom;
+}
+
+void QQuickStylePrivate::init(const QUrl &baseUrl)
+{
+ QQuickStyleSpec *spec = styleSpec();
+ spec->resolve(baseUrl);
+
+ if (!spec->fallbackStyle.isEmpty()) {
+ QString fallbackStyle = spec->findStyle(baseUrl.toLocalFile(), spec->fallbackStyle);
+ if (fallbackStyle.isEmpty()) {
+ if (spec->fallbackStyle.compare(QStringLiteral("Default")) != 0) {
+ qWarning() << "ERROR: unable to locate fallback style" << spec->fallbackStyle;
+ qInfo().nospace().noquote() << spec->fallbackMethod << ": the fallback style must be the name of one of the built-in Qt Quick Controls 2 styles.";
+ }
+ spec->fallbackStyle.clear();
+ }
+ }
+}
+
+void QQuickStylePrivate::reset()
+{
+ styleSpec()->reset();
+}
+
+QString QQuickStylePrivate::configFilePath()
+{
+ return styleSpec()->resolveConfigFilePath();
+}
+
/*!
Returns the name of the application style.
@@ -217,4 +332,26 @@ void QQuickStyle::setStyle(const QString &style)
styleSpec()->setStyle(style);
}
+/*!
+ \since 5.8
+ Sets the application fallback style to \a style.
+
+ \note The fallback style must be the name of one of the built-in Qt Quick Controls 2 styles, e.g. "Material".
+
+ \note The style must be configured \b before loading QML that imports Qt Quick Controls 2.
+ It is not possible to change the style after the QML types have been registered.
+
+ The fallback style can be also specified by setting the \c QT_QUICK_CONTROLS_FALLBACK_STYLE
+ \l {Supported Environment Variables in Qt Quick Controls 2}{environment variable}.
+*/
+void QQuickStyle::setFallbackStyle(const QString &style)
+{
+ if (QQmlMetaType::isModule(QStringLiteral("QtQuick.Controls"), 2, 0)) {
+ qWarning() << "ERROR: QQuickStyle::setFallbackStyle() must be called before loading QML that imports Qt Quick Controls 2.";
+ return;
+ }
+
+ styleSpec()->setFallbackStyle(style, "QQuickStyle::setFallbackStyle()");
+}
+
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyle.h b/src/quickcontrols2/qquickstyle.h
index 4476a29a..d2e7faf1 100644
--- a/src/quickcontrols2/qquickstyle.h
+++ b/src/quickcontrols2/qquickstyle.h
@@ -49,6 +49,7 @@ public:
static QString name();
static QString path();
static void setStyle(const QString &style);
+ static void setFallbackStyle(const QString &style);
};
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyle_p.h b/src/quickcontrols2/qquickstyle_p.h
new file mode 100644
index 00000000..65f48d95
--- /dev/null
+++ b/src/quickcontrols2/qquickstyle_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSTYLE_P_H
+#define QQUICKSTYLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qurl.h>
+#include <QtQuickControls2/private/qtquickcontrols2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickStylePrivate
+{
+public:
+ static QString fallbackStyle();
+ static bool isCustomStyle();
+ static void init(const QUrl &baseUrl);
+ static void reset();
+ static QString configFilePath();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSTYLE_P_H
diff --git a/src/quickcontrols2/qquickstyleattached.cpp b/src/quickcontrols2/qquickstyleattached.cpp
index e72abde0..d1f27ff3 100644
--- a/src/quickcontrols2/qquickstyleattached.cpp
+++ b/src/quickcontrols2/qquickstyleattached.cpp
@@ -35,16 +35,38 @@
****************************************************************************/
#include "qquickstyleattached_p.h"
+#include "qquickstyle_p.h"
#include <QtCore/qfile.h>
#include <QtCore/qsettings.h>
#include <QtCore/qfileselector.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qpalette.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
#include <QtQuick/qquickwindow.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
QT_BEGIN_NAMESPACE
+static bool isDarkSystemTheme()
+{
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
+ if (const QPalette *systemPalette = theme->palette(QPlatformTheme::SystemPalette)) {
+ const QColor textColor = systemPalette->color(QPalette::WindowText);
+ return textColor.red() > 128 && textColor.blue() > 128 && textColor.green() > 128;
+ }
+ }
+ return false;
+}
+
+Q_QUICKCONTROLS2_PRIVATE_EXPORT bool qt_is_dark_system_theme()
+{
+ static bool dark = isDarkSystemTheme();
+ return dark;
+}
+
static QQuickStyleAttached *attachedStyle(const QMetaObject *type, QObject *object, bool create = false)
{
if (!object)
@@ -146,18 +168,6 @@ static QList<QQuickStyleAttached *> findChildStyles(const QMetaObject *type, QOb
return children;
}
-static QString resolveConfigFile()
-{
- QString filePath = QFile::decodeName(qgetenv("QT_QUICK_CONTROLS_CONF"));
- if (!QFile::exists(filePath)) {
- if (!filePath.isEmpty())
- qWarning("QT_QUICK_CONTROLS_CONF=%s: No such file", qPrintable(filePath));
-
- filePath = QStringLiteral(":/qtquickcontrols2.conf");
- }
- return filePath;
-}
-
QQuickStyleAttached::QQuickStyleAttached(QObject *parent) : QObject(parent)
{
QQuickItem *item = qobject_cast<QQuickItem *>(parent);
@@ -187,7 +197,7 @@ QQuickStyleAttached::~QQuickStyleAttached()
QSharedPointer<QSettings> QQuickStyleAttached::settings(const QString &group)
{
#ifndef QT_NO_SETTINGS
- static const QString filePath = resolveConfigFile();
+ const QString filePath = QQuickStylePrivate::configFilePath();
if (QFile::exists(filePath)) {
QFileSelector selector;
QSettings *settings = new QSettings(selector.select(filePath), QSettings::IniFormat);
diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp
index 5210a684..8dbbc064 100644
--- a/src/quickcontrols2/qquickstyleselector.cpp
+++ b/src/quickcontrols2/qquickstyleselector.cpp
@@ -35,12 +35,14 @@
#include "qquickstyleselector_p.h"
#include "qquickstyleselector_p_p.h"
#include "qquickstyle.h"
+#include "qquickstyle_p.h"
#include <QtCore/qdir.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qlocale.h>
+#include <QtQml/qqmlfile.h>
#include <QtCore/private/qfileselector_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -56,6 +58,13 @@ static bool isLocalScheme(const QString &scheme)
return local;
}
+static QString ensureSlash(const QString &path)
+{
+ if (path.endsWith(QLatin1Char('/')))
+ return path;
+ return path + QLatin1Char('/');
+}
+
static QStringList allSelectors(const QString &style = QString())
{
static const QStringList platformSelectors = QFileSelectorPrivate::platformSelectors();
@@ -66,33 +75,6 @@ static QStringList allSelectors(const QString &style = QString())
return selectors;
}
-static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
-{
- /* selectionHelper does a depth-first search of possible selected files. Because there is strict
- selector ordering in the API, we can stop checking as soon as we find the file in a directory
- which does not contain any other valid selector directories.
- */
- Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
-
- for (const QString &s : selectors) {
- QString prospectiveBase = path + s + QLatin1Char('/');
- QStringList remainingSelectors = selectors;
- remainingSelectors.removeAll(s);
- if (!QDir(prospectiveBase).exists())
- continue;
- QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
- if (!prospectiveFile.isEmpty())
- return prospectiveFile;
- }
-
- // If we reach here there were no successful files found at a lower level in this branch, so we
- // should check this level as a potential result.
- const QString result = path + fileName;
- if (!QFileInfo::exists(result))
- return QString();
- return result;
-}
-
QString QQuickStyleSelectorPrivate::select(const QString &filePath) const
{
QFileInfo fi(filePath);
@@ -101,18 +83,35 @@ QString QQuickStyleSelectorPrivate::select(const QString &filePath) const
return filePath;
const QString path = fi.path();
- const QString ret = selectionHelper(path.isEmpty() ? QString() : path + QLatin1Char('/'),
- fi.fileName(), allSelectors(style));
+ const QString ret = QFileSelectorPrivate::selectionHelper(path.isEmpty() ? QString() : path + QLatin1Char('/'),
+ fi.fileName(), allSelectors(styleName), QChar());
if (!ret.isEmpty())
return ret;
return filePath;
}
+QString QQuickStyleSelectorPrivate::trySelect(const QString &filePath, const QString &fallback) const
+{
+ QFileInfo fi(filePath);
+ if (!fi.exists())
+ return fallback;
+
+ // the path contains the name of the custom/fallback style, so exclude it from
+ // the selectors. the rest of the selectors (os, locale) are still valid, though.
+ const QString path = fi.path();
+ const QString selectedPath = QFileSelectorPrivate::selectionHelper(path.isEmpty() ? QString() : path + QLatin1Char('/'),
+ fi.fileName(), allSelectors(), QChar());
+ if (selectedPath.startsWith(QLatin1Char(':')))
+ return QLatin1String("qrc") + selectedPath;
+ return QUrl::fromLocalFile(QFileInfo(selectedPath).absoluteFilePath()).toString();
+}
+
QQuickStyleSelector::QQuickStyleSelector() : d_ptr(new QQuickStyleSelectorPrivate)
{
Q_D(QQuickStyleSelector);
- d->style = QQuickStyle::name();
+ d->styleName = QQuickStyle::name();
+ d->stylePath = QQuickStyle::path();
}
QQuickStyleSelector::~QQuickStyleSelector()
@@ -129,29 +128,32 @@ void QQuickStyleSelector::setBaseUrl(const QUrl &url)
{
Q_D(QQuickStyleSelector);
d->baseUrl = url;
+ d->basePath = QQmlFile::urlToLocalFileOrQrc(url.toString(QUrl::StripTrailingSlash) + QLatin1Char('/'));
}
QString QQuickStyleSelector::select(const QString &fileName) const
{
Q_D(const QQuickStyleSelector);
- const QString overridePath = QQuickStyle::path();
- if (!overridePath.isEmpty()) {
- const QString stylePath = overridePath + d->style + QLatin1Char('/');
- if (QFile::exists(stylePath + fileName)) {
- // the style name is included to the path, so exclude it from the selectors.
- // the rest of the selectors (os, locale) are still valid, though.
- const QString selectedPath = selectionHelper(stylePath, fileName, allSelectors());
- if (selectedPath.startsWith(QLatin1Char(':')))
- return QLatin1String("qrc") + selectedPath;
- return QUrl::fromLocalFile(QFileInfo(selectedPath).absoluteFilePath()).toString();
- }
+
+ // 1) try selecting from a custom style path, for example ":/mystyle"
+ if (QQuickStylePrivate::isCustomStyle()) {
+ // NOTE: this path may contain a subset of controls
+ const QString selectedPath = d->trySelect(ensureSlash(d->stylePath) + d->styleName + QLatin1Char('/') + fileName);
+ if (!selectedPath.isEmpty())
+ return selectedPath;
}
- QString base = d->baseUrl.toString();
- if (!base.isEmpty() && !base.endsWith(QLatin1Char('/')))
- base += QLatin1Char('/');
+ // 2) try selecting from the fallback style path, for example QT_INSTALL_QML/QtQuick/Controls.2/Material
+ const QString fallbackStyle = QQuickStylePrivate::fallbackStyle();
+ if (!fallbackStyle.isEmpty()) {
+ // NOTE: this path may also contain a subset of controls
+ const QString selectedPath = d->trySelect(ensureSlash(d->basePath) + fallbackStyle + QLatin1Char('/') + fileName);
+ if (!selectedPath.isEmpty())
+ return selectedPath;
+ }
- QUrl url(base + fileName);
+ // 3) fallback to the default style that is guaranteed to contain all controls
+ QUrl url(ensureSlash(d->baseUrl.toString()) + fileName);
if (isLocalScheme(url.scheme())) {
QString equivalentPath = QLatin1Char(':') + url.path();
QString selectedPath = d->select(equivalentPath);
diff --git a/src/quickcontrols2/qquickstyleselector_p_p.h b/src/quickcontrols2/qquickstyleselector_p_p.h
index cc3f0a58..4ff28d5d 100644
--- a/src/quickcontrols2/qquickstyleselector_p_p.h
+++ b/src/quickcontrols2/qquickstyleselector_p_p.h
@@ -54,9 +54,12 @@ class QQuickStyleSelectorPrivate
{
public:
QString select(const QString &filePath) const;
+ QString trySelect(const QString &filePath, const QString &fallback = QString()) const;
QUrl baseUrl;
- QString style;
+ QString basePath;
+ QString styleName;
+ QString stylePath;
};
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp
new file mode 100644
index 00000000..540a8dd1
--- /dev/null
+++ b/src/quickcontrols2/qquicktumblerview.cpp
@@ -0,0 +1,273 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktumblerview_p.h"
+
+#include <QtQml/private/qqmldelegatemodel_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
+#include <QtQuick/private/qquickpathview_p.h>
+
+#include <QtQuickTemplates2/private/qquicktumbler_p.h>
+#include <QtQuickTemplates2/private/qquicktumbler_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickTumblerView::QQuickTumblerView(QQuickItem *parent) :
+ QQuickItem(parent),
+ m_tumbler(nullptr),
+ m_delegate(nullptr),
+ m_pathView(nullptr),
+ m_listView(nullptr),
+ m_path(nullptr)
+{
+ // We don't call createView() here because we don't know what the wrap flag is set to
+ // yet, and we don't want to create a view that might never get used.
+}
+
+QVariant QQuickTumblerView::model() const
+{
+ return m_model;
+}
+
+void QQuickTumblerView::setModel(const QVariant &model)
+{
+ if (model == m_model)
+ return;
+
+ m_model = model;
+
+ if (m_pathView) {
+ m_pathView->setModel(m_model);
+ } else if (m_listView) {
+ // QQuickItemView::setModel() resets the current index,
+ // but if we're still creating the Tumbler, it should be maintained.
+ const int oldCurrentIndex = m_listView->currentIndex();
+ m_listView->setModel(m_model);
+ if (!isComponentComplete())
+ m_listView->setCurrentIndex(oldCurrentIndex);
+ }
+
+ emit modelChanged();
+}
+
+QQmlComponent *QQuickTumblerView::delegate() const
+{
+ return m_delegate;
+}
+
+void QQuickTumblerView::setDelegate(QQmlComponent *delegate)
+{
+ if (delegate == m_delegate)
+ return;
+
+ m_delegate = delegate;
+
+ if (m_pathView)
+ m_pathView->setDelegate(m_delegate);
+ else if (m_listView)
+ m_listView->setDelegate(m_delegate);
+
+ emit delegateChanged();
+}
+
+QQuickPath *QQuickTumblerView::path() const
+{
+ return m_path;
+}
+
+void QQuickTumblerView::setPath(QQuickPath *path)
+{
+ if (path == m_path)
+ return;
+
+ m_path = path;
+ emit pathChanged();
+}
+
+void QQuickTumblerView::createView()
+{
+ Q_ASSERT(m_tumbler);
+
+ // We create a view regardless of whether or not we know
+ // the count yet, because we rely on the view to tell us the count.
+ if (m_tumbler->wrap()) {
+ if (m_listView) {
+ delete m_listView;
+ m_listView = nullptr;
+ }
+
+ if (!m_pathView) {
+ m_pathView = new QQuickPathView;
+ QQmlEngine::setContextForObject(m_pathView, qmlContext(this));
+ QQml_setParent_noEvent(m_pathView, this);
+ m_pathView->setParentItem(this);
+ m_pathView->setPath(m_path);
+ m_pathView->setDelegate(m_delegate);
+ m_pathView->setPreferredHighlightBegin(0.5);
+ m_pathView->setPreferredHighlightEnd(0.5);
+ m_pathView->setClip(true);
+
+ // Give the view a size.
+ updateView();
+ // Ensure that the model is set eventually.
+ polish();
+ }
+ } else {
+ if (m_pathView) {
+ delete m_pathView;
+ m_pathView = nullptr;
+ }
+
+ if (!m_listView) {
+ m_listView = new QQuickListView;
+ QQmlEngine::setContextForObject(m_listView, qmlContext(this));
+ QQml_setParent_noEvent(m_listView, this);
+ m_listView->setParentItem(this);
+ m_listView->setSnapMode(QQuickListView::SnapToItem);
+ m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ m_listView->setClip(true);
+ m_listView->setDelegate(m_delegate);
+
+ // Give the view a size.
+ updateView();
+ // Ensure that the model is set eventually.
+ polish();
+ }
+ }
+}
+
+// Called whever the size or visibleItemCount changes.
+void QQuickTumblerView::updateView()
+{
+ QQuickItem *theView = view();
+ if (!theView)
+ return;
+
+ theView->setSize(QSizeF(width(), height()));
+
+ // Can be called in geometryChanged when it might not have a parent item yet.
+ if (!m_tumbler)
+ return;
+
+ // Set view-specific properties that have a dependency on the size, etc.
+ if (m_pathView) {
+ m_pathView->setPathItemCount(m_tumbler->visibleItemCount() + 1);
+ m_pathView->setDragMargin(width() / 2);
+ } else {
+ m_listView->setPreferredHighlightBegin(height() / 2 - (height() / m_tumbler->visibleItemCount() / 2));
+ m_listView->setPreferredHighlightEnd(height() / 2 + (height() / m_tumbler->visibleItemCount() / 2));
+ }
+}
+
+void QQuickTumblerView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ updateView();
+}
+
+void QQuickTumblerView::componentComplete()
+{
+ QQuickItem::componentComplete();
+ updateView();
+}
+
+void QQuickTumblerView::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
+{
+ QQuickItem::itemChange(change, data);
+
+ if (change == QQuickItem::ItemParentHasChanged && data.item) {
+ if (m_tumbler)
+ m_tumbler->disconnect(this);
+
+ m_tumbler = qobject_cast<QQuickTumbler*>(parentItem());
+
+ if (m_tumbler) {
+ // We assume that the parentChanged() signal of the tumbler will be emitted before its wrap property is set...
+ connect(m_tumbler, &QQuickTumbler::wrapChanged, this, &QQuickTumblerView::createView);
+ connect(m_tumbler, &QQuickTumbler::visibleItemCountChanged, this, &QQuickTumblerView::updateView);
+ }
+ }
+}
+
+void QQuickTumblerView::updatePolish()
+{
+ // There are certain cases where model count changes can potentially cause problems.
+ // An example of this is a ListModel that appends items in a for loop in Component.onCompleted.
+ // If we didn't delay assignment of the model, the PathView/ListView would be deleted in
+ // response to it emitting countChanged(), causing a crash. To avoid this issue,
+ // and to avoid the overhead of count affecting the wrap property, which in turn may
+ // unnecessarily create delegates that are never seen, we delay setting the model. This ensures that
+ // Component.onCompleted would have been finished, for example.
+ if (m_pathView && !m_pathView->model().isValid() && m_model.isValid()) {
+ // QQuickPathView::setPathItemCount() resets the offset animation,
+ // so we just skip the animation while constructing the view.
+ const int oldHighlightMoveDuration = m_pathView->highlightMoveDuration();
+ m_pathView->setHighlightMoveDuration(0);
+
+ // Setting model can change the count, which can affect the wrap, which can cause
+ // the current view to be deleted before setModel() is finished, which causes a crash.
+ // Since QQuickTumbler can't know about QQuickTumblerView, we use its private API to
+ // inform it that it should delay setting wrap.
+ QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(m_tumbler);
+ tumblerPrivate->lockWrap();
+ m_pathView->setModel(m_model);
+ tumblerPrivate->unlockWrap();
+
+ // The count-depends-on-wrap behavior could cause wrap to change after
+ // the call above, so we must check that we're still using a PathView.
+ if (m_pathView)
+ m_pathView->setHighlightMoveDuration(oldHighlightMoveDuration);
+ } else if (m_listView && !m_listView->model().isValid() && m_model.isValid()) {
+ // Usually we'd do this in QQuickTumbler::setWrap(), but that will be too early for polishes.
+ const int currentIndex = m_tumbler->currentIndex();
+ m_listView->setModel(m_model);
+ m_listView->setCurrentIndex(currentIndex);
+ }
+}
+
+QQuickItem *QQuickTumblerView::view()
+{
+ if (!m_tumbler)
+ return nullptr;
+
+ if (m_tumbler->wrap())
+ return m_pathView;
+
+ return m_listView;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquicktumblerview_p.h b/src/quickcontrols2/qquicktumblerview_p.h
new file mode 100644
index 00000000..f3ba3721
--- /dev/null
+++ b/src/quickcontrols2/qquicktumblerview_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTUMBLERVIEW_P_H
+#define QQUICKTUMBLERVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QQuickItem>
+#include <QtQuickControls2/private/qtquickcontrols2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickListView;
+class QQuickPath;
+class QQuickPathView;
+
+class QQuickTumbler;
+
+class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickTumblerView : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(QQuickPath *path READ path WRITE setPath NOTIFY pathChanged)
+
+public:
+ QQuickTumblerView(QQuickItem *parent = nullptr);
+
+ QVariant model() const;
+ void setModel(const QVariant &model);
+
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
+ QQuickPath *path() const;
+ void setPath(QQuickPath *path);
+
+Q_SIGNALS:
+ void modelChanged();
+ void delegateChanged();
+ void pathChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void componentComplete() override;
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
+ void updatePolish() override;
+
+private:
+ QQuickItem *view();
+ void createView();
+ void updateView();
+
+ void wrapChange();
+
+ QQuickTumbler *m_tumbler;
+ QVariant m_model;
+ QQmlComponent *m_delegate;
+ QQuickPathView *m_pathView;
+ QQuickListView *m_listView;
+ QQuickPath *m_path;
+};
+
+QT_END_NAMESPACE
+
+#endif // TUMBLERVIEW_H
diff --git a/src/quickcontrols2/quickcontrols2.pri b/src/quickcontrols2/quickcontrols2.pri
index aaf01ed6..8e4e0046 100644
--- a/src/quickcontrols2/quickcontrols2.pri
+++ b/src/quickcontrols2/quickcontrols2.pri
@@ -2,11 +2,13 @@ HEADERS += \
$$PWD/qquickcolorimageprovider_p.h \
$$PWD/qquickproxytheme_p.h \
$$PWD/qquickstyle.h \
+ $$PWD/qquickstyle_p.h \
$$PWD/qquickstyleattached_p.h \
$$PWD/qquickstyleplugin_p.h \
$$PWD/qquickstyleselector_p.h \
$$PWD/qquickstyleselector_p_p.h \
- $$PWD/qquickpaddedrectangle_p.h
+ $$PWD/qquickpaddedrectangle_p.h \
+ $$PWD/qquicktumblerview_p.h
SOURCES += \
$$PWD/qquickcolorimageprovider.cpp \
@@ -15,4 +17,5 @@ SOURCES += \
$$PWD/qquickstyleattached.cpp \
$$PWD/qquickstyleplugin.cpp \
$$PWD/qquickstyleselector.cpp \
- $$PWD/qquickpaddedrectangle.cpp
+ $$PWD/qquickpaddedrectangle.cpp \
+ $$PWD/qquicktumblerview.cpp
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 75854d04..67fa7704 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -330,6 +330,8 @@ void QQuickAbstractButton::setPressed(bool isPressed)
\qmlproperty bool QtQuick.Controls::AbstractButton::checked
This property holds whether the button is checked.
+
+ \sa checkable
*/
bool QQuickAbstractButton::isChecked() const
{
@@ -352,11 +354,21 @@ void QQuickAbstractButton::setChecked(bool checked)
emit checkedChanged();
}
-// We define these in QQuickAbstractButton without exposing checkable as a
-// property, and instead expose it as a property in QQuickButton.
-// QQuickRadioButton, QQuickSwitch and QQuickCheckBox are checkable by default,
-// but if we removed the checkable code from here, they'd each have to
-// duplicate it.
+/*!
+ \qmlproperty bool QtQuick.Controls::AbstractButton::checkable
+
+ This property holds whether the button is checkable.
+
+ A checkable button toggles between checked (on) and unchecked (off) when
+ the user clicks on it or presses the space bar while the button has active
+ focus.
+
+ Setting \l checked to \c true forces this property to \c true.
+
+ The default value is \c false.
+
+ \sa checked
+*/
bool QQuickAbstractButton::isCheckable() const
{
Q_D(const QQuickAbstractButton);
@@ -372,6 +384,7 @@ void QQuickAbstractButton::setCheckable(bool checkable)
d->checkable = checkable;
setAccessibleProperty("checkable", checkable);
checkableChange();
+ emit checkableChanged();
}
/*!
@@ -474,8 +487,8 @@ void QQuickAbstractButton::keyPressEvent(QKeyEvent *event)
Q_D(QQuickAbstractButton);
QQuickControl::keyPressEvent(event);
if (event->key() == Qt::Key_Space) {
- setPressed(true);
d->pressPoint = QPoint(qRound(width() / 2), qRound(height() / 2));
+ setPressed(true);
if (d->autoRepeat) {
d->startRepeatDelay();
@@ -506,8 +519,8 @@ void QQuickAbstractButton::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickAbstractButton);
QQuickControl::mousePressEvent(event);
- setPressed(true);
d->pressPoint = event->pos();
+ setPressed(true);
emit pressed();
@@ -540,7 +553,7 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
bool wasPressed = d->pressed;
setPressed(false);
- if (d->keepPressed || contains(event->pos()))
+ if (!d->wasHeld && (d->keepPressed || contains(event->pos())))
nextCheckState();
if (wasPressed) {
diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
index 779739de..97b5c06b 100644
--- a/src/quicktemplates2/qquickabstractbutton_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p.h
@@ -61,6 +61,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr
Q_PROPERTY(bool down READ isDown WRITE setDown NOTIFY downChanged RESET resetDown FINAL)
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL)
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL)
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
@@ -107,6 +108,7 @@ Q_SIGNALS:
void downChanged();
void pressedChanged();
void checkedChanged();
+ void checkableChanged();
void autoExclusiveChanged();
void indicatorChanged();
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index 8138a61d..688ad804 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
class QQuickButtonGroup;
-class QQuickAbstractButtonPrivate : public QQuickControlPrivate
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButtonPrivate : public QQuickControlPrivate
{
Q_DECLARE_PUBLIC(QQuickAbstractButton)
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index 3a454353..87dc8816 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -42,6 +42,7 @@
#include "qquicktextfield_p.h"
#include "qquicktoolbar_p.h"
#include "qquicktabbar_p.h"
+#include "qquickdialogbuttonbox_p.h"
#include <QtCore/private/qobject_p.h>
#include <QtQuick/private/qquickitem_p.h>
@@ -68,7 +69,7 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-applicationwindow-wireframe.png
\qml
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
visible: true
@@ -153,7 +154,7 @@ public:
void relayout();
- void itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
void itemVisibilityChanged(QQuickItem *item) override;
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
@@ -223,11 +224,11 @@ void QQuickApplicationWindowPrivate::relayout()
}
}
-void QQuickApplicationWindowPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect)
+void QQuickApplicationWindowPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff)
{
Q_UNUSED(item)
- Q_UNUSED(newRect)
- Q_UNUSED(oldRect)
+ Q_UNUSED(change)
+ Q_UNUSED(diff)
relayout();
}
@@ -357,8 +358,9 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background)
}
\endcode
- \note Assigning a ToolBar or TabBar as a window header sets the respective
- \l ToolBar::position or \l TabBar::position property automatically to \c Header.
+ \note Assigning a ToolBar, TabBar, or DialogButtonBox as a window header
+ automatically sets the respective \l ToolBar::position, \l TabBar::position,
+ or \l DialogButtonBox::position property to \c Header.
\sa footer, Page::header
*/
@@ -391,6 +393,8 @@ void QQuickApplicationWindow::setHeader(QQuickItem *header)
toolBar->setPosition(QQuickToolBar::Header);
else if (QQuickTabBar *tabBar = qobject_cast<QQuickTabBar *>(header))
tabBar->setPosition(QQuickTabBar::Header);
+ else if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(header))
+ buttonBox->setPosition(QQuickDialogButtonBox::Header);
}
if (isComponentComplete())
d->relayout();
@@ -411,8 +415,9 @@ void QQuickApplicationWindow::setHeader(QQuickItem *header)
}
\endcode
- \note Assigning a ToolBar or TabBar as a window footer sets the respective
- \l ToolBar::position or \l TabBar::position property automatically to \c Footer.
+ \note Assigning a ToolBar, TabBar, or DialogButtonBox as a window footer
+ automatically sets the respective \l ToolBar::position, \l TabBar::position,
+ or \l DialogButtonBox::position property to \c Footer.
\sa header, Page::footer
*/
@@ -445,6 +450,8 @@ void QQuickApplicationWindow::setFooter(QQuickItem *footer)
toolBar->setPosition(QQuickToolBar::Footer);
else if (QQuickTabBar *tabBar = qobject_cast<QQuickTabBar *>(footer))
tabBar->setPosition(QQuickTabBar::Footer);
+ else if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(footer))
+ buttonBox->setPosition(QQuickDialogButtonBox::Footer);
}
if (isComponentComplete())
d->relayout();
diff --git a/src/quicktemplates2/qquickbusyindicator.cpp b/src/quicktemplates2/qquickbusyindicator.cpp
index 2cd3f62d..a59a8e5f 100644
--- a/src/quicktemplates2/qquickbusyindicator.cpp
+++ b/src/quicktemplates2/qquickbusyindicator.cpp
@@ -98,7 +98,6 @@ QQuickBusyIndicator::QQuickBusyIndicator(QQuickItem *parent) :
\note The indicator is only visible when this property is set to \c true.
The default value is \c true.
-
*/
bool QQuickBusyIndicator::isRunning() const
{
diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp
index ca6d4551..b11d2179 100644
--- a/src/quicktemplates2/qquickbutton.cpp
+++ b/src/quicktemplates2/qquickbutton.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include "qquickbutton_p.h"
-#include "qquickabstractbutton_p_p.h"
+#include "qquickbutton_p_p.h"
#include <QtGui/qpa/qplatformtheme.h>
@@ -80,17 +80,6 @@ QT_BEGIN_NAMESPACE
\sa {Customizing Button}, {Button Controls}
*/
-class QQuickButtonPrivate : public QQuickAbstractButtonPrivate
-{
- Q_DECLARE_PUBLIC(QQuickButton)
-
-public:
- QQuickButtonPrivate();
-
- bool flat;
- bool highlighted;
-};
-
QQuickButtonPrivate::QQuickButtonPrivate() :
flat(false), highlighted(false)
{
@@ -101,26 +90,9 @@ QQuickButton::QQuickButton(QQuickItem *parent) :
{
}
-/*!
- \qmlproperty bool QtQuick.Controls::Button::checkable
-
- This property holds whether the button is checkable.
-
- A checkable button toggles between checked (on) and unchecked (off) when
- the user clicks on it or presses the space bar while the button has active
- focus.
-
- Setting \l {AbstractButton::}{checked} to \c true forces this property to
- \c true.
-
- The default value is \c false.
-
- \sa CheckBox, Switch
-*/
-
-void QQuickButton::checkableChange()
+QQuickButton::QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent) :
+ QQuickAbstractButton(dd, parent)
{
- emit checkableChanged();
}
/*!
diff --git a/src/quicktemplates2/qquickbutton_p.h b/src/quicktemplates2/qquickbutton_p.h
index fafce150..5edbbe4e 100644
--- a/src/quicktemplates2/qquickbutton_p.h
+++ b/src/quicktemplates2/qquickbutton_p.h
@@ -57,7 +57,6 @@ class QQuickButtonPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButton : public QQuickAbstractButton
{
Q_OBJECT
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL)
@@ -72,13 +71,13 @@ public:
void setFlat(bool flat);
Q_SIGNALS:
- void checkableChanged();
void autoRepeatChanged();
void highlightedChanged();
void flatChanged();
protected:
- void checkableChange() override;
+ QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent);
+
void autoRepeatChange() override;
QFont defaultFont() const override;
diff --git a/src/quicktemplates2/qquickbutton_p_p.h b/src/quicktemplates2/qquickbutton_p_p.h
new file mode 100644
index 00000000..86663e9e
--- /dev/null
+++ b/src/quicktemplates2/qquickbutton_p_p.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKBUTTON_P_P_H
+#define QQUICKBUTTON_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickabstractbutton_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickButtonPrivate : public QQuickAbstractButtonPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickButton)
+
+public:
+ QQuickButtonPrivate();
+
+ bool flat;
+ bool highlighted;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKBUTTON_P_P_H
diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp
index 6ed75a2b..89941c19 100644
--- a/src/quicktemplates2/qquickbuttongroup.cpp
+++ b/src/quicktemplates2/qquickbuttongroup.cpp
@@ -123,6 +123,32 @@ QT_BEGIN_NAMESPACE
\sa RadioButton, {Button Controls}
*/
+/*!
+ \qmlsignal QtQuick.Controls::ButtonGroup::clicked(AbstractButton button)
+ \since QtQuick.Controls 2.1
+
+ This signal is emitted when a \a button in the group has been clicked.
+
+ This signal is convenient for implementing a common signal handler for
+ all buttons in the same group.
+
+ \code
+ ButtonGroup {
+ buttons: column.children
+ onClicked: console.log("clicked:", button.text)
+ }
+
+ Column {
+ id: column
+ Button { text: "First" }
+ Button { text: "Second" }
+ Button { text: "Third" }
+ }
+ \endcode
+
+ \sa AbstractButton::clicked()
+*/
+
class QQuickButtonGroupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QQuickButtonGroup)
@@ -131,6 +157,7 @@ public:
QQuickButtonGroupPrivate() : checkedButton(nullptr) { }
void clear();
+ void buttonClicked();
void _q_updateCurrent();
static void buttons_append(QQmlListProperty<QQuickAbstractButton> *prop, QQuickAbstractButton *obj);
@@ -146,11 +173,20 @@ void QQuickButtonGroupPrivate::clear()
{
for (QQuickAbstractButton *button : qAsConst(buttons)) {
QQuickAbstractButtonPrivate::get(button)->group = nullptr;
+ QObjectPrivate::disconnect(button, &QQuickAbstractButton::clicked, this, &QQuickButtonGroupPrivate::buttonClicked);
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, this, &QQuickButtonGroupPrivate::_q_updateCurrent);
}
buttons.clear();
}
+void QQuickButtonGroupPrivate::buttonClicked()
+{
+ Q_Q(QQuickButtonGroup);
+ QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton*>(q->sender());
+ if (button)
+ emit q->clicked(button);
+}
+
void QQuickButtonGroupPrivate::_q_updateCurrent()
{
Q_Q(QQuickButtonGroup);
@@ -289,6 +325,7 @@ void QQuickButtonGroup::addButton(QQuickAbstractButton *button)
return;
QQuickAbstractButtonPrivate::get(button)->group = this;
+ QObjectPrivate::connect(button, &QQuickAbstractButton::clicked, d, &QQuickButtonGroupPrivate::buttonClicked);
QObjectPrivate::connect(button, &QQuickAbstractButton::checkedChanged, d, &QQuickButtonGroupPrivate::_q_updateCurrent);
if (button->isChecked())
@@ -316,6 +353,7 @@ void QQuickButtonGroup::removeButton(QQuickAbstractButton *button)
return;
QQuickAbstractButtonPrivate::get(button)->group = nullptr;
+ QObjectPrivate::disconnect(button, &QQuickAbstractButton::clicked, d, &QQuickButtonGroupPrivate::buttonClicked);
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, d, &QQuickButtonGroupPrivate::_q_updateCurrent);
if (d->checkedButton == button)
diff --git a/src/quicktemplates2/qquickbuttongroup_p.h b/src/quicktemplates2/qquickbuttongroup_p.h
index baf4e13f..2202ae2f 100644
--- a/src/quicktemplates2/qquickbuttongroup_p.h
+++ b/src/quicktemplates2/qquickbuttongroup_p.h
@@ -83,6 +83,7 @@ public Q_SLOTS:
Q_SIGNALS:
void checkedButtonChanged();
void buttonsChanged();
+ Q_REVISION(1) void clicked(QQuickAbstractButton *button);
private:
Q_DISABLE_COPY(QQuickButtonGroup)
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 01f0f699..a0fcbe8c 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -170,7 +170,7 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate
Q_DECLARE_PUBLIC(QQuickComboBox)
public:
- QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false), hasCurrentIndex(false),
+ QQuickComboBoxPrivate() : flat(false), pressed(false), ownModel(false), hasDisplayText(false), hasCurrentIndex(false),
highlightedIndex(-1), currentIndex(-1), delegateModel(nullptr),
delegate(nullptr), indicator(nullptr), popup(nullptr) { }
@@ -195,6 +195,7 @@ public:
void createDelegateModel();
+ bool flat;
bool pressed;
bool ownModel;
bool hasDisplayText;
@@ -532,6 +533,36 @@ QQmlInstanceModel *QQuickComboBox::delegateModel() const
}
/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::ComboBox::flat
+
+ This property holds whether the combo box button is flat.
+
+ A flat combo box button does not draw a background unless it is interacted
+ with. In comparison to normal combo boxes, flat combo boxes provide looks
+ that make them stand out less from the rest of the UI. For instance, when
+ placing a combo box into a tool bar, it may be desirable to make the combo
+ box flat so it matches better with the flat looks of tool buttons.
+
+ The default value is \c false.
+*/
+bool QQuickComboBox::isFlat() const
+{
+ Q_D(const QQuickComboBox);
+ return d->flat;
+}
+
+void QQuickComboBox::setFlat(bool flat)
+{
+ Q_D(QQuickComboBox);
+ if (d->flat == flat)
+ return;
+
+ d->flat = flat;
+ emit flatChanged();
+}
+
+/*!
\qmlproperty bool QtQuick.Controls::ComboBox::pressed
This property holds whether the combo box button is pressed.
diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h
index 4cbdd77b..0e18a4d5 100644
--- a/src/quicktemplates2/qquickcombobox_p.h
+++ b/src/quicktemplates2/qquickcombobox_p.h
@@ -62,6 +62,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickComboBox : public QQuickControl
Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
Q_PROPERTY(QQmlInstanceModel *delegateModel READ delegateModel NOTIFY delegateModelChanged FINAL)
+ Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL REVISION 1)
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
Q_PROPERTY(int highlightedIndex READ highlightedIndex NOTIFY highlightedIndexChanged FINAL)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
@@ -82,6 +83,9 @@ public:
void setModel(const QVariant &model);
QQmlInstanceModel *delegateModel() const;
+ bool isFlat() const;
+ void setFlat(bool flat);
+
bool isPressed() const;
void setPressed(bool pressed);
@@ -119,6 +123,7 @@ Q_SIGNALS:
void countChanged();
void modelChanged();
void delegateModelChanged();
+ Q_REVISION(1) void flatChanged();
void pressedChanged();
void highlightedIndexChanged();
void currentIndexChanged();
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index c95cfc75..decc6e8a 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -548,7 +548,7 @@ QQmlListProperty<QQuickItem> QQuickContainer::contentChildren()
This property holds the index of the current item.
- \sa currentItem
+ \sa currentItem, incrementCurrentIndex(), decrementCurrentIndex()
*/
int QQuickContainer::currentIndex() const
{
@@ -568,6 +568,36 @@ void QQuickContainer::setCurrentIndex(int index)
}
/*!
+ \qmlmethod void QtQuick.Controls::Container::incrementCurrentIndex()
+ \since QtQuick.Controls 2.1
+
+ Increments the current index of the container.
+
+ \sa currentIndex
+*/
+void QQuickContainer::incrementCurrentIndex()
+{
+ Q_D(QQuickContainer);
+ if (d->currentIndex < count() - 1)
+ setCurrentIndex(d->currentIndex + 1);
+}
+
+/*!
+ \qmlmethod void QtQuick.Controls::Container::decrementCurrentIndex()
+ \since QtQuick.Controls 2.1
+
+ Decrements the current index of the container.
+
+ \sa currentIndex
+*/
+void QQuickContainer::decrementCurrentIndex()
+{
+ Q_D(QQuickContainer);
+ if (d->currentIndex > 0)
+ setCurrentIndex(d->currentIndex - 1);
+}
+
+/*!
\qmlproperty Item QtQuick.Controls::Container::currentItem
\readonly
diff --git a/src/quicktemplates2/qquickcontainer_p.h b/src/quicktemplates2/qquickcontainer_p.h
index 2ed30b77..98873c09 100644
--- a/src/quicktemplates2/qquickcontainer_p.h
+++ b/src/quicktemplates2/qquickcontainer_p.h
@@ -86,6 +86,8 @@ public:
public Q_SLOTS:
void setCurrentIndex(int index);
+ Q_REVISION(1) void incrementCurrentIndex();
+ Q_REVISION(1) void decrementCurrentIndex();
Q_SIGNALS:
void countChanged();
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index cb891ee9..d8088f24 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -109,7 +109,8 @@ QQuickControlPrivate::ExtraData::ExtraData()
}
QQuickControlPrivate::QQuickControlPrivate() :
- hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false), hovered(false), wheelEnabled(false),
+ hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false),
+ hasLocale(false), hovered(false), wheelEnabled(false), explicitHoverEnabled(false),
padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), spacing(0),
focusPolicy(Qt::NoFocus), focusReason(Qt::OtherFocusReason),
background(nullptr), contentItem(nullptr), accessibleAttached(nullptr)
@@ -214,6 +215,11 @@ void QQuickControlPrivate::resizeContent()
}
}
+QQuickItem *QQuickControlPrivate::getContentItem()
+{
+ return contentItem;
+}
+
#ifndef QT_NO_ACCESSIBILITY
void QQuickControlPrivate::accessibilityActiveChanged(bool active)
{
@@ -356,6 +362,62 @@ void QQuickControlPrivate::updateFontRecur(QQuickItem *item, const QFont &f)
}
}
+void QQuickControlPrivate::updateHoverEnabled(bool enabled, bool xplicit)
+{
+ Q_Q(QQuickControl);
+ if (!xplicit && explicitHoverEnabled)
+ return;
+
+ bool wasEnabled = q->isHoverEnabled();
+ explicitHoverEnabled = xplicit;
+ if (wasEnabled != enabled) {
+ q->setAcceptHoverEvents(enabled);
+ QQuickControlPrivate::updateHoverEnabledRecur(q, enabled);
+ emit q->hoverEnabledChanged();
+ }
+}
+
+void QQuickControlPrivate::updateHoverEnabledRecur(QQuickItem *item, bool enabled)
+{
+ const auto childItems = item->childItems();
+ for (QQuickItem *child : childItems) {
+ if (QQuickControl *control = qobject_cast<QQuickControl *>(child))
+ QQuickControlPrivate::get(control)->updateHoverEnabled(enabled, false);
+ else
+ updateHoverEnabledRecur(child, enabled);
+ }
+}
+
+bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item)
+{
+ const QQuickItem *p = item;
+ while (p) {
+ // QQuickPopupItem accepts hover events to avoid leaking them through.
+ // Don't inherit that to the children of the popup, but fallback to the
+ // environment variable or style hint.
+ if (qobject_cast<const QQuickPopupItem *>(p))
+ break;
+
+ if (const QQuickControl *control = qobject_cast<const QQuickControl *>(p))
+ return control->isHoverEnabled();
+
+ QVariant v = p->property("hoverEnabled");
+ if (v.isValid() && v.userType() == QMetaType::Bool)
+ return v.toBool();
+
+ p = p->parentItem();
+ }
+
+ bool ok = false;
+ int env = qEnvironmentVariableIntValue("QT_QUICK_CONTROLS_HOVER_ENABLED", &ok);
+ if (ok)
+ return env != 0;
+
+ // TODO: QQuickApplicationWindow::isHoverEnabled()
+
+ return QGuiApplication::styleHints()->useHoverEffects();
+}
+
QString QQuickControl::accessibleName() const
{
#ifndef QT_NO_ACCESSIBILITY
@@ -424,6 +486,8 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::
d->resolveFont();
if (!d->hasLocale)
d->updateLocale(QQuickControlPrivate::calcLocale(d->parentItem), false); // explicit=false
+ if (!d->explicitHoverEnabled)
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
}
break;
case ItemActiveFocusHasChanged:
@@ -702,10 +766,13 @@ qreal QQuickControl::spacing() const
void QQuickControl::setSpacing(qreal spacing)
{
Q_D(QQuickControl);
- if (!qFuzzyCompare(d->spacing, spacing)) {
- d->spacing = spacing;
- emit spacingChanged();
- }
+ if (qFuzzyCompare(d->spacing, spacing))
+ return;
+
+ qreal oldSpacing = d->spacing;
+ d->spacing = spacing;
+ emit spacingChanged();
+ spacingChange(spacing, oldSpacing);
}
void QQuickControl::resetSpacing()
@@ -936,12 +1003,21 @@ void QQuickControl::setHovered(bool hovered)
d->hovered = hovered;
emit hoveredChanged();
+ hoverChange();
}
/*!
\qmlproperty bool QtQuick.Controls::Control::hoverEnabled
- This property determines whether the control accepts hover events. The default value is \c false.
+ This property determines whether the control accepts hover events. The default value
+ is \c Qt.styleHints.useHoverEffects.
+
+ Setting this property propagates the value to all child controls that do not have
+ \c hoverEnabled explicitly set.
+
+ You can also enable or disable hover effects for all Qt Quick Controls 2 applications
+ by setting the \c QT_QUICK_CONTROLS_HOVER_ENABLED \l {Supported Environment Variables
+ in Qt Quick Controls 2}{environment variable}.
\sa hovered
*/
@@ -954,11 +1030,20 @@ bool QQuickControl::isHoverEnabled() const
void QQuickControl::setHoverEnabled(bool enabled)
{
Q_D(QQuickControl);
- if (enabled == d->hoverEnabled)
+ if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
return;
- setAcceptHoverEvents(enabled);
- emit hoverEnabledChanged();
+ d->updateHoverEnabled(enabled, true); // explicit=true
+}
+
+void QQuickControl::resetHoverEnabled()
+{
+ Q_D(QQuickControl);
+ if (!d->explicitHoverEnabled)
+ return;
+
+ d->explicitHoverEnabled = false;
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
}
/*!
@@ -1062,8 +1147,8 @@ void QQuickControl::setBackground(QQuickItem *background)
*/
QQuickItem *QQuickControl::contentItem() const
{
- Q_D(const QQuickControl);
- return d->contentItem;
+ QQuickControlPrivate *d = const_cast<QQuickControlPrivate *>(d_func());
+ return d->getContentItem();
}
void QQuickControl::setContentItem(QQuickItem *item)
@@ -1097,6 +1182,8 @@ void QQuickControl::componentComplete()
QQuickItem::componentComplete();
if (!d->hasLocale)
d->locale = QQuickControlPrivate::calcLocale(d->parentItem);
+ if (!d->explicitHoverEnabled)
+ setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
accessibilityActiveChanged(true);
@@ -1198,11 +1285,21 @@ void QQuickControl::fontChange(const QFont &newFont, const QFont &oldFont)
Q_UNUSED(oldFont);
}
+void QQuickControl::hoverChange()
+{
+}
+
void QQuickControl::mirrorChange()
{
emit mirroredChanged();
}
+void QQuickControl::spacingChange(qreal newSpacing, qreal oldSpacing)
+{
+ Q_UNUSED(newSpacing);
+ Q_UNUSED(oldSpacing);
+}
+
void QQuickControl::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding)
{
Q_D(QQuickControl);
diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h
index d9827017..3bc21684 100644
--- a/src/quicktemplates2/qquickcontrol_p.h
+++ b/src/quicktemplates2/qquickcontrol_p.h
@@ -74,7 +74,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControl : public QQuickItem
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
Q_PROPERTY(bool visualFocus READ hasVisualFocus NOTIFY visualFocusChanged FINAL)
Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL)
- Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged FINAL)
+ Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL)
Q_PROPERTY(bool wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL)
@@ -132,6 +132,7 @@ public:
bool isHoverEnabled() const;
void setHoverEnabled(bool enabled);
+ void resetHoverEnabled();
bool isWheelEnabled() const;
void setWheelEnabled(bool enabled);
@@ -186,7 +187,9 @@ protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
virtual void fontChange(const QFont &newFont, const QFont &oldFont);
+ virtual void hoverChange();
virtual void mirrorChange();
+ virtual void spacingChange(qreal newSpacing, qreal oldSpacing);
virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding);
virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem);
virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale);
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 64f29986..cae1ae59 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -88,6 +88,8 @@ public:
void resizeBackground();
virtual void resizeContent();
+ virtual QQuickItem *getContentItem();
+
#ifndef QT_NO_ACCESSIBILITY
void accessibilityActiveChanged(bool active) override;
QAccessible::Role accessibleRole() const override;
@@ -109,6 +111,10 @@ public:
static void updateLocaleRecur(QQuickItem *item, const QLocale &l);
static QLocale calcLocale(const QQuickItem *item);
+ void updateHoverEnabled(bool enabled, bool xplicit);
+ static void updateHoverEnabledRecur(QQuickItem *item, bool enabled);
+ static bool calcHoverEnabled(const QQuickItem *item);
+
void deleteDelegate(QObject *object);
struct ExtraData {
@@ -129,6 +135,7 @@ public:
bool hasLocale;
bool hovered;
bool wheelEnabled;
+ bool explicitHoverEnabled;
qreal padding;
qreal topPadding;
qreal leftPadding;
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index 79aff781..2b9f83a4 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -606,6 +606,20 @@ void QQuickDial::mouseUngrabEvent()
setPressed(false);
}
+void QQuickDial::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QQuickDial);
+ QQuickControl::wheelEvent(event);
+ if (d->wheelEnabled) {
+ const qreal oldValue = d->value;
+ const QPointF angle = event->angleDelta();
+ const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / QWheelEvent::DefaultDeltasPerStep;
+ const qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize;
+ setValue(oldValue + step * delta);
+ event->setAccepted(!qFuzzyCompare(d->value, oldValue));
+ }
+}
+
void QQuickDial::mirrorChange()
{
QQuickControl::mirrorChange();
diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h
index 2d87d6d9..291a6ac2 100644
--- a/src/quicktemplates2/qquickdial_p.h
+++ b/src/quicktemplates2/qquickdial_p.h
@@ -132,6 +132,8 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseUngrabEvent() override;
+ void wheelEvent(QWheelEvent *event) override;
+
void mirrorChange() override;
void componentComplete() override;
diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp
new file mode 100644
index 00000000..c84c9269
--- /dev/null
+++ b/src/quicktemplates2/qquickdialog.cpp
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickdialog_p.h"
+#include "qquickdialog_p_p.h"
+#include "qquickdialogbuttonbox_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Dialog
+ \inherits Popup
+ \instantiates QQuickDialog
+ \inqmlmodule QtQuick.Controls
+ \ingroup qtquickcontrols2-dialogs
+ \ingroup qtquickcontrols2-popups
+ \brief Popup dialog with standard buttons and a title, used for short-term interaction with the user.
+ \since 5.8
+
+ A dialog is a popup mostly used for short-term tasks and brief communications
+ with the user. Similarly to \l ApplicationWindow and \l Page, Dialog is organized
+ into three sections: \l header, \l {Popup::}{contentItem}, and \l footer.
+
+ \image qtquickcontrols2-page-wireframe.png
+
+ \section1 Dialog Title and Buttons
+
+ Dialog's \l title is displayed by a style-specific title bar that is assigned
+ as a dialog \l header by default.
+
+ Dialog's standard buttons are managed by a \l DialogButtonBox that is assigned
+ as a dialog \l footer by default. The dialog's \l standardButtons property is
+ forwarded to the respective property of the button box. Furthermore, the
+ \l {DialogButtonBox::}{accepted()} and \l {DialogButtonBox::}{rejected()}
+ signals of the button box are connected to the respective signals in Dialog.
+
+ \snippet qtquickcontrols2-dialog.qml 1
+
+ \section1 Modal Dialogs
+
+ A \l {Popup::}{modal} dialog blocks input to other content beneath
+ the dialog. When a modal dialog is opened, the user must finish
+ interacting with the dialog and close it before they can access any
+ other content in the same window.
+
+ \snippet qtquickcontrols2-dialog-modal.qml 1
+
+ \section1 Modeless Dialogs
+
+ A modeless dialog is a dialog that operates independently of other
+ content around the dialog. When a modeless dialog is opened, the user
+ is allowed to interact with both the dialog and the other content in
+ the same window.
+
+ \snippet qtquickcontrols2-dialog-modeless.qml 1
+
+ \sa DialogButtonBox, {Popup Controls}
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::Dialog::accepted()
+
+ This signal is emitted when the dialog has been accepted either
+ interactively or by calling \l accept().
+
+ \note This signal is \e not emitted when closing the dialog with
+ \l {Popup::}{close()} or setting \l {Popup::}{visible} to \c false.
+
+ \sa rejected()
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::Dialog::rejected()
+
+ This signal is emitted when the dialog has been rejected either
+ interactively or by calling \l reject().
+
+ \note This signal is \e not emitted when closing the dialog with
+ \l {Popup::}{close()} or setting \l {Popup::}{visible} to \c false.
+
+ \sa accepted()
+*/
+
+QQuickDialog::QQuickDialog(QObject *parent) :
+ QQuickPopup(*(new QQuickDialogPrivate), parent)
+{
+ Q_D(QQuickDialog);
+ d->layout.reset(new QQuickPageLayout(d->popupItem));
+}
+
+/*!
+ \qmlproperty string QtQuick.Controls::Dialog::title
+
+ This property holds the dialog title.
+
+ The title is displayed in the dialog header.
+
+ \code
+ Dialog {
+ title: qsTr("About")
+
+ Label {
+ text: "Lorem ipsum..."
+ }
+ }
+ \endcode
+*/
+QString QQuickDialog::title() const
+{
+ Q_D(const QQuickDialog);
+ return d->title;
+}
+
+void QQuickDialog::setTitle(const QString &title)
+{
+ Q_D(QQuickDialog);
+ if (d->title == title)
+ return;
+
+ d->title = title;
+ setAccessibleName(title);
+ emit titleChanged();
+}
+
+/*!
+ \qmlproperty Item QtQuick.Controls::Dialog::header
+
+ This property holds the dialog header item. The header item is positioned to
+ the top, and resized to the width of the dialog. The default value is \c null.
+
+ \note Assigning a \l DialogButtonBox as a dialog header automatically connects
+ its \l {DialogButtonBox::}{accepted()} and \l {DialogButtonBox::}{rejected()}
+ signals to the respective signals in Dialog.
+
+ \note Assigning a \l DialogButtonBox, \l ToolBar, or \l TabBar as a dialog
+ header automatically sets the respective \l DialogButtonBox::position,
+ \l ToolBar::position, or \l TabBar::position property to \c Header.
+
+ \sa footer
+*/
+QQuickItem *QQuickDialog::header() const
+{
+ Q_D(const QQuickDialog);
+ return d->layout->header();
+}
+
+void QQuickDialog::setHeader(QQuickItem *header)
+{
+ Q_D(QQuickDialog);
+ QQuickItem *oldHeader = d->layout->header();
+ if (!d->layout->setHeader(header))
+ return;
+
+ if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(oldHeader)) {
+ disconnect(buttonBox, &QQuickDialogButtonBox::accepted, this, &QQuickDialog::accept);
+ disconnect(buttonBox, &QQuickDialogButtonBox::rejected, this, &QQuickDialog::reject);
+ if (d->buttonBox == buttonBox)
+ d->buttonBox = nullptr;
+ }
+ if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(header)) {
+ connect(buttonBox, &QQuickDialogButtonBox::accepted, this, &QQuickDialog::accept);
+ connect(buttonBox, &QQuickDialogButtonBox::rejected, this, &QQuickDialog::reject);
+ d->buttonBox = buttonBox;
+ buttonBox->setStandardButtons(d->standardButtons);
+ }
+
+ if (isComponentComplete())
+ d->layout->update();
+ emit headerChanged();
+}
+
+/*!
+ \qmlproperty Item QtQuick.Controls::Dialog::footer
+
+ This property holds the dialog footer item. The footer item is positioned to
+ the bottom, and resized to the width of the dialog. The default value is \c null.
+
+ \note Assigning a \l DialogButtonBox as a dialog footer automatically connects
+ its \l {DialogButtonBox::}{accepted()} and \l {DialogButtonBox::}{rejected()}
+ signals to the respective signals in Dialog.
+
+ \note Assigning a \l DialogButtonBox, \l ToolBar, or \l TabBar as a dialog
+ footer automatically sets the respective \l DialogButtonBox::position,
+ \l ToolBar::position, or \l TabBar::position property to \c Footer.
+
+ \sa header
+*/
+QQuickItem *QQuickDialog::footer() const
+{
+ Q_D(const QQuickDialog);
+ return d->layout->footer();
+}
+
+void QQuickDialog::setFooter(QQuickItem *footer)
+{
+ Q_D(QQuickDialog);
+ QQuickItem *oldFooter = d->layout->footer();
+ if (!d->layout->setFooter(footer))
+ return;
+
+ if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(oldFooter)) {
+ disconnect(buttonBox, &QQuickDialogButtonBox::accepted, this, &QQuickDialog::accept);
+ disconnect(buttonBox, &QQuickDialogButtonBox::rejected, this, &QQuickDialog::reject);
+ if (d->buttonBox == buttonBox)
+ d->buttonBox = nullptr;
+ }
+ if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(footer)) {
+ connect(buttonBox, &QQuickDialogButtonBox::accepted, this, &QQuickDialog::accept);
+ connect(buttonBox, &QQuickDialogButtonBox::rejected, this, &QQuickDialog::reject);
+ d->buttonBox = buttonBox;
+ buttonBox->setStandardButtons(d->standardButtons);
+ }
+
+ if (isComponentComplete())
+ d->layout->update();
+ emit footerChanged();
+}
+
+/*!
+ \qmlproperty enumeration QtQuick.Controls::Dialog::standardButtons
+
+ This property holds a combination of standard buttons that are used by the dialog.
+
+ \snippet qtquickcontrols2-dialog.qml 1
+
+ Possible flags:
+ \value Dialog.Ok An "OK" button defined with the \c AcceptRole.
+ \value Dialog.Open An "Open" button defined with the \c AcceptRole.
+ \value Dialog.Save A "Save" button defined with the \c AcceptRole.
+ \value Dialog.Cancel A "Cancel" button defined with the \c RejectRole.
+ \value Dialog.Close A "Close" button defined with the \c RejectRole.
+ \value Dialog.Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the \c DestructiveRole.
+ \value Dialog.Apply An "Apply" button defined with the \c ApplyRole.
+ \value Dialog.Reset A "Reset" button defined with the \c ResetRole.
+ \value Dialog.RestoreDefaults A "Restore Defaults" button defined with the \c ResetRole.
+ \value Dialog.Help A "Help" button defined with the \c HelpRole.
+ \value Dialog.SaveAll A "Save All" button defined with the \c AcceptRole.
+ \value Dialog.Yes A "Yes" button defined with the \c YesRole.
+ \value Dialog.YesToAll A "Yes to All" button defined with the \c YesRole.
+ \value Dialog.No A "No" button defined with the \c NoRole.
+ \value Dialog.NoToAll A "No to All" button defined with the \c NoRole.
+ \value Dialog.Abort An "Abort" button defined with the \c RejectRole.
+ \value Dialog.Retry A "Retry" button defined with the \c AcceptRole.
+ \value Dialog.Ignore An "Ignore" button defined with the \c AcceptRole.
+ \value Dialog.NoButton An invalid button.
+
+ \sa DialogButtonBox
+*/
+QPlatformDialogHelper::StandardButtons QQuickDialog::standardButtons() const
+{
+ Q_D(const QQuickDialog);
+ return d->standardButtons;
+}
+
+void QQuickDialog::setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
+{
+ Q_D(QQuickDialog);
+ if (d->standardButtons == buttons)
+ return;
+
+ d->standardButtons = buttons;
+ if (d->buttonBox)
+ d->buttonBox->setStandardButtons(buttons);
+ emit standardButtonsChanged();
+}
+
+/*!
+ \qmlmethod void QtQuick.Controls::Dialog::accept()
+
+ Closes the dialog and emits the \l accepted() signal.
+
+ \sa reject()
+*/
+void QQuickDialog::accept()
+{
+ close();
+ emit accepted();
+}
+
+/*!
+ \qmlmethod void QtQuick.Controls::Dialog::reject()
+
+ Closes the dialog and emits the \l rejected() signal.
+
+ \sa accept()
+*/
+void QQuickDialog::reject()
+{
+ close();
+ emit rejected();
+}
+
+void QQuickDialog::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickDialog);
+ QQuickPopup::geometryChanged(newGeometry, oldGeometry);
+ d->layout->update();
+}
+
+void QQuickDialog::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding)
+{
+ Q_D(QQuickDialog);
+ QQuickPopup::paddingChange(newPadding, oldPadding);
+ d->layout->update();
+}
+
+void QQuickDialog::spacingChange(qreal newSpacing, qreal oldSpacing)
+{
+ Q_D(QQuickDialog);
+ QQuickPopup::spacingChange(newSpacing, oldSpacing);
+ d->layout->update();
+}
+
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickDialog::accessibleRole() const
+{
+ return QAccessible::Dialog;
+}
+
+void QQuickDialog::accessibilityActiveChanged(bool active)
+{
+ Q_D(QQuickDialog);
+ QQuickPopup::accessibilityActiveChanged(active);
+
+ if (active)
+ setAccessibleName(d->title);
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h
new file mode 100644
index 00000000..6ec440bf
--- /dev/null
+++ b/src/quicktemplates2/qquickdialog_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDIALOG_P_H
+#define QQUICKDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickpopup_p.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickDialogPrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
+ Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
+ Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
+ Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL)
+ Q_FLAGS(QPlatformDialogHelper::StandardButtons)
+
+public:
+ explicit QQuickDialog(QObject *parent = nullptr);
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ QQuickItem *header() const;
+ void setHeader(QQuickItem *header);
+
+ QQuickItem *footer() const;
+ void setFooter(QQuickItem *footer);
+
+ QPlatformDialogHelper::StandardButtons standardButtons() const;
+ void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons);
+
+public Q_SLOTS:
+ void accept();
+ void reject();
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+
+ void titleChanged();
+ void headerChanged();
+ void footerChanged();
+ void standardButtonsChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
+ void spacingChange(qreal newSpacing, qreal oldSpacing) override;
+
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+ void accessibilityActiveChanged(bool active) override;
+#endif
+
+private:
+ Q_DISABLE_COPY(QQuickDialog)
+ Q_DECLARE_PRIVATE(QQuickDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickDialog)
+
+#endif // QQUICKDIALOG_P_H
diff --git a/src/quicktemplates2/qquickdialog_p_p.h b/src/quicktemplates2/qquickdialog_p_p.h
new file mode 100644
index 00000000..5ea84cc8
--- /dev/null
+++ b/src/quicktemplates2/qquickdialog_p_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDIALOG_P_P_H
+#define QQUICKDIALOG_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickpopup_p_p.h>
+#include <QtQuickTemplates2/private/qquickpagelayout_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickDialogButtonBox;
+
+class QQuickDialogPrivate : public QQuickPopupPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickDialog)
+
+public:
+ QQuickDialogPrivate() : buttonBox(nullptr) { }
+
+ static QQuickDialogPrivate *get(QQuickDialog *dialog)
+ {
+ return dialog->d_func();
+ }
+
+ QString title;
+ QQuickDialogButtonBox *buttonBox;
+ QScopedPointer<QQuickPageLayout> layout;
+ QPlatformDialogHelper::StandardButtons standardButtons;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKDIALOG_P_P_H
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
new file mode 100644
index 00000000..10603d58
--- /dev/null
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -0,0 +1,672 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickdialogbuttonbox_p.h"
+#include "qquickdialogbuttonbox_p_p.h"
+#include "qquickabstractbutton_p.h"
+#include "qquickbutton_p.h"
+
+#include <QtCore/qpointer.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlcomponent.h>
+
+#include <algorithm>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype DialogButtonBox
+ \inherits Container
+ \instantiates QQuickDialogButtonBox
+ \inqmlmodule QtQuick.Controls
+ \ingroup qtquickcontrols2-dialogs
+ \brief A button box used in dialogs.
+ \since 5.8
+
+ Dialogs and message boxes typically present buttons in an order that
+ conforms to the interface guidelines for that platform. Invariably,
+ different platforms have their dialog buttons in different orders.
+ DialogButtonBox allows a developer to add buttons to it and will
+ automatically use the appropriate order for the user's platform.
+
+ Most buttons for a dialog follow certain roles. Such roles include:
+
+ \list
+ \li Accepting or rejecting the dialog.
+ \li Asking for help.
+ \li Performing actions on the dialog itself (such as resetting fields or
+ applying changes).
+ \endlist
+
+ There can also be alternate ways of dismissing the dialog which may cause
+ destructive results.
+
+ Most dialogs have buttons that can almost be considered standard (e.g.
+ \uicontrol OK and \uicontrol Cancel buttons). It is sometimes convenient
+ to create these buttons in a standard way.
+
+ There are a couple ways of using DialogButtonBox. One way is to specify
+ the standard buttons (e.g. \uicontrol OK, \uicontrol Cancel, \uicontrol Save)
+ and let the button box setup the buttons.
+
+ \image qtquickcontrols2-dialogbuttonbox.png
+
+ \snippet qtquickcontrols2-dialogbuttonbox.qml 1
+
+ Alternatively, buttons and their roles can be specified by hand:
+
+ \snippet qtquickcontrols2-dialogbuttonbox-attached.qml 1
+
+ You can also mix and match normal buttons and standard buttons.
+
+ When a button is clicked in the button box, the \l clicked() signal is
+ emitted for the actual button that is pressed. For convenience, if the
+ button has an \c AcceptRole, \c RejectRole, or \c HelpRole, the \l accepted(),
+ \l rejected(), or \l helpRequested() signals are emitted respectively.
+
+ \sa Dialog
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::DialogButtonBox::accepted()
+
+ This signal is emitted when a button defined with the \c AcceptRole or
+ \c YesRole is clicked.
+
+ \sa rejected(), clicked(), helpRequested()
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::DialogButtonBox::rejected()
+
+ This signal is emitted when a button defined with the \c RejectRole or
+ \c NoRole is clicked.
+
+ \sa accepted(), helpRequested(), clicked()
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::DialogButtonBox::helpRequested()
+
+ This signal is emitted when a button defined with the \c HelpRole is clicked.
+
+ \sa accepted(), rejected(), clicked()
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::DialogButtonBox::clicked(AbstractButton button)
+
+ This signal is emitted when a \a button inside the button box is clicked.
+
+ \sa accepted(), rejected(), helpRequested()
+*/
+
+static QPlatformDialogHelper::ButtonRole buttonRole(QQuickAbstractButton *button)
+{
+ const QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, false));
+ return attached ? attached->buttonRole() : QPlatformDialogHelper::InvalidRole;
+}
+
+QQuickDialogButtonBoxPrivate::QQuickDialogButtonBoxPrivate() :
+ alignment(0),
+ position(QQuickDialogButtonBox::Footer),
+ standardButtons(QPlatformDialogHelper::NoButton),
+ delegate(nullptr)
+{
+}
+
+void QQuickDialogButtonBoxPrivate::itemImplicitWidthChanged(QQuickItem *item)
+{
+ Q_UNUSED(item);
+ resizeContent();
+}
+
+void QQuickDialogButtonBoxPrivate::itemImplicitHeightChanged(QQuickItem *item)
+{
+ Q_UNUSED(item);
+ resizeContent();
+}
+
+// adapted from QStyle::alignedRect()
+static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSizeF &size, const QRectF &rectangle)
+{
+ alignment = QGuiApplicationPrivate::visualAlignment(direction, alignment);
+ qreal x = rectangle.x();
+ qreal y = rectangle.y();
+ qreal w = size.width();
+ qreal h = size.height();
+ if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
+ y += rectangle.size().height() / 2 - h / 2;
+ else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
+ y += rectangle.size().height() - h;
+ if ((alignment & Qt::AlignRight) == Qt::AlignRight)
+ x += rectangle.size().width() - w;
+ else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
+ x += rectangle.size().width() / 2 - w / 2;
+ return QRectF(x, y, w, h);
+}
+
+void QQuickDialogButtonBoxPrivate::resizeContent()
+{
+ Q_Q(QQuickDialogButtonBox);
+ if (!contentItem)
+ return;
+
+ const int halign = alignment & Qt::AlignHorizontal_Mask;
+ const int valign = alignment & Qt::AlignVertical_Mask;
+
+ const qreal cw = !halign ? q->availableWidth() : contentItem->implicitWidth();
+ const qreal ch = !valign ? q->availableHeight() : contentItem->implicitWidth();
+
+ QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+ if (halign || valign)
+ geometry = alignedRect(q->isMirrored() ? Qt::RightToLeft : Qt::LeftToRight, alignment, QSizeF(cw, ch), geometry);
+
+ contentItem->setPosition(geometry.topLeft());
+ contentItem->setSize(geometry.size());
+}
+
+void QQuickDialogButtonBoxPrivate::updateLayout()
+{
+ Q_Q(QQuickDialogButtonBox);
+ const int count = contentModel->count();
+ if (count <= 0)
+ return;
+
+ const int halign = alignment & Qt::AlignHorizontal_Mask;
+ const int valign = alignment & Qt::AlignVertical_Mask;
+
+ QVector<QQuickAbstractButton *> buttons;
+ const qreal maxItemWidth = (contentItem->width() - qMax(0, count - 1) * spacing) / count;
+ const qreal maxItemHeight = contentItem->height();
+
+ for (int i = 0; i < count; ++i) {
+ QQuickItem *item = q->itemAt(i);
+ if (item) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(item);
+ if (!p->widthValid) {
+ if (!halign)
+ item->setWidth(maxItemWidth);
+ else
+ item->resetWidth();
+ if (!valign)
+ item->setHeight(maxItemHeight);
+ else
+ item->resetHeight();
+ p->widthValid = false;
+ }
+ }
+ buttons += static_cast<QQuickAbstractButton *>(item);
+ }
+
+ struct ButtonLayout {
+ bool operator()(QQuickAbstractButton *first, QQuickAbstractButton *second)
+ {
+ const QPlatformDialogHelper::ButtonRole firstRole = buttonRole(first);
+ const QPlatformDialogHelper::ButtonRole secondRole = buttonRole(second);
+
+ if (firstRole != secondRole && firstRole != QPlatformDialogHelper::InvalidRole && secondRole != QPlatformDialogHelper::InvalidRole) {
+ const int *l = m_layout;
+ while (*l != QPlatformDialogHelper::EOL) {
+ const int role = (*l & ~QPlatformDialogHelper::Reverse);
+ if (role == firstRole)
+ return true;
+ if (role == secondRole)
+ return false;
+ ++l;
+ }
+ }
+
+ if (firstRole == secondRole)
+ return first < second;
+
+ return firstRole != QPlatformDialogHelper::InvalidRole;
+ }
+ const int *m_layout = QPlatformDialogHelper::buttonLayout();
+ };
+
+ std::sort(buttons.begin(), buttons.end(), ButtonLayout());
+
+ for (int i = 0; i < buttons.count() - 1; ++i)
+ q->insertItem(i, buttons.at(i));
+}
+
+void QQuickDialogButtonBoxPrivate::handleClick()
+{
+ Q_Q(QQuickDialogButtonBox);
+ QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(q->sender());
+ if (!button)
+ return;
+
+ // Can't fetch this *after* emitting clicked, as clicked may destroy the button
+ // or change its role. Now changing the role is not possible yet, but arguably
+ // both clicked and accepted/rejected/etc. should be emitted "atomically"
+ // depending on whatever role the button had at the time of the click.
+ const QPlatformDialogHelper::ButtonRole role = buttonRole(button);
+ QPointer<QQuickDialogButtonBox> guard(q);
+
+ emit q->clicked(button);
+
+ if (!guard)
+ return;
+
+ switch (role) {
+ case QPlatformDialogHelper::AcceptRole:
+ case QPlatformDialogHelper::YesRole:
+ emit q->accepted();
+ break;
+ case QPlatformDialogHelper::RejectRole:
+ case QPlatformDialogHelper::NoRole:
+ emit q->rejected();
+ break;
+ case QPlatformDialogHelper::HelpRole:
+ emit q->helpRequested();
+ break;
+ default:
+ break;
+ }
+}
+
+QQuickAbstractButton *QQuickDialogButtonBoxPrivate::createStandardButton(QPlatformDialogHelper::StandardButton standardButton)
+{
+ Q_Q(QQuickDialogButtonBox);
+ if (!delegate)
+ return nullptr;
+
+ QQmlContext *creationContext = delegate->creationContext();
+ if (!creationContext)
+ creationContext = qmlContext(q);
+ QQmlContext *context = new QQmlContext(creationContext);
+ context->setContextObject(q);
+
+ QObject *object = delegate->beginCreate(context);
+ QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton*>(object);
+ if (button) {
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, true));
+ QQuickDialogButtonBoxAttachedPrivate::get(attached)->standardButton = standardButton;
+ attached->setButtonRole(QPlatformDialogHelper::buttonRole(standardButton));
+ button->setText(QPlatformTheme::removeMnemonics(QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton)));
+ delegate->completeCreate();
+ return button;
+ }
+
+ delete object;
+ return nullptr;
+}
+
+void QQuickDialogButtonBoxPrivate::removeStandardButtons()
+{
+ Q_Q(QQuickDialogButtonBox);
+ int i = q->count() - 1;
+ while (i >= 0) {
+ QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(q->itemAt(i));
+ if (button) {
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(button, false));
+ if (attached) {
+ QQuickDialogButtonBoxAttachedPrivate *p = QQuickDialogButtonBoxAttachedPrivate::get(attached);
+ if (p->standardButton != QPlatformDialogHelper::NoButton) {
+ q->removeItem(i);
+ button->deleteLater();
+ }
+ }
+ }
+ --i;
+ }
+}
+
+QQuickDialogButtonBox::QQuickDialogButtonBox(QQuickItem *parent) :
+ QQuickContainer(*(new QQuickDialogButtonBoxPrivate), parent)
+{
+}
+
+QQuickDialogButtonBox::~QQuickDialogButtonBox()
+{
+}
+
+
+/*!
+ \qmlproperty enumeration QtQuick.Controls::DialogButtonBox::position
+
+ This property holds the position of the button box.
+
+ \note If the button box is assigned as a header or footer of ApplicationWindow
+ or Page, the appropriate position is set automatically.
+
+ Possible values:
+ \value DialogButtonBox.Header The button box is at the top, as a window or page header.
+ \value DialogButtonBox.Footer The button box is at the bottom, as a window or page header.
+
+ The default value is \c Footer.
+
+ \sa Dialog::header, Dialog::footer
+*/
+QQuickDialogButtonBox::Position QQuickDialogButtonBox::position() const
+{
+ Q_D(const QQuickDialogButtonBox);
+ return d->position;
+}
+
+void QQuickDialogButtonBox::setPosition(Position position)
+{
+ Q_D(QQuickDialogButtonBox);
+ if (d->position == position)
+ return;
+
+ d->position = position;
+ emit positionChanged();
+}
+
+/*!
+ \qmlproperty flags QtQuick.Controls::DialogButtonBox::alignment
+
+ This property holds the alignment of the buttons.
+
+ Possible values:
+ \value undefined The buttons are resized to fill the available space.
+ \value Qt.AlignLeft The buttons are aligned to the left.
+ \value Qt.AlignHCenter The buttons are horizontally centered.
+ \value Qt.AlignRight The buttons are aligned to the right.
+ \value Qt.AlignTop The buttons are aligned to the top.
+ \value Qt.AlignVCenter The buttons are vertically centered.
+ \value Qt.AlignBottom The buttons are aligned to the bottom.
+*/
+Qt::Alignment QQuickDialogButtonBox::alignment() const
+{
+ Q_D(const QQuickDialogButtonBox);
+ return d->alignment;
+}
+
+void QQuickDialogButtonBox::setAlignment(Qt::Alignment alignment)
+{
+ Q_D(QQuickDialogButtonBox);
+ if (d->alignment == alignment)
+ return;
+
+ d->alignment = alignment;
+ if (isComponentComplete()) {
+ d->resizeContent();
+ polish();
+ }
+ emit alignmentChanged();
+}
+
+void QQuickDialogButtonBox::resetAlignment()
+{
+ setAlignment(0);
+}
+
+/*!
+ \qmlproperty enumeration QtQuick.Controls::DialogButtonBox::standardButtons
+
+ This property holds a combination of standard buttons that are used by the button box.
+
+ \snippet qtquickcontrols2-dialogbuttonbox.qml 1
+
+ Possible flags:
+ \value DialogButtonBox.Ok An "OK" button defined with the \c AcceptRole.
+ \value DialogButtonBox.Open An "Open" button defined with the \c AcceptRole.
+ \value DialogButtonBox.Save A "Save" button defined with the \c AcceptRole.
+ \value DialogButtonBox.Cancel A "Cancel" button defined with the \c RejectRole.
+ \value DialogButtonBox.Close A "Close" button defined with the \c RejectRole.
+ \value DialogButtonBox.Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the \c DestructiveRole.
+ \value DialogButtonBox.Apply An "Apply" button defined with the \c ApplyRole.
+ \value DialogButtonBox.Reset A "Reset" button defined with the \c ResetRole.
+ \value DialogButtonBox.RestoreDefaults A "Restore Defaults" button defined with the \c ResetRole.
+ \value DialogButtonBox.Help A "Help" button defined with the \c HelpRole.
+ \value DialogButtonBox.SaveAll A "Save All" button defined with the \c AcceptRole.
+ \value DialogButtonBox.Yes A "Yes" button defined with the \c YesRole.
+ \value DialogButtonBox.YesToAll A "Yes to All" button defined with the \c YesRole.
+ \value DialogButtonBox.No A "No" button defined with the \c NoRole.
+ \value DialogButtonBox.NoToAll A "No to All" button defined with the \c NoRole.
+ \value DialogButtonBox.Abort An "Abort" button defined with the \c RejectRole.
+ \value DialogButtonBox.Retry A "Retry" button defined with the \c AcceptRole.
+ \value DialogButtonBox.Ignore An "Ignore" button defined with the \c AcceptRole.
+ \value DialogButtonBox.NoButton An invalid button.
+
+ \sa standardButton()
+*/
+QPlatformDialogHelper::StandardButtons QQuickDialogButtonBox::standardButtons() const
+{
+ Q_D(const QQuickDialogButtonBox);
+ return d->standardButtons;
+}
+
+void QQuickDialogButtonBox::setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
+{
+ Q_D(QQuickDialogButtonBox);
+ if (d->standardButtons == buttons)
+ return;
+
+ d->removeStandardButtons();
+
+ for (int i = QPlatformDialogHelper::FirstButton; i <= QPlatformDialogHelper::LastButton; i<<=1) {
+ QPlatformDialogHelper::StandardButton standardButton = static_cast<QPlatformDialogHelper::StandardButton>(i);
+ if (standardButton & buttons) {
+ QQuickAbstractButton *button = d->createStandardButton(standardButton);
+ if (button)
+ addItem(button);
+ }
+ }
+
+ if (isComponentComplete())
+ polish();
+
+ d->standardButtons = buttons;
+ emit standardButtonsChanged();
+}
+
+/*!
+ \qmlmethod AbstractButton QtQuick.Controls::DialogButtonBox::standardButton(StandardButton button)
+
+ Returns the specified standard \a button, or \c null if it does not exist.
+
+ \sa standardButtons
+*/
+QQuickAbstractButton *QQuickDialogButtonBox::standardButton(QPlatformDialogHelper::StandardButton button) const
+{
+ Q_UNUSED(button);
+ return nullptr;
+}
+
+/*!
+ \qmlproperty Component QtQuick.Controls::DialogButtonBox::delegate
+
+ This property holds a delegate for creating standard buttons.
+
+ \sa standardButtons
+*/
+QQmlComponent *QQuickDialogButtonBox::delegate() const
+{
+ Q_D(const QQuickDialogButtonBox);
+ return d->delegate;
+}
+
+void QQuickDialogButtonBox::setDelegate(QQmlComponent* delegate)
+{
+ Q_D(QQuickDialogButtonBox);
+ if (d->delegate == delegate)
+ return;
+
+ delete d->delegate;
+ d->delegate = delegate;
+ emit delegateChanged();
+}
+
+QQuickDialogButtonBoxAttached *QQuickDialogButtonBox::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickDialogButtonBoxAttached(object);
+}
+
+void QQuickDialogButtonBox::updatePolish()
+{
+ Q_D(QQuickDialogButtonBox);
+ QQuickContainer::updatePolish();
+ d->updateLayout();
+}
+
+void QQuickDialogButtonBox::componentComplete()
+{
+ Q_D(QQuickDialogButtonBox);
+ QQuickContainer::componentComplete();
+ d->updateLayout();
+}
+
+void QQuickDialogButtonBox::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickDialogButtonBox);
+ QQuickContainer::geometryChanged(newGeometry, oldGeometry);
+ d->updateLayout();
+}
+
+void QQuickDialogButtonBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
+{
+ Q_D(QQuickDialogButtonBox);
+ QQuickContainer::contentItemChange(newItem, oldItem);
+ if (oldItem)
+ QQuickItemPrivate::get(oldItem)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
+ if (newItem)
+ QQuickItemPrivate::get(newItem)->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
+}
+
+bool QQuickDialogButtonBox::isContent(QQuickItem *item) const
+{
+ return qobject_cast<QQuickAbstractButton *>(item);
+}
+
+void QQuickDialogButtonBox::itemAdded(int index, QQuickItem *item)
+{
+ Q_D(QQuickDialogButtonBox);
+ Q_UNUSED(index);
+ if (QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(item))
+ QObjectPrivate::connect(button, &QQuickAbstractButton::clicked, d, &QQuickDialogButtonBoxPrivate::handleClick);
+ if (QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(item, false)))
+ QQuickDialogButtonBoxAttachedPrivate::get(attached)->setButtonBox(this);
+ if (isComponentComplete())
+ polish();
+}
+
+void QQuickDialogButtonBox::itemRemoved(int index, QQuickItem *item)
+{
+ Q_D(QQuickDialogButtonBox);
+ Q_UNUSED(index);
+ if (QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(item))
+ QObjectPrivate::disconnect(button, &QQuickAbstractButton::clicked, d, &QQuickDialogButtonBoxPrivate::handleClick);
+ if (QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(item, false)))
+ QQuickDialogButtonBoxAttachedPrivate::get(attached)->setButtonBox(nullptr);
+ if (isComponentComplete())
+ polish();
+}
+
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickDialogButtonBox::accessibleRole() const
+{
+ return QAccessible::PageTabList;
+}
+#endif
+
+void QQuickDialogButtonBoxAttachedPrivate::setButtonBox(QQuickDialogButtonBox *box)
+{
+ Q_Q(QQuickDialogButtonBoxAttached);
+ if (buttonBox == box)
+ return;
+
+ buttonBox = box;
+ emit q->buttonBoxChanged();
+}
+
+QQuickDialogButtonBoxAttached::QQuickDialogButtonBoxAttached(QObject *parent) :
+ QObject(*(new QQuickDialogButtonBoxAttachedPrivate), parent)
+{
+ Q_D(QQuickDialogButtonBoxAttached);
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent);
+ while (parentItem && !d->buttonBox) {
+ d->buttonBox = qobject_cast<QQuickDialogButtonBox *>(parentItem);
+ parentItem = parentItem->parentItem();
+ }
+}
+
+/*!
+ \qmlattachedproperty DialogButtonBox QtQuick.Controls::DialogButtonBox::buttonBox
+ \readonly
+
+ This attached property holds the button box that manages this button, or
+ \c null if the button is not in a button box.
+*/
+QQuickDialogButtonBox *QQuickDialogButtonBoxAttached::buttonBox() const
+{
+ Q_D(const QQuickDialogButtonBoxAttached);
+ return d->buttonBox;
+}
+
+/*!
+ \qmlattachedproperty enumeration QtQuick.Controls::DialogButtonBox::buttonRole
+
+ This attached property holds the role of each button in a button box.
+
+ \snippet qtquickcontrols2-dialogbuttonbox-attached.qml 1
+
+ Available values:
+ \value DialogButtonBox.InvalidRole The button is invalid.
+ \value DialogButtonBox.AcceptRole Clicking the button causes the dialog to be accepted (e.g. \uicontrol OK).
+ \value DialogButtonBox.RejectRole Clicking the button causes the dialog to be rejected (e.g. \uicontrol Cancel).
+ \value DialogButtonBox.DestructiveRole Clicking the button causes a destructive change (e.g. for discarding changes) and closes the dialog.
+ \value DialogButtonBox.ActionRole Clicking the button causes changes to the elements within the dialog.
+ \value DialogButtonBox.HelpRole The button can be clicked to request help.
+ \value DialogButtonBox.YesRole The button is a "Yes"-like button.
+ \value DialogButtonBox.NoRole The button is a "No"-like button.
+ \value DialogButtonBox.ResetRole The button resets the dialog's fields to default values.
+ \value DialogButtonBox.ApplyRole The button applies current changes.
+*/
+QPlatformDialogHelper::ButtonRole QQuickDialogButtonBoxAttached::buttonRole() const
+{
+ Q_D(const QQuickDialogButtonBoxAttached);
+ return d->buttonRole;
+}
+
+void QQuickDialogButtonBoxAttached::setButtonRole(QPlatformDialogHelper::ButtonRole role)
+{
+ Q_D(QQuickDialogButtonBoxAttached);
+ if (d->buttonRole == role)
+ return;
+
+ d->buttonRole = role;
+ emit buttonRoleChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p.h
new file mode 100644
index 00000000..445b645b
--- /dev/null
+++ b/src/quicktemplates2/qquickdialogbuttonbox_p.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDIALOGBUTTONBOX_P_H
+#define QQUICKDIALOGBUTTONBOX_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickcontainer_p.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlComponent;
+class QQuickAbstractButton;
+class QQuickDialogButtonBoxPrivate;
+class QQuickDialogButtonBoxAttached;
+class QQuickDialogButtonBoxAttachedPrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBox : public QQuickContainer
+{
+ Q_OBJECT
+ Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment RESET resetAlignment NOTIFY alignmentChanged FINAL)
+ Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
+ Q_FLAGS(QPlatformDialogHelper::StandardButtons)
+
+public:
+ explicit QQuickDialogButtonBox(QQuickItem *parent = nullptr);
+ ~QQuickDialogButtonBox();
+
+ enum Position {
+ Header,
+ Footer
+ };
+ Q_ENUM(Position)
+
+ Position position() const;
+ void setPosition(Position position);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment alignment);
+ void resetAlignment();
+
+ QPlatformDialogHelper::StandardButtons standardButtons() const;
+ void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons);
+ Q_INVOKABLE QQuickAbstractButton *standardButton(QPlatformDialogHelper::StandardButton button) const;
+
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
+ static QQuickDialogButtonBoxAttached *qmlAttachedProperties(QObject *object);
+
+Q_SIGNALS:
+ void accepted();
+ void rejected();
+ void helpRequested();
+ void clicked(QQuickAbstractButton *button);
+
+ void positionChanged();
+ void alignmentChanged();
+ void standardButtonsChanged();
+ void delegateChanged();
+
+protected:
+ void updatePolish() override;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
+ bool isContent(QQuickItem *item) const override;
+ void itemAdded(int index, QQuickItem *item) override;
+ void itemRemoved(int index, QQuickItem *item) override;
+
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
+private:
+ Q_DISABLE_COPY(QQuickDialogButtonBox)
+ Q_DECLARE_PRIVATE(QQuickDialogButtonBox)
+};
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBoxAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL)
+ Q_PROPERTY(QPlatformDialogHelper::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY buttonRoleChanged FINAL)
+ Q_ENUMS(QPlatformDialogHelper::ButtonRole)
+
+public:
+ explicit QQuickDialogButtonBoxAttached(QObject *parent = nullptr);
+
+ QQuickDialogButtonBox *buttonBox() const;
+
+ QPlatformDialogHelper::ButtonRole buttonRole() const;
+ void setButtonRole(QPlatformDialogHelper::ButtonRole role);
+
+Q_SIGNALS:
+ void buttonBoxChanged();
+ void buttonRoleChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickDialogButtonBoxAttached)
+ Q_DECLARE_PRIVATE(QQuickDialogButtonBoxAttached)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickDialogButtonBox)
+QML_DECLARE_TYPEINFO(QQuickDialogButtonBox, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QQUICKDIALOGBUTTONBOX_P_H
diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
new file mode 100644
index 00000000..d25bd90a
--- /dev/null
+++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKDIALOGBUTTONBOX_P_P_H
+#define QQUICKDIALOGBUTTONBOX_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickcontainer_p_p.h>
+#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickDialogButtonBoxPrivate : public QQuickContainerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickDialogButtonBox)
+
+public:
+ QQuickDialogButtonBoxPrivate();
+
+ static QQuickDialogButtonBoxPrivate *get(QQuickDialogButtonBox *box)
+ {
+ return box->d_func();
+ }
+
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
+
+ void resizeContent() override;
+ void updateLayout();
+ void handleClick();
+
+ QQuickAbstractButton *createStandardButton(QPlatformDialogHelper::StandardButton button);
+ void removeStandardButtons();
+
+ Qt::Alignment alignment;
+ QQuickDialogButtonBox::Position position;
+ QPlatformDialogHelper::StandardButtons standardButtons;
+ QQmlComponent *delegate;
+};
+
+class QQuickDialogButtonBoxAttachedPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickDialogButtonBoxAttached)
+
+public:
+ QQuickDialogButtonBoxAttachedPrivate() : buttonBox(nullptr),
+ buttonRole(QPlatformDialogHelper::InvalidRole),
+ standardButton(QPlatformDialogHelper::NoButton) { }
+
+ static QQuickDialogButtonBoxAttachedPrivate *get(QQuickDialogButtonBoxAttached *q)
+ {
+ return q->d_func();
+ }
+
+ void setButtonBox(QQuickDialogButtonBox *box);
+
+ QQuickDialogButtonBox *buttonBox;
+ QPlatformDialogHelper::ButtonRole buttonRole;
+ QPlatformDialogHelper::StandardButton standardButton;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKDIALOGBUTTONBOX_P_P_H
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 1dae911e..36493e79 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -118,7 +118,7 @@ QT_BEGIN_NAMESPACE
\code
import QtQuick 2.7
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
id: window
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index 2203e574..ab5415d3 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -211,7 +211,7 @@ void QQuickMenuPrivate::itemDestroyed(QQuickItem *item)
removeItem(index, item);
}
-void QQuickMenuPrivate::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
+void QQuickMenuPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
if (complete)
resizeItems();
diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h
index c27e6631..4ca3c379 100644
--- a/src/quicktemplates2/qquickmenu_p_p.h
+++ b/src/quicktemplates2/qquickmenu_p_p.h
@@ -76,7 +76,7 @@ public:
void itemSiblingOrderChanged(QQuickItem *item) override;
void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
void itemDestroyed(QQuickItem *item) override;
- void itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *, QQuickGeometryChange change, const QRectF &diff) override;
void onItemPressed();
void onItemActiveFocusChanged();
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp
index 564d3f38..cb23df07 100644
--- a/src/quicktemplates2/qquickmenuitem.cpp
+++ b/src/quicktemplates2/qquickmenuitem.cpp
@@ -110,22 +110,6 @@ QQuickMenuItem::QQuickMenuItem(QQuickItem *parent) :
connect(this, &QQuickAbstractButton::clicked, this, &QQuickMenuItem::triggered);
}
-/*!
- \qmlproperty bool QtQuick.Controls::MenuItem::checkable
-
- This property holds whether the menu item is checkable.
-
- A checkable menu item toggles between checked (on) and unchecked (off) when
- the user clicks on it or interacts with it via the keyboard.
-
- \sa {AbstractButton::}{checked}
-*/
-
-void QQuickMenuItem::checkableChange()
-{
- emit checkableChanged();
-}
-
QFont QQuickMenuItem::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::MenuItemFont);
diff --git a/src/quicktemplates2/qquickmenuitem_p.h b/src/quicktemplates2/qquickmenuitem_p.h
index 6c717e13..258a096f 100644
--- a/src/quicktemplates2/qquickmenuitem_p.h
+++ b/src/quicktemplates2/qquickmenuitem_p.h
@@ -57,7 +57,6 @@ class QQuickMenuItemPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuItem : public QQuickAbstractButton
{
Q_OBJECT
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
public:
@@ -67,12 +66,10 @@ public:
void setHighlighted(bool highlighted);
Q_SIGNALS:
- void checkableChanged();
void triggered();
void highlightedChanged();
protected:
- void checkableChange() override;
QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/quicktemplates2/qquickmenuseparator.cpp b/src/quicktemplates2/qquickmenuseparator.cpp
new file mode 100644
index 00000000..9aea6a91
--- /dev/null
+++ b/src/quicktemplates2/qquickmenuseparator.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickmenuseparator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype MenuSeparator
+ \inherits Control
+ \instantiates QQuickMenuSeparator
+ \inqmlmodule QtQuick.Controls
+ \since 5.8
+ \ingroup qtquickcontrols2-separators
+ \brief Separates a group of items in a menu from adjacent items.
+
+ MenuSeparator is used to visually distinguish between groups of items in a
+ menu by separating them with a line.
+
+ \image qtquickcontrols2-menuseparator.png
+
+ \quotefromfile qtquickcontrols2-menuseparator-custom.qml
+ \skipto import QtQuick 2.6
+ \printuntil import QtQuick.Controls 2.1
+ \skipto Menu
+ \printto contentItem.parent: window
+ \skipline contentItem.parent: window
+ \printuntil text: qsTr("Exit")
+ \printuntil }
+ \printuntil }
+
+ \sa {Customizing MenuSeparator}, {Separator Controls}
+*/
+
+QQuickMenuSeparator::QQuickMenuSeparator(QQuickItem *parent) :
+ QQuickControl(parent)
+{
+}
+
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickMenuSeparator::accessibleRole() const
+{
+ return QAccessible::Separator;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickmenuseparator_p.h b/src/quicktemplates2/qquickmenuseparator_p.h
new file mode 100644
index 00000000..95a8f8fa
--- /dev/null
+++ b/src/quicktemplates2/qquickmenuseparator_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKMENUSEPARATOR_P_H
+#define QQUICKMENUSEPARATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickcontrol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuSeparator : public QQuickControl
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickMenuSeparator(QQuickItem *parent = nullptr);
+
+protected:
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
+private:
+ Q_DISABLE_COPY(QQuickMenuSeparator)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickMenuSeparator)
+
+#endif // QQUICKMENUSEPARATOR_P_H
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 4a95244f..6bb44499 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -163,10 +163,10 @@ QVector<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
return sorted;
}
-void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &)
+void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &)
{
Q_Q(QQuickOverlay);
- q->setSize(newGeometry.size());
+ q->setSize(QSizeF(item->width(), item->height()));
}
QQuickOverlayPrivate::QQuickOverlayPrivate() :
diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h
index 6e72b39a..b10bfe83 100644
--- a/src/quicktemplates2/qquickoverlay_p_p.h
+++ b/src/quicktemplates2/qquickoverlay_p_p.h
@@ -84,7 +84,7 @@ public:
QVector<QQuickPopup *> stackingOrderPopups() const;
QVector<QQuickDrawer *> stackingOrderDrawers() const;
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
QQmlComponent *modal;
QQmlComponent *modeless;
diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp
index c71ecd42..ad1e4ebd 100644
--- a/src/quicktemplates2/qquickpage.cpp
+++ b/src/quicktemplates2/qquickpage.cpp
@@ -36,10 +36,7 @@
#include "qquickpage_p.h"
#include "qquickcontrol_p_p.h"
-#include "qquicktoolbar_p.h"
-#include "qquicktabbar_p.h"
-
-#include <QtQuick/private/qquickitemchangelistener_p.h>
+#include "qquickpagelayout_p_p.h"
QT_BEGIN_NAMESPACE
@@ -61,7 +58,7 @@ QT_BEGIN_NAMESPACE
toolbar header and an application-wide tabbar footer.
\qml
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
visible: true
@@ -85,81 +82,42 @@ QT_BEGIN_NAMESPACE
\sa ApplicationWindow, {Container Controls}
*/
-class QQuickPagePrivate : public QQuickControlPrivate, public QQuickItemChangeListener
+class QQuickPagePrivate : public QQuickControlPrivate
{
Q_DECLARE_PUBLIC(QQuickPage)
public:
QQuickPagePrivate();
- void relayout();
-
- void itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect) override;
- void itemVisibilityChanged(QQuickItem *item) override;
- void itemImplicitWidthChanged(QQuickItem *item) override;
- void itemImplicitHeightChanged(QQuickItem *item) override;
+ QQuickItem *getContentItem() override;
+ qreal contentWidth;
+ qreal contentHeight;
QString title;
- QQuickItem *header;
- QQuickItem *footer;
+ QScopedPointer<QQuickPageLayout> layout;
};
-QQuickPagePrivate::QQuickPagePrivate() : header(nullptr), footer(nullptr)
+QQuickPagePrivate::QQuickPagePrivate()
+ : contentWidth(0),
+ contentHeight(0)
{
}
-void QQuickPagePrivate::relayout()
+QQuickItem *QQuickPagePrivate::getContentItem()
{
Q_Q(QQuickPage);
- QQuickItem *content = q->contentItem();
- const qreal hh = header && header->isVisible() ? header->height() : 0;
- const qreal fh = footer && footer->isVisible() ? footer->height() : 0;
-
- content->setY(hh + q->topPadding());
- content->setX(q->leftPadding());
- content->setWidth(q->availableWidth());
- content->setHeight(q->availableHeight() - hh - fh);
-
- if (header)
- header->setWidth(q->width());
-
- if (footer) {
- footer->setY(q->height() - fh);
- footer->setWidth(q->width());
- }
-}
-
-void QQuickPagePrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newRect, const QRectF &oldRect)
-{
- Q_UNUSED(item)
- Q_UNUSED(newRect)
- Q_UNUSED(oldRect)
- relayout();
-}
-
-void QQuickPagePrivate::itemVisibilityChanged(QQuickItem *item)
-{
- Q_UNUSED(item);
- relayout();
-}
-
-void QQuickPagePrivate::itemImplicitWidthChanged(QQuickItem *item)
-{
- Q_UNUSED(item);
- relayout();
-}
-
-void QQuickPagePrivate::itemImplicitHeightChanged(QQuickItem *item)
-{
- Q_UNUSED(item);
- relayout();
+ if (!contentItem)
+ contentItem = new QQuickItem(q);
+ return contentItem;
}
QQuickPage::QQuickPage(QQuickItem *parent) :
QQuickControl(*(new QQuickPagePrivate), parent)
{
+ Q_D(QQuickPage);
setFlag(ItemIsFocusScope);
setAcceptedMouseButtons(Qt::AllButtons);
+ d->layout.reset(new QQuickPageLayout(this));
}
/*!
@@ -221,43 +179,25 @@ void QQuickPage::setTitle(const QString &title)
This property holds the page header item. The header item is positioned to
the top, and resized to the width of the page. The default value is \c null.
- \note Assigning a ToolBar or TabBar as a page header sets the respective
- \l ToolBar::position or \l TabBar::position property automatically to \c Header.
+ \note Assigning a ToolBar, TabBar, or DialogButtonBox as a page header
+ automatically sets the respective \l ToolBar::position, \l TabBar::position,
+ or \l DialogButtonBox::position property to \c Header.
\sa footer, ApplicationWindow::header
*/
QQuickItem *QQuickPage::header() const
{
Q_D(const QQuickPage);
- return d->header;
+ return d->layout->header();
}
void QQuickPage::setHeader(QQuickItem *header)
{
Q_D(QQuickPage);
- if (d->header == header)
+ if (!d->layout->setHeader(header))
return;
-
- if (d->header) {
- QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility |
- QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->header->setParentItem(nullptr);
- }
- d->header = header;
- if (header) {
- header->setParentItem(this);
- QQuickItemPrivate *p = QQuickItemPrivate::get(header);
- p->addItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility |
- QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(header->z()))
- header->setZ(1);
- if (QQuickToolBar *toolBar = qobject_cast<QQuickToolBar *>(header))
- toolBar->setPosition(QQuickToolBar::Header);
- else if (QQuickTabBar *tabBar = qobject_cast<QQuickTabBar *>(header))
- tabBar->setPosition(QQuickTabBar::Header);
- }
if (isComponentComplete())
- d->relayout();
+ d->layout->update();
emit headerChanged();
}
@@ -267,47 +207,79 @@ void QQuickPage::setHeader(QQuickItem *header)
This property holds the page footer item. The footer item is positioned to
the bottom, and resized to the width of the page. The default value is \c null.
- \note Assigning a ToolBar or TabBar as a page footer sets the respective
- \l ToolBar::position or \l TabBar::position property automatically to \c Footer.
+ \note Assigning a ToolBar, TabBar, or DialogButtonBox as a page footer
+ automatically sets the respective \l ToolBar::position, \l TabBar::position,
+ or \l DialogButtonBox::position property to \c Footer.
\sa header, ApplicationWindow::footer
*/
QQuickItem *QQuickPage::footer() const
{
Q_D(const QQuickPage);
- return d->footer;
+ return d->layout->footer();
}
void QQuickPage::setFooter(QQuickItem *footer)
{
Q_D(QQuickPage);
- if (d->footer == footer)
+ if (!d->layout->setFooter(footer))
return;
-
- if (d->footer) {
- QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility |
- QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->footer->setParentItem(nullptr);
- }
- d->footer = footer;
- if (footer) {
- footer->setParentItem(this);
- QQuickItemPrivate *p = QQuickItemPrivate::get(footer);
- p->addItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility |
- QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(footer->z()))
- footer->setZ(1);
- if (QQuickToolBar *toolBar = qobject_cast<QQuickToolBar *>(footer))
- toolBar->setPosition(QQuickToolBar::Footer);
- else if (QQuickTabBar *tabBar = qobject_cast<QQuickTabBar *>(footer))
- tabBar->setPosition(QQuickTabBar::Footer);
- }
if (isComponentComplete())
- d->relayout();
+ d->layout->update();
emit footerChanged();
}
/*!
+ \qmlproperty real QtQuick.Controls::Page::contentWidth
+ \since QtQuick.Controls 2.1
+
+ This property holds the content width. It is used for calculating the total
+ implicit width of the page.
+
+ \sa contentHeight
+*/
+qreal QQuickPage::contentWidth() const
+{
+ Q_D(const QQuickPage);
+ return d->contentWidth;
+}
+
+void QQuickPage::setContentWidth(qreal width)
+{
+ Q_D(QQuickPage);
+ if (qFuzzyCompare(d->contentWidth, width))
+ return;
+
+ d->contentWidth = width;
+ emit contentWidthChanged();
+}
+
+/*!
+ \qmlproperty real QtQuick.Controls::Page::contentHeight
+ \since QtQuick.Controls 2.1
+
+ This property holds the content height. It is used for calculating the total
+ implicit height of the page.
+
+ \sa contentWidth
+*/
+qreal QQuickPage::contentHeight() const
+{
+ Q_D(const QQuickPage);
+ return d->contentHeight;
+}
+
+void QQuickPage::setContentHeight(qreal height)
+{
+ Q_D(QQuickPage);
+ if (qFuzzyCompare(d->contentHeight, height))
+ return;
+
+ d->contentHeight = height;
+ emit contentHeightChanged();
+}
+
+/*!
\qmlproperty list<Object> QtQuick.Controls::Page::contentData
\default
@@ -324,7 +296,7 @@ void QQuickPage::setFooter(QQuickItem *footer)
QQmlListProperty<QObject> QQuickPage::contentData()
{
Q_D(QQuickPage);
- return QQmlListProperty<QObject>(d->contentItem, nullptr,
+ return QQmlListProperty<QObject>(d->getContentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -347,7 +319,7 @@ QQmlListProperty<QObject> QQuickPage::contentData()
QQmlListProperty<QQuickItem> QQuickPage::contentChildren()
{
Q_D(QQuickPage);
- return QQmlListProperty<QQuickItem>(d->contentItem, nullptr,
+ return QQmlListProperty<QQuickItem>(d->getContentItem(), nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
@@ -368,14 +340,21 @@ void QQuickPage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo
{
Q_D(QQuickPage);
QQuickControl::geometryChanged(newGeometry, oldGeometry);
- d->relayout();
+ d->layout->update();
}
void QQuickPage::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding)
{
Q_D(QQuickPage);
QQuickControl::paddingChange(newPadding, oldPadding);
- d->relayout();
+ d->layout->update();
+}
+
+void QQuickPage::spacingChange(qreal newSpacing, qreal oldSpacing)
+{
+ Q_D(QQuickPage);
+ QQuickControl::spacingChange(newSpacing, oldSpacing);
+ d->layout->update();
}
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/quicktemplates2/qquickpage_p.h b/src/quicktemplates2/qquickpage_p.h
index 64f7602f..6493cee7 100644
--- a/src/quicktemplates2/qquickpage_p.h
+++ b/src/quicktemplates2/qquickpage_p.h
@@ -61,6 +61,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPage : public QQuickControl
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
+ Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL REVISION 1)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL REVISION 1)
Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL)
Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL)
Q_CLASSINFO("DefaultProperty", "contentData")
@@ -77,6 +79,12 @@ public:
QQuickItem *footer() const;
void setFooter(QQuickItem *footer);
+ qreal contentWidth() const;
+ void setContentWidth(qreal width);
+
+ qreal contentHeight() const;
+ void setContentHeight(qreal height);
+
QQmlListProperty<QObject> contentData();
QQmlListProperty<QQuickItem> contentChildren();
@@ -84,12 +92,15 @@ Q_SIGNALS:
void titleChanged();
void headerChanged();
void footerChanged();
+ Q_REVISION(1) void contentWidthChanged();
+ Q_REVISION(1) void contentHeightChanged();
void contentChildrenChanged();
protected:
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
+ void spacingChange(qreal newSpacing, qreal oldSpacing) override;
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role accessibleRole() const override;
diff --git a/src/quicktemplates2/qquickpagelayout.cpp b/src/quicktemplates2/qquickpagelayout.cpp
new file mode 100644
index 00000000..b787dd08
--- /dev/null
+++ b/src/quicktemplates2/qquickpagelayout.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickpagelayout_p_p.h"
+#include "qquickcontrol_p.h"
+#include "qquicktoolbar_p.h"
+#include "qquicktabbar_p.h"
+#include "qquickdialogbuttonbox_p.h"
+
+#include <QtQuick/private/qquickitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static const QQuickItemPrivate::ChangeTypes ItemChanges = QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility | QQuickItemPrivate::Destroyed
+ | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight;
+
+namespace {
+ enum Position {
+ Header,
+ Footer
+ };
+
+ Q_STATIC_ASSERT(int(Header) == int(QQuickTabBar::Header));
+ Q_STATIC_ASSERT(int(Footer) == int(QQuickTabBar::Footer));
+
+ Q_STATIC_ASSERT(int(Header) == int(QQuickToolBar::Header));
+ Q_STATIC_ASSERT(int(Footer) == int(QQuickToolBar::Footer));
+
+ Q_STATIC_ASSERT(int(Header) == int(QQuickDialogButtonBox::Header));
+ Q_STATIC_ASSERT(int(Footer) == int(QQuickDialogButtonBox::Footer));
+}
+
+static void setPosition(QQuickItem *item, Position position)
+{
+ if (QQuickToolBar *toolBar = qobject_cast<QQuickToolBar *>(item))
+ toolBar->setPosition(static_cast<QQuickToolBar::Position>(position));
+ else if (QQuickTabBar *tabBar = qobject_cast<QQuickTabBar *>(item))
+ tabBar->setPosition(static_cast<QQuickTabBar::Position>(position));
+ else if (QQuickDialogButtonBox *buttonBox = qobject_cast<QQuickDialogButtonBox *>(item))
+ buttonBox->setPosition(static_cast<QQuickDialogButtonBox::Position>(position));
+}
+
+QQuickPageLayout::QQuickPageLayout(QQuickControl *control)
+ : m_header(nullptr), m_footer(nullptr), m_control(control)
+{
+}
+
+QQuickPageLayout::~QQuickPageLayout()
+{
+ if (m_header)
+ QQuickItemPrivate::get(m_header)->removeItemChangeListener(this, ItemChanges);
+ if (m_footer)
+ QQuickItemPrivate::get(m_footer)->removeItemChangeListener(this, ItemChanges);
+}
+
+QQuickItem *QQuickPageLayout::header() const
+{
+ return m_header;
+}
+
+bool QQuickPageLayout::setHeader(QQuickItem *header)
+{
+ if (m_header == header)
+ return false;
+
+ if (m_header) {
+ QQuickItemPrivate::get(m_header)->removeItemChangeListener(this, ItemChanges);
+ m_header->setParentItem(nullptr);
+ }
+ m_header = header;
+ if (header) {
+ header->setParentItem(m_control);
+ QQuickItemPrivate::get(header)->addItemChangeListener(this, ItemChanges);
+ if (qFuzzyIsNull(header->z()))
+ header->setZ(1);
+ setPosition(header, Header);
+ }
+ return true;
+}
+
+QQuickItem *QQuickPageLayout::footer() const
+{
+ return m_footer;
+}
+
+bool QQuickPageLayout::setFooter(QQuickItem *footer)
+{
+ if (m_footer == footer)
+ return false;
+
+ if (m_footer) {
+ QQuickItemPrivate::get(m_footer)->removeItemChangeListener(this, ItemChanges);
+ m_footer->setParentItem(nullptr);
+ }
+ m_footer = footer;
+ if (footer) {
+ footer->setParentItem(m_control);
+ QQuickItemPrivate::get(footer)->addItemChangeListener(this, ItemChanges);
+ if (qFuzzyIsNull(footer->z()))
+ footer->setZ(1);
+ setPosition(footer, Footer);
+ }
+ return true;
+}
+
+void QQuickPageLayout::update()
+{
+ QQuickItem *content = m_control->contentItem();
+
+ const qreal hh = m_header && m_header->isVisible() ? m_header->height() : 0;
+ const qreal fh = m_footer && m_footer->isVisible() ? m_footer->height() : 0;
+ const qreal hsp = hh > 0 ? m_control->spacing() : 0;
+ const qreal fsp = fh > 0 ? m_control->spacing() : 0;
+
+ content->setY(m_control->topPadding() + hh + hsp);
+ content->setX(m_control->leftPadding());
+ content->setWidth(m_control->availableWidth());
+ content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp);
+
+ if (m_header)
+ m_header->setWidth(m_control->width());
+
+ if (m_footer) {
+ m_footer->setY(m_control->height() - m_footer->height());
+ m_footer->setWidth(m_control->width());
+ }
+}
+
+void QQuickPageLayout::itemVisibilityChanged(QQuickItem *)
+{
+ update();
+}
+
+void QQuickPageLayout::itemImplicitWidthChanged(QQuickItem *)
+{
+ update();
+}
+
+void QQuickPageLayout::itemImplicitHeightChanged(QQuickItem *)
+{
+ update();
+}
+
+void QQuickPageLayout::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
+{
+ update();
+}
+
+void QQuickPageLayout::itemDestroyed(QQuickItem *item)
+{
+ if (item == m_header)
+ m_header = nullptr;
+ else if (item == m_footer)
+ m_footer = nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickpagelayout_p_p.h b/src/quicktemplates2/qquickpagelayout_p_p.h
new file mode 100644
index 00000000..fbeaa877
--- /dev/null
+++ b/src/quicktemplates2/qquickpagelayout_p_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPAGELAYOUT_P_P_H
+#define QQUICKPAGELAYOUT_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qquickitemchangelistener_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickControl;
+
+class QQuickPageLayout : public QQuickItemChangeListener
+{
+public:
+ explicit QQuickPageLayout(QQuickControl *control);
+ ~QQuickPageLayout();
+
+ QQuickItem *header() const;
+ bool setHeader(QQuickItem *header);
+
+ QQuickItem *footer() const;
+ bool setFooter(QQuickItem *footer);
+
+ void update();
+
+protected:
+ void itemVisibilityChanged(QQuickItem *item) override;
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
+ void itemDestroyed(QQuickItem *item) override;
+
+private:
+ QQuickItem *m_header;
+ QQuickItem *m_footer;
+ QQuickControl *m_control;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPAGELAYOUT_P_P_H
diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp
index 9f9c139b..ea296eb6 100644
--- a/src/quicktemplates2/qquickpane.cpp
+++ b/src/quicktemplates2/qquickpane.cpp
@@ -108,6 +108,14 @@ QQuickPanePrivate::QQuickPanePrivate() : contentWidth(0), contentHeight(0)
{
}
+QQuickItem *QQuickPanePrivate::getContentItem()
+{
+ Q_Q(QQuickPane);
+ if (!contentItem)
+ contentItem = new QQuickItem(q);
+ return contentItem;
+}
+
QQuickPane::QQuickPane(QQuickItem *parent) :
QQuickControl(*(new QQuickPanePrivate), parent)
{
@@ -191,7 +199,7 @@ void QQuickPane::setContentHeight(qreal height)
QQmlListProperty<QObject> QQuickPane::contentData()
{
Q_D(QQuickPane);
- return QQmlListProperty<QObject>(d->contentItem, nullptr,
+ return QQmlListProperty<QObject>(d->getContentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -214,7 +222,7 @@ QQmlListProperty<QObject> QQuickPane::contentData()
QQmlListProperty<QQuickItem> QQuickPane::contentChildren()
{
Q_D(QQuickPane);
- return QQmlListProperty<QQuickItem>(d->contentItem, nullptr,
+ return QQmlListProperty<QQuickItem>(d->getContentItem(), nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
diff --git a/src/quicktemplates2/qquickpane_p_p.h b/src/quicktemplates2/qquickpane_p_p.h
index acc0d0ab..62789664 100644
--- a/src/quicktemplates2/qquickpane_p_p.h
+++ b/src/quicktemplates2/qquickpane_p_p.h
@@ -61,6 +61,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPanePrivate : public QQuickControlP
public:
QQuickPanePrivate();
+ QQuickItem *getContentItem() override;
+
qreal contentWidth;
qreal contentHeight;
};
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index bdcfe6ca..b0281cdf 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -40,6 +40,7 @@
#include "qquickshortcutcontext_p_p.h"
#include "qquickoverlay_p_p.h"
#include "qquickcontrol_p_p.h"
+#include "qquickdialog_p.h"
#include <QtGui/private/qshortcutmap_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -64,7 +65,7 @@ QT_BEGIN_NAMESPACE
\qml
import QtQuick.Window 2.2
- import QtQuick.Controls 2.0
+ import QtQuick.Controls 2.1
ApplicationWindow {
id: window
@@ -252,6 +253,14 @@ void QQuickPopupPrivate::init()
QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged);
}
+static void closeOrReject(QQuickPopup *popup)
+{
+ if (QQuickDialog *dialog = qobject_cast<QQuickDialog*>(popup))
+ dialog->reject();
+ else
+ popup->close();
+}
+
bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
{
Q_Q(QQuickPopup);
@@ -261,7 +270,7 @@ bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
if (onOutside || onOutsideParent) {
if (!popupItem->contains(item->mapToItem(popupItem, event->pos()))) {
if (!onOutsideParent || !parentItem || !parentItem->contains(item->mapToItem(parentItem, event->pos()))) {
- q->close();
+ closeOrReject(q);
return true;
}
}
@@ -436,6 +445,8 @@ public:
void resolveFont() override;
+ QQuickItem *getContentItem() override;
+
int backId;
int escapeId;
QQuickPopup *popup;
@@ -467,6 +478,14 @@ void QQuickPopupItemPrivate::resolveFont()
inheritFont(window->font());
}
+QQuickItem *QQuickPopupItemPrivate::getContentItem()
+{
+ Q_Q(QQuickPopupItem);
+ if (!contentItem)
+ contentItem = new QQuickItem(q);
+ return contentItem;
+}
+
QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr)
{
@@ -476,7 +495,7 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
setAcceptedMouseButtons(Qt::AllButtons);
// TODO: switch to QStyleHints::useHoverEffects in Qt 5.8
- setAcceptHoverEvents(true);
+ setHoverEnabled(true);
// setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects());
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents);
}
@@ -521,7 +540,7 @@ bool QQuickPopupItem::event(QEvent *event)
if (event->type() == QEvent::Shortcut) {
QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
if (se->shortcutId() == d->escapeId || se->shortcutId() == d->backId) {
- d->popup->close();
+ closeOrReject(d->popup);
return true;
}
}
@@ -636,6 +655,13 @@ void QQuickPopupItem::paddingChange(const QMarginsF &newPadding, const QMarginsF
d->popup->paddingChange(newPadding, oldPadding);
}
+void QQuickPopupItem::spacingChange(qreal newSpacing, qreal oldSpacing)
+{
+ Q_D(QQuickPopupItem);
+ QQuickControl::spacingChange(newSpacing, oldSpacing);
+ d->popup->spacingChange(newSpacing, oldSpacing);
+}
+
QFont QQuickPopupItem::defaultFont() const
{
Q_D(const QQuickPopupItem);
@@ -698,7 +724,7 @@ void QQuickPopupPositioner::setParentItem(QQuickItem *parent)
m_popup->reposition();
}
-void QQuickPopupPositioner::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
+void QQuickPopupPositioner::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
if (m_parentItem && m_popup->popupItem->isVisible())
m_popup->reposition();
@@ -1265,6 +1291,35 @@ qreal QQuickPopup::availableHeight() const
}
/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty real QtQuick.Controls::Popup::spacing
+
+ This property holds the spacing.
+
+ Spacing is useful for popups that have multiple or repetitive building
+ blocks. For example, some styles use spacing to determine the distance
+ between the header, content, and footer of \l Dialog. Spacing is not
+ enforced by Popup, so each style may interpret it differently, and some
+ may ignore it altogether.
+*/
+qreal QQuickPopup::spacing() const
+{
+ Q_D(const QQuickPopup);
+ return d->popupItem->spacing();
+}
+
+void QQuickPopup::setSpacing(qreal spacing)
+{
+ Q_D(QQuickPopup);
+ d->popupItem->setSpacing(spacing);
+}
+
+void QQuickPopup::resetSpacing()
+{
+ setSpacing(0);
+}
+
+/*!
\qmlproperty real QtQuick.Controls::Popup::margins
This property holds the default margins around the popup.
@@ -2352,6 +2407,13 @@ void QQuickPopup::paddingChange(const QMarginsF &newPadding, const QMarginsF &ol
emit availableHeightChanged();
}
+void QQuickPopup::spacingChange(qreal newSpacing, qreal oldSpacing)
+{
+ Q_UNUSED(newSpacing);
+ Q_UNUSED(oldSpacing);
+ emit spacingChanged();
+}
+
QFont QQuickPopup::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::SystemFont);
diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
index 6393dcdc..0cff8fd7 100644
--- a/src/quicktemplates2/qquickpopup_p.h
+++ b/src/quicktemplates2/qquickpopup_p.h
@@ -84,6 +84,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL)
Q_PROPERTY(qreal availableWidth READ availableWidth NOTIFY availableWidthChanged FINAL)
Q_PROPERTY(qreal availableHeight READ availableHeight NOTIFY availableHeightChanged FINAL)
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL REVISION 1)
Q_PROPERTY(qreal margins READ margins WRITE setMargins RESET resetMargins NOTIFY marginsChanged FINAL)
Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY topMarginChanged FINAL)
Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY leftMarginChanged FINAL)
@@ -154,6 +155,10 @@ public:
qreal availableWidth() const;
qreal availableHeight() const;
+ qreal spacing() const;
+ void setSpacing(qreal spacing);
+ void resetSpacing();
+
qreal margins() const;
void setMargins(qreal margins);
void resetMargins();
@@ -293,6 +298,7 @@ Q_SIGNALS:
void contentHeightChanged();
void availableWidthChanged();
void availableHeightChanged();
+ Q_REVISION(1) void spacingChanged();
void marginsChanged();
void topMarginChanged();
void leftMarginChanged();
@@ -354,6 +360,7 @@ protected:
virtual void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data);
virtual void marginsChange(const QMarginsF &newMargins, const QMarginsF &oldMargins);
virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding);
+ virtual void spacingChange(qreal newSpacing, qreal oldSpacing);
virtual QFont defaultFont() const;
diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h
index 0c12b077..ca02530e 100644
--- a/src/quicktemplates2/qquickpopup_p_p.h
+++ b/src/quicktemplates2/qquickpopup_p_p.h
@@ -111,6 +111,7 @@ protected:
void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
void itemChange(ItemChange change, const ItemChangeData &data) override;
void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
+ void spacingChange(qreal newSpacing, qreal oldSpacing) override;
QFont defaultFont() const override;
@@ -135,7 +136,7 @@ public:
void setParentItem(QQuickItem *parent);
protected:
- void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) override;
+ void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
void itemParentChanged(QQuickItem *, QQuickItem *parent) override;
void itemChildRemoved(QQuickItem *, QQuickItem *child) override;
diff --git a/src/quicktemplates2/qquickpresshandler.cpp b/src/quicktemplates2/qquickpresshandler.cpp
index 1e1a17bc..5c868ee2 100644
--- a/src/quicktemplates2/qquickpresshandler.cpp
+++ b/src/quicktemplates2/qquickpresshandler.cpp
@@ -48,6 +48,8 @@ QQuickPressHandler::QQuickPressHandler()
: control(nullptr)
, longPress(false)
, pressAndHoldSignalIndex(-1)
+ , pressedSignalIndex(-1)
+ , releasedSignalIndex(-1)
, delayedMousePressEvent(nullptr)
{ }
@@ -61,6 +63,21 @@ void QQuickPressHandler::mousePressEvent(QMouseEvent *event)
} else {
timer.stop();
}
+
+ if (pressedSignalIndex == -1)
+ pressedSignalIndex = control->metaObject()->indexOfSignal("pressed(QQuickMouseEvent*)");
+ Q_ASSERT(pressedSignalIndex != -1);
+
+ if (QObjectPrivate::get(control)->isSignalConnected(pressedSignalIndex)) {
+ QQuickMouseEvent mev;
+ mev.reset(pressPos.x(), pressPos.y(), event->button(), event->buttons(),
+ QGuiApplication::keyboardModifiers(), false/*isClick*/, false/*wasHeld*/);
+ mev.setAccepted(true);
+ QQuickMouseEvent *mevPtr = &mev;
+ void *args[] = { nullptr, &mevPtr };
+ QMetaObject::metacall(control, QMetaObject::InvokeMetaMethod, pressedSignalIndex, args);
+ event->setAccepted(mev.isAccepted());
+ }
}
void QQuickPressHandler::mouseMoveEvent(QMouseEvent *event)
@@ -69,10 +86,26 @@ void QQuickPressHandler::mouseMoveEvent(QMouseEvent *event)
timer.stop();
}
-void QQuickPressHandler::mouseReleaseEvent(QMouseEvent *)
+void QQuickPressHandler::mouseReleaseEvent(QMouseEvent *event)
{
- if (!longPress)
+ if (!longPress) {
timer.stop();
+
+ if (releasedSignalIndex == -1)
+ releasedSignalIndex = control->metaObject()->indexOfSignal("released(QQuickMouseEvent*)");
+ Q_ASSERT(releasedSignalIndex != -1);
+
+ if (QObjectPrivate::get(control)->isSignalConnected(releasedSignalIndex)) {
+ QQuickMouseEvent mev;
+ mev.reset(pressPos.x(), pressPos.y(), event->button(), event->buttons(),
+ QGuiApplication::keyboardModifiers(), false/*isClick*/, false/*wasHeld*/);
+ mev.setAccepted(true);
+ QQuickMouseEvent *mevPtr = &mev;
+ void *args[] = { nullptr, &mevPtr };
+ QMetaObject::metacall(control, QMetaObject::InvokeMetaMethod, releasedSignalIndex, args);
+ event->setAccepted(mev.isAccepted());
+ }
+ }
}
void QQuickPressHandler::timerEvent(QTimerEvent *)
@@ -86,8 +119,9 @@ void QQuickPressHandler::timerEvent(QTimerEvent *)
longPress = QObjectPrivate::get(control)->isSignalConnected(pressAndHoldSignalIndex);
if (longPress) {
- QQuickMouseEvent mev(pressPos.x(), pressPos.y(), Qt::LeftButton, Qt::LeftButton,
- QGuiApplication::keyboardModifiers(), false/*isClick*/, true/*wasHeld*/);
+ QQuickMouseEvent mev;
+ mev.reset(pressPos.x(), pressPos.y(), Qt::LeftButton, Qt::LeftButton,
+ QGuiApplication::keyboardModifiers(), false/*isClick*/, true/*wasHeld*/);
mev.setAccepted(true);
// Use fast signal invocation since we already got its index
QQuickMouseEvent *mevPtr = &mev;
diff --git a/src/quicktemplates2/qquickpresshandler_p_p.h b/src/quicktemplates2/qquickpresshandler_p_p.h
index dec6f202..e432fe10 100644
--- a/src/quicktemplates2/qquickpresshandler_p_p.h
+++ b/src/quicktemplates2/qquickpresshandler_p_p.h
@@ -74,6 +74,8 @@ struct QQuickPressHandler
QPointF pressPos;
bool longPress;
int pressAndHoldSignalIndex;
+ int pressedSignalIndex;
+ int releasedSignalIndex;
QMouseEvent *delayedMousePressEvent;
};
diff --git a/src/quicktemplates2/qquickprogressbar.cpp b/src/quicktemplates2/qquickprogressbar.cpp
index d8ada6f4..9c198312 100644
--- a/src/quicktemplates2/qquickprogressbar.cpp
+++ b/src/quicktemplates2/qquickprogressbar.cpp
@@ -234,7 +234,6 @@ qreal QQuickProgressBar::visualPosition() const
doesn't show how much progress has been made.
\image qtquickcontrols2-progressbar-indeterminate.gif
-
*/
bool QQuickProgressBar::isIndeterminate() const
{
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 26a5b010..2f2b621c 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -91,7 +91,8 @@ public:
position(0),
handle(nullptr),
slider(slider),
- pressed(false)
+ pressed(false),
+ hovered(false)
{
}
@@ -112,6 +113,7 @@ private:
QQuickItem *handle;
QQuickRangeSlider *slider;
bool pressed;
+ bool hovered;
};
bool QQuickRangeSliderNodePrivate::isFirst() const
@@ -275,6 +277,22 @@ void QQuickRangeSliderNode::setPressed(bool pressed)
emit pressedChanged();
}
+bool QQuickRangeSliderNode::isHovered() const
+{
+ Q_D(const QQuickRangeSliderNode);
+ return d->hovered;
+}
+
+void QQuickRangeSliderNode::setHovered(bool hovered)
+{
+ Q_D(QQuickRangeSliderNode);
+ if (d->hovered == hovered)
+ return;
+
+ d->hovered = hovered;
+ emit hoveredChanged();
+}
+
void QQuickRangeSliderNode::increase()
{
Q_D(QQuickRangeSliderNode);
@@ -308,6 +326,8 @@ public:
{
}
+ void updateHover(const QPointF &pos);
+
qreal from;
qreal to;
qreal stepSize;
@@ -318,6 +338,15 @@ public:
QQuickRangeSlider::SnapMode snapMode;
};
+void QQuickRangeSliderPrivate::updateHover(const QPointF &pos)
+{
+ Q_Q(QQuickRangeSlider);
+ QQuickItem *firstHandle = first->handle();
+ QQuickItem *secondHandle = second->handle();
+ first->setHovered(firstHandle && firstHandle->isEnabled() && firstHandle->contains(q->mapToItem(firstHandle, pos)));
+ second->setHovered(secondHandle && secondHandle->isEnabled() && secondHandle->contains(q->mapToItem(secondHandle, pos)));
+}
+
static qreal valueAt(const QQuickRangeSlider *slider, qreal position)
{
return slider->from() + (slider->to() - slider->from()) * position;
@@ -431,6 +460,7 @@ void QQuickRangeSlider::setTo(qreal to)
\qmlproperty real QtQuick.Controls::RangeSlider::first.visualPosition
\qmlproperty Item QtQuick.Controls::RangeSlider::first.handle
\qmlproperty bool QtQuick.Controls::RangeSlider::first.pressed
+ \qmlproperty bool QtQuick.Controls::RangeSlider::first.hovered
\table
\header
@@ -471,6 +501,10 @@ void QQuickRangeSlider::setTo(qreal to)
\row
\li pressed
\li This property holds whether the first handle is pressed.
+ \row
+ \li hovered
+ \li This property holds whether the first handle is hovered.
+ This property was introduced in QtQuick.Controls 2.1.
\endtable
\sa first.increase(), first.decrease()
@@ -488,6 +522,7 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\qmlproperty real QtQuick.Controls::RangeSlider::second.visualPosition
\qmlproperty Item QtQuick.Controls::RangeSlider::second.handle
\qmlproperty bool QtQuick.Controls::RangeSlider::second.pressed
+ \qmlproperty bool QtQuick.Controls::RangeSlider::second.hovered
\table
\header
@@ -528,6 +563,10 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\row
\li pressed
\li This property holds whether the second handle is pressed.
+ \row
+ \li hovered
+ \li This property holds whether the second handle is hovered.
+ This property was introduced in QtQuick.Controls 2.1.
\endtable
\sa second.increase(), second.decrease()
@@ -731,6 +770,28 @@ void QQuickRangeSlider::keyPressEvent(QKeyEvent *event)
}
}
+void QQuickRangeSlider::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QQuickRangeSlider);
+ QQuickControl::hoverEnterEvent(event);
+ d->updateHover(event->posF());
+}
+
+void QQuickRangeSlider::hoverMoveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickRangeSlider);
+ QQuickControl::hoverMoveEvent(event);
+ d->updateHover(event->posF());
+}
+
+void QQuickRangeSlider::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickRangeSlider);
+ QQuickControl::hoverLeaveEvent(event);
+ d->first->setHovered(false);
+ d->second->setHovered(false);
+}
+
void QQuickRangeSlider::keyReleaseEvent(QKeyEvent *event)
{
Q_D(QQuickRangeSlider);
diff --git a/src/quicktemplates2/qquickrangeslider_p.h b/src/quicktemplates2/qquickrangeslider_p.h
index 4c2eb4bb..1b102e87 100644
--- a/src/quicktemplates2/qquickrangeslider_p.h
+++ b/src/quicktemplates2/qquickrangeslider_p.h
@@ -105,6 +105,9 @@ Q_SIGNALS:
protected:
void focusInEvent(QFocusEvent *event) override;
+ void hoverEnterEvent(QHoverEvent *event) override;
+ void hoverMoveEvent(QHoverEvent *event) override;
+ void hoverLeaveEvent(QHoverEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
@@ -135,6 +138,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRangeSliderNode : public QObject
Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
+ Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1)
public:
explicit QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider);
@@ -152,6 +156,9 @@ public:
bool isPressed() const;
void setPressed(bool pressed);
+ bool isHovered() const;
+ void setHovered(bool hovered);
+
public Q_SLOTS:
void increase();
void decrease();
@@ -162,6 +169,7 @@ Q_SIGNALS:
void visualPositionChanged();
void handleChanged();
void pressedChanged();
+ Q_REVISION(1) void hoveredChanged();
private:
Q_DISABLE_COPY(QQuickRangeSliderNode)
diff --git a/src/quicktemplates2/qquickroundbutton.cpp b/src/quicktemplates2/qquickroundbutton.cpp
new file mode 100644
index 00000000..4169b269
--- /dev/null
+++ b/src/quicktemplates2/qquickroundbutton.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickroundbutton_p.h"
+
+#include <QtQuickTemplates2/private/qquickbutton_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype RoundButton
+ \inherits Button
+ \instantiates QQuickRoundButton
+ \inqmlmodule QtQuick.Controls
+ \since 5.8
+ \ingroup qtquickcontrols2-buttons
+ \brief A push-button control with rounded corners that can be clicked by the user.
+
+ \image qtquickcontrols2-roundbutton.png
+
+ RoundButton is identical to \l Button, except that it has a \l radius property
+ which allows the corners to be rounded without having to customize the
+ \l background.
+
+ \snippet qtquickcontrols2-roundbutton.qml 1
+
+ \sa {Customizing RoundButton}, {Button Controls}
+*/
+
+class QQuickRoundButtonPrivate : public QQuickButtonPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickRoundButton)
+
+public:
+ QQuickRoundButtonPrivate();
+
+ qreal radius;
+ bool explicitRadius;
+
+ void setRadius(qreal newRadius = -1.0);
+};
+
+QQuickRoundButtonPrivate::QQuickRoundButtonPrivate() :
+ radius(0),
+ explicitRadius(false)
+{
+}
+
+void QQuickRoundButtonPrivate::setRadius(qreal newRadius)
+{
+ Q_Q(QQuickRoundButton);
+ const qreal oldRadius = radius;
+ if (newRadius < 0)
+ radius = qMax<qreal>(0, qMin(width, height) / 2);
+ else
+ radius = newRadius;
+
+ if (!qFuzzyCompare(radius, oldRadius))
+ emit q->radiusChanged();
+}
+
+QQuickRoundButton::QQuickRoundButton(QQuickItem *parent) :
+ QQuickButton(*(new QQuickRoundButtonPrivate), parent)
+{
+}
+
+/*!
+ \qmlproperty real QtQuick.Controls::RoundButton::radius
+
+ This property holds the radius of the button.
+
+ To create a relatively square button that has slightly rounded corners,
+ use a small value, such as \c 3.
+
+ To create a completely circular button (the default), use a value that is
+ equal to half of the width or height of the button, and make the button's
+ width and height identical.
+
+ To reset this property back to the default value, set its value to
+ \c undefined.
+*/
+qreal QQuickRoundButton::radius() const
+{
+ Q_D(const QQuickRoundButton);
+ return d->radius;
+}
+
+void QQuickRoundButton::setRadius(qreal radius)
+{
+ Q_D(QQuickRoundButton);
+ d->explicitRadius = true;
+ d->setRadius(radius);
+}
+
+void QQuickRoundButton::resetRadius()
+{
+ Q_D(QQuickRoundButton);
+ d->explicitRadius = false;
+ d->setRadius();
+}
+
+void QQuickRoundButton::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickRoundButton);
+ QQuickControl::geometryChanged(newGeometry, oldGeometry);
+ if (!d->explicitRadius)
+ d->setRadius();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickroundbutton_p.h b/src/quicktemplates2/qquickroundbutton_p.h
new file mode 100644
index 00000000..f308ddd3
--- /dev/null
+++ b/src/quicktemplates2/qquickroundbutton_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKROUNDBUTTON_P_H
+#define QQUICKROUNDBUTTON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickbutton_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickRoundButtonPrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRoundButton : public QQuickButton
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal radius READ radius WRITE setRadius RESET resetRadius NOTIFY radiusChanged FINAL)
+
+public:
+ explicit QQuickRoundButton(QQuickItem *parent = nullptr);
+
+ qreal radius() const;
+ void setRadius(qreal radius);
+ void resetRadius();
+
+Q_SIGNALS:
+ void radiusChanged();
+
+protected:
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+
+private:
+ Q_DISABLE_COPY(QQuickRoundButton)
+ Q_DECLARE_PRIVATE(QQuickRoundButton)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickRoundButton)
+
+#endif // QQUICKROUNDBUTTON_P_H
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index 7ac1df34..c291e4b1 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -168,7 +168,7 @@ public:
}
qreal positionAt(const QPoint &point) const;
-
+ void updateActive();
void resizeContent() override;
qreal size;
@@ -190,6 +190,12 @@ qreal QQuickScrollBarPrivate::positionAt(const QPoint &point) const
return (point.y() - q->topPadding()) / q->availableHeight();
}
+void QQuickScrollBarPrivate::updateActive()
+{
+ Q_Q(QQuickScrollBar);
+ q->setActive(moving || pressed || hovered);
+}
+
void QQuickScrollBarPrivate::resizeContent()
{
Q_Q(QQuickScrollBar);
@@ -349,7 +355,7 @@ void QQuickScrollBar::setPressed(bool pressed)
d->pressed = pressed;
setAccessibleProperty("pressed", pressed);
- setActive(d->pressed || d->moving);
+ d->updateActive();
emit pressedChanged();
}
@@ -443,6 +449,12 @@ void QQuickScrollBar::mouseReleaseEvent(QMouseEvent *event)
setPressed(false);
}
+void QQuickScrollBar::hoverChange()
+{
+ Q_D(QQuickScrollBar);
+ d->updateActive();
+}
+
#ifndef QT_NO_ACCESSIBILITY
void QQuickScrollBar::accessibilityActiveChanged(bool active)
{
@@ -473,7 +485,7 @@ public:
void layoutHorizontal(bool move = true);
void layoutVertical(bool move = true);
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
void itemDestroyed(QQuickItem *item) override;
QQuickFlickable *flickable;
@@ -485,14 +497,14 @@ void QQuickScrollBarAttachedPrivate::activateHorizontal()
{
QQuickScrollBarPrivate *p = QQuickScrollBarPrivate::get(horizontal);
p->moving = flickable->isMovingHorizontally();
- horizontal->setActive(p->moving || p->pressed);
+ p->updateActive();
}
void QQuickScrollBarAttachedPrivate::activateVertical()
{
QQuickScrollBarPrivate *p = QQuickScrollBarPrivate::get(vertical);
p->moving = flickable->isMovingVertically();
- vertical->setActive(p->moving || p->pressed);
+ p->updateActive();
}
// TODO: QQuickFlickable::maxXYExtent()
@@ -548,16 +560,24 @@ void QQuickScrollBarAttachedPrivate::layoutVertical(bool move)
vertical->setX(vertical->isMirrored() ? 0 : flickable->width() - vertical->width());
}
-void QQuickScrollBarAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
+void QQuickScrollBarAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QQuickGeometryChange change, const QRectF &diff)
{
Q_UNUSED(item);
- Q_UNUSED(newGeometry);
+ Q_UNUSED(change);
if (horizontal && horizontal->height() > 0) {
- bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height());
+#ifdef QT_QUICK_NEW_GEOMETRY_CHANGED_HANDLING // TODO: correct/rename diff to oldGeometry
+ bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), diff.height() - horizontal->height());
+#else
+ bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), item->height() - diff.height() - horizontal->height());
+#endif
layoutHorizontal(move);
}
if (vertical && vertical->width() > 0) {
- bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width());
+#ifdef QT_QUICK_NEW_GEOMETRY_CHANGED_HANDLING // TODO: correct/rename diff to oldGeometry
+ bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), diff.width() - vertical->width());
+#else
+ bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), item->width() - diff.width() - vertical->width());
+#endif
layoutVertical(move);
}
}
@@ -576,7 +596,7 @@ QQuickScrollBarAttached::QQuickScrollBarAttached(QQuickFlickable *flickable) :
Q_D(QQuickScrollBarAttached);
if (flickable) {
QQuickItemPrivate *p = QQuickItemPrivate::get(flickable);
- p->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ p->updateOrAddGeometryChangeListener(d, QQuickGeometryChange::Size);
}
}
diff --git a/src/quicktemplates2/qquickscrollbar_p.h b/src/quicktemplates2/qquickscrollbar_p.h
index 8feba604..b82e0438 100644
--- a/src/quicktemplates2/qquickscrollbar_p.h
+++ b/src/quicktemplates2/qquickscrollbar_p.h
@@ -105,6 +105,8 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+ void hoverChange() override;
+
#ifndef QT_NO_ACCESSIBILITY
void accessibilityActiveChanged(bool active) override;
QAccessible::Role accessibleRole() const override;
diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp
index 7d93215d..66830ec1 100644
--- a/src/quicktemplates2/qquickscrollindicator.cpp
+++ b/src/quicktemplates2/qquickscrollindicator.cpp
@@ -303,7 +303,7 @@ public:
void layoutHorizontal(bool move = true);
void layoutVertical(bool move = true);
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
void itemDestroyed(QQuickItem *item) override;
QQuickFlickable *flickable;
@@ -341,16 +341,24 @@ void QQuickScrollIndicatorAttachedPrivate::layoutVertical(bool move)
vertical->setX(flickable->width() - vertical->width());
}
-void QQuickScrollIndicatorAttachedPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
+void QQuickScrollIndicatorAttachedPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff)
{
Q_UNUSED(item);
- Q_UNUSED(newGeometry);
+ Q_UNUSED(change);
if (horizontal && horizontal->height() > 0) {
- bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), oldGeometry.height() - horizontal->height());
+#ifdef QT_QUICK_NEW_GEOMETRY_CHANGED_HANDLING // TODO: correct/rename diff to oldGeometry
+ bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), diff.height() - horizontal->height());
+#else
+ bool move = qFuzzyIsNull(horizontal->y()) || qFuzzyCompare(horizontal->y(), item->height() - diff.height() - horizontal->height());
+#endif
layoutHorizontal(move);
}
if (vertical && vertical->width() > 0) {
- bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), oldGeometry.width() - vertical->width());
+#ifdef QT_QUICK_NEW_GEOMETRY_CHANGED_HANDLING // TODO: correct/rename diff to oldGeometry
+ bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), diff.width() - vertical->width());
+#else
+ bool move = qFuzzyIsNull(vertical->x()) || qFuzzyCompare(vertical->x(), item->width() - diff.width() - vertical->width());
+#endif
layoutVertical(move);
}
}
@@ -369,7 +377,7 @@ QQuickScrollIndicatorAttached::QQuickScrollIndicatorAttached(QQuickFlickable *fl
Q_D(QQuickScrollIndicatorAttached);
if (flickable) {
QQuickItemPrivate *p = QQuickItemPrivate::get(flickable);
- p->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ p->updateOrAddGeometryChangeListener(d, QQuickGeometryChange::Size);
}
}
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index 454002c2..c0680725 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -86,7 +86,6 @@ public:
{
}
- qreal valueAt(qreal position) const;
qreal snapPosition(qreal position) const;
qreal positionAt(const QPoint &point) const;
void setPosition(qreal position);
@@ -104,11 +103,6 @@ public:
QQuickItem *handle;
};
-qreal QQuickSliderPrivate::valueAt(qreal position) const
-{
- return from + (to - from) * position;
-}
-
qreal QQuickSliderPrivate::snapPosition(qreal position) const
{
const qreal range = to - from;
@@ -232,10 +226,11 @@ void QQuickSlider::setTo(qreal to)
This property holds the value in the range \c from - \c to. The default value is \c 0.0.
Unlike the \l position property, the \c value is not updated while the
- handle is dragged. The value is updated after the value has been chosen
- and the slider has been released.
+ handle is dragged, but only after the value has been chosen and the slider
+ has been released. The \l valueAt() method can be used to get continuous
+ updates.
- \sa position
+ \sa position, valueAt()
*/
qreal QQuickSlider::value() const
{
@@ -268,7 +263,7 @@ void QQuickSlider::setValue(qreal value)
continuously updated while the handle is dragged. For visualizing a
slider, the right-to-left aware \l visualPosition should be used instead.
- \sa value, visualPosition
+ \sa value, visualPosition, valueAt()
*/
qreal QQuickSlider::position() const
{
@@ -434,6 +429,25 @@ void QQuickSlider::setHandle(QQuickItem *handle)
}
/*!
+ \since QtQuick.Controls 2.1
+ \qmlmethod real QtQuick.Controls::Slider::valueAt(real position)
+
+ Returns the value for the given \a position.
+
+ The \l value property is not updated while the handle is dragged, but this
+ method can be used to get continuous value updates:
+
+ \snippet qtquickcontrols2-tooltip-slider.qml 1
+
+ \sa value, position
+*/
+qreal QQuickSlider::valueAt(qreal position) const
+{
+ Q_D(const QQuickSlider);
+ return d->from + (d->to - d->from) * position;
+}
+
+/*!
\qmlmethod void QtQuick.Controls::Slider::increase()
Increases the value by \l stepSize or \c 0.1 if stepSize is not defined.
@@ -534,7 +548,7 @@ void QQuickSlider::mouseReleaseEvent(QMouseEvent *event)
qreal pos = d->positionAt(event->pos());
if (d->snapMode != NoSnap)
pos = d->snapPosition(pos);
- qreal val = d->valueAt(pos);
+ qreal val = valueAt(pos);
if (!qFuzzyCompare(val, d->value))
setValue(val);
else if (d->snapMode != NoSnap)
diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h
index f6c1401a..d17af5c4 100644
--- a/src/quicktemplates2/qquickslider_p.h
+++ b/src/quicktemplates2/qquickslider_p.h
@@ -105,6 +105,8 @@ public:
QQuickItem *handle() const;
void setHandle(QQuickItem *handle);
+ Q_REVISION(1) Q_INVOKABLE qreal valueAt(qreal position) const;
+
public Q_SLOTS:
void increase();
void decrease();
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 473b6643..506405fe 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -109,6 +109,7 @@ public:
void updateUpEnabled();
bool downEnabled() const;
void updateDownEnabled();
+ void updateHover(const QPointF &pos);
void startRepeatDelay();
void startPressRepeat();
@@ -190,6 +191,15 @@ void QQuickSpinBoxPrivate::updateDownEnabled()
downIndicator->setEnabled(from < to ? value > from : value < from);
}
+void QQuickSpinBoxPrivate::updateHover(const QPointF &pos)
+{
+ Q_Q(QQuickSpinBox);
+ QQuickItem *ui = up->indicator();
+ QQuickItem *di = down->indicator();
+ up->setHovered(ui && ui->isEnabled() && ui->contains(q->mapToItem(ui, pos)));
+ down->setHovered(di && di->isEnabled() && di->contains(q->mapToItem(di, pos)));
+}
+
void QQuickSpinBoxPrivate::startRepeatDelay()
{
Q_Q(QQuickSpinBox);
@@ -553,8 +563,10 @@ void QQuickSpinBox::setValueFromText(const QJSValue &callback)
\qmlpropertygroup QtQuick.Controls::SpinBox::up
\qmlproperty bool QtQuick.Controls::SpinBox::up.pressed
\qmlproperty Item QtQuick.Controls::SpinBox::up.indicator
+ \qmlproperty bool QtQuick.Controls::SpinBox::up.hovered
- These properties hold the up indicator item and whether it is pressed.
+ These properties hold the up indicator item and whether it is pressed or
+ hovered. The \c up.hovered property was introduced in QtQuick.Controls 2.1.
\sa increase()
*/
@@ -568,8 +580,10 @@ QQuickSpinButton *QQuickSpinBox::up() const
\qmlpropertygroup QtQuick.Controls::SpinBox::down
\qmlproperty bool QtQuick.Controls::SpinBox::down.pressed
\qmlproperty Item QtQuick.Controls::SpinBox::down.indicator
+ \qmlproperty bool QtQuick.Controls::SpinBox::down.hovered
- These properties hold the down indicator item and whether it is pressed.
+ These properties hold the down indicator item and whether it is pressed or
+ hovered. The \c down.hovered property was introduced in QtQuick.Controls 2.1.
\sa decrease()
*/
@@ -605,6 +619,28 @@ void QQuickSpinBox::decrease()
setValue(d->value - d->effectiveStepSize());
}
+void QQuickSpinBox::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QQuickSpinBox);
+ QQuickControl::hoverEnterEvent(event);
+ d->updateHover(event->posF());
+}
+
+void QQuickSpinBox::hoverMoveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickSpinBox);
+ QQuickControl::hoverMoveEvent(event);
+ d->updateHover(event->posF());
+}
+
+void QQuickSpinBox::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickSpinBox);
+ QQuickControl::hoverLeaveEvent(event);
+ d->down->setHovered(false);
+ d->up->setHovered(false);
+}
+
void QQuickSpinBox::keyPressEvent(QKeyEvent *event)
{
Q_D(QQuickSpinBox);
@@ -757,8 +793,9 @@ QAccessible::Role QQuickSpinBox::accessibleRole() const
class QQuickSpinButtonPrivate : public QObjectPrivate
{
public:
- QQuickSpinButtonPrivate() : pressed(false), indicator(nullptr) { }
+ QQuickSpinButtonPrivate() : pressed(false), hovered(false), indicator(nullptr) { }
bool pressed;
+ bool hovered;
QQuickItem *indicator;
};
@@ -783,6 +820,22 @@ void QQuickSpinButton::setPressed(bool pressed)
emit pressedChanged();
}
+bool QQuickSpinButton::isHovered() const
+{
+ Q_D(const QQuickSpinButton);
+ return d->hovered;
+}
+
+void QQuickSpinButton::setHovered(bool hovered)
+{
+ Q_D(QQuickSpinButton);
+ if (d->hovered == hovered)
+ return;
+
+ d->hovered = hovered;
+ emit hoveredChanged();
+}
+
QQuickItem *QQuickSpinButton::indicator() const
{
Q_D(const QQuickSpinButton);
diff --git a/src/quicktemplates2/qquickspinbox_p.h b/src/quicktemplates2/qquickspinbox_p.h
index 3898a28b..b34f81a2 100644
--- a/src/quicktemplates2/qquickspinbox_p.h
+++ b/src/quicktemplates2/qquickspinbox_p.h
@@ -118,6 +118,9 @@ Q_SIGNALS:
protected:
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
+ void hoverEnterEvent(QHoverEvent *event) override;
+ void hoverMoveEvent(QHoverEvent *event) override;
+ void hoverLeaveEvent(QHoverEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
@@ -146,6 +149,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSpinButton : public QObject
{
Q_OBJECT
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
+ Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION 1)
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
public:
@@ -154,11 +158,15 @@ public:
bool isPressed() const;
void setPressed(bool pressed);
+ bool isHovered() const;
+ void setHovered(bool hovered);
+
QQuickItem *indicator() const;
void setIndicator(QQuickItem *indicator);
Q_SIGNALS:
void pressedChanged();
+ Q_REVISION(1) void hoveredChanged();
void indicatorChanged();
private:
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index df9ab74f..d16d7b16 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -314,12 +314,7 @@ QQuickStackView::~QQuickStackView()
QQuickStackAttached *QQuickStackView::qmlAttachedProperties(QObject *object)
{
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- if (!item) {
- qmlInfo(object) << "StackView must be attached to an Item";
- return nullptr;
- }
- return new QQuickStackAttached(item);
+ return new QQuickStackAttached(object);
}
/*!
@@ -463,8 +458,11 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with transitions.
+ \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
+ \value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
+ \value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
+ \value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
\sa initialItem, {Pushing Items}
*/
@@ -480,7 +478,7 @@ void QQuickStackView::push(QQmlV4Function *args)
QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
- Operation operation = d->elements.isEmpty() ? Immediate : Transition;
+ Operation operation = d->elements.isEmpty() ? Immediate : PushTransition;
QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]);
if (lastArg->isInt32())
operation = static_cast<Operation>(lastArg->toInt32());
@@ -499,7 +497,9 @@ void QQuickStackView::push(QQmlV4Function *args)
if (d->pushElements(elements)) {
emit depthChanged();
QQuickStackElement *enter = d->elements.top();
- d->pushTransition(enter, exit, boundingRect(), operation == Immediate);
+ d->startTransition(QQuickStackTransition::pushEnter(operation, enter, this),
+ QQuickStackTransition::pushExit(operation, exit, this),
+ operation == Immediate);
d->setCurrentItem(enter->item);
}
@@ -524,8 +524,11 @@ void QQuickStackView::push(QQmlV4Function *args)
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with transitions.
+ \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
+ \value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
+ \value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
+ \value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
Examples:
\code
@@ -571,7 +574,7 @@ void QQuickStackView::pop(QQmlV4Function *args)
}
}
- Operation operation = Transition;
+ Operation operation = PopTransition;
if (argc > 0) {
QV4::ScopedValue lastArg(scope, (*args)[argc - 1]);
if (lastArg->isInt32())
@@ -581,10 +584,14 @@ void QQuickStackView::pop(QQmlV4Function *args)
QQuickItem *previousItem = nullptr;
if (d->popElements(enter)) {
- if (exit)
+ if (exit) {
+ exit->removal = true;
previousItem = exit->item;
+ }
emit depthChanged();
- d->popTransition(enter, exit, boundingRect(), operation == Immediate);
+ d->startTransition(QQuickStackTransition::popExit(operation, exit, this),
+ QQuickStackTransition::popEnter(operation, enter, this),
+ operation == Immediate);
d->setCurrentItem(enter->item);
}
@@ -647,8 +654,39 @@ void QQuickStackView::pop(QQmlV4Function *args)
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with transitions.
+ \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
+ \value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
+ \value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
+ \value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
+
+ The following example illustrates the use of push and pop transitions with replace().
+
+ \code
+ StackView {
+ id: stackView
+
+ initialItem: Component {
+ id: page
+
+ Page {
+ Row {
+ spacing: 20
+ anchors.centerIn: parent
+
+ Button {
+ text: "<"
+ onClicked: stackView.replace(page, StackView.PopTransition)
+ }
+ Button {
+ text: ">"
+ onClicked: stackView.replace(page, StackView.PushTransition)
+ }
+ }
+ }
+ }
+ }
+ \endcode
\sa push(), {Replacing Items}
*/
@@ -664,7 +702,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
QV4::ExecutionEngine *v4 = args->v4engine();
QV4::Scope scope(v4);
- Operation operation = d->elements.isEmpty() ? Immediate : Transition;
+ Operation operation = d->elements.isEmpty() ? Immediate : ReplaceTransition;
QV4::ScopedValue lastArg(scope, (*args)[args->length() - 1]);
if (lastArg->isInt32())
operation = static_cast<Operation>(lastArg->toInt32());
@@ -691,8 +729,12 @@ void QQuickStackView::replace(QQmlV4Function *args)
if (exit != target ? d->replaceElements(target, elements) : d->pushElements(elements)) {
if (depth != d->elements.count())
emit depthChanged();
+ if (exit)
+ exit->removal = true;
QQuickStackElement *enter = d->elements.top();
- d->replaceTransition(enter, exit, boundingRect(), operation == Immediate);
+ d->startTransition(QQuickStackTransition::replaceExit(operation, exit, this),
+ QQuickStackTransition::replaceEnter(operation, enter, this),
+ operation == Immediate);
d->setCurrentItem(enter->item);
}
@@ -978,19 +1020,25 @@ void QQuickStackAttachedPrivate::itemParentChanged(QQuickItem *item, QQuickItem
emit q->statusChanged();
}
-QQuickStackAttached::QQuickStackAttached(QQuickItem *parent) :
+QQuickStackAttached::QQuickStackAttached(QObject *parent) :
QObject(*(new QQuickStackAttachedPrivate), parent)
{
Q_D(QQuickStackAttached);
- QQuickItemPrivate::get(parent)->addItemChangeListener(d, QQuickItemPrivate::Parent);
- d->itemParentChanged(parent, parent->parentItem());
+ QQuickItem *item = qobject_cast<QQuickItem *>(parent);
+ if (item) {
+ QQuickItemPrivate::get(item)->addItemChangeListener(d, QQuickItemPrivate::Parent);
+ d->itemParentChanged(item, item->parentItem());
+ } else if (parent) {
+ qmlInfo(parent) << "StackView must be attached to an Item";
+ }
}
QQuickStackAttached::~QQuickStackAttached()
{
Q_D(QQuickStackAttached);
- QQuickItem *parentItem = static_cast<QQuickItem *>(parent());
- QQuickItemPrivate::get(parentItem)->removeItemChangeListener(d, QQuickItemPrivate::Parent);
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ if (parentItem)
+ QQuickItemPrivate::get(parentItem)->removeItemChangeListener(d, QQuickItemPrivate::Parent);
}
/*!
@@ -1038,4 +1086,59 @@ QQuickStackView::Status QQuickStackAttached::status() const
return d->element ? d->element->status : QQuickStackView::Inactive;
}
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::activated()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to is activated in the stack.
+
+ \sa status
+*/
+
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::deactivated()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to is deactivated in the stack.
+
+ \sa status
+*/
+
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::activating()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to is in the process of being
+ activated in the stack.
+
+ \sa status
+*/
+
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::deactivating()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to is in the process of being
+ dectivated in the stack.
+
+ \sa status
+*/
+
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::removed()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to has been
+ removed from the stack. It can be used to safely destroy an Item that was
+ pushed onto the stack, for example:
+
+ \code
+ Item {
+ StackView.onRemoved: destroy() // Will be destroyed sometime after this call.
+ }
+ \endcode
+
+ \sa status
+*/
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp
index 050bfde9..2657695d 100644
--- a/src/quicktemplates2/qquickstackview_p.cpp
+++ b/src/quicktemplates2/qquickstackview_p.cpp
@@ -72,7 +72,7 @@ private:
QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(nullptr),
index(-1), init(false), removal(false), ownItem(false), ownComponent(false), widthValid(false), heightValid(false),
- context(nullptr), component(nullptr), incubator(nullptr), view(nullptr),
+ context(nullptr), component(nullptr), view(nullptr),
status(QQuickStackView::Inactive)
{
}
@@ -85,6 +85,7 @@ QQuickStackElement::~QQuickStackElement()
if (ownComponent)
delete component;
+ QQuickStackAttached *attached = attachedStackObject(this);
if (item) {
if (ownItem) {
item->setParentItem(nullptr);
@@ -99,15 +100,16 @@ QQuickStackElement::~QQuickStackElement()
if (item->parentItem() != originalParent) {
item->setParentItem(originalParent);
} else {
- QQuickStackAttached *attached = attachedStackObject(this);
if (attached)
QQuickStackAttachedPrivate::get(attached)->itemParentChanged(item, nullptr);
}
}
}
+ if (attached)
+ emit attached->removed();
+
delete context;
- delete incubator;
}
QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view)
@@ -120,12 +122,9 @@ QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickSta
QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackView *view)
{
+ Q_UNUSED(view);
QQuickStackElement *element = new QQuickStackElement;
element->component = qobject_cast<QQmlComponent *>(object);
- if (!element->component) {
- element->component = new QQmlComponent(qmlEngine(view), view);
- element->ownComponent = true;
- }
element->item = qobject_cast<QQuickItem *>(object);
if (element->item)
element->originalParent = element->item->parentItem();
@@ -154,9 +153,8 @@ bool QQuickStackElement::load(QQuickStackView *parent)
context = new QQmlContext(creationContext);
context->setContextObject(parent);
- delete incubator;
- incubator = new QQuickStackIncubator(this);
- component->create(*incubator, context);
+ QQuickStackIncubator incubator(this);
+ component->create(incubator, context);
if (component->isError())
qWarning() << qPrintable(component->errorString().trimmed());
} else {
@@ -189,14 +187,15 @@ void QQuickStackElement::initialize()
p->addItemChangeListener(this, QQuickItemPrivate::Destroyed);
if (!properties.isUndefined()) {
- QQmlComponentPrivate *d = QQmlComponentPrivate::get(component);
- Q_ASSERT(d && d->engine);
- QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(d->engine);
+ QQmlEngine *engine = qmlEngine(view);
+ Q_ASSERT(engine);
+ QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine);
Q_ASSERT(v4);
QV4::Scope scope(v4);
QV4::ScopedValue ipv(scope, properties.value());
QV4::Scoped<QV4::QmlContext> qmlContext(scope, qmlCallingContext.value());
- d->initializeObjectWithInitialProperties(qmlContext, ipv, item);
+ QV4::ScopedValue qmlObject(scope, QV4::QObjectWrapper::wrap(v4, item));
+ QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv);
properties.clear();
}
@@ -232,8 +231,28 @@ void QQuickStackElement::setStatus(QQuickStackView::Status value)
status = value;
QQuickStackAttached *attached = attachedStackObject(this);
- if (attached)
- emit attached->statusChanged();
+ if (!attached)
+ return;
+
+ switch (value) {
+ case QQuickStackView::Inactive:
+ emit attached->deactivated();
+ break;
+ case QQuickStackView::Deactivating:
+ emit attached->deactivating();
+ break;
+ case QQuickStackView::Activating:
+ emit attached->activating();
+ break;
+ case QQuickStackView::Active:
+ emit attached->activated();
+ break;
+ default:
+ Q_UNREACHABLE();
+ break;
+ }
+
+ emit attached->statusChanged();
}
void QQuickStackElement::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget)
@@ -422,84 +441,24 @@ void QQuickStackViewPrivate::ensureTransitioner()
}
}
-void QQuickStackViewPrivate::popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate)
+void QQuickStackViewPrivate::startTransition(const QQuickStackTransition &first, const QQuickStackTransition &second, bool immediate)
{
- ensureTransitioner();
+ if (first.element)
+ first.element->transitionNextReposition(transitioner, first.type, first.target);
+ if (second.element)
+ second.element->transitionNextReposition(transitioner, second.type, second.target);
- if (exit)
- exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true);
- if (enter)
- enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, false);
-
- if (exit) {
- exit->removal = true;
- if (immediate || !exit->item || !exit->prepareTransition(transitioner, viewBounds))
- completeTransition(exit, transitioner->removeTransition, QQuickStackView::Deactivating);
+ if (first.element) {
+ if (immediate || !first.element->item || !first.element->prepareTransition(transitioner, first.viewBounds))
+ completeTransition(first.element, transitioner->removeTransition, first.status);
else
- exit->startTransition(transitioner, QQuickStackView::Deactivating);
+ first.element->startTransition(transitioner, first.status);
}
- if (enter) {
- if (immediate || !enter->item || !enter->prepareTransition(transitioner, QRectF()))
- completeTransition(enter, transitioner->removeDisplacedTransition, QQuickStackView::Activating);
+ if (second.element) {
+ if (immediate || !second.element->item || !second.element->prepareTransition(transitioner, second.viewBounds))
+ completeTransition(second.element, transitioner->removeDisplacedTransition, second.status);
else
- enter->startTransition(transitioner, QQuickStackView::Activating);
- }
-
- if (transitioner) {
- setBusy(!transitioner->runningJobs.isEmpty());
- transitioner->resetTargetLists();
- }
-}
-
-void QQuickStackViewPrivate::pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate)
-{
- ensureTransitioner();
-
- if (enter)
- enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, true);
- if (exit)
- exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::AddTransition, false);
-
- if (enter) {
- if (immediate || !enter->item || !enter->prepareTransition(transitioner, viewBounds))
- completeTransition(enter, transitioner->addTransition, QQuickStackView::Activating);
- else
- enter->startTransition(transitioner, QQuickStackView::Activating);
- }
- if (exit) {
- if (immediate || !exit->item || !exit->prepareTransition(transitioner, QRectF()))
- completeTransition(exit, transitioner->addDisplacedTransition, QQuickStackView::Deactivating);
- else
- exit->startTransition(transitioner, QQuickStackView::Deactivating);
- }
-
- if (transitioner) {
- setBusy(!transitioner->runningJobs.isEmpty());
- transitioner->resetTargetLists();
- }
-}
-
-void QQuickStackViewPrivate::replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate)
-{
- ensureTransitioner();
-
- if (exit)
- exit->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, false);
- if (enter)
- enter->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, true);
-
- if (exit) {
- exit->removal = true;
- if (immediate || !exit->item || !exit->prepareTransition(transitioner, QRectF()))
- completeTransition(exit, transitioner->moveDisplacedTransition, QQuickStackView::Deactivating);
- else
- exit->startTransition(transitioner, QQuickStackView::Deactivating);
- }
- if (enter) {
- if (immediate || !enter->item || !enter->prepareTransition(transitioner, viewBounds))
- completeTransition(enter, transitioner->moveTransition, QQuickStackView::Activating);
- else
- enter->startTransition(transitioner, QQuickStackView::Activating);
+ second.element->startTransition(transitioner, second.status);
}
if (transitioner) {
@@ -554,4 +513,119 @@ void QQuickStackViewPrivate::setBusy(bool b)
emit q->busyChanged();
}
+static QQuickStackTransition exitTransition(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ QQuickStackTransition st;
+ st.status = QQuickStackView::Deactivating;
+ st.transition = nullptr;
+ st.element = element;
+
+ const QQuickItemViewTransitioner *transitioner = QQuickStackViewPrivate::get(view)->transitioner;
+
+ switch (operation) {
+ case QQuickStackView::PushTransition:
+ st.target = false;
+ st.type = QQuickItemViewTransitioner::AddTransition;
+ st.viewBounds = QRectF();
+ if (transitioner)
+ st.transition = transitioner->addDisplacedTransition;
+ break;
+ case QQuickStackView::ReplaceTransition:
+ st.target = false;
+ st.type = QQuickItemViewTransitioner::MoveTransition;
+ st.viewBounds = QRectF();
+ if (transitioner)
+ st.transition = transitioner->moveDisplacedTransition;
+ break;
+ case QQuickStackView::PopTransition:
+ st.target = true;
+ st.type = QQuickItemViewTransitioner::RemoveTransition;
+ st.viewBounds = view->boundingRect();
+ if (transitioner)
+ st.transition = transitioner->removeTransition;
+ break;
+ default:
+ Q_UNREACHABLE();
+ break;
+ }
+
+ return st;
+}
+
+static QQuickStackTransition enterTransition(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ QQuickStackTransition st;
+ st.status = QQuickStackView::Activating;
+ st.transition = nullptr;
+ st.element = element;
+
+ const QQuickItemViewTransitioner *transitioner = QQuickStackViewPrivate::get(view)->transitioner;
+
+ switch (operation) {
+ case QQuickStackView::PushTransition:
+ st.target = true;
+ st.type = QQuickItemViewTransitioner::AddTransition;
+ st.viewBounds = view->boundingRect();
+ if (transitioner)
+ st.transition = transitioner->addTransition;
+ break;
+ case QQuickStackView::ReplaceTransition:
+ st.target = true;
+ st.type = QQuickItemViewTransitioner::MoveTransition;
+ st.viewBounds = view->boundingRect();
+ if (transitioner)
+ st.transition = transitioner->moveTransition;
+ break;
+ case QQuickStackView::PopTransition:
+ st.target = false;
+ st.type = QQuickItemViewTransitioner::RemoveTransition;
+ st.viewBounds = QRectF();
+ if (transitioner)
+ st.transition = transitioner->removeDisplacedTransition;
+ break;
+ default:
+ Q_UNREACHABLE();
+ break;
+ }
+
+ return st;
+}
+
+static QQuickStackView::Operation operationTransition(QQuickStackView::Operation operation, QQuickStackView::Operation transition)
+{
+ if (operation == QQuickStackView::Immediate || operation == QQuickStackView::Transition)
+ return transition;
+ return operation;
+}
+
+QQuickStackTransition QQuickStackTransition::popExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return exitTransition(operationTransition(operation, QQuickStackView::PopTransition), element, view);
+}
+
+QQuickStackTransition QQuickStackTransition::popEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return enterTransition(operationTransition(operation, QQuickStackView::PopTransition), element, view);
+}
+
+QQuickStackTransition QQuickStackTransition::pushExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return exitTransition(operationTransition(operation, QQuickStackView::PushTransition), element, view);
+}
+
+QQuickStackTransition QQuickStackTransition::pushEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return enterTransition(operationTransition(operation, QQuickStackView::PushTransition), element, view);
+}
+
+QQuickStackTransition QQuickStackTransition::replaceExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return exitTransition(operationTransition(operation, QQuickStackView::ReplaceTransition), element, view);
+}
+
+QQuickStackTransition QQuickStackTransition::replaceEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view)
+{
+ return enterTransition(operationTransition(operation, QQuickStackView::ReplaceTransition), element, view);
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index f994f361..7491f8f6 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -121,8 +121,11 @@ public:
Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad);
enum Operation {
- Transition,
- Immediate
+ Transition = -1, // deprecated
+ Immediate = 0,
+ PushTransition = 1,
+ ReplaceTransition = 2,
+ PopTransition = 3,
};
Q_ENUM(Operation)
@@ -168,7 +171,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackAttached : public QObject
Q_PROPERTY(QQuickStackView::Status status READ status NOTIFY statusChanged FINAL)
public:
- explicit QQuickStackAttached(QQuickItem *parent = nullptr);
+ explicit QQuickStackAttached(QObject *parent = nullptr);
~QQuickStackAttached();
int index() const;
@@ -179,6 +182,11 @@ Q_SIGNALS:
void indexChanged();
void viewChanged();
void statusChanged();
+ /*Q_REVISION(1)*/ void activated();
+ /*Q_REVISION(1)*/ void activating();
+ /*Q_REVISION(1)*/ void deactivated();
+ /*Q_REVISION(1)*/ void deactivating();
+ /*Q_REVISION(1)*/ void removed();
private:
Q_DISABLE_COPY(QQuickStackAttached)
diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h
index 6abaaad6..5b3b1445 100644
--- a/src/quicktemplates2/qquickstackview_p_p.h
+++ b/src/quicktemplates2/qquickstackview_p_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
class QQmlContext;
class QQmlComponent;
-class QQmlIncubator;
+struct QQuickStackTransition;
class QQuickStackElement : public QQuickItemViewTransitionableItem, public QQuickItemChangeListener
{
@@ -93,7 +93,6 @@ public:
bool heightValid;
QQmlContext *context;
QQmlComponent *component;
- QQmlIncubator *incubator;
QQuickStackView *view;
QPointer<QQuickItem> originalParent;
QQuickStackView::Status status;
@@ -125,9 +124,7 @@ public:
bool replaceElements(QQuickStackElement *element, const QList<QQuickStackElement *> &elements);
void ensureTransitioner();
- void popTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate);
- void pushTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate);
- void replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate);
+ void startTransition(const QQuickStackTransition &first, const QQuickStackTransition &second, bool immediate);
void completeTransition(QQuickStackElement *element, QQuickTransition *transition, QQuickStackView::Status status);
void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
@@ -141,6 +138,25 @@ public:
QQuickItemViewTransitioner *transitioner;
};
+struct QQuickStackTransition
+{
+ static QQuickStackTransition popExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+ static QQuickStackTransition popEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+
+ static QQuickStackTransition pushExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+ static QQuickStackTransition pushEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+
+ static QQuickStackTransition replaceExit(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+ static QQuickStackTransition replaceEnter(QQuickStackView::Operation operation, QQuickStackElement *element, QQuickStackView *view);
+
+ bool target;
+ QQuickStackView::Status status;
+ QQuickItemViewTransitioner::TransitionType type;
+ QRectF viewBounds;
+ QQuickStackElement *element;
+ QQuickTransition *transition;
+};
+
class QQuickStackAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
Q_DECLARE_PUBLIC(QQuickStackAttached)
diff --git a/src/quicktemplates2/qquickswipe_p.h b/src/quicktemplates2/qquickswipe_p.h
index f701c63c..c1a28819 100644
--- a/src/quicktemplates2/qquickswipe_p.h
+++ b/src/quicktemplates2/qquickswipe_p.h
@@ -97,9 +97,12 @@ public:
QQuickItem *rightItem() const;
void setRightItem(QQuickItem *item);
+ Q_REVISION(1) Q_INVOKABLE void close();
+
Q_SIGNALS:
void positionChanged();
void completeChanged();
+ /*Q_REVISION(1)*/ void completed();
void leftChanged();
void behindChanged();
void rightChanged();
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index f07b107e..d4688867 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -101,6 +101,12 @@ QT_BEGIN_NAMESPACE
*/
namespace {
+ typedef QQuickSwipeDelegateAttached Attached;
+
+ Attached *attachedObject(QQuickItem *item) {
+ return qobject_cast<Attached*>(qmlAttachedPropertiesObject<QQuickSwipeDelegate>(item, false));
+ }
+
enum PositionAnimation {
DontAnimatePosition,
AnimatePosition
@@ -564,6 +570,18 @@ void QQuickSwipe::setComplete(bool complete)
d->complete = complete;
emit completeChanged();
+ if (d->complete)
+ emit completed();
+}
+
+void QQuickSwipe::close()
+{
+ Q_D(QQuickSwipe);
+ setPosition(0);
+ setComplete(false);
+ d->wasComplete = false;
+ d->positionBeforePress = 0.0;
+ d->velocityCalculator.reset();
}
QQuickSwipeDelegatePrivate::QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) :
@@ -580,12 +598,29 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE
// events will go through the regular channels (mousePressEvent()) until then.
if (qFuzzyIsNull(swipePrivate->position)) {
q->mousePressEvent(event);
+ // The press point could be incorrect if the press happened over a child item,
+ // so we correct it after calling the base class' mousePressEvent(), rather
+ // than having to duplicate its code just so we can set the pressPoint.
+ pressPoint = item->mapToItem(q, event->pos());
return true;
}
+ // The position is non-zero, this press could be either for a delegate or the control itself
+ // (the control can be clicked to e.g. close the swipe). Either way, we must begin measuring
+ // mouse movement in case it turns into a swipe, in which case we grab the mouse.
swipePrivate->positionBeforePress = swipePrivate->position;
swipePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp());
pressPoint = item->mapToItem(q, event->pos());
+
+ // When a delegate uses the attached properties and signals, it declares that it wants mouse events.
+ Attached *attached = attachedObject(item);
+ if (attached) {
+ attached->setPressed(true);
+ // Stop the event from propagating, as QQuickItem explicitly ignores events.
+ event->accept();
+ return true;
+ }
+
return false;
}
@@ -611,7 +646,8 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
if (item == q && !pressed)
return false;
- const qreal distance = (event->pos() - pressPoint).x();
+ const QPointF mappedEventPos = item->mapToItem(q, event->pos());
+ const qreal distance = (mappedEventPos - pressPoint).x();
if (!q->keepMouseGrab()) {
// Taken from QQuickDrawerPrivate::grabMouse; see comments there.
int threshold = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5);
@@ -620,9 +656,12 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
QQuickItem *grabber = q->window()->mouseGrabberItem();
if (!grabber || !grabber->keepMouseGrab()) {
q->grabMouse();
- q->setKeepMouseGrab(overThreshold);
+ q->setKeepMouseGrab(true);
q->setPressed(true);
swipe.setComplete(false);
+
+ if (Attached *attached = attachedObject(item))
+ attached->setPressed(false);
}
}
}
@@ -689,7 +728,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
static const qreal exposeVelocityThreshold = 300.0;
-bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEvent *event)
+bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event)
{
Q_Q(QQuickSwipeDelegate);
QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe);
@@ -731,6 +770,14 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEve
swipePrivate->wasComplete = false;
}
+ if (Attached *attached = attachedObject(item)) {
+ const bool wasPressed = attached->isPressed();
+ if (wasPressed) {
+ attached->setPressed(false);
+ emit attached->clicked();
+ }
+ }
+
// Only consume child events if we had grabbed the mouse.
return hadGrabbedMouse;
}
@@ -773,6 +820,17 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
}
/*!
+ \since QtQuick.Controls 2.1
+ \qmlmethod void QtQuick.Controls::SwipeDelegate::swipe.close()
+
+ This method sets the \c position of the swipe to \c 0. Any animations
+ defined for the \l {Item::}{x} position of \l {Control::}{contentItem}
+ and \l {Control::}{background} will be triggered.
+
+ \sa swipe
+*/
+
+/*!
\qmlpropertygroup QtQuick.Controls::SwipeDelegate::swipe
\qmlproperty real QtQuick.Controls::SwipeDelegate::swipe.position
\qmlproperty bool QtQuick.Controls::SwipeDelegate::swipe.complete
@@ -785,7 +843,7 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
\table
\header
- \li Property
+ \li Name
\li Description
\row
\li position
@@ -847,9 +905,18 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
If \c right has not been set, or the position hasn't changed since
creation of the SwipeDelegate, this property will be \c null.
+ \row
+ \li completed()
+ \li This signal is emitted when \c complete becomes \c true.
+
+ It is useful for performing some action upon completion of a swipe.
+ For example, it can be used to remove the delegate from the list
+ that it is in.
+
+ This signal was added in QtQuick.Controls 2.1.
\endtable
- \sa {Control::}{contentItem}, {Control::}{background}
+ \sa {Control::}{contentItem}, {Control::}{background}, swipe.close()
*/
QQuickSwipe *QQuickSwipeDelegate::swipe() const
{
@@ -857,6 +924,11 @@ QQuickSwipe *QQuickSwipeDelegate::swipe() const
return const_cast<QQuickSwipe*>(&d->swipe);
}
+QQuickSwipeDelegateAttached *QQuickSwipeDelegate::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickSwipeDelegateAttached(object);
+}
+
static bool isChildOrGrandchildOf(QQuickItem *child, QQuickItem *item)
{
return item && (child == item || item->isAncestorOf(child));
@@ -887,6 +959,14 @@ bool QQuickSwipeDelegate::childMouseEventFilter(QQuickItem *child, QEvent *event
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
QQuickItemDelegate::mouseReleaseEvent(mouseEvent);
return d->handleMouseReleaseEvent(child, mouseEvent);
+ } case QEvent::UngrabMouse: {
+ // If the mouse was pressed over e.g. rightItem and then dragged down,
+ // the ListView would eventually grab the mouse, at which point we must
+ // clear the pressed flag so that it doesn't stay pressed after the release.
+ Attached *attached = attachedObject(child);
+ if (attached)
+ attached->setPressed(false);
+ return false;
} default:
return false;
}
@@ -942,4 +1022,155 @@ QAccessible::Role QQuickSwipeDelegate::accessibleRole() const
}
#endif
+class QQuickSwipeDelegateAttachedPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSwipeDelegateAttached)
+
+public:
+ QQuickSwipeDelegateAttachedPrivate() :
+ pressed(false)
+ {
+ }
+
+ // True when left/right/behind is non-interactive and is pressed.
+ bool pressed;
+};
+
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlattachedsignal QtQuick.Controls::SwipeDelegate::clicked()
+
+ This signal can be attached to a non-interactive item declared in
+ \c swipe.left, \c swipe.right, or \c swipe.behind, in order to react to
+ clicks. Items can only be clicked when \c swipe.complete is \c true.
+
+ For interactive controls (such as \l Button) declared in these
+ items, use their respective \c clicked() signal instead.
+
+ To respond to clicks on the SwipeDelegate itself, use its
+ \l {AbstractButton::}{clicked()} signal.
+
+ \note See the documentation for \l pressed for information on
+ how to use the event-related properties correctly.
+
+ \sa pressed
+*/
+
+QQuickSwipeDelegateAttached::QQuickSwipeDelegateAttached(QObject *object) :
+ QObject(*(new QQuickSwipeDelegateAttachedPrivate), object)
+{
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ if (item) {
+ // This allows us to be notified when an otherwise non-interactive item
+ // is pressed and clicked. The alternative is much more more complex:
+ // iterating through children that contain the event pos and finding
+ // the first one with an attached object.
+ item->setAcceptedMouseButtons(Qt::AllButtons);
+ } else {
+ qWarning() << "Attached properties of SwipeDelegate must be accessed through an Item";
+ }
+}
+
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlattachedproperty bool QtQuick.Controls::SwipeDelegate::pressed
+ \readonly
+
+ This property can be attached to a non-interactive item declared in
+ \c swipe.left, \c swipe.right, or \c swipe.behind, in order to detect if it
+ is pressed. Items can only be pressed when \c swipe.complete is \c true.
+
+ For example:
+
+ \code
+ swipe.right: Label {
+ anchors.right: parent.right
+ height: parent.height
+ text: "Action"
+ color: "white"
+ padding: 12
+ background: Rectangle {
+ color: SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
+ }
+ }
+ \endcode
+
+ It is possible to have multiple items which individually receive mouse and
+ touch events. For example, to have two actions in the \c swipe.right item,
+ use the following code:
+
+ \code
+ swipe.right: Row {
+ anchors.right: parent.right
+ height: parent.height
+
+ Label {
+ id: moveLabel
+ text: qsTr("Move")
+ color: "white"
+ verticalAlignment: Label.AlignVCenter
+ padding: 12
+ height: parent.height
+
+ SwipeDelegate.onClicked: console.log("Moving...")
+
+ background: Rectangle {
+ color: moveLabel.SwipeDelegate.pressed ? Qt.darker("#ffbf47", 1.1) : "#ffbf47"
+ }
+ }
+ Label {
+ id: deleteLabel
+ text: qsTr("Delete")
+ color: "white"
+ verticalAlignment: Label.AlignVCenter
+ padding: 12
+ height: parent.height
+
+ SwipeDelegate.onClicked: console.log("Deleting...")
+
+ background: Rectangle {
+ color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
+ }
+ }
+ }
+ \endcode
+
+ Note how the \c color assignment in each \l {Control::}{background} item
+ qualifies the attached property with the \c id of the label. This
+ is important; using the attached properties on an item causes that item
+ to accept events. Suppose we had left out the \c id in the previous example:
+
+ \code
+ color: SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
+ \endcode
+
+ The \l Rectangle background item is a child of the label, so it naturally
+ receives events before it. In practice, this means that the background
+ color will change, but the \c onClicked handler in the label will never
+ get called.
+
+ For interactive controls (such as \l Button) declared in these
+ items, use their respective \c pressed property instead.
+
+ For presses on the SwipeDelegate itself, use its
+ \l {AbstractButton::}{pressed} property.
+
+ \sa clicked()
+*/
+bool QQuickSwipeDelegateAttached::isPressed() const
+{
+ Q_D(const QQuickSwipeDelegateAttached);
+ return d->pressed;
+}
+
+void QQuickSwipeDelegateAttached::setPressed(bool pressed)
+{
+ Q_D(QQuickSwipeDelegateAttached);
+ if (pressed == d->pressed)
+ return;
+
+ d->pressed = pressed;
+ emit pressedChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h
index 2e1c515d..16aa9837 100644
--- a/src/quicktemplates2/qquickswipedelegate_p.h
+++ b/src/quicktemplates2/qquickswipedelegate_p.h
@@ -52,8 +52,10 @@
QT_BEGIN_NAMESPACE
-class QQuickSwipeDelegatePrivate;
class QQuickSwipe;
+class QQuickSwipeDelegatePrivate;
+class QQuickSwipeDelegateAttached;
+class QQuickSwipeDelegateAttachedPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegate : public QQuickItemDelegate
{
@@ -65,6 +67,8 @@ public:
QQuickSwipe *swipe() const;
+ static QQuickSwipeDelegateAttached *qmlAttachedProperties(QObject *object);
+
protected:
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
@@ -84,8 +88,29 @@ private:
Q_DECLARE_PRIVATE(QQuickSwipeDelegate)
};
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegateAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL)
+
+public:
+ explicit QQuickSwipeDelegateAttached(QObject *object = nullptr);
+
+ bool isPressed() const;
+ void setPressed(bool pressed);
+
+Q_SIGNALS:
+ void pressedChanged();
+ void clicked();
+
+private:
+ Q_DISABLE_COPY(QQuickSwipeDelegateAttached)
+ Q_DECLARE_PRIVATE(QQuickSwipeDelegateAttached)
+};
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickSwipeDelegate)
+QML_DECLARE_TYPEINFO(QQuickSwipeDelegate, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQUICKSWIPEDELEGATE_P_H
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index 82d05fbe..ef98c59b 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -69,6 +69,29 @@ QT_BEGIN_NAMESPACE
\l {Container::moveItem()}{move}, and \l {Container::removeItem()}{remove}
pages dynamically at run time.
+ It is generally not advisable to add excessive amounts of pages to a
+ SwipeView. However, when the amount of pages grows larger, or individual
+ pages are relatively complex, it may be desired free up resources by
+ unloading pages that are outside the reach. The following example presents
+ how to use \l Loader to keep a maximum of three pages simultaneously
+ instantiated.
+
+ \code
+ SwipeView {
+ Repeater {
+ model: 6
+ Loader {
+ active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
+ sourceComponent: Text {
+ text: index
+ Component.onCompleted: console.log("created:", index)
+ Component.onDestruction: console.log("destroyed:", index)
+ }
+ }
+ }
+ }
+ \endcode
+
\note SwipeView takes over the geometry management of items added to the
view. Using anchors on the items is not supported, and any \c width
or \c height assignment will be overridden by the view. Notice that
@@ -83,10 +106,14 @@ class QQuickSwipeViewPrivate : public QQuickContainerPrivate
Q_DECLARE_PUBLIC(QQuickSwipeView)
public:
+ QQuickSwipeViewPrivate() : interactive(true) { }
+
void resizeItem(QQuickItem *item);
void resizeItems();
static QQuickSwipeViewPrivate *get(QQuickSwipeView *view);
+
+ bool interactive;
};
void QQuickSwipeViewPrivate::resizeItems()
@@ -120,15 +147,34 @@ QQuickSwipeView::QQuickSwipeView(QQuickItem *parent) :
setActiveFocusOnTab(true);
}
-QQuickSwipeViewAttached *QQuickSwipeView::qmlAttachedProperties(QObject *object)
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::SwipeView::interactive
+
+ This property describes whether the user can interact with the SwipeView.
+ The user cannot swipe a view that is not interactive.
+
+ The default value is \c true.
+*/
+bool QQuickSwipeView::isInteractive() const
{
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- if (!item) {
- qWarning() << "SwipeView: attached properties must be accessed from within a child item";
- return nullptr;
- }
+ Q_D(const QQuickSwipeView);
+ return d->interactive;
+}
+
+void QQuickSwipeView::setInteractive(bool interactive)
+{
+ Q_D(QQuickSwipeView);
+ if (d->interactive == interactive)
+ return;
- return new QQuickSwipeViewAttached(item);
+ d->interactive = interactive;
+ emit interactiveChanged();
+}
+
+QQuickSwipeViewAttached *QQuickSwipeView::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickSwipeViewAttached(object);
}
void QQuickSwipeView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -172,6 +218,26 @@ QAccessible::Role QQuickSwipeView::accessibleRole() const
*/
/*!
+ \qmlattachedproperty bool QtQuick.Controls::SwipeView::isNextItem
+ \since QtQuick.Controls 2.1
+ \readonly
+
+ This attached property is \c true if this child is the next item.
+
+ It is attached to each child item of the SwipeView.
+*/
+
+/*!
+ \qmlattachedproperty bool QtQuick.Controls::SwipeView::isPreviousItem
+ \since QtQuick.Controls 2.1
+ \readonly
+
+ This attached property is \c true if this child is the previous item.
+
+ It is attached to each child item of the SwipeView.
+*/
+
+/*!
\qmlattachedproperty SwipeView QtQuick.Controls::SwipeView::view
\readonly
@@ -184,11 +250,11 @@ class QQuickSwipeViewAttachedPrivate : public QObjectPrivate, public QQuickItemC
{
Q_DECLARE_PUBLIC(QQuickSwipeViewAttached)
public:
- QQuickSwipeViewAttachedPrivate(QQuickItem *item) :
- item(item),
+ QQuickSwipeViewAttachedPrivate() :
+ item(nullptr),
swipeView(nullptr),
index(-1),
- isCurrent(false)
+ currentIndex(-1)
{
}
@@ -203,19 +269,16 @@ public:
void itemDestroyed(QQuickItem *) override;
void updateIndex();
- void updateIsCurrent();
+ void updateCurrentIndex();
void setView(QQuickSwipeView *view);
void setIndex(int i);
- void setIsCurrent(bool current);
+ void setCurrentIndex(int i);
QQuickItem *item;
QQuickSwipeView *swipeView;
int index;
- // Better to store this so that we don't need to lump its calculation
- // together with index's calculation, as it would otherwise need to know
- // the old index to know if it should emit the change signal.
- bool isCurrent;
+ int currentIndex;
};
void QQuickSwipeViewAttachedPrivate::updateIndex()
@@ -223,9 +286,9 @@ void QQuickSwipeViewAttachedPrivate::updateIndex()
setIndex(swipeView ? QQuickSwipeViewPrivate::get(swipeView)->contentModel->indexOf(item, nullptr) : -1);
}
-void QQuickSwipeViewAttachedPrivate::updateIsCurrent()
+void QQuickSwipeViewAttachedPrivate::updateCurrentIndex()
{
- setIsCurrent(swipeView ? swipeView->currentIndex() == index : false);
+ setCurrentIndex(swipeView ? swipeView->currentIndex() : -1);
}
void QQuickSwipeViewAttachedPrivate::setView(QQuickSwipeView *view)
@@ -238,7 +301,7 @@ void QQuickSwipeViewAttachedPrivate::setView(QQuickSwipeView *view)
p->removeItemChangeListener(this, QQuickItemPrivate::Children);
disconnect(swipeView, &QQuickSwipeView::currentIndexChanged,
- this, &QQuickSwipeViewAttachedPrivate::updateIsCurrent);
+ this, &QQuickSwipeViewAttachedPrivate::updateCurrentIndex);
disconnect(swipeView, &QQuickSwipeView::contentChildrenChanged,
this, &QQuickSwipeViewAttachedPrivate::updateIndex);
}
@@ -250,7 +313,7 @@ void QQuickSwipeViewAttachedPrivate::setView(QQuickSwipeView *view)
p->addItemChangeListener(this, QQuickItemPrivate::Children);
connect(swipeView, &QQuickSwipeView::currentIndexChanged,
- this, &QQuickSwipeViewAttachedPrivate::updateIsCurrent);
+ this, &QQuickSwipeViewAttachedPrivate::updateCurrentIndex);
connect(swipeView, &QQuickSwipeView::contentChildrenChanged,
this, &QQuickSwipeViewAttachedPrivate::updateIndex);
}
@@ -259,17 +322,26 @@ void QQuickSwipeViewAttachedPrivate::setView(QQuickSwipeView *view)
emit q->viewChanged();
updateIndex();
- updateIsCurrent();
+ updateCurrentIndex();
}
-void QQuickSwipeViewAttachedPrivate::setIsCurrent(bool current)
+void QQuickSwipeViewAttachedPrivate::setCurrentIndex(int i)
{
- if (current == isCurrent)
+ if (i == currentIndex)
return;
- isCurrent = current;
Q_Q(QQuickSwipeViewAttached);
- emit q->isCurrentItemChanged();
+ const bool wasCurrent = q->isCurrentItem();
+ const bool wasNext = q->isNextItem();
+ const bool wasPrevious = q->isPreviousItem();
+
+ currentIndex = i;
+ if (wasCurrent != q->isCurrentItem())
+ emit q->isCurrentItemChanged();
+ if (wasNext != q->isNextItem())
+ emit q->isNextItemChanged();
+ if (wasPrevious != q->isPreviousItem())
+ emit q->isPreviousItemChanged();
}
void QQuickSwipeViewAttachedPrivate::setIndex(int i)
@@ -323,15 +395,20 @@ void QQuickSwipeViewAttachedPrivate::itemDestroyed(QQuickItem *item)
QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed);
}
-QQuickSwipeViewAttached::QQuickSwipeViewAttached(QQuickItem *item) :
- QObject(*(new QQuickSwipeViewAttachedPrivate(item)), item)
+QQuickSwipeViewAttached::QQuickSwipeViewAttached(QObject *parent) :
+ QObject(*(new QQuickSwipeViewAttachedPrivate), parent)
{
Q_D(QQuickSwipeViewAttached);
- if (item->parentItem())
- d->updateView(item->parentItem());
-
- QQuickItemPrivate *p = QQuickItemPrivate::get(item);
- p->addItemChangeListener(d, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed);
+ d->item = qobject_cast<QQuickItem *>(parent);
+ if (d->item) {
+ if (d->item->parentItem())
+ d->updateView(d->item->parentItem());
+
+ QQuickItemPrivate *p = QQuickItemPrivate::get(d->item);
+ p->addItemChangeListener(d, QQuickItemPrivate::Parent | QQuickItemPrivate::Destroyed);
+ } else if (parent) {
+ qmlInfo(parent) << "SwipeView: attached properties must be accessed from within a child item";
+ }
}
QQuickSwipeViewAttached::~QQuickSwipeViewAttached()
@@ -357,7 +434,19 @@ int QQuickSwipeViewAttached::index() const
bool QQuickSwipeViewAttached::isCurrentItem() const
{
Q_D(const QQuickSwipeViewAttached);
- return d->swipeView ? d->swipeView->currentIndex() == d->index : false;
+ return d->index != -1 && d->currentIndex != -1 && d->index == d->currentIndex;
+}
+
+bool QQuickSwipeViewAttached::isNextItem() const
+{
+ Q_D(const QQuickSwipeViewAttached);
+ return d->index != -1 && d->currentIndex != -1 && d->index == d->currentIndex + 1;
+}
+
+bool QQuickSwipeViewAttached::isPreviousItem() const
+{
+ Q_D(const QQuickSwipeViewAttached);
+ return d->index != -1 && d->currentIndex != -1 && d->index == d->currentIndex - 1;
}
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickswipeview_p.h b/src/quicktemplates2/qquickswipeview_p.h
index c6cb62ba..8c489d53 100644
--- a/src/quicktemplates2/qquickswipeview_p.h
+++ b/src/quicktemplates2/qquickswipeview_p.h
@@ -58,12 +58,19 @@ class QQuickSwipeViewPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeView : public QQuickContainer
{
Q_OBJECT
+ Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged FINAL REVISION 1)
public:
explicit QQuickSwipeView(QQuickItem *parent = nullptr);
+ bool isInteractive() const;
+ void setInteractive(bool interactive);
+
static QQuickSwipeViewAttached *qmlAttachedProperties(QObject *object);
+Q_SIGNALS:
+ Q_REVISION(1) void interactiveChanged();
+
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void itemAdded(int index, QQuickItem *item) override;
@@ -84,19 +91,25 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeViewAttached : public QObject
Q_OBJECT
Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL)
Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY isCurrentItemChanged FINAL)
+ Q_PROPERTY(bool isNextItem READ isNextItem NOTIFY isNextItemChanged FINAL REVISION 1)
+ Q_PROPERTY(bool isPreviousItem READ isPreviousItem NOTIFY isPreviousItemChanged FINAL REVISION 1)
Q_PROPERTY(QQuickSwipeView *view READ view NOTIFY viewChanged FINAL)
public:
- explicit QQuickSwipeViewAttached(QQuickItem *delegateItem);
+ explicit QQuickSwipeViewAttached(QObject *parent = nullptr);
~QQuickSwipeViewAttached();
int index() const;
bool isCurrentItem() const;
+ bool isNextItem() const;
+ bool isPreviousItem() const;
QQuickSwipeView *view() const;
Q_SIGNALS:
void indexChanged();
void isCurrentItemChanged();
+ /*Q_REVISION(1)*/ void isNextItemChanged();
+ /*Q_REVISION(1)*/ void isPreviousItemChanged();
void viewChanged();
private:
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index ee3436f9..9aead901 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -104,7 +104,7 @@ public:
void updateCurrentIndex();
void updateLayout();
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
bool updatingLayout;
QQuickTabBar::Position position;
@@ -164,7 +164,7 @@ void QQuickTabBarPrivate::updateLayout()
}
}
-void QQuickTabBarPrivate::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
+void QQuickTabBarPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
if (!updatingLayout)
updateLayout();
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index a66d7bf5..56a538ee 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -101,15 +101,40 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtQuick.Controls::TextArea::pressAndHold(MouseEvent mouse)
+ \qmlsignal QtQuick.Controls::TextArea::pressAndHold(MouseEvent event)
This signal is emitted when there is a long press (the delay depends on the platform plugin).
- The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ The \l {MouseEvent}{event} parameter provides information about the press, including the x and y
position of the press, and which button is pressed.
+
+ \sa pressed, released
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::TextArea::pressed(MouseEvent event)
+ \since QtQuick.Controls 2.1
+
+ This signal is emitted when the text area is pressed by the user.
+ The \l {MouseEvent}{event} parameter provides information about the press,
+ including the x and y position of the press, and which button is pressed.
+
+ \sa released, pressAndHold
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::TextArea::released(MouseEvent event)
+ \since QtQuick.Controls 2.1
+
+ This signal is emitted when the text area is released by the user.
+ The \l {MouseEvent}{event} parameter provides information about the release,
+ including the x and y position of the press, and which button is pressed.
+
+ \sa pressed, pressAndHold
*/
QQuickTextAreaPrivate::QQuickTextAreaPrivate()
- : background(nullptr), focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr), flickable(nullptr)
+ : hovered(false), explicitHoverEnabled(false), background(nullptr),
+ focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr), flickable(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -160,7 +185,7 @@ void QQuickTextAreaPrivate::attachFlickable(QQuickFlickable *item)
QObject::connect(flickable, &QQuickFlickable::contentXChanged, q, &QQuickItem::update);
QObject::connect(flickable, &QQuickFlickable::contentYChanged, q, &QQuickItem::update);
- QQuickItemPrivate::get(flickable)->updateOrAddGeometryChangeListener(this, QQuickItemPrivate::SizeChange);
+ QQuickItemPrivate::get(flickable)->updateOrAddGeometryChangeListener(this, QQuickGeometryChange::Size);
QObjectPrivate::connect(flickable, &QQuickFlickable::contentWidthChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
QObjectPrivate::connect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
@@ -180,7 +205,7 @@ void QQuickTextAreaPrivate::detachFlickable()
QObject::disconnect(flickable, &QQuickFlickable::contentXChanged, q, &QQuickItem::update);
QObject::disconnect(flickable, &QQuickFlickable::contentYChanged, q, &QQuickItem::update);
- QQuickItemPrivate::get(flickable)->updateOrRemoveGeometryChangeListener(this, QQuickItemPrivate::SizeChange);
+ QQuickItemPrivate::get(flickable)->updateOrRemoveGeometryChangeListener(this, QQuickGeometryChange::Size);
QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentWidthChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
@@ -247,11 +272,11 @@ void QQuickTextAreaPrivate::resizeFlickableContent()
flickable->setContentHeight(q->contentHeight() + q->topPadding() + q->bottomPadding());
}
-void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
+void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff)
{
Q_UNUSED(item);
- Q_UNUSED(newGeometry);
- Q_UNUSED(oldGeometry);
+ Q_UNUSED(change);
+ Q_UNUSED(diff);
resizeFlickableControl();
}
@@ -285,6 +310,7 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent) :
{
Q_D(QQuickTextArea);
setActiveFocusOnTab(true);
+ setAcceptedMouseButtons(Qt::AllButtons);
d->setImplicitResizeEnabled(false);
d->pressHandler.control = this;
#ifndef QT_NO_CURSOR
@@ -332,6 +358,21 @@ void QQuickTextAreaPrivate::inheritFont(const QFont &f)
emit q->fontChanged();
}
+void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit)
+{
+ Q_Q(QQuickTextArea);
+ if (!xplicit && explicitHoverEnabled)
+ return;
+
+ bool wasEnabled = q->isHoverEnabled();
+ explicitHoverEnabled = xplicit;
+ if (wasEnabled != enabled) {
+ q->setAcceptHoverEvents(enabled);
+ QQuickControlPrivate::updateHoverEnabledRecur(q, enabled);
+ emit q->hoverEnabledChanged();
+ }
+}
+
void QQuickTextAreaPrivate::_q_readOnlyChanged(bool isReadOnly)
{
#ifndef QT_NO_ACCESSIBILITY
@@ -468,6 +509,64 @@ void QQuickTextArea::setFocusReason(Qt::FocusReason reason)
emit focusReasonChanged();
}
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::TextArea::hovered
+ \readonly
+
+ This property holds whether the text area is hovered.
+
+ \sa hoverEnabled
+*/
+bool QQuickTextArea::isHovered() const
+{
+ Q_D(const QQuickTextArea);
+ return d->hovered;
+}
+
+void QQuickTextArea::setHovered(bool hovered)
+{
+ Q_D(QQuickTextArea);
+ if (hovered == d->hovered)
+ return;
+
+ d->hovered = hovered;
+ emit hoveredChanged();
+}
+
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::TextArea::hoverEnabled
+
+ This property determines whether the text area accepts hover events. The default value is \c true.
+
+ \sa hovered
+*/
+bool QQuickTextArea::isHoverEnabled() const
+{
+ Q_D(const QQuickTextArea);
+ return d->hoverEnabled;
+}
+
+void QQuickTextArea::setHoverEnabled(bool enabled)
+{
+ Q_D(QQuickTextArea);
+ if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
+ return;
+
+ d->updateHoverEnabled(enabled, true); // explicit=true
+}
+
+void QQuickTextArea::resetHoverEnabled()
+{
+ Q_D(QQuickTextArea);
+ if (!d->explicitHoverEnabled)
+ return;
+
+ d->explicitHoverEnabled = false;
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+}
+
bool QQuickTextArea::contains(const QPointF &point) const
{
Q_D(const QQuickTextArea);
@@ -487,6 +586,8 @@ void QQuickTextArea::componentComplete()
{
Q_D(QQuickTextArea);
QQuickTextEdit::componentComplete();
+ if (!d->explicitHoverEnabled)
+ setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
d->accessibilityActiveChanged(true);
@@ -500,8 +601,11 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem:
{
Q_D(QQuickTextArea);
QQuickTextEdit::itemChange(change, value);
- if (change == ItemParentHasChanged && value.item)
+ if (change == ItemParentHasChanged && value.item) {
d->resolveFont();
+ if (!d->explicitHoverEnabled)
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+ }
}
void QQuickTextArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -551,6 +655,22 @@ void QQuickTextArea::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+void QQuickTextArea::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QQuickTextArea);
+ QQuickTextEdit::hoverEnterEvent(event);
+ setHovered(d->hoverEnabled);
+ event->setAccepted(d->hoverEnabled);
+}
+
+void QQuickTextArea::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickTextArea);
+ QQuickTextEdit::hoverLeaveEvent(event);
+ setHovered(false);
+ event->setAccepted(d->hoverEnabled);
+}
+
void QQuickTextArea::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickTextArea);
@@ -560,7 +680,12 @@ void QQuickTextArea::mousePressEvent(QMouseEvent *event)
QQuickTextEdit::mousePressEvent(d->pressHandler.delayedMousePressEvent);
d->pressHandler.clearDelayedMouseEvent();
}
+ // Calling the base class implementation will result in QQuickTextControl's
+ // press handler being called, which ignores events that aren't Qt::LeftButton.
+ const bool wasAccepted = event->isAccepted();
QQuickTextEdit::mousePressEvent(event);
+ if (wasAccepted)
+ event->accept();
}
}
diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h
index f00943aa..35bddba0 100644
--- a/src/quicktemplates2/qquicktextarea_p.h
+++ b/src/quicktemplates2/qquicktextarea_p.h
@@ -67,6 +67,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextArea : public QQuickTextEdit
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL)
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
+ Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION 1)
+ Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1)
public:
explicit QQuickTextArea(QQuickItem *parent = nullptr);
@@ -86,6 +88,13 @@ public:
Qt::FocusReason focusReason() const;
void setFocusReason(Qt::FocusReason reason);
+ bool isHovered() const;
+ void setHovered(bool hovered);
+
+ bool isHoverEnabled() const;
+ void setHoverEnabled(bool enabled);
+ void resetHoverEnabled();
+
bool contains(const QPointF &point) const override;
Q_SIGNALS:
@@ -95,7 +104,11 @@ Q_SIGNALS:
void backgroundChanged();
void placeholderTextChanged();
void focusReasonChanged();
+ Q_REVISION(1) void hoveredChanged();
+ Q_REVISION(1) void hoverEnabledChanged();
void pressAndHold(QQuickMouseEvent *event);
+ Q_REVISION(1) void pressed(QQuickMouseEvent *event);
+ Q_REVISION(1) void released(QQuickMouseEvent *event);
protected:
void classBegin() override;
@@ -107,6 +120,8 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
+ void hoverEnterEvent(QHoverEvent *event) override;
+ void hoverLeaveEvent(QHoverEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h
index 1598a87e..ed74ac9a 100644
--- a/src/quicktemplates2/qquicktextarea_p_p.h
+++ b/src/quicktemplates2/qquicktextarea_p_p.h
@@ -81,13 +81,15 @@ public:
void resolveFont();
void inheritFont(const QFont &f);
+ void updateHoverEnabled(bool h, bool e);
+
void attachFlickable(QQuickFlickable *flickable);
void detachFlickable();
void ensureCursorVisible();
void resizeFlickableControl();
void resizeFlickableContent();
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
qreal getImplicitWidth() const override;
qreal getImplicitHeight() const override;
@@ -104,6 +106,8 @@ public:
void deleteDelegate(QObject *object);
+ bool hovered;
+ bool explicitHoverEnabled;
QFont font;
QQuickItem *background;
QString placeholder;
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 610df907..2bb902a1 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -82,15 +82,41 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal QtQuick.Controls::TextField::pressAndHold(MouseEvent mouse)
+ \qmlsignal QtQuick.Controls::TextField::pressAndHold(MouseEvent event)
This signal is emitted when there is a long press (the delay depends on the platform plugin).
- The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ The \l {MouseEvent}{event} parameter provides information about the press, including the x and y
position of the press, and which button is pressed.
+
+ \sa pressed, released
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::TextField::pressed(MouseEvent event)
+ \since QtQuick.Controls 2.1
+
+ This signal is emitted when the text field is pressed by the user.
+ The \l {MouseEvent}{event} parameter provides information about the press,
+ including the x and y position of the press, and which button is pressed.
+
+ \sa released, pressAndHold
+*/
+
+/*!
+ \qmlsignal QtQuick.Controls::TextField::released(MouseEvent event)
+ \since QtQuick.Controls 2.1
+
+ This signal is emitted when the text field is released by the user.
+ The \l {MouseEvent}{event} parameter provides information about the release,
+ including the x and y position of the press, and which button is pressed.
+
+ \sa pressed, pressAndHold
*/
QQuickTextFieldPrivate::QQuickTextFieldPrivate()
- : background(nullptr)
+ : hovered(false)
+ , explicitHoverEnabled(false)
+ , background(nullptr)
, focusReason(Qt::OtherFocusReason)
, accessibleAttached(nullptr)
{
@@ -152,6 +178,7 @@ QQuickTextField::QQuickTextField(QQuickItem *parent) :
Q_D(QQuickTextField);
d->pressHandler.control = this;
d->setImplicitResizeEnabled(false);
+ setAcceptedMouseButtons(Qt::AllButtons);
setActiveFocusOnTab(true);
#ifndef QT_NO_CURSOR
setCursor(Qt::IBeamCursor);
@@ -195,6 +222,21 @@ void QQuickTextFieldPrivate::inheritFont(const QFont &f)
emit q->fontChanged();
}
+void QQuickTextFieldPrivate::updateHoverEnabled(bool enabled, bool xplicit)
+{
+ Q_Q(QQuickTextField);
+ if (!xplicit && explicitHoverEnabled)
+ return;
+
+ bool wasEnabled = q->isHoverEnabled();
+ explicitHoverEnabled = xplicit;
+ if (wasEnabled != enabled) {
+ q->setAcceptHoverEvents(enabled);
+ QQuickControlPrivate::updateHoverEnabledRecur(q, enabled);
+ emit q->hoverEnabledChanged();
+ }
+}
+
void QQuickTextFieldPrivate::_q_readOnlyChanged(bool isReadOnly)
{
#ifndef QT_NO_ACCESSIBILITY
@@ -346,6 +388,64 @@ void QQuickTextField::setFocusReason(Qt::FocusReason reason)
emit focusReasonChanged();
}
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::TextField::hovered
+ \readonly
+
+ This property holds whether the text field is hovered.
+
+ \sa hoverEnabled
+*/
+bool QQuickTextField::isHovered() const
+{
+ Q_D(const QQuickTextField);
+ return d->hovered;
+}
+
+void QQuickTextField::setHovered(bool hovered)
+{
+ Q_D(QQuickTextField);
+ if (hovered == d->hovered)
+ return;
+
+ d->hovered = hovered;
+ emit hoveredChanged();
+}
+
+/*!
+ \since QtQuick.Controls 2.1
+ \qmlproperty bool QtQuick.Controls::TextField::hoverEnabled
+
+ This property determines whether the text field accepts hover events. The default value is \c false.
+
+ \sa hovered
+*/
+bool QQuickTextField::isHoverEnabled() const
+{
+ Q_D(const QQuickTextField);
+ return d->hoverEnabled;
+}
+
+void QQuickTextField::setHoverEnabled(bool enabled)
+{
+ Q_D(QQuickTextField);
+ if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
+ return;
+
+ d->updateHoverEnabled(enabled, true); // explicit=true
+}
+
+void QQuickTextField::resetHoverEnabled()
+{
+ Q_D(QQuickTextField);
+ if (!d->explicitHoverEnabled)
+ return;
+
+ d->explicitHoverEnabled = false;
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+}
+
void QQuickTextField::classBegin()
{
Q_D(QQuickTextField);
@@ -357,6 +457,8 @@ void QQuickTextField::componentComplete()
{
Q_D(QQuickTextField);
QQuickTextInput::componentComplete();
+ if (!d->explicitHoverEnabled)
+ setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
d->accessibilityActiveChanged(true);
@@ -370,8 +472,11 @@ void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem
{
Q_D(QQuickTextField);
QQuickTextInput::itemChange(change, value);
- if (change == ItemParentHasChanged && value.item)
+ if (change == ItemParentHasChanged && value.item) {
d->resolveFont();
+ if (!d->explicitHoverEnabled)
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+ }
}
void QQuickTextField::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -409,6 +514,22 @@ void QQuickTextField::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+void QQuickTextField::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QQuickTextField);
+ QQuickTextInput::hoverEnterEvent(event);
+ setHovered(d->hoverEnabled);
+ event->setAccepted(d->hoverEnabled);
+}
+
+void QQuickTextField::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickTextField);
+ QQuickTextInput::hoverLeaveEvent(event);
+ setHovered(false);
+ event->setAccepted(d->hoverEnabled);
+}
+
void QQuickTextField::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickTextField);
diff --git a/src/quicktemplates2/qquicktextfield_p.h b/src/quicktemplates2/qquicktextfield_p.h
index 591d6edd..57521592 100644
--- a/src/quicktemplates2/qquicktextfield_p.h
+++ b/src/quicktemplates2/qquicktextfield_p.h
@@ -66,6 +66,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextField : public QQuickTextInput
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL)
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
+ Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION 1)
+ Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION 1)
public:
explicit QQuickTextField(QQuickItem *parent = nullptr);
@@ -83,6 +85,13 @@ public:
Qt::FocusReason focusReason() const;
void setFocusReason(Qt::FocusReason reason);
+ bool isHovered() const;
+ void setHovered(bool hovered);
+
+ bool isHoverEnabled() const;
+ void setHoverEnabled(bool enabled);
+ void resetHoverEnabled();
+
Q_SIGNALS:
void fontChanged();
void implicitWidthChanged3();
@@ -90,7 +99,11 @@ Q_SIGNALS:
void backgroundChanged();
void placeholderTextChanged();
void focusReasonChanged();
- void pressAndHold(QQuickMouseEvent *mouse);
+ Q_REVISION(1) void hoveredChanged();
+ Q_REVISION(1) void hoverEnabledChanged();
+ void pressAndHold(QQuickMouseEvent *event);
+ Q_REVISION(1) void pressed(QQuickMouseEvent *event);
+ Q_REVISION(1) void released(QQuickMouseEvent *event);
protected:
void classBegin() override;
@@ -102,6 +115,8 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
+ void hoverEnterEvent(QHoverEvent *event) override;
+ void hoverLeaveEvent(QHoverEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h
index 5800f448..fb973ad4 100644
--- a/src/quicktemplates2/qquicktextfield_p_p.h
+++ b/src/quicktemplates2/qquicktextfield_p_p.h
@@ -79,6 +79,8 @@ public:
void resolveFont();
void inheritFont(const QFont &f);
+ void updateHoverEnabled(bool h, bool e);
+
qreal getImplicitWidth() const override;
qreal getImplicitHeight() const override;
@@ -95,6 +97,8 @@ public:
void deleteDelegate(QObject *object);
+ bool hovered;
+ bool explicitHoverEnabled;
QFont font;
QQuickItem *background;
QString placeholder;
diff --git a/src/quicktemplates2/qquicktoolseparator.cpp b/src/quicktemplates2/qquicktoolseparator.cpp
new file mode 100644
index 00000000..36c5ac12
--- /dev/null
+++ b/src/quicktemplates2/qquicktoolseparator.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicktoolseparator_p.h"
+
+#include "qquickcontrol_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype ToolSeparator
+ \inherits Control
+ \instantiates QQuickToolSeparator
+ \inqmlmodule QtQuick.Controls
+ \since 5.8
+ \ingroup qtquickcontrols2-separators
+ \brief Separates a group of items in a toolbar from adjacent items.
+
+ ToolSeparator is used to visually distinguish between groups of items in a
+ toolbar by separating them with a line. It can be used in horizontal or
+ vertical toolbars by setting the \l orientation property to \c Qt.Vertical
+ or \c Qt.Horizontal, respectively.
+
+ \image qtquickcontrols2-toolseparator.png
+
+ \snippet qtquickcontrols2-toolseparator.qml 1
+
+ \sa {Customizing ToolSeparator}, {Separator Controls}
+*/
+
+class QQuickToolSeparatorPrivate : public QQuickControlPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickToolSeparator)
+
+public:
+ QQuickToolSeparatorPrivate() :
+ orientation(Qt::Vertical)
+ {
+ }
+
+ Qt::Orientation orientation;
+};
+
+QQuickToolSeparator::QQuickToolSeparator(QQuickItem *parent) :
+ QQuickControl(*(new QQuickToolSeparatorPrivate), parent)
+{
+}
+
+/*!
+ \qmlproperty enumeration QtQuick.Controls::ToolSeparator::orientation
+
+ This property holds the orientation of the tool separator.
+
+ Possible values:
+ \value Qt.Horizontal A horizontal separator is used in a vertical toolbar.
+ \value Qt.Vertical A vertical separator is used in a horizontal toolbar. (default)
+*/
+Qt::Orientation QQuickToolSeparator::orientation() const
+{
+ Q_D(const QQuickToolSeparator);
+ return d->orientation;
+}
+
+void QQuickToolSeparator::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QQuickToolSeparator);
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged();
+}
+
+/*!
+ \readonly
+ \qmlproperty bool QtQuick.Controls::ToolSeparator::horizontal
+
+ This property holds whether \l orientation is equal to \c Qt.Horizontal.
+
+ It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
+
+ \sa orientation, vertical
+*/
+bool QQuickToolSeparator::isHorizontal() const
+{
+ Q_D(const QQuickToolSeparator);
+ return d->orientation == Qt::Horizontal;
+}
+
+/*!
+ \readonly
+ \qmlproperty bool QtQuick.Controls::ToolSeparator::vertical
+
+ This property holds whether \l orientation is equal to \c Qt.Vertical.
+
+ It is useful for \l {Customizing ToolSeparator}{customizing ToolSeparator}.
+
+ \sa orientation, horizontal
+*/
+bool QQuickToolSeparator::isVertical() const
+{
+ Q_D(const QQuickToolSeparator);
+ return d->orientation == Qt::Vertical;
+}
+
+#ifndef QT_NO_ACCESSIBILITY
+QAccessible::Role QQuickToolSeparator::accessibleRole() const
+{
+ return QAccessible::Separator;
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquicktoolseparator_p.h b/src/quicktemplates2/qquicktoolseparator_p.h
new file mode 100644
index 00000000..c3376c22
--- /dev/null
+++ b/src/quicktemplates2/qquicktoolseparator_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTOOLSEPARATOR_P_H
+#define QQUICKTOOLSEPARATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickcontrol_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickToolSeparatorPrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickToolSeparator : public QQuickControl
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
+ Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL)
+ Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL)
+
+public:
+ explicit QQuickToolSeparator(QQuickItem *parent = nullptr);
+
+ Qt::Orientation orientation() const;
+ void setOrientation(Qt::Orientation orientation);
+
+ bool isHorizontal() const;
+ bool isVertical() const;
+
+Q_SIGNALS:
+ void orientationChanged();
+
+protected:
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::Role accessibleRole() const override;
+#endif
+
+private:
+ Q_DISABLE_COPY(QQuickToolSeparator)
+ Q_DECLARE_PRIVATE(QQuickToolSeparator)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickToolSeparator)
+
+#endif // QQUICKTOOLSEPARATOR_P_H
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 3bd47457..b60dec22 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -345,7 +345,7 @@ QQuickToolTip *QQuickToolTipAttachedPrivate::instance(bool create) const
if (!tip && create) {
// TODO: a cleaner way to create the instance? QQml(Meta)Type?
QQmlComponent component(engine);
- component.setData("import QtQuick.Controls 2.0; ToolTip { }", QUrl());
+ component.setData("import QtQuick.Controls 2.1; ToolTip { }", QUrl());
QObject *object = component.create();
if (object)
diff --git a/src/quicktemplates2/qquicktooltip_p.h b/src/quicktemplates2/qquicktooltip_p.h
index 9b628747..3be9214b 100644
--- a/src/quicktemplates2/qquicktooltip_p.h
+++ b/src/quicktemplates2/qquicktooltip_p.h
@@ -110,7 +110,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickToolTipAttached : public QObject
Q_PROPERTY(QQuickToolTip *toolTip READ toolTip CONSTANT FINAL)
public:
- explicit QQuickToolTipAttached(QObject *parent);
+ explicit QQuickToolTipAttached(QObject *parent = nullptr);
QString text() const;
void setText(const QString &text);
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 9f19f661..cf5df27a 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -36,8 +36,10 @@
#include "qquicktumbler_p.h"
+#include <QtQml/qqmlinfo.h>
#include <QtQuick/private/qquickflickable_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
+#include <QtQuickTemplates2/private/qquicktumbler_p_p.h>
QT_BEGIN_NAMESPACE
@@ -59,51 +61,48 @@ QT_BEGIN_NAMESPACE
}
\endcode
- \section1 Non-wrapping Tumbler
+ Tumbler allows the user to select an option from a spinnable \e "wheel" of
+ items. It is useful for when there are too many options to use, for
+ example, a RadioButton, and too few options to require the use of an
+ editable SpinBox. It is convenient in that it requires no keyboard usage
+ and wraps around at each end when there are a large number of items.
- The default contentItem of Tumbler is a \l PathView, which wraps when it
- reaches the top and bottom. To achieve a non-wrapping Tumbler, use ListView
- as the contentItem:
+ The API is similar to that of views like \l ListView and \l PathView; a
+ \l model and \l delegate can be set, and the \l count and \l currentItem
+ properties provide read-only access to information about the view.
- \snippet tst_tumbler.qml contentItem
+ Unlike views like \l PathView and \l ListView, however, there is always a
+ current item (when the model isn't empty). This means that when \l count is
+ equal to \c 0, \l currentIndex will be \c -1. In all other cases, it will
+ be greater than or equal to \c 0.
+
+ By default, Tumbler \l {wrap}{wraps} when it reaches the top and bottom, as
+ long as there are more items in the model than there are visible items;
+ that is, when \l count is greater than \l visibleItemCount:
+
+ \snippet qtquickcontrols2-tumbler-timePicker.qml tumbler
\sa {Customizing Tumbler}, {Input Controls}
*/
-class QQuickTumblerPrivate : public QQuickControlPrivate, public QQuickItemChangeListener
+QQuickTumblerPrivate::QQuickTumblerPrivate() :
+ delegate(nullptr),
+ visibleItemCount(5),
+ wrap(true),
+ explicitWrap(false),
+ ignoreWrapChanges(false),
+ view(nullptr),
+ viewContentItem(nullptr),
+ viewContentItemType(UnsupportedContentItemType),
+ currentIndex(-1),
+ pendingCurrentIndex(-1),
+ ignoreCurrentIndexChanges(false),
+ count(0)
{
- Q_DECLARE_PUBLIC(QQuickTumbler)
-
-public:
- QQuickTumblerPrivate() :
- delegate(nullptr),
- visibleItemCount(3)
- {
- }
-
- ~QQuickTumblerPrivate()
- {
- }
-
- QVariant model;
- QQmlComponent *delegate;
- int visibleItemCount;
-
- void _q_updateItemHeights();
- void _q_updateItemWidths();
-
- void itemChildAdded(QQuickItem *, QQuickItem *) override;
- void itemChildRemoved(QQuickItem *, QQuickItem *) override;
-};
+}
-static QList<QQuickItem *> contentItemChildItems(QQuickItem *contentItem)
+QQuickTumblerPrivate::~QQuickTumblerPrivate()
{
- if (!contentItem)
- return QList<QQuickItem *>();
-
- // PathView has no contentItem property, but ListView does.
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(contentItem);
- return flickable ? flickable->contentItem()->childItems() : contentItem->childItems();
}
namespace {
@@ -111,44 +110,55 @@ namespace {
{
return tumbler->availableHeight() / tumbler->visibleItemCount();
}
+}
- enum ContentItemType {
- UnsupportedContentItemType,
- PathViewContentItem,
- ListViewContentItem
- };
-
- static inline QQuickItem *actualContentItem(QQuickItem *rootContentItem, ContentItemType contentType)
- {
- if (contentType == PathViewContentItem)
- return rootContentItem;
- else if (contentType == ListViewContentItem)
- return qobject_cast<QQuickFlickable*>(rootContentItem)->contentItem();
-
- return nullptr;
+/*
+ Finds the contentItem of the view that is a child of the control's \a contentItem.
+ The type is stored in \a type.
+*/
+QQuickItem *QQuickTumblerPrivate::determineViewType(QQuickItem *contentItem)
+{
+ if (contentItem->inherits("QQuickPathView")) {
+ view = contentItem;
+ viewContentItem = contentItem;
+ viewContentItemType = PathViewContentItem;
+ return contentItem;
+ } else if (contentItem->inherits("QQuickListView")) {
+ view = contentItem;
+ viewContentItem = qobject_cast<QQuickFlickable*>(contentItem)->contentItem();
+ viewContentItemType = ListViewContentItem;
+ return contentItem;
+ } else {
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *childItem : childItems) {
+ QQuickItem *item = determineViewType(childItem);
+ if (item)
+ return item;
+ }
}
- static inline ContentItemType contentItemType(QQuickItem *rootContentItem)
- {
- if (rootContentItem->inherits("QQuickPathView"))
- return PathViewContentItem;
- else if (rootContentItem->inherits("QQuickListView"))
- return ListViewContentItem;
+ resetViewData();
+ return nullptr;
+}
- return UnsupportedContentItemType;
- }
+void QQuickTumblerPrivate::resetViewData()
+{
+ view = nullptr;
+ viewContentItem = nullptr;
+ viewContentItemType = UnsupportedContentItemType;
+}
- static inline ContentItemType contentItemTypeFromDelegate(QQuickItem *delegateItem)
- {
- if (delegateItem->parentItem()->inherits("QQuickPathView")) {
- return PathViewContentItem;
- } else if (delegateItem->parentItem()->parentItem()
- && delegateItem->parentItem()->parentItem()->inherits("QQuickListView")) {
- return ListViewContentItem;
- }
+QList<QQuickItem *> QQuickTumblerPrivate::viewContentItemChildItems() const
+{
+ if (!viewContentItem)
+ return QList<QQuickItem *>();
- return UnsupportedContentItemType;
- }
+ return viewContentItem->childItems();
+}
+
+QQuickTumblerPrivate *QQuickTumblerPrivate::get(QQuickTumbler *tumbler)
+{
+ return tumbler->d_func();
}
void QQuickTumblerPrivate::_q_updateItemHeights()
@@ -157,7 +167,7 @@ void QQuickTumblerPrivate::_q_updateItemHeights()
// which doesn't affect them, only their getters.
Q_Q(const QQuickTumbler);
const qreal itemHeight = delegateHeight(q);
- const auto items = contentItemChildItems(contentItem);
+ const auto items = viewContentItemChildItems();
for (QQuickItem *childItem : items)
childItem->setHeight(itemHeight);
}
@@ -166,11 +176,49 @@ void QQuickTumblerPrivate::_q_updateItemWidths()
{
Q_Q(const QQuickTumbler);
const qreal availableWidth = q->availableWidth();
- const auto items = contentItemChildItems(contentItem);
+ const auto items = viewContentItemChildItems();
for (QQuickItem *childItem : items)
childItem->setWidth(availableWidth);
}
+void QQuickTumblerPrivate::_q_onViewCurrentIndexChanged()
+{
+ Q_Q(QQuickTumbler);
+ if (view && !ignoreCurrentIndexChanges) {
+ const int oldCurrentIndex = currentIndex;
+ currentIndex = view->property("currentIndex").toInt();
+ if (oldCurrentIndex != currentIndex)
+ emit q->currentIndexChanged();
+ }
+}
+
+void QQuickTumblerPrivate::_q_onViewCountChanged()
+{
+ Q_Q(QQuickTumbler);
+
+ setCount(view->property("count").toInt());
+
+ if (count > 0) {
+ if (pendingCurrentIndex != -1) {
+ // If there was an attempt to set currentIndex at creation, try to finish that attempt now.
+ // componentComplete() is too early, because the count might only be known sometime after completion.
+ q->setCurrentIndex(pendingCurrentIndex);
+ // If we could successfully set the currentIndex, consider it done.
+ // Otherwise, we'll try again later in updatePolish().
+ if (currentIndex == pendingCurrentIndex)
+ pendingCurrentIndex = -1;
+ else
+ q->polish();
+ } else if (currentIndex == -1) {
+ // If new items were added and our currentIndex was -1, we must
+ // enforce our rule of a non-negative currentIndex when count > 0.
+ q->setCurrentIndex(0);
+ }
+ } else {
+ q->setCurrentIndex(-1);
+ }
+}
+
void QQuickTumblerPrivate::itemChildAdded(QQuickItem *, QQuickItem *)
{
_q_updateItemWidths();
@@ -196,6 +244,9 @@ QQuickTumbler::QQuickTumbler(QQuickItem *parent) :
QQuickTumbler::~QQuickTumbler()
{
+ Q_D(QQuickTumbler);
+ // Ensure that the item change listener is removed.
+ d->disconnectFromView();
}
/*!
@@ -215,8 +266,17 @@ void QQuickTumbler::setModel(const QVariant &model)
if (model == d->model)
return;
+ d->lockWrap();
+
d->model = model;
emit modelChanged();
+
+ d->unlockWrap();
+
+ // Don't try to correct the currentIndex if count() isn't known yet.
+ // We can check in setupViewData() instead.
+ if (isComponentComplete() && d->view && count() == 0)
+ setCurrentIndex(-1);
}
/*!
@@ -228,24 +288,67 @@ void QQuickTumbler::setModel(const QVariant &model)
int QQuickTumbler::count() const
{
Q_D(const QQuickTumbler);
- return d->contentItem->property("count").toInt();
+ return d->count;
}
/*!
\qmlproperty int QtQuick.Controls::Tumbler::currentIndex
This property holds the index of the current item.
+
+ The value of this property is \c -1 when \l count is equal to \c 0. In all
+ other cases, it will be greater than or equal to \c 0.
*/
int QQuickTumbler::currentIndex() const
{
Q_D(const QQuickTumbler);
- return d->contentItem ? d->contentItem->property("currentIndex").toInt() : -1;
+ return d->currentIndex;
}
void QQuickTumbler::setCurrentIndex(int currentIndex)
{
Q_D(QQuickTumbler);
- d->contentItem->setProperty("currentIndex", currentIndex);
+ if (currentIndex == d->currentIndex || currentIndex < -1)
+ return;
+
+ if (!isComponentComplete()) {
+ // Views can't set currentIndex until they're ready.
+ d->pendingCurrentIndex = currentIndex;
+ return;
+ }
+
+ // -1 doesn't make sense for a non-empty Tumbler, because unlike
+ // e.g. ListView, there's always one item selected.
+ // Wait until the component has finished before enforcing this rule, though,
+ // because the count might not be known yet.
+ if ((d->count > 0 && currentIndex == -1) || (currentIndex >= d->count)) {
+ return;
+ }
+
+ // The view might not have been created yet, as is the case
+ // if you create a Tumbler component and pass e.g. { currentIndex: 2 }
+ // to createObject().
+ if (d->view) {
+ // Only actually set our currentIndex if the view was able to set theirs.
+ bool couldSet = false;
+ if (d->count == 0 && currentIndex == -1) {
+ // PathView insists on using 0 as the currentIndex when there are no items.
+ couldSet = true;
+ } else {
+ d->ignoreCurrentIndexChanges = true;
+ d->view->setProperty("currentIndex", currentIndex);
+ d->ignoreCurrentIndexChanges = false;
+
+ couldSet = d->view->property("currentIndex").toInt() == currentIndex;
+ }
+
+ if (couldSet) {
+ // The view's currentIndex might not have actually changed, but ours has,
+ // and that's what user code sees.
+ d->currentIndex = currentIndex;
+ emit currentIndexChanged();
+ }
+ }
}
/*!
@@ -257,7 +360,7 @@ void QQuickTumbler::setCurrentIndex(int currentIndex)
QQuickItem *QQuickTumbler::currentItem() const
{
Q_D(const QQuickTumbler);
- return d->contentItem ? d->contentItem->property("currentItem").value<QQuickItem*>() : nullptr;
+ return d->view ? d->view->property("currentItem").value<QQuickItem*>() : nullptr;
}
/*!
@@ -304,15 +407,41 @@ void QQuickTumbler::setVisibleItemCount(int visibleItemCount)
emit visibleItemCountChanged();
}
-QQuickTumblerAttached *QQuickTumbler::qmlAttachedProperties(QObject *object)
+/*!
+ \qmlproperty bool QtQuick.Controls::Tumbler::wrap
+ \since QtQuick.Controls 2.1
+
+ This property determines whether or not the tumbler wraps around when it
+ reaches the top or bottom.
+
+ The default value is \c false when \l count is less than
+ \l visibleItemCount, as it is simpler to interact with a non-wrapping Tumbler
+ when there are only a few items. To override this behavior, explicitly set
+ the value of this property. To return to the default behavior, set this
+ property to \c undefined.
+*/
+bool QQuickTumbler::wrap() const
{
- QQuickItem *delegateItem = qobject_cast<QQuickItem *>(object);
- if (!delegateItem) {
- qWarning() << "Tumbler: attached properties of Tumbler must be accessed from within a delegate item";
- return nullptr;
- }
+ Q_D(const QQuickTumbler);
+ return d->wrap;
+}
+
+void QQuickTumbler::setWrap(bool wrap)
+{
+ Q_D(QQuickTumbler);
+ d->setWrap(wrap, true);
+}
- return new QQuickTumblerAttached(delegateItem);
+void QQuickTumbler::resetWrap()
+{
+ Q_D(QQuickTumbler);
+ d->explicitWrap = false;
+ d->setWrapBasedOnCount();
+}
+
+QQuickTumblerAttached *QQuickTumbler::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickTumblerAttached(object);
}
void QQuickTumbler::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -333,6 +462,13 @@ void QQuickTumbler::componentComplete()
QQuickControl::componentComplete();
d->_q_updateItemHeights();
d->_q_updateItemWidths();
+
+ if (!d->view) {
+ // Force the view to be created.
+ emit wrapChanged();
+ // Determine the type of view for attached properties, etc.
+ d->setupViewData(d->contentItem);
+ }
}
void QQuickTumbler::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
@@ -341,59 +477,189 @@ void QQuickTumbler::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
QQuickControl::contentItemChange(newItem, oldItem);
- // Since we use the currentIndex of the contentItem directly, we must
- // ensure that we keep track of the currentIndex so it doesn't get lost
- // between contentItem changes.
- const int previousCurrentIndex = currentIndex();
-
- if (oldItem) {
- disconnect(oldItem, SIGNAL(currentIndexChanged()), this, SIGNAL(currentIndexChanged()));
- disconnect(oldItem, SIGNAL(currentItemChanged()), this, SIGNAL(currentItemChanged()));
- disconnect(oldItem, SIGNAL(countChanged()), this, SIGNAL(countChanged()));
-
- ContentItemType oldContentItemType = contentItemType(oldItem);
- QQuickItem *actualOldContentItem = actualContentItem(oldItem, oldContentItemType);
- QQuickItemPrivate *actualContentItemPrivate = QQuickItemPrivate::get(actualOldContentItem);
- actualContentItemPrivate->removeItemChangeListener(d, QQuickItemPrivate::Children);
- }
+ if (oldItem)
+ d->disconnectFromView();
if (newItem) {
- ContentItemType contentType = contentItemType(newItem);
- if (contentType == UnsupportedContentItemType) {
- qWarning() << "Tumbler: contentItems other than PathView and ListView are not supported";
- return;
+ // We wait until wrap is set to that we know which type of view to create.
+ // If we try to set up the view too early, we'll issue warnings about it not existing.
+ if (isComponentComplete()) {
+ // Make sure we use the new content item and not the current one, as that won't
+ // be changed until after contentItemChange() has finished.
+ d->setupViewData(newItem);
}
+ }
+}
+
+void QQuickTumblerPrivate::disconnectFromView()
+{
+ Q_Q(QQuickTumbler);
+ if (!view) {
+ // If a custom content item is declared, it can happen that
+ // the original contentItem exists without the view etc. having been
+ // determined yet, and then this is called when the custom content item
+ // is eventually set.
+ return;
+ }
- connect(newItem, SIGNAL(currentIndexChanged()), this, SIGNAL(currentIndexChanged()));
- connect(newItem, SIGNAL(currentItemChanged()), this, SIGNAL(currentItemChanged()));
- connect(newItem, SIGNAL(countChanged()), this, SIGNAL(countChanged()));
+ QObject::disconnect(view, SIGNAL(currentIndexChanged()), q, SLOT(_q_onViewCurrentIndexChanged()));
+ QObject::disconnect(view, SIGNAL(currentItemChanged()), q, SIGNAL(currentItemChanged()));
+ QObject::disconnect(view, SIGNAL(countChanged()), q, SLOT(_q_onViewCountChanged()));
- QQuickItem *actualNewContentItem = actualContentItem(newItem, contentType);
- QQuickItemPrivate *actualContentItemPrivate = QQuickItemPrivate::get(actualNewContentItem);
- actualContentItemPrivate->addItemChangeListener(d, QQuickItemPrivate::Children);
+ QQuickItemPrivate *oldViewContentItemPrivate = QQuickItemPrivate::get(viewContentItem);
+ oldViewContentItemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Children);
- // If the previous currentIndex is -1, it means we had no contentItem previously.
- if (previousCurrentIndex != -1) {
- // Can't call setCurrentIndex here, as contentItemChange() is
- // called *before* the contentItem is set.
- newItem->setProperty("currentIndex", previousCurrentIndex);
- }
+ resetViewData();
+}
+
+void QQuickTumblerPrivate::setupViewData(QQuickItem *newControlContentItem)
+{
+ // Don't do anything if we've already set up.
+ if (view)
+ return;
+
+ determineViewType(newControlContentItem);
+
+ if (viewContentItemType == QQuickTumblerPrivate::UnsupportedContentItemType) {
+ qWarning() << "Tumbler: contentItem must contain either a PathView or a ListView";
+ return;
}
+
+ Q_Q(QQuickTumbler);
+ QObject::connect(view, SIGNAL(currentIndexChanged()), q, SLOT(_q_onViewCurrentIndexChanged()));
+ QObject::connect(view, SIGNAL(currentItemChanged()), q, SIGNAL(currentItemChanged()));
+ QObject::connect(view, SIGNAL(countChanged()), q, SLOT(_q_onViewCountChanged()));
+
+ QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(viewContentItem);
+ viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Children);
+
+ // Sync the view's currentIndex with ours.
+ syncCurrentIndex();
}
-void QQuickTumbler::keyPressEvent(QKeyEvent *event)
+void QQuickTumblerPrivate::syncCurrentIndex()
{
- Q_D(QQuickTumbler);
+ const int actualViewIndex = view->property("currentIndex").toInt();
+ Q_Q(QQuickTumbler);
+
+ // Nothing to do.
+ if (actualViewIndex == currentIndex)
+ return;
+ // PathView likes to use 0 as currentIndex for empty models, but we use -1 for that.
+ if (q->count() == 0 && actualViewIndex == 0)
+ return;
+
+ ignoreCurrentIndexChanges = true;
+ view->setProperty("currentIndex", currentIndex);
+ ignoreCurrentIndexChanges = false;
+}
+
+void QQuickTumblerPrivate::setCount(int newCount)
+{
+ if (newCount == count)
+ return;
+
+ count = newCount;
+
+ Q_Q(QQuickTumbler);
+ setWrapBasedOnCount();
+
+ emit q->countChanged();
+}
+
+void QQuickTumblerPrivate::setWrapBasedOnCount()
+{
+ if (count == 0 || explicitWrap || ignoreWrapChanges)
+ return;
+
+ setWrap(count >= visibleItemCount, false);
+}
+
+void QQuickTumblerPrivate::setWrap(bool shouldWrap, bool isExplicit)
+{
+ if (isExplicit)
+ explicitWrap = true;
+
+ Q_Q(QQuickTumbler);
+ if (q->isComponentComplete() && shouldWrap == wrap)
+ return;
+
+ // Since we use the currentIndex of the contentItem directly, we must
+ // ensure that we keep track of the currentIndex so it doesn't get lost
+ // between view changes.
+ const int oldCurrentIndex = currentIndex;
+
+ disconnectFromView();
+
+ wrap = shouldWrap;
+
+ // New views will set their currentIndex upon creation, which we'd otherwise
+ // take as the correct one, so we must ignore them.
+ ignoreCurrentIndexChanges = true;
+
+ // This will cause the view to be created if our contentItem is a TumblerView.
+ emit q->wrapChanged();
+
+ ignoreCurrentIndexChanges = false;
+
+ // The view should have been created now, so we can start determining its type, etc.
+ // If the delegates use attached properties, this will have already been called,
+ // in which case it will return early. If the delegate doesn't use attached properties,
+ // we need to call it here.
+ setupViewData(contentItem);
+
+ q->setCurrentIndex(oldCurrentIndex);
+}
+
+void QQuickTumblerPrivate::lockWrap()
+{
+ ignoreWrapChanges = true;
+}
+
+void QQuickTumblerPrivate::unlockWrap()
+{
+ ignoreWrapChanges = false;
+ setWrapBasedOnCount();
+}
+
+void QQuickTumbler::keyPressEvent(QKeyEvent *event)
+{
QQuickControl::keyPressEvent(event);
- if (event->isAutoRepeat())
+ Q_D(QQuickTumbler);
+ if (event->isAutoRepeat() || !d->view)
return;
if (event->key() == Qt::Key_Up) {
- QMetaObject::invokeMethod(d->contentItem, "decrementCurrentIndex");
+ QMetaObject::invokeMethod(d->view, "decrementCurrentIndex");
} else if (event->key() == Qt::Key_Down) {
- QMetaObject::invokeMethod(d->contentItem, "incrementCurrentIndex");
+ QMetaObject::invokeMethod(d->view, "incrementCurrentIndex");
+ }
+}
+
+void QQuickTumbler::updatePolish()
+{
+ Q_D(QQuickTumbler);
+ if (d->pendingCurrentIndex != -1) {
+ // If the count is still 0, it's not going to happen.
+ if (d->count == 0) {
+ d->pendingCurrentIndex = -1;
+ return;
+ }
+
+ // If there is a pending currentIndex at this stage, it means that
+ // the view wouldn't set our currentIndex in _q_onViewCountChanged
+ // because it wasn't ready. Try one last time here.
+ setCurrentIndex(d->pendingCurrentIndex);
+
+ if (d->currentIndex != d->pendingCurrentIndex && d->currentIndex == -1) {
+ // If we *still* couldn't set it, it's probably invalid.
+ // See if we can at least enforce our rule of "non-negative currentIndex when count > 0" instead.
+ setCurrentIndex(0);
+ }
+
+ d->pendingCurrentIndex = -1;
}
}
@@ -401,13 +667,17 @@ class QQuickTumblerAttachedPrivate : public QObjectPrivate, public QQuickItemCha
{
Q_DECLARE_PUBLIC(QQuickTumblerAttached)
public:
- QQuickTumblerAttachedPrivate(QQuickItem *delegateItem) :
+ QQuickTumblerAttachedPrivate() :
tumbler(nullptr),
index(-1),
displacement(0)
{
+ }
+
+ void init(QQuickItem *delegateItem)
+ {
if (!delegateItem->parentItem()) {
- qWarning() << "Tumbler: attached properties must be accessed from within a delegate item that has a parent";
+ qWarning() << "Tumbler: attached properties must be accessed through a delegate item that has a parent";
return;
}
@@ -418,20 +688,15 @@ public:
}
index = indexContextProperty.toInt();
- const ContentItemType contentItemType = contentItemTypeFromDelegate(delegateItem);
- if (contentItemType == UnsupportedContentItemType)
- return;
- // ListView has an "additional" content item.
- tumbler = qobject_cast<QQuickTumbler* >(contentItemType == PathViewContentItem
- ? delegateItem->parentItem()->parentItem() : delegateItem->parentItem()->parentItem()->parentItem());
- Q_ASSERT(tumbler);
- }
-
- ~QQuickTumblerAttachedPrivate() {
+ QQuickItem *parentItem = delegateItem;
+ while ((parentItem = parentItem->parentItem())) {
+ if ((tumbler = qobject_cast<QQuickTumbler*>(parentItem)))
+ break;
+ }
}
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
void itemChildAdded(QQuickItem *, QQuickItem *) override;
void itemChildRemoved(QQuickItem *, QQuickItem *) override;
@@ -446,7 +711,7 @@ public:
qreal displacement;
};
-void QQuickTumblerAttachedPrivate::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
+void QQuickTumblerAttachedPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
_q_calculateDisplacement();
}
@@ -477,41 +742,43 @@ void QQuickTumblerAttachedPrivate::_q_calculateDisplacement()
const int previousDisplacement = displacement;
displacement = 0;
+ // Can happen if the attached properties are accessed on the wrong type of item or the tumbler was destroyed.
if (!tumbler) {
emitIfDisplacementChanged(previousDisplacement, displacement);
return;
}
- const int count = tumbler->count();
- // This can happen in tests, so it may happen in normal usage too.
- if (count == 0) {
+ // Can happen if there is no ListView or PathView within the contentItem.
+ QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(tumbler);
+ if (!tumblerPrivate->viewContentItem) {
emitIfDisplacementChanged(previousDisplacement, displacement);
return;
}
- ContentItemType contentType = contentItemType(tumbler->contentItem());
- if (contentType == UnsupportedContentItemType) {
+ // The attached property gets created before our count is updated, so just cheat here
+ // to avoid having to listen to count changes.
+ const int count = tumblerPrivate->view->property("count").toInt();
+ // This can happen in tests, so it may happen in normal usage too.
+ if (count == 0) {
emitIfDisplacementChanged(previousDisplacement, displacement);
return;
}
- qreal offset = 0;
-
- if (contentType == PathViewContentItem) {
- offset = tumbler->contentItem()->property("offset").toReal();
+ if (tumblerPrivate->viewContentItemType == QQuickTumblerPrivate::PathViewContentItem) {
+ const qreal offset = tumblerPrivate->view->property("offset").toReal();
displacement = count > 1 ? count - index - offset : 0;
// Don't add 1 if count <= visibleItemCount
const int visibleItems = tumbler->visibleItemCount();
- int halfVisibleItems = visibleItems / 2 + (visibleItems < count ? 1 : 0);
+ const int halfVisibleItems = visibleItems / 2 + (visibleItems < count ? 1 : 0);
if (displacement > halfVisibleItems)
displacement -= count;
else if (displacement < -halfVisibleItems)
displacement += count;
} else {
- const qreal contentY = tumbler->contentItem()->property("contentY").toReal();
+ const qreal contentY = tumblerPrivate->view->property("contentY").toReal();
const qreal delegateH = delegateHeight(tumbler);
- const qreal preferredHighlightBegin = tumbler->contentItem()->property("preferredHighlightBegin").toReal();
+ const qreal preferredHighlightBegin = tumblerPrivate->view->property("preferredHighlightBegin").toReal();
// Tumbler's displacement goes from negative at the top to positive towards the bottom, so we must switch this around.
const qreal reverseDisplacement = (contentY + preferredHighlightBegin) / delegateH;
displacement = reverseDisplacement - index;
@@ -527,19 +794,34 @@ void QQuickTumblerAttachedPrivate::emitIfDisplacementChanged(qreal oldDisplaceme
emit q->displacementChanged();
}
-QQuickTumblerAttached::QQuickTumblerAttached(QQuickItem *delegateItem) :
- QObject(*(new QQuickTumblerAttachedPrivate(delegateItem)), delegateItem)
+QQuickTumblerAttached::QQuickTumblerAttached(QObject *parent) :
+ QObject(*(new QQuickTumblerAttachedPrivate), parent)
{
Q_D(QQuickTumblerAttached);
+ QQuickItem *delegateItem = qobject_cast<QQuickItem *>(parent);
+ if (delegateItem)
+ d->init(delegateItem);
+ else if (parent)
+ qmlInfo(parent) << "Tumbler: attached properties of Tumbler must be accessed through a delegate item";
+
if (d->tumbler) {
- QQuickItem *rootContentItem = d->tumbler->contentItem();
- const ContentItemType contentType = contentItemType(rootContentItem);
- QQuickItemPrivate *p = QQuickItemPrivate::get(actualContentItem(rootContentItem, contentType));
+ // When the Tumbler is completed, wrapChanged() is emitted to let QQuickTumblerView
+ // know that it can create the view. The view itself might instantiate delegates
+ // that use attached properties. At this point, setupViewData() hasn't been called yet
+ // (it's called on the next line in componentComplete()), so we call it here so that
+ // we have access to the view.
+ QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler);
+ tumblerPrivate->setupViewData(tumblerPrivate->contentItem);
+
+ if (!tumblerPrivate->viewContentItem)
+ return;
+
+ QQuickItemPrivate *p = QQuickItemPrivate::get(tumblerPrivate->viewContentItem);
p->addItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children);
- const char *contentItemSignal = contentType == PathViewContentItem
+ const char *contentItemSignal = tumblerPrivate->viewContentItemType == QQuickTumblerPrivate::PathViewContentItem
? SIGNAL(offsetChanged()) : SIGNAL(contentYChanged());
- connect(d->tumbler->contentItem(), contentItemSignal, this, SLOT(_q_calculateDisplacement()));
+ connect(tumblerPrivate->view, contentItemSignal, this, SLOT(_q_calculateDisplacement()));
d->_q_calculateDisplacement();
}
@@ -548,17 +830,15 @@ QQuickTumblerAttached::QQuickTumblerAttached(QQuickItem *delegateItem) :
QQuickTumblerAttached::~QQuickTumblerAttached()
{
Q_D(QQuickTumblerAttached);
- if (!d->tumbler || !d->tumbler->contentItem())
+ if (!d->tumbler)
return;
- QQuickItem *rootContentItem = d->tumbler->contentItem();
- const ContentItemType contentType = contentItemType(rootContentItem);
- QQuickItem *actualItem = actualContentItem(rootContentItem, contentType);
- if (!actualItem)
+ QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(d->tumbler);
+ if (!tumblerPrivate->viewContentItem)
return;
- QQuickItemPrivate *p = QQuickItemPrivate::get(actualItem);
- p->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children);
+ QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(tumblerPrivate->viewContentItem);
+ viewContentItemPrivate->removeItemChangeListener(d, QQuickItemPrivate::Geometry | QQuickItemPrivate::Children);
}
/*!
diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h
index e28102e4..1c8cfa18 100644
--- a/src/quicktemplates2/qquicktumbler_p.h
+++ b/src/quicktemplates2/qquicktumbler_p.h
@@ -66,6 +66,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumbler : public QQuickControl
Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
Q_PROPERTY(int visibleItemCount READ visibleItemCount WRITE setVisibleItemCount NOTIFY visibleItemCountChanged FINAL)
+ Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION 1)
public:
explicit QQuickTumbler(QQuickItem *parent = nullptr);
@@ -86,6 +87,10 @@ public:
int visibleItemCount() const;
void setVisibleItemCount(int visibleItemCount);
+ bool wrap() const;
+ void setWrap(bool wrap);
+ void resetWrap();
+
static QQuickTumblerAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
@@ -95,12 +100,14 @@ Q_SIGNALS:
void currentItemChanged();
void delegateChanged();
void visibleItemCountChanged();
+ Q_REVISION(1) void wrapChanged();
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
void componentComplete() override;
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
void keyPressEvent(QKeyEvent *event) override;
+ void updatePolish() override;
private:
Q_DISABLE_COPY(QQuickTumbler)
@@ -108,6 +115,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_updateItemWidths())
Q_PRIVATE_SLOT(d_func(), void _q_updateItemHeights())
+ Q_PRIVATE_SLOT(d_func(), void _q_onViewCurrentIndexChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_onViewCountChanged())
};
class QQuickTumblerAttachedPrivate;
@@ -119,7 +128,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerAttached : public QObject
Q_PROPERTY(qreal displacement READ displacement NOTIFY displacementChanged FINAL)
public:
- explicit QQuickTumblerAttached(QQuickItem *delegateItem);
+ explicit QQuickTumblerAttached(QObject *parent = nullptr);
~QQuickTumblerAttached();
QQuickTumbler *tumbler() const;
diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h
new file mode 100644
index 00000000..daced3a3
--- /dev/null
+++ b/src/quicktemplates2/qquicktumbler_p_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKTUMBLER_P_P_H
+#define QQUICKTUMBLER_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qquickitemchangelistener_p.h>
+#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickTumbler;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerPrivate : public QQuickControlPrivate, public QQuickItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickTumbler)
+
+public:
+ QQuickTumblerPrivate();
+ ~QQuickTumblerPrivate();
+
+ enum ContentItemType {
+ UnsupportedContentItemType,
+ PathViewContentItem,
+ ListViewContentItem
+ };
+
+ QQuickItem *determineViewType(QQuickItem *contentItem);
+ void resetViewData();
+ QList<QQuickItem *> viewContentItemChildItems() const;
+
+ static QQuickTumblerPrivate *get(QQuickTumbler *tumbler);
+
+ QVariant model;
+ QQmlComponent *delegate;
+ int visibleItemCount;
+ bool wrap;
+ bool explicitWrap;
+ bool ignoreWrapChanges;
+ QQuickItem *view;
+ QQuickItem *viewContentItem;
+ ContentItemType viewContentItemType;
+ int currentIndex;
+ int pendingCurrentIndex;
+ bool ignoreCurrentIndexChanges;
+ int count;
+
+ void _q_updateItemHeights();
+ void _q_updateItemWidths();
+ void _q_onViewCurrentIndexChanged();
+ void _q_onViewCountChanged();
+
+ void disconnectFromView();
+ void setupViewData(QQuickItem *newControlContentItem);
+ void syncCurrentIndex();
+
+ void setCount(int newCount);
+ void setWrapBasedOnCount();
+ void setWrap(bool shouldWrap, bool isExplicit);
+ void lockWrap();
+ void unlockWrap();
+
+ void itemChildAdded(QQuickItem *, QQuickItem *) override;
+ void itemChildRemoved(QQuickItem *, QQuickItem *) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKTUMBLER_P_P_H
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 5caa1bd7..4a128501 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -6,6 +6,7 @@ HEADERS += \
$$PWD/qquickapplicationwindow_p.h \
$$PWD/qquickbusyindicator_p.h \
$$PWD/qquickbutton_p.h \
+ $$PWD/qquickbutton_p_p.h \
$$PWD/qquickbuttongroup_p.h \
$$PWD/qquickcheckbox_p.h \
$$PWD/qquickcheckdelegate_p.h \
@@ -15,6 +16,10 @@ HEADERS += \
$$PWD/qquickcontrol_p.h \
$$PWD/qquickcontrol_p_p.h \
$$PWD/qquickdial_p.h \
+ $$PWD/qquickdialog_p.h \
+ $$PWD/qquickdialog_p_p.h \
+ $$PWD/qquickdialogbuttonbox_p.h \
+ $$PWD/qquickdialogbuttonbox_p_p.h \
$$PWD/qquickdrawer_p.h \
$$PWD/qquickdrawer_p_p.h \
$$PWD/qquickframe_p.h \
@@ -27,10 +32,12 @@ HEADERS += \
$$PWD/qquickmenu_p.h \
$$PWD/qquickmenu_p_p.h \
$$PWD/qquickmenuitem_p.h \
+ $$PWD/qquickmenuseparator_p.h \
$$PWD/qquickoverlay_p.h \
$$PWD/qquickoverlay_p_p.h \
$$PWD/qquickpage_p.h \
$$PWD/qquickpageindicator_p.h \
+ $$PWD/qquickpagelayout_p_p.h \
$$PWD/qquickpane_p.h \
$$PWD/qquickpane_p_p.h \
$$PWD/qquickpopup_p.h \
@@ -40,6 +47,7 @@ HEADERS += \
$$PWD/qquickradiobutton_p.h \
$$PWD/qquickradiodelegate_p.h \
$$PWD/qquickrangeslider_p.h \
+ $$PWD/qquickroundbutton_p.h \
$$PWD/qquickscrollbar_p.h \
$$PWD/qquickscrollindicator_p.h \
$$PWD/qquickshortcutcontext_p_p.h \
@@ -61,8 +69,10 @@ HEADERS += \
$$PWD/qquicktextfield_p_p.h \
$$PWD/qquicktoolbar_p.h \
$$PWD/qquicktoolbutton_p.h \
+ $$PWD/qquicktoolseparator_p.h \
$$PWD/qquicktooltip_p.h \
$$PWD/qquicktumbler_p.h \
+ $$PWD/qquicktumbler_p_p.h \
$$PWD/qquickvelocitycalculator_p_p.h
SOURCES += \
@@ -77,6 +87,8 @@ SOURCES += \
$$PWD/qquickcontainer.cpp \
$$PWD/qquickcontrol.cpp \
$$PWD/qquickdial.cpp \
+ $$PWD/qquickdialog.cpp \
+ $$PWD/qquickdialogbuttonbox.cpp \
$$PWD/qquickdrawer.cpp \
$$PWD/qquickframe.cpp \
$$PWD/qquickgroupbox.cpp \
@@ -84,9 +96,11 @@ SOURCES += \
$$PWD/qquicklabel.cpp \
$$PWD/qquickmenu.cpp \
$$PWD/qquickmenuitem.cpp \
+ $$PWD/qquickmenuseparator.cpp \
$$PWD/qquickoverlay.cpp \
$$PWD/qquickpage.cpp \
$$PWD/qquickpageindicator.cpp \
+ $$PWD/qquickpagelayout.cpp \
$$PWD/qquickpane.cpp \
$$PWD/qquickpopup.cpp \
$$PWD/qquickpresshandler.cpp \
@@ -94,6 +108,7 @@ SOURCES += \
$$PWD/qquickradiobutton.cpp \
$$PWD/qquickradiodelegate.cpp \
$$PWD/qquickrangeslider.cpp \
+ $$PWD/qquickroundbutton.cpp \
$$PWD/qquickscrollbar.cpp \
$$PWD/qquickscrollindicator.cpp \
$$PWD/qquickshortcutcontext.cpp \
@@ -111,6 +126,7 @@ SOURCES += \
$$PWD/qquicktextfield.cpp \
$$PWD/qquicktoolbar.cpp \
$$PWD/qquicktoolbutton.cpp \
+ $$PWD/qquicktoolseparator.cpp \
$$PWD/qquicktooltip.cpp \
$$PWD/qquicktumbler.cpp \
$$PWD/qquickvelocitycalculator.cpp
diff --git a/tests/auto/accessibility/accessibility.pro b/tests/auto/accessibility/accessibility.pro
index bef6eae4..e6b38828 100644
--- a/tests/auto/accessibility/accessibility.pro
+++ b/tests/auto/accessibility/accessibility.pro
@@ -11,5 +11,5 @@ include (../shared/util.pri)
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/accessibility/data/busyindicator.qml b/tests/auto/accessibility/data/busyindicator.qml
index b15ea80a..5a1cf54a 100644
--- a/tests/auto/accessibility/data/busyindicator.qml
+++ b/tests/auto/accessibility/data/busyindicator.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
BusyIndicator { }
diff --git a/tests/auto/accessibility/data/button.qml b/tests/auto/accessibility/data/button.qml
index 0fd14210..ecaba6cc 100644
--- a/tests/auto/accessibility/data/button.qml
+++ b/tests/auto/accessibility/data/button.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Button {
text: "Button"
diff --git a/tests/auto/accessibility/data/checkbox.qml b/tests/auto/accessibility/data/checkbox.qml
index e70d7d83..cb46c074 100644
--- a/tests/auto/accessibility/data/checkbox.qml
+++ b/tests/auto/accessibility/data/checkbox.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckBox {
text: "CheckBox"
diff --git a/tests/auto/accessibility/data/checkdelegate.qml b/tests/auto/accessibility/data/checkdelegate.qml
index 0a1a4a4f..f911caf0 100644
--- a/tests/auto/accessibility/data/checkdelegate.qml
+++ b/tests/auto/accessibility/data/checkdelegate.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
CheckDelegate {
text: "CheckDelegate"
diff --git a/tests/auto/accessibility/data/combobox.qml b/tests/auto/accessibility/data/combobox.qml
index 42e4d47b..52931968 100644
--- a/tests/auto/accessibility/data/combobox.qml
+++ b/tests/auto/accessibility/data/combobox.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ComboBox {
model: ["ComboBox"]
diff --git a/tests/auto/accessibility/data/control.qml b/tests/auto/accessibility/data/control.qml
index 4831a6c6..a8fd0613 100644
--- a/tests/auto/accessibility/data/control.qml
+++ b/tests/auto/accessibility/data/control.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Control { }
diff --git a/tests/auto/accessibility/data/dial.qml b/tests/auto/accessibility/data/dial.qml
index 39b85550..354ccdbd 100644
--- a/tests/auto/accessibility/data/dial.qml
+++ b/tests/auto/accessibility/data/dial.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Dial { }
diff --git a/tests/auto/accessibility/data/dialog.qml b/tests/auto/accessibility/data/dialog.qml
new file mode 100644
index 00000000..26e944fd
--- /dev/null
+++ b/tests/auto/accessibility/data/dialog.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.5
+import QtQuick.Controls 2.1
+
+Dialog {
+ title: "Dialog"
+}
diff --git a/tests/auto/accessibility/data/frame.qml b/tests/auto/accessibility/data/frame.qml
index 6fcbab23..6a2ec40e 100644
--- a/tests/auto/accessibility/data/frame.qml
+++ b/tests/auto/accessibility/data/frame.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Frame { }
diff --git a/tests/auto/accessibility/data/groupbox.qml b/tests/auto/accessibility/data/groupbox.qml
index c48b4847..ebb3cf7d 100644
--- a/tests/auto/accessibility/data/groupbox.qml
+++ b/tests/auto/accessibility/data/groupbox.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
GroupBox {
title: "GroupBox"
diff --git a/tests/auto/accessibility/data/itemdelegate.qml b/tests/auto/accessibility/data/itemdelegate.qml
index 9b647315..91e1d910 100644
--- a/tests/auto/accessibility/data/itemdelegate.qml
+++ b/tests/auto/accessibility/data/itemdelegate.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ItemDelegate {
text: "ItemDelegate"
diff --git a/tests/auto/accessibility/data/label.qml b/tests/auto/accessibility/data/label.qml
index bb87a4e9..e799f8de 100644
--- a/tests/auto/accessibility/data/label.qml
+++ b/tests/auto/accessibility/data/label.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Label {
text: "Label"
diff --git a/tests/auto/accessibility/data/menu.qml b/tests/auto/accessibility/data/menu.qml
index def3020b..b931644a 100644
--- a/tests/auto/accessibility/data/menu.qml
+++ b/tests/auto/accessibility/data/menu.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Menu { }
diff --git a/tests/auto/accessibility/data/menuitem.qml b/tests/auto/accessibility/data/menuitem.qml
index 70c2ff33..308c1c2b 100644
--- a/tests/auto/accessibility/data/menuitem.qml
+++ b/tests/auto/accessibility/data/menuitem.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
MenuItem {
text: "MenuItem"
diff --git a/tests/auto/accessibility/data/page.qml b/tests/auto/accessibility/data/page.qml
index 59139855..cda7b80b 100644
--- a/tests/auto/accessibility/data/page.qml
+++ b/tests/auto/accessibility/data/page.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Page {
title: "Page"
diff --git a/tests/auto/accessibility/data/pageindicator.qml b/tests/auto/accessibility/data/pageindicator.qml
index bb69a27a..a882296e 100644
--- a/tests/auto/accessibility/data/pageindicator.qml
+++ b/tests/auto/accessibility/data/pageindicator.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
PageIndicator { }
diff --git a/tests/auto/accessibility/data/pane.qml b/tests/auto/accessibility/data/pane.qml
index 1de210ec..24856e26 100644
--- a/tests/auto/accessibility/data/pane.qml
+++ b/tests/auto/accessibility/data/pane.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Pane { }
diff --git a/tests/auto/accessibility/data/popup.qml b/tests/auto/accessibility/data/popup.qml
index 05e968e5..e1d9f8ff 100644
--- a/tests/auto/accessibility/data/popup.qml
+++ b/tests/auto/accessibility/data/popup.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Popup { }
diff --git a/tests/auto/accessibility/data/progressbar.qml b/tests/auto/accessibility/data/progressbar.qml
index 5e9b11f1..c8733d5d 100644
--- a/tests/auto/accessibility/data/progressbar.qml
+++ b/tests/auto/accessibility/data/progressbar.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ProgressBar {
from: 0
diff --git a/tests/auto/accessibility/data/radiobutton.qml b/tests/auto/accessibility/data/radiobutton.qml
index 58bdf225..1ca431f5 100644
--- a/tests/auto/accessibility/data/radiobutton.qml
+++ b/tests/auto/accessibility/data/radiobutton.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
RadioButton {
text: "RadioButton"
diff --git a/tests/auto/accessibility/data/rangeslider.qml b/tests/auto/accessibility/data/rangeslider.qml
index 45b1d4ae..76736fb8 100644
--- a/tests/auto/accessibility/data/rangeslider.qml
+++ b/tests/auto/accessibility/data/rangeslider.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
RangeSlider {
from: 0
diff --git a/tests/auto/accessibility/data/roundbutton.qml b/tests/auto/accessibility/data/roundbutton.qml
new file mode 100644
index 00000000..8edf58de
--- /dev/null
+++ b/tests/auto/accessibility/data/roundbutton.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.5
+import QtQuick.Controls 2.1
+
+RoundButton {
+ text: "RoundButton"
+}
diff --git a/tests/auto/accessibility/data/scrollbar.qml b/tests/auto/accessibility/data/scrollbar.qml
index f0598b4b..1420ed19 100644
--- a/tests/auto/accessibility/data/scrollbar.qml
+++ b/tests/auto/accessibility/data/scrollbar.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollBar { }
diff --git a/tests/auto/accessibility/data/scrollindicator.qml b/tests/auto/accessibility/data/scrollindicator.qml
index 4cb81c4e..34e429ad 100644
--- a/tests/auto/accessibility/data/scrollindicator.qml
+++ b/tests/auto/accessibility/data/scrollindicator.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ScrollIndicator { }
diff --git a/tests/auto/accessibility/data/slider.qml b/tests/auto/accessibility/data/slider.qml
index 775ce7d0..088bd23a 100644
--- a/tests/auto/accessibility/data/slider.qml
+++ b/tests/auto/accessibility/data/slider.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Slider {
from: 0
diff --git a/tests/auto/accessibility/data/spinbox.qml b/tests/auto/accessibility/data/spinbox.qml
index 029cbc65..07e2a54e 100644
--- a/tests/auto/accessibility/data/spinbox.qml
+++ b/tests/auto/accessibility/data/spinbox.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SpinBox {
from: 0
diff --git a/tests/auto/accessibility/data/switch.qml b/tests/auto/accessibility/data/switch.qml
index 8bb43893..0678f113 100644
--- a/tests/auto/accessibility/data/switch.qml
+++ b/tests/auto/accessibility/data/switch.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Switch {
text: "Switch"
diff --git a/tests/auto/accessibility/data/switchdelegate.qml b/tests/auto/accessibility/data/switchdelegate.qml
index 9f2324c0..fba0c321 100644
--- a/tests/auto/accessibility/data/switchdelegate.qml
+++ b/tests/auto/accessibility/data/switchdelegate.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
SwitchDelegate {
text: "SwitchDelegate"
diff --git a/tests/auto/accessibility/data/tabbar.qml b/tests/auto/accessibility/data/tabbar.qml
index 4b1f73a1..209a094f 100644
--- a/tests/auto/accessibility/data/tabbar.qml
+++ b/tests/auto/accessibility/data/tabbar.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TabBar { }
diff --git a/tests/auto/accessibility/data/tabbutton.qml b/tests/auto/accessibility/data/tabbutton.qml
index 6b979bc8..c76e9048 100644
--- a/tests/auto/accessibility/data/tabbutton.qml
+++ b/tests/auto/accessibility/data/tabbutton.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TabButton {
text: "TabButton"
diff --git a/tests/auto/accessibility/data/textarea.qml b/tests/auto/accessibility/data/textarea.qml
index 93b5b220..1ffe366f 100644
--- a/tests/auto/accessibility/data/textarea.qml
+++ b/tests/auto/accessibility/data/textarea.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextArea {
text: "TextArea"
diff --git a/tests/auto/accessibility/data/textfield.qml b/tests/auto/accessibility/data/textfield.qml
index 06ba1a58..f87957eb 100644
--- a/tests/auto/accessibility/data/textfield.qml
+++ b/tests/auto/accessibility/data/textfield.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TextField {
text: "TextField"
diff --git a/tests/auto/accessibility/data/toolbar.qml b/tests/auto/accessibility/data/toolbar.qml
index 7b3ba07f..e1887de4 100644
--- a/tests/auto/accessibility/data/toolbar.qml
+++ b/tests/auto/accessibility/data/toolbar.qml
@@ -1,4 +1,4 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ToolBar { }
diff --git a/tests/auto/accessibility/data/toolbutton.qml b/tests/auto/accessibility/data/toolbutton.qml
index 79f155ec..e088bb56 100644
--- a/tests/auto/accessibility/data/toolbutton.qml
+++ b/tests/auto/accessibility/data/toolbutton.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ToolButton {
text: "ToolButton"
diff --git a/tests/auto/accessibility/data/tooltip.qml b/tests/auto/accessibility/data/tooltip.qml
index 1d1bae28..dcb5b3b9 100644
--- a/tests/auto/accessibility/data/tooltip.qml
+++ b/tests/auto/accessibility/data/tooltip.qml
@@ -1,5 +1,5 @@
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ToolTip {
text: "ToolTip"
diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp
index 99f6391e..b4286aad 100644
--- a/tests/auto/accessibility/tst_accessibility.cpp
+++ b/tests/auto/accessibility/tst_accessibility.cpp
@@ -73,6 +73,7 @@ void tst_accessibility::a11y_data()
QTest::newRow("Container") << "container" << 0x00000000 << ""; //QAccessible::NoRole
QTest::newRow("Control") << "control" << 0x00000000 << ""; //QAccessible::NoRole
QTest::newRow("Dial") << "dial" << 0x00000031 << ""; //QAccessible::Dial
+ QTest::newRow("Dialog") << "dialog" << 0x00000012 << "Dialog"; //QAccessible::Dialog
QTest::newRow("Drawer") << "drawer" << 0x00000012 << ""; //QAccessible::Dialog
QTest::newRow("Frame") << "frame" << 0x00000013 << ""; //QAccessible::Border
QTest::newRow("GroupBox") << "groupbox" << 0x00000014 << "GroupBox"; //QAccessible::Grouping
@@ -88,6 +89,7 @@ void tst_accessibility::a11y_data()
QTest::newRow("RadioButton") << "radiobutton" << 0x0000002D << "RadioButton"; //QAccessible::RadioButton
QTest::newRow("RadioDelegate") << "radiodelegate" << 0x0000002D << "RadioDelegate"; //QAccessible::RadioButton
QTest::newRow("RangeSlider") << "rangeslider" << 0x00000033 << ""; //QAccessible::Slider
+ QTest::newRow("RoundButton") << "roundbutton" << 0x0000002B << "RoundButton"; //QAccessible::Button
QTest::newRow("ScrollBar") << "scrollbar" << 0x00000003 << ""; //QAccessible::ScrollBar
QTest::newRow("ScrollIndicator") << "scrollindicator" << 0x00000027 << ""; //QAccessible::Indicator
QTest::newRow("Slider") << "slider" << 0x00000033 << ""; //QAccessible::Slider
diff --git a/tests/auto/applicationwindow/applicationwindow.pro b/tests/auto/applicationwindow/applicationwindow.pro
index 8eb1c933..3371a78e 100644
--- a/tests/auto/applicationwindow/applicationwindow.pro
+++ b/tests/auto/applicationwindow/applicationwindow.pro
@@ -11,5 +11,5 @@ include (../shared/util.pri)
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/applicationwindow/data/activeFocusControl.qml b/tests/auto/applicationwindow/data/activeFocusControl.qml
index b407a91b..8a206aaf 100644
--- a/tests/auto/applicationwindow/data/activeFocusControl.qml
+++ b/tests/auto/applicationwindow/data/activeFocusControl.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/applicationwindow/data/activefocusontab.qml b/tests/auto/applicationwindow/data/activefocusontab.qml
index 6cbd132f..dc4d2ddb 100644
--- a/tests/auto/applicationwindow/data/activefocusontab.qml
+++ b/tests/auto/applicationwindow/data/activefocusontab.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
title: "Test Application Window"
diff --git a/tests/auto/applicationwindow/data/attachedProperties.qml b/tests/auto/applicationwindow/data/attachedProperties.qml
index 0e518a0b..dd14c30c 100644
--- a/tests/auto/applicationwindow/data/attachedProperties.qml
+++ b/tests/auto/applicationwindow/data/attachedProperties.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
property alias childControl: childControl
diff --git a/tests/auto/applicationwindow/data/basicapplicationwindow.qml b/tests/auto/applicationwindow/data/basicapplicationwindow.qml
index afac65f3..f53035d9 100644
--- a/tests/auto/applicationwindow/data/basicapplicationwindow.qml
+++ b/tests/auto/applicationwindow/data/basicapplicationwindow.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
title: "Test Application Window"
diff --git a/tests/auto/applicationwindow/data/defaultFocus.qml b/tests/auto/applicationwindow/data/defaultFocus.qml
index ed2a9303..9839e15c 100644
--- a/tests/auto/applicationwindow/data/defaultFocus.qml
+++ b/tests/auto/applicationwindow/data/defaultFocus.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
visible: true
diff --git a/tests/auto/applicationwindow/data/fill.qml b/tests/auto/applicationwindow/data/fill.qml
index 02d413b7..ef228e66 100644
--- a/tests/auto/applicationwindow/data/fill.qml
+++ b/tests/auto/applicationwindow/data/fill.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
index 629e0cf9..b500c29b 100644
--- a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
+++ b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 200
diff --git a/tests/auto/applicationwindow/data/font.qml b/tests/auto/applicationwindow/data/font.qml
index 0bc744b1..d6055de4 100644
--- a/tests/auto/applicationwindow/data/font.qml
+++ b/tests/auto/applicationwindow/data/font.qml
@@ -39,8 +39,8 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
ApplicationWindow {
objectName: "appWin"
diff --git a/tests/auto/applicationwindow/data/locale.qml b/tests/auto/applicationwindow/data/locale.qml
index d6d46a0d..cb6cb555 100644
--- a/tests/auto/applicationwindow/data/locale.qml
+++ b/tests/auto/applicationwindow/data/locale.qml
@@ -39,8 +39,8 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
ApplicationWindow {
objectName: "appWin"
diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp
index 2f91f664..fb7f96b8 100644
--- a/tests/auto/applicationwindow/tst_applicationwindow.cpp
+++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp
@@ -523,7 +523,7 @@ void tst_applicationwindow::defaultFont()
QQmlEngine engine;
QQmlComponent component(&engine);
- component.setData("import QtQuick.Controls 2.0; ApplicationWindow { }", QUrl());
+ component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl());
QScopedPointer<QQuickApplicationWindow> window;
window.reset(static_cast<QQuickApplicationWindow *>(component.create()));
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 91850968..4dabf06f 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -6,6 +6,7 @@ SUBDIRS += \
controls \
drawer \
menu \
+ platform \
popup \
pressandhold \
qquickmaterialstyle \
@@ -14,6 +15,7 @@ SUBDIRS += \
qquickstyleselector \
qquickuniversalstyle \
qquickuniversalstyleconf \
+ revisions \
sanity \
snippets
diff --git a/tests/auto/calendar/calendar.pro b/tests/auto/calendar/calendar.pro
index e7cd6665..9fdf20ad 100644
--- a/tests/auto/calendar/calendar.pro
+++ b/tests/auto/calendar/calendar.pro
@@ -6,7 +6,7 @@ SOURCES += \
$$PWD/tst_calendar.cpp
OTHER_FILES += \
- $$PWD/data/*
+ $$PWD/data/*.qml
TESTDATA += \
$$PWD/data/tst_*
diff --git a/tests/auto/controls/data/TumblerDatePicker.qml b/tests/auto/controls/data/TumblerDatePicker.qml
index 18d7fb97..e5340493 100644
--- a/tests/auto/controls/data/TumblerDatePicker.qml
+++ b/tests/auto/controls/data/TumblerDatePicker.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Row {
id: datePicker
diff --git a/examples/quickcontrols2/gallery/pages/DrawerPage.qml b/tests/auto/controls/data/TumblerListView.qml
index f4a7d272..cccf8adf 100644
--- a/examples/quickcontrols2/gallery/pages/DrawerPage.qml
+++ b/tests/auto/controls/data/TumblerListView.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -39,35 +39,15 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
-Pane {
- id: pane
+ListView {
+ anchors.fill: parent
+ model: parent.model
+ delegate: parent.delegate
- Column {
- spacing: 40
- width: parent.width
-
- Label {
- width: parent.width
- wrapMode: Label.Wrap
- horizontalAlignment: Qt.AlignHCenter
- text: "Drawer provides a swipe-based side panel, similar to those often used "
- + "in touch interfaces to provide a central location for navigation."
- }
-
- Button {
- text: "Open"
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3))
-
- onClicked: drawer.open()
- }
- }
-
- Image {
- source: "qrc:/images/arrow.png"
- anchors.left: parent.left
- anchors.bottom: parent.bottom
- }
+ snapMode: ListView.SnapToItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin: height / 2 - (height / parent.visibleItemCount / 2)
+ preferredHighlightEnd: height / 2 + (height / parent.visibleItemCount / 2)
+ clip: true
}
diff --git a/examples/quickcontrols2/gallery/pages/MenuPage.qml b/tests/auto/controls/data/TumblerPathView.qml
index 1e975bd0..e325faf6 100644
--- a/examples/quickcontrols2/gallery/pages/MenuPage.qml
+++ b/tests/auto/controls/data/TumblerPathView.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -39,29 +39,25 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
-ScrollablePage {
- id: page
+PathView {
+ id: pathView
+ model: parent.model
+ delegate: parent.delegate
+ clip: true
+ pathItemCount: parent.visibleItemCount + 1
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ dragMargin: width / 2
- Column {
- spacing: 40
- width: parent.width
-
- Label {
- width: parent.width
- wrapMode: Label.Wrap
- horizontalAlignment: Qt.AlignHCenter
- text: "Menu can be used either as a context menu, or as a popup menu."
- }
-
- Button {
- id: button
- text: "Open"
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3))
-
- onClicked: optionsMenu.open()
+ path: Path {
+ startX: pathView.width / 2
+ startY: -pathView.delegateHeight / 2
+ PathLine {
+ x: pathView.width / 2
+ y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
}
}
+
+ property real delegateHeight: parent.availableHeight / parent.visibleItemCount
}
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index ba5ee94c..83ca7980 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -60,6 +60,11 @@ TestCase {
Item { }
}
+ Component {
+ id: signalSpy
+ SignalSpy { }
+ }
+
function test_text() {
var control = button.createObject(testCase);
verify(control);
@@ -103,4 +108,21 @@ TestCase {
control.destroy()
}
+
+ function test_pressAndHold() {
+ var control = button.createObject(testCase, {checkable: true})
+ verify(control)
+
+ var pressAndHoldSpy = signalSpy.createObject(control, {target: control, signalName: "pressAndHold"})
+ verify(pressAndHoldSpy.valid)
+
+ mousePress(control)
+ pressAndHoldSpy.wait()
+ compare(control.checked, false)
+
+ mouseRelease(control)
+ compare(control.checked, false)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_busyindicator.qml b/tests/auto/controls/data/tst_busyindicator.qml
index 142ec70a..c456a2e8 100644
--- a/tests/auto/controls/data/tst_busyindicator.qml
+++ b/tests/auto/controls/data/tst_busyindicator.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index 9038f1d6..dcce20d7 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_buttongroup.qml b/tests/auto/controls/data/tst_buttongroup.qml
index 754e4f0b..186eb9d1 100644
--- a/tests/auto/controls/data/tst_buttongroup.qml
+++ b/tests/auto/controls/data/tst_buttongroup.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -196,6 +196,32 @@ TestCase {
group.destroy()
}
+ function test_clicked() {
+ var group = buttonGroup.createObject(testCase)
+ verify(group)
+
+ var clickedSpy = signalSpy.createObject(testCase, {target: group, signalName: "clicked"})
+ verify(clickedSpy.valid)
+
+ var button1 = button.createObject(testCase)
+ var button2 = button.createObject(testCase)
+
+ group.addButton(button1)
+ group.addButton(button2)
+
+ button1.clicked()
+ compare(clickedSpy.count, 1)
+ compare(clickedSpy.signalArguments[0][0], button1)
+
+ button2.clicked()
+ compare(clickedSpy.count, 2)
+ compare(clickedSpy.signalArguments[1][0], button2)
+
+ group.destroy()
+ button1.destroy()
+ button2.destroy()
+ }
+
Component {
id: checkBoxes
Item {
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml
index 044b0006..b88e6deb 100644
--- a/tests/auto/controls/data/tst_checkbox.qml
+++ b/tests/auto/controls/data/tst_checkbox.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_checkdelegate.qml b/tests/auto/controls/data/tst_checkdelegate.qml
index a471b1d6..2fa8b4be 100644
--- a/tests/auto/controls/data/tst_checkdelegate.qml
+++ b/tests/auto/controls/data/tst_checkdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 607de2e8..2ba9be8f 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -41,7 +41,7 @@
import QtQuick 2.2
import QtQuick.Window 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -76,6 +76,7 @@ TestCase {
compare(control.count, 0)
compare(control.model, undefined)
+ compare(control.flat, false)
compare(control.pressed, false)
compare(control.currentIndex, -1)
compare(control.highlightedIndex, -1)
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
index d1ff54e0..3c7032c7 100644
--- a/tests/auto/controls/data/tst_container.qml
+++ b/tests/auto/controls/data/tst_container.qml
@@ -40,8 +40,8 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index 3018498e..1b60eb73 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -40,8 +40,8 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
TestCase {
id: testCase
@@ -859,7 +859,9 @@ TestCase {
verify(control)
compare(control.hovered, false)
- compare(control.hoverEnabled, false)
+ compare(control.hoverEnabled, Qt.styleHints.useHoverEffects)
+
+ control.hoverEnabled = false
mouseMove(control, control.width / 2, control.height / 2)
compare(control.hovered, false)
@@ -891,6 +893,42 @@ TestCase {
control.destroy()
}
+ function test_hoverEnabled() {
+ var control = component.createObject(testCase)
+ compare(control.hoverEnabled, Qt.styleHints.useHoverEffects)
+
+ var child = component.createObject(control)
+ var grandChild = component.createObject(child)
+
+ var childExplicitHoverEnabled = component.createObject(control, {hoverEnabled: true})
+ var grandChildExplicitHoverDisabled = component.createObject(childExplicitHoverEnabled, {hoverEnabled: false})
+
+ var childExplicitHoverDisabled = component.createObject(control, {hoverEnabled: false})
+ var grandChildExplicitHoverEnabled = component.createObject(childExplicitHoverDisabled, {hoverEnabled: true})
+
+ control.hoverEnabled = false
+ compare(control.hoverEnabled, false)
+ compare(grandChild.hoverEnabled, false)
+
+ compare(childExplicitHoverEnabled.hoverEnabled, true)
+ compare(grandChildExplicitHoverDisabled.hoverEnabled, false)
+
+ compare(childExplicitHoverDisabled.hoverEnabled, false)
+ compare(grandChildExplicitHoverEnabled.hoverEnabled, true)
+
+ control.hoverEnabled = true
+ compare(control.hoverEnabled, true)
+ compare(grandChild.hoverEnabled, true)
+
+ compare(childExplicitHoverEnabled.hoverEnabled, true)
+ compare(grandChildExplicitHoverDisabled.hoverEnabled, false)
+
+ compare(childExplicitHoverDisabled.hoverEnabled, false)
+ compare(grandChildExplicitHoverEnabled.hoverEnabled, true)
+
+ control.destroy()
+ }
+
function test_implicitSize() {
var control = component.createObject(testCase)
verify(control)
diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml
index a2ebf192..d0129755 100644
--- a/tests/auto/controls/data/tst_dial.qml
+++ b/tests/auto/controls/data/tst_dial.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -356,4 +356,51 @@ TestCase {
fuzzyCompare(dial.value, data.values[2], fuzz);
fuzzyCompare(dial.position, data.positions[2], fuzz);
}
+
+ function test_wheel_data() {
+ return [
+ { tag: "horizontal", orientation: Qt.Horizontal, dx: 120, dy: 0 },
+ { tag: "vertical", orientation: Qt.Vertical, dx: 0, dy: 120 }
+ ]
+ }
+
+ function test_wheel(data) {
+ var control = dialComponent.createObject(testCase, {wheelEnabled: true, orientation: data.orientation})
+ verify(control)
+
+ compare(control.value, 0.0)
+
+ mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy)
+ compare(control.value, 0.1)
+ compare(control.position, 0.1)
+
+ control.stepSize = 0.2
+
+ mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy)
+ compare(control.value, 0.3)
+ compare(control.position, 0.3)
+
+ control.stepSize = 10.0
+
+ mouseWheel(control, control.width / 2, control.height / 2, -data.dx, -data.dy)
+ compare(control.value, 0.0)
+ compare(control.position, 0.0)
+
+ control.to = 10.0
+ control.stepSize = 5.0
+
+ mouseWheel(control, control.width / 2, control.height / 2, data.dx, data.dy)
+ compare(control.value, 5.0)
+ compare(control.position, 0.5)
+
+ mouseWheel(control, control.width / 2, control.height / 2, 0.5 * data.dx, 0.5 * data.dy)
+ compare(control.value, 7.5)
+ compare(control.position, 0.75)
+
+ mouseWheel(control, control.width / 2, control.height / 2, -data.dx, -data.dy)
+ compare(control.value, 2.5)
+ compare(control.position, 0.25)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_dialog.qml b/tests/auto/controls/data/tst_dialog.qml
new file mode 100644
index 00000000..4cfda8ee
--- /dev/null
+++ b/tests/auto/controls/data/tst_dialog.qml
@@ -0,0 +1,346 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtTest 1.0
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
+
+TestCase {
+ id: testCase
+ width: 400
+ height: 400
+ visible: true
+ when: windowShown
+ name: "Dialog"
+
+ Component {
+ id: dialog
+ Dialog { }
+ }
+
+ Component {
+ id: buttonBox
+ DialogButtonBox { }
+ }
+
+ Component {
+ id: signalSpy
+ SignalSpy { }
+ }
+
+ function test_defaults() {
+ var control = dialog.createObject(testCase)
+ verify(control)
+ verify(control.header)
+ verify(control.footer)
+ compare(control.standardButtons, 0)
+ control.destroy()
+ }
+
+ function test_accept() {
+ var control = dialog.createObject(testCase)
+
+ control.open()
+ waitForRendering(control.contentItem)
+ verify(control.visible)
+
+ var acceptedSpy = signalSpy.createObject(testCase, {target: control, signalName: "accepted"})
+ verify(acceptedSpy.valid)
+ control.accept()
+ compare(acceptedSpy.count, 1)
+
+ tryCompare(control, "visible", false)
+
+ control.destroy()
+ }
+
+ function test_reject() {
+ var control = dialog.createObject(testCase)
+
+ control.open()
+ waitForRendering(control.contentItem)
+ verify(control.visible)
+
+ var rejectedSpy = signalSpy.createObject(testCase, {target: control, signalName: "rejected"})
+ verify(rejectedSpy.valid)
+ control.reject()
+ compare(rejectedSpy.count, 1)
+
+ tryCompare(control, "visible", false)
+
+ // Check that rejected() is emitted when CloseOnEscape is triggered.
+ control.x = 10
+ control.y = 10
+ control.width = 100
+ control.height = 100
+ control.closePolicy = Popup.CloseOnEscape
+ control.open()
+ verify(control.visible)
+
+ keyPress(Qt.Key_Escape)
+ compare(rejectedSpy.count, 2)
+ tryCompare(control, "visible", false)
+
+ keyRelease(Qt.Key_Escape)
+ compare(rejectedSpy.count, 2)
+
+ // Check that rejected() is emitted when CloseOnPressOutside is triggered.
+ control.closePolicy = Popup.CloseOnPressOutside
+ control.open()
+ verify(control.visible)
+
+ mousePress(testCase, 1, 1)
+ compare(rejectedSpy.count, 3)
+ tryCompare(control, "visible", false)
+
+ mouseRelease(testCase, 1, 1)
+ compare(rejectedSpy.count, 3)
+
+ // Check that rejected() is emitted when CloseOnReleaseOutside is triggered.
+ // For this, we need to make the dialog modal, because the overlay won't accept
+ // the press event because it doesn't want to block the press.
+ control.modal = true
+ control.closePolicy = Popup.CloseOnReleaseOutside
+ control.open()
+ verify(control.visible)
+
+ mousePress(testCase, 1, 1)
+ compare(rejectedSpy.count, 3)
+ verify(control.visible)
+
+ mouseRelease(testCase, 1, 1)
+ compare(rejectedSpy.count, 4)
+ tryCompare(control, "visible", false)
+
+ control.destroy()
+ }
+
+ function test_buttonBox_data() {
+ return [
+ { tag: "default" },
+ { tag: "custom", custom: true }
+ ]
+ }
+
+ function test_buttonBox(data) {
+ var control = dialog.createObject(testCase)
+
+ if (data.custom)
+ control.footer = buttonBox.createObject(testCase)
+ control.standardButtons = Dialog.Ok | Dialog.Cancel
+ var box = control.footer
+ verify(box)
+ compare(box.standardButtons, Dialog.Ok | Dialog.Cancel)
+
+ var acceptedSpy = signalSpy.createObject(testCase, {target: control, signalName: "accepted"})
+ verify(acceptedSpy.valid)
+ box.accepted()
+ compare(acceptedSpy.count, 1)
+
+ var rejectedSpy = signalSpy.createObject(testCase, {target: control, signalName: "rejected"})
+ verify(rejectedSpy.valid)
+ box.rejected()
+ compare(rejectedSpy.count, 1)
+
+ control.destroy()
+ }
+
+ function test_standardButtons() {
+ var control = dialog.createObject(testCase)
+
+ control.standardButtons = Dialog.Ok
+
+ var box = control.footer ? control.footer : control.header
+ verify(box)
+ compare(box.count, 1)
+ var okButton = box.itemAt(0)
+ verify(okButton)
+ compare(okButton.text.toUpperCase(), "OK")
+
+ control.standardButtons = Dialog.Cancel
+ compare(box.count, 1)
+ var cancelButton = control.footer.itemAt(0)
+ verify(cancelButton)
+ compare(cancelButton.text.toUpperCase(), "CANCEL")
+
+ control.standardButtons = Dialog.Ok | Dialog.Cancel
+ compare(box.count, 2)
+ if (box.itemAt(0).text.toUpperCase() === "OK") {
+ okButton = box.itemAt(0)
+ cancelButton = box.itemAt(1)
+ } else {
+ okButton = box.itemAt(1)
+ cancelButton = box.itemAt(0)
+ }
+ verify(okButton)
+ verify(cancelButton)
+ compare(okButton.text.toUpperCase(), "OK")
+ compare(cancelButton.text.toUpperCase(), "CANCEL")
+
+ control.standardButtons = 0
+ compare(box.count, 0)
+
+ control.destroy()
+ }
+
+ function test_layout() {
+ var control = dialog.createObject(testCase, {width: 100, height: 100})
+ verify(control)
+
+ control.open()
+ waitForRendering(control.contentItem)
+ verify(control.visible)
+
+ compare(control.width, 100)
+ compare(control.height, 100)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight)
+
+ control.header = buttonBox.createObject(control.contentItem)
+ compare(control.header.width, control.width)
+ verify(control.header.height > 0)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight - control.header.height)
+
+ control.footer = buttonBox.createObject(control.contentItem)
+ compare(control.footer.width, control.width)
+ verify(control.footer.height > 0)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight - control.header.height - control.footer.height)
+
+ control.topPadding = 9
+ control.leftPadding = 2
+ control.rightPadding = 6
+ control.bottomPadding = 7
+
+ compare(control.header.x, 0)
+ compare(control.header.y, 0)
+ compare(control.header.width, control.width)
+ verify(control.header.height > 0)
+
+ compare(control.footer.x, 0)
+ compare(control.footer.y, control.height - control.footer.height)
+ compare(control.footer.width, control.width)
+ verify(control.footer.height > 0)
+
+ compare(control.contentItem.x, control.leftPadding)
+ compare(control.contentItem.y, control.topPadding + control.header.height)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight - control.header.height - control.footer.height)
+
+ control.header.visible = false
+ compare(control.contentItem.x, control.leftPadding)
+ compare(control.contentItem.y, control.topPadding)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight - control.footer.height)
+
+ control.footer.visible = false
+ compare(control.contentItem.x, control.leftPadding)
+ compare(control.contentItem.y, control.topPadding)
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight)
+
+ control.contentItem.implicitWidth = 50
+ control.contentItem.implicitHeight = 60
+ compare(control.implicitWidth, control.contentItem.implicitWidth + control.leftPadding + control.rightPadding)
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding)
+
+ control.header.visible = true
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding
+ + control.header.implicitHeight)
+
+ control.footer.visible = true
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding
+ + control.header.implicitHeight + control.footer.implicitHeight)
+
+ control.header.implicitWidth = 150
+ compare(control.implicitWidth, control.header.implicitWidth)
+
+ control.footer.implicitWidth = 160
+ compare(control.implicitWidth, control.footer.implicitWidth)
+
+ control.destroy()
+ }
+
+ function test_spacing_data() {
+ return [
+ { tag: "content", header: false, content: true, footer: false },
+ { tag: "header,content", header: true, content: true, footer: false },
+ { tag: "content,footer", header: false, content: true, footer: true },
+ { tag: "header,content,footer", header: true, content: true, footer: true },
+ { tag: "header,footer", header: true, content: false, footer: true },
+ { tag: "header", header: true, content: false, footer: false },
+ { tag: "footer", header: false, content: false, footer: true },
+ ]
+ }
+
+ function test_spacing(data) {
+ var control = dialog.createObject(testCase, {spacing: 20, width: 100, height: 100})
+ verify(control)
+
+ control.open()
+ waitForRendering(control.contentItem)
+ verify(control.visible)
+
+ control.contentItem.visible = data.content
+ control.header = buttonBox.createObject(control.contentItem, {visible: data.header})
+ control.footer = buttonBox.createObject(control.contentItem, {visible: data.footer})
+
+ compare(control.header.x, 0)
+ compare(control.header.y, 0)
+ compare(control.header.width, control.width)
+ verify(control.header.height > 0)
+
+ compare(control.footer.x, 0)
+ compare(control.footer.y, control.height - control.footer.height)
+ compare(control.footer.width, control.width)
+ verify(control.footer.height > 0)
+
+ compare(control.contentItem.x, control.leftPadding)
+ compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0))
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight
+ - (data.header ? control.header.height + control.spacing : 0)
+ - (data.footer ? control.footer.height + control.spacing : 0))
+
+ control.destroy()
+ }
+}
diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml
new file mode 100644
index 00000000..8474e89b
--- /dev/null
+++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import QtQuick.Controls 2.1
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "DialogButtonBox"
+
+ Component {
+ id: buttonBox
+ DialogButtonBox { }
+ }
+
+ Component {
+ id: button
+ Button { }
+ }
+
+ Component {
+ id: signalSpy
+ SignalSpy { }
+ }
+
+ function test_defaults() {
+ var control = buttonBox.createObject(testCase)
+ verify(control)
+ compare(control.count, 0)
+ verify(control.delegate)
+ compare(control.standardButtons, 0)
+ control.destroy()
+ }
+
+ function test_standardButtons() {
+ var control = buttonBox.createObject(testCase)
+
+ compare(control.count, 0)
+
+ control.standardButtons = DialogButtonBox.Ok
+ compare(control.count, 1)
+ var okButton = control.itemAt(0)
+ verify(okButton)
+ compare(okButton.text.toUpperCase(), "OK")
+
+ control.standardButtons = DialogButtonBox.Cancel
+ compare(control.count, 1)
+ var cancelButton = control.itemAt(0)
+ verify(cancelButton)
+ compare(cancelButton.text.toUpperCase(), "CANCEL")
+
+ control.standardButtons = DialogButtonBox.Ok | DialogButtonBox.Cancel
+ compare(control.count, 2)
+ if (control.itemAt(0).text.toUpperCase() === "OK") {
+ okButton = control.itemAt(0)
+ cancelButton = control.itemAt(1)
+ } else {
+ okButton = control.itemAt(1)
+ cancelButton = control.itemAt(0)
+ }
+ verify(okButton)
+ verify(cancelButton)
+ compare(okButton.text.toUpperCase(), "OK")
+ compare(cancelButton.text.toUpperCase(), "CANCEL")
+
+ control.standardButtons = 0
+ compare(control.count, 0)
+
+ control.destroy()
+ }
+
+ function test_attached() {
+ var control = buttonBox.createObject(testCase)
+
+ control.standardButtons = DialogButtonBox.Ok
+ var okButton = control.itemAt(0)
+ compare(okButton.DialogButtonBox.buttonBox, control)
+ compare(okButton.DialogButtonBox.buttonRole, DialogButtonBox.AcceptRole)
+
+ var saveButton = button.createObject(control, {text: "Save"})
+ compare(saveButton.DialogButtonBox.buttonBox, control)
+ compare(saveButton.DialogButtonBox.buttonRole, DialogButtonBox.InvalidRole)
+ saveButton.DialogButtonBox.buttonRole = DialogButtonBox.AcceptRole
+ compare(saveButton.DialogButtonBox.buttonRole, DialogButtonBox.AcceptRole)
+
+ var closeButton = button.createObject(null, {text: "Save"})
+ compare(closeButton.DialogButtonBox.buttonBox, null)
+ compare(closeButton.DialogButtonBox.buttonRole, DialogButtonBox.InvalidRole)
+ closeButton.DialogButtonBox.buttonRole = DialogButtonBox.DestructiveRole
+ compare(closeButton.DialogButtonBox.buttonRole, DialogButtonBox.DestructiveRole)
+ control.addItem(closeButton)
+ compare(closeButton.DialogButtonBox.buttonBox, control)
+
+ control.contentModel.clear()
+ compare(okButton.DialogButtonBox.buttonBox, null)
+ compare(saveButton.DialogButtonBox.buttonBox, null)
+ compare(closeButton.DialogButtonBox.buttonBox, null)
+
+ control.destroy()
+ }
+
+ function test_signals_data() {
+ return [
+ { tag: "Ok", standardButton: DialogButtonBox.Ok, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" },
+ { tag: "Open", standardButton: DialogButtonBox.Open, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" },
+ { tag: "Save", standardButton: DialogButtonBox.Save, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" },
+ { tag: "Cancel", standardButton: DialogButtonBox.Cancel, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" },
+ { tag: "Close", standardButton: DialogButtonBox.Close, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" },
+ { tag: "Discard", standardButton: DialogButtonBox.Discard, buttonRole: DialogButtonBox.DestructiveRole },
+ { tag: "Apply", standardButton: DialogButtonBox.Apply, buttonRole: DialogButtonBox.ApplyRole },
+ { tag: "Reset", standardButton: DialogButtonBox.Reset, buttonRole: DialogButtonBox.ResetRole },
+ { tag: "RestoreDefaults", standardButton: DialogButtonBox.RestoreDefaults, buttonRole: DialogButtonBox.ResetRole },
+ { tag: "Help", standardButton: DialogButtonBox.Help, buttonRole: DialogButtonBox.HelpRole, signalName: "helpRequested" },
+ { tag: "SaveAll", standardButton: DialogButtonBox.SaveAll, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" },
+ { tag: "Yes", standardButton: DialogButtonBox.Yes, buttonRole: DialogButtonBox.YesRole, signalName: "accepted" },
+ { tag: "YesToAll", standardButton: DialogButtonBox.YesToAll, buttonRole: DialogButtonBox.YesRole, signalName: "accepted" },
+ { tag: "No", standardButton: DialogButtonBox.No, buttonRole: DialogButtonBox.NoRole, signalName: "rejected" },
+ { tag: "NoToAll", standardButton: DialogButtonBox.NoToAll, buttonRole: DialogButtonBox.NoRole, signalName: "rejected" },
+ { tag: "Abort", standardButton: DialogButtonBox.Abort, buttonRole: DialogButtonBox.RejectRole, signalName: "rejected" },
+ { tag: "Retry", standardButton: DialogButtonBox.Retry, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" },
+ { tag: "Ignore", standardButton: DialogButtonBox.Ignore, buttonRole: DialogButtonBox.AcceptRole, signalName: "accepted" }
+ ]
+ }
+
+ function test_signals(data) {
+ var control = buttonBox.createObject(testCase)
+
+ control.standardButtons = data.standardButton
+ compare(control.count, 1)
+ var button = control.itemAt(0)
+ verify(button)
+ compare(button.DialogButtonBox.buttonRole, data.buttonRole)
+
+ var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
+ verify(clickedSpy.valid)
+ var roleSpy = signalSpy.createObject(control, {target: control, signalName: data.signalName})
+ compare(roleSpy.valid, !!data.signalName)
+
+ button.clicked()
+ compare(clickedSpy.count, 1)
+ compare(clickedSpy.signalArguments[0][0], button)
+ compare(roleSpy.count, !!data.signalName ? 1 : 0)
+
+ control.destroy()
+ }
+}
diff --git a/tests/auto/controls/data/tst_drawer.qml b/tests/auto/controls/data/tst_drawer.qml
index 021afdb2..2e1f32dc 100644
--- a/tests/auto/controls/data/tst_drawer.qml
+++ b/tests/auto/controls/data/tst_drawer.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_frame.qml b/tests/auto/controls/data/tst_frame.qml
index a96397de..c64b0048 100644
--- a/tests/auto/controls/data/tst_frame.qml
+++ b/tests/auto/controls/data/tst_frame.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml
index 0181ea6b..41f1c780 100644
--- a/tests/auto/controls/data/tst_groupbox.qml
+++ b/tests/auto/controls/data/tst_groupbox.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_itemdelegate.qml b/tests/auto/controls/data/tst_itemdelegate.qml
index 37b0db2a..8eafad57 100644
--- a/tests/auto/controls/data/tst_itemdelegate.qml
+++ b/tests/auto/controls/data/tst_itemdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml
index 6dae0992..b3350cf5 100644
--- a/tests/auto/controls/data/tst_label.qml
+++ b/tests/auto/controls/data/tst_label.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_menuitem.qml b/tests/auto/controls/data/tst_menuitem.qml
index be0c0652..b5e08866 100644
--- a/tests/auto/controls/data/tst_menuitem.qml
+++ b/tests/auto/controls/data/tst_menuitem.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_page.qml b/tests/auto/controls/data/tst_page.qml
index bc7afa50..9b52236e 100644
--- a/tests/auto/controls/data/tst_page.qml
+++ b/tests/auto/controls/data/tst_page.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -56,6 +56,40 @@ TestCase {
}
Component {
+ id: oneChildPage
+ Page {
+ Item {
+ implicitWidth: 100
+ implicitHeight: 30
+ }
+ }
+ }
+
+ Component {
+ id: twoChildrenPage
+ Page {
+ Item {
+ implicitWidth: 100
+ implicitHeight: 30
+ }
+ Item {
+ implicitWidth: 200
+ implicitHeight: 60
+ }
+ }
+ }
+
+ Component {
+ id: contentPage
+ Page {
+ contentItem: Item {
+ implicitWidth: 100
+ implicitHeight: 30
+ }
+ }
+ }
+
+ Component {
id: toolBar
ToolBar { }
}
@@ -71,6 +105,53 @@ TestCase {
control.destroy()
}
+ function test_empty() {
+ var control = page.createObject(testCase)
+ verify(control)
+
+ verify(control.contentItem)
+ compare(control.contentWidth, 0)
+ compare(control.contentHeight, 0)
+
+ control.destroy()
+ }
+
+ function test_oneChild() {
+ var control = oneChildPage.createObject(testCase)
+ verify(control)
+
+ compare(control.contentWidth, 100)
+ compare(control.contentHeight, 30)
+ compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding)
+ compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding)
+
+ control.destroy()
+ }
+
+ function test_twoChildren() {
+ var control = twoChildrenPage.createObject(testCase)
+ verify(control)
+
+ compare(control.contentWidth, 0)
+ compare(control.contentHeight, 0)
+ compare(control.implicitWidth, control.leftPadding + control.rightPadding)
+ compare(control.implicitHeight, control.topPadding + control.bottomPadding)
+
+ control.destroy()
+ }
+
+ function test_contentItem() {
+ var control = contentPage.createObject(testCase)
+ verify(control)
+
+ compare(control.contentWidth, 100)
+ compare(control.contentHeight, 30)
+ compare(control.implicitWidth, 100 + control.leftPadding + control.rightPadding)
+ compare(control.implicitHeight, 30 + control.topPadding + control.bottomPadding)
+
+ control.destroy()
+ }
+
function test_layout() {
var control = page.createObject(testCase, {width: 100, height: 100})
verify(control)
@@ -124,6 +205,65 @@ TestCase {
compare(control.contentItem.width, control.availableWidth)
compare(control.contentItem.height, control.availableHeight)
+ control.contentItem.implicitWidth = 50
+ control.contentItem.implicitHeight = 60
+ compare(control.implicitWidth, control.contentItem.implicitWidth + control.leftPadding + control.rightPadding)
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding)
+
+ control.header.visible = true
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding
+ + control.header.implicitHeight + control.spacing)
+
+ control.footer.visible = true
+ compare(control.implicitHeight, control.contentItem.implicitHeight + control.topPadding + control.bottomPadding
+ + control.header.implicitHeight + control.footer.implicitHeight + 2 * control.spacing)
+
+ control.header.implicitWidth = 150
+ compare(control.implicitWidth, control.header.implicitWidth + control.leftPadding + control.rightPadding)
+
+ control.footer.implicitWidth = 160
+ compare(control.implicitWidth, control.footer.implicitWidth + control.leftPadding + control.rightPadding)
+
+ control.destroy()
+ }
+
+ function test_spacing_data() {
+ return [
+ { tag: "content", header: false, content: true, footer: false },
+ { tag: "header,content", header: true, content: true, footer: false },
+ { tag: "content,footer", header: false, content: true, footer: true },
+ { tag: "header,content,footer", header: true, content: true, footer: true },
+ { tag: "header,footer", header: true, content: false, footer: true },
+ { tag: "header", header: true, content: false, footer: false },
+ { tag: "footer", header: false, content: false, footer: true },
+ ]
+ }
+
+ function test_spacing(data) {
+ var control = page.createObject(testCase, {spacing: 20, width: 100, height: 100})
+ verify(control)
+
+ control.contentItem.visible = data.content
+ control.header = toolBar.createObject(control.contentItem, {visible: data.header})
+ control.footer = toolBar.createObject(control.contentItem, {visible: data.footer})
+
+ compare(control.header.x, 0)
+ compare(control.header.y, 0)
+ compare(control.header.width, control.width)
+ verify(control.header.height > 0)
+
+ compare(control.footer.x, 0)
+ compare(control.footer.y, control.height - control.footer.height)
+ compare(control.footer.width, control.width)
+ verify(control.footer.height > 0)
+
+ compare(control.contentItem.x, control.leftPadding)
+ compare(control.contentItem.y, control.topPadding + (data.header ? control.header.height + control.spacing : 0))
+ compare(control.contentItem.width, control.availableWidth)
+ compare(control.contentItem.height, control.availableHeight
+ - (data.header ? control.header.height + control.spacing : 0)
+ - (data.footer ? control.footer.height + control.spacing : 0))
+
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml
index d1f1223a..a39265c3 100644
--- a/tests/auto/controls/data/tst_pageindicator.qml
+++ b/tests/auto/controls/data/tst_pageindicator.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_pane.qml b/tests/auto/controls/data/tst_pane.qml
index a0b8a5c8..2f5ddef3 100644
--- a/tests/auto/controls/data/tst_pane.qml
+++ b/tests/auto/controls/data/tst_pane.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index 0ca8ce57..982ac7ab 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -40,13 +40,13 @@
import QtQuick 2.4
import QtTest 1.0
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
TestCase {
id: testCase
- width: 480
- height: 360
+ width: 400
+ height: 400
visible: true
when: windowShown
name: "Popup"
diff --git a/tests/auto/controls/data/tst_progressbar.qml b/tests/auto/controls/data/tst_progressbar.qml
index 5603c280..d7280503 100644
--- a/tests/auto/controls/data/tst_progressbar.qml
+++ b/tests/auto/controls/data/tst_progressbar.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
index e86b862e..9b6a2ae5 100644
--- a/tests/auto/controls/data/tst_radiobutton.qml
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_radiodelegate.qml b/tests/auto/controls/data/tst_radiodelegate.qml
index 1a424a32..66b47b3a 100644
--- a/tests/auto/controls/data/tst_radiodelegate.qml
+++ b/tests/auto/controls/data/tst_radiodelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml
index 3167be0b..eb654bbc 100644
--- a/tests/auto/controls/data/tst_rangeslider.qml
+++ b/tests/auto/controls/data/tst_rangeslider.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -675,4 +675,31 @@ TestCase {
control.destroy()
}
+
+ function test_hover_data() {
+ return [
+ { tag: "first:true", node: "first", hoverEnabled: true },
+ { tag: "first:false", node: "first", hoverEnabled: false },
+ { tag: "second:true", node: "second", hoverEnabled: true },
+ { tag: "second:false", node: "second", hoverEnabled: false }
+ ]
+ }
+
+ function test_hover(data) {
+ var control = sliderComponent.createObject(testCase, {hoverEnabled: data.hoverEnabled})
+ verify(control)
+
+ var node = control[data.node]
+ compare(control.hovered, false)
+ compare(node.hovered, false)
+
+ mouseMove(control, node.handle.x + node.handle.width / 2, node.handle.y + node.handle.height / 2)
+ compare(control.hovered, data.hoverEnabled)
+ compare(node.hovered, data.hoverEnabled && node.handle.enabled)
+
+ mouseMove(control, node.handle.x - 1, node.handle.y - 1)
+ compare(node.hovered, false)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_roundbutton.qml b/tests/auto/controls/data/tst_roundbutton.qml
new file mode 100644
index 00000000..aa956776
--- /dev/null
+++ b/tests/auto/controls/data/tst_roundbutton.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import QtQuick.Controls 2.1
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "RoundButton"
+
+ Component {
+ id: roundButton
+ RoundButton { }
+ }
+
+ function test_radius() {
+ var control = roundButton.createObject(testCase);
+ verify(control);
+
+ var implicitRadius = control.radius;
+ compare(implicitRadius, Math.min(control.width, control.height) / 2);
+
+ control.radius = 10;
+ compare(control.radius, 10);
+
+ control.radius = undefined;
+ compare(control.radius, implicitRadius);
+
+ control.width = -1;
+ compare(control.radius, 0);
+
+ control.width = 10;
+ compare(control.radius, 5);
+
+ control.destroy();
+ }
+}
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml
index 7c83cca9..54ecf15f 100644
--- a/tests/auto/controls/data/tst_scrollbar.qml
+++ b/tests/auto/controls/data/tst_scrollbar.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -97,6 +97,13 @@ TestCase {
compare(vertical.y, 0)
verify(vertical.width > 0)
compare(vertical.height, container.height)
+ // vertical scroll bar follows flickable's width
+ container.width += 10
+ compare(vertical.x, container.width - vertical.width)
+ // ...unless explicitly positioned
+ vertical.x = 123
+ container.width += 10
+ compare(vertical.x, 123)
var horizontal = scrollBar.createObject()
verify(!horizontal.parent)
@@ -118,6 +125,13 @@ TestCase {
compare(horizontal.y, container.height - horizontal.height)
compare(horizontal.width, container.width)
verify(horizontal.height > 0)
+ // horizontal scroll bar follows flickable's height
+ container.height += 10
+ compare(horizontal.y, container.height - horizontal.height)
+ // ...unless explicitly positioned
+ horizontal.y = 123
+ container.height += 10
+ compare(horizontal.y, 123)
var velocity = container.maximumFlickVelocity
@@ -315,4 +329,28 @@ TestCase {
container.destroy()
}
+
+ function test_hover_data() {
+ return [
+ { tag: "enabled", hoverEnabled: true },
+ { tag: "disabled", hoverEnabled: false },
+ ]
+ }
+
+ function test_hover(data) {
+ var control = scrollBar.createObject(testCase, {hoverEnabled: data.hoverEnabled})
+ verify(control)
+
+ compare(control.hovered, false)
+
+ mouseMove(control)
+ compare(control.hovered, data.hoverEnabled)
+ compare(control.active, data.hoverEnabled)
+
+ mouseMove(control, -1, -1)
+ compare(control.hovered, false)
+ compare(control.active, false)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml
index f5e57e2d..1ec03b15 100644
--- a/tests/auto/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/controls/data/tst_scrollindicator.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -92,6 +92,13 @@ TestCase {
compare(vertical.y, 0)
verify(vertical.width > 0)
compare(vertical.height, container.height)
+ // vertical scroll indicator follows flickable's width
+ container.width += 10
+ compare(vertical.x, container.width - vertical.width)
+ // ...unless explicitly positioned
+ vertical.x = 123
+ container.width += 10
+ compare(vertical.x, 123)
var horizontal = scrollIndicator.createObject()
verify(!horizontal.parent)
@@ -113,6 +120,13 @@ TestCase {
compare(horizontal.y, container.height - horizontal.height)
compare(horizontal.width, container.width)
verify(horizontal.height > 0)
+ // horizontal scroll indicator follows flickable's height
+ container.height += 10
+ compare(horizontal.y, container.height - horizontal.height)
+ // ...unless explicitly positioned
+ horizontal.y = 123
+ container.height += 10
+ compare(horizontal.y, 123)
var velocity = container.maximumFlickVelocity
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 4a698076..029aff14 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -520,4 +520,24 @@ TestCase {
control.destroy()
}
+
+ function test_valueAt_data() {
+ return [
+ { tag: "0.0..1.0", from: 0.0, to: 1.0, values: [0.0, 0.2, 0.5, 1.0] },
+ { tag: "0..100", from: 0, to: 100, values: [0, 20, 50, 100] },
+ { tag: "100..-100", from: 100, to: -100, values: [100, 60, 0, -100] }
+ ]
+ }
+
+ function test_valueAt(data) {
+ var control = slider.createObject(testCase, {from: data.from, to: data.to})
+ verify(control)
+
+ compare(control.valueAt(0.0), data.values[0])
+ compare(control.valueAt(0.2), data.values[1])
+ compare(control.valueAt(0.5), data.values[2])
+ compare(control.valueAt(1.0), data.values[3])
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index f2d8d3ef..de44415d 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -460,6 +460,35 @@ TestCase {
control.destroy()
}
+ function test_hover_data() {
+ return [
+ { tag: "up:true", button: "up", hoverEnabled: true, value: 50 },
+ { tag: "up:false", button: "up", hoverEnabled: false, value: 50 },
+ { tag: "up:max", button: "up", hoverEnabled: true, value: 99 },
+ { tag: "down:true", button: "down", hoverEnabled: true, value: 50 },
+ { tag: "down:false", button: "down", hoverEnabled: false, value: 50 },
+ { tag: "down:min", button: "down", hoverEnabled: true, value: 0 }
+ ]
+ }
+
+ function test_hover(data) {
+ var control = spinBox.createObject(testCase, {hoverEnabled: data.hoverEnabled, value: data.value})
+ verify(control)
+
+ var button = control[data.button]
+ compare(control.hovered, false)
+ compare(button.hovered, false)
+
+ mouseMove(control, button.indicator.x + button.indicator.width / 2, button.indicator.y + button.indicator.height / 2)
+ compare(control.hovered, data.hoverEnabled)
+ compare(button.hovered, data.hoverEnabled && button.indicator.enabled)
+
+ mouseMove(control, button.indicator.x - 1, button.indicator.y - 1)
+ compare(button.hovered, false)
+
+ control.destroy()
+ }
+
function test_valueFromText_data() {
return [
{ tag: "editable", editable: true },
diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml
index 28a22306..b0e18389 100644
--- a/tests/auto/controls/data/tst_stackview.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -567,29 +567,60 @@ TestCase {
}
}
- function test_transitions() {
+ function test_transitions_data() {
+ return [
+ { tag: "undefined", operation: undefined,
+ pushEnterRuns: [0,1,1,1], pushExitRuns: [0,1,1,1], replaceEnterRuns: [0,0,1,1], replaceExitRuns: [0,0,1,1], popEnterRuns: [0,0,0,1], popExitRuns: [0,0,0,1] },
+ { tag: "immediate", operation: StackView.Immediate,
+ pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] },
+ { tag: "push", operation: StackView.PushTransition,
+ pushEnterRuns: [1,2,3,4], pushExitRuns: [0,1,2,3], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] },
+ { tag: "pop", operation: StackView.PopTransition,
+ pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [0,0,0,0], replaceExitRuns: [0,0,0,0], popEnterRuns: [1,2,3,4], popExitRuns: [0,1,2,3] },
+ { tag: "replace", operation: StackView.ReplaceTransition,
+ pushEnterRuns: [0,0,0,0], pushExitRuns: [0,0,0,0], replaceEnterRuns: [1,2,3,4], replaceExitRuns: [0,1,2,3], popEnterRuns: [0,0,0,0], popExitRuns: [0,0,0,0] },
+ ]
+ }
+
+ function test_transitions(data) {
var control = transitionView.createObject(testCase)
verify(control)
- control.push(component)
- verify(!control.busy)
- compare(control.pushEnterRuns, 0)
- compare(control.pushExitRuns, 0)
-
- control.push(component)
+ control.push(component, data.operation)
+ tryCompare(control, "busy", false)
+ compare(control.pushEnterRuns, data.pushEnterRuns[0])
+ compare(control.pushExitRuns, data.pushExitRuns[0])
+ compare(control.replaceEnterRuns, data.replaceEnterRuns[0])
+ compare(control.replaceExitRuns, data.replaceExitRuns[0])
+ compare(control.popEnterRuns, data.popEnterRuns[0])
+ compare(control.popExitRuns, data.popExitRuns[0])
+
+ control.push(component, data.operation)
tryCompare(control, "busy", false)
- compare(control.pushEnterRuns, 1)
- compare(control.pushExitRuns, 1)
+ compare(control.pushEnterRuns, data.pushEnterRuns[1])
+ compare(control.pushExitRuns, data.pushExitRuns[1])
+ compare(control.replaceEnterRuns, data.replaceEnterRuns[1])
+ compare(control.replaceExitRuns, data.replaceExitRuns[1])
+ compare(control.popEnterRuns, data.popEnterRuns[1])
+ compare(control.popExitRuns, data.popExitRuns[1])
- control.replace(component)
+ control.replace(component, data.operation)
tryCompare(control, "busy", false)
- compare(control.replaceEnterRuns, 1)
- compare(control.replaceExitRuns, 1)
+ compare(control.pushEnterRuns, data.pushEnterRuns[2])
+ compare(control.pushExitRuns, data.pushExitRuns[2])
+ compare(control.replaceEnterRuns, data.replaceEnterRuns[2])
+ compare(control.replaceExitRuns, data.replaceExitRuns[2])
+ compare(control.popEnterRuns, data.popEnterRuns[2])
+ compare(control.popExitRuns, data.popExitRuns[2])
- control.pop()
+ control.pop(data.operation)
tryCompare(control, "busy", false)
- compare(control.popEnterRuns, 1)
- compare(control.popExitRuns, 1)
+ compare(control.pushEnterRuns, data.pushEnterRuns[3])
+ compare(control.pushExitRuns, data.pushExitRuns[3])
+ compare(control.replaceEnterRuns, data.replaceEnterRuns[3])
+ compare(control.replaceExitRuns, data.replaceExitRuns[3])
+ compare(control.popEnterRuns, data.popEnterRuns[3])
+ compare(control.popExitRuns, data.popExitRuns[3])
control.destroy()
}
@@ -644,6 +675,60 @@ TestCase {
}
Component {
+ id: removeComponent
+
+ Item {
+ objectName: "removeItem"
+ StackView.onRemoved: destroy()
+ }
+ }
+
+ function test_destroyOnRemoved() {
+ var control = stackView.createObject(testCase, { initialItem: component })
+ verify(control)
+
+ var item = removeComponent.createObject(control)
+ verify(item)
+
+ var removedSpy = signalSpy.createObject(control, { target: item.StackView, signalName: "removed" })
+ verify(removedSpy)
+ verify(removedSpy.valid)
+
+ var destructionSpy = signalSpy.createObject(control, { target: item.Component, signalName: "destruction" })
+ verify(destructionSpy)
+ verify(destructionSpy.valid)
+
+ // push-pop
+ control.push(item, StackView.Immediate)
+ compare(control.currentItem, item)
+ control.pop(StackView.Transition)
+ item = null
+ tryCompare(removedSpy, "count", 1)
+ tryCompare(destructionSpy, "count", 1)
+ compare(control.busy, false)
+
+ item = removeComponent.createObject(control)
+ verify(item)
+
+ removedSpy.target = item.StackView
+ verify(removedSpy.valid)
+
+ destructionSpy.target = item.Component
+ verify(destructionSpy.valid)
+
+ // push-replace
+ control.push(item, StackView.Immediate)
+ compare(control.currentItem, item)
+ control.replace(component, StackView.Transition)
+ item = null
+ tryCompare(removedSpy, "count", 2)
+ tryCompare(destructionSpy, "count", 2)
+ compare(control.busy, false)
+
+ control.destroy()
+ }
+
+ Component {
id: attachedItem
Item {
property int index: StackView.index
@@ -831,11 +916,11 @@ TestCase {
verify(control)
ignoreWarning("QQmlComponent: Component is not ready")
- ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 File not found")
+ ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory")
control.push(Qt.resolvedUrl("non-existent.qml"))
ignoreWarning("QQmlComponent: Component is not ready")
- ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 File not found")
+ ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory")
control.replace(Qt.resolvedUrl("non-existent.qml"))
control.pop()
@@ -862,6 +947,62 @@ TestCase {
control.destroy()
}
+ Component {
+ id: signalTest
+ Control {
+ id: ctrl
+ property SignalSpy activatedSpy: SignalSpy { target: ctrl.StackView; signalName: "activated" }
+ property SignalSpy activatingSpy: SignalSpy { target: ctrl.StackView; signalName: "activating" }
+ property SignalSpy deactivatedSpy: SignalSpy { target: ctrl.StackView; signalName: "deactivated" }
+ property SignalSpy deactivatingSpy: SignalSpy { target: ctrl.StackView; signalName: "deactivating" }
+ }
+ }
+
+ function test_signals() {
+ var control = stackView.createObject(testCase)
+ verify(control)
+
+ var item1 = signalTest.createObject(control)
+ compare(item1.StackView.status, StackView.Inactive)
+ control.push(item1)
+ compare(item1.StackView.status, StackView.Active)
+ compare(item1.activatedSpy.count, 1)
+ compare(item1.activatingSpy.count, 1)
+ compare(item1.deactivatedSpy.count, 0)
+ compare(item1.deactivatingSpy.count, 0)
+
+ var item2 = signalTest.createObject(control)
+ compare(item2.StackView.status, StackView.Inactive)
+ control.push(item2)
+ compare(item2.StackView.status, StackView.Activating)
+ compare(item2.activatedSpy.count, 0)
+ compare(item2.activatingSpy.count, 1)
+ compare(item2.deactivatedSpy.count, 0)
+ compare(item2.deactivatingSpy.count, 0)
+ compare(item1.StackView.status, StackView.Deactivating)
+ compare(item1.activatedSpy.count, 1)
+ compare(item1.activatingSpy.count, 1)
+ compare(item1.deactivatedSpy.count, 0)
+ compare(item1.deactivatingSpy.count, 1)
+ tryCompare(item2.activatedSpy, "count", 1)
+ tryCompare(item1.deactivatedSpy, "count", 1)
+
+ control.pop()
+ compare(item2.StackView.status, StackView.Deactivating)
+ compare(item2.activatedSpy.count, 1)
+ compare(item2.activatingSpy.count, 1)
+ compare(item2.deactivatedSpy.count, 0)
+ compare(item2.deactivatingSpy.count, 1)
+ compare(item1.StackView.status, StackView.Activating)
+ compare(item1.activatedSpy.count, 1)
+ compare(item1.activatingSpy.count, 2)
+ compare(item1.deactivatedSpy.count, 1)
+ compare(item1.deactivatingSpy.count, 1)
+ tryCompare(item1.activatedSpy, "count", 2)
+
+ control.destroy()
+ }
+
// QTBUG-56158
function test_repeatedPop() {
var control = stackView.createObject(testCase, {initialItem: component, width: testCase.width, height: testCase.height})
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 6d017dc8..7a2ad44d 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -40,7 +40,8 @@
import QtQuick 2.6
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
+
TestCase {
id: testCase
@@ -110,14 +111,14 @@ TestCase {
function test_horizontalAnchors_data() {
return [
- { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":58:25" },
- { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":65:25" },
- { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":72:25" },
- { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":79:25" },
- { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":86:26" },
- { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":93:26" },
- { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":100:26" },
- { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":107:26" }
+ { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":59:25" },
+ { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":66:25" },
+ { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":73:25" },
+ { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":80:25" },
+ { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":87:26" },
+ { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":94:26" },
+ { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":101:26" },
+ { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":108:26" }
];
}
@@ -166,6 +167,12 @@ TestCase {
}
Component {
+ id: signalSpyComponent
+
+ SignalSpy {}
+ }
+
+ Component {
id: itemComponent
Item {}
@@ -201,7 +208,7 @@ TestCase {
verify(control);
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.behind = itemComponent;
// Shouldn't be any warnings when unsetting delegates.
@@ -210,7 +217,7 @@ TestCase {
// right is still set.
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.behind = itemComponent;
control.swipe.right = null;
@@ -219,11 +226,11 @@ TestCase {
control.swipe.behind = itemComponent;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.left = itemComponent;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: cannot set both behind and left/right properties")
+ ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties")
control.swipe.right = itemComponent;
control.swipe.behind = null;
@@ -238,7 +245,7 @@ TestCase {
var oldLeft = control.swipe.left;
var oldLeftItem = control.swipe.leftItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.left = null;
compare(control.swipe.left, oldLeft);
compare(control.swipe.leftItem, oldLeftItem);
@@ -249,7 +256,7 @@ TestCase {
var oldRight = control.swipe.right;
var oldRightItem = control.swipe.rightItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.right = null;
compare(control.swipe.right, oldRight);
compare(control.swipe.rightItem, oldRightItem);
@@ -275,7 +282,7 @@ TestCase {
var oldBehind = control.swipe.behind;
var oldBehindItem = control.swipe.behindItem;
ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") +
- ":159:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
+ ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0")
control.swipe.behind = null;
compare(control.swipe.behind, oldBehind);
compare(control.swipe.behindItem, oldBehindItem);
@@ -297,7 +304,7 @@ TestCase {
SignalSequenceSpy {
id: mouseSignalSequenceSpy
- signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged"]
+ signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "pressAndHold"]
}
function test_swipe() {
@@ -306,12 +313,17 @@ TestCase {
var overDragDistance = Math.round(dragDistance * 1.1);
+ var completedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "completed" });
+ verify(completedSpy);
+ verify(completedSpy.valid);
+
mouseSignalSequenceSpy.target = control;
mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"];
mousePress(control, control.width / 2, control.height / 2);
verify(control.pressed);
compare(control.swipe.position, 0.0);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 0);
verify(mouseSignalSequenceSpy.success);
verify(!control.swipe.leftItem);
verify(!control.swipe.rightItem);
@@ -321,6 +333,7 @@ TestCase {
verify(control.pressed);
compare(control.swipe.position, overDragDistance / control.width);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 0);
verify(control.swipe.leftItem);
verify(control.swipe.leftItem.visible);
compare(control.swipe.leftItem.parent, control);
@@ -332,6 +345,7 @@ TestCase {
verify(control.pressed);
compare(control.swipe.position, 0.0);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 0);
verify(control.swipe.leftItem);
verify(control.swipe.leftItem.visible);
compare(control.swipe.leftItem.parent, control);
@@ -344,6 +358,7 @@ TestCase {
verify(control.pressed);
compare(control.swipe.position, -overDragDistance / control.width);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 0);
verify(control.swipe.leftItem);
verify(!control.swipe.leftItem.visible);
verify(control.swipe.rightItem);
@@ -356,6 +371,7 @@ TestCase {
verify(control.pressed);
compare(control.swipe.position, 0.6);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 0);
verify(control.swipe.leftItem);
verify(control.swipe.leftItem.visible);
verify(control.swipe.rightItem);
@@ -366,6 +382,7 @@ TestCase {
verify(!control.pressed);
compare(control.swipe.position, 1.0);
verify(control.swipe.complete);
+ compare(completedSpy.count, 1);
verify(mouseSignalSequenceSpy.success);
verify(control.swipe.leftItem);
verify(control.swipe.leftItem.visible);
@@ -381,11 +398,13 @@ TestCase {
// complete should still be true, because we haven't moved yet, and hence
// haven't started grabbing behind's mouse events.
verify(control.swipe.complete);
+ compare(completedSpy.count, 1);
verify(mouseSignalSequenceSpy.success);
mouseMove(control, control.width / 2 - overDragDistance, control.height / 2);
verify(control.pressed);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 1);
compare(control.swipe.position, 1.0 - overDragDistance / control.width);
// Since we went over the drag distance, we should expect canceled() to be emitted.
@@ -394,6 +413,7 @@ TestCase {
verify(!control.pressed);
compare(control.swipe.position, 1.0);
verify(control.swipe.complete);
+ compare(completedSpy.count, 2);
verify(mouseSignalSequenceSpy.success);
tryCompare(control.contentItem, "x", control.width + control.leftPadding);
@@ -403,11 +423,13 @@ TestCase {
verify(control.pressed);
compare(control.swipe.position, 1.0);
verify(control.swipe.complete);
+ compare(completedSpy.count, 2);
verify(mouseSignalSequenceSpy.success);
mouseMove(control, control.width * -0.1, control.height / 2);
verify(control.pressed);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 2);
compare(control.swipe.position, 0.4);
mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"];
@@ -415,6 +437,7 @@ TestCase {
verify(!control.pressed);
compare(control.swipe.position, 0.0);
verify(!control.swipe.complete);
+ compare(completedSpy.count, 2);
verify(mouseSignalSequenceSpy.success);
tryCompare(control.contentItem, "x", control.leftPadding);
@@ -508,12 +531,6 @@ TestCase {
}
}
- Component {
- id: signalSpyComponent
-
- SignalSpy {}
- }
-
function test_eventsToLeftAndRight() {
var control = swipeDelegateWithButtonComponent.createObject(testCase);
verify(control);
@@ -608,6 +625,26 @@ TestCase {
mouseDoubleClickSequence(control, control.width / 2, control.height / 2, Qt.LeftButton);
verify(mouseSignalSequenceSpy.success);
+ // press and hold
+ var pressAndHoldSpy = signalSpyComponent.createObject(control, { target: control, signalName: "pressAndHold" });
+ verify(pressAndHoldSpy);
+ verify(pressAndHoldSpy.valid);
+
+ mouseSignalSequenceSpy.expectedSequence = [
+ ["pressedChanged", { "pressed": true }],
+ "pressed",
+ "pressAndHold",
+ ["pressedChanged", { "pressed": false }],
+ "released"
+ ];
+ mousePress(control);
+ compare(control.pressed, true);
+ tryCompare(pressAndHoldSpy, "count", 1);
+
+ mouseRelease(control);
+ compare(control.pressed, false);
+ verify(mouseSignalSequenceSpy.success);
+
control.destroy();
}
@@ -630,8 +667,6 @@ TestCase {
text: modelData
width: listView.width
- onClicked: if (swipe.complete) ListView.view.model.remove(index)
-
property alias removeAnimation: onRemoveAnimation
ListView.onRemove: SequentialAnimation {
@@ -656,9 +691,12 @@ TestCase {
}
swipe.left: Rectangle {
- color: rootDelegate.swipe.complete && rootDelegate.pressed ? "#333" : "#444"
+ objectName: "rectangle"
+ color: SwipeDelegate.pressed ? "#333" : "#444"
anchors.fill: parent
+ SwipeDelegate.onClicked: listView.model.remove(index)
+
Label {
objectName: "label"
text: "Remove"
@@ -681,11 +719,14 @@ TestCase {
verify(firstItem.pressed);
compare(firstItem.swipe.position, 0.0);
verify(!firstItem.swipe.complete);
+ verify(!firstItem.swipe.leftItem);
mouseMove(listView, firstItem.width * 1.1, firstItem.height / 2);
verify(firstItem.pressed);
compare(firstItem.swipe.position, 0.6);
verify(!firstItem.swipe.complete);
+ verify(firstItem.swipe.leftItem);
+ verify(!firstItem.swipe.leftItem.SwipeDelegate.pressed);
mouseRelease(listView, firstItem.width / 2, firstItem.height / 2);
verify(!firstItem.pressed);
@@ -696,9 +737,23 @@ TestCase {
// Wait for it to settle down.
tryCompare(firstItem.contentItem, "x", firstItem.leftPadding + firstItem.width);
- // Click the button to remove the item.
+ var leftClickedSpy = signalSpyComponent.createObject(firstItem.swipe.leftItem,
+ { target: firstItem.swipe.leftItem.SwipeDelegate, signalName: "clicked" });
+ verify(leftClickedSpy);
+ verify(leftClickedSpy.valid);
+
+ // Click the left item to remove the delegate from the list.
var contentItemX = firstItem.contentItem.x;
- mouseClick(listView, firstItem.width / 2, firstItem.height / 2);
+ mousePress(listView, firstItem.width / 2, firstItem.height / 2);
+ verify(firstItem.swipe.leftItem.SwipeDelegate.pressed);
+ compare(leftClickedSpy.count, 0);
+ verify(!firstItem.pressed);
+
+ mouseRelease(listView, firstItem.width / 2, firstItem.height / 2);
+ verify(!firstItem.swipe.leftItem.SwipeDelegate.pressed);
+ compare(leftClickedSpy.count, 1);
+ verify(!firstItem.pressed);
+ leftClickedSpy = null;
tryCompare(firstItem.removeAnimation, "running", true);
// There was a bug where the resizeContent() would be called because the height
// of the control was changing due to the animation. contentItem would then
@@ -993,6 +1048,170 @@ TestCase {
control.destroy();
}
+ Component {
+ id: closeSwipeDelegateComponent
+
+ SwipeDelegate {
+ text: "SwipeDelegate"
+ width: 150
+
+ swipe.right: Item {
+ width: parent.width
+ height: parent.height
+
+ SwipeDelegate.onClicked: swipe.close()
+ }
+ }
+ }
+
+ function test_close() {
+ var control = closeSwipeDelegateComponent.createObject(testCase);
+ verify(control);
+
+ swipe(control, 0.0, -1.0);
+ compare(control.swipe.rightItem.visible, true);
+ // Should animate, so it shouldn't change right away.
+ compare(control.swipe.rightItem.x, 0);
+ tryCompare(control.swipe.rightItem, "x", control.background.x + control.background.width);
+
+ mousePress(control);
+ verify(control.swipe.rightItem.SwipeDelegate.pressed);
+
+ mouseRelease(control);
+ verify(!control.swipe.rightItem.SwipeDelegate.pressed);
+ tryCompare(control.swipe, "position", 0);
+
+ // Swiping after closing should work as normal.
+ swipe(control, 0.0, -1.0);
+
+ control.destroy();
+ }
+
+ Component {
+ id: multiActionSwipeDelegateComponent
+
+ SwipeDelegate {
+ text: "SwipeDelegate"
+ width: 150
+
+ swipe.right: Item {
+ objectName: "rightItemRoot"
+ width: parent.width
+ height: parent.height
+
+ property alias firstAction: firstAction
+ property alias secondAction: secondAction
+
+ property int firstClickCount: 0
+ property int secondClickCount: 0
+
+ Row {
+ anchors.fill: parent
+ anchors.margins: 5
+
+ Rectangle {
+ id: firstAction
+ width: parent.width / 2
+ height: parent.height
+ color: "tomato"
+
+ SwipeDelegate.onClicked: ++firstClickCount
+ }
+ Rectangle {
+ id: secondAction
+ width: parent.width / 2
+ height: parent.height
+ color: "navajowhite"
+
+ SwipeDelegate.onClicked: ++secondClickCount
+ }
+ }
+ }
+ }
+ }
+
+ // Tests that it's possible to have multiple non-interactive items in one delegate
+ // (e.g. left/right/behind) that can each receive clicks.
+ function test_multipleClickableActions() {
+ var control = multiActionSwipeDelegateComponent.createObject(testCase);
+ verify(control);
+
+ swipe(control, 0.0, -1.0);
+ verify(control.swipe.rightItem);
+ tryCompare(control.swipe, "complete", true);
+
+ var firstClickedSpy = signalSpyComponent.createObject(control,
+ { target: control.swipe.rightItem.firstAction.SwipeDelegate, signalName: "clicked" });
+ verify(firstClickedSpy);
+ verify(firstClickedSpy.valid);
+
+ // Clicked within rightItem, but not within an item using the attached properties.
+ mousePress(control, 2, 2);
+ compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false);
+ compare(firstClickedSpy.count, 0);
+
+ mouseRelease(control, 2, 2);
+ compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false);
+ compare(firstClickedSpy.count, 0);
+
+ // Click within the first item.
+ mousePress(control.swipe.rightItem.firstAction, 0, 0);
+ compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, true);
+ compare(firstClickedSpy.count, 0);
+
+ mouseRelease(control.swipe.rightItem.firstAction, 0, 0);
+ compare(control.swipe.rightItem.firstAction.SwipeDelegate.pressed, false);
+ compare(firstClickedSpy.count, 1);
+ compare(control.swipe.rightItem.firstClickCount, 1);
+
+ var secondClickedSpy = signalSpyComponent.createObject(control,
+ { target: control.swipe.rightItem.secondAction.SwipeDelegate, signalName: "clicked" });
+ verify(secondClickedSpy);
+ verify(secondClickedSpy.valid);
+
+ // Click within the second item.
+ mousePress(control.swipe.rightItem.secondAction, 0, 0);
+ compare(control.swipe.rightItem.secondAction.SwipeDelegate.pressed, true);
+ compare(secondClickedSpy.count, 0);
+
+ mouseRelease(control.swipe.rightItem.secondAction, 0, 0);
+ compare(control.swipe.rightItem.secondAction.SwipeDelegate.pressed, false);
+ compare(secondClickedSpy.count, 1);
+ compare(control.swipe.rightItem.secondClickCount, 1);
+
+ control.destroy();
+ }
+
+ // Pressing on a "side action" and then dragging should eventually
+ // cause the ListView to grab the mouse and start changing its contentY.
+ // When this happens, it will grab the mouse and hence we must clear
+ // that action's pressed state so that it doesn't stay pressed after releasing.
+ function test_dragSideAction() {
+ var listView = removableDelegatesComponent.createObject(testCase);
+ verify(listView);
+
+ var control = listView.itemAt(0, 0);
+ verify(control);
+
+ // Expose the side action.
+ swipe(control, 0.0, 1.0);
+ verify(control.swipe.leftItem);
+ tryCompare(control.swipe, "complete", true);
+
+ var pressedSpy = signalSpyComponent.createObject(control,
+ { target: control.swipe.leftItem.SwipeDelegate, signalName: "pressedChanged" });
+ verify(pressedSpy);
+ verify(pressedSpy.valid);
+
+ mouseDrag(listView, 20, 20, 0, listView.height);
+ compare(pressedSpy.count, 2);
+ verify(listView.contentY !== 0);
+
+ compare(control.swipe.leftItem.SwipeDelegate.pressed, false);
+
+ listView.destroy();
+ }
+
// When the width of a SwipeDelegate changes (as it does upon portrait => landscape
// rotation, for example), the positions of the contentItem and background items
// should be updated accordingly.
@@ -1074,6 +1293,80 @@ TestCase {
verify(mouseSignalSequenceSpy.success);
}
+ Component {
+ id: leftRightWithLabelsComponent
+
+ SwipeDelegate {
+ id: delegate
+ text: "SwipeDelegate"
+ width: 150
+
+ background.opacity: 0.5
+
+ swipe.left: Rectangle {
+ width: parent.width
+ height: parent.height
+ color: SwipeDelegate.pressed ? Qt.darker("green") : "green"
+
+ property alias label: label
+
+ Label {
+ id: label
+ text: "Left"
+ color: "white"
+ anchors.margins: 10
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ SwipeDelegate.onClicked: delegate.swipe.close()
+ }
+
+ swipe.right: Rectangle {
+ width: parent.width
+ height: parent.height
+ anchors.right: parent.right
+ color: SwipeDelegate.pressed ? Qt.darker("green") : "red"
+
+ property alias label: label
+
+ Label {
+ id: label
+ text: "Right"
+ color: "white"
+ anchors.margins: 10
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ }
+
+ SwipeDelegate.onClicked: delegate.swipe.close()
+ }
+ }
+ }
+
+ function test_beginSwipeOverRightItem() {
+ var control = leftRightWithLabelsComponent.createObject(testCase);
+ verify(control);
+
+ // Swipe to the left, exposing the right item.
+ swipe(control, 0.0, -1.0);
+
+ // Click to close it and go back to a position of 0.
+ mouseClick(control);
+
+ // TODO: Swipe to the left, with the mouse over the Label in the right item.
+ // The left item should not become visible at any point.
+ var rightLabel = control.swipe.rightItem.label;
+ var overDragDistance = Math.round(dragDistance * 1.1);
+ mousePress(rightLabel, rightLabel.width / 2, rightLabel.height / 2, Qt.rightButton);
+ mouseMove(rightLabel, rightLabel.width / 2 - overDragDistance, rightLabel.height / 2, Qt.LeftButton);
+ verify(!control.swipe.leftItem);
+
+ mouseRelease(rightLabel, rightLabel.width / 2 - overDragDistance, control.height / 2, Qt.LeftButton);
+ verify(!control.swipe.leftItem);
+
+ control.destroy();
+ }
Component {
id: animationSwipeDelegateComponent
diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml
index 3afcdf16..2d5f413a 100644
--- a/tests/auto/controls/data/tst_swipeview.qml
+++ b/tests/auto/controls/data/tst_swipeview.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -103,6 +103,16 @@ TestCase {
compare(control.currentItem.text, "2")
compare(currentItemChangedSpy.count, 3);
+ control.decrementCurrentIndex()
+ compare(control.currentIndex, 1)
+ compare(control.currentItem.text, "1")
+ compare(currentItemChangedSpy.count, 4);
+
+ control.incrementCurrentIndex()
+ compare(control.currentIndex, 2)
+ compare(control.currentItem.text, "2")
+ compare(currentItemChangedSpy.count, 5);
+
control.destroy()
}
@@ -404,6 +414,8 @@ TestCase {
property int index: SwipeView.index
property SwipeView view: SwipeView.view
property bool isCurrentItem: SwipeView.isCurrentItem
+ property bool isNextItem: SwipeView.isNextItem
+ property bool isPreviousItem: SwipeView.isPreviousItem
}
}
@@ -424,11 +436,15 @@ TestCase {
compare(control.itemAt(i).text, titles[i])
compare(control.itemAt(i).SwipeView.index, i)
compare(control.itemAt(i).SwipeView.isCurrentItem, i === 0)
+ compare(control.itemAt(i).SwipeView.isNextItem, i === 1)
+ compare(control.itemAt(i).SwipeView.isPreviousItem, false)
}
control.currentIndex = data.currentBefore
for (i = 0; i < control.count; ++i) {
compare(control.itemAt(i).SwipeView.isCurrentItem, i === data.currentBefore)
+ compare(control.itemAt(i).SwipeView.isNextItem, i === data.currentBefore + 1)
+ compare(control.itemAt(i).SwipeView.isPreviousItem, i === data.currentBefore - 1)
}
control.moveItem(data.from, data.to)
@@ -445,6 +461,8 @@ TestCase {
compare(control.itemAt(i).text, titles[i])
compare(control.itemAt(i).SwipeView.index, i);
compare(control.itemAt(i).SwipeView.isCurrentItem, i === data.currentAfter)
+ compare(control.itemAt(i).SwipeView.isNextItem, i === data.currentAfter + 1)
+ compare(control.itemAt(i).SwipeView.isPreviousItem, i === data.currentAfter - 1)
}
control.destroy()
@@ -489,12 +507,16 @@ TestCase {
compare(page.view, null);
compare(page.index, -1);
compare(page.isCurrentItem, false);
+ compare(page.isNextItem, false);
+ compare(page.isPreviousItem, false);
page.destroy();
page = pageAttached.createObject(null);
compare(page.view, null);
compare(page.index, -1);
compare(page.isCurrentItem, false);
+ compare(page.isNextItem, false);
+ compare(page.isPreviousItem, false);
control.insertItem(0, page);
compare(control.count, 1);
@@ -502,6 +524,8 @@ TestCase {
compare(page.view, control);
compare(page.index, 0);
compare(page.isCurrentItem, true);
+ compare(page.isNextItem, false);
+ compare(page.isPreviousItem, false);
control.removeItem(0);
compare(control.count, 0);
@@ -509,6 +533,8 @@ TestCase {
compare(page.view, null);
compare(page.index, -1);
compare(page.isCurrentItem, false);
+ compare(page.isNextItem, false);
+ compare(page.isPreviousItem, false);
control.destroy();
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index 93773e0d..f3843cf7 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_switchdelegate.qml b/tests/auto/controls/data/tst_switchdelegate.qml
index 8bc0e4c3..4a5d711f 100644
--- a/tests/auto/controls/data/tst_switchdelegate.qml
+++ b/tests/auto/controls/data/tst_switchdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_tabbar.qml b/tests/auto/controls/data/tst_tabbar.qml
index 9268f765..da0181a1 100644
--- a/tests/auto/controls/data/tst_tabbar.qml
+++ b/tests/auto/controls/data/tst_tabbar.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -134,6 +134,16 @@ TestCase {
compare(control.currentItem.text, "2")
compare(control.currentItem.checked, true)
+ control.decrementCurrentIndex()
+ compare(control.currentIndex, 1)
+ compare(control.currentItem.text, "1")
+ compare(control.currentItem.checked, true)
+
+ control.incrementCurrentIndex()
+ compare(control.currentIndex, 2)
+ compare(control.currentItem.text, "2")
+ compare(control.currentItem.checked, true)
+
control.destroy()
}
diff --git a/tests/auto/controls/data/tst_tabbutton.qml b/tests/auto/controls/data/tst_tabbutton.qml
index 4ab9d955..77d22a48 100644
--- a/tests/auto/controls/data/tst_tabbutton.qml
+++ b/tests/auto/controls/data/tst_tabbutton.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml
index bda0b3e3..5d3e8d55 100644
--- a/tests/auto/controls/data/tst_textarea.qml
+++ b/tests/auto/controls/data/tst_textarea.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -199,6 +199,196 @@ TestCase {
testCase.TextArea.flickable = null
}
+ function test_hover_data() {
+ return [
+ { tag: "enabled", hoverEnabled: true },
+ { tag: "disabled", hoverEnabled: false },
+ ]
+ }
+
+ function test_hover(data) {
+ var control = textArea.createObject(testCase, {text: "TextArea", hoverEnabled: data.hoverEnabled})
+ verify(control)
+
+ compare(control.hovered, false)
+
+ mouseMove(control)
+ compare(control.hovered, data.hoverEnabled)
+
+ mouseMove(control, -1, -1)
+ compare(control.hovered, false)
+
+ control.destroy()
+ }
+
+ function test_pressedReleased_data() {
+ return [
+ {
+ tag: "pressed outside", x: -1, y: -1, button: Qt.LeftButton,
+ controlPressEvent: null,
+ controlReleaseEvent: null,
+ parentPressEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentReleaseEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ },
+ {
+ tag: "left click", x: 0, y: 0, button: Qt.LeftButton,
+ controlPressEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ controlReleaseEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentPressEvent: null,
+ parentReleaseEvent: null,
+ },
+ {
+ tag: "right click", x: 0, y: 0, button: Qt.RightButton,
+ controlPressEvent: {
+ x: 0, y: 0, button: Qt.RightButton, buttons: Qt.RightButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ controlReleaseEvent: {
+ x: 0, y: 0, button: Qt.RightButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentPressEvent: null,
+ parentReleaseEvent: null,
+ },
+ ];
+ }
+
+ Component {
+ id: mouseAreaComponent
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+
+ function checkMouseEvent(event, expectedEvent) {
+ compare(event.x, expectedEvent.x)
+ compare(event.y, expectedEvent.y)
+ compare(event.button, expectedEvent.button)
+ compare(event.buttons, expectedEvent.buttons)
+ }
+
+ function test_pressedReleased(data) {
+ var mouseArea = mouseAreaComponent.createObject(testCase)
+ verify(mouseArea)
+ var control = textArea.createObject(mouseArea, {text: "TextArea"})
+ verify(control)
+
+ // Give enough room to check presses outside of the control and on the parent.
+ control.x = 1;
+ control.y = 1;
+
+ function checkControlPressEvent(event) {
+ checkMouseEvent(event, data.controlPressEvent)
+ }
+ function checkControlReleaseEvent(event) {
+ checkMouseEvent(event, data.controlReleaseEvent)
+ }
+ function checkParentPressEvent(event) {
+ checkMouseEvent(event, data.parentPressEvent)
+ }
+ function checkParentReleaseEvent(event) {
+ checkMouseEvent(event, data.parentReleaseEvent)
+ }
+
+ // Can't use signalArguments, because the event won't live that long.
+ if (data.controlPressEvent)
+ control.onPressed.connect(checkControlPressEvent)
+ if (data.controlReleaseEvent)
+ control.onReleased.connect(checkControlReleaseEvent)
+ if (data.parentPressEvent)
+ control.onPressed.connect(checkParentPressEvent)
+ if (data.parentReleaseEvent)
+ control.onReleased.connect(checkParentReleaseEvent)
+
+ var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" })
+ verify(controlPressedSpy.valid)
+ var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" })
+ verify(controlReleasedSpy.valid)
+ var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" })
+ verify(parentPressedSpy.valid)
+ var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" })
+ verify(parentReleasedSpy.valid)
+
+ mousePress(control, data.x, data.y, data.button)
+ compare(controlPressedSpy.count, data.controlPressEvent ? 1 : 0)
+ compare(parentPressedSpy.count, data.parentPressEvent ? 1 : 0)
+ mouseRelease(control, data.x, data.y, data.button)
+ compare(controlReleasedSpy.count, data.controlReleaseEvent ? 1 : 0)
+ compare(parentReleasedSpy.count, data.parentReleaseEvent ? 1 : 0)
+
+ mouseArea.destroy()
+ }
+
+ Component {
+ id: ignoreTextArea
+
+ TextArea {
+ property bool ignorePress: false
+ property bool ignoreRelease: false
+
+ onPressed: if (ignorePress) event.accepted = false
+ onReleased: if (ignoreRelease) event.accepted = false
+ }
+ }
+
+ function checkEventAccepted(event) {
+ compare(event.accepted, true)
+ }
+
+ function checkEventIgnored(event) {
+ compare(event.accepted, false)
+ }
+
+ function test_ignorePressRelease() {
+ var mouseArea = mouseAreaComponent.createObject(testCase)
+ verify(mouseArea)
+ var control = ignoreTextArea.createObject(mouseArea)
+ verify(control)
+
+ var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" })
+ verify(controlPressedSpy.valid)
+ var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" })
+ verify(controlReleasedSpy.valid)
+ var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" })
+ verify(parentPressedSpy.valid)
+ var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" })
+ verify(parentReleasedSpy.valid)
+
+ // Ignore only press events.
+ control.onPressed.connect(checkEventIgnored)
+ control.ignorePress = true
+ mousePress(control, 0, 0, data.button)
+ // The control will still get the signal, it just won't accept the event.
+ compare(controlPressedSpy.count, 1)
+ compare(parentPressedSpy.count, 1)
+ mouseRelease(control, 0, 0, data.button)
+ compare(controlReleasedSpy.count, 0)
+ compare(parentReleasedSpy.count, 1)
+ control.onPressed.disconnect(checkEventIgnored)
+
+ // Ignore only release events.
+ control.onPressed.connect(checkEventAccepted)
+ control.onReleased.connect(checkEventIgnored)
+ control.ignorePress = false
+ control.ignoreRelease = true
+ mousePress(control, 0, 0, data.button)
+ compare(controlPressedSpy.count, 2)
+ compare(parentPressedSpy.count, 1)
+ mouseRelease(control, 0, 0, data.button)
+ compare(controlReleasedSpy.count, 1)
+ compare(parentReleasedSpy.count, 1)
+ control.onPressed.disconnect(checkEventAccepted)
+ control.onReleased.disconnect(checkEventIgnored)
+
+ mouseArea.destroy()
+ }
+
function test_multiClick() {
var control = textArea.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true})
verify(control)
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml
index 959662ee..5dc93287 100644
--- a/tests/auto/controls/data/tst_textfield.qml
+++ b/tests/auto/controls/data/tst_textfield.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -164,6 +164,196 @@ TestCase {
control.destroy()
}
+ function test_hover_data() {
+ return [
+ { tag: "enabled", hoverEnabled: true },
+ { tag: "disabled", hoverEnabled: false },
+ ]
+ }
+
+ function test_hover(data) {
+ var control = textField.createObject(testCase, {hoverEnabled: data.hoverEnabled})
+ verify(control)
+
+ compare(control.hovered, false)
+
+ mouseMove(control)
+ compare(control.hovered, data.hoverEnabled)
+
+ mouseMove(control, -1, -1)
+ compare(control.hovered, false)
+
+ control.destroy()
+ }
+
+ function test_pressedReleased_data() {
+ return [
+ {
+ tag: "pressed outside", x: -1, y: -1, button: Qt.LeftButton,
+ controlPressEvent: null,
+ controlReleaseEvent: null,
+ parentPressEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentReleaseEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ },
+ {
+ tag: "left click", x: 0, y: 0, button: Qt.LeftButton,
+ controlPressEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ controlReleaseEvent: {
+ x: 0, y: 0, button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentPressEvent: null,
+ parentReleaseEvent: null,
+ },
+ {
+ tag: "right click", x: 0, y: 0, button: Qt.RightButton,
+ controlPressEvent: {
+ x: 0, y: 0, button: Qt.RightButton, buttons: Qt.RightButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ controlReleaseEvent: {
+ x: 0, y: 0, button: Qt.RightButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false
+ },
+ parentPressEvent: null,
+ parentReleaseEvent: null,
+ },
+ ];
+ }
+
+ Component {
+ id: mouseAreaComponent
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+
+ function checkMouseEvent(event, expectedEvent) {
+ compare(event.x, expectedEvent.x)
+ compare(event.y, expectedEvent.y)
+ compare(event.button, expectedEvent.button)
+ compare(event.buttons, expectedEvent.buttons)
+ }
+
+ function test_pressedReleased(data) {
+ var mouseArea = mouseAreaComponent.createObject(testCase)
+ verify(mouseArea)
+ var control = textField.createObject(mouseArea)
+ verify(control)
+
+ // Give enough room to check presses outside of the control and on the parent.
+ control.x = 1;
+ control.y = 1;
+
+ function checkControlPressEvent(event) {
+ checkMouseEvent(event, data.controlPressEvent)
+ }
+ function checkControlReleaseEvent(event) {
+ checkMouseEvent(event, data.controlReleaseEvent)
+ }
+ function checkParentPressEvent(event) {
+ checkMouseEvent(event, data.parentPressEvent)
+ }
+ function checkParentReleaseEvent(event) {
+ checkMouseEvent(event, data.parentReleaseEvent)
+ }
+
+ // Can't use signalArguments, because the event won't live that long.
+ if (data.controlPressEvent)
+ control.onPressed.connect(checkControlPressEvent)
+ if (data.controlReleaseEvent)
+ control.onReleased.connect(checkControlReleaseEvent)
+ if (data.parentPressEvent)
+ control.onPressed.connect(checkParentPressEvent)
+ if (data.parentReleaseEvent)
+ control.onReleased.connect(checkParentReleaseEvent)
+
+ var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" })
+ verify(controlPressedSpy.valid)
+ var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" })
+ verify(controlReleasedSpy.valid)
+ var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" })
+ verify(parentPressedSpy.valid)
+ var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" })
+ verify(parentReleasedSpy.valid)
+
+ mousePress(control, data.x, data.y, data.button)
+ compare(controlPressedSpy.count, data.controlPressEvent ? 1 : 0)
+ compare(parentPressedSpy.count, data.parentPressEvent ? 1 : 0)
+ mouseRelease(control, data.x, data.y, data.button)
+ compare(controlReleasedSpy.count, data.controlReleaseEvent ? 1 : 0)
+ compare(parentReleasedSpy.count, data.parentReleaseEvent ? 1 : 0)
+
+ mouseArea.destroy()
+ }
+
+ Component {
+ id: ignoreTextField
+
+ TextField {
+ property bool ignorePress: false
+ property bool ignoreRelease: false
+
+ onPressed: if (ignorePress) event.accepted = false
+ onReleased: if (ignoreRelease) event.accepted = false
+ }
+ }
+
+ function checkEventAccepted(event) {
+ compare(event.accepted, true)
+ }
+
+ function checkEventIgnored(event) {
+ compare(event.accepted, false)
+ }
+
+ function test_ignorePressRelease() {
+ var mouseArea = mouseAreaComponent.createObject(testCase)
+ verify(mouseArea)
+ var control = ignoreTextField.createObject(mouseArea)
+ verify(control)
+
+ var controlPressedSpy = signalSpy.createObject(control, { target: control, signalName: "pressed" })
+ verify(controlPressedSpy.valid)
+ var controlReleasedSpy = signalSpy.createObject(control, { target: control, signalName: "released" })
+ verify(controlReleasedSpy.valid)
+ var parentPressedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "pressed" })
+ verify(parentPressedSpy.valid)
+ var parentReleasedSpy = signalSpy.createObject(mouseArea, { target: mouseArea, signalName: "released" })
+ verify(parentReleasedSpy.valid)
+
+ // Ignore only press events.
+ control.onPressed.connect(checkEventIgnored)
+ control.ignorePress = true
+ mousePress(control, 0, 0, data.button)
+ // The control will still get the signal, it just won't accept the event.
+ compare(controlPressedSpy.count, 1)
+ compare(parentPressedSpy.count, 1)
+ mouseRelease(control, 0, 0, data.button)
+ compare(controlReleasedSpy.count, 0)
+ compare(parentReleasedSpy.count, 1)
+ control.onPressed.disconnect(checkEventIgnored)
+
+ // Ignore only release events.
+ control.onPressed.connect(checkEventAccepted)
+ control.onReleased.connect(checkEventIgnored)
+ control.ignorePress = false
+ control.ignoreRelease = true
+ mousePress(control, 0, 0, data.button)
+ compare(controlPressedSpy.count, 2)
+ compare(parentPressedSpy.count, 1)
+ mouseRelease(control, 0, 0, data.button)
+ compare(controlReleasedSpy.count, 1)
+ compare(parentReleasedSpy.count, 1)
+ control.onPressed.disconnect(checkEventAccepted)
+ control.onReleased.disconnect(checkEventIgnored)
+
+ mouseArea.destroy()
+ }
+
function test_multiClick() {
var control = textField.createObject(testCase, {text: "Qt Quick Controls 2 TextArea", selectByMouse: true})
verify(control)
diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml
index b68f26e6..cc64383e 100644
--- a/tests/auto/controls/data/tst_toolbar.qml
+++ b/tests/auto/controls/data/tst_toolbar.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml
index 73431ca6..a59cff07 100644
--- a/tests/auto/controls/data/tst_toolbutton.qml
+++ b/tests/auto/controls/data/tst_toolbutton.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
diff --git a/tests/auto/controls/data/tst_toolseparator.qml b/tests/auto/controls/data/tst_toolseparator.qml
new file mode 100644
index 00000000..47eb933f
--- /dev/null
+++ b/tests/auto/controls/data/tst_toolseparator.qml
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtTest 1.0
+import QtQuick.Controls 2.1
+
+TestCase {
+ id: testCase
+ width: 400
+ height: 400
+ visible: true
+ name: "ToolSeparator"
+
+ Component {
+ id: toolSeparator
+ ToolSeparator {}
+ }
+
+ function test_size() {
+ var control = toolSeparator.createObject(testCase);
+ verify(control);
+ verify(control.width > 1);
+ verify(control.height > 1);
+
+ control.destroy();
+ }
+
+ Component {
+ id: signalSpyComponent
+ SignalSpy {}
+ }
+
+ function test_orientation() {
+ var control = toolSeparator.createObject(testCase);
+ verify(control);
+ compare(control.horizontal, false);
+ compare(control.vertical, true);
+
+ var orientationSpy = signalSpyComponent.createObject(control, { target: control, signalName: "orientationChanged" });
+
+ var originalWidth = control.width;
+ var originalHeight = control.height;
+ control.orientation = Qt.Horizontal;
+ compare(control.orientation, Qt.Horizontal);
+ compare(control.width, originalHeight);
+ compare(control.height, originalWidth);
+ compare(control.horizontal, true);
+ compare(control.vertical, false);
+ compare(orientationSpy.count, 1);
+
+ control.orientation = Qt.Vertical;
+ compare(control.orientation, Qt.Vertical);
+ compare(control.width, originalWidth);
+ compare(control.height, originalHeight);
+ compare(control.horizontal, false);
+ compare(control.vertical, true);
+ compare(orientationSpy.count, 2);
+
+ control.destroy();
+ }
+}
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index c78a7770..51601d66 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -40,7 +40,7 @@
import QtQuick 2.4
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -240,8 +240,7 @@ TestCase {
else
control.visible = false
verify(control.exit.running)
- wait(100) // TODO: replace with tryVerify() in 5.8
- verify(control.opacity < 1)
+ tryVerify(function() { return control.opacity < 1; })
if (data.imperative)
control.open()
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 2e0e3295..01d5cdee 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -40,7 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
TestCase {
id: testCase
@@ -58,6 +58,16 @@ TestCase {
readonly property real implicitTumblerHeight: 200
readonly property real defaultImplicitDelegateHeight: implicitTumblerHeight / 3
readonly property real defaultListViewTumblerOffset: -defaultImplicitDelegateHeight
+ readonly property real tumblerDelegateHeight: tumbler ? tumbler.availableHeight / tumbler.visibleItemCount : 0
+ property Item tumblerView: null
+
+ Component {
+ id: tumblerComponent
+
+ Tumbler {
+ visibleItemCount: 3
+ }
+ }
Component {
id: itemComponent
@@ -73,16 +83,20 @@ TestCase {
}
function cleanup() {
- var destroyed = false;
- cleanupItem.Component.destruction.connect(function() { destroyed = true; });
-
cleanupItem.destroy();
-
// Waiting until it's deleted before continuing makes debugging
// test failures much easier, because there aren't unrelated items hanging around.
- // TODO: Replace with tryVerify(!tumbler) in 5.8.
- while (!destroyed)
- wait(0)
+ tryVerify(function() { return !tumbler; });
+ }
+
+ function createTumbler(args) {
+ if (args === undefined)
+ tumbler = tumblerComponent.createObject(cleanupItem);
+ else
+ tumbler = tumblerComponent.createObject(cleanupItem, args);
+ verify(tumbler, "Tumbler: failed to create an instance");
+ tumblerView = findView(tumbler);
+ verify(tumblerView);
}
function tumblerXCenter() {
@@ -95,26 +109,46 @@ TestCase {
// visualItemIndex is from 0 to the amount of visible items.
function itemCenterPos(visualItemIndex) {
- var halfDelegateHeight = tumbler.contentItem.delegateHeight / 2;
+ var halfDelegateHeight = tumblerDelegateHeight / 2;
var yCenter = tumbler.y + tumbler.topPadding + halfDelegateHeight
- + (tumbler.contentItem.delegateHeight * visualItemIndex);
+ + (tumblerDelegateHeight * visualItemIndex);
return Qt.point(tumblerXCenter(), yCenter);
}
function checkItemSizes() {
- var contentChildren = tumbler.contentItem.hasOwnProperty("contentItem")
- ? tumbler.contentItem.contentItem.children : tumbler.contentItem.children;
+ var contentChildren = tumbler.wrap ? tumblerView.children : tumblerView.contentItem.children;
verify(contentChildren.length >= tumbler.count);
for (var i = 0; i < contentChildren.length; ++i) {
- compare(contentChildren[i].width, tumbler.width);
- compare(contentChildren[i].height, tumbler.contentItem.delegateHeight);
+ compare(contentChildren[i].width, tumbler.availableWidth);
+ compare(contentChildren[i].height, tumblerDelegateHeight);
}
}
- Component {
- id: tumblerComponent
+ function findView(parent) {
+ for (var i = 0; i < parent.children.length; ++i) {
+ var child = parent.children[i];
+ if (child.hasOwnProperty("currentIndex")) {
+ return child;
+ }
+
+ return findView(child);
+ }
- Tumbler {}
+ return null;
+ }
+
+ property Component noAttachedPropertiesDelegate: Text {
+ text: modelData
+ }
+
+ function test_wrapWithoutAttachedProperties() {
+ createTumbler();
+ verify(tumbler.wrap);
+
+ tumbler.delegate = noAttachedPropertiesDelegate;
+ // Shouldn't assert.
+ tumbler.wrap = false;
+ verify(findView(tumbler));
}
// TODO: test that currentIndex is maintained between contentItem changes...
@@ -122,8 +156,7 @@ TestCase {
// }
function test_currentIndex() {
- tumbler = tumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
compare(tumbler.contentItem.parent, tumbler);
tumbler.model = 5;
@@ -133,75 +166,193 @@ TestCase {
// Set it through user interaction.
var pos = Qt.point(tumblerXCenter(), tumbler.height / 2);
- mouseDrag(tumbler, pos.x, pos.y, 0, -tumbler.contentItem.delegateHeight / 2, Qt.LeftButton, Qt.NoModifier, 200);
- compare(tumbler.currentIndex, 1);
- compare(tumbler.contentItem.currentIndex, 1);
+ mouseDrag(tumbler, pos.x, pos.y, 0, tumbler.height / 3, Qt.LeftButton, Qt.NoModifier, 200);
+ tryCompare(tumblerView, "offset", 1);
+ compare(tumbler.currentIndex, 4);
+ compare(tumblerView.currentIndex, 4);
// Set it manually.
tumbler.currentIndex = 2;
tryCompare(tumbler, "currentIndex", 2);
- compare(tumbler.contentItem.currentIndex, 2);
+ compare(tumblerView.currentIndex, 2);
- // PathView has 0 as its currentIndex in this case for some reason.
tumbler.model = null;
- tryCompare(tumbler, "currentIndex", 0);
+ tryCompare(tumbler, "currentIndex", -1);
+ // PathView will only use 0 as the currentIndex when there are no items.
+ compare(tumblerView.currentIndex, 0);
tumbler.model = ["A", "B", "C"];
tryCompare(tumbler, "currentIndex", 0);
+
+ // Setting a negative current index should have no effect, because the model isn't empty.
+ tumbler.currentIndex = -1;
+ compare(tumbler.currentIndex, 0);
+
+ tumbler.model = 1;
+ compare(tumbler.currentIndex, 0);
+
+ tumbler.model = 5;
+ compare(tumbler.count, 5);
+ tumblerView = findView(tumbler);
+ tryCompare(tumblerView, "count", 5);
+ tumbler.currentIndex = 4;
+ compare(tumbler.currentIndex, 4);
+ compare(tumblerView.currentIndex, 4);
+
+ --tumbler.model;
+ compare(tumbler.count, 4);
+ compare(tumblerView.count, 4);
+ // Removing an item from an integer-based model will cause views to reset their currentIndex to 0.
+ compare(tumbler.currentIndex, 0);
+ compare(tumblerView.currentIndex, 0);
+
+ tumbler.model = 0;
+ compare(tumbler.currentIndex, -1);
}
- function test_keyboardNavigation() {
- tumbler = tumblerComponent.createObject(cleanupItem);
+ Component {
+ id: currentIndexTumbler
+
+ Tumbler {
+ model: 5
+ currentIndex: 2
+ visibleItemCount: 3
+ }
+ }
+
+ Component {
+ id: currentIndexTumblerNoWrap
+
+ Tumbler {
+ model: 5
+ currentIndex: 2
+ wrap: false
+ visibleItemCount: 3
+ }
+ }
+
+ Component {
+ id: currentIndexTumblerNoWrapReversedOrder
+
+ Tumbler {
+ model: 5
+ wrap: false
+ currentIndex: 2
+ visibleItemCount: 3
+ }
+ }
+
+ Component {
+ id: negativeCurrentIndexTumblerNoWrap
+
+ Tumbler {
+ model: 5
+ wrap: false
+ currentIndex: -1
+ visibleItemCount: 3
+ }
+ }
+
+ Component {
+ id: currentIndexTooLargeTumbler
+
+ Tumbler {
+ objectName: "currentIndexTooLargeTumbler"
+ model: 10
+ currentIndex: 10
+ }
+ }
+
+
+ function test_currentIndexAtCreation_data() {
+ return [
+ { tag: "wrap: implicit, expected currentIndex: 2", currentIndex: 2, wrap: true, component: currentIndexTumbler },
+ { tag: "wrap: false, expected currentIndex: 2", currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrap },
+ // Order of property assignments shouldn't matter
+ { tag: "wrap: false, expected currentIndex: 2, reversed property assignment order",
+ currentIndex: 2, wrap: false, component: currentIndexTumblerNoWrapReversedOrder },
+ { tag: "wrap: false, expected currentIndex: 0", currentIndex: 0, wrap: false, component: negativeCurrentIndexTumblerNoWrap },
+ { tag: "wrap: implicit, expected currentIndex: 0", currentIndex: 0, wrap: true, component: currentIndexTooLargeTumbler }
+ ]
+ }
+
+ function test_currentIndexAtCreation(data) {
+ // Test setting currentIndex at creation time
+ tumbler = data.component.createObject(cleanupItem);
verify(tumbler);
+ // A "statically declared" currentIndex will be pending until the count has changed,
+ // which happens when the model is set, which happens on the TumblerView's next polish.
+ tryCompare(tumbler, "currentIndex", data.currentIndex);
+
+ tumblerView = findView(tumbler);
+ // TODO: replace once QTBUG-19708 is fixed.
+ for (var delay = 1000; delay >= 0; delay -= 50) {
+ if (tumblerView.currentItem)
+ break;
+ wait(50);
+ }
+ verify(tumblerView.currentItem);
+ compare(tumblerView.currentIndex, data.currentIndex);
+ compare(tumblerView.currentItem.text, data.currentIndex.toString());
+
+ var fuzz = 1;
+ if (data.wrap) {
+ fuzzyCompare(tumblerView.offset, data.currentIndex > 0 ? tumblerView.count - data.currentIndex : 0, fuzz);
+ } else {
+ fuzzyCompare(tumblerView.contentY, tumblerDelegateHeight * data.currentIndex - tumblerView.preferredHighlightBegin, fuzz);
+ }
+ }
+
+ function test_keyboardNavigation() {
+ createTumbler();
tumbler.model = 5;
tumbler.forceActiveFocus();
- tumbler.contentItem.highlightMoveDuration = 0;
+ tumblerView.highlightMoveDuration = 0;
// Navigate upwards through entire wheel.
for (var j = 0; j < tumbler.count - 1; ++j) {
keyClick(Qt.Key_Up, Qt.NoModifier);
- tryCompare(tumbler.contentItem, "offset", j + 1);
+ tryCompare(tumblerView, "offset", j + 1);
compare(tumbler.currentIndex, tumbler.count - 1 - j);
}
keyClick(Qt.Key_Up, Qt.NoModifier);
- tryCompare(tumbler.contentItem, "offset", 0);
+ tryCompare(tumblerView, "offset", 0);
compare(tumbler.currentIndex, 0);
// Navigate downwards through entire wheel.
for (j = 0; j < tumbler.count - 1; ++j) {
keyClick(Qt.Key_Down, Qt.NoModifier);
- tryCompare(tumbler.contentItem, "offset", tumbler.count - 1 - j);
+ tryCompare(tumblerView, "offset", tumbler.count - 1 - j);
compare(tumbler.currentIndex, j + 1);
}
keyClick(Qt.Key_Down, Qt.NoModifier);
- tryCompare(tumbler.contentItem, "offset", 0);
+ tryCompare(tumblerView, "offset", 0);
compare(tumbler.currentIndex, 0);
}
function test_itemsCorrectlyPositioned() {
- tumbler = tumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
tumbler.model = 4;
tumbler.height = 120;
- compare(tumbler.contentItem.delegateHeight, 40);
+ compare(tumblerDelegateHeight, 40);
checkItemSizes();
- wait(tumbler.contentItem.highlightMoveDuration);
+ wait(tumblerView.highlightMoveDuration);
var firstItemCenterPos = itemCenterPos(1);
- var firstItem = tumbler.contentItem.itemAt(firstItemCenterPos.x, firstItemCenterPos.y);
+ var firstItem = tumblerView.itemAt(firstItemCenterPos.x, firstItemCenterPos.y);
var actualPos = cleanupItem.mapFromItem(firstItem, 0, 0);
compare(actualPos.x, tumbler.leftPadding);
compare(actualPos.y, tumbler.topPadding + 40);
tumbler.forceActiveFocus();
keyClick(Qt.Key_Down);
- tryCompare(tumbler.contentItem, "offset", 3.0);
+ tryCompare(tumblerView, "offset", 3.0);
firstItemCenterPos = itemCenterPos(0);
- firstItem = tumbler.contentItem.itemAt(firstItemCenterPos.x, firstItemCenterPos.y);
+ firstItem = tumblerView.itemAt(firstItemCenterPos.x, firstItemCenterPos.y);
verify(firstItem);
// Test QTBUG-40298.
actualPos = cleanupItem.mapFromItem(firstItem, 0, 0);
@@ -209,12 +360,12 @@ TestCase {
compare(actualPos.y, tumbler.topPadding);
var secondItemCenterPos = itemCenterPos(1);
- var secondItem = tumbler.contentItem.itemAt(secondItemCenterPos.x, secondItemCenterPos.y);
+ var secondItem = tumblerView.itemAt(secondItemCenterPos.x, secondItemCenterPos.y);
verify(secondItem);
verify(firstItem.y < secondItem.y);
var thirdItemCenterPos = itemCenterPos(2);
- var thirdItem = tumbler.contentItem.itemAt(thirdItemCenterPos.x, thirdItemCenterPos.y);
+ var thirdItem = tumblerView.itemAt(thirdItemCenterPos.x, thirdItemCenterPos.y);
verify(thirdItem);
verify(firstItem.y < thirdItem.y);
verify(secondItem.y < thirdItem.y);
@@ -241,18 +392,18 @@ TestCase {
tumbler = component.createObject(cleanupItem);
// Should not be any warnings.
- compare(tumbler.dayTumbler.currentIndex, 0);
+ tryCompare(tumbler.dayTumbler, "currentIndex", 0);
compare(tumbler.dayTumbler.count, 31);
compare(tumbler.monthTumbler.currentIndex, 0);
compare(tumbler.monthTumbler.count, 12);
compare(tumbler.yearTumbler.currentIndex, 0);
compare(tumbler.yearTumbler.count, 100);
- verify(tumbler.dayTumbler.contentItem.children.length >= tumbler.dayTumbler.visibleItemCount);
- verify(tumbler.monthTumbler.contentItem.children.length >= tumbler.monthTumbler.visibleItemCount);
+ verify(findView(tumbler.dayTumbler).children.length >= tumbler.dayTumbler.visibleItemCount);
+ verify(findView(tumbler.monthTumbler).children.length >= tumbler.monthTumbler.visibleItemCount);
// TODO: do this properly somehow
wait(100);
- verify(tumbler.yearTumbler.contentItem.children.length >= tumbler.yearTumbler.visibleItemCount);
+ verify(findView(tumbler.yearTumbler).children.length >= tumbler.yearTumbler.visibleItemCount);
// March.
tumbler.monthTumbler.currentIndex = 2;
@@ -361,27 +512,106 @@ TestCase {
}
function test_displacement(data) {
- tumbler = tumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
// TODO: test setting these in the opposite order (delegate after model
// doesn't seem to cause a change in delegates in PathView)
+ tumbler.wrap = true;
tumbler.delegate = displacementDelegate;
tumbler.model = data.count;
compare(tumbler.count, data.count);
- var delegate = findChild(tumbler.contentItem, "delegate" + data.index);
+ var delegate = findChild(tumblerView, "delegate" + data.index);
verify(delegate);
- tumbler.contentItem.offset = data.offset;
+ tumblerView.offset = data.offset;
compare(delegate.displacement, data.expectedDisplacement);
// test displacement after adding and removing items
}
+ function test_wrap() {
+ createTumbler();
+
+ tumbler.model = 5;
+ compare(tumbler.count, 5);
+
+ tumbler.currentIndex = 2;
+ compare(tumblerView.currentIndex, 2);
+
+ tumbler.wrap = false;
+ tumblerView = findView(tumbler);
+ compare(tumbler.count, 5);
+ compare(tumbler.currentIndex, 2);
+ // Tumbler's count hasn't changed (the model hasn't changed),
+ // but the new view needs time to instantiate its items.
+ tryCompare(tumblerView, "count", 5);
+ compare(tumblerView.currentIndex, 2);
+ }
+
+ Component {
+ id: twoItemTumbler
+
+ Tumbler {
+ model: 2
+ }
+ }
+
+ Component {
+ id: tenItemTumbler
+
+ Tumbler {
+ model: 10
+ }
+ }
+
+ function test_countWrap() {
+ tumbler = tumblerComponent.createObject(cleanupItem);
+ verify(tumbler);
+
+ // Check that a count that is less than visibleItemCount results in wrap being set to false.
+ verify(2 < tumbler.visibleItemCount);
+ tumbler.model = 2;
+ compare(tumbler.count, 2);
+ compare(tumbler.wrap, false);
+ }
+
+ function test_explicitlyNonwrapping() {
+ // Check that explicitly setting wrap to false works even when it was implicitly false.
+ var explicitlyNonWrapping = twoItemTumbler.createObject(cleanupItem);
+ verify(explicitlyNonWrapping);
+ tryCompare(explicitlyNonWrapping, "wrap", false);
+
+ explicitlyNonWrapping.wrap = false;
+ // wrap shouldn't be set to true now that there are more items than there are visible ones.
+ verify(10 > explicitlyNonWrapping.visibleItemCount);
+ explicitlyNonWrapping.model = 10;
+ compare(explicitlyNonWrapping.wrap, false);
+
+ // Test resetting wrap back to the default behavior.
+ explicitlyNonWrapping.wrap = undefined;
+ compare(explicitlyNonWrapping.wrap, true);
+ }
+
+ function test_explicitlyWrapping() {
+ // Check that explicitly setting wrap to true works even when it was implicitly true.
+ var explicitlyWrapping = tenItemTumbler.createObject(cleanupItem);
+ verify(explicitlyWrapping);
+ compare(explicitlyWrapping.wrap, true);
+
+ explicitlyWrapping.wrap = true;
+ // wrap shouldn't be set to false now that there are more items than there are visible ones.
+ explicitlyWrapping.model = 2;
+ compare(explicitlyWrapping.wrap, true);
+
+ // Test resetting wrap back to the default behavior.
+ explicitlyWrapping.wrap = undefined;
+ compare(explicitlyWrapping.wrap, false);
+ }
+
Component {
- id: listViewTumblerComponent
- //! [contentItem]
+ id: customListViewTumblerComponent
+
Tumbler {
id: listViewTumbler
@@ -397,7 +627,95 @@ TestCase {
clip: true
}
}
- //! [contentItem]
+ }
+
+ Component {
+ id: customPathViewTumblerComponent
+
+ Tumbler {
+ id: pathViewTumbler
+
+ contentItem: PathView {
+ id: pathView
+ model: pathViewTumbler.model
+ delegate: pathViewTumbler.delegate
+ clip: true
+ pathItemCount: pathViewTumbler.visibleItemCount + 1
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ dragMargin: width / 2
+
+ path: Path {
+ startX: pathView.width / 2
+ startY: -pathView.delegateHeight / 2
+ PathLine {
+ x: pathView.width / 2
+ y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2
+ }
+ }
+
+ property real delegateHeight: pathViewTumbler.availableHeight / pathViewTumbler.visibleItemCount
+ }
+ }
+ }
+
+ function test_customContentItemAtConstruction_data() {
+ return [
+ { tag: "ListView", component: customListViewTumblerComponent },
+ { tag: "PathView", component: customPathViewTumblerComponent }
+ ];
+ }
+
+ function test_customContentItemAtConstruction(data) {
+ var tumbler = data.component.createObject(cleanupItem);
+ // Shouldn't assert.
+
+ tumbler.model = 5;
+ compare(tumbler.count, 5);
+
+ tumbler.currentIndex = 2;
+ var tumblerView = findView(tumbler);
+ compare(tumblerView.currentIndex, 2);
+
+ tumblerView.incrementCurrentIndex();
+ compare(tumblerView.currentIndex, 3);
+ compare(tumbler.currentIndex, 3);
+
+ // Shouldn't have any affect.
+ tumbler.wrap = false;
+ compare(tumbler.count, 5);
+ compare(tumblerView.currentIndex, 3);
+ compare(tumbler.currentIndex, 3);
+ }
+
+ function test_customContentItemAfterConstruction_data() {
+ return [
+ { tag: "ListView", componentPath: "TumblerListView.qml" },
+ { tag: "PathView", componentPath: "TumblerPathView.qml" }
+ ];
+ }
+
+ function test_customContentItemAfterConstruction(data) {
+ createTumbler();
+
+ tumbler.model = 5;
+ compare(tumbler.count, 5);
+
+ tumbler.currentIndex = 2;
+ compare(tumblerView.currentIndex, 2);
+
+ var contentItemComponent = Qt.createComponent(data.componentPath);
+ compare(contentItemComponent.status, Component.Ready);
+
+ var customContentItem = contentItemComponent.createObject(tumbler);
+ tumbler.contentItem = customContentItem;
+ compare(tumbler.count, 5);
+ tumblerView = findView(tumbler);
+ compare(tumblerView.currentIndex, 2);
+
+ tumblerView.incrementCurrentIndex();
+ compare(tumblerView.currentIndex, 3);
+ compare(tumbler.currentIndex, 3);
}
function test_displacementListView_data() {
@@ -438,20 +756,18 @@ TestCase {
}
function test_displacementListView(data) {
- // Sanity check that they're aren't any children at this stage.
- tryCompare(cleanupItem.children, "length", 0);
-
- tumbler = listViewTumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
+ tumbler.wrap = false;
tumbler.delegate = displacementDelegate;
tumbler.model = 5;
compare(tumbler.count, 5);
// Ensure assumptions about the tumbler used in our data() function are correct.
- compare(tumbler.contentItem.contentY, -defaultImplicitDelegateHeight);
+ tumblerView = findView(tumbler);
+ compare(tumblerView.contentY, -defaultImplicitDelegateHeight);
var delegateCount = 0;
- var listView = tumbler.contentItem;
- var listViewContentItem = tumbler.contentItem.contentItem;
+ var listView = tumblerView;
+ var listViewContentItem = tumblerView.contentItem;
// We use the mouse instead of setting contentY directly, otherwise the
// items snap back into place. This doesn't seem to be an issue for
@@ -511,16 +827,17 @@ TestCase {
}
function test_listViewFlickAboveBounds(data) {
- tumbler = listViewTumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
+ tumbler.wrap = false;
tumbler.delegate = displacementDelegate;
tumbler.model = data.model;
+ tumblerView = findView(tumbler);
mousePress(tumbler, tumblerXCenter(), tumblerYCenter());
// Ensure it's stationary.
- var listView = tumbler.contentItem;
+ var listView = tumblerView;
compare(listView.contentY, defaultListViewTumblerOffset);
// We could just move up until the contentY changed, but this is safer.
@@ -577,8 +894,7 @@ TestCase {
}
function test_visibleItemCount(data) {
- tumbler = tumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
tumbler.delegate = objectNameDelegate;
tumbler.visibleItemCount = data.visibleItemCount;
@@ -588,9 +904,9 @@ TestCase {
for (var delegateIndex = 0; delegateIndex < data.visibleItemCount; ++delegateIndex) {
if (data.expectedYPositions.hasOwnProperty(delegateIndex)) {
- var delegate = findChild(tumbler.contentItem, "delegate" + delegateIndex);
+ var delegate = findChild(tumblerView, "delegate" + delegateIndex);
verify(delegate, "Delegate found at index " + delegateIndex);
- var expectedYPos = data.expectedYPositions[delegateIndex] * tumbler.contentItem.delegateHeight;
+ var expectedYPos = data.expectedYPositions[delegateIndex] * tumblerDelegateHeight;
compare(delegate.mapToItem(tumbler.contentItem, 0, 0).y, expectedYPos);
}
}
@@ -604,12 +920,6 @@ TestCase {
property real displacement: Tumbler.displacement
}
- property Component gridViewComponent: GridView {}
- property Component simpleDisplacementDelegate: Text {
- property real displacement: Tumbler.displacement
- property int index: -1
- }
-
function test_attachedProperties() {
tumbler = tumblerComponent.createObject(cleanupItem);
verify(tumbler);
@@ -621,19 +931,12 @@ TestCase {
// // Cause displacement to be changed. The warning isn't triggered if we don't do this.
// tumbler.contentItem.offset += 1;
- ignoreWarning("Tumbler: attached properties must be accessed from within a delegate item that has a parent");
+ ignoreWarning("Tumbler: attached properties must be accessed through a delegate item that has a parent");
noParentDelegateComponent.createObject(null);
ignoreWarning("Tumbler: attempting to access attached property on item without an \"index\" property");
var object = noParentDelegateComponent.createObject(cleanupItem);
verify(object);
- object.destroy();
-
- // Should not be any warnings from this, as ListView, for example, doesn't produce warnings for the same code.
- var gridView = gridViewComponent.createObject(cleanupItem);
- object = simpleDisplacementDelegate.createObject(gridView);
- verify(object);
- object.destroy();
}
property Component paddingDelegate: Text {
@@ -680,8 +983,7 @@ TestCase {
}
function test_padding(data) {
- tumbler = tumblerComponent.createObject(cleanupItem);
- verify(tumbler);
+ createTumbler();
tumbler.delegate = paddingDelegate;
tumbler.model = 5;
@@ -733,8 +1035,8 @@ TestCase {
}
// Force new items to be created, as there was a bug where the path was correct until this happened.
- compare(tumbler.contentItem.offset, 0);
+ compare(tumblerView.offset, 0);
++tumbler.currentIndex;
- tryCompare(tumbler.contentItem, "offset", 4, tumbler.contentItem.highlightMoveDuration * 2);
+ tryCompare(tumblerView, "offset", 4, tumblerView.highlightMoveDuration * 2);
}
}
diff --git a/tests/auto/controls/default/default.pro b/tests/auto/controls/default/default.pro
index 6ab5b5ff..290edc5f 100644
--- a/tests/auto/controls/default/default.pro
+++ b/tests/auto/controls/default/default.pro
@@ -8,7 +8,7 @@ SOURCES += \
$$PWD/tst_default.cpp
OTHER_FILES += \
- $$PWD/../data/*
+ $$PWD/../data/*.qml
TESTDATA += \
$$PWD/../data/tst_*
diff --git a/tests/auto/controls/default/dependencies.qml b/tests/auto/controls/default/dependencies.qml
new file mode 100644
index 00000000..091ab39f
--- /dev/null
+++ b/tests/auto/controls/default/dependencies.qml
@@ -0,0 +1,5 @@
+import QtTest 1.0
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+TestCase { }
diff --git a/tests/auto/controls/material/dependencies.qml b/tests/auto/controls/material/dependencies.qml
new file mode 100644
index 00000000..fe0de037
--- /dev/null
+++ b/tests/auto/controls/material/dependencies.qml
@@ -0,0 +1,6 @@
+import QtTest 1.0
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+
+TestCase { }
diff --git a/tests/auto/controls/material/material.pro b/tests/auto/controls/material/material.pro
index 1a8260f3..652dcf7f 100644
--- a/tests/auto/controls/material/material.pro
+++ b/tests/auto/controls/material/material.pro
@@ -9,7 +9,7 @@ SOURCES += \
$$PWD/tst_material.cpp
OTHER_FILES += \
- $$PWD/../data/*
+ $$PWD/../data/*.qml
TESTDATA += \
$$PWD/../data/tst_*
diff --git a/tests/auto/controls/universal/dependencies.qml b/tests/auto/controls/universal/dependencies.qml
new file mode 100644
index 00000000..97da9810
--- /dev/null
+++ b/tests/auto/controls/universal/dependencies.qml
@@ -0,0 +1,6 @@
+import QtTest 1.0
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Universal 2.1
+
+TestCase { }
diff --git a/tests/auto/controls/universal/universal.pro b/tests/auto/controls/universal/universal.pro
index 7a16cc64..835798b3 100644
--- a/tests/auto/controls/universal/universal.pro
+++ b/tests/auto/controls/universal/universal.pro
@@ -9,7 +9,7 @@ SOURCES += \
$$PWD/tst_universal.cpp
OTHER_FILES += \
- $$PWD/../data/*
+ $$PWD/../data/*.qml
TESTDATA += \
$$PWD/../data/tst_*
diff --git a/tests/auto/drawer/data/applicationwindow.qml b/tests/auto/drawer/data/applicationwindow.qml
index 9032ea0d..0aa4b34e 100644
--- a/tests/auto/drawer/data/applicationwindow.qml
+++ b/tests/auto/drawer/data/applicationwindow.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/drawer/drawer.pro b/tests/auto/drawer/drawer.pro
index 95ed44e9..e1ba0ce5 100644
--- a/tests/auto/drawer/drawer.pro
+++ b/tests/auto/drawer/drawer.pro
@@ -11,4 +11,4 @@ include (../shared/util.pri)
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index ab652466..4743a8cd 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -452,6 +452,10 @@ void tst_Drawer::hover()
QVERIFY(drawer);
drawer->setModal(modal);
+ QQuickControl *drawerItem = qobject_cast<QQuickControl *>(drawer->popupItem());
+ QVERIFY(drawerItem);
+ QVERIFY(drawerItem->isHoverEnabled());
+
QQuickButton *backgroundButton = window->property("backgroundButton").value<QQuickButton*>();
QVERIFY(backgroundButton);
backgroundButton->setHoverEnabled(true);
@@ -469,16 +473,19 @@ void tst_Drawer::hover()
QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1));
QCOMPARE(backgroundButton->isHovered(), !modal);
QVERIFY(!drawerButton->isHovered());
+ QVERIFY(!drawerItem->isHovered());
// hover the drawer background
QTest::mouseMove(window, QPoint(1, 1));
QVERIFY(!backgroundButton->isHovered());
QVERIFY(!drawerButton->isHovered());
+ QVERIFY(drawerItem->isHovered());
// hover the button in a drawer
QTest::mouseMove(window, QPoint(2, 2));
QVERIFY(!backgroundButton->isHovered());
QVERIFY(drawerButton->isHovered());
+ QVERIFY(drawerItem->isHovered());
QSignalSpy closedSpy(drawer, SIGNAL(closed()));
QVERIFY(closedSpy.isValid());
@@ -488,6 +495,8 @@ void tst_Drawer::hover()
// hover the background button after closing the drawer
QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
QVERIFY(backgroundButton->isHovered());
+ QVERIFY(!drawerButton->isHovered());
+ QVERIFY(!drawerItem->isHovered());
}
void tst_Drawer::wheel_data()
@@ -745,7 +754,7 @@ void tst_Drawer::touch()
QTest::touchEvent(window, device.data()).move(0, QPoint(300 - drawer->dragMargin(), 100));
for (int x = 300; x > 100; x -= 10) {
QTest::touchEvent(window, device.data()).move(0, QPoint(x, 100));
- QQuickWindowPrivate::get(window)->flushDelayedTouchEvent();
+ QQuickWindowPrivate::get(window)->flushFrameSynchronousEvents();
}
QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100));
QTRY_COMPARE(drawer->position(), 0.5);
diff --git a/tests/auto/focus/data/activeFocusOnTab.qml b/tests/auto/focus/data/activeFocusOnTab.qml
index 249cdba9..08cf6e3e 100644
--- a/tests/auto/focus/data/activeFocusOnTab.qml
+++ b/tests/auto/focus/data/activeFocusOnTab.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: main
diff --git a/tests/auto/focus/data/keyNavigation.qml b/tests/auto/focus/data/keyNavigation.qml
index 3be791b5..d17d79f3 100644
--- a/tests/auto/focus/data/keyNavigation.qml
+++ b/tests/auto/focus/data/keyNavigation.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.5
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
id: main
diff --git a/tests/auto/focus/tst_focus.cpp b/tests/auto/focus/tst_focus.cpp
index 3f3b1ae5..409f2fc7 100644
--- a/tests/auto/focus/tst_focus.cpp
+++ b/tests/auto/focus/tst_focus.cpp
@@ -126,7 +126,7 @@ void tst_focus::policy()
{
QQmlEngine engine;
QQmlComponent component(&engine);
- component.setData("import QtQuick.Controls 2.0; ApplicationWindow { width: 100; height: 100; Control { anchors.fill: parent } }", QUrl());
+ component.setData("import QtQuick.Controls 2.1; ApplicationWindow { width: 100; height: 100; Control { anchors.fill: parent } }", QUrl());
QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create()));
QVERIFY(window);
@@ -209,7 +209,7 @@ void tst_focus::reason()
QQmlEngine engine;
QQmlComponent component(&engine);
- component.setData(QString("import QtQuick.Controls 2.0; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl());
+ component.setData(QString("import QtQuick.Controls 2.1; ApplicationWindow { width: 100; height: 100; %1 { anchors.fill: parent } }").arg(name).toUtf8(), QUrl());
QScopedPointer<QQuickApplicationWindow> window(qobject_cast<QQuickApplicationWindow *>(component.create()));
QVERIFY(window.data());
diff --git a/tests/auto/menu/data/addItem.qml b/tests/auto/menu/data/addItem.qml
index 7bf07ecb..81814f06 100644
--- a/tests/auto/menu/data/addItem.qml
+++ b/tests/auto/menu/data/addItem.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 200
diff --git a/tests/auto/menu/data/applicationwindow.qml b/tests/auto/menu/data/applicationwindow.qml
index 03bbe67b..6ac2e88e 100644
--- a/tests/auto/menu/data/applicationwindow.qml
+++ b/tests/auto/menu/data/applicationwindow.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
title: "Test Application Window"
diff --git a/examples/quickcontrols2/gallery/pages/PopupPage.qml b/tests/auto/menu/data/menuSeparator.qml
index 66c46143..913e8e98 100644
--- a/examples/quickcontrols2/gallery/pages/PopupPage.qml
+++ b/tests/auto/menu/data/menuSeparator.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -39,30 +39,35 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
-ScrollablePage {
- id: page
+ApplicationWindow {
+ width: 200
+ height: 200
- Column {
- spacing: 40
- width: parent.width
+ property alias menu: menu
- Label {
- width: parent.width
- wrapMode: Label.Wrap
- horizontalAlignment: Qt.AlignHCenter
- text: "Popup is used to display modal or modeless content that overlays other "
- + "application content. In this example, the settings are shown in a popup."
- }
+ MenuItem {
+ id: newMenuItem
+ text: qsTr("New")
+ }
+
+ MenuSeparator {
+ id: menuSeparator
+ }
+
+ MenuItem {
+ id: saveMenuItem
+ text: qsTr("Save")
+ }
- Button {
- id: button
- text: "Open"
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3))
+ Menu {
+ id: menu
- onClicked: settingsPopup.open()
+ Component.onCompleted: {
+ addItem(newMenuItem)
+ addItem(menuSeparator)
+ addItem(saveMenuItem)
}
}
}
diff --git a/tests/auto/menu/menu.pro b/tests/auto/menu/menu.pro
index 649f3fd4..44cbd5ed 100644
--- a/tests/auto/menu/menu.pro
+++ b/tests/auto/menu/menu.pro
@@ -11,5 +11,5 @@ include (../shared/util.pri)
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp
index 7617cfcc..0635ad81 100644
--- a/tests/auto/menu/tst_menu.cpp
+++ b/tests/auto/menu/tst_menu.cpp
@@ -50,6 +50,7 @@
#include <QtQuickTemplates2/private/qquickbutton_p.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
#include <QtQuickTemplates2/private/qquickmenuitem_p.h>
+#include <QtQuickTemplates2/private/qquickmenuseparator_p.h>
using namespace QQuickVisualTestUtil;
@@ -65,6 +66,7 @@ private slots:
void contextMenuKeyboard();
void menuButton();
void addItem();
+ void menuSeparator();
};
void tst_menu::defaults()
@@ -272,6 +274,49 @@ void tst_menu::addItem()
QTRY_VERIFY(!menu->isVisible());
}
+void tst_menu::menuSeparator()
+{
+ QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml"));
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickMenu *menu = window->property("menu").value<QQuickMenu*>();
+ QVERIFY(menu);
+ menu->open();
+ QVERIFY(menu->isVisible());
+
+ QQuickMenuItem *newMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(0));
+ QVERIFY(newMenuItem);
+ QCOMPARE(newMenuItem->text(), QStringLiteral("New"));
+
+ QQuickMenuSeparator *menuSeparator = qobject_cast<QQuickMenuSeparator*>(menu->itemAt(1));
+ QVERIFY(menuSeparator);
+
+ QQuickMenuItem *saveMenuItem = qobject_cast<QQuickMenuItem*>(menu->itemAt(2));
+ QVERIFY(saveMenuItem);
+ QCOMPARE(saveMenuItem->text(), QStringLiteral("Save"));
+ QTRY_VERIFY(!QQuickItemPrivate::get(saveMenuItem)->culled); // QTBUG-53262
+
+ // Clicking on items should still close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ newMenuItem->mapToScene(QPointF(newMenuItem->width() / 2, newMenuItem->height() / 2)).toPoint());
+ QTRY_VERIFY(!menu->isVisible());
+
+ menu->open();
+ QVERIFY(menu->isVisible());
+
+ // Clicking on a separator shouldn't close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ menuSeparator->mapToScene(QPointF(menuSeparator->width() / 2, menuSeparator->height() / 2)).toPoint());
+ QVERIFY(menu->isVisible());
+
+ // Clicking on items should still close the menu.
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier,
+ saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint());
+ QTRY_VERIFY(!menu->isVisible());
+}
+
QTEST_MAIN(tst_menu)
#include "tst_menu.moc"
diff --git a/tests/auto/platform/data/tst_colordialog.qml b/tests/auto/platform/data/tst_colordialog.qml
new file mode 100644
index 00000000..1e9bbccf
--- /dev/null
+++ b/tests/auto/platform/data/tst_colordialog.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "ColorDialog"
+
+ Component {
+ id: colorDialog
+ ColorDialog { }
+ }
+
+ function test_instance() {
+ var dialog = colorDialog.createObject(testCase)
+ verify(dialog)
+ dialog.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_filedialog.qml b/tests/auto/platform/data/tst_filedialog.qml
new file mode 100644
index 00000000..1f34c5a7
--- /dev/null
+++ b/tests/auto/platform/data/tst_filedialog.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "FileDialog"
+
+ Component {
+ id: fileDialog
+ FileDialog { }
+ }
+
+ function test_instance() {
+ var dialog = fileDialog.createObject(testCase)
+ verify(dialog)
+ dialog.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_folderdialog.qml b/tests/auto/platform/data/tst_folderdialog.qml
new file mode 100644
index 00000000..9061d825
--- /dev/null
+++ b/tests/auto/platform/data/tst_folderdialog.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "FolderDialog"
+
+ Component {
+ id: folderDialog
+ FolderDialog { }
+ }
+
+ function test_instance() {
+ var dialog = folderDialog.createObject(testCase)
+ verify(dialog)
+ dialog.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_fontdialog.qml b/tests/auto/platform/data/tst_fontdialog.qml
new file mode 100644
index 00000000..b05737aa
--- /dev/null
+++ b/tests/auto/platform/data/tst_fontdialog.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "FontDialog"
+
+ Component {
+ id: fontDialog
+ FontDialog { }
+ }
+
+ function test_instance() {
+ var dialog = fontDialog.createObject(testCase)
+ verify(dialog)
+ dialog.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_menu.qml b/tests/auto/platform/data/tst_menu.qml
new file mode 100644
index 00000000..cc846d99
--- /dev/null
+++ b/tests/auto/platform/data/tst_menu.qml
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "Menu"
+
+ Component {
+ id: item
+ MenuItem { }
+ }
+
+ Component {
+ id: menu
+ Menu { }
+ }
+
+ SignalSpy {
+ id: itemsSpy
+ signalName: "itemsChanged"
+ }
+
+ function init() {
+ verify(!itemsSpy.target)
+ compare(itemsSpy.count, 0)
+ }
+
+ function cleanup() {
+ itemsSpy.target = null
+ itemsSpy.clear()
+ }
+
+ function test_addRemove() {
+ var control = menu.createObject(testCase)
+
+ itemsSpy.target = control
+ verify(itemsSpy.valid)
+
+ control.addItem(item.createObject(control, {text: "1"}))
+ compare(control.items.length, 1)
+ compare(control.items[0].text, "1")
+ compare(itemsSpy.count, 1)
+
+ control.addItem(item.createObject(control, {text: "2"}))
+ compare(control.items.length, 2)
+ compare(control.items[0].text, "1")
+ compare(control.items[1].text, "2")
+ compare(itemsSpy.count, 2)
+
+ control.insertItem(1, item.createObject(control, {text: "3"}))
+ compare(control.items.length, 3)
+ compare(control.items[0].text, "1")
+ compare(control.items[1].text, "3")
+ compare(control.items[2].text, "2")
+ compare(itemsSpy.count, 3)
+
+ control.insertItem(0, item.createObject(control, {text: "4"}))
+ compare(control.items.length, 4)
+ compare(control.items[0].text, "4")
+ compare(control.items[1].text, "1")
+ compare(control.items[2].text, "3")
+ compare(control.items[3].text, "2")
+ compare(itemsSpy.count, 4)
+
+ control.insertItem(control.items.length, item.createObject(control, {text: "5"}))
+ compare(control.items.length, 5)
+ compare(control.items[0].text, "4")
+ compare(control.items[1].text, "1")
+ compare(control.items[2].text, "3")
+ compare(control.items[3].text, "2")
+ compare(control.items[4].text, "5")
+ compare(itemsSpy.count, 5)
+
+ control.removeItem(control.items[4])
+ compare(control.items.length, 4)
+ compare(control.items[0].text, "4")
+ compare(control.items[1].text, "1")
+ compare(control.items[2].text, "3")
+ compare(control.items[3].text, "2")
+ compare(itemsSpy.count, 6)
+
+ control.removeItem(control.items[0])
+ compare(control.items.length, 3)
+ compare(control.items[0].text, "1")
+ compare(control.items[1].text, "3")
+ compare(control.items[2].text, "2")
+ compare(itemsSpy.count, 7)
+
+ control.removeItem(control.items[1])
+ compare(control.items.length, 2)
+ compare(control.items[0].text, "1")
+ compare(control.items[1].text, "2")
+ compare(itemsSpy.count, 8)
+
+ control.removeItem(control.items[1])
+ compare(control.items.length, 1)
+ compare(control.items[0].text, "1")
+ compare(itemsSpy.count, 9)
+
+ control.removeItem(control.items[0])
+ compare(control.items.length, 0)
+ compare(itemsSpy.count, 10)
+
+ control.destroy()
+ }
+
+ Component {
+ id: contentMenu
+ Menu {
+ QtObject { objectName: "object" }
+ MenuItem { objectName: "item1" }
+ Timer { objectName: "timer" }
+ MenuItem { objectName: "item2" }
+ Component { MenuItem { } }
+ }
+ }
+
+ function test_content() {
+ var control = contentMenu.createObject(testCase)
+
+ function compareObjectNames(content, names) {
+ if (content.length !== names.length)
+ return false
+ for (var i = 0; i < names.length; ++i) {
+ if (content[i].objectName !== names[i])
+ return false
+ }
+ return true
+ }
+
+ itemsSpy.target = control
+ verify(itemsSpy.valid)
+
+ verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", ""]))
+ verify(compareObjectNames(control.items, ["item1", "item2"]))
+
+ control.addItem(item.createObject(control, {objectName: "item3"}))
+ verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", "", "item3"]))
+ verify(compareObjectNames(control.items, ["item1", "item2", "item3"]))
+ compare(itemsSpy.count, 1)
+
+ control.insertItem(0, item.createObject(control, {objectName: "item4"}))
+ verify(compareObjectNames(control.data, ["object", "item1", "timer", "item2", "", "item3", "item4"]))
+ verify(compareObjectNames(control.items, ["item4", "item1", "item2", "item3"]))
+ compare(itemsSpy.count, 2)
+
+ control.removeItem(control.items[1])
+ verify(compareObjectNames(control.data, ["object", "timer", "item2", "", "item3", "item4"]))
+ verify(compareObjectNames(control.items, ["item4", "item2", "item3"]))
+ compare(itemsSpy.count, 3)
+
+ control.destroy()
+ }
+
+ Component {
+ id: dynamicMenu
+ Menu {
+ id: dmenu
+ MenuItem { text: "static" }
+ Component.onCompleted: {
+ addItem(item.createObject(dmenu, {text: "added"}))
+ insertItem(0, item.createObject(dmenu, {text: "inserted"}))
+ }
+ }
+ }
+
+ function test_dynamic() {
+ var control = dynamicMenu.createObject(testCase)
+
+ // insertItem(), addItem(), and static MenuItem {}
+ compare(control.items.length, 3)
+ compare(control.items[0].text, "inserted")
+
+ var dying = item.createObject(control, {text: "dying"})
+ control.addItem(dying)
+ compare(control.items.length, 4)
+ compare(control.items[3].text, "dying")
+ dying.destroy()
+ wait(0)
+ compare(control.items.length, 3)
+
+ control.destroy()
+ }
+
+ function test_type() {
+ // Q_ENUMS(QPlatformMenu::MenuType)
+ compare(Menu.DefaultMenu, 0)
+ compare(Menu.EditMenu, 1)
+ }
+}
diff --git a/tests/auto/platform/data/tst_menubar.qml b/tests/auto/platform/data/tst_menubar.qml
new file mode 100644
index 00000000..6c29f164
--- /dev/null
+++ b/tests/auto/platform/data/tst_menubar.qml
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "MenuBar"
+
+ Component {
+ id: menu
+ Menu { }
+ }
+
+ Component {
+ id: menuBar
+ MenuBar { }
+ }
+
+ SignalSpy {
+ id: menusSpy
+ signalName: "menusChanged"
+ }
+
+ function init() {
+ verify(!menusSpy.target)
+ compare(menusSpy.count, 0)
+ }
+
+ function cleanup() {
+ menusSpy.target = null
+ menusSpy.clear()
+ }
+
+ function test_addRemove() {
+ var control = menuBar.createObject(testCase)
+
+ menusSpy.target = control
+ verify(menusSpy.valid)
+
+ control.addMenu(menu.createObject(control, {title: "1"}))
+ compare(control.menus.length, 1)
+ compare(control.menus[0].title, "1")
+ compare(menusSpy.count, 1)
+
+ control.addMenu(menu.createObject(control, {title: "2"}))
+ compare(control.menus.length, 2)
+ compare(control.menus[0].title, "1")
+ compare(control.menus[1].title, "2")
+ compare(menusSpy.count, 2)
+
+ control.insertMenu(1, menu.createObject(control, {title: "3"}))
+ compare(control.menus.length, 3)
+ compare(control.menus[0].title, "1")
+ compare(control.menus[1].title, "3")
+ compare(control.menus[2].title, "2")
+ compare(menusSpy.count, 3)
+
+ control.insertMenu(0, menu.createObject(control, {title: "4"}))
+ compare(control.menus.length, 4)
+ compare(control.menus[0].title, "4")
+ compare(control.menus[1].title, "1")
+ compare(control.menus[2].title, "3")
+ compare(control.menus[3].title, "2")
+ compare(menusSpy.count, 4)
+
+ control.insertMenu(control.menus.length, menu.createObject(control, {title: "5"}))
+ compare(control.menus.length, 5)
+ compare(control.menus[0].title, "4")
+ compare(control.menus[1].title, "1")
+ compare(control.menus[2].title, "3")
+ compare(control.menus[3].title, "2")
+ compare(control.menus[4].title, "5")
+ compare(menusSpy.count, 5)
+
+ control.removeMenu(control.menus[4])
+ compare(control.menus.length, 4)
+ compare(control.menus[0].title, "4")
+ compare(control.menus[1].title, "1")
+ compare(control.menus[2].title, "3")
+ compare(control.menus[3].title, "2")
+ compare(menusSpy.count, 6)
+
+ control.removeMenu(control.menus[0])
+ compare(control.menus.length, 3)
+ compare(control.menus[0].title, "1")
+ compare(control.menus[1].title, "3")
+ compare(control.menus[2].title, "2")
+ compare(menusSpy.count, 7)
+
+ control.removeMenu(control.menus[1])
+ compare(control.menus.length, 2)
+ compare(control.menus[0].title, "1")
+ compare(control.menus[1].title, "2")
+ compare(menusSpy.count, 8)
+
+ control.removeMenu(control.menus[1])
+ compare(control.menus.length, 1)
+ compare(control.menus[0].title, "1")
+ compare(menusSpy.count, 9)
+
+ control.removeMenu(control.menus[0])
+ compare(control.menus.length, 0)
+ compare(menusSpy.count, 10)
+
+ control.destroy()
+ }
+
+ Component {
+ id: contentBar
+ MenuBar {
+ QtObject { objectName: "object" }
+ Menu { objectName: "menu1" }
+ Timer { objectName: "timer" }
+ Menu { objectName: "menu2" }
+ Component { Menu { } }
+ }
+ }
+
+ function test_content() {
+ var control = contentBar.createObject(testCase)
+
+ function compareObjectNames(content, names) {
+ if (content.length !== names.length)
+ return false
+ for (var i = 0; i < names.length; ++i) {
+ if (content[i].objectName !== names[i])
+ return false
+ }
+ return true
+ }
+
+ menusSpy.target = control
+ verify(menusSpy.valid)
+
+ verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", ""]))
+ verify(compareObjectNames(control.menus, ["menu1", "menu2"]))
+
+ control.addMenu(menu.createObject(control, {objectName: "menu3"}))
+ verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", "", "menu3"]))
+ verify(compareObjectNames(control.menus, ["menu1", "menu2", "menu3"]))
+ compare(menusSpy.count, 1)
+
+ control.insertMenu(0, menu.createObject(control, {objectName: "menu4"}))
+ verify(compareObjectNames(control.data, ["object", "menu1", "timer", "menu2", "", "menu3", "menu4"]))
+ verify(compareObjectNames(control.menus, ["menu4", "menu1", "menu2", "menu3"]))
+ compare(menusSpy.count, 2)
+
+ control.removeMenu(control.menus[1])
+ verify(compareObjectNames(control.data, ["object", "timer", "menu2", "", "menu3", "menu4"]))
+ verify(compareObjectNames(control.menus, ["menu4", "menu2", "menu3"]))
+ compare(menusSpy.count, 3)
+
+ control.destroy()
+ }
+
+ Component {
+ id: dynamicBar
+ MenuBar {
+ id: dbar
+ Menu { title: "static" }
+ Component.onCompleted: {
+ addMenu(menu.createObject(dbar, {title: "added"}))
+ insertMenu(0, menu.createObject(dbar, {title: "inserted"}))
+ }
+ }
+ }
+
+ function test_dynamic() {
+ var control = dynamicBar.createObject(testCase)
+
+ // insertMenu(), addMenu(), and static Menu {}
+ compare(control.menus.length, 3)
+ compare(control.menus[0].title, "inserted")
+
+ var dying = menu.createObject(control, {title: "dying"})
+ control.addMenu(dying)
+ compare(control.menus.length, 4)
+ compare(control.menus[3].title, "dying")
+ dying.destroy()
+ wait(0)
+ compare(control.menus.length, 3)
+
+ control.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_menuitem.qml b/tests/auto/platform/data/tst_menuitem.qml
new file mode 100644
index 00000000..7c2dd8f5
--- /dev/null
+++ b/tests/auto/platform/data/tst_menuitem.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "MenuItem"
+
+ Component {
+ id: menuItem
+ MenuItem { }
+ }
+
+ SignalSpy {
+ id: spy
+ }
+
+ function test_properties_data() {
+ return [
+ {tag: "enabled", signal: "enabledChanged", init: true, value: false},
+ {tag: "visible", signal: "visibleChanged", init: true, value: false},
+ {tag: "separator", signal: "separatorChanged", init: false, value: true},
+ {tag: "checkable", signal: "checkableChanged", init: false, value: true},
+ {tag: "checked", signal: "checkedChanged", init: false, value: true},
+ {tag: "role", signal: "roleChanged", init: MenuItem.TextHeuristicRole, value: MenuItem.AboutRole},
+ {tag: "text", signal: "textChanged", init: "", value: "text"},
+ {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/undo.png"},
+ {tag: "iconName", signal: "iconNameChanged", init: "", value: "edit-undo"},
+ {tag: "shortcut", signal: "shortcutChanged", init: undefined, value: StandardKey.Undo}
+ ]
+ }
+
+ function test_properties(data) {
+ var item = menuItem.createObject(testCase)
+ verify(item)
+
+ spy.target = item
+ spy.signalName = data.signal
+ verify(spy.valid)
+
+ compare(item[data.tag], data.init)
+ item[data.tag] = data.value
+ compare(spy.count, 1)
+ compare(item[data.tag], data.value)
+
+ item[data.tag] = data.value
+ compare(spy.count, 1)
+
+ spy.clear()
+ item.destroy()
+ }
+
+ function test_role() {
+ // Q_ENUMS(QPlatformMenuItem::MenuRole)
+ compare(MenuItem.NoRole, 0)
+ compare(MenuItem.TextHeuristicRole, 1)
+ compare(MenuItem.ApplicationSpecificRole, 2)
+ compare(MenuItem.AboutQtRole, 3)
+ compare(MenuItem.AboutRole, 4)
+ compare(MenuItem.PreferencesRole, 5)
+ compare(MenuItem.QuitRole, 6)
+ }
+}
diff --git a/tests/auto/platform/data/tst_menuitemgroup.qml b/tests/auto/platform/data/tst_menuitemgroup.qml
new file mode 100644
index 00000000..31fc18b1
--- /dev/null
+++ b/tests/auto/platform/data/tst_menuitemgroup.qml
@@ -0,0 +1,380 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "MenuItemGroup"
+
+ Component {
+ id: menuItemGroup
+ MenuItemGroup { }
+ }
+
+ SignalSpy {
+ id: checkedItemSpy
+ signalName: "checkedItemChanged"
+ }
+
+ SignalSpy {
+ id: itemsSpy
+ signalName: "itemsChanged"
+ }
+
+ function init() {
+ verify(!checkedItemSpy.target)
+ compare(checkedItemSpy.count, 0)
+
+ verify(!itemsSpy.target)
+ compare(itemsSpy.count, 0)
+ }
+
+ function cleanup() {
+ checkedItemSpy.target = null
+ checkedItemSpy.clear()
+
+ itemsSpy.target = null
+ itemsSpy.clear()
+ }
+
+ function test_null() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ group.addItem(null)
+ group.removeItem(null)
+
+ group.destroy()
+ }
+
+ Component {
+ id: item
+ MenuItem { }
+ }
+
+ function test_exclusive() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ compare(group.exclusive, true)
+
+ checkedItemSpy.target = group
+ verify(checkedItemSpy.valid)
+ verify(!group.checkedItem)
+
+ var item1 = item.createObject(testCase, {checked: true})
+ var item2 = item.createObject(testCase, {checked: false})
+ var item3 = item.createObject(testCase, {checked: true})
+
+ // add checked
+ group.addItem(item1)
+ compare(group.checkedItem, item1)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 1)
+
+ // add non-checked
+ group.addItem(item2)
+ compare(group.checkedItem, item1)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 1)
+
+ // add checked
+ group.addItem(item3)
+ compare(group.checkedItem, item3)
+ compare(item1.checked, false)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 2)
+
+ // change checked
+ group.checkedItem = item2
+ compare(group.checkedItem, item2)
+ compare(item1.checked, false)
+ compare(item2.checked, true)
+ compare(item3.checked, false)
+ compare(checkedItemSpy.count, 3)
+
+ // check
+ item1.checked = true
+ compare(group.checkedItem, item1)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, false)
+ compare(checkedItemSpy.count, 4)
+
+ // remove non-checked
+ group.removeItem(item2)
+ compare(group.checkedItem, item1)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, false)
+ compare(checkedItemSpy.count, 4)
+
+ // remove checked
+ group.removeItem(item1)
+ compare(group.checkedItem, null)
+ compare(item1.checked, false)
+ compare(item2.checked, false)
+ compare(item3.checked, false)
+ compare(checkedItemSpy.count, 5)
+
+ group.destroy()
+ }
+
+ function test_nonExclusive() {
+ var group = menuItemGroup.createObject(testCase, {exclusive: false})
+ verify(group)
+
+ compare(group.exclusive, false)
+
+ checkedItemSpy.target = group
+ verify(checkedItemSpy.valid)
+ verify(!group.checkedItem)
+
+ var item1 = item.createObject(testCase, {checked: true})
+ var item2 = item.createObject(testCase, {checked: false})
+ var item3 = item.createObject(testCase, {checked: true})
+
+ // add checked
+ group.addItem(item1)
+ compare(group.checkedItem, null)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 0)
+
+ // add non-checked
+ group.addItem(item2)
+ compare(group.checkedItem, null)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 0)
+
+ // add checked
+ group.addItem(item3)
+ compare(group.checkedItem, null)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 0)
+
+ // change checked
+ group.checkedItem = item2
+ compare(group.checkedItem, item2)
+ compare(item1.checked, true)
+ compare(item2.checked, true)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 1)
+
+ // check
+ item1.checked = false
+ item1.checked = true
+ compare(group.checkedItem, item2)
+ compare(item1.checked, true)
+ compare(item2.checked, true)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 1)
+
+ // remove checked
+ group.removeItem(item2)
+ compare(group.checkedItem, null)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 2)
+
+ // remove non-checked
+ group.removeItem(item1)
+ compare(group.checkedItem, null)
+ compare(item1.checked, true)
+ compare(item2.checked, false)
+ compare(item3.checked, true)
+ compare(checkedItemSpy.count, 2)
+
+ group.destroy()
+ }
+
+ function test_items() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ itemsSpy.target = group
+ verify(itemsSpy.valid)
+
+ compare(group.items.length, 0)
+ compare(group.checkedItem, null)
+
+ var item1 = item.createObject(testCase, {checked: true})
+ var item2 = item.createObject(testCase, {checked: false})
+
+ group.items = [item1, item2]
+ compare(group.items.length, 2)
+ compare(group.items[0], item1)
+ compare(group.items[1], item2)
+ compare(group.checkedItem, item1)
+ compare(itemsSpy.count, 2)
+
+ var item3 = item.createObject(testCase, {checked: true})
+
+ group.addItem(item3)
+ compare(group.items.length, 3)
+ compare(group.items[0], item1)
+ compare(group.items[1], item2)
+ compare(group.items[2], item3)
+ compare(group.checkedItem, item3)
+ compare(itemsSpy.count, 3)
+
+ group.removeItem(item1)
+ compare(group.items.length, 2)
+ compare(group.items[0], item2)
+ compare(group.items[1], item3)
+ compare(group.checkedItem, item3)
+ compare(itemsSpy.count, 4)
+
+ group.items = []
+ compare(group.items.length, 0)
+ compare(group.checkedItem, null)
+ compare(itemsSpy.count, 5)
+
+ group.destroy()
+ }
+
+ function test_itemDestroyed() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ itemsSpy.target = group
+ verify(itemsSpy.valid)
+
+ var item1 = item.createObject(testCase, {checked: true})
+
+ group.addItem(item1)
+ compare(group.items.length, 1)
+ compare(group.items[0], item1)
+ compare(group.checkedItem, item1)
+ compare(itemsSpy.count, 1)
+
+ item1.destroy()
+ wait(0)
+ compare(group.items.length, 0)
+ compare(group.checkedItem, null)
+ compare(itemsSpy.count, 2)
+
+ group.destroy()
+ }
+
+ function test_visible() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ compare(group.visible, true)
+
+ for (var i = 0; i < 3; ++i) {
+ group.addItem(item.createObject(testCase))
+ compare(group.items[i].visible, true)
+ }
+
+ group.visible = false
+ compare(group.visible, false)
+
+ for (i = 0; i < 3; ++i)
+ compare(group.items[i].visible, false)
+
+ group.items[1].visible = true
+ compare(group.items[1].visible, false)
+
+ group.items[1].visible = false
+ compare(group.items[1].visible, false)
+
+ group.visible = true
+ compare(group.visible, true)
+
+ compare(group.items[0].visible, true)
+ compare(group.items[1].visible, false)
+ compare(group.items[2].visible, true)
+
+ group.destroy()
+ }
+
+ function test_enabled() {
+ var group = menuItemGroup.createObject(testCase)
+ verify(group)
+
+ compare(group.enabled, true)
+
+ for (var i = 0; i < 3; ++i) {
+ group.addItem(item.createObject(testCase))
+ compare(group.items[i].enabled, true)
+ }
+
+ group.enabled = false
+ compare(group.enabled, false)
+
+ for (i = 0; i < 3; ++i)
+ compare(group.items[i].enabled, false)
+
+ group.items[1].enabled = true
+ compare(group.items[1].enabled, false)
+
+ group.items[1].enabled = false
+ compare(group.items[1].enabled, false)
+
+ group.enabled = true
+ compare(group.enabled, true)
+
+ compare(group.items[0].enabled, true)
+ compare(group.items[1].enabled, false)
+ compare(group.items[2].enabled, true)
+
+ group.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_menuseparator.qml b/tests/auto/platform/data/tst_menuseparator.qml
new file mode 100644
index 00000000..b04a8f31
--- /dev/null
+++ b/tests/auto/platform/data/tst_menuseparator.qml
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "MenuSeparator"
+
+ Component {
+ id: menuSeparator
+ MenuSeparator { }
+ }
+
+ function test_separator() {
+ var separator = menuSeparator.createObject(testCase)
+ verify(separator)
+
+ compare(separator.separator, true)
+
+ separator.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_messagedialog.qml b/tests/auto/platform/data/tst_messagedialog.qml
new file mode 100644
index 00000000..ceb6a872
--- /dev/null
+++ b/tests/auto/platform/data/tst_messagedialog.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ name: "MessageDialog"
+
+ Component {
+ id: messageDialog
+ MessageDialog { }
+ }
+
+ function test_instance() {
+ var dialog = messageDialog.createObject(testCase)
+ verify(dialog)
+ dialog.destroy()
+ }
+}
diff --git a/tests/auto/platform/data/tst_standardpaths.qml b/tests/auto/platform/data/tst_standardpaths.qml
new file mode 100644
index 00000000..3b8dde3e
--- /dev/null
+++ b/tests/auto/platform/data/tst_standardpaths.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ name: "StandardPaths"
+
+ function test_standardLocation() {
+ // Q_ENUMS(QStandardPaths::StandardLocation)
+ compare(StandardPaths.DesktopLocation, 0)
+ compare(StandardPaths.DocumentsLocation, 1)
+ compare(StandardPaths.FontsLocation, 2)
+ compare(StandardPaths.ApplicationsLocation, 3)
+ compare(StandardPaths.MusicLocation, 4)
+ compare(StandardPaths.MoviesLocation, 5)
+ compare(StandardPaths.PicturesLocation, 6)
+ compare(StandardPaths.TempLocation, 7)
+ compare(StandardPaths.HomeLocation, 8)
+ compare(StandardPaths.DataLocation, 9)
+ compare(StandardPaths.CacheLocation, 10)
+ compare(StandardPaths.GenericDataLocation, 11)
+ compare(StandardPaths.RuntimeLocation, 12)
+ compare(StandardPaths.ConfigLocation, 13)
+ compare(StandardPaths.DownloadLocation, 14)
+ compare(StandardPaths.GenericCacheLocation, 15)
+ compare(StandardPaths.GenericConfigLocation, 16)
+ compare(StandardPaths.AppDataLocation, 17)
+ compare(StandardPaths.AppConfigLocation, 18)
+ compare(StandardPaths.AppLocalDataLocation, StandardPaths.DataLocation)
+ }
+
+ function test_locateOptions() {
+ // Q_ENUMS(QStandardPaths::LocateOptions)
+ compare(StandardPaths.LocateFile, 0)
+ compare(StandardPaths.LocateDirectory, 1)
+ }
+}
diff --git a/tests/auto/platform/data/tst_systemtrayicon.qml b/tests/auto/platform/data/tst_systemtrayicon.qml
new file mode 100644
index 00000000..58f6401f
--- /dev/null
+++ b/tests/auto/platform/data/tst_systemtrayicon.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import Qt.labs.platform 1.0
+
+TestCase {
+ id: testCase
+ width: 200
+ height: 200
+ visible: true
+ when: windowShown
+ name: "SystemTrayIcon"
+
+ Component {
+ id: systemTrayIcon
+ SystemTrayIcon { }
+ }
+
+ SignalSpy {
+ id: spy
+ }
+
+ function test_properties_data() {
+ return [
+ {tag: "visible", signal: "visibleChanged", init: false, value: true},
+ {tag: "iconSource", signal: "iconSourceChanged", init: "", value: "qrc:/tray.png"},
+ {tag: "iconName", signal: "iconNameChanged", init: "", value: "icon-name"},
+ {tag: "tooltip", signal: "tooltipChanged", init: "", value: "tooltip"},
+ ]
+ }
+
+ function test_properties(data) {
+ var icon = systemTrayIcon.createObject(testCase)
+ verify(icon)
+
+ spy.target = icon
+ spy.signalName = data.signal
+ verify(spy.valid)
+
+ compare(icon[data.tag], data.init)
+ icon[data.tag] = data.value
+ compare(spy.count, 1)
+ compare(icon[data.tag], data.value)
+
+ icon[data.tag] = data.value
+ compare(spy.count, 1)
+
+ spy.clear()
+ icon.destroy()
+ }
+}
diff --git a/tests/auto/platform/platform.pro b/tests/auto/platform/platform.pro
new file mode 100644
index 00000000..cc537b32
--- /dev/null
+++ b/tests/auto/platform/platform.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = tst_platform
+CONFIG += qmltestcase
+
+SOURCES += \
+ $$PWD/tst_platform.cpp
+
+OTHER_FILES += \
+ $$PWD/data/*.qml
+
+TESTDATA += \
+ $$PWD/data/tst_*
diff --git a/src/imports/controls/material/Ripple.qml b/tests/auto/platform/tst_platform.cpp
index 15650384..3866f7c2 100644
--- a/src/imports/controls/material/Ripple.qml
+++ b/tests/auto/platform/tst_platform.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
@@ -34,18 +34,5 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Controls.Material 2.0
-
-Rectangle {
- property Item control
- property bool colored: false
-
- radius: width / 2
- scale: 2.5
- color: colored ? control.Material.checkBoxCheckedRippleColor : control.Material.checkBoxUncheckedRippleColor
-
- Behavior on opacity {
- NumberAnimation {}
- }
-}
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(tst_platform)
diff --git a/tests/auto/popup/data/activeFocusOnClose1.qml b/tests/auto/popup/data/activeFocusOnClose1.qml
index e1a4cec2..d6b00110 100644
--- a/tests/auto/popup/data/activeFocusOnClose1.qml
+++ b/tests/auto/popup/data/activeFocusOnClose1.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/popup/data/activeFocusOnClose2.qml b/tests/auto/popup/data/activeFocusOnClose2.qml
index 9418d521..ef5ccfc6 100644
--- a/tests/auto/popup/data/activeFocusOnClose2.qml
+++ b/tests/auto/popup/data/activeFocusOnClose2.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/popup/data/applicationwindow.qml b/tests/auto/popup/data/applicationwindow.qml
index 2e868192..9b85eb85 100644
--- a/tests/auto/popup/data/applicationwindow.qml
+++ b/tests/auto/popup/data/applicationwindow.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
width: 400
diff --git a/tests/auto/popup/popup.pro b/tests/auto/popup/popup.pro
index af4db794..9b3ee75a 100644
--- a/tests/auto/popup/popup.pro
+++ b/tests/auto/popup/popup.pro
@@ -11,4 +11,4 @@ include (../shared/util.pri)
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/pressandhold/data/dependencies.qml b/tests/auto/pressandhold/data/dependencies.qml
index caf89569..cd3e88ba 100644
--- a/tests/auto/pressandhold/data/dependencies.qml
+++ b/tests/auto/pressandhold/data/dependencies.qml
@@ -1,4 +1,4 @@
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Control { }
diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp
index 713cc60c..2d209788 100644
--- a/tests/auto/pressandhold/tst_pressandhold.cpp
+++ b/tests/auto/pressandhold/tst_pressandhold.cpp
@@ -67,10 +67,10 @@ void tst_PressAndHold::pressAndHold_data()
QTest::addColumn<QByteArray>("data");
QTest::addColumn<QByteArray>("signal");
- QTest::newRow("Button") << QByteArray("import QtQuick.Controls 2.0; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold()));
- QTest::newRow("SwipeDelegate") << QByteArray("import QtQuick.Controls 2.0; SwipeDelegate { text: 'SwipeDelegate' }") << QByteArray(SIGNAL(pressAndHold()));
- QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.0; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
- QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.0; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
+ QTest::newRow("Button") << QByteArray("import QtQuick.Controls 2.1; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold()));
+ QTest::newRow("SwipeDelegate") << QByteArray("import QtQuick.Controls 2.1; SwipeDelegate { text: 'SwipeDelegate' }") << QByteArray(SIGNAL(pressAndHold()));
+ QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.1; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
+ QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.1; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
}
void tst_PressAndHold::pressAndHold()
@@ -144,8 +144,8 @@ void tst_PressAndHold::keepSelection_data()
{
QTest::addColumn<QByteArray>("data");
- QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.0; TextField { text: 'TextField' }");
- QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.0; TextArea { text: 'TextArea' }");
+ QTest::newRow("TextField") << QByteArray("import QtQuick.Controls 2.1; TextField { text: 'TextField' }");
+ QTest::newRow("TextArea") << QByteArray("import QtQuick.Controls 2.1; TextArea { text: 'TextArea' }");
}
void tst_PressAndHold::keepSelection()
diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml
index e1e100d7..9985997b 100644
--- a/tests/auto/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml
@@ -41,9 +41,9 @@
import QtQuick 2.2
import QtQuick.Window 2.2
import QtTest 1.0
-import QtQuick.Templates 2.0 as T
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
+import QtQuick.Templates 2.1 as T
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
TestCase {
id: testCase
@@ -596,7 +596,7 @@ TestCase {
verify(window)
verify(window.pane)
- var control = Qt.createQmlObject("import QtQuick.Controls 2.0; " + data.type + " { }", window.pane)
+ var control = Qt.createQmlObject("import QtQuick.Controls 2.1; " + data.type + " { }", window.pane)
verify(control)
compare(control.font[data.attribute], data.value)
diff --git a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro
index eac9bdc4..dac2176a 100644
--- a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro
+++ b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.pro
@@ -6,10 +6,10 @@ SOURCES += \
$$PWD/tst_qquickmaterialstyle.cpp
RESOURCES += \
- $$PWD/qquickmaterialstyle.qrc
+ $$PWD/qtquickcontrols2.conf
OTHER_FILES += \
- $$PWD/data/*
+ $$PWD/data/*.qml
TESTDATA += \
$$PWD/data/tst_*
diff --git a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc b/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc
deleted file mode 100644
index 53ba6450..00000000
--- a/tests/auto/qquickmaterialstyle/qquickmaterialstyle.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>qtquickcontrols2.conf</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml b/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
index a1657a69..853506bd 100644
--- a/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
+++ b/tests/auto/qquickmaterialstyleconf/data/applicationwindow.qml
@@ -40,6 +40,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
+import QtQuick.Controls.Material 2.0
ApplicationWindow {
width: 400
diff --git a/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.pro b/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.pro
index fe8953e9..af4e5349 100644
--- a/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.pro
+++ b/tests/auto/qquickmaterialstyleconf/qquickmaterialstyleconf.pro
@@ -13,5 +13,5 @@ RESOURCES += qquickmaterialstyleconf.qrc
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/qquickstyle/data/dependencies.qml b/tests/auto/qquickstyle/data/dependencies.qml
new file mode 100644
index 00000000..cd3e88ba
--- /dev/null
+++ b/tests/auto/qquickstyle/data/dependencies.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+
+Control { }
diff --git a/tests/auto/qquickstyle/qquickstyle.pro b/tests/auto/qquickstyle/qquickstyle.pro
index b6173c1b..5514685a 100644
--- a/tests/auto/qquickstyle/qquickstyle.pro
+++ b/tests/auto/qquickstyle/qquickstyle.pro
@@ -5,3 +5,4 @@ SOURCES += tst_qquickstyle.cpp
osx:CONFIG -= app_bundle
QT += quickcontrols2 testlib
+QT_PRIVATE += core-private gui-private quickcontrols2-private
diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp
index b4da3045..15edc67b 100644
--- a/tests/auto/qquickstyle/tst_qquickstyle.cpp
+++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp
@@ -38,15 +38,28 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <QtQuickControls2/private/qquickstyle_p.h>
+#include <QtGui/private/qguiapplication_p.h>
class tst_QQuickStyle : public QObject
{
Q_OBJECT
private slots:
+ void init();
void lookup();
+ void commandLineArgument();
+ void environmentVariables();
};
+void tst_QQuickStyle::init()
+{
+ QQuickStylePrivate::reset();
+ QGuiApplicationPrivate::styleOverride.clear();
+ qunsetenv("QT_QUICK_CONTROLS_STYLE");
+ qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE");
+}
+
void tst_QQuickStyle::lookup()
{
QVERIFY(QQuickStyle::name().isEmpty());
@@ -58,7 +71,7 @@ void tst_QQuickStyle::lookup()
QQmlEngine engine;
QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Control { }", QUrl());
+ component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Control { }", QUrl());
QScopedPointer<QObject> object(component.create());
QVERIFY(!object.isNull());
@@ -67,6 +80,20 @@ void tst_QQuickStyle::lookup()
QVERIFY(!QQuickStyle::path().isEmpty());
}
+void tst_QQuickStyle::commandLineArgument()
+{
+ QGuiApplicationPrivate::styleOverride = "CmdLineArgStyle";
+ QCOMPARE(QQuickStyle::name(), QString("CmdLineArgStyle"));
+}
+
+void tst_QQuickStyle::environmentVariables()
+{
+ qputenv("QT_QUICK_CONTROLS_STYLE", "EnvVarStyle");
+ qputenv("QT_QUICK_CONTROLS_FALLBACK_STYLE", "EnvVarFallbackStyle");
+ QCOMPARE(QQuickStyle::name(), QString("EnvVarStyle"));
+ QCOMPARE(QQuickStylePrivate::fallbackStyle(), QString("EnvVarFallbackStyle"));
+}
+
QTEST_MAIN(tst_QQuickStyle)
#include "tst_qquickstyle.moc"
diff --git a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml b/tests/auto/qquickstyleselector/ResourceStyle/Button.qml
index 5b08222c..ee17c230 100644
--- a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml
+++ b/tests/auto/qquickstyleselector/ResourceStyle/Button.qml
@@ -1,2 +1,2 @@
-import QtQuick.Templates 2.0 as T
+import QtQuick.Templates 2.1 as T
T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Button.qml b/tests/auto/qquickstyleselector/data/Button.qml
index 5b08222c..ee17c230 100644
--- a/tests/auto/qquickstyleselector/data/Button.qml
+++ b/tests/auto/qquickstyleselector/data/Button.qml
@@ -1,2 +1,2 @@
-import QtQuick.Templates 2.0 as T
+import QtQuick.Templates 2.1 as T
T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Control.qml b/tests/auto/qquickstyleselector/data/Control.qml
new file mode 100644
index 00000000..697662f6
--- /dev/null
+++ b/tests/auto/qquickstyleselector/data/Control.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.1 as T
+T.Control { }
diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml
new file mode 100644
index 00000000..ee17c230
--- /dev/null
+++ b/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.1 as T
+T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml
new file mode 100644
index 00000000..8879d93f
--- /dev/null
+++ b/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.1 as T
+T.Label { }
diff --git a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml b/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml
index 5b08222c..ee17c230 100644
--- a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml
+++ b/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml
@@ -1,2 +1,2 @@
-import QtQuick.Templates 2.0 as T
+import QtQuick.Templates 2.1 as T
T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Label.qml b/tests/auto/qquickstyleselector/data/Label.qml
new file mode 100644
index 00000000..8879d93f
--- /dev/null
+++ b/tests/auto/qquickstyleselector/data/Label.qml
@@ -0,0 +1,2 @@
+import QtQuick.Templates 2.1 as T
+T.Label { }
diff --git a/tests/auto/qquickstyleselector/qquickstyleselector.pro b/tests/auto/qquickstyleselector/qquickstyleselector.pro
index c56e5732..3ad4d516 100644
--- a/tests/auto/qquickstyleselector/qquickstyleselector.pro
+++ b/tests/auto/qquickstyleselector/qquickstyleselector.pro
@@ -15,5 +15,5 @@ RESOURCES += resourcestyle
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
index 6c2aebe4..1e7d7add 100644
--- a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
+++ b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
@@ -36,6 +36,7 @@
#include <QtTest/qtest.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <QtQuickControls2/private/qquickstyle_p.h>
#include <QtQuickControls2/private/qquickstyleselector_p.h>
#include "../shared/util.h"
@@ -44,24 +45,82 @@ class tst_QQuickStyleSelector : public QQmlDataTest
Q_OBJECT
private slots:
+ void initTestCase();
+
void select_data();
void select();
};
+void tst_QQuickStyleSelector::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ QQuickStylePrivate::init(dataDirectoryUrl());
+}
+
void tst_QQuickStyleSelector::select_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<QString>("style");
QTest::addColumn<QString>("path");
+ QTest::addColumn<QString>("fallback");
QTest::addColumn<QString>("expected");
- QTest::newRow("empty") << "Button.qml" << "" << dataDirectory() << testFileUrl("Button.qml").toString();
- QTest::newRow("no such dir") << "Button.qml" << "Foo" << dataDirectory() << testFileUrl("Button.qml").toString();
- QTest::newRow("no such file") << "Foo.qml" << "FileSystemStyle" << dataDirectory() << testFileUrl("Foo.qml").toString();
- QTest::newRow("relative/path/to/FileSystemStyle") << "Button.qml" << "FileSystemStyle" << "data" << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow("/absolute/path/to/FileSystemStyle") << "Button.qml" << "FileSystemStyle" << dataDirectory() << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow(":/ResourceStyle") << "Button.qml" << "ResourceStyle" << ":/" << "qrc:/ResourceStyle/Button.qml";
- QTest::newRow("qrc:/ResourceStyle") << "Button.qml" << "ResourceStyle" << "qrc:/" << "qrc:/ResourceStyle/Button.qml";
+ // Control.qml exists only in the default style
+ QTest::newRow("control") << "Control.qml" << "" << "data" << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/control") << "Control.qml" << "" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("fs/control") << "Control.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/fs/control") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow(":/control") << "Control.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("qrc:/control") << "Control.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("nosuch/control") << "Control.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/nosuch/control") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
+
+ QTest::newRow("control->base") << "Control.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/control->base") << "Control.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("fs/control->base") << "Control.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/fs/control->base") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow(":/control->base") << "Control.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("qrc:/control->base") << "Control.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("nosuch/control->base") << "Control.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
+ QTest::newRow("/nosuch/control->base") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
+
+ // Label.qml exists in the default and fallback styles
+ QTest::newRow("label") << "Label.qml" << "" << "data" << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("/label") << "Label.qml" << "" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("fs/label") << "Label.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("/fs/label") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow(":/label") << "Label.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("qrc:/label") << "Label.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("nosuch/label") << "Label.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Label.qml").toString();
+ QTest::newRow("/nosuch/label") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
+
+ QTest::newRow("label->base") << "Label.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("/label->base") << "Label.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Label.qml").toString();
+ QTest::newRow("fs/label->base") << "Label.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("/fs/label->base") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow(":/label->base") << "Label.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("qrc:/label->base") << "Label.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("nosuch/label->base") << "Label.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+ QTest::newRow("/nosuch/label->base") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
+
+ // Button.qml exists in all styles including the fs and qrc styles
+ QTest::newRow("button") << "Button.qml" << "" << "data" << "" << testFileUrl("Button.qml").toString();
+ QTest::newRow("/button") << "Button.qml" << "" << dataDirectory() << "" << testFileUrl("Button.qml").toString();
+ QTest::newRow("fs/button") << "Button.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("FileSystemStyle/Button.qml").toString();
+ QTest::newRow("/fs/button") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("FileSystemStyle/Button.qml").toString();
+ QTest::newRow(":/button") << "Button.qml" << "ResourceStyle" << ":/" << "" << "qrc:/ResourceStyle/Button.qml";
+ QTest::newRow("qrc:/button") << "Button.qml" << "ResourceStyle" << "qrc:/" << "" << "qrc:/ResourceStyle/Button.qml";
+ QTest::newRow("nosuch/button") << "Button.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Button.qml").toString();
+ QTest::newRow("/nosuch/button") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Button.qml").toString();
+
+ QTest::newRow("button->base") << "Button.qml" << "" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
+ QTest::newRow("/button->base") << "Button.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Button.qml").toString();
+ QTest::newRow("fs/button->base") << "Button.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
+ QTest::newRow("/fs/button->base") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
+ QTest::newRow(":/button->base") << "Button.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml";
+ QTest::newRow("qrc:/button->base") << "Button.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml";
+ QTest::newRow("nosuch/button->base") << "Button.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
+ QTest::newRow("/nosuch/button->base") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
}
void tst_QQuickStyleSelector::select()
@@ -69,9 +128,11 @@ void tst_QQuickStyleSelector::select()
QFETCH(QString, file);
QFETCH(QString, style);
QFETCH(QString, path);
+ QFETCH(QString, fallback);
QFETCH(QString, expected);
QQuickStyle::setStyle(QDir(path).filePath(style));
+ QQuickStyle::setFallbackStyle(fallback);
QQuickStyleSelector selector;
selector.setBaseUrl(dataDirectoryUrl());
diff --git a/tests/auto/qquickuniversalstyle/data/tst_universal.qml b/tests/auto/qquickuniversalstyle/data/tst_universal.qml
index 7ee14da8..2934b444 100644
--- a/tests/auto/qquickuniversalstyle/data/tst_universal.qml
+++ b/tests/auto/qquickuniversalstyle/data/tst_universal.qml
@@ -41,8 +41,8 @@
import QtQuick 2.2
import QtQuick.Window 2.2
import QtTest 1.0
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Universal 2.1
TestCase {
id: testCase
@@ -406,7 +406,7 @@ TestCase {
verify(window)
verify(window.pane)
- var control = Qt.createQmlObject("import QtQuick.Controls 2.0; " + data.type + " { }", window.pane)
+ var control = Qt.createQmlObject("import QtQuick.Controls 2.1; " + data.type + " { }", window.pane)
verify(control)
compare(control.font[data.attribute], data.value)
diff --git a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro
index 83bd19a5..f77d812f 100644
--- a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro
+++ b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.pro
@@ -6,10 +6,10 @@ SOURCES += \
$$PWD/tst_qquickuniversalstyle.cpp
RESOURCES += \
- $$PWD/qquickuniversalstyle.qrc
+ $$PWD/qtquickcontrols2.conf
OTHER_FILES += \
- $$PWD/data/*
+ $$PWD/data/*.qml
TESTDATA += \
$$PWD/data/tst_*
diff --git a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc b/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc
deleted file mode 100644
index 53ba6450..00000000
--- a/tests/auto/qquickuniversalstyle/qquickuniversalstyle.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>qtquickcontrols2.conf</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/qquickuniversalstyleconf/data/applicationwindow.qml b/tests/auto/qquickuniversalstyleconf/data/applicationwindow.qml
index a1657a69..e2023cf7 100644
--- a/tests/auto/qquickuniversalstyleconf/data/applicationwindow.qml
+++ b/tests/auto/qquickuniversalstyleconf/data/applicationwindow.qml
@@ -40,6 +40,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.0
+import QtQuick.Controls.Universal 2.0
ApplicationWindow {
width: 400
diff --git a/tests/auto/qquickuniversalstyleconf/qquickuniversalstyleconf.pro b/tests/auto/qquickuniversalstyleconf/qquickuniversalstyleconf.pro
index 9aaedbee..6236f075 100644
--- a/tests/auto/qquickuniversalstyleconf/qquickuniversalstyleconf.pro
+++ b/tests/auto/qquickuniversalstyleconf/qquickuniversalstyleconf.pro
@@ -13,5 +13,5 @@ RESOURCES += qquickuniversalstyleconf.qrc
TESTDATA = data/*
OTHER_FILES += \
- data/*
+ data/*.qml
diff --git a/tests/auto/revisions/data/dependencies.qml b/tests/auto/revisions/data/dependencies.qml
new file mode 100644
index 00000000..6f21af18
--- /dev/null
+++ b/tests/auto/revisions/data/dependencies.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.8
+import QtQuick.Controls 2.0
+import QtQuick.Controls.Material 2.0
+import QtQuick.Controls.Universal 2.0
+
+Control { }
diff --git a/tests/auto/revisions/revisions.pro b/tests/auto/revisions/revisions.pro
new file mode 100644
index 00000000..b3c448da
--- /dev/null
+++ b/tests/auto/revisions/revisions.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_revisions
+SOURCES += tst_revisions.cpp
+
+macos:CONFIG -= app_bundle
+
+QT += qml testlib
diff --git a/tests/auto/revisions/tst_revisions.cpp b/tests/auto/revisions/tst_revisions.cpp
new file mode 100644
index 00000000..33649d62
--- /dev/null
+++ b/tests/auto/revisions/tst_revisions.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+
+class tst_revisions : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void revisions_data();
+ void revisions();
+};
+
+void tst_revisions::revisions_data()
+{
+ QTest::addColumn<int>("revision");
+
+ // In theory, this could be done in a loop from 5.7 to QT_VERSION, but
+ // the test would immediately fail when the Qt version was bumped up.
+ // Therefore it is better to just add these lines by hand when adding
+ // new revisions.
+ QTest::newRow("2.0") << 0; // Qt 5.7
+ QTest::newRow("2.1") << 1; // Qt 5.8
+}
+
+void tst_revisions::revisions()
+{
+ QFETCH(int, revision);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QString("import QtQuick 2.0; \
+ import QtQuick.Controls 2.%1; \
+ import QtQuick.Controls.impl 2.%1; \
+ import QtQuick.Controls.Material 2.%1; \
+ import QtQuick.Controls.Material.impl 2.%1; \
+ import QtQuick.Controls.Universal 2.%1; \
+ import QtQuick.Controls.Universal.impl 2.%1; \
+ Control { }").arg(revision).toUtf8(), QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+}
+
+QTEST_MAIN(tst_revisions)
+
+#include "tst_revisions.moc"
diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST
index 09cc7f3d..768f3985 100644
--- a/tests/auto/sanity/BLACKLIST
+++ b/tests/auto/sanity/BLACKLIST
@@ -14,3 +14,7 @@
*
[attachedObjects:universal/ComboBox.qml]
*
+[functions:material/RectangularGlow.qml]
+*
+[anchors:material/RectangularGlow.qml]
+*
diff --git a/tests/auto/sanity/data/dependencies.qml b/tests/auto/sanity/data/dependencies.qml
index caf89569..cd3e88ba 100644
--- a/tests/auto/sanity/data/dependencies.qml
+++ b/tests/auto/sanity/data/dependencies.qml
@@ -1,4 +1,4 @@
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Control { }
diff --git a/tests/auto/snippets/data/dependencies.qml b/tests/auto/snippets/data/dependencies.qml
index aed6ce87..6c897566 100644
--- a/tests/auto/snippets/data/dependencies.qml
+++ b/tests/auto/snippets/data/dependencies.qml
@@ -1,6 +1,8 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
import Qt.labs.calendar 1.0
Control { }
diff --git a/tests/auto/snippets/snippets.pro b/tests/auto/snippets/snippets.pro
index 3147fb4b..b14ac8ea 100644
--- a/tests/auto/snippets/snippets.pro
+++ b/tests/auto/snippets/snippets.pro
@@ -11,7 +11,7 @@ SOURCES += \
$$PWD/tst_snippets.cpp
OTHER_FILES += \
- $$PWD/data/*
+ $$PWD/data/*.qml
TESTDATA += \
$$PWD/data/*
diff --git a/tests/benchmarks/creationtime/data/dependencies.qml b/tests/benchmarks/creationtime/data/dependencies.qml
index 4c1702cc..6b6d951b 100644
--- a/tests/benchmarks/creationtime/data/dependencies.qml
+++ b/tests/benchmarks/creationtime/data/dependencies.qml
@@ -1,7 +1,7 @@
import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
import Qt.labs.calendar 1.0
Control { }
diff --git a/tests/benchmarks/objectcount/data/dependencies.qml b/tests/benchmarks/objectcount/data/dependencies.qml
index 4c1702cc..6b6d951b 100644
--- a/tests/benchmarks/objectcount/data/dependencies.qml
+++ b/tests/benchmarks/objectcount/data/dependencies.qml
@@ -1,7 +1,7 @@
import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
import Qt.labs.calendar 1.0
Control { }
diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp
index 549d7eef..14a950f3 100644
--- a/tests/benchmarks/objectcount/tst_objectcount.cpp
+++ b/tests/benchmarks/objectcount/tst_objectcount.cpp
@@ -84,7 +84,7 @@ void tst_ObjectCount::init()
// warmup
QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Item { Button {} }", QUrl());
+ component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Item { Button {} }", QUrl());
delete component.create();
}
diff --git a/tests/manual/buttons/ButtonLoader.qml b/tests/manual/buttons/ButtonLoader.qml
new file mode 100644
index 00000000..8793d98f
--- /dev/null
+++ b/tests/manual/buttons/ButtonLoader.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+import QtQuick.Controls 2.1
+
+Item {
+ id: root
+ implicitWidth: activeButton.implicitWidth
+ implicitHeight: activeButton.implicitHeight
+
+ property bool round: false
+
+ property string text
+ property bool flat
+ property bool hoverEnabled
+ property bool highlighted
+ property bool checked
+ property var down: undefined
+
+ property AbstractButton activeButton: round ? roundButton : button
+
+ Button {
+ id: button
+ visible: !round
+ text: root.text
+ flat: root.flat
+ hoverEnabled: root.hoverEnabled
+ highlighted: root.highlighted
+ checked: root.checked
+ down: root.down
+ enabled: root.enabled
+ }
+
+ RoundButton {
+ id: roundButton
+ visible: round
+ text: "\u2713"
+ flat: root.flat
+ hoverEnabled: root.hoverEnabled
+ highlighted: root.highlighted
+ checked: root.checked
+ down: root.down
+ enabled: root.enabled
+
+ Label {
+ text: root.text
+ font.pixelSize: roundButton.contentItem.font.pixelSize * 0.5
+ anchors.top: parent.bottom
+ anchors.topMargin: 2
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+}
diff --git a/tests/manual/buttons/buttons.cpp b/tests/manual/buttons/buttons.cpp
new file mode 100644
index 00000000..2f73e3d2
--- /dev/null
+++ b/tests/manual/buttons/buttons.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl("qrc:/buttons.qml"));
+
+ return app.exec();
+}
diff --git a/tests/manual/buttons/buttons.pro b/tests/manual/buttons/buttons.pro
new file mode 100644
index 00000000..2cb1c14c
--- /dev/null
+++ b/tests/manual/buttons/buttons.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = buttons
+QT += qml quickcontrols2
+
+SOURCES += buttons.cpp
+RESOURCES += $$files(*.qml)
diff --git a/tests/manual/buttons/buttons.qml b/tests/manual/buttons/buttons.qml
new file mode 100644
index 00000000..b3aba775
--- /dev/null
+++ b/tests/manual/buttons/buttons.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
+
+ApplicationWindow {
+ id: window
+ visible: true
+ title: "Buttons"
+
+ Component.onCompleted: {
+ var pane = repeater.itemAt(0)
+ width = pane.implicitWidth * 2 + flickable.leftMargin + flickable.rightMargin + flow.spacing
+ height = header.height + pane.implicitHeight * 2 + flickable.topMargin + flickable.bottomMargin + flow.spacing
+ }
+
+ header: ToolBar {
+ Row {
+ spacing: 20
+ anchors.right: parent.right
+ CheckBox {
+ id: hoverBox
+ text: "Hover"
+ checked: true
+ }
+ CheckBox {
+ id: roundBox
+ text: "Round"
+ checked: false
+ }
+ }
+ }
+
+ Flickable {
+ id: flickable
+ anchors.fill: parent
+
+ topMargin: 40
+ leftMargin: 40
+ rightMargin: 40
+ bottomMargin: 40
+
+ contentHeight: flow.implicitHeight
+
+ Flow {
+ id: flow
+ spacing: 40
+ width: flickable.width - flickable.leftMargin - flickable.rightMargin
+
+ Repeater {
+ id: repeater
+
+ model: [
+ { title: "Normal", theme: Material.Light, flat: false },
+ { title: "Flat", theme: Material.Light, flat: true },
+ { title: "Normal", theme: Material.Dark, flat: false },
+ { title: "Flat", theme: Material.Dark, flat: true }
+ ]
+
+ Pane {
+ Material.elevation: 8
+ Material.theme: modelData.theme
+ Universal.theme: modelData.theme
+
+ GroupBox {
+ title: modelData.title
+ background.visible: false
+
+ Grid {
+ columns: 4
+ spacing: 20
+ padding: 20
+
+ ButtonLoader { text: "Normal"; flat: modelData.flat; hoverEnabled: hoverBox.checked; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; enabled: false; round: roundBox.checked }
+ ButtonLoader { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; down: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; down: true; enabled: false; round: roundBox.checked }
+
+ ButtonLoader { text: "Checked"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; enabled: false; round: roundBox.checked }
+ ButtonLoader { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; down: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; checked: true; down: true; enabled: false; round: roundBox.checked }
+
+ ButtonLoader { text: "Highlighted"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; enabled: false; round: roundBox.checked }
+ ButtonLoader { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; down: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; down: true; enabled: false; round: roundBox.checked }
+
+ ButtonLoader { text: "Hi-checked"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; enabled: false; round: roundBox.checked }
+ ButtonLoader { text: "Down"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; down: true; round: roundBox.checked }
+ ButtonLoader { text: "Disabled"; flat: modelData.flat; hoverEnabled: hoverBox.checked; highlighted: true; checked: true; down: true; enabled: false; round: roundBox.checked }
+ }
+ }
+ }
+ }
+ }
+
+ ScrollIndicator.vertical: ScrollIndicator { }
+ }
+}
diff --git a/tests/manual/fonts/main.qml b/tests/manual/fonts/main.qml
index 883226a7..089906ee 100644
--- a/tests/manual/fonts/main.qml
+++ b/tests/manual/fonts/main.qml
@@ -39,8 +39,8 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
-import QtQuick.Templates 2.0 as T
+import QtQuick.Controls 2.1
+import QtQuick.Templates 2.1 as T
import QtQuick.Layouts 1.2
ApplicationWindow {
diff --git a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml
index 5c655cab..bb7efc5d 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-busyindicator.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: busyIndicator.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-button.qml b/tests/manual/gifs/data/qtquickcontrols2-button.qml
index 31b8da47..65262589 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-button.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-button.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: button.width
diff --git a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml
index df80a417..184ab339 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-checkdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: column.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml
index b280b385..98ce78a1 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: dial.implicitWidth + 20
diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml
index 7ecda085..d5065f6d 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: dial.implicitWidth + 20
diff --git a/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml
index 18bf942c..6aab7fc7 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-itemdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: column.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-menu.qml b/tests/manual/gifs/data/qtquickcontrols2-menu.qml
index 332e4d2b..60850a28 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-menu.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-menu.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
// TODO: restore and finish https://codereview.qt-project.org/#/c/123948/
ApplicationWindow {
diff --git a/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml
index 60a0424f..77480ef0 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-radiodelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: column.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml b/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml
index 4f764f8a..ece806d7 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-rangeslider.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: slider.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-slider.qml b/tests/manual/gifs/data/qtquickcontrols2-slider.qml
index d109b1d2..412ce307 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-slider.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-slider.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: slider.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml
index d019368e..7d6da848 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: swipeDelegate.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml
index ecc7924e..74b69773 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: swipeDelegate.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml
index 9dfee7f5..76c65e32 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: swipeDelegate.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-switch.qml b/tests/manual/gifs/data/qtquickcontrols2-switch.qml
index 44d07e24..7bdaf102 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-switch.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-switch.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: 100
diff --git a/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml
index a0ee4e03..e65890a1 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-switchdelegate.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: column.implicitWidth
diff --git a/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml b/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml
index 3d0568e1..ff38277b 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-tabbar.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Window {
width: 300
diff --git a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
index e1139177..b610d099 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -38,37 +38,35 @@
**
****************************************************************************/
-import QtQuick 2.6
-import QtQuick.Window 2.0
-import QtQuick.Controls 2.0
+import QtQuick 2.8
+import QtQuick.Window 2.2
+import QtQuick.Controls 2.1
Window {
- width: 200
- height: 200
+ width: frame.implicitWidth + 10
+ height: frame.implicitHeight + 10
visible: true
- Frame {
- padding: 0
- anchors.centerIn: parent
- width: row.implicitWidth
- height: row.implicitHeight
-
- FontMetrics {
- id: fontMetrics
- }
+ function formatText(count, modelData) {
+ var data = count === 12 ? modelData + 1 : modelData;
+ return data.toString().length < 2 ? "0" + data : data;
+ }
- Component {
- id: delegateComponent
+ Component {
+ id: delegateComponent
- Text {
- text: modelData.toString().length < 2 ? "0" + modelData : modelData
- color: "#666666"
- opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: fontMetrics.font.pixelSize * 1.25
- }
+ Label {
+ text: formatText(Tumbler.tumbler.count, modelData)
+ opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
}
+ }
+
+ Frame {
+ id: frame
+ padding: 0
+ anchors.centerIn: parent
Row {
id: row
@@ -76,44 +74,20 @@ Window {
Tumbler {
id: hoursTumbler
model: 12
- delegate: Text {
- text: (modelData.toString().length < 2 ? "0" : "") + (modelData + 1)
- color: "#666666"
- opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pixelSize: fontMetrics.font.pixelSize * 1.25
- }
- width: 50
- height: 150
+ delegate: delegateComponent
}
Tumbler {
id: minutesTumbler
- currentIndex: 6
model: 60
delegate: delegateComponent
- width: 50
- height: 150
}
Tumbler {
id: amPmTumbler
+ wrap: false
model: ["AM", "PM"]
delegate: delegateComponent
- width: 50
- height: 150
- contentItem: ListView {
- anchors.fill: parent
- model: amPmTumbler.model
- delegate: amPmTumbler.delegate
-
- snapMode: ListView.SnapToItem
- highlightRangeMode: ListView.StrictlyEnforceRange
- preferredHighlightBegin: height / 2 - (height / 3 / 2)
- preferredHighlightEnd: height / 2 + (height / 3 / 2)
- clip: true
- }
}
}
}
diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp
index 1e3f141f..5a2ebdca 100644
--- a/tests/manual/gifs/gifrecorder.cpp
+++ b/tests/manual/gifs/gifrecorder.cpp
@@ -243,7 +243,7 @@ void GifRecorder::waitForFinish()
if (mHighQuality) {
// Indicate the end of recording and the beginning of conversion.
QQmlComponent busyComponent(&mEngine);
- busyComponent.setData("import QtQuick 2.6; import QtQuick.Controls 2.0; Rectangle { anchors.fill: parent; " \
+ busyComponent.setData("import QtQuick 2.6; import QtQuick.Controls 2.1; Rectangle { anchors.fill: parent; " \
"BusyIndicator { width: 32; height: 32; anchors.centerIn: parent } }", QUrl());
QCOMPARE(busyComponent.status(), QQmlComponent::Ready);
QQuickItem *busyRect = qobject_cast<QQuickItem*>(busyComponent.create());
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index d3fb5f6d..8849e593 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -144,7 +144,7 @@ void tst_Gifs::tumblerWrap()
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
- gifRecorder.setRecordingDuration(4);
+ gifRecorder.setRecordingDuration(5);
gifRecorder.setQmlFileName("qtquickcontrols2-tumbler-wrap.qml");
gifRecorder.start();
@@ -169,37 +169,40 @@ void tst_Gifs::tumblerWrap()
QTest::mouseMove(window, QPoint(105, 158), 10);
QTest::mouseMove(window, QPoint(105, 162), 13);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(105, 162), 0);
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 130), 1098);
- QTest::mouseMove(window, QPoint(154, 129), 50);
- QTest::mouseMove(window, QPoint(153, 128), 0);
- QTest::mouseMove(window, QPoint(153, 125), 16);
- QTest::mouseMove(window, QPoint(152, 121), 0);
- QTest::mouseMove(window, QPoint(152, 117), 17);
- QTest::mouseMove(window, QPoint(151, 113), 0);
- QTest::mouseMove(window, QPoint(151, 106), 16);
- QTest::mouseMove(window, QPoint(150, 99), 1);
- QTest::mouseMove(window, QPoint(148, 93), 16);
- QTest::mouseMove(window, QPoint(148, 88), 0);
- QTest::mouseMove(window, QPoint(148, 84), 17);
- QTest::mouseMove(window, QPoint(147, 81), 0);
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 81), 0);
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 74), 550);
- QTest::mouseMove(window, QPoint(147, 75), 17);
- QTest::mouseMove(window, QPoint(147, 76), 17);
- QTest::mouseMove(window, QPoint(147, 80), 0);
- QTest::mouseMove(window, QPoint(148, 85), 16);
- QTest::mouseMove(window, QPoint(148, 92), 0);
- QTest::mouseMove(window, QPoint(148, 103), 17);
- QTest::mouseMove(window, QPoint(150, 119), 17);
- QTest::mouseMove(window, QPoint(151, 138), 16);
- QTest::mouseMove(window, QPoint(151, 145), 1);
- QTest::mouseMove(window, QPoint(153, 151), 16);
- QTest::mouseMove(window, QPoint(153, 157), 0);
- QTest::mouseMove(window, QPoint(153, 163), 17);
- QTest::mouseMove(window, QPoint(153, 167), 0);
- QTest::mouseMove(window, QPoint(155, 171), 17);
- QTest::mouseMove(window, QPoint(155, 175), 0);
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(155, 175), 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 100), 1098);
+ QTest::mouseMove(window, QPoint(154, 99), 16);
+ QTest::mouseMove(window, QPoint(153, 98), 16);
+ QTest::mouseMove(window, QPoint(153, 95), 16);
+ QTest::mouseMove(window, QPoint(152, 91), 15);
+ QTest::mouseMove(window, QPoint(152, 87), 14);
+ QTest::mouseMove(window, QPoint(151, 83), 13);
+ QTest::mouseMove(window, QPoint(151, 86), 13);
+ QTest::mouseMove(window, QPoint(150, 79), 12);
+ QTest::mouseMove(window, QPoint(148, 73), 12);
+ QTest::mouseMove(window, QPoint(148, 68), 12);
+ QTest::mouseMove(window, QPoint(148, 60), 10);
+ QTest::mouseMove(window, QPoint(147, 50), 10);
+ QTest::mouseMove(window, QPoint(147, 40), 9);
+ QTest::mouseMove(window, QPoint(147, 30), 8);
+ QTest::mouseMove(window, QPoint(147, 20), 7);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(147, 20), 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(154, 100), 1000);
+ QTest::mouseMove(window, QPoint(147, 101), 16);
+ QTest::mouseMove(window, QPoint(147, 102), 16);
+ QTest::mouseMove(window, QPoint(147, 105), 16);
+ QTest::mouseMove(window, QPoint(148, 109), 15);
+ QTest::mouseMove(window, QPoint(148, 115), 14);
+ QTest::mouseMove(window, QPoint(148, 120), 13);
+ QTest::mouseMove(window, QPoint(150, 125), 13);
+ QTest::mouseMove(window, QPoint(151, 130), 12);
+ QTest::mouseMove(window, QPoint(151, 135), 12);
+ QTest::mouseMove(window, QPoint(153, 140), 12);
+ QTest::mouseMove(window, QPoint(153, 150), 10);
+ QTest::mouseMove(window, QPoint(153, 160), 10);
+ QTest::mouseMove(window, QPoint(153, 170), 9);
+ QTest::mouseMove(window, QPoint(155, 180), 8);
+ QTest::mouseMove(window, QPoint(155, 188), 7);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(20, 188), 0);
#endif
gifRecorder.waitForFinish();
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 5c648cea..d81ea32f 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS += \
+ buttons \
gifs \
fonts \
screenshots \
diff --git a/tests/manual/styles/styles.qml b/tests/manual/styles/styles.qml
index 277604eb..4655aec6 100644
--- a/tests/manual/styles/styles.qml
+++ b/tests/manual/styles/styles.qml
@@ -40,7 +40,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.3
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
ApplicationWindow {
id: window
diff --git a/tests/manual/testbench/testbench.qml b/tests/manual/testbench/testbench.qml
index 3e8b3d0f..38fd06fc 100644
--- a/tests/manual/testbench/testbench.qml
+++ b/tests/manual/testbench/testbench.qml
@@ -41,9 +41,9 @@
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Layouts 1.0
-import QtQuick.Controls 2.0
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Universal 2.0
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+import QtQuick.Controls.Universal 2.1
ApplicationWindow {
id: window
@@ -97,6 +97,12 @@ ApplicationWindow {
text: "Option 3"
checkable: true
}
+
+ MenuSeparator {}
+
+ MenuItem {
+ text: "Option A"
+ }
}
}
ToolButton {
@@ -128,6 +134,18 @@ ApplicationWindow {
text: "Disabled"
enabled: false
}
+
+ ToolSeparator {}
+
+ ToolButton {
+ text: "1"
+ }
+ ToolButton {
+ text: "2"
+ }
+
+ ToolSeparator {}
+
Item {
Layout.fillWidth: true
}
@@ -233,6 +251,108 @@ ApplicationWindow {
}
RowLayout {
+ spacing: window.controlSpacing * 2
+
+ Button {
+ text: "Normal"
+ }
+ Button {
+ text: "Pressed"
+ down: true
+ }
+ Button {
+ text: "Checked"
+ checked: true
+ }
+ Button {
+ text: "CH + PR"
+ checked: true
+ down: true
+ }
+ Button {
+ text: "Disabled"
+ enabled: false
+ }
+ Button {
+ text: "CH + DIS"
+ enabled: false
+ checked: true
+ }
+ }
+
+ RowLayout {
+ spacing: window.controlSpacing * 2
+
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ down: true
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI + PR"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ checked: true
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI + CH"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ down: true
+ checked: true
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI+CH+PR"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ enabled: false
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI + DIS"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ ColumnLayout {
+ RoundButton {
+ highlighted: true
+ enabled: false
+ checked: true
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Label {
+ text: "HI+CH+DIS"
+ Layout.alignment: Qt.AlignHCenter
+ }
+ }
+ }
+
+ RowLayout {
CheckBox {
text: "Normal"
}
diff --git a/tests/manual/viewinqwidget/main.qml b/tests/manual/viewinqwidget/main.qml
index 5ad52d83..f90a6972 100644
--- a/tests/manual/viewinqwidget/main.qml
+++ b/tests/manual/viewinqwidget/main.qml
@@ -35,7 +35,7 @@
****************************************************************************/
import QtQuick 2.6
-import QtQuick.Controls 2.0
+import QtQuick.Controls 2.1
Item {
visible: true