aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--.qmake.conf2
-rw-r--r--examples/controls/chattutorial/chapter1-settingup/chapter1-settingup.pro10
-rw-r--r--examples/controls/chattutorial/chapter1-settingup/deployment.pri14
-rw-r--r--examples/controls/chattutorial/chapter1-settingup/main.cpp55
-rw-r--r--examples/controls/chattutorial/chapter1-settingup/main.qml60
-rw-r--r--examples/controls/chattutorial/chapter1-settingup/qml.qrc6
-rw-r--r--examples/controls/chattutorial/chapter2-lists/chapter2-lists.pro12
-rw-r--r--examples/controls/chattutorial/chapter2-lists/deployment.pri14
-rw-r--r--examples/controls/chattutorial/chapter2-lists/main.cpp55
-rw-r--r--examples/controls/chattutorial/chapter2-lists/main.qml82
-rw-r--r--examples/controls/chattutorial/chapter2-lists/qml.qrc6
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/ContactPage.qml78
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/ConversationPage.qml132
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/chapter3-navigation.pro12
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/deployment.pri14
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/main.cpp55
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/main.qml56
-rw-r--r--examples/controls/chattutorial/chapter3-navigation/qml.qrc7
-rw-r--r--examples/controls/chattutorial/chapter4-models/ContactPage.qml80
-rw-r--r--examples/controls/chattutorial/chapter4-models/ConversationPage.qml155
-rw-r--r--examples/controls/chattutorial/chapter4-models/chapter4-models.pro20
-rw-r--r--examples/controls/chattutorial/chapter4-models/deployment.pri14
-rw-r--r--examples/controls/chattutorial/chapter4-models/main.cpp90
-rw-r--r--examples/controls/chattutorial/chapter4-models/main.qml56
-rw-r--r--examples/controls/chattutorial/chapter4-models/qml.qrc7
-rw-r--r--examples/controls/chattutorial/chapter4-models/sqlcontactmodel.cpp80
-rw-r--r--examples/controls/chattutorial/chapter4-models/sqlcontactmodel.h52
-rw-r--r--examples/controls/chattutorial/chapter4-models/sqlconversationmodel.cpp144
-rw-r--r--examples/controls/chattutorial/chapter4-models/sqlconversationmodel.h69
-rw-r--r--examples/controls/chattutorial/chapter5-styling/+material/ChatToolBar.qml46
-rw-r--r--examples/controls/chattutorial/chapter5-styling/ChatToolBar.qml44
-rw-r--r--examples/controls/chattutorial/chapter5-styling/ContactPage.qml80
-rw-r--r--examples/controls/chattutorial/chapter5-styling/ConversationPage.qml154
-rw-r--r--examples/controls/chattutorial/chapter5-styling/chapter5-styling.pro20
-rw-r--r--examples/controls/chattutorial/chapter5-styling/deployment.pri14
-rw-r--r--examples/controls/chattutorial/chapter5-styling/main.cpp90
-rw-r--r--examples/controls/chattutorial/chapter5-styling/main.qml56
-rw-r--r--examples/controls/chattutorial/chapter5-styling/qml.qrc10
-rw-r--r--examples/controls/chattutorial/chapter5-styling/qtlabscontrols.conf7
-rw-r--r--examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.cpp80
-rw-r--r--examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.h52
-rw-r--r--examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.cpp144
-rw-r--r--examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.h69
-rw-r--r--examples/controls/chattutorial/chattutorial.pro8
-rw-r--r--examples/controls/chattutorial/shared/Albert Einstein.pngbin0 -> 3638 bytes
-rw-r--r--examples/controls/chattutorial/shared/Albert Einstein@2x.pngbin0 -> 10178 bytes
-rw-r--r--examples/controls/chattutorial/shared/Albert Einstein@3x.pngbin0 -> 18568 bytes
-rw-r--r--examples/controls/chattutorial/shared/Albert Einstein@4x.pngbin0 -> 29420 bytes
-rw-r--r--examples/controls/chattutorial/shared/Ernest Hemingway.pngbin0 -> 4053 bytes
-rw-r--r--examples/controls/chattutorial/shared/Ernest Hemingway@2x.pngbin0 -> 12231 bytes
-rw-r--r--examples/controls/chattutorial/shared/Ernest Hemingway@3x.pngbin0 -> 23040 bytes
-rw-r--r--examples/controls/chattutorial/shared/Ernest Hemingway@4x.pngbin0 -> 38378 bytes
-rw-r--r--examples/controls/chattutorial/shared/Hans Gude.pngbin0 -> 3610 bytes
-rw-r--r--examples/controls/chattutorial/shared/Hans Gude@2x.pngbin0 -> 10977 bytes
-rw-r--r--examples/controls/chattutorial/shared/Hans Gude@3x.pngbin0 -> 21196 bytes
-rw-r--r--examples/controls/chattutorial/shared/Hans Gude@4x.pngbin0 -> 32962 bytes
-rw-r--r--examples/controls/chattutorial/shared/shared.qrc16
-rw-r--r--examples/controls/controls.pro3
-rw-r--r--examples/controls/gallery/gallery.qml12
-rw-r--r--examples/controls/gallery/pages/BusyIndicatorPage.qml2
-rw-r--r--examples/controls/gallery/pages/ComboBoxPage.qml4
-rw-r--r--examples/controls/gallery/pages/GroupBoxPage.qml2
-rw-r--r--examples/controls/gallery/pages/StackViewPage.qml4
-rw-r--r--examples/controls/gallery/pages/SwipeViewPage.qml3
-rw-r--r--examples/controls/gallery/pages/TabBarPage.qml13
-rw-r--r--src/controls/controls.pri2
-rw-r--r--src/controls/qquickcolorimageprovider.cpp (renamed from src/imports/controls/universal/qquickuniversalimageprovider.cpp)11
-rw-r--r--src/controls/qquickcolorimageprovider_p.h (renamed from src/imports/controls/universal/qquickuniversalimageprovider_p.h)15
-rw-r--r--src/controls/qquickpaddedrectangle_p.h4
-rw-r--r--src/controls/qquickproxytheme_p.h30
-rw-r--r--src/controls/qquickstyle.cpp21
-rw-r--r--src/controls/qquickstyle_p.h4
-rw-r--r--src/controls/qquickstyleselector.cpp5
-rw-r--r--src/imports/calendar/plugins.qmltypes1
-rw-r--r--src/imports/calendar/qquickcalendar_p.h2
-rw-r--r--src/imports/calendar/qquickcalendarmodel_p.h12
-rw-r--r--src/imports/calendar/qquickdayofweekmodel_p.h8
-rw-r--r--src/imports/calendar/qquickdayofweekrow.cpp5
-rw-r--r--src/imports/calendar/qquickdayofweekrow_p.h10
-rw-r--r--src/imports/calendar/qquickmonthgrid.cpp12
-rw-r--r--src/imports/calendar/qquickmonthgrid_p.h24
-rw-r--r--src/imports/calendar/qquickmonthmodel_p.h8
-rw-r--r--src/imports/calendar/qquickweeknumbercolumn.cpp5
-rw-r--r--src/imports/calendar/qquickweeknumbercolumn_p.h10
-rw-r--r--src/imports/calendar/qquickweeknumbermodel_p.h8
-rw-r--r--src/imports/calendar/qtlabscalendarplugin.cpp13
-rw-r--r--src/imports/controls/Button.qml16
-rw-r--r--src/imports/controls/CheckBox.qml20
-rw-r--r--src/imports/controls/ComboBox.qml1
-rw-r--r--src/imports/controls/Frame.qml9
-rw-r--r--src/imports/controls/GroupBox.qml6
-rw-r--r--src/imports/controls/ItemDelegate.qml20
-rw-r--r--src/imports/controls/MenuItem.qml24
-rw-r--r--src/imports/controls/RadioButton.qml20
-rw-r--r--src/imports/controls/SpinBox.qml1
-rw-r--r--src/imports/controls/StackView.qml14
-rw-r--r--src/imports/controls/Switch.qml20
-rw-r--r--src/imports/controls/TabButton.qml17
-rw-r--r--src/imports/controls/TextArea.qml2
-rw-r--r--src/imports/controls/TextField.qml2
-rw-r--r--src/imports/controls/ToolButton.qml17
-rw-r--r--src/imports/controls/controls.pri4
-rw-r--r--src/imports/controls/controls.pro6
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-button-label.png)bin1550 -> 1550 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.pngbin0 -> 5877 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gifbin0 -> 176936 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.pngbin0 -> 22195 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gifbin0 -> 262432 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.pngbin0 -> 3895 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gifbin0 -> 169856 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.pngbin0 -> 16495 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.pngbin0 -> 10762 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gifbin0 -> 102536 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.pngbin0 -> 21774 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.pngbin0 -> 18308 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.pngbin0 -> 19284 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.pngbin0 -> 19534 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.pngbin0 -> 18259 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.pngbin0 -> 16739 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.pngbin0 -> 2970 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.pngbin0 -> 3524 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.pngbin0 -> 9875 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.pngbin0 -> 11716 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png)bin2582 -> 2582 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-frame-frame.pngbin341 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.pngbin2653 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png)bin3441 -> 3441 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png)bin3435 -> 3435 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-switch-label.png)bin2605 -> 2605 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.pngbin217 -> 0 bytes
-rw-r--r--src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png (renamed from src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png)bin1682 -> 1682 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml40
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml41
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml)2
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml38
-rw-r--r--src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml (renamed from src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml)2
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc861
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-customize.qdoc80
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-differences.qdoc2
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc141
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-index.qdoc1
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-material.qdoc21
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-styles.qdoc1
-rw-r--r--src/imports/controls/doc/src/qtlabscontrols-universal.qdoc21
-rw-r--r--src/imports/controls/material/Button.qml17
-rw-r--r--src/imports/controls/material/CheckBox.qml21
-rw-r--r--src/imports/controls/material/ComboBox.qml1
-rw-r--r--src/imports/controls/material/Frame.qml9
-rw-r--r--src/imports/controls/material/GroupBox.qml6
-rw-r--r--src/imports/controls/material/ItemDelegate.qml21
-rw-r--r--src/imports/controls/material/MenuItem.qml21
-rw-r--r--src/imports/controls/material/RadioButton.qml21
-rw-r--r--src/imports/controls/material/RangeSlider.qml1
-rw-r--r--src/imports/controls/material/Slider.qml1
-rw-r--r--src/imports/controls/material/SpinBox.qml1
-rw-r--r--src/imports/controls/material/StackView.qml14
-rw-r--r--src/imports/controls/material/Switch.qml21
-rw-r--r--src/imports/controls/material/TabBar.qml2
-rw-r--r--src/imports/controls/material/TabButton.qml17
-rw-r--r--src/imports/controls/material/TextArea.qml2
-rw-r--r--src/imports/controls/material/TextField.qml2
-rw-r--r--src/imports/controls/material/ToolButton.qml17
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp29
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring_p.h10
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip.cpp14
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip_p.h10
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp128
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h4
-rw-r--r--src/imports/controls/material/qquickmaterialtheme_p.h2
-rw-r--r--src/imports/controls/material/qtlabsmaterialstyleplugin.cpp18
-rw-r--r--src/imports/controls/plugins.qmltypes30
-rw-r--r--src/imports/controls/qquickbusyindicatorring.cpp14
-rw-r--r--src/imports/controls/qquickbusyindicatorring_p.h10
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp14
-rw-r--r--src/imports/controls/qquickprogressstrip_p.h10
-rw-r--r--src/imports/controls/qtlabscontrolsplugin.cpp21
-rw-r--r--src/imports/controls/universal/Button.qml17
-rw-r--r--src/imports/controls/universal/CheckBox.qml20
-rw-r--r--src/imports/controls/universal/ComboBox.qml1
-rw-r--r--src/imports/controls/universal/Frame.qml9
-rw-r--r--src/imports/controls/universal/GroupBox.qml6
-rw-r--r--src/imports/controls/universal/ItemDelegate.qml20
-rw-r--r--src/imports/controls/universal/MenuItem.qml24
-rw-r--r--src/imports/controls/universal/RadioButton.qml20
-rw-r--r--src/imports/controls/universal/SpinBox.qml1
-rw-r--r--src/imports/controls/universal/StackView.qml8
-rw-r--r--src/imports/controls/universal/Switch.qml20
-rw-r--r--src/imports/controls/universal/TabButton.qml17
-rw-r--r--src/imports/controls/universal/TextArea.qml2
-rw-r--r--src/imports/controls/universal/TextField.qml2
-rw-r--r--src/imports/controls/universal/ToolButton.qml17
-rw-r--r--src/imports/controls/universal/qquickuniversalfocusrectangle_p.h4
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring.cpp38
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring_p.h10
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip.cpp29
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip_p.h10
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle.cpp76
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle_p.h4
-rw-r--r--src/imports/controls/universal/qquickuniversaltheme_p.h2
-rw-r--r--src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp18
-rw-r--r--src/imports/controls/universal/universal.pri2
-rw-r--r--src/imports/templates/plugins.qmltypes30
-rw-r--r--src/imports/templates/qtlabstemplatesplugin.cpp13
-rw-r--r--src/templates/qquickabstractbutton.cpp139
-rw-r--r--src/templates/qquickabstractbutton_p.h29
-rw-r--r--src/templates/qquickabstractbutton_p_p.h1
-rw-r--r--src/templates/qquickapplicationwindow.cpp158
-rw-r--r--src/templates/qquickapplicationwindow_p.h15
-rw-r--r--src/templates/qquickbusyindicator.cpp11
-rw-r--r--src/templates/qquickbusyindicator_p.h4
-rw-r--r--src/templates/qquickbutton.cpp2
-rw-r--r--src/templates/qquickbutton_p.h4
-rw-r--r--src/templates/qquickbuttongroup.cpp50
-rw-r--r--src/templates/qquickbuttongroup_p.h4
-rw-r--r--src/templates/qquickcheckbox.cpp29
-rw-r--r--src/templates/qquickcheckbox_p.h10
-rw-r--r--src/templates/qquickcombobox.cpp163
-rw-r--r--src/templates/qquickcombobox_p.h28
-rw-r--r--src/templates/qquickcontainer.cpp27
-rw-r--r--src/templates/qquickcontainer_p.h6
-rw-r--r--src/templates/qquickcontainer_p_p.h8
-rw-r--r--src/templates/qquickcontrol.cpp201
-rw-r--r--src/templates/qquickcontrol_p.h41
-rw-r--r--src/templates/qquickcontrol_p_p.h9
-rw-r--r--src/templates/qquickdial.cpp98
-rw-r--r--src/templates/qquickdial_p.h22
-rw-r--r--src/templates/qquickdrawer.cpp76
-rw-r--r--src/templates/qquickdrawer_p.h16
-rw-r--r--src/templates/qquickframe.cpp31
-rw-r--r--src/templates/qquickframe_p.h9
-rw-r--r--src/templates/qquickframe_p_p.h6
-rw-r--r--src/templates/qquickgroupbox.cpp28
-rw-r--r--src/templates/qquickgroupbox_p.h4
-rw-r--r--src/templates/qquickitemdelegate.cpp2
-rw-r--r--src/templates/qquickitemdelegate_p.h6
-rw-r--r--src/templates/qquicklabel.cpp23
-rw-r--r--src/templates/qquicklabel_p.h8
-rw-r--r--src/templates/qquicklabel_p_p.h4
-rw-r--r--src/templates/qquickmenu.cpp22
-rw-r--r--src/templates/qquickmenu_p.h10
-rw-r--r--src/templates/qquickmenu_p_p.h10
-rw-r--r--src/templates/qquickmenuitem_p.h6
-rw-r--r--src/templates/qquickoverlay.cpp103
-rw-r--r--src/templates/qquickoverlay_p.h15
-rw-r--r--src/templates/qquickpage.cpp94
-rw-r--r--src/templates/qquickpage_p.h10
-rw-r--r--src/templates/qquickpageindicator.cpp51
-rw-r--r--src/templates/qquickpageindicator_p.h14
-rw-r--r--src/templates/qquickpane.cpp24
-rw-r--r--src/templates/qquickpane_p.h6
-rw-r--r--src/templates/qquickpopup.cpp345
-rw-r--r--src/templates/qquickpopup_p.h16
-rw-r--r--src/templates/qquickpopup_p_p.h59
-rw-r--r--src/templates/qquickpressandholdhelper.cpp6
-rw-r--r--src/templates/qquickprogressbar.cpp75
-rw-r--r--src/templates/qquickprogressbar_p.h8
-rw-r--r--src/templates/qquickradiobutton.cpp2
-rw-r--r--src/templates/qquickradiobutton_p.h6
-rw-r--r--src/templates/qquickrangeslider.cpp124
-rw-r--r--src/templates/qquickrangeslider_p.h22
-rw-r--r--src/templates/qquickscrollbar.cpp206
-rw-r--r--src/templates/qquickscrollbar_p.h12
-rw-r--r--src/templates/qquickscrollindicator.cpp185
-rw-r--r--src/templates/qquickscrollindicator_p.h4
-rw-r--r--src/templates/qquickslider.cpp138
-rw-r--r--src/templates/qquickslider_p.h24
-rw-r--r--src/templates/qquickspinbox.cpp137
-rw-r--r--src/templates/qquickspinbox_p.h32
-rw-r--r--src/templates/qquickstackview.cpp96
-rw-r--r--src/templates/qquickstackview_p.cpp89
-rw-r--r--src/templates/qquickstackview_p.h10
-rw-r--r--src/templates/qquickstackview_p_p.h6
-rw-r--r--src/templates/qquickswipeview.cpp38
-rw-r--r--src/templates/qquickswipeview_p.h6
-rw-r--r--src/templates/qquickswitch.cpp13
-rw-r--r--src/templates/qquickswitch_p.h6
-rw-r--r--src/templates/qquicktabbar.cpp44
-rw-r--r--src/templates/qquicktabbar_p.h29
-rw-r--r--src/templates/qquicktabbutton.cpp2
-rw-r--r--src/templates/qquicktabbutton_p.h6
-rw-r--r--src/templates/qquicktextarea.cpp47
-rw-r--r--src/templates/qquicktextarea_p.h26
-rw-r--r--src/templates/qquicktextarea_p_p.h12
-rw-r--r--src/templates/qquicktextfield.cpp49
-rw-r--r--src/templates/qquicktextfield_p.h26
-rw-r--r--src/templates/qquicktextfield_p_p.h12
-rw-r--r--src/templates/qquicktoolbar.cpp45
-rw-r--r--src/templates/qquicktoolbar_p.h23
-rw-r--r--src/templates/qquicktoolbutton.cpp2
-rw-r--r--src/templates/qquicktoolbutton_p.h4
-rw-r--r--src/templates/qquicktumbler.cpp64
-rw-r--r--src/templates/qquicktumbler_p.h10
-rw-r--r--sync.profile1
-rw-r--r--tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml1
-rw-r--r--tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp14
-rw-r--r--tests/auto/applicationwindow/tst_applicationwindow.cpp6
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/controls/data/tst_button.qml2
-rw-r--r--tests/auto/controls/data/tst_checkbox.qml2
-rw-r--r--tests/auto/controls/data/tst_combobox.qml147
-rw-r--r--tests/auto/controls/data/tst_control.qml66
-rw-r--r--tests/auto/controls/data/tst_itemdelegate.qml2
-rw-r--r--tests/auto/controls/data/tst_menuitem.qml2
-rw-r--r--tests/auto/controls/data/tst_radiobutton.qml2
-rw-r--r--tests/auto/controls/data/tst_slider.qml47
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml59
-rw-r--r--tests/auto/controls/data/tst_switch.qml2
-rw-r--r--tests/auto/controls/data/tst_tabbutton.qml2
-rw-r--r--tests/auto/controls/data/tst_toolbutton.qml2
-rw-r--r--tests/auto/pressandhold/data/dependencies.qml4
-rw-r--r--tests/auto/pressandhold/tst_pressandhold.cpp15
-rw-r--r--tests/auto/sanity/data/dependencies.qml4
-rw-r--r--tests/auto/sanity/tst_sanity.cpp18
-rw-r--r--tests/auto/snippets/data/dependencies.qml6
-rw-r--r--tests/auto/styles/data/dependencies.qml7
-rw-r--r--tests/auto/styles/tst_styles.cpp2
-rw-r--r--tests/benchmarks/creationtime/data/dependencies.qml7
-rw-r--r--tests/benchmarks/creationtime/tst_creationtime.cpp16
-rw-r--r--tests/benchmarks/objectcount/data/dependencies.qml7
-rw-r--r--tests/benchmarks/objectcount/tst_objectcount.cpp18
-rw-r--r--tests/manual/gifs/eventcapturer.cpp2
-rw-r--r--tests/manual/gifs/eventcapturer.h2
-rw-r--r--tests/manual/gifs/gifrecorder.cpp6
-rw-r--r--tests/manual/viewinqwidget/main.cpp2
329 files changed, 6619 insertions, 2535 deletions
diff --git a/.gitignore b/.gitignore
index 8a6be8b6..00df0e94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,11 @@
/lib
/mkspecs
+/examples/controls/chattutorial/chapter1-settingup/chapter1-settingup
+/examples/controls/chattutorial/chapter2-lists/chapter2-lists
+/examples/controls/chattutorial/chapter3-navigation/chapter3-navigation
+/examples/controls/chattutorial/chapter4-models/chapter4-models
+/examples/controls/chattutorial/chapter5-styling/chapter5-styling
/examples/controls/gallery/gallery
/tests/auto/accessibility/tst_accessibility
@@ -95,6 +100,7 @@ app_process
qtc-debugging-helper
android-*.so-deployment-settings.json
*.directory
+*_plugin_import.cpp
*_wrapper.sh
*_wrapper.bat
*.mak
diff --git a/.qmake.conf b/.qmake.conf
index c55a429d..12ab0814 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -3,4 +3,4 @@ CONFIG += warning_clean
QQC2_SOURCE_TREE = $$PWD
-MODULE_VERSION = 5.6.1
+MODULE_VERSION = 5.7.0
diff --git a/examples/controls/chattutorial/chapter1-settingup/chapter1-settingup.pro b/examples/controls/chattutorial/chapter1-settingup/chapter1-settingup.pro
new file mode 100644
index 00000000..36ee0586
--- /dev/null
+++ b/examples/controls/chattutorial/chapter1-settingup/chapter1-settingup.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+include(deployment.pri)
diff --git a/examples/controls/chattutorial/chapter1-settingup/deployment.pri b/examples/controls/chattutorial/chapter1-settingup/deployment.pri
new file mode 100644
index 00000000..c89af25a
--- /dev/null
+++ b/examples/controls/chattutorial/chapter1-settingup/deployment.pri
@@ -0,0 +1,14 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
+
diff --git a/examples/controls/chattutorial/chapter1-settingup/main.cpp b/examples/controls/chattutorial/chapter1-settingup/main.cpp
new file mode 100644
index 00000000..3a095d2f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter1-settingup/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
diff --git a/examples/controls/chattutorial/chapter1-settingup/main.qml b/examples/controls/chattutorial/chapter1-settingup/main.qml
new file mode 100644
index 00000000..477d14e2
--- /dev/null
+++ b/examples/controls/chattutorial/chapter1-settingup/main.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ApplicationWindow {
+ width: 540
+ height: 960
+ visible: true
+
+ Page {
+ anchors.fill: parent
+ header: Label {
+ padding: 10
+ text: qsTr("Contacts")
+ font.pixelSize: 20
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter1-settingup/qml.qrc b/examples/controls/chattutorial/chapter1-settingup/qml.qrc
new file mode 100644
index 00000000..0ff3892d
--- /dev/null
+++ b/examples/controls/chattutorial/chapter1-settingup/qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
+
diff --git a/examples/controls/chattutorial/chapter2-lists/chapter2-lists.pro b/examples/controls/chattutorial/chapter2-lists/chapter2-lists.pro
new file mode 100644
index 00000000..ed23d115
--- /dev/null
+++ b/examples/controls/chattutorial/chapter2-lists/chapter2-lists.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc \
+ ../shared/shared.qrc
+
+include(deployment.pri)
+
diff --git a/examples/controls/chattutorial/chapter2-lists/deployment.pri b/examples/controls/chattutorial/chapter2-lists/deployment.pri
new file mode 100644
index 00000000..c89af25a
--- /dev/null
+++ b/examples/controls/chattutorial/chapter2-lists/deployment.pri
@@ -0,0 +1,14 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
+
diff --git a/examples/controls/chattutorial/chapter2-lists/main.cpp b/examples/controls/chattutorial/chapter2-lists/main.cpp
new file mode 100644
index 00000000..3a095d2f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter2-lists/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
diff --git a/examples/controls/chattutorial/chapter2-lists/main.qml b/examples/controls/chattutorial/chapter2-lists/main.qml
new file mode 100644
index 00000000..290219aa
--- /dev/null
+++ b/examples/controls/chattutorial/chapter2-lists/main.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ApplicationWindow {
+ width: 540
+ height: 960
+ visible: true
+
+ Page {
+ anchors.fill: parent
+ header: Label {
+ padding: 10
+ text: qsTr("Contacts")
+ font.pixelSize: 20
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ topMargin: 48
+ leftMargin: 48
+ bottomMargin: 48
+ rightMargin: 48
+ spacing: 20
+ model: ["Albert Einstein", "Ernest Hemingway", "Hans Gude"]
+ delegate: ItemDelegate {
+ text: modelData
+ width: listView.width - listView.leftMargin - listView.rightMargin
+ height: avatar.implicitHeight
+ leftPadding: avatar.implicitWidth + 32
+
+ Image {
+ id: avatar
+ source: "qrc:/" + modelData + ".png"
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter2-lists/qml.qrc b/examples/controls/chattutorial/chapter2-lists/qml.qrc
new file mode 100644
index 00000000..0ff3892d
--- /dev/null
+++ b/examples/controls/chattutorial/chapter2-lists/qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/ContactPage.qml b/examples/controls/chattutorial/chapter3-navigation/ContactPage.qml
new file mode 100644
index 00000000..f1589387
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/ContactPage.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+Page {
+ id: root
+
+ header: ToolBar {
+ Label {
+ text: qsTr("Contacts")
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ topMargin: 48
+ leftMargin: 48
+ bottomMargin: 48
+ rightMargin: 48
+ spacing: 20
+ model: ["Albert Einstein", "Ernest Hemingway", "Hans Gude"]
+ delegate: ItemDelegate {
+ text: modelData
+ width: listView.width - listView.leftMargin - listView.rightMargin
+ height: avatar.implicitHeight
+ leftPadding: avatar.implicitWidth + 32
+ onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: modelData })
+
+ Image {
+ id: avatar
+ source: "qrc:/" + modelData + ".png"
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/ConversationPage.qml b/examples/controls/chattutorial/chapter3-navigation/ConversationPage.qml
new file mode 100644
index 00000000..b4393a93
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/ConversationPage.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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.3
+import Qt.labs.controls 1.0
+
+Page {
+ id: root
+
+ property string inConversationWith
+
+ header: ToolBar {
+ ToolButton {
+ text: qsTr("Back")
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ onClicked: root.StackView.view.pop()
+ }
+
+ Label {
+ id: pageTitle
+ text: inConversationWith
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ ListView {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.margins: pane.leftPadding + messageField.leftPadding
+ displayMarginBeginning: 40
+ displayMarginEnd: 40
+ verticalLayoutDirection: ListView.BottomToTop
+ spacing: 12
+ model: 10
+ delegate: Row {
+ readonly property bool sentByMe: index % 2 == 0
+
+ anchors.right: sentByMe ? parent.right : undefined
+ spacing: 6
+
+ Rectangle {
+ id: avatar
+ width: height
+ height: parent.height
+ color: "grey"
+ visible: !sentByMe
+ }
+
+ Rectangle {
+ width: 80
+ height: 40
+ color: sentByMe ? "lightgrey" : "steelblue"
+
+ Label {
+ anchors.centerIn: parent
+ text: index
+ color: sentByMe ? "black" : "white"
+ }
+ }
+ }
+
+ ScrollBar.vertical: ScrollBar {}
+ }
+
+ Pane {
+ id: pane
+ Layout.fillWidth: true
+
+ RowLayout {
+ width: parent.width
+
+ TextArea {
+ id: messageField
+ Layout.fillWidth: true
+ placeholderText: qsTr("Compose message")
+ wrapMode: TextArea.Wrap
+ }
+
+ Button {
+ id: sendButton
+ text: qsTr("Send")
+ enabled: messageField.length > 0
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/chapter3-navigation.pro b/examples/controls/chattutorial/chapter3-navigation/chapter3-navigation.pro
new file mode 100644
index 00000000..ed23d115
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/chapter3-navigation.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc \
+ ../shared/shared.qrc
+
+include(deployment.pri)
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/deployment.pri b/examples/controls/chattutorial/chapter3-navigation/deployment.pri
new file mode 100644
index 00000000..c89af25a
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/deployment.pri
@@ -0,0 +1,14 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/main.cpp b/examples/controls/chattutorial/chapter3-navigation/main.cpp
new file mode 100644
index 00000000..3a095d2f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/main.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/main.qml b/examples/controls/chattutorial/chapter3-navigation/main.qml
new file mode 100644
index 00000000..b373c6b8
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/main.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ApplicationWindow {
+ id: window
+ width: 540
+ height: 960
+ visible: true
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: ContactPage {}
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter3-navigation/qml.qrc b/examples/controls/chattutorial/chapter3-navigation/qml.qrc
new file mode 100644
index 00000000..a72e1b71
--- /dev/null
+++ b/examples/controls/chattutorial/chapter3-navigation/qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>ContactPage.qml</file>
+ <file>ConversationPage.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/controls/chattutorial/chapter4-models/ContactPage.qml b/examples/controls/chattutorial/chapter4-models/ContactPage.qml
new file mode 100644
index 00000000..8ec0ca51
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/ContactPage.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+import io.qt.examples.chattutorial 1.0
+
+Page {
+ id: root
+
+ header: ToolBar {
+ Label {
+ text: qsTr("Contacts")
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ topMargin: 48
+ leftMargin: 48
+ bottomMargin: 48
+ rightMargin: 48
+ spacing: 20
+ model: SqlContactModel {}
+ delegate: ItemDelegate {
+ text: model.display
+ width: listView.width - listView.leftMargin - listView.rightMargin
+ height: avatar.implicitHeight
+ leftPadding: avatar.implicitWidth + 32
+ onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display })
+
+ Image {
+ id: avatar
+ source: "qrc:/" + model.display + ".png"
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter4-models/ConversationPage.qml b/examples/controls/chattutorial/chapter4-models/ConversationPage.qml
new file mode 100644
index 00000000..467a1924
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/ConversationPage.qml
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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.3
+import Qt.labs.controls 1.0
+
+import io.qt.examples.chattutorial 1.0
+
+Page {
+ id: root
+
+ property string inConversationWith
+
+ header: ToolBar {
+ ToolButton {
+ text: qsTr("Back")
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ onClicked: root.StackView.view.pop()
+ }
+
+ Label {
+ id: pageTitle
+ text: inConversationWith
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ ListView {
+ id: listView
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.margins: pane.leftPadding + messageField.leftPadding
+ displayMarginBeginning: 40
+ displayMarginEnd: 40
+ verticalLayoutDirection: ListView.BottomToTop
+ spacing: 12
+ model: SqlConversationModel {
+ recipient: inConversationWith
+ }
+ delegate: Column {
+ anchors.right: sentByMe ? parent.right : undefined
+ spacing: 6
+
+ readonly property bool sentByMe: model.recipient !== "Me"
+
+ Row {
+ id: messageRow
+ spacing: 6
+ anchors.right: sentByMe ? parent.right : undefined
+
+ Image {
+ id: avatar
+ source: !sentByMe ? "qrc:/" + model.author + ".png" : ""
+ }
+
+ Rectangle {
+ width: Math.min(messageText.implicitWidth + 24,
+ listView.width - (!sentByMe ? avatar.width + messageRow.spacing : 0))
+ height: messageText.implicitHeight + 24
+ color: sentByMe ? "lightgrey" : "steelblue"
+
+ Label {
+ id: messageText
+ text: model.message
+ color: sentByMe ? "black" : "white"
+ anchors.fill: parent
+ anchors.margins: 12
+ wrapMode: Label.Wrap
+ }
+ }
+ }
+
+ Label {
+ id: timestampText
+ text: Qt.formatDateTime(model.timestamp, "d MMM hh:mm")
+ color: "lightgrey"
+ anchors.right: sentByMe ? parent.right : undefined
+ }
+ }
+
+ ScrollBar.vertical: ScrollBar {}
+ }
+
+ Pane {
+ id: pane
+ Layout.fillWidth: true
+
+ RowLayout {
+ width: parent.width
+
+ TextArea {
+ id: messageField
+ Layout.fillWidth: true
+ placeholderText: qsTr("Compose message")
+ wrapMode: TextArea.Wrap
+ }
+
+ Button {
+ id: sendButton
+ text: qsTr("Send")
+ enabled: messageField.length > 0
+ onClicked: {
+ listView.model.sendMessage(inConversationWith, messageField.text);
+ messageField.text = "";
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter4-models/chapter4-models.pro b/examples/controls/chattutorial/chapter4-models/chapter4-models.pro
new file mode 100644
index 00000000..4f35e954
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/chapter4-models.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+QT += qml quick sql
+CONFIG += c++11
+
+!contains(sql-drivers, sqlite): QTPLUGIN += qsqlite
+
+HEADERS += sqlcontactmodel.h \
+ sqlconversationmodel.h
+
+SOURCES += main.cpp \
+ sqlcontactmodel.cpp \
+ sqlconversationmodel.cpp
+
+RESOURCES += \
+ qml.qrc \
+ ../shared/shared.qrc
+
+include(deployment.pri)
+
diff --git a/examples/controls/chattutorial/chapter4-models/deployment.pri b/examples/controls/chattutorial/chapter4-models/deployment.pri
new file mode 100644
index 00000000..c89af25a
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/deployment.pri
@@ -0,0 +1,14 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
+
diff --git a/examples/controls/chattutorial/chapter4-models/main.cpp b/examples/controls/chattutorial/chapter4-models/main.cpp
new file mode 100644
index 00000000..9f2109fa
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QStandardPaths>
+#include <QSqlDatabase>
+#include <QSqlError>
+#include <QtQml>
+
+#include "sqlcontactmodel.h"
+#include "sqlconversationmodel.h"
+
+static void connectToDatabase()
+{
+ QSqlDatabase database = QSqlDatabase::database();
+ if (!database.isValid()) {
+ database = QSqlDatabase::addDatabase("QSQLITE");
+ if (!database.isValid())
+ qFatal("Cannot add database: %s", qPrintable(database.lastError().text()));
+ }
+
+ const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
+ if (!writeDir.mkpath("."))
+ qFatal("Failed to create writable directory at %s", qPrintable(writeDir.absolutePath()));
+
+ // Ensure that we have a writable location on all devices.
+ const QString fileName = writeDir.absolutePath() + "/chat-database.sqlite3";
+ // When using the SQLite driver, open() will create the SQLite database if it doesn't exist.
+ database.setDatabaseName(fileName);
+ if (!database.open()) {
+ qFatal("Cannot open database: %s", qPrintable(database.lastError().text()));
+ QFile::remove(fileName);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<SqlContactModel>("io.qt.examples.chattutorial", 1, 0, "SqlContactModel");
+ qmlRegisterType<SqlConversationModel>("io.qt.examples.chattutorial", 1, 0, "SqlConversationModel");
+
+ connectToDatabase();
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
+
diff --git a/examples/controls/chattutorial/chapter4-models/main.qml b/examples/controls/chattutorial/chapter4-models/main.qml
new file mode 100644
index 00000000..b373c6b8
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/main.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ApplicationWindow {
+ id: window
+ width: 540
+ height: 960
+ visible: true
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: ContactPage {}
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter4-models/qml.qrc b/examples/controls/chattutorial/chapter4-models/qml.qrc
new file mode 100644
index 00000000..a72e1b71
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/qml.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>ContactPage.qml</file>
+ <file>ConversationPage.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.cpp b/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.cpp
new file mode 100644
index 00000000..d1cfb796
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include "sqlcontactmodel.h"
+
+#include <QDebug>
+#include <QSqlError>
+#include <QSqlQuery>
+
+static void createTable()
+{
+ if (QSqlDatabase::database().tables().contains(QStringLiteral("Contacts"))) {
+ // The table already exists; we don't need to do anything.
+ return;
+ }
+
+ QSqlQuery query;
+ if (!query.exec(
+ "CREATE TABLE IF NOT EXISTS 'Contacts' ("
+ " 'name' TEXT NOT NULL,"
+ " PRIMARY KEY(name)"
+ ")")) {
+ qFatal("Failed to query database: %s", qPrintable(query.lastError().text()));
+ }
+
+ query.exec("INSERT INTO Contacts VALUES('Albert Einstein')");
+ query.exec("INSERT INTO Contacts VALUES('Ernest Hemingway')");
+ query.exec("INSERT INTO Contacts VALUES('Hans Gude')");
+}
+
+SqlContactModel::SqlContactModel(QObject *parent) :
+ QSqlQueryModel(parent)
+{
+ createTable();
+
+ QSqlQuery query;
+ if (!query.exec("SELECT * FROM Contacts"))
+ qFatal("Contacts SELECT query failed: %s", qPrintable(query.lastError().text()));
+
+ setQuery(query);
+ if (lastError().isValid())
+ qFatal("Cannot set query on SqlContactModel: %s", qPrintable(lastError().text()));
+}
diff --git a/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.h b/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.h
new file mode 100644
index 00000000..00dd6a6f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/sqlcontactmodel.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#ifndef SQLCONTACTMODEL_H
+#define SQLCONTACTMODEL_H
+
+#include <QSqlQueryModel>
+
+class SqlContactModel : public QSqlQueryModel
+{
+public:
+ SqlContactModel(QObject *parent = 0);
+};
+
+#endif // SQLCONTACTMODEL_H
diff --git a/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.cpp b/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.cpp
new file mode 100644
index 00000000..56f1b838
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include "sqlconversationmodel.h"
+
+#include <QDateTime>
+#include <QDebug>
+#include <QSqlError>
+#include <QSqlRecord>
+#include <QSqlQuery>
+
+static const char *conversationsTableName = "Conversations";
+
+static void createTable()
+{
+ if (QSqlDatabase::database().tables().contains(conversationsTableName)) {
+ // The table already exists; we don't need to do anything.
+ return;
+ }
+
+ QSqlQuery query;
+ if (!query.exec(
+ "CREATE TABLE IF NOT EXISTS 'Conversations' ("
+ "'author' TEXT NOT NULL,"
+ "'recipient' TEXT NOT NULL,"
+ "'timestamp' TEXT NOT NULL,"
+ "'message' TEXT NOT NULL,"
+ "FOREIGN KEY('author') REFERENCES Contacts ( name ),"
+ "FOREIGN KEY('recipient') REFERENCES Contacts ( name )"
+ ")")) {
+ qFatal("Failed to query database: %s", qPrintable(query.lastError().text()));
+ }
+
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Ernest Hemingway', '2016-01-07T14:36:06', 'Hello!')");
+ query.exec("INSERT INTO Conversations VALUES('Ernest Hemingway', 'Me', '2016-01-07T14:36:16', 'Good afternoon.')");
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Albert Einstein', '2016-01-01T11:24:53', 'Hi!')");
+ query.exec("INSERT INTO Conversations VALUES('Albert Einstein', 'Me', '2016-01-07T14:36:16', 'Good morning.')");
+ query.exec("INSERT INTO Conversations VALUES('Hans Gude', 'Me', '2015-11-20T06:30:02', 'God morgen. Har du fått mitt maleri?')");
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Hans Gude', '2015-11-20T08:21:03', 'God morgen, Hans. Ja, det er veldig fint. Tusen takk! "
+ "Hvor mange timer har du brukt på den?')");
+}
+
+SqlConversationModel::SqlConversationModel(QObject *parent) :
+ QSqlTableModel(parent)
+{
+ createTable();
+ setTable(conversationsTableName);
+ setSort(2, Qt::DescendingOrder);
+ // Ensures that the model is sorted correctly after submitting a new row.
+ setEditStrategy(QSqlTableModel::OnManualSubmit);
+}
+
+QString SqlConversationModel::recipient() const
+{
+ return m_recipient;
+}
+
+void SqlConversationModel::setRecipient(const QString &recipient)
+{
+ if (recipient == m_recipient)
+ return;
+
+ m_recipient = recipient;
+
+ const QString filterString = QString::fromLatin1(
+ "(recipient = '%1' AND author = 'Me') OR (recipient = 'Me' AND author='%1')").arg(m_recipient);
+ setFilter(filterString);
+ select();
+
+ emit recipientChanged();
+}
+
+QVariant SqlConversationModel::data(const QModelIndex &index, int role) const
+{
+ if (role < Qt::UserRole)
+ return QSqlTableModel::data(index, role);
+
+ const QSqlRecord sqlRecord = record(index.row());
+ return sqlRecord.value(role - Qt::UserRole);
+}
+
+QHash<int, QByteArray> SqlConversationModel::roleNames() const
+{
+ QHash<int, QByteArray> names;
+ names[Qt::UserRole] = "author";
+ names[Qt::UserRole + 1] = "recipient";
+ names[Qt::UserRole + 2] = "timestamp";
+ names[Qt::UserRole + 3] = "message";
+ return names;
+}
+
+void SqlConversationModel::sendMessage(const QString &recipient, const QString &message)
+{
+ const QString timestamp = QDateTime::currentDateTime().toString(Qt::ISODate);
+
+ QSqlRecord newRecord = record();
+ newRecord.setValue("author", "Me");
+ newRecord.setValue("recipient", recipient);
+ newRecord.setValue("timestamp", timestamp);
+ newRecord.setValue("message", message);
+ if (!insertRecord(rowCount(), newRecord)) {
+ qWarning() << "Failed to send message:" << lastError().text();
+ return;
+ }
+
+ submitAll();
+}
diff --git a/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.h b/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.h
new file mode 100644
index 00000000..0ce12049
--- /dev/null
+++ b/examples/controls/chattutorial/chapter4-models/sqlconversationmodel.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#ifndef SQLCONVERSATIONMODEL_H
+#define SQLCONVERSATIONMODEL_H
+
+#include <QSqlTableModel>
+
+class SqlConversationModel : public QSqlTableModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QString recipient READ recipient WRITE setRecipient NOTIFY recipientChanged)
+
+public:
+ SqlConversationModel(QObject *parent = 0);
+
+ QString recipient() const;
+ void setRecipient(const QString &recipient);
+
+ QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
+
+ Q_INVOKABLE void sendMessage(const QString &recipient, const QString &message);
+
+signals:
+ void recipientChanged();
+
+private:
+ QString m_recipient;
+};
+
+#endif // SQLCONVERSATIONMODEL_H
diff --git a/examples/controls/chattutorial/chapter5-styling/+material/ChatToolBar.qml b/examples/controls/chattutorial/chapter5-styling/+material/ChatToolBar.qml
new file mode 100644
index 00000000..57a239cb
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/+material/ChatToolBar.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+import Qt.labs.controls.material 1.0
+
+ToolBar {
+ Material.theme: Material.Dark
+}
diff --git a/examples/controls/chattutorial/chapter5-styling/ChatToolBar.qml b/examples/controls/chattutorial/chapter5-styling/ChatToolBar.qml
new file mode 100644
index 00000000..10c2890f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/ChatToolBar.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ToolBar {
+}
diff --git a/examples/controls/chattutorial/chapter5-styling/ContactPage.qml b/examples/controls/chattutorial/chapter5-styling/ContactPage.qml
new file mode 100644
index 00000000..7f24f275
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/ContactPage.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+import io.qt.examples.chattutorial 1.0
+
+Page {
+ id: root
+
+ header: ChatToolBar {
+ Label {
+ text: qsTr("Contacts")
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ListView {
+ id: listView
+ anchors.fill: parent
+ topMargin: 48
+ leftMargin: 48
+ bottomMargin: 48
+ rightMargin: 48
+ spacing: 20
+ model: SqlContactModel {}
+ delegate: ItemDelegate {
+ text: model.display
+ width: listView.width - listView.leftMargin - listView.rightMargin
+ height: avatar.implicitHeight
+ leftPadding: avatar.implicitWidth + 32
+ onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display })
+
+ Image {
+ id: avatar
+ source: "qrc:/" + model.display + ".png"
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter5-styling/ConversationPage.qml b/examples/controls/chattutorial/chapter5-styling/ConversationPage.qml
new file mode 100644
index 00000000..b65f69a9
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/ConversationPage.qml
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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.3
+import Qt.labs.controls 1.0
+
+import io.qt.examples.chattutorial 1.0
+
+Page {
+ id: root
+
+ property string inConversationWith
+
+ header: ChatToolBar {
+ ToolButton {
+ text: qsTr("Back")
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ onClicked: root.StackView.view.pop()
+ }
+
+ Label {
+ id: pageTitle
+ text: inConversationWith
+ font.pixelSize: 20
+ anchors.centerIn: parent
+ }
+ }
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ ListView {
+ id: listView
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.margins: pane.leftPadding + messageField.leftPadding
+ displayMarginBeginning: 40
+ displayMarginEnd: 40
+ verticalLayoutDirection: ListView.BottomToTop
+ spacing: 12
+ model: SqlConversationModel {
+ recipient: inConversationWith
+ }
+ delegate: Column {
+ anchors.right: sentByMe ? parent.right : undefined
+ spacing: 6
+
+ readonly property bool sentByMe: model.recipient !== "Me"
+
+ Row {
+ id: messageRow
+ spacing: 6
+ anchors.right: sentByMe ? parent.right : undefined
+
+ Image {
+ id: avatar
+ source: !sentByMe ? "qrc:/" + model.author + ".png" : ""
+ }
+
+ Rectangle {
+ width: Math.min(messageText.implicitWidth + 24, listView.width - avatar.width - messageRow.spacing)
+ height: messageText.implicitHeight + 24
+ color: sentByMe ? "lightgrey" : "steelblue"
+
+ Label {
+ id: messageText
+ text: model.message
+ color: sentByMe ? "black" : "white"
+ anchors.fill: parent
+ anchors.margins: 12
+ wrapMode: Label.Wrap
+ }
+ }
+ }
+
+ Label {
+ id: timestampText
+ text: Qt.formatDateTime(model.timestamp, "d MMM hh:mm")
+ color: "lightgrey"
+ anchors.right: sentByMe ? parent.right : undefined
+ }
+ }
+
+ ScrollBar.vertical: ScrollBar {}
+ }
+
+ Pane {
+ id: pane
+ Layout.fillWidth: true
+
+ RowLayout {
+ width: parent.width
+
+ TextArea {
+ id: messageField
+ Layout.fillWidth: true
+ placeholderText: qsTr("Compose message")
+ wrapMode: TextArea.Wrap
+ }
+
+ Button {
+ id: sendButton
+ text: qsTr("Send")
+ enabled: messageField.length > 0
+ onClicked: {
+ listView.model.sendMessage(inConversationWith, messageField.text);
+ messageField.text = "";
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter5-styling/chapter5-styling.pro b/examples/controls/chattutorial/chapter5-styling/chapter5-styling.pro
new file mode 100644
index 00000000..4f35e954
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/chapter5-styling.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+
+QT += qml quick sql
+CONFIG += c++11
+
+!contains(sql-drivers, sqlite): QTPLUGIN += qsqlite
+
+HEADERS += sqlcontactmodel.h \
+ sqlconversationmodel.h
+
+SOURCES += main.cpp \
+ sqlcontactmodel.cpp \
+ sqlconversationmodel.cpp
+
+RESOURCES += \
+ qml.qrc \
+ ../shared/shared.qrc
+
+include(deployment.pri)
+
diff --git a/examples/controls/chattutorial/chapter5-styling/deployment.pri b/examples/controls/chattutorial/chapter5-styling/deployment.pri
new file mode 100644
index 00000000..c89af25a
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/deployment.pri
@@ -0,0 +1,14 @@
+unix:!android {
+ isEmpty(target.path) {
+ qnx {
+ target.path = /tmp/$${TARGET}/bin
+ } else {
+ target.path = /opt/$${TARGET}/bin
+ }
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export(INSTALLS)
+
diff --git a/examples/controls/chattutorial/chapter5-styling/main.cpp b/examples/controls/chattutorial/chapter5-styling/main.cpp
new file mode 100644
index 00000000..9f2109fa
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/main.cpp
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QStandardPaths>
+#include <QSqlDatabase>
+#include <QSqlError>
+#include <QtQml>
+
+#include "sqlcontactmodel.h"
+#include "sqlconversationmodel.h"
+
+static void connectToDatabase()
+{
+ QSqlDatabase database = QSqlDatabase::database();
+ if (!database.isValid()) {
+ database = QSqlDatabase::addDatabase("QSQLITE");
+ if (!database.isValid())
+ qFatal("Cannot add database: %s", qPrintable(database.lastError().text()));
+ }
+
+ const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
+ if (!writeDir.mkpath("."))
+ qFatal("Failed to create writable directory at %s", qPrintable(writeDir.absolutePath()));
+
+ // Ensure that we have a writable location on all devices.
+ const QString fileName = writeDir.absolutePath() + "/chat-database.sqlite3";
+ // When using the SQLite driver, open() will create the SQLite database if it doesn't exist.
+ database.setDatabaseName(fileName);
+ if (!database.open()) {
+ qFatal("Cannot open database: %s", qPrintable(database.lastError().text()));
+ QFile::remove(fileName);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<SqlContactModel>("io.qt.examples.chattutorial", 1, 0, "SqlContactModel");
+ qmlRegisterType<SqlConversationModel>("io.qt.examples.chattutorial", 1, 0, "SqlConversationModel");
+
+ connectToDatabase();
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
+
diff --git a/examples/controls/chattutorial/chapter5-styling/main.qml b/examples/controls/chattutorial/chapter5-styling/main.qml
new file mode 100644
index 00000000..b373c6b8
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/main.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Qt.labs.controls 1.0
+
+ApplicationWindow {
+ id: window
+ width: 540
+ height: 960
+ visible: true
+
+ StackView {
+ id: stackView
+ anchors.fill: parent
+ initialItem: ContactPage {}
+ }
+}
+
diff --git a/examples/controls/chattutorial/chapter5-styling/qml.qrc b/examples/controls/chattutorial/chapter5-styling/qml.qrc
new file mode 100644
index 00000000..d2446409
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/qml.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>ContactPage.qml</file>
+ <file>ConversationPage.qml</file>
+ <file>qtlabscontrols.conf</file>
+ <file>ChatToolBar.qml</file>
+ <file>+material/ChatToolBar.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/controls/chattutorial/chapter5-styling/qtlabscontrols.conf b/examples/controls/chattutorial/chapter5-styling/qtlabscontrols.conf
new file mode 100644
index 00000000..e338c804
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/qtlabscontrols.conf
@@ -0,0 +1,7 @@
+[material]
+Primary=Indigo
+Accent=Indigo
+Theme=Dark
+
+[Universal]
+Theme=Dark
diff --git a/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.cpp b/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.cpp
new file mode 100644
index 00000000..d1cfb796
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include "sqlcontactmodel.h"
+
+#include <QDebug>
+#include <QSqlError>
+#include <QSqlQuery>
+
+static void createTable()
+{
+ if (QSqlDatabase::database().tables().contains(QStringLiteral("Contacts"))) {
+ // The table already exists; we don't need to do anything.
+ return;
+ }
+
+ QSqlQuery query;
+ if (!query.exec(
+ "CREATE TABLE IF NOT EXISTS 'Contacts' ("
+ " 'name' TEXT NOT NULL,"
+ " PRIMARY KEY(name)"
+ ")")) {
+ qFatal("Failed to query database: %s", qPrintable(query.lastError().text()));
+ }
+
+ query.exec("INSERT INTO Contacts VALUES('Albert Einstein')");
+ query.exec("INSERT INTO Contacts VALUES('Ernest Hemingway')");
+ query.exec("INSERT INTO Contacts VALUES('Hans Gude')");
+}
+
+SqlContactModel::SqlContactModel(QObject *parent) :
+ QSqlQueryModel(parent)
+{
+ createTable();
+
+ QSqlQuery query;
+ if (!query.exec("SELECT * FROM Contacts"))
+ qFatal("Contacts SELECT query failed: %s", qPrintable(query.lastError().text()));
+
+ setQuery(query);
+ if (lastError().isValid())
+ qFatal("Cannot set query on SqlContactModel: %s", qPrintable(lastError().text()));
+}
diff --git a/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.h b/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.h
new file mode 100644
index 00000000..00dd6a6f
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/sqlcontactmodel.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#ifndef SQLCONTACTMODEL_H
+#define SQLCONTACTMODEL_H
+
+#include <QSqlQueryModel>
+
+class SqlContactModel : public QSqlQueryModel
+{
+public:
+ SqlContactModel(QObject *parent = 0);
+};
+
+#endif // SQLCONTACTMODEL_H
diff --git a/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.cpp b/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.cpp
new file mode 100644
index 00000000..56f1b838
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#include "sqlconversationmodel.h"
+
+#include <QDateTime>
+#include <QDebug>
+#include <QSqlError>
+#include <QSqlRecord>
+#include <QSqlQuery>
+
+static const char *conversationsTableName = "Conversations";
+
+static void createTable()
+{
+ if (QSqlDatabase::database().tables().contains(conversationsTableName)) {
+ // The table already exists; we don't need to do anything.
+ return;
+ }
+
+ QSqlQuery query;
+ if (!query.exec(
+ "CREATE TABLE IF NOT EXISTS 'Conversations' ("
+ "'author' TEXT NOT NULL,"
+ "'recipient' TEXT NOT NULL,"
+ "'timestamp' TEXT NOT NULL,"
+ "'message' TEXT NOT NULL,"
+ "FOREIGN KEY('author') REFERENCES Contacts ( name ),"
+ "FOREIGN KEY('recipient') REFERENCES Contacts ( name )"
+ ")")) {
+ qFatal("Failed to query database: %s", qPrintable(query.lastError().text()));
+ }
+
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Ernest Hemingway', '2016-01-07T14:36:06', 'Hello!')");
+ query.exec("INSERT INTO Conversations VALUES('Ernest Hemingway', 'Me', '2016-01-07T14:36:16', 'Good afternoon.')");
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Albert Einstein', '2016-01-01T11:24:53', 'Hi!')");
+ query.exec("INSERT INTO Conversations VALUES('Albert Einstein', 'Me', '2016-01-07T14:36:16', 'Good morning.')");
+ query.exec("INSERT INTO Conversations VALUES('Hans Gude', 'Me', '2015-11-20T06:30:02', 'God morgen. Har du fått mitt maleri?')");
+ query.exec("INSERT INTO Conversations VALUES('Me', 'Hans Gude', '2015-11-20T08:21:03', 'God morgen, Hans. Ja, det er veldig fint. Tusen takk! "
+ "Hvor mange timer har du brukt på den?')");
+}
+
+SqlConversationModel::SqlConversationModel(QObject *parent) :
+ QSqlTableModel(parent)
+{
+ createTable();
+ setTable(conversationsTableName);
+ setSort(2, Qt::DescendingOrder);
+ // Ensures that the model is sorted correctly after submitting a new row.
+ setEditStrategy(QSqlTableModel::OnManualSubmit);
+}
+
+QString SqlConversationModel::recipient() const
+{
+ return m_recipient;
+}
+
+void SqlConversationModel::setRecipient(const QString &recipient)
+{
+ if (recipient == m_recipient)
+ return;
+
+ m_recipient = recipient;
+
+ const QString filterString = QString::fromLatin1(
+ "(recipient = '%1' AND author = 'Me') OR (recipient = 'Me' AND author='%1')").arg(m_recipient);
+ setFilter(filterString);
+ select();
+
+ emit recipientChanged();
+}
+
+QVariant SqlConversationModel::data(const QModelIndex &index, int role) const
+{
+ if (role < Qt::UserRole)
+ return QSqlTableModel::data(index, role);
+
+ const QSqlRecord sqlRecord = record(index.row());
+ return sqlRecord.value(role - Qt::UserRole);
+}
+
+QHash<int, QByteArray> SqlConversationModel::roleNames() const
+{
+ QHash<int, QByteArray> names;
+ names[Qt::UserRole] = "author";
+ names[Qt::UserRole + 1] = "recipient";
+ names[Qt::UserRole + 2] = "timestamp";
+ names[Qt::UserRole + 3] = "message";
+ return names;
+}
+
+void SqlConversationModel::sendMessage(const QString &recipient, const QString &message)
+{
+ const QString timestamp = QDateTime::currentDateTime().toString(Qt::ISODate);
+
+ QSqlRecord newRecord = record();
+ newRecord.setValue("author", "Me");
+ newRecord.setValue("recipient", recipient);
+ newRecord.setValue("timestamp", timestamp);
+ newRecord.setValue("message", message);
+ if (!insertRecord(rowCount(), newRecord)) {
+ qWarning() << "Failed to send message:" << lastError().text();
+ return;
+ }
+
+ submitAll();
+}
diff --git a/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.h b/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.h
new file mode 100644
index 00000000..0ce12049
--- /dev/null
+++ b/examples/controls/chattutorial/chapter5-styling/sqlconversationmodel.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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$
+**
+****************************************************************************/
+
+#ifndef SQLCONVERSATIONMODEL_H
+#define SQLCONVERSATIONMODEL_H
+
+#include <QSqlTableModel>
+
+class SqlConversationModel : public QSqlTableModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QString recipient READ recipient WRITE setRecipient NOTIFY recipientChanged)
+
+public:
+ SqlConversationModel(QObject *parent = 0);
+
+ QString recipient() const;
+ void setRecipient(const QString &recipient);
+
+ QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
+
+ Q_INVOKABLE void sendMessage(const QString &recipient, const QString &message);
+
+signals:
+ void recipientChanged();
+
+private:
+ QString m_recipient;
+};
+
+#endif // SQLCONVERSATIONMODEL_H
diff --git a/examples/controls/chattutorial/chattutorial.pro b/examples/controls/chattutorial/chattutorial.pro
new file mode 100644
index 00000000..2f38254e
--- /dev/null
+++ b/examples/controls/chattutorial/chattutorial.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ chapter1-settingup \
+ chapter2-lists \
+ chapter3-navigation \
+ chapter4-models \
+ chapter5-styling
diff --git a/examples/controls/chattutorial/shared/Albert Einstein.png b/examples/controls/chattutorial/shared/Albert Einstein.png
new file mode 100644
index 00000000..47cb15f6
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Albert Einstein.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Albert Einstein@2x.png b/examples/controls/chattutorial/shared/Albert Einstein@2x.png
new file mode 100644
index 00000000..c80ddd15
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Albert Einstein@2x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Albert Einstein@3x.png b/examples/controls/chattutorial/shared/Albert Einstein@3x.png
new file mode 100644
index 00000000..41778835
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Albert Einstein@3x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Albert Einstein@4x.png b/examples/controls/chattutorial/shared/Albert Einstein@4x.png
new file mode 100644
index 00000000..88768902
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Albert Einstein@4x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Ernest Hemingway.png b/examples/controls/chattutorial/shared/Ernest Hemingway.png
new file mode 100644
index 00000000..988c2416
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Ernest Hemingway.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Ernest Hemingway@2x.png b/examples/controls/chattutorial/shared/Ernest Hemingway@2x.png
new file mode 100644
index 00000000..efffc1f2
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Ernest Hemingway@2x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Ernest Hemingway@3x.png b/examples/controls/chattutorial/shared/Ernest Hemingway@3x.png
new file mode 100644
index 00000000..12633ec2
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Ernest Hemingway@3x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Ernest Hemingway@4x.png b/examples/controls/chattutorial/shared/Ernest Hemingway@4x.png
new file mode 100644
index 00000000..f5639280
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Ernest Hemingway@4x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Hans Gude.png b/examples/controls/chattutorial/shared/Hans Gude.png
new file mode 100644
index 00000000..7367a4a4
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Hans Gude.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Hans Gude@2x.png b/examples/controls/chattutorial/shared/Hans Gude@2x.png
new file mode 100644
index 00000000..c3a394e1
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Hans Gude@2x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Hans Gude@3x.png b/examples/controls/chattutorial/shared/Hans Gude@3x.png
new file mode 100644
index 00000000..38ec67ee
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Hans Gude@3x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/Hans Gude@4x.png b/examples/controls/chattutorial/shared/Hans Gude@4x.png
new file mode 100644
index 00000000..8c75d3e0
--- /dev/null
+++ b/examples/controls/chattutorial/shared/Hans Gude@4x.png
Binary files differ
diff --git a/examples/controls/chattutorial/shared/shared.qrc b/examples/controls/chattutorial/shared/shared.qrc
new file mode 100644
index 00000000..8e112513
--- /dev/null
+++ b/examples/controls/chattutorial/shared/shared.qrc
@@ -0,0 +1,16 @@
+<RCC>
+ <qresource prefix="/">
+ <file>Albert Einstein.png</file>
+ <file>Albert Einstein@2x.png</file>
+ <file>Albert Einstein@3x.png</file>
+ <file>Albert Einstein@4x.png</file>
+ <file>Ernest Hemingway.png</file>
+ <file>Ernest Hemingway@2x.png</file>
+ <file>Ernest Hemingway@3x.png</file>
+ <file>Ernest Hemingway@4x.png</file>
+ <file>Hans Gude.png</file>
+ <file>Hans Gude@2x.png</file>
+ <file>Hans Gude@3x.png</file>
+ <file>Hans Gude@4x.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/controls/controls.pro b/examples/controls/controls.pro
index 889077f2..4f0f2fcc 100644
--- a/examples/controls/controls.pro
+++ b/examples/controls/controls.pro
@@ -1,3 +1,4 @@
TEMPLATE = subdirs
SUBDIRS += \
- gallery
+ gallery \
+ chattutorial
diff --git a/examples/controls/gallery/gallery.qml b/examples/controls/gallery/gallery.qml
index ac808649..fd019c65 100644
--- a/examples/controls/gallery/gallery.qml
+++ b/examples/controls/gallery/gallery.qml
@@ -63,8 +63,10 @@ ApplicationWindow {
anchors.fill: parent
ToolButton {
- label: Image {
- anchors.centerIn: parent
+ contentItem: Image {
+ fillMode: Image.Pad
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignVCenter
source: "qrc:/images/drawer.png"
}
onClicked: drawer.open()
@@ -81,8 +83,10 @@ ApplicationWindow {
}
ToolButton {
- label: Image {
- anchors.centerIn: parent
+ contentItem: Image {
+ fillMode: Image.Pad
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignVCenter
source: "qrc:/images/menu.png"
}
onClicked: optionsMenu.open()
diff --git a/examples/controls/gallery/pages/BusyIndicatorPage.qml b/examples/controls/gallery/pages/BusyIndicatorPage.qml
index 2d538216..5aed6e59 100644
--- a/examples/controls/gallery/pages/BusyIndicatorPage.qml
+++ b/examples/controls/gallery/pages/BusyIndicatorPage.qml
@@ -53,7 +53,7 @@ Pane {
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
text: "BusyIndicator is used to indicate activity while content is being loaded,"
- + " or the UI is blocked waiting for a resource to become available."
+ + " or when the UI is blocked waiting for a resource to become available."
}
BusyIndicator {
diff --git a/examples/controls/gallery/pages/ComboBoxPage.qml b/examples/controls/gallery/pages/ComboBoxPage.qml
index 3c497c48..4400612f 100644
--- a/examples/controls/gallery/pages/ComboBoxPage.qml
+++ b/examples/controls/gallery/pages/ComboBoxPage.qml
@@ -52,8 +52,8 @@ Pane {
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
- text: "ComboBox is a combined button and popup list. It provides means of presenting a "
- + "list of options to the user in a way that takes up the minimum amount of screen space."
+ text: "ComboBox is a combined button and popup list. It presents "
+ + "a list of options to the user that occupies minimal screen space."
}
ComboBox {
diff --git a/examples/controls/gallery/pages/GroupBoxPage.qml b/examples/controls/gallery/pages/GroupBoxPage.qml
index e9d67849..996e65d2 100644
--- a/examples/controls/gallery/pages/GroupBoxPage.qml
+++ b/examples/controls/gallery/pages/GroupBoxPage.qml
@@ -54,7 +54,7 @@ Pane {
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
- text: "GroupBox is used to layout a logical group of controls together, within a titled visual frame."
+ text: "A GroupBox provides a frame, a title on top of it, and a logical group of controls within that frame."
}
GroupBox {
diff --git a/examples/controls/gallery/pages/StackViewPage.qml b/examples/controls/gallery/pages/StackViewPage.qml
index 42e1df43..19416aa6 100644
--- a/examples/controls/gallery/pages/StackViewPage.qml
+++ b/examples/controls/gallery/pages/StackViewPage.qml
@@ -60,7 +60,9 @@ StackView {
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
- text: "StackView provides a stack-based navigation model."
+ text: "StackView provides a stack-based navigation model which can be used with a set of interlinked pages. "
+ + "Items are pushed onto the stack as the user navigates deeper into the material, and popped off again "
+ + "when he chooses to go back."
}
Button {
diff --git a/examples/controls/gallery/pages/SwipeViewPage.qml b/examples/controls/gallery/pages/SwipeViewPage.qml
index 29739451..aded5d73 100644
--- a/examples/controls/gallery/pages/SwipeViewPage.qml
+++ b/examples/controls/gallery/pages/SwipeViewPage.qml
@@ -64,7 +64,8 @@ Pane {
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
- text: "SwipeView provides a swipe-based navigation model."
+ text: "SwipeView provides a navigation model that simplifies horizontal paged scrolling. "
+ + "The page indicator on the bottom shows which is the presently active page."
}
Image {
diff --git a/examples/controls/gallery/pages/TabBarPage.qml b/examples/controls/gallery/pages/TabBarPage.qml
index 0ab4a100..7e465ec3 100644
--- a/examples/controls/gallery/pages/TabBarPage.qml
+++ b/examples/controls/gallery/pages/TabBarPage.qml
@@ -41,14 +41,12 @@
import QtQuick 2.6
import Qt.labs.controls 1.0
-Pane {
- id: pane
- padding: 0
+Page {
+ id: page
SwipeView {
id: swipeView
anchors.fill: parent
- anchors.bottomMargin: tabBar.height
currentIndex: tabBar.currentIndex
Repeater {
@@ -66,7 +64,8 @@ Pane {
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
- text: "TabBar provides a tab-based navigation model."
+ text: "TabBar is a bar with icons or text which allows the user"
+ + "to switch between different subtasks, views, or modes."
}
Image {
@@ -78,10 +77,8 @@ Pane {
}
}
- TabBar {
+ footer: TabBar {
id: tabBar
- width: parent.width
- anchors.bottom: parent.bottom
currentIndex: swipeView.currentIndex
TabButton {
diff --git a/src/controls/controls.pri b/src/controls/controls.pri
index 005ee839..7aa9447f 100644
--- a/src/controls/controls.pri
+++ b/src/controls/controls.pri
@@ -1,4 +1,5 @@
HEADERS += \
+ $$PWD/qquickcolorimageprovider_p.h \
$$PWD/qquickproxytheme_p.h \
$$PWD/qquickstyle_p.h \
$$PWD/qquickstyleselector_p.h \
@@ -6,6 +7,7 @@ HEADERS += \
$$PWD/qquickpaddedrectangle_p.h
SOURCES += \
+ $$PWD/qquickcolorimageprovider.cpp \
$$PWD/qquickproxytheme.cpp \
$$PWD/qquickstyle.cpp \
$$PWD/qquickstyleselector.cpp \
diff --git a/src/imports/controls/universal/qquickuniversalimageprovider.cpp b/src/controls/qquickcolorimageprovider.cpp
index 7cb7b926..582b73ed 100644
--- a/src/imports/controls/universal/qquickuniversalimageprovider.cpp
+++ b/src/controls/qquickcolorimageprovider.cpp
@@ -34,7 +34,7 @@
**
****************************************************************************/
-#include "qquickuniversalimageprovider_p.h"
+#include "qquickcolorimageprovider_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qpainter.h>
@@ -44,11 +44,12 @@
QT_BEGIN_NAMESPACE
-QQuickUniversalImageProvider::QQuickUniversalImageProvider() : QQuickImageProvider(Image)
+QQuickColorImageProvider::QQuickColorImageProvider(const QString &path)
+ : QQuickImageProvider(Image), m_path(path)
{
}
-QImage QQuickUniversalImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
+QImage QQuickColorImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(requestedSize);
@@ -56,11 +57,11 @@ QImage QQuickUniversalImageProvider::requestImage(const QString &id, QSize *size
QString name = id.left(sep);
QString color = id.mid(sep + 1);
qreal dpr = qApp->primaryScreen()->devicePixelRatio();
- QString file = qt_findAtNxFile(QStringLiteral(":/qt-project.org/imports/Qt/labs/controls/universal/images/") + name + QStringLiteral(".png"), dpr);
+ QString file = qt_findAtNxFile(m_path + QLatin1Char('/') + name + QStringLiteral(".png"), dpr);
QImage image(file);
if (image.isNull()) {
- qWarning() << "QQuickUniversalImageProvider: unknown id:" << id;
+ qWarning() << "QQuickColorImageProvider: unknown id:" << id;
return QImage();
}
diff --git a/src/imports/controls/universal/qquickuniversalimageprovider_p.h b/src/controls/qquickcolorimageprovider_p.h
index 15648157..6f55f75f 100644
--- a/src/imports/controls/universal/qquickuniversalimageprovider_p.h
+++ b/src/controls/qquickcolorimageprovider_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QQUICKUNIVERSALIMAGEPROVIDER_P_H
-#define QQUICKUNIVERSALIMAGEPROVIDER_P_H
+#ifndef QQUICKCOLORIMAGEPROVIDER_P_H
+#define QQUICKCOLORIMAGEPROVIDER_P_H
//
// W A R N I N G
@@ -52,14 +52,17 @@
QT_BEGIN_NAMESPACE
-class QQuickUniversalImageProvider : public QQuickImageProvider
+class QQuickColorImageProvider : public QQuickImageProvider
{
public:
- QQuickUniversalImageProvider();
+ QQuickColorImageProvider(const QString &path);
- QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) Q_DECL_OVERRIDE;
+ QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
+
+private:
+ QString m_path;
};
QT_END_NAMESPACE
-#endif // QQUICKUNIVERSALIMAGEPROVIDER_P_H
+#endif // QQUICKOCOLORIMAGEPROVIDER_P_H
diff --git a/src/controls/qquickpaddedrectangle_p.h b/src/controls/qquickpaddedrectangle_p.h
index 5c0a8919..690448d6 100644
--- a/src/controls/qquickpaddedrectangle_p.h
+++ b/src/controls/qquickpaddedrectangle_p.h
@@ -62,7 +62,7 @@ class QQuickPaddedRectangle : public QQuickRectangle
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL)
public:
- QQuickPaddedRectangle(QQuickItem *parent = Q_NULLPTR);
+ QQuickPaddedRectangle(QQuickItem *parent = nullptr);
qreal padding() const;
void setPadding(qreal padding);
@@ -92,7 +92,7 @@ Q_SIGNALS:
void bottomPaddingChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
private:
void setTopPadding(qreal padding, bool has);
diff --git a/src/controls/qquickproxytheme_p.h b/src/controls/qquickproxytheme_p.h
index 47f931b5..6d7040e5 100644
--- a/src/controls/qquickproxytheme_p.h
+++ b/src/controls/qquickproxytheme_p.h
@@ -61,33 +61,33 @@ public:
QPlatformTheme* theme() const;
- QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE;
- QPlatformMenu* createPlatformMenu() const Q_DECL_OVERRIDE;
- QPlatformMenuBar* createPlatformMenuBar() const Q_DECL_OVERRIDE;
- void showPlatformMenuBar() Q_DECL_OVERRIDE;
+ QPlatformMenuItem* createPlatformMenuItem() const override;
+ QPlatformMenu* createPlatformMenu() const override;
+ QPlatformMenuBar* createPlatformMenuBar() const override;
+ void showPlatformMenuBar() override;
- bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE;
- QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE;
+ bool usePlatformNativeDialog(DialogType type) const override;
+ QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;
#ifndef QT_NO_SYSTEMTRAYICON
- QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE;
+ QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override;
#endif
- const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
+ const QPalette *palette(Palette type = SystemPalette) const override;
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
+ const QFont *font(Font type = SystemFont) const override;
- QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ QVariant themeHint(ThemeHint hint) const override;
- QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE;
+ QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override;
QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE;
+ QPlatformTheme::IconOptions iconOptions = 0) const override;
- QIconEngine *createIconEngine(const QString &iconName) const Q_DECL_OVERRIDE;
+ QIconEngine *createIconEngine(const QString &iconName) const override;
- QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const Q_DECL_OVERRIDE;
+ QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const override;
- QString standardButtonText(int button) const Q_DECL_OVERRIDE;
+ QString standardButtonText(int button) const override;
private:
QPlatformTheme *m_theme;
diff --git a/src/controls/qquickstyle.cpp b/src/controls/qquickstyle.cpp
index 0ca6558e..320148c3 100644
--- a/src/controls/qquickstyle.cpp
+++ b/src/controls/qquickstyle.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
static QQuickStyle *attachedStyle(const QMetaObject *type, QObject *object, bool create = false)
{
if (!object)
- return Q_NULLPTR;
+ return nullptr;
int idx = -1;
return qobject_cast<QQuickStyle *>(qmlAttachedPropertiesObject(&idx, object, type, create));
}
@@ -55,7 +55,7 @@ static QQuickStyle *attachedStyle(const QMetaObject *type, QObject *object, bool
static QQuickStyle *findParentStyle(const QMetaObject *type, QObject *parent)
{
if (!parent)
- return Q_NULLPTR;
+ return nullptr;
QQuickStyle *style = attachedStyle(type, parent);
if (style)
@@ -97,7 +97,7 @@ static QQuickStyle *findParentStyle(const QMetaObject *type, QObject *parent)
return style;
}
- return Q_NULLPTR;
+ return nullptr;
}
static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *object)
@@ -109,7 +109,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob
if (QQuickWindow *window = qobject_cast<QQuickWindow *>(object)) {
item = window->contentItem();
- foreach (QObject *child, window->children()) {
+ const auto windowChildren = window->children();
+ for (QObject *child : windowChildren) {
QQuickWindow *childWindow = qobject_cast<QQuickWindow *>(child);
if (childWindow) {
QQuickStyle *style = attachedStyle(type, childWindow);
@@ -127,7 +128,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob
}
if (item) {
- foreach (QQuickItem *child, item->childItems()) {
+ const auto childItems = item->childItems();
+ for (QQuickItem *child : childItems) {
QQuickStyle *style = attachedStyle(type, child);
if (style)
children += style;
@@ -135,7 +137,8 @@ static QList<QQuickStyle *> findChildStyles(const QMetaObject *type, QObject *ob
children += findChildStyles(type, child);
}
- foreach (QObject *child, item->children()) {
+ const auto itemChildren = item->children();
+ for (QObject *child : itemChildren) {
if (!qobject_cast<QQuickItem *>(child)) {
QQuickStyle *style = attachedStyle(type, child);
if (style)
@@ -162,7 +165,7 @@ QQuickStyle::~QQuickStyle()
if (item)
QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Parent);
- setParentStyle(Q_NULLPTR);
+ setParentStyle(nullptr);
}
QSharedPointer<QSettings> QQuickStyle::settings(const QString &group)
@@ -214,8 +217,8 @@ void QQuickStyle::init()
if (parentStyle)
setParentStyle(parentStyle);
- QList<QQuickStyle *> children = findChildStyles(metaObject(), parent);
- foreach (QQuickStyle *child, children)
+ const QList<QQuickStyle *> children = findChildStyles(metaObject(), parent);
+ for (QQuickStyle *child : children)
child->setParentStyle(this);
}
diff --git a/src/controls/qquickstyle_p.h b/src/controls/qquickstyle_p.h
index 02ee667a..36a2320c 100644
--- a/src/controls/qquickstyle_p.h
+++ b/src/controls/qquickstyle_p.h
@@ -64,7 +64,7 @@ class QQuickStyle : public QObject, public QQuickItemChangeListener
Q_OBJECT
public:
- explicit QQuickStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickStyle(QObject *parent = nullptr);
~QQuickStyle();
static QSharedPointer<QSettings> settings(const QString &group = QString());
@@ -79,7 +79,7 @@ protected:
virtual void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent);
- void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE;
+ void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
private:
QList<QQuickStyle *> m_childStyles;
diff --git a/src/controls/qquickstyleselector.cpp b/src/controls/qquickstyleselector.cpp
index b8a15ee9..0f0fb3b0 100644
--- a/src/controls/qquickstyleselector.cpp
+++ b/src/controls/qquickstyleselector.cpp
@@ -35,7 +35,6 @@
#include "qquickstyleselector_p.h"
#include "qquickstyleselector_p_p.h"
-#include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>
@@ -107,7 +106,7 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
*/
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
- foreach (const QString &s, selectors) {
+ for (const QString &s : selectors) {
QString prospectiveBase = path + s + QLatin1Char('/');
QStringList remainingSelectors = selectors;
remainingSelectors.removeAll(s);
@@ -120,7 +119,7 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
// 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.
- if (!QFile::exists(path + fileName))
+ if (!QFileInfo::exists(path + fileName))
return QString();
return path + fileName;
}
diff --git a/src/imports/calendar/plugins.qmltypes b/src/imports/calendar/plugins.qmltypes
index 74c407c4..17295f06 100644
--- a/src/imports/calendar/plugins.qmltypes
+++ b/src/imports/calendar/plugins.qmltypes
@@ -78,6 +78,7 @@ Module {
Property { name: "spacing"; type: "double" }
Property { name: "locale"; type: "QLocale" }
Property { name: "mirrored"; type: "bool"; isReadonly: true }
+ Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
diff --git a/src/imports/calendar/qquickcalendar_p.h b/src/imports/calendar/qquickcalendar_p.h
index c44a6a1c..cdc9cc94 100644
--- a/src/imports/calendar/qquickcalendar_p.h
+++ b/src/imports/calendar/qquickcalendar_p.h
@@ -59,7 +59,7 @@ class QQuickCalendar : public QObject
Q_OBJECT
public:
- explicit QQuickCalendar(QObject *parent = Q_NULLPTR);
+ explicit QQuickCalendar(QObject *parent = nullptr);
enum Month {
January,
diff --git a/src/imports/calendar/qquickcalendarmodel_p.h b/src/imports/calendar/qquickcalendarmodel_p.h
index 4f17980a..fa7717ed 100644
--- a/src/imports/calendar/qquickcalendarmodel_p.h
+++ b/src/imports/calendar/qquickcalendarmodel_p.h
@@ -66,7 +66,7 @@ class QQuickCalendarModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
public:
- explicit QQuickCalendarModel(QObject *parent = Q_NULLPTR);
+ explicit QQuickCalendarModel(QObject *parent = nullptr);
QDate from() const;
void setFrom(const QDate &from);
@@ -84,9 +84,9 @@ public:
YearRole
};
- QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_SIGNALS:
void fromChanged();
@@ -94,8 +94,8 @@ Q_SIGNALS:
void countChanged();
protected:
- void classBegin() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void classBegin() override;
+ void componentComplete() override;
private:
Q_DISABLE_COPY(QQuickCalendarModel)
diff --git a/src/imports/calendar/qquickdayofweekmodel_p.h b/src/imports/calendar/qquickdayofweekmodel_p.h
index 90ebdc6c..9e76b961 100644
--- a/src/imports/calendar/qquickdayofweekmodel_p.h
+++ b/src/imports/calendar/qquickdayofweekmodel_p.h
@@ -63,7 +63,7 @@ class QQuickDayOfWeekModel : public QAbstractListModel
Q_PROPERTY(int count READ rowCount CONSTANT FINAL)
public:
- explicit QQuickDayOfWeekModel(QObject *parent = Q_NULLPTR);
+ explicit QQuickDayOfWeekModel(QObject *parent = nullptr);
QLocale locale() const;
void setLocale(const QLocale &locale);
@@ -77,9 +77,9 @@ public:
NarrowNameRole
};
- QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_SIGNALS:
void localeChanged();
diff --git a/src/imports/calendar/qquickdayofweekrow.cpp b/src/imports/calendar/qquickdayofweekrow.cpp
index 76bcf5df..1f5e4387 100644
--- a/src/imports/calendar/qquickdayofweekrow.cpp
+++ b/src/imports/calendar/qquickdayofweekrow.cpp
@@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
class QQuickDayOfWeekRowPrivate : public QQuickControlPrivate
{
public:
- QQuickDayOfWeekRowPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { }
+ QQuickDayOfWeekRowPrivate() : delegate(nullptr), model(nullptr) { }
void resizeItems();
@@ -90,7 +90,8 @@ void QQuickDayOfWeekRowPrivate::resizeItems()
itemSize.setWidth((contentItem->width() - 6 * spacing) / 7);
itemSize.setHeight(contentItem->height());
- foreach (QQuickItem *item, contentItem->childItems())
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *item : childItems)
item->setSize(itemSize);
}
diff --git a/src/imports/calendar/qquickdayofweekrow_p.h b/src/imports/calendar/qquickdayofweekrow_p.h
index d1e5e16f..b0c4ead9 100644
--- a/src/imports/calendar/qquickdayofweekrow_p.h
+++ b/src/imports/calendar/qquickdayofweekrow_p.h
@@ -62,7 +62,7 @@ class QQuickDayOfWeekRow : public QQuickControl
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
- explicit QQuickDayOfWeekRow(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickDayOfWeekRow(QQuickItem *parent = nullptr);
QVariant source() const;
void setSource(const QVariant &source);
@@ -75,10 +75,10 @@ Q_SIGNALS:
void delegateChanged();
protected:
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void localeChange(const QLocale &newLocale, const QLocale &oldLocale) Q_DECL_OVERRIDE;
- void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
+ void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
private:
Q_DISABLE_COPY(QQuickDayOfWeekRow)
diff --git a/src/imports/calendar/qquickmonthgrid.cpp b/src/imports/calendar/qquickmonthgrid.cpp
index fde4a71d..c6ad3d53 100644
--- a/src/imports/calendar/qquickmonthgrid.cpp
+++ b/src/imports/calendar/qquickmonthgrid.cpp
@@ -78,7 +78,7 @@ class QQuickMonthGridPrivate : public QQuickControlPrivate
Q_DECLARE_PUBLIC(QQuickMonthGrid)
public:
- QQuickMonthGridPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR), delegate(Q_NULLPTR) { }
+ QQuickMonthGridPrivate() : pressTimer(0), pressedItem(nullptr), model(nullptr), delegate(nullptr) { }
void resizeItems();
@@ -108,7 +108,8 @@ void QQuickMonthGridPrivate::resizeItems()
itemSize.setWidth((contentItem->width() - 6 * spacing) / 7);
itemSize.setHeight((contentItem->height() - 5 * spacing) / 6);
- foreach (QQuickItem *item, contentItem->childItems())
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *item : childItems)
item->setSize(itemSize);
}
@@ -119,7 +120,7 @@ QQuickItem *QQuickMonthGridPrivate::cellAt(const QPoint &pos) const
QPointF mapped = q->mapToItem(contentItem, pos);
return contentItem->childAt(mapped.x(), mapped.y());
}
- return Q_NULLPTR;
+ return nullptr;
}
QDate QQuickMonthGridPrivate::dateOf(QQuickItem *cell) const
@@ -150,7 +151,7 @@ void QQuickMonthGridPrivate::clearPress(bool clicked)
emit q->clicked(pressedDate);
}
pressedDate = QDate();
- pressedItem = Q_NULLPTR;
+ pressedItem = nullptr;
}
void QQuickMonthGridPrivate::setContextProperty(QQuickItem *item, const QString &name, const QVariant &value)
@@ -335,7 +336,8 @@ void QQuickMonthGrid::componentComplete()
Q_D(QQuickMonthGrid);
QQuickControl::componentComplete();
if (d->contentItem) {
- foreach (QQuickItem *child, d->contentItem->childItems()) {
+ const auto childItems = d->contentItem->childItems();
+ for (QQuickItem *child : childItems) {
if (!QQuickItemPrivate::get(child)->isTransparentForPositioner())
d->setContextProperty(child, QStringLiteral("pressed"), false);
}
diff --git a/src/imports/calendar/qquickmonthgrid_p.h b/src/imports/calendar/qquickmonthgrid_p.h
index b2d8124a..93ba3900 100644
--- a/src/imports/calendar/qquickmonthgrid_p.h
+++ b/src/imports/calendar/qquickmonthgrid_p.h
@@ -65,7 +65,7 @@ class QQuickMonthGrid : public QQuickControl
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
- explicit QQuickMonthGrid(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickMonthGrid(QQuickItem *parent = nullptr);
int month() const;
void setMonth(int month);
@@ -95,17 +95,17 @@ Q_SIGNALS:
void pressAndHold(const QDate &date);
protected:
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void localeChange(const QLocale &newLocale, const QLocale &oldLocale) Q_DECL_OVERRIDE;
- void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE;
- void updatePolish() Q_DECL_OVERRIDE;
-
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
+ void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
+ void updatePolish() override;
+
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void timerEvent(QTimerEvent *event) override;
private:
Q_DISABLE_COPY(QQuickMonthGrid)
diff --git a/src/imports/calendar/qquickmonthmodel_p.h b/src/imports/calendar/qquickmonthmodel_p.h
index 0f8347b5..578fe620 100644
--- a/src/imports/calendar/qquickmonthmodel_p.h
+++ b/src/imports/calendar/qquickmonthmodel_p.h
@@ -67,7 +67,7 @@ class QQuickMonthModel : public QAbstractListModel
Q_PROPERTY(int count READ rowCount CONSTANT FINAL)
public:
- explicit QQuickMonthModel(QObject *parent = Q_NULLPTR);
+ explicit QQuickMonthModel(QObject *parent = nullptr);
int month() const;
void setMonth(int month);
@@ -93,9 +93,9 @@ public:
YearRole
};
- QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_SIGNALS:
void monthChanged();
diff --git a/src/imports/calendar/qquickweeknumbercolumn.cpp b/src/imports/calendar/qquickweeknumbercolumn.cpp
index f31497c6..a128b500 100644
--- a/src/imports/calendar/qquickweeknumbercolumn.cpp
+++ b/src/imports/calendar/qquickweeknumbercolumn.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
class QQuickWeekNumberColumnPrivate : public QQuickControlPrivate
{
public:
- QQuickWeekNumberColumnPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { }
+ QQuickWeekNumberColumnPrivate() : delegate(nullptr), model(nullptr) { }
void resizeItems();
@@ -92,7 +92,8 @@ void QQuickWeekNumberColumnPrivate::resizeItems()
itemSize.setWidth(contentItem->width());
itemSize.setHeight((contentItem->height() - 5 * spacing) / 6);
- foreach (QQuickItem *item, contentItem->childItems())
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *item : childItems)
item->setSize(itemSize);
}
diff --git a/src/imports/calendar/qquickweeknumbercolumn_p.h b/src/imports/calendar/qquickweeknumbercolumn_p.h
index 2cacdeac..f2e0e1cc 100644
--- a/src/imports/calendar/qquickweeknumbercolumn_p.h
+++ b/src/imports/calendar/qquickweeknumbercolumn_p.h
@@ -64,7 +64,7 @@ class QQuickWeekNumberColumn : public QQuickControl
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
- explicit QQuickWeekNumberColumn(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickWeekNumberColumn(QQuickItem *parent = nullptr);
int month() const;
void setMonth(int month);
@@ -85,10 +85,10 @@ Q_SIGNALS:
void delegateChanged();
protected:
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void localeChange(const QLocale &newLocale, const QLocale &oldLocale) Q_DECL_OVERRIDE;
- void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
+ void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
private:
Q_DISABLE_COPY(QQuickWeekNumberColumn)
diff --git a/src/imports/calendar/qquickweeknumbermodel_p.h b/src/imports/calendar/qquickweeknumbermodel_p.h
index 2c8b484f..74f2550f 100644
--- a/src/imports/calendar/qquickweeknumbermodel_p.h
+++ b/src/imports/calendar/qquickweeknumbermodel_p.h
@@ -65,7 +65,7 @@ class QQuickWeekNumberModel : public QAbstractListModel
Q_PROPERTY(int count READ rowCount CONSTANT FINAL)
public:
- explicit QQuickWeekNumberModel(QObject *parent = Q_NULLPTR);
+ explicit QQuickWeekNumberModel(QObject *parent = nullptr);
int month() const;
void setMonth(int month);
@@ -83,9 +83,9 @@ public:
WeekNumberRole = Qt::UserRole + 1
};
- QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
Q_SIGNALS:
void monthChanged();
diff --git a/src/imports/calendar/qtlabscalendarplugin.cpp b/src/imports/calendar/qtlabscalendarplugin.cpp
index 8d7d563d..4ecd5ddb 100644
--- a/src/imports/calendar/qtlabscalendarplugin.cpp
+++ b/src/imports/calendar/qtlabscalendarplugin.cpp
@@ -42,6 +42,13 @@
#include "qquickcalendarmodel_p.h"
#include "qquickcalendar_p.h"
+static inline void initResources()
+{
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_calendar);
+#endif
+}
+
QT_BEGIN_NAMESPACE
class QtLabsCalendarPlugin: public QQmlExtensionPlugin
@@ -50,9 +57,15 @@ class QtLabsCalendarPlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsCalendarPlugin(QObject *parent = nullptr);
void registerTypes(const char *uri);
};
+QtLabsCalendarPlugin::QtLabsCalendarPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
static QObject *calendarSingleton(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine);
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
index 290f4ce4..67e9bffe 100644
--- a/src/imports/controls/Button.qml
+++ b/src/imports/controls/Button.qml
@@ -41,21 +41,17 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
leftPadding: 8
rightPadding: 8
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
opacity: enabled || highlighted ? 1 : 0.3
@@ -64,7 +60,7 @@ T.Button {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index 4b7af3b1..52061681 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -41,13 +41,11 @@ T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -81,12 +79,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -96,5 +92,5 @@ T.CheckBox {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml
index 2745a0d8..6e3dc91b 100644
--- a/src/imports/controls/ComboBox.qml
+++ b/src/imports/controls/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
T.ComboBox {
diff --git a/src/imports/controls/Frame.qml b/src/imports/controls/Frame.qml
index 3c9326e1..1f1bfac6 100644
--- a/src/imports/controls/Frame.qml
+++ b/src/imports/controls/Frame.qml
@@ -52,13 +52,10 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
color: "transparent"
border.color: "#bdbebf"
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/GroupBox.qml b/src/imports/controls/GroupBox.qml
index bc1801c2..7ae14c24 100644
--- a/src/imports/controls/GroupBox.qml
+++ b/src/imports/controls/GroupBox.qml
@@ -70,8 +70,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -79,5 +79,5 @@ T.GroupBox {
color: "transparent"
border.color: "#bdbebf"
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/ItemDelegate.qml b/src/imports/controls/ItemDelegate.qml
index b5dfb4b6..13a13e1e 100644
--- a/src/imports/controls/ItemDelegate.qml
+++ b/src/imports/controls/ItemDelegate.qml
@@ -41,23 +41,19 @@ T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12
spacing: 12
- //! [label]
- label: Text {
- x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -67,7 +63,7 @@ T.ItemDelegate {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/MenuItem.qml b/src/imports/controls/MenuItem.qml
index ae5a8e38..75866fbe 100644
--- a/src/imports/controls/MenuItem.qml
+++ b/src/imports/controls/MenuItem.qml
@@ -40,21 +40,19 @@ import Qt.labs.templates 1.0 as T
T.MenuItem {
id: control
- implicitWidth: background ? background.implicitWidth
- : (label ? label.implicitWidth : 0) + (indicator ? indicator.implicitWidth : 0)
- + (label && indicator ? spacing : 0) + leftPadding + rightPadding
- implicitHeight: background ? background.implicitHeight
- : (label ? label.implicitHeight : 0) + (indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
+ indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -64,7 +62,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml
index 8e1e0bce..f1e10a6c 100644
--- a/src/imports/controls/RadioButton.qml
+++ b/src/imports/controls/RadioButton.qml
@@ -42,13 +42,11 @@ T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -78,12 +76,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -93,5 +89,5 @@ T.RadioButton {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml
index 77f89206..d3184626 100644
--- a/src/imports/controls/SpinBox.qml
+++ b/src/imports/controls/SpinBox.qml
@@ -74,6 +74,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/StackView.qml b/src/imports/controls/StackView.qml
index f0869307..2de21885 100644
--- a/src/imports/controls/StackView.qml
+++ b/src/imports/controls/StackView.qml
@@ -39,41 +39,41 @@ import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * -root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * -control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [popEnter]
//! [popExit]
popExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [popExit]
//! [pushEnter]
pushEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [pushEnter]
//! [pushExit]
pushExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * -root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * -control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [pushExit]
//! [replaceEnter]
replaceEnter: Transition {
- XAnimator { from: (root.mirrored ? -1 : 1) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: (control.mirrored ? -1 : 1) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
//! [replaceEnter]
//! [replaceExit]
replaceExit: Transition {
- XAnimator { from: 0; to: (root.mirrored ? -1 : 1) * -root.width; duration: 400; easing.type: Easing.OutCubic }
+ XAnimator { from: 0; to: (control.mirrored ? -1 : 1) * -control.width; duration: 400; easing.type: Easing.OutCubic }
}
//! [replaceExit]
}
diff --git a/src/imports/controls/Switch.qml b/src/imports/controls/Switch.qml
index 51348e77..01f561a1 100644
--- a/src/imports/controls/Switch.qml
+++ b/src/imports/controls/Switch.qml
@@ -41,13 +41,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 6
@@ -87,12 +85,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -102,5 +98,5 @@ T.Switch {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/TabButton.qml b/src/imports/controls/TabButton.qml
index 178a0a7f..63a88b10 100644
--- a/src/imports/controls/TabButton.qml
+++ b/src/imports/controls/TabButton.qml
@@ -41,20 +41,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.contentWidth + leftPadding + rightPadding : 0)
+ contentItem.contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.contentHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.contentHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,7 +58,7 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/TextArea.qml b/src/imports/controls/TextArea.qml
index 8326fc89..46b6bc6c 100644
--- a/src/imports/controls/TextArea.qml
+++ b/src/imports/controls/TextArea.qml
@@ -67,7 +67,7 @@ T.TextArea {
color: "#c2c2c2"
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
}
}
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml
index d9f31b2f..7abf540b 100644
--- a/src/imports/controls/TextField.qml
+++ b/src/imports/controls/TextField.qml
@@ -66,7 +66,7 @@ T.TextField {
color: "#bdbebf"
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
}
diff --git a/src/imports/controls/ToolButton.qml b/src/imports/controls/ToolButton.qml
index 314ce966..a610dc2b 100644
--- a/src/imports/controls/ToolButton.qml
+++ b/src/imports/controls/ToolButton.qml
@@ -41,20 +41,15 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? "#26282a" : "#c2c2c2"
@@ -62,7 +57,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index c3391929..32e86f3a 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -1,4 +1,4 @@
-QML_FILES = \
+QML_CONTROLS = \
ApplicationWindow.qml \
BusyIndicator.qml \
Button.qml \
@@ -33,3 +33,5 @@ QML_FILES = \
ToolBar.qml \
ToolButton.qml \
Tumbler.qml
+
+!qtquickcompiler: QML_FILES += $$QML_CONTROLS
diff --git a/src/imports/controls/controls.pro b/src/imports/controls/controls.pro
index b5c258eb..9a3f9628 100644
--- a/src/imports/controls/controls.pro
+++ b/src/imports/controls/controls.pro
@@ -27,5 +27,11 @@ RESOURCES += \
include(controls.pri)
!ios: include(designer/designer.pri)
+qtquickcompiler {
+ qmlfiles.prefix = /qt-project.org/imports/Qt/labs/controls
+ qmlfiles.files += $$QML_CONTROLS
+ RESOURCES += qmlfiles
+}
+
CONFIG += no_cxx_module
load(qml_plugin)
diff --git a/src/imports/controls/doc/images/qtlabscontrols-button-label.png b/src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png
index 73d8f2fb..73d8f2fb 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-button-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-button-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png
new file mode 100644
index 00000000..ee03535f
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter1.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif
new file mode 100644
index 00000000..17096519
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2-listview-header.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png
new file mode 100644
index 00000000..c2c49e3e
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter2.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif
new file mode 100644
index 00000000..07eb93b1
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-listview-header.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png
new file mode 100644
index 00000000..9ca0fe69
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3-view-margins.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif
new file mode 100644
index 00000000..1763b1f3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter3.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png
new file mode 100644
index 00000000..acbe1886
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-long-message.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png
new file mode 100644
index 00000000..e4a578cc
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4-message-timestamp.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif
new file mode 100644
index 00000000..dd47c4cb
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter4.gif
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
new file mode 100644
index 00000000..9a3d00bd
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
new file mode 100644
index 00000000..501ea772
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png
new file mode 100644
index 00000000..57782b58
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-material.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
new file mode 100644
index 00000000..22183c82
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png
new file mode 100644
index 00000000..327076d3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-contacts-universal.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
new file mode 100644
index 00000000..19a7b685
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
new file mode 100644
index 00000000..4cc4caa3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png
new file mode 100644
index 00000000..bdc9bcd3
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-material.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
new file mode 100644
index 00000000..f10d6cb6
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png
new file mode 100644
index 00000000..a6913c3c
--- /dev/null
+++ b/src/imports/controls/doc/images/qtlabscontrols-chattutorial-chapter5-conversations-universal.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png b/src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png
index d5a1ef2e..d5a1ef2e 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-checkbox-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-checkbox-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png b/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png
deleted file mode 100644
index a379d915..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-frame-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png b/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png
deleted file mode 100644
index 2ed75011..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-groupbox-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png
index 89f094c6..89f094c6 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-itemdelegate-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png b/src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png
index 457555b7..457555b7 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-radiobutton-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-radiobutton-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-switch-label.png b/src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png
index 50f608ab..50f608ab 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-switch-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-switch-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png b/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png
deleted file mode 100644
index 12b4c348..00000000
--- a/src/imports/controls/doc/images/qtlabscontrols-toolbar-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png b/src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png
index f4797098..f4797098 100644
--- a/src/imports/controls/doc/images/qtlabscontrols-toolbutton-label.png
+++ b/src/imports/controls/doc/images/qtlabscontrols-toolbutton-contentItem.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml
index 4fbeab08..ee59ab7f 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-button-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-button-contentItem.qml
@@ -32,7 +32,7 @@ Button {
width: 80
text: "Button"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: 'transparent'
border.color: 'red'
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml
index fcb3a49d..bef150a3 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-checkbox-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
CheckBox {
text: "CheckBox"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml
deleted file mode 100644
index e4c9e32b..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-frame-frame.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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 Qt.labs.controls 1.0
-
-Frame {
- width: 100
- height: 100
- Rectangle {
- parent: frame
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml
deleted file mode 100644
index 49ecc00d..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-groupbox-frame.qml
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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 Qt.labs.controls 1.0
-
-GroupBox {
- width: 100
- height: 100
- title: "GroupBox"
- Rectangle {
- parent: frame
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml
index 696560a5..43e6f85e 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-itemdelegate-contentItem.qml
@@ -33,7 +33,7 @@ ItemDelegate {
checked: true
checkable: true
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml
index eab52fbe..14bb7c47 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-radiobutton-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
RadioButton {
text: "RadioButton"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml
index c739bf57..99f2af7e 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-switch-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-switch-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
Switch {
text: "Switch"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: "transparent"
border.color: "red"
}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml b/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml
deleted file mode 100644
index b887d464..00000000
--- a/src/imports/controls/doc/snippets/qtlabscontrols-toolbar-frame.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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 Qt.labs.controls 1.0
-
-ToolBar {
- width: 100
- frame: Rectangle {
- anchors.fill: parent
- color: 'transparent'
- border.color: 'red'
- }
-}
diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml b/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml
index 5a8c3a50..9a25d130 100644
--- a/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-label.qml
+++ b/src/imports/controls/doc/snippets/qtlabscontrols-toolbutton-contentItem.qml
@@ -31,7 +31,7 @@ import Qt.labs.controls 1.0
ToolButton {
text: "ToolButton"
Rectangle {
- anchors.fill: label
+ anchors.fill: contentItem
color: 'transparent'
border.color: 'red'
}
diff --git a/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc b/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc
new file mode 100644
index 00000000..eeadd070
--- /dev/null
+++ b/src/imports/controls/doc/src/qtlabscontrols-chattutorial.qdoc
@@ -0,0 +1,861 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 chattutorial
+\title Qt Labs Controls - Chat Tutorial
+\brief Tutorial about writing a basic chat client using Qt Labs Controls.
+\ingroup qtlabscontrols-examples
+
+This tutorial shows how to write a basic chat application using Qt Labs
+Controls. It will also explain how to integrate an SQL database into a Qt
+application.
+
+\section1 Chapter 1: Setting Up
+
+When setting up a new project, it's easiest to use
+\l {Qt Creator Manual}{Qt Creator}. For this project, we chose the
+\l {Creating Qt Quick Projects}{Qt Quick application} template, which creates a
+basic "Hello World" application with all of the necessary files.
+
+\section2 main.cpp
+
+As we created a Qt Quick application, our \c main.cpp has two includes:
+
+\quotefromfile chattutorial/chapter1-settingup/main.cpp
+\skipto include
+\printline include
+\printline include
+
+The first gives us access to QGuiApplication. All Qt applications require
+an application object, but the precise type depends on what the application
+does. QCoreApplication is sufficient for non-graphical applications.
+QGuiApplication is sufficient for graphical applications that do not use
+\l {Qt Widgets}, while QApplication is required for those that do.
+
+The second include makes QQmlApplicationEngine available, along with
+some useful functions required for making C++ types accessible from QML.
+
+Within \c main(), we set up the application object and QML engine:
+
+\skipto main
+\printuntil }
+
+To enable Qt's support for \l {High DPI Support in Qt}{high DPI scaling}, it
+is necessary to set an attribute before the application object is constructed.
+
+After that's done, we construct the application object, passing any application
+arguments provided by the user.
+
+Next, the QML engine is created. \l QQmlApplicationEngine is a convenient
+wrapper over QQmlEngine, providing the \l {QQmlApplicationEngine::load}{load()}
+function to easily load QML for an application. It also adds some convenience
+for using \l {Using File Selectors with Qt Labs Controls}{file selectors}.
+
+Once we've set up things in C++, we can move on to the user interface in QML.
+
+\section2 main.qml
+
+\quotefromfile chattutorial/chapter1-settingup/main.qml
+\skipto import
+\printuntil import Qt.labs.controls 1.0
+
+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
+on.
+For the full list of types, see the \l {Qt Quick QML Types} documentation.
+
+Next, we import the Qt Labs Controls module. Amongst other things, this
+makes \l ApplicationWindow available:
+
+\skipto ApplicationWindow
+\printuntil visible: true
+\printuntil }
+\printuntil }
+\printuntil }
+
+ApplicationWindow is a \l Window with some added convenience for creating a
+\l {ApplicationWindow::}{header} and a \l {ApplicationWindow::}{footer}.
+It also provides the foundation for \l {Popup}{popups} and supports some
+basic styling, such as the background \l {Window::}{color}.
+
+There are three properties that are almost always set when using
+ApplicationWindow: \l {Window::}{width}, \l {Window::}{height}, and
+\l {Window::}{visible}.
+Once we've set these, we have a properly sized, empty window ready to be
+filled with content.
+
+The first \e "screen" in our application will be a list of contacts. It would
+be nice to have some text at the top of each screen that describes its purpose.
+The header and footer properties of ApplicationWindow could work in
+this situation. They have some characteristics that make them ideal for
+items that should be displayed on every screen of an application:
+
+\list
+\li They are anchored to the top and bottom of the window, respectively.
+\li They fill the width of the window.
+\endlist
+
+However, when the contents of the header and footer varies depending on
+which screen the user is viewing, it can be much easier to use \l Page.
+For now, we'll just add one page, but in the next chapter, we'll demonstrate
+how to navigate between several pages.
+
+Now that we have a Page, we can assign a \l Label to its \l {Page::}{header}
+property. Label extends the primitive \l Text item from the Qt Quick module by
+adding \l {Styling Qt Labs Controls}{styling} and \l {Control::}{font}
+inheritance. This means that a Label can look different depending on which
+style is in use, and can also propagate its pixel size to its children.
+
+We want some distance between the top of the application window and the text,
+so we set the \l {Text::padding}{padding} property. This will allocate extra
+space on each side of the label (within its bounds). We could have also set the
+\l {Text::}{topPadding} and \l {Text::}{bottomPadding} properties explicitly.
+
+We set the text of the label using the \c qsTr() function, which ensures that
+the text can be translated by \l {Writing Source Code for Translation}{Qt's
+translation system}. It's a good idea to do this for text that will
+be visible to the end users of your application.
+
+By default, text is vertically aligned to the top of its bounds, while the
+horizontal alignment depends on the natural direction of the text; for example,
+text that is read from left to right will be aligned to the left. If we
+used these defaults, our text would be at the top-left corner of the window.
+This is not desirable for a header, so we align the text to the center of its
+bounds, both horizontally and vertically.
+
+\section2 The Project File
+
+The \c .pro or \l {Creating Project Files}{project} file contains all of the
+information needed by \l {qmake Manual}{qmake} to generate a Makefile, which is
+then used to compile and link the application.
+
+\quotefromfile chattutorial/chapter1-settingup/chapter1-settingup.pro
+\printline TEMPLATE
+
+The first line tells \c qmake which kind of project this is. We're building an
+application, so we use the \c app template.
+
+\printline QT
+
+The next line declares the Qt libraries that we want to use from C++.
+
+\printline CONFIG
+
+This line states that a C++11 compatible compiler is required to build the
+project.
+
+\printline SOURCES
+
+The \c SOURCES variable lists all of the source files that should be compiled.
+A similar variable, \c HEADERS, is available for header files.
+
+\printline RESOURCES
+
+The next line tells \c qmake that we have a collection of
+\l {The Qt Resource System}{resources} that should be built into the
+executable.
+
+\printline QML_IMPORT_PATH
+
+\c QML_IMPORT_PATH is added by Qt Creator in case you have a custom module that
+you'd like to be made available to Creator's code model.
+
+\printline include
+
+This line includes a generated \c .pri file that handles deployment of our
+application to certain devices.
+
+Now we can build and run the application:
+
+\image qtlabscontrols-chattutorial-chapter1.png
+
+\section1 Chapter 2: Lists
+
+In this chapter, we'll explain how to create a list of interactive items using
+\l ListView and \l ItemDelegate.
+
+ListView comes from the Qt Quick module, and displays a list of items
+populated from a \l {Model/View Programming}{model}. ItemDelegate comes from
+the Qt Labs Controls module, and provides a standard view item for use in views
+and controls such as ListView and \l ComboBox. For example, each ItemDelegate
+can display text, be checked on and off, and react to mouse clicks.
+
+Here is our ListView:
+
+\quotefromfile chattutorial/chapter2-lists/main.qml
+\dots 8
+\codeline
+\skipto ListView
+\printuntil }
+\printuntil }
+\printuntil }
+\codeline
+\dots 8
+
+\section2 Sizing and Positioning
+
+The first thing we do is set a size for the view. It should fill the available
+space on the page, so we use \l {Item::anchors}{anchors.fill}. Note that
+Page ensures that its header and footer have enough of their own space
+reserved, so the view in this case will sit below the header, for example.
+
+Next, we set \l {Flickable::leftMargin}{margins} around the ListView to put
+some distance between it and the edges of the window. The margin properties
+reserve space within the bounds of the view, which means that the empty areas
+can still be \e "flicked" by the user.
+
+The items should be nicely spaced out within the view, so the
+\l {ListView::}{spacing} property is set to \c 20.
+
+\section2 Model
+
+In order to quickly populate the view with some items, we've used a JavaScript
+array as the model. One of the greatest strengths of QML is its ability to
+make prototyping an application extremely quick, and this is an example of
+that. It's also possible to simply assign a \l {Integers as Models}{number} to
+the model property to indicate how many items you need. For example, if you
+assign \c 10 to the \c model property, each item's display text will be a
+number from \c 0 to \c 9.
+
+However, once the application gets past the prototype stage, it quickly becomes
+necessary to use some real data. For this, it's best to use a proper C++ model
+by \l {QAbstractItemModel subclass}{subclassing QAbstractItemModel}.
+
+\section2 Delegate
+
+On to the \l {ListView::}{delegate}. We assign the corresponding text from the
+model to the \l {ItemDelegate::}{text} property of ItemDelegate. The exact
+manner in which the data from the model is made available to each delegate
+depends on the type of model used. See \l {Models and Views in Qt Quick} for
+more information.
+
+In our application, the width of each item in the view should be the same
+as the width of the view. This ensures that the user has a lot of room with
+which to select a contact from the list, which is an important factor on
+devices with small touch screens, like mobile phones. However, the width of the
+view includes our \c 48 pixel margins, so we must account for that in our
+assignment to the width property.
+
+Next, we define an \l Image. This will display a picture of the user's contact.
+The image will be \c 40 pixels wide and \c 40 pixels high. We'll base the
+height of the delegate on the image's height, so that we don't have any empty
+vertical space.
+
+\image qtlabscontrols-chattutorial-chapter2.png
+
+\section1 Chapter 3: Navigation
+
+In this chapter, you'll learn how to use \l StackView to navigate between pages
+in an application. Here's the revised \c main.qml:
+
+\quotefromfile chattutorial/chapter3-navigation/main.qml
+\skipto import
+\printuntil }
+\printuntil }
+\printuntil }
+
+\section2 StackView
+
+As its name suggests, StackView provides stack-based navigation. The last item
+to be \e "pushed" onto the stack is the first one to be removed, and the
+top-most item is always the one that is visible.
+
+In the same manner as we did with Page, we tell the StackView to fill the
+application window. The only thing left to do after that is to give it an item
+to display, via \l {StackView::}{initialItem}. StackView accepts
+\l {Item}{items}, \l {Component}{components} and \l [QML]{url}{URLs}.
+
+You'll notice that we moved the code for the contact list into
+\c ContactPage.qml. It's a good idea to do this as soon as you have a general
+idea of which screens your application will contain. Doing so not only makes
+your code easier to read, but ensures that items are only instantiated from
+a given component when completely necessary, reducing memory usage.
+
+\note Qt Creator provides several convenient
+\l {Refactoring QML Code}{refactoring options for QML}, one of which allows you
+to move a block of code into a separate file (\c {Alt + Enter > Move Component
+into Separate File}).
+
+Another thing to consider when using ListView is whether to refer to it by
+\l {Item::}{id}, or use the attached \l {ListView::view}{ListView.view}
+property. The best approach depends on a few different factors. Giving the
+view an id will result in shorter and more efficient binding expressions, as
+the attached property has a very small amount of overhead. However, if you plan
+on reusing the delegate in other views, it is better to use the attached
+properties to avoid tying the delegate to a particular view. For example, using
+the attached properties, the \c width assignment in our delegate becomes:
+
+\code
+width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin
+\endcode
+
+In chapter 2, we added a ListView below the header. If you run the application
+for that chapter, you'll see that the contents of the view can be scrolled over
+the top of the header:
+
+\image qtlabscontrols-chattutorial-chapter2-listview-header.gif
+
+This is not that nice, especially if the text in the
+delegates is long enough that it reaches the text in the header. What we
+ideally want to do is to have a solid block of color under the header text, but
+\e {above} the view. This ensures that the listview contents can't visually
+interfere with the header contents. Note that it's also possible to achieve
+this by setting the \l {Item::}{clip} property of the view to \c true, but
+doing so \l {Clipping}{can affect performance}.
+
+\l ToolBar is the right tool for this job. It is a container of both
+application-wide and context-sensitive actions and controls, such as navigation
+buttons and search fields. Best of all, it has a background color that, as
+usual, comes from the application style. Here it is in action:
+
+\quotefromfile chattutorial/chapter3-navigation/ContactPage.qml
+\skipto header
+\printuntil }
+\printuntil }
+
+\image qtlabscontrols-chattutorial-chapter3-listview-header.gif
+
+It has no layout of its own, so we center the label within it ourselves.
+
+The rest of the code is the same as it was in chapter 2, except that we've
+taken advantage of the \l {AbstractButton::}{clicked} signal to push the next
+page onto the stackview:
+
+\skipto onClicked
+\printline onClicked
+
+When pushing a \l Component or \l [QML] url onto StackView, it's often
+necessary to initialize the (eventually) instantiated item with some variables.
+StackView's \l push() function accounts for this, by taking a JavaScript object
+as the second argument. We use this to provide the next page with a contact's
+name, which it then uses to display the relevant conversation. Note the
+\c {root.StackView.view.push} syntax; this is necessary because of how
+\l {A Note About Accessing Attached Properties and Signal Handlers}
+{attached properties} work.
+
+Let's step through \c ConversationPage.qml, beginning with the imports:
+
+\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml
+\skipto import
+\printline import
+\printline import
+\printline import
+
+These are the same as before, except for the addition of the \c QtQuick.Layouts
+import, which we'll cover shortly.
+
+\skipto Page
+\printuntil }
+\printuntil }
+\printuntil }
+\dots 4
+
+The root item of this component is another Page, which has a custom property
+called \c inConversationWith. For now, this property will simply determine what
+the label in the header displays. Later on, we'll use it in the SQL query that
+populates the list of messages in the conversation.
+
+To allow the user to go back to the Contact page, we add a \l ToolButton that
+calls \l {StackView::pop}{pop()} when clicked. A \l ToolButton is functionally
+similar to \l Button, but provides a look that is more suitable within a
+ToolBar.
+
+There are two ways of laying out items in QML: \l {Item Positioners}
+and \l {Qt Quick Layouts}. Item positioners (\l Row, \l Column, and so on) are
+useful for situations where the size of items is known or fixed, and all that
+is required is to neatly position them in a certain formation. The layouts in
+Qt Quick Layouts can both position and resize items, making them well suited
+for resizable user interfaces. Below, we use \l ColumnLayout to vertically
+lay out a ListView and a \l Pane:
+
+\skipto ColumnLayout
+\printto Layout.margins
+\codeline
+\dots 12
+\codeline
+\skipuntil ScrollBar
+\printline }
+\codeline
+\dots 8
+\codeline
+\printuntil Layout.fillWidth: true
+\dots 12
+\skipuntil }
+\skipuntil }
+\skipuntil }
+\skipuntil }
+\printline }
+
+Pane is basically a rectangle whose color comes from the application's style.
+It is similar to \l Frame, with the only difference being that it has no stroke
+around its border.
+
+Items that are direct children of a layout have various
+\l {Layout}{attached properties} available to them. We use
+\l {Layout::fillWidth}{Layout.fillWidth} and
+\l {Layout::fillHeight}{Layout.fillHeight} on the ListView to ensure
+that it takes as much space within the ColumnLayout as it can. The
+same is done for the Pane. As ColumnLayout is a vertical layout, there
+aren't any items to the left or right of each child, so this will result in
+each item consuming the entire width of the layout.
+
+On the other hand, the \l {Layout::fillHeight}{Layout.fillHeight} statement in
+the ListView will enable it to occupy the remaining space that is left after
+accommodating the Pane.
+
+Let's look at the listview in detail:
+
+\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml
+\skipto ListView
+\printuntil ScrollBar
+\printuntil }
+
+After filling the width and height of its parent, we also set some margins on
+the view. This gives us a nice alignment with the placeholder text in the
+"compose message" field:
+
+\omit
+TODO: recreate image
+\endomit
+\image qtlabscontrols-chattutorial-chapter3-view-margins.png
+
+Next, we set \l {ListView::}{displayMarginBeginning} and \l
+{ListView::}{displayMarginEnd}. These properties ensure that the delegates
+outside the bounds of the view do not disappear while scrolling at the edges of
+the view. It's easiest to understand this by commenting out the properties and
+seeing what happens when scrolling the view.
+
+We then flip the vertical direction of the view, so that first items are at the
+bottom. The delegates are spaced out by 12 pixels, and a \e "dummy" model is
+assigned for testing purposes, until we implement the real model in chapter 4.
+
+Within the delegate, we declare a \l Row as the root item, as we want the
+avatar to be followed by the message contents, as shown in the image above.
+
+Messages sent by the user should be distinguished from those sent by a contact.
+For now, we set a dummy property \c sentByMe, which simply uses the index
+of the delegate to alternate between different authors. Using this property,
+we distinguish between different authors in three ways:
+
+\list
+\li Messages sent by the user are aligned to the right side of the screen
+by setting \c anchors.right to \c parent.right.
+
+\li By setting the \c visible property of the avatar (which is simply a
+Rectangle for now) based on \c sentByMe, we only show it if the message was
+sent by a contact.
+
+\li We change the color of the rectangle depending on the author. Since we
+do not want to display dark text on a dark background, and vice versa, we also
+set the text color depending on who the author is. In chapter 5, we'll see how
+styling takes care of matters like this for us.
+\endlist
+
+At the bottom of the screen, we place a \l TextArea item to allow multi-line
+text input, and a button to send the message. We use Pane to cover the area
+under these two items, in the same way that we use ToolBar to prevent the
+contents of the listview from interfering with the page header:
+
+\skipto Pane
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+
+The TextArea should fill the available width of the screen. We assign some
+placeholder text to provide a visual cue to the user as to where they should
+begin typing. The text within the input area is wrapped to ensure that it
+does not go outside of the screen.
+
+Finally, the button is only enabled when there is actually a message to send.
+
+\image qtlabscontrols-chattutorial-chapter3.gif
+
+\section1 Chapter 4: Models
+
+In chapter 4, we'll take you through the process of creating both read-only and
+read-write SQL models in C++ and exposing them to QML to populate views.
+
+\section2 QSqlQueryModel
+
+In order to keep the tutorial simple, we've chosen to make the list of user
+contacts non-editable. \l QSqlQueryModel is the logical choice for this
+purpose, as it provides a read-only data model for SQL result sets.
+
+Let's take a look at our \c SqlContactModel class that derives from
+QSqlQueryModel:
+
+\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.h
+\skipto #include
+\printuntil };
+
+There's not much going on here, so let's move on to the \c .cpp file:
+
+\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.cpp
+\skipto #include
+\printuntil }
+\printuntil }
+\printuntil }
+
+We include the header file of our class and those that we require from Qt. We
+then define a static function named \c createTable() that we'll use to create
+the SQL table (if it doesn't already exist), and then populate it with some
+dummy contacts.
+
+The call to \l {QSqlDatabase::database}{database()} might look a little bit
+confusing because we have not set up a specific database yet. If no connection
+name is passed to this function, it will return a \e {"default connection"},
+whose creation we will cover soon.
+
+\skipto SqlContactModel
+\printuntil }
+
+In the constructor, we call \c createTable(). We then construct a query that
+will be used to populate the model. In this case, we are simply interested in
+all rows of the \c Contacts table.
+
+\section2 QSqlTableModel
+
+\c SqlConversationModel is more complex:
+
+\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.h
+\skipto #include
+\printuntil };
+
+We use both the \c Q_PROPERTY and \c Q_INVOKABLE macros, and therefore we must
+let \l {Using the Meta-Object Compiler (moc)}{moc} know by using the \c
+Q_OBJECT macro.
+
+The \c recipient property will be set from QML to let the model know which
+conversation it should retrieve messages for.
+
+We override the \l {QSqlTableModel::data}{data()} and
+\l {QSqlTableModel::roleNames}{roleNames()} functions so that we can use our
+custom roles in QML.
+
+We also define the \c sendMessage() function that we want to call from
+QML, hence the \c Q_INVOKABLE macro.
+
+Let's take a look at the \c .cpp file:
+
+\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.cpp
+\skipto #include
+\printuntil }
+\printuntil }
+\printuntil }
+
+This is very similar to \c sqlcontactmodel.cpp, with the exception that we are
+now operating on the \c Conversations table. We also define
+\c conversationsTableName as a static const variable, as we use it in a couple
+of places throughout the file.
+
+\skipto SqlConversationModel
+\printuntil }
+
+As with \c SqlContactModel, the first thing that we do in the constructor is
+create the table. We tell QSqlTableModel the name of the table we'll be using
+via the \l {QSqlTableModel::setTable}{setTable()} function. To ensure that the
+latest messages in the conversation are shown first, we sort the query results
+by the \c timestamp field in descending order. This goes hand in hand with
+setting ListView's \l {ListView::}{verticalLayoutDirection} property to
+\c ListView.BottomToTop (which we covered in chapter 3).
+
+\skipto ::recipient(
+\printuntil }
+\printuntil }
+
+In \c setRecipient(), we set a filter over the results returned from
+the database.
+
+\skipto ::data(
+\printuntil }
+
+The \c data() function falls back to QSqlTableModel's implementation if the
+role is not a custom user role. If the role is a user role, we can subtract
+Qt::UserRole from it to get the index of that field and then use that to find
+the value that we need to return.
+
+\skipto ::roleNames(
+\printuntil }
+
+In \c roleNames(), we return a mapping of our custom role values to role names.
+This enables us to use these roles in QML. It can be useful to declare an enum
+to hold all of the role values, but since we don't refer to any specific value
+in code outside of this function, we don't bother.
+
+\skipto ::sendMessage(
+\printuntil }
+
+The \c sendMessage() function uses the given \c recipient and a \c message to
+insert a new record into the database. Due to our usage
+of \l QSqlTableModel::OnManualSubmit, we must manually call
+\l {QSqlTableModel::submitAll}{submitAll()}.
+
+\section2 Connecting to the Database and Registering Types With QML
+
+Now that we've established the model classes, let's take a look at \c main.cpp:
+
+\quotefromfile chattutorial/chapter4-models/main.cpp
+\skipto #include
+\printuntil return app.exec();
+\printuntil }
+
+\c connectToDatabase() creates the connection to the SQLite database, creating
+the actual file if it doesn't already exist.
+
+Within \c main(), we call \l {qmlRegisterType}{qmlRegisterType()} to
+register our models as types within QML.
+
+\section2 Using the Models in QML
+
+Now that we have the models available as QML types, there are some minor
+changes to be done to \c ContactPage.qml. To be able to use the types,
+we must first import them using the URI we set in \c main.cpp:
+
+\quotefromfile chattutorial/chapter4-models/ContactPage.qml
+\skipto import org.qtproject.examples.chattutorial 1.0
+\printline import org.qtproject.examples.chattutorial 1.0
+
+We then replace the dummy model with the proper one:
+
+\skipto model: SqlContactModel {}
+\printline model: SqlContactModel {}
+
+Within the delegate, we use a different syntax for accessing the model data:
+
+\skipto text: model.display
+\printline text: model.display
+
+In \c ConversationPage.qml, we add the same \c chattutorial import, and replace
+the dummy model:
+
+\quotefromfile chattutorial/chapter4-models/ConversationPage.qml
+\skipto model: SqlConversationModel {
+\printuntil }
+
+Within the model, we set the \c recipient property to the name of the contact
+for which the page is being displayed.
+
+The root delegate item changes from a Row to a Column, to accommodate the
+timestamp that we want to display below every message:
+
+\skipto delegate: Column {
+\printuntil Label {
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+\printuntil }
+
+\image qtlabscontrols-chattutorial-chapter4-message-timestamp.png
+
+Now that we have a proper model, we can use its \c recipient role in the
+expression for the \c sentByMe property.
+
+The Rectangle that was used for the avatar has been converted into an Image.
+The image has its own implicit size, so we don't need to specify it explicitly.
+As before, we only show the avatar when the author isn't the user, except this
+time we set the \c source of the image to an empty URL instead of using the
+\c visible property.
+
+We want each message background to be slightly wider (12 pixels each side) than
+its text. However, if it's too long, we want to limit its width to the edge
+of the listview, hence the usage of \c Math.min(). When the message wasn't sent
+by us, an avatar will always come before it, so we account for that by
+subtracting the width of the avatar and the row spacing.
+
+For example, in the image above, the implicit width of the message text is the
+smaller value. However, in the image below, the message text is quite long, so
+the smaller value (the width of the view) is chosen, ensuring that the text
+stops at the opposite edge of the screen:
+
+\image qtlabscontrols-chattutorial-chapter4-long-message.png
+
+In order to display the timestamp for each message that we discussed earlier,
+we use a Label. The date and time are formatted with
+\l {QtQml::Qt::formatDateTime}{Qt.formatDateTime()}, using a custom format.
+
+The \e "send" button must now react to being clicked:
+
+\skipto Button
+\printuntil }
+\printuntil }
+
+First, we call the invokable \c sendMessage() function of the model, which
+inserts a new row into the Conversations database table. Then, we clear the
+text field to make way for future input.
+
+\image qtlabscontrols-chattutorial-chapter4.gif
+
+\section1 Chapter 5: Styling
+
+Styles in Qt Labs Controls are designed to work on any platform. In this
+chapter, we'll do some minor visual tweaks to make sure our application
+looks good when run with the \l {Default Style}{Default},
+\l {Material Style}{Material}, and \l {Universal Style}{Universal} styles.
+
+So far, we've just been testing the application with the Default style. If we
+\l {Selecting and Configuring Styles}{run it with the Material style}, for
+example, we'll immediately see some issues. Here is the Contacts page:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material-test.png
+
+The header text is black on a dark blue background, which is very difficult to
+read. The same thing occurs with the Conversations page:
+
+\image qtlabscontrols-chattutorial-chapter5-conversations-material-test.png
+
+The solution is to tell the toolbar that it should use the \e "Dark" theme, so
+that this information is propagated to its children, allowing them to switch
+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 Qt.labs.controls.material 1.0
+
+ // ...
+
+ header: ToolBar {
+ Material.theme: Material.Dark
+
+ // ...
+ }
+\endcode
+
+However, this brings with it a hard dependency to the Material style; the
+Material style plugin \e must be deployed with the application, even if the
+target device doesn't use it, otherwise the QML engine will fail to find the
+import.
+
+Instead, it is better to rely on Qt Labs Controls' built-in support for
+\l {Using File Selectors with Qt Labs Controls}{style-based file selectors}.
+To do this, we must move the ToolBar out into its own file. We'll call it
+\c ChatToolBar.qml. This will be the \e "default" version of the file, which
+means that it will be used when the \l {Default Style}{Default style} is in
+use. Here's the new file:
+
+\quotefromfile chattutorial/chapter5-styling/ChatToolBar.qml
+\skipto import
+\printuntil }
+
+As we only use the ToolBar type within this file, we only need the
+Qt Labs Controls import. The code itself has not changed from how it was
+in \c ContactPage.qml, which is how it should be; for the default version
+of the file, nothing needs to be different.
+
+Back in \c ContactPage.qml, we update the code to use the new type:
+
+\quotefromfile chattutorial/chapter5-styling/ContactPage.qml
+\skipto ToolBar
+\printuntil }
+\printuntil }
+
+Now we need to add the Material version of the toolbar. File selectors expect
+variants of a file to be in appropriately named directories that exist
+alongside the default version of the file. This means that we need to add a
+folder named "+material" in the same directory that ChatToolBar.qml is in:
+the root folder. The "+" is required by \l QFileSelector as a way of ensuring
+that the selection feature is not accidentally triggered.
+
+Here's \c +material/ChatToolBar.qml:
+
+\quotefromfile chattutorial/chapter5-styling/+material/ChatToolBar.qml
+\skipto import
+\printuntil }
+
+We'll make the same changes to \c ConversationPage.qml:
+
+\quotefromfile chattutorial/chapter5-styling/ConversationPage.qml
+\skipto header: ChatToolBar
+\printuntil }
+\printuntil }
+\printuntil }
+
+Now both pages look correct:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-material.png
+
+Let's try out the Universal style:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-universal.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-universal.png
+
+No issues there. For a relatively simple application such as this one, there
+should be very few adjustments necessary when switching styles.
+
+Now let's try each style's dark theme. The Default style has no dark theme, as
+it would add a slight overhead to a style that is designed to be as performant
+as possible. We'll test out the Material style first, so add an entry to
+\c qtlabscontrols.conf that tells it to use its dark theme:
+
+\code
+[material]
+Primary=Indigo
+Accent=Indigo
+Theme=Dark
+\endcode
+
+Once this is done, build and run the application. This is what you should see:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-material-dark.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-material-dark.png
+
+Both pages look fine. Now add an entry for the Universal style:
+
+\code
+[universal]
+Theme=Dark
+\endcode
+
+After building and running the application, you should see these results:
+
+\image qtlabscontrols-chattutorial-chapter5-contacts-universal-dark.png
+\image qtlabscontrols-chattutorial-chapter5-conversations-universal-dark.png
+
+\section1 Summary
+
+In this tutorial, we've taken you through the following steps of writing a
+basic application using Qt Labs Controls:
+
+\list
+\li Creating a new project using Qt Creator.
+\li Setting up a basic ApplicationWindow.
+\li Defining headers and footers with Page.
+\li Displaying content in a ListView.
+\li Refactoring components into their own files.
+\li Navigating between screens with StackView.
+\li Using layouts to allow an application to resize gracefully.
+\li Implementing both custom read-only and writable models that integrate an
+SQL database into the application.
+\li Integrating C++ with QML via \l Q_PROPERTY, \l Q_INVOKABLE, and
+\l qmlRegisterType().
+\li Testing and configuring multiple styles.
+\endlist
+
+*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
index 4aff46a4..1187b07d 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc
@@ -57,7 +57,7 @@
\section1 Customizing Button
Button consists of two visual items: \l {Control::background}{background}
- and \l {AbstractButton::label}{label}.
+ and \l {Control::contentItem}{content item}.
\section3 Background
@@ -65,17 +65,17 @@
\snippet Button.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-button-label.png
+ \image qtlabscontrols-button-contentItem.png
- \snippet Button.qml label
+ \snippet Button.qml contentItem
\section1 Customizing CheckBox
CheckBox consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{contentItem} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -83,11 +83,11 @@
CheckBox has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-checkbox-label.png
+ \image qtlabscontrols-checkbox-contentItem.png
- \snippet CheckBox.qml label
+ \snippet CheckBox.qml contentItem
\section3 Indicator
@@ -162,38 +162,25 @@
\section1 Customizing Frame
- Frame consists of two visual items: \l {Control::background}{background}
- and \l {Frame::frame}{frame}.
+ Frame consists of one visual item: \l {Control::background}{background}.
\section3 Background
\image qtlabscontrols-frame-background.png
- Frame has no background item by default.
-
- \section3 Frame
-
- \image qtlabscontrols-frame-frame.png
-
- \snippet Frame.qml frame
+ \snippet Frame.qml background
\section1 Customizing GroupBox
- GroupBox consists of three visual items: \l {Control::background}{background},
- \l {Frame::frame}{frame} and \l {GroupBox::label}{label}.
+ GroupBox consists of two visual items: \l {Control::background}{background}
+ and \l {GroupBox::label}{label}.
\section3 Background
\image qtlabscontrols-groupbox-background.png
- GroupBox has no background item by default.
-
- \section3 Frame
-
- \image qtlabscontrols-groupbox-frame.png
-
- \snippet GroupBox.qml frame
+ \snippet GroupBox.qml background
\section3 Label
@@ -205,7 +192,7 @@
\section1 Customizing ItemDelegate
ItemDelegate consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
The indicator is only visible for \l {AbstractButton::checkable}{checkable} items.
\section3 Background
@@ -214,11 +201,11 @@
\snippet ItemDelegate.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-itemdelegate-label.png
+ \image qtlabscontrols-itemdelegate-contentItem.png
- \snippet ItemDelegate.qml label
+ \snippet ItemDelegate.qml contentItem
\section3 Indicator
@@ -292,7 +279,7 @@
\section1 Customizing RadioButton
RadioButton consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -300,11 +287,11 @@
RadioButton has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-radiobutton-label.png
+ \image qtlabscontrols-radiobutton-contentItem.png
- \snippet RadioButton.qml label
+ \snippet RadioButton.qml contentItem
\section3 Indicator
@@ -484,7 +471,7 @@
\section1 Customizing Switch
Switch consists of three visual items: \l {Control::background}{background},
- \l {AbstractButton::label}{label} and \l {AbstractButton::indicator}{indicator}.
+ \l {Control::contentItem}{content item} and \l {AbstractButton::indicator}{indicator}.
\section3 Background
@@ -492,11 +479,11 @@
Switch has no background item by default.
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-switch-label.png
+ \image qtlabscontrols-switch-contentItem.png
- \snippet Switch.qml label
+ \snippet Switch.qml contentItem
\section3 Indicator
@@ -533,8 +520,7 @@
\section1 Customizing ToolBar
- ToolBar consists of two visual items: \l {Control::background}{background} and
- \l {Frame::frame}{frame}.
+ ToolBar consists of one visual item: \l {Control::background}{background}.
\section3 Background
@@ -542,17 +528,11 @@
\snippet ToolBar.qml background
- \section3 Frame
-
- \image qtlabscontrols-toolbar-frame.png
-
- ToolBar has no frame item by default.
-
\section1 Customizing ToolButton
ToolButton consists of two visual items: \l {Control::background}{background}
- and \l {AbstractButton::label}{label}.
+ and \l {Control::contentItem}{content item}.
\section3 Background
@@ -560,11 +540,11 @@
\snippet ToolButton.qml background
- \section3 Label
+ \section3 Content item
- \image qtlabscontrols-toolbutton-label.png
+ \image qtlabscontrols-toolbutton-contentItem.png
- \snippet ToolButton.qml label
+ \snippet ToolButton.qml contentItem
\section1 Customizing Tumbler
diff --git a/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc b/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
index 7fcce7a3..87bf152d 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-differences.qdoc
@@ -155,7 +155,7 @@
\qml
Button {
- label: Label {
+ contentItem: Label {
// ...
}
}
diff --git a/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc b/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc
new file mode 100644
index 00000000..4e14c37b
--- /dev/null
+++ b/src/imports/controls/doc/src/qtlabscontrols-fileselectors.qdoc
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** 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 qtlabscontrols-fileselectors.html
+ \title Using File Selectors with Qt Labs Controls
+
+ \l {QFileSelector}{File selectors} provide a convenient way of selecting
+ file variants. Qt offers the platform name and the locale as built-in
+ selectors. Qt Labs Controls extends the built-in selectors with the name
+ of the style that an application is running with.
+
+ By using file selectors, style-specific tweaks can be applied without
+ creating a hard dependency to a style. From the available file variants,
+ only the selected QML file is loaded by the QML engine. Each file variant
+ can assume the context, that is, a specific style. This typically leads
+ to some code duplication, but on the other hand, cuts the aforementioned
+ hard dependency to the style, and leads to simpler and more efficient
+ QML code. The same technique is used to implement the \l {Styling Qt
+ Labs Controls}{Qt Labs Controls styles}.
+
+ The following example demonstrates a custom rounded button that has a
+ styled drop shadow in the \l {Material Style}{Material style}, and looks
+ flat in other styles. The files are organized so that the Material version
+ of \c CustomButton.qml is placed into a \c +material sub-directory.
+
+ \code
+ :/main.qml
+ :/CustomButton.qml
+ :/+material/CustomButton.qml
+ \endcode
+
+ By default, \c main.qml will use \c CustomButton.qml for the \c CustomButton
+ type. However, when the application is run with the Material style, the
+ \c material selector will be present and the \c +material/CustomButton.qml
+ version will be used instead.
+
+ \code
+ // main.qml
+ import QtQuick 2.6
+ import Qt.labs.controls 1.0
+
+ ApplicationWindow {
+ id: window
+ visible: true
+
+ CustomButton {
+ text: "Button"
+ anchors.centerIn: parent
+ }
+ }
+ \endcode
+
+ The base implementation of the custom button is a simple rounded
+ flat button.
+
+ \code
+ // CustomButton.qml
+ import QtQuick 2.6
+ import Qt.labs.controls 1.0
+
+ Button {
+ id: control
+
+ background: Rectangle {
+ radius: width / 2
+ implicitWidth: 36
+ implicitHeight: 36
+ color: control.pressed ? "#ccc" : "#eee"
+ }
+ }
+ \endcode
+
+ The Material style's implementation of the custom button imports the
+ Material style, requests a dark theme to get light text, and creates
+ a drop shadow for the background.
+
+ \code
+ // +material/CustomButton.qml
+ import QtQuick 2.6
+ import QtGraphicalEffects 1.0
+ import Qt.labs.controls 1.0
+ import Qt.labs.controls.material 1.0
+
+ Button {
+ id: control
+
+ Material.theme: Material.Dark
+
+ background: Rectangle {
+ implicitWidth: 48
+ implicitHeight: 48
+ color: Material.accentColor
+ radius: width / 2
+
+ layer.enabled: control.enabled
+ layer.effect: DropShadow {
+ verticalOffset: 1
+ color: Material.dropShadowColor
+ samples: control.pressed ? 20 : 10
+ spread: 0.5
+ }
+ }
+ }
+ \endcode
+
+ \note It is recommended to use \l QQmlApplicationEngine, which internally
+ creates a \l QQmlFileSelector instance. This is all that is needed to take
+ QML file selectors in use.
+
+ \section1 Related Information
+ \list
+ \li \l {QFileSelector}
+ \li \l {QQmlFileSelector}
+ \li \l {Styling Qt Labs Controls}
+ \endlist
+*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-index.qdoc b/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
index 2f554db7..e8fa2303 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-index.qdoc
@@ -48,6 +48,7 @@
\li \l{Getting Started with Qt Labs Controls}
\li \l{Styling Qt Labs Controls}
\li \l{High-DPI Support in Qt Labs Controls}
+ \li \l{Using File Selectors with Qt Labs Controls}
\li \l{Differences between Qt Quick Controls}
\endlist
diff --git a/src/imports/controls/doc/src/qtlabscontrols-material.qdoc b/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
index e2cadbda..d5a3bd00 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-material.qdoc
@@ -116,13 +116,20 @@
\image qtlabscontrols-material-dark.png
\endtable
- \note The Material style must be separately imported to gain access to
- these style-specific attributes. It should be noted that regardless of the
- references to the Material style, the same application code runs with any
- other style. The Material style-specific attributes only have an effect
- when the application is run with the Material style. Furthermore, in case
- of explicit Material style-specific references, the Material style must
- be deployed with the application.
+ \section2 Dependency
+
+ The Material style must be separately imported to gain access to the
+ attributes that are specific to the Material style. It should be noted
+ that regardless of the references to the Material style, the same
+ application code runs with any other style. Material-specific attributes
+ only have an effect when the application is run with the Material style.
+
+ If the Material style is imported in a QML file that is always loaded, the
+ Material style must be deployed with the application in order to be able
+ to run the application regardless of which style the application is run with.
+ By using \l {Using File Selectors with Qt Labs Controls}{file selectors},
+ style-specific tweaks can be applied without creating a hard dependency to
+ a style.
\section2 Pre-defined Colors
diff --git a/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc b/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
index 858a9105..46939712 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-styles.qdoc
@@ -115,5 +115,6 @@
\li \l {Default Style}
\li \l {Material Style}
\li \l {Universal Style}
+ \li \l{Using File Selectors with Qt Labs Controls}
\endlist
*/
diff --git a/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc b/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
index bf3dcfdc..3c09bdd0 100644
--- a/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
+++ b/src/imports/controls/doc/src/qtlabscontrols-universal.qdoc
@@ -116,13 +116,20 @@
\image qtlabscontrols-universal-dark.png
\endtable
- \note The Universal style must be separately imported to gain access to
- these style-specific attributes. It should be noted that regardless of the
- references to the Universal style, the same application code runs with any
- other style. The Universal style-specific attributes only have an effect
- when the application is run with the Universal style. Furthermore, in case
- of explicit Universal style-specific references, the Universal style must
- be deployed with the application.
+ \section2 Dependency
+
+ The Universal style must be separately imported to gain access to the
+ attributes that are specific to the Universal style. It should be noted
+ that regardless of the references to the Universal style, the same
+ application code runs with any other style. Universal-specific attributes
+ only have an effect when the application is run with the Universal style.
+
+ If the Universal style is imported in a QML file that is always loaded, the
+ Universal style must be deployed with the application in order to be able
+ to run the application regardless of which style the application is run with.
+ By using \l {Using File Selectors with Qt Labs Controls}{file selectors},
+ style-specific tweaks can be applied without creating a hard dependency to
+ a style.
\labs
diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml
index a869c915..4dc9bfc5 100644
--- a/src/imports/controls/material/Button.qml
+++ b/src/imports/controls/material/Button.qml
@@ -43,23 +43,18 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
// external vertical padding is 6 (to increase touch area)
padding: 12
leftPadding: 8
rightPadding: 8
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: !control.enabled ? control.Material.hintTextColor :
@@ -68,7 +63,7 @@ T.Button {
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml
index 230f696f..fd6ef256 100644
--- a/src/imports/controls/material/CheckBox.qml
+++ b/src/imports/controls/material/CheckBox.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 8
topPadding: 14
@@ -143,12 +142,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -158,5 +155,5 @@ T.CheckBox {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index 1c293567..ef073370 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
import QtGraphicalEffects 1.0
diff --git a/src/imports/controls/material/Frame.qml b/src/imports/controls/material/Frame.qml
index 9336850d..4c21e40b 100644
--- a/src/imports/controls/material/Frame.qml
+++ b/src/imports/controls/material/Frame.qml
@@ -53,14 +53,11 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
radius: 3
color: "transparent"
border.color: control.Material.frameColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml
index 3461cb6e..ef54ea7c 100644
--- a/src/imports/controls/material/GroupBox.qml
+++ b/src/imports/controls/material/GroupBox.qml
@@ -71,8 +71,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -81,5 +81,5 @@ T.GroupBox {
color: "transparent"
border.color: control.Material.frameColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index acfbfb98..132cce3d 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 16
spacing: 16
@@ -128,12 +127,10 @@ T.ItemDelegate {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -143,7 +140,7 @@ T.ItemDelegate {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml
index 89867e15..e2042894 100644
--- a/src/imports/controls/material/MenuItem.qml
+++ b/src/imports/controls/material/MenuItem.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.MenuItem {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 16
spacing: 16
@@ -128,12 +127,10 @@ T.MenuItem {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -143,7 +140,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml
index f01d2dc9..4c8831a5 100644
--- a/src/imports/controls/material/RadioButton.qml
+++ b/src/imports/controls/material/RadioButton.qml
@@ -37,18 +37,17 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 8
topPadding: 14
@@ -87,12 +86,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -102,5 +99,5 @@ T.RadioButton {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml
index bf8c16ef..617f9ac7 100644
--- a/src/imports/controls/material/RangeSlider.qml
+++ b/src/imports/controls/material/RangeSlider.qml
@@ -37,6 +37,7 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.RangeSlider {
id: control
diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml
index 139c9151..c121c10b 100644
--- a/src/imports/controls/material/Slider.qml
+++ b/src/imports/controls/material/Slider.qml
@@ -37,6 +37,7 @@
import QtQuick 2.6
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
T.Slider {
id: control
diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml
index 5d2044e6..f6aba60d 100644
--- a/src/imports/controls/material/SpinBox.qml
+++ b/src/imports/controls/material/SpinBox.qml
@@ -75,6 +75,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/material/StackView.qml b/src/imports/controls/material/StackView.qml
index c31c13d2..0eb14832 100644
--- a/src/imports/controls/material/StackView.qml
+++ b/src/imports/controls/material/StackView.qml
@@ -38,12 +38,12 @@ import QtQuick 2.4
import Qt.labs.templates 1.0 as T
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
// slide_in_left
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * -root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * -control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [popEnter]
@@ -51,7 +51,7 @@ T.StackView {
//! [popExit]
popExit: Transition {
// slide_out_right
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [popExit]
@@ -59,7 +59,7 @@ T.StackView {
//! [pushEnter]
pushEnter: Transition {
// slide_in_right
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [pushEnter]
@@ -67,7 +67,7 @@ T.StackView {
//! [pushExit]
pushExit: Transition {
// slide_out_left
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * -root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [pushExit]
@@ -75,7 +75,7 @@ T.StackView {
//! [replaceEnter]
replaceEnter: Transition {
// slide_in_right
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.5 : 0.5) * root.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.5 : 0.5) * control.width; to: 0; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [replaceEnter]
@@ -83,7 +83,7 @@ T.StackView {
//! [replaceExit]
replaceExit: Transition {
// slide_out_left
- NumberAnimation { property: "x"; from: 0; to: (root.mirrored ? -0.5 : 0.5) * -root.width; duration: 200; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: 0; to: (control.mirrored ? -0.5 : 0.5) * -control.width; duration: 200; easing.type: Easing.OutCubic }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 200; easing.type: Easing.OutCubic }
}
//! [replaceExit]
diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml
index 0b9edcab..ca4b1ff6 100644
--- a/src/imports/controls/material/Switch.qml
+++ b/src/imports/controls/material/Switch.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import Qt.labs.controls.material 1.0
+import Qt.labs.controls.material.impl 1.0
import Qt.labs.templates 1.0 as T
import QtGraphicalEffects 1.0
@@ -43,13 +44,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 8
spacing: 8
@@ -107,12 +106,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -122,5 +119,5 @@ T.Switch {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/material/TabBar.qml b/src/imports/controls/material/TabBar.qml
index dbc62512..6a09dbb5 100644
--- a/src/imports/controls/material/TabBar.qml
+++ b/src/imports/controls/material/TabBar.qml
@@ -69,7 +69,7 @@ T.TabBar {
Rectangle {
height: 2
width: parent.width
- y: parent.height - height
+ y: control.position === T.TabBar.Footer ? 0 : parent.height - height
color: control.Material.accentColor
}
}
diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml
index 27b27e3b..496513dd 100644
--- a/src/imports/controls/material/TabButton.qml
+++ b/src/imports/controls/material/TabButton.qml
@@ -42,20 +42,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.contentWidth + leftPadding + rightPadding : 0)
+ contentItem.contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.contentHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.contentHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,7 +58,7 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Item {
diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml
index a5423727..b6f614c0 100644
--- a/src/imports/controls/material/TextArea.qml
+++ b/src/imports/controls/material/TextArea.qml
@@ -92,7 +92,7 @@ T.TextArea {
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
}
//! [placeholder]
diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml
index 6a0010f7..eaea710e 100644
--- a/src/imports/controls/material/TextField.qml
+++ b/src/imports/controls/material/TextField.qml
@@ -91,7 +91,7 @@ T.TextField {
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
}
//! [placeholder]
diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml
index ebdc36f2..34a745c1 100644
--- a/src/imports/controls/material/ToolButton.qml
+++ b/src/imports/controls/material/ToolButton.qml
@@ -42,20 +42,15 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor
@@ -63,7 +58,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index c11a347f..d21bb0b6 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.cpp
@@ -67,11 +67,11 @@ public:
QQuickMaterialRingAnimatorJob();
~QQuickMaterialRingAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
qreal m_devicePixelRatio;
@@ -134,11 +134,12 @@ QColor QQuickMaterialProgressRing::color() const
void QQuickMaterialProgressRing::setColor(QColor color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
static const int spanAnimationDuration = 700;
@@ -167,8 +168,8 @@ QQuickAnimatorJob *QQuickMaterialRingAnimator::createJob() const
QQuickMaterialRingAnimatorJob::QQuickMaterialRingAnimatorJob() :
m_devicePixelRatio(1.0),
- m_containerNode(Q_NULLPTR),
- m_window(Q_NULLPTR)
+ m_containerNode(nullptr),
+ m_window(nullptr)
{
}
@@ -258,8 +259,8 @@ void QQuickMaterialRingAnimatorJob::writeBack()
void QQuickMaterialRingAnimatorJob::nodeWasDestroyed()
{
- m_containerNode = Q_NULLPTR;
- m_window = Q_NULLPTR;
+ m_containerNode = nullptr;
+ m_window = nullptr;
}
void QQuickMaterialRingAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/material/qquickmaterialprogressring_p.h b/src/imports/controls/material/qquickmaterialprogressring_p.h
index 6f4ebc6b..a829f948 100644
--- a/src/imports/controls/material/qquickmaterialprogressring_p.h
+++ b/src/imports/controls/material/qquickmaterialprogressring_p.h
@@ -60,7 +60,7 @@ class QQuickMaterialProgressRing : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- explicit QQuickMaterialProgressRing(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickMaterialProgressRing(QQuickItem *parent = nullptr);
~QQuickMaterialProgressRing();
QColor color() const;
@@ -70,7 +70,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -79,11 +79,11 @@ private:
class QQuickMaterialRingAnimator : public QQuickAnimator
{
public:
- QQuickMaterialRingAnimator(QObject *parent = Q_NULLPTR);
+ QQuickMaterialRingAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip.cpp b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
index 1d888183..34590340 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
@@ -54,11 +54,11 @@ class QQuickMaterialProgressStripAnimatorJob : public QQuickAnimatorJob
public:
QQuickMaterialProgressStripAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
void moveNode(QSGTransformNode *node, const QRectF &geometry, qreal progress);
@@ -66,7 +66,7 @@ private:
QSGNode *m_node;
};
-QQuickMaterialProgressStripAnimatorJob::QQuickMaterialProgressStripAnimatorJob() : m_node(Q_NULLPTR)
+QQuickMaterialProgressStripAnimatorJob::QQuickMaterialProgressStripAnimatorJob() : m_node(nullptr)
{
}
@@ -111,7 +111,7 @@ void QQuickMaterialProgressStripAnimatorJob::writeBack()
void QQuickMaterialProgressStripAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickMaterialProgressStripAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip_p.h b/src/imports/controls/material/qquickmaterialprogressstrip_p.h
index d0618af6..38333ee5 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip_p.h
+++ b/src/imports/controls/material/qquickmaterialprogressstrip_p.h
@@ -61,7 +61,7 @@ class QQuickMaterialProgressStrip : public QQuickItem
Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate FINAL)
public:
- QQuickMaterialProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ QQuickMaterialProgressStrip(QQuickItem *parent = nullptr);
QColor color() const;
void setColor(const QColor &color);
@@ -73,7 +73,7 @@ public:
void setIndeterminate(bool indeterminate);
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -86,11 +86,11 @@ class QQuickMaterialStripAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickMaterialStripAnimator(QObject *parent = Q_NULLPTR);
+ QQuickMaterialStripAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index 57b74d62..280acb77 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -431,27 +431,30 @@ QQuickMaterialStyle::Theme QQuickMaterialStyle::theme() const
void QQuickMaterialStyle::setTheme(Theme theme)
{
m_explicitTheme = true;
- if (m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritTheme(Theme theme)
{
- if (!m_explicitTheme && m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_explicitTheme || m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::propagateTheme()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritTheme(m_theme);
@@ -460,11 +463,12 @@ void QQuickMaterialStyle::propagateTheme()
void QQuickMaterialStyle::resetTheme()
{
- if (m_explicitTheme) {
- m_explicitTheme = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritTheme(material ? material->theme() : defaultTheme);
- }
+ if (!m_explicitTheme)
+ return;
+
+ m_explicitTheme = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritTheme(material ? material->theme() : defaultTheme);
}
QVariant QQuickMaterialStyle::primary() const
@@ -499,28 +503,31 @@ void QQuickMaterialStyle::setPrimary(const QVariant &var)
}
m_explicitPrimary = true;
- if (m_primary != primary) {
- m_customPrimary = custom;
- m_primary = primary;
- propagatePrimary();
- emit primaryChanged();
- emit paletteChanged();
- }
+ if (m_primary == primary)
+ return;
+
+ m_customPrimary = custom;
+ m_primary = primary;
+ propagatePrimary();
+ emit primaryChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritPrimary(uint primary, bool custom)
{
- if (!m_explicitPrimary && m_primary != primary) {
- m_customPrimary = custom;
- m_primary = primary;
- propagatePrimary();
- emit primaryChanged();
- }
+ if (m_explicitPrimary || m_primary == primary)
+ return;
+
+ m_customPrimary = custom;
+ m_primary = primary;
+ propagatePrimary();
+ emit primaryChanged();
}
void QQuickMaterialStyle::propagatePrimary()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritPrimary(m_primary, m_customPrimary);
@@ -529,12 +536,13 @@ void QQuickMaterialStyle::propagatePrimary()
void QQuickMaterialStyle::resetPrimary()
{
- if (m_explicitPrimary) {
- m_customPrimary = false;
- m_explicitPrimary = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritPrimary(material ? material->m_primary : defaultPrimary, true);
- }
+ if (!m_explicitPrimary)
+ return;
+
+ m_customPrimary = false;
+ m_explicitPrimary = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritPrimary(material ? material->m_primary : defaultPrimary, true);
}
QVariant QQuickMaterialStyle::accent() const
@@ -569,28 +577,31 @@ void QQuickMaterialStyle::setAccent(const QVariant &var)
}
m_explicitAccent = true;
- if (m_accent != accent) {
- m_customAccent = custom;
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- emit paletteChanged();
- }
+ if (m_accent == accent)
+ return;
+
+ m_customAccent = custom;
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritAccent(uint accent, bool custom)
{
- if (!m_explicitAccent && m_accent != accent) {
- m_customAccent = custom;
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_explicitAccent || m_accent == accent)
+ return;
+
+ m_customAccent = custom;
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickMaterialStyle::propagateAccent()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(child);
if (material)
material->inheritAccent(m_accent, m_customAccent);
@@ -599,12 +610,13 @@ void QQuickMaterialStyle::propagateAccent()
void QQuickMaterialStyle::resetAccent()
{
- if (m_explicitAccent) {
- m_customAccent = false;
- m_explicitAccent = false;
- QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
- inheritAccent(material ? material->m_accent : defaultAccent, true);
- }
+ if (!m_explicitAccent)
+ return;
+
+ m_customAccent = false;
+ m_explicitAccent = false;
+ QQuickMaterialStyle *material = qobject_cast<QQuickMaterialStyle *>(parentStyle());
+ inheritAccent(material ? material->m_accent : defaultAccent, true);
}
QColor QQuickMaterialStyle::primaryColor() const
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index f92bfe9d..9f3dbbbd 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -146,7 +146,7 @@ public:
Q_ENUM(Color)
Q_ENUM(Shade)
- explicit QQuickMaterialStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickMaterialStyle(QObject *parent = nullptr);
static QQuickMaterialStyle *qmlAttachedProperties(QObject *object);
@@ -214,7 +214,7 @@ Q_SIGNALS:
void paletteChanged();
protected:
- void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE;
+ void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) override;
private:
void init();
diff --git a/src/imports/controls/material/qquickmaterialtheme_p.h b/src/imports/controls/material/qquickmaterialtheme_p.h
index e0279bf6..27ffdddc 100644
--- a/src/imports/controls/material/qquickmaterialtheme_p.h
+++ b/src/imports/controls/material/qquickmaterialtheme_p.h
@@ -61,7 +61,7 @@ public:
~QQuickMaterialTheme();
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
+ const QFont *font(Font type = SystemFont) const override;
private:
QFont systemFont;
diff --git a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
index 11df4464..e4b44890 100644
--- a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
+++ b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
@@ -47,6 +47,9 @@
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabsmaterialstyleplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls_material);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -57,14 +60,20 @@ class QtLabsMaterialStylePlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsMaterialStylePlugin(QObject *parent = nullptr);
~QtLabsMaterialStylePlugin();
- void registerTypes(const char *uri) Q_DECL_OVERRIDE;
- void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
+ void registerTypes(const char *uri) override;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
QQuickProxyTheme *theme;
};
+QtLabsMaterialStylePlugin::QtLabsMaterialStylePlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
QtLabsMaterialStylePlugin::~QtLabsMaterialStylePlugin()
{
if (theme) {
@@ -82,7 +91,6 @@ void QtLabsMaterialStylePlugin::registerTypes(const char *uri)
void QtLabsMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine);
- Q_UNUSED(uri);
QQuickStyleSelector selector;
if (selector.style() == QLatin1String("material")) {
@@ -93,13 +101,13 @@ void QtLabsMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char
}
}
- initResources();
-
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickMaterialProgressRing>(import, 1, 0, "ProgressRing");
qmlRegisterType<QQuickMaterialProgressStrip>(import, 1, 0, "ProgressStrip");
qmlRegisterType<QQuickMaterialRingAnimator>(import, 1, 0, "RingAnimator");
qmlRegisterType<QQuickMaterialStripAnimator>(import, 1, 0, "StripAnimator");
+ qmlRegisterType(QUrl(baseUrl().toString() + QStringLiteral("/Ripple.qml")), import, 1, 0, "Ripple");
+ qmlRegisterType(QUrl(baseUrl().toString() + QStringLiteral("/SliderHandle.qml")), import, 1, 0, "SliderHandle");
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index e9f0cff2..e8083e6b 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -28,7 +28,6 @@ Module {
Property { name: "autoExclusive"; type: "bool" }
Property { name: "autoRepeat"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
- Property { name: "label"; type: "QQuickItem"; isPointer: true }
Signal { name: "pressed" }
Signal { name: "released" }
Signal { name: "canceled" }
@@ -44,6 +43,7 @@ Module {
exports: ["Qt.labs.templates/ApplicationWindow 1.0"]
exportMetaObjectRevisions: [0]
attachedType: "QQuickApplicationWindowAttached"
+ Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "activeFocusControl"; type: "QQuickItem"; isReadonly: true; isPointer: true }
@@ -186,7 +186,11 @@ Module {
Property { name: "spacing"; type: "double" }
Property { name: "locale"; type: "QLocale" }
Property { name: "mirrored"; type: "bool"; isReadonly: true }
+ Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; type: "bool" }
+ Property { name: "wheelEnabled"; type: "bool" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
}
@@ -236,7 +240,6 @@ Module {
prototype: "QQuickPane"
exports: ["Qt.labs.templates/Frame 1.0"]
exportMetaObjectRevisions: [0]
- Property { name: "frame"; type: "QQuickItem"; isPointer: true }
}
Component {
name: "QQuickGroupBox"
@@ -580,6 +583,7 @@ Module {
Property { name: "to"; type: "int" }
Property { name: "value"; type: "int" }
Property { name: "stepSize"; type: "int" }
+ Property { name: "editable"; type: "bool" }
Property { name: "validator"; type: "QValidator"; isPointer: true }
Property { name: "textFromValue"; type: "QJSValue" }
Property { name: "valueFromText"; type: "QJSValue" }
@@ -707,6 +711,14 @@ Module {
prototype: "QQuickContainer"
exports: ["Qt.labs.templates/TabBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickTabButton"
@@ -1012,6 +1024,8 @@ Module {
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"
@@ -1123,6 +1137,7 @@ Module {
revision: 2
Parameter { name: "text"; type: "string" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "inputMethodQuery"
revision: 4
@@ -1275,6 +1290,7 @@ Module {
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" }
@@ -1330,6 +1346,7 @@ Module {
revision: 3
Parameter { name: "delay"; type: "int" }
}
+ Signal { name: "preeditTextChanged"; revision: 7 }
Signal {
name: "activeFocusOnPressChanged"
Parameter { name: "activeFocusOnPress"; type: "bool" }
@@ -1386,6 +1403,7 @@ Module {
revision: 3
Parameter { name: "position"; type: "int" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "positionAt"
Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
@@ -1424,6 +1442,14 @@ Module {
prototype: "QQuickFrame"
exports: ["Qt.labs.templates/ToolBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickToolButton"
diff --git a/src/imports/controls/qquickbusyindicatorring.cpp b/src/imports/controls/qquickbusyindicatorring.cpp
index 96213fa4..06e62c16 100644
--- a/src/imports/controls/qquickbusyindicatorring.cpp
+++ b/src/imports/controls/qquickbusyindicatorring.cpp
@@ -50,11 +50,11 @@ public:
QQuickBusyIndicatorAnimatorJob();
~QQuickBusyIndicatorAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
QSGNode *m_node;
@@ -159,7 +159,7 @@ QQuickAnimatorJob *QQuickBusyIndicatorAnimator::createJob() const
return new QQuickBusyIndicatorAnimatorJob;
}
-QQuickBusyIndicatorAnimatorJob::QQuickBusyIndicatorAnimatorJob() : m_node(Q_NULLPTR)
+QQuickBusyIndicatorAnimatorJob::QQuickBusyIndicatorAnimatorJob() : m_node(nullptr)
{
}
@@ -217,7 +217,7 @@ void QQuickBusyIndicatorAnimatorJob::writeBack()
void QQuickBusyIndicatorAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickBusyIndicatorAnimatorJob::afterNodeSync()
diff --git a/src/imports/controls/qquickbusyindicatorring_p.h b/src/imports/controls/qquickbusyindicatorring_p.h
index 4697628d..cd1e70ad 100644
--- a/src/imports/controls/qquickbusyindicatorring_p.h
+++ b/src/imports/controls/qquickbusyindicatorring_p.h
@@ -58,21 +58,21 @@ class QQuickBusyIndicatorRing : public QQuickItem
Q_OBJECT
public:
- explicit QQuickBusyIndicatorRing(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickBusyIndicatorRing(QQuickItem *parent = nullptr);
~QQuickBusyIndicatorRing();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
};
class QQuickBusyIndicatorAnimator : public QQuickAnimator
{
public:
- QQuickBusyIndicatorAnimator(QObject *parent = Q_NULLPTR);
+ QQuickBusyIndicatorAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
index e9480ff1..0fc72087 100644
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ b/src/imports/controls/qquickprogressstrip.cpp
@@ -47,11 +47,11 @@ public:
QQuickProgressAnimatorJob();
~QQuickProgressAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void afterNodeSync() override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
private:
QSGNode *m_node;
@@ -210,7 +210,7 @@ QQuickAnimatorJob *QQuickProgressAnimator::createJob() const
}
QQuickProgressAnimatorJob::QQuickProgressAnimatorJob() :
- m_node(Q_NULLPTR)
+ m_node(nullptr)
{
}
@@ -308,7 +308,7 @@ void QQuickProgressAnimatorJob::writeBack()
void QQuickProgressAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickprogressstrip_p.h b/src/imports/controls/qquickprogressstrip_p.h
index c34698dc..105c6a29 100644
--- a/src/imports/controls/qquickprogressstrip_p.h
+++ b/src/imports/controls/qquickprogressstrip_p.h
@@ -60,7 +60,7 @@ class QQuickProgressStrip : public QQuickItem
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged FINAL)
public:
- explicit QQuickProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickProgressStrip(QQuickItem *parent = nullptr);
~QQuickProgressStrip();
bool isIndeterminate() const;
@@ -74,7 +74,7 @@ Q_SIGNALS:
void indeterminateChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
qreal m_progress;
@@ -84,11 +84,11 @@ private:
class QQuickProgressAnimator : public QQuickAnimator
{
public:
- QQuickProgressAnimator(QObject *parent = Q_NULLPTR);
+ QQuickProgressAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/qtlabscontrolsplugin.cpp b/src/imports/controls/qtlabscontrolsplugin.cpp
index 4258fb9c..37b68ef5 100644
--- a/src/imports/controls/qtlabscontrolsplugin.cpp
+++ b/src/imports/controls/qtlabscontrolsplugin.cpp
@@ -36,7 +36,9 @@
#include <QtQml/qqmlextensionplugin.h>
#include <QtCore/qurl.h>
+#include <QtCore/qfile.h>
#include <QtCore/qcoreapplication.h>
+#include <QtCore/private/qfileselector_p.h>
#include <QtLabsTemplates/private/qquickabstractbutton_p.h>
#include <QtLabsTemplates/private/qquickbuttongroup_p.h>
@@ -51,6 +53,9 @@
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabscontrolsplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -61,10 +66,16 @@ class QtLabsControlsPlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsControlsPlugin(QObject *parent = nullptr);
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
};
+QtLabsControlsPlugin::QtLabsControlsPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
void QtLabsControlsPlugin::registerTypes(const char *uri)
{
qmlRegisterType<QQuickAbstractButton>(uri, 1, 0, "AbstractButton");
@@ -74,7 +85,14 @@ void QtLabsControlsPlugin::registerTypes(const char *uri)
qmlRegisterType<QQuickControl>(uri, 1, 0, "Control");
QQuickStyleSelector selector;
- selector.setBaseUrl(baseUrl());
+ if (QFile::exists(QLatin1String(":/qt-project.org/imports/Qt/labs/controls/ApplicationWindow.qml")))
+ selector.setBaseUrl(QUrl(QLatin1String("qrc:/qt-project.org/imports/Qt/labs/controls")));\
+ else
+ selector.setBaseUrl(baseUrl());
+
+ const QString style = selector.style();
+ if (!style.isEmpty())
+ QFileSelectorPrivate::addStatics(QStringList() << style);
qmlRegisterType(selector.select(QStringLiteral("/ApplicationWindow.qml")), uri, 1, 0, "ApplicationWindow");
qmlRegisterType(selector.select(QStringLiteral("/BusyIndicator.qml")), uri, 1, 0, "BusyIndicator");
@@ -116,7 +134,6 @@ void QtLabsControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine);
Q_UNUSED(uri);
- initResources();
const QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickBusyIndicatorRing>(import, 1, 0, "BusyRing");
diff --git a/src/imports/controls/universal/Button.qml b/src/imports/controls/universal/Button.qml
index 1dc94c89..5198b756 100644
--- a/src/imports/controls/universal/Button.qml
+++ b/src/imports/controls/universal/Button.qml
@@ -42,10 +42,10 @@ T.Button {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
topPadding: 4
leftPadding: 8
@@ -54,13 +54,8 @@ T.Button {
property bool useSystemFocusVisuals: true
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -69,7 +64,7 @@ T.Button {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/CheckBox.qml b/src/imports/controls/universal/CheckBox.qml
index 37c20d00..2dff0488 100644
--- a/src/imports/controls/universal/CheckBox.qml
+++ b/src/imports/controls/universal/CheckBox.qml
@@ -42,13 +42,11 @@ T.CheckBox {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 8
@@ -92,12 +90,10 @@ T.CheckBox {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -108,5 +104,5 @@ T.CheckBox {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml
index 03278e10..fe6a033f 100644
--- a/src/imports/controls/universal/ComboBox.qml
+++ b/src/imports/controls/universal/ComboBox.qml
@@ -36,6 +36,7 @@
import QtQuick 2.6
import QtQuick.Window 2.2
+import Qt.labs.controls 1.0
import Qt.labs.templates 1.0 as T
import Qt.labs.controls.universal 1.0
diff --git a/src/imports/controls/universal/Frame.qml b/src/imports/controls/universal/Frame.qml
index 9427dc2f..70f1647d 100644
--- a/src/imports/controls/universal/Frame.qml
+++ b/src/imports/controls/universal/Frame.qml
@@ -53,13 +53,10 @@ T.Frame {
contentItem: Item { }
//! [contentItem]
- //! [frame]
- frame: Rectangle {
- width: parent.width
- height: parent.height
-
+ //! [background]
+ background: Rectangle {
color: "transparent"
border.color: control.Universal.chromeDisabledLowColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/universal/GroupBox.qml b/src/imports/controls/universal/GroupBox.qml
index b4e28eb1..2b8ae935 100644
--- a/src/imports/controls/universal/GroupBox.qml
+++ b/src/imports/controls/universal/GroupBox.qml
@@ -71,8 +71,8 @@ T.GroupBox {
}
//! [label]
- //! [frame]
- frame: Rectangle {
+ //! [background]
+ background: Rectangle {
y: control.topPadding - control.padding
width: parent.width
height: parent.height - control.topPadding + control.padding
@@ -80,5 +80,5 @@ T.GroupBox {
color: "transparent"
border.color: control.Universal.chromeDisabledLowColor
}
- //! [frame]
+ //! [background]
}
diff --git a/src/imports/controls/universal/ItemDelegate.qml b/src/imports/controls/universal/ItemDelegate.qml
index 2aaf270b..3296a7cd 100644
--- a/src/imports/controls/universal/ItemDelegate.qml
+++ b/src/imports/controls/universal/ItemDelegate.qml
@@ -42,13 +42,11 @@ T.ItemDelegate {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
spacing: 12
@@ -67,12 +65,10 @@ T.ItemDelegate {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -83,7 +79,7 @@ T.ItemDelegate {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/MenuItem.qml b/src/imports/controls/universal/MenuItem.qml
index fee5d886..cc8cb75d 100644
--- a/src/imports/controls/universal/MenuItem.qml
+++ b/src/imports/controls/universal/MenuItem.qml
@@ -41,12 +41,12 @@ import Qt.labs.controls.universal 1.0
T.MenuItem {
id: control
- implicitWidth: background ? background.implicitWidth
- : (label ? label.implicitWidth : 0) + (indicator ? indicator.implicitWidth : 0)
- + (label && indicator ? spacing : 0) + leftPadding + rightPadding
- implicitHeight: background ? background.implicitHeight
- : (label ? label.implicitHeight : 0) + (indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
+ indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
topPadding: 11
leftPadding: 12
@@ -54,12 +54,10 @@ T.MenuItem {
bottomPadding: 13
spacing: 12
- //! [label]
- label: Text {
- x: control.mirrored || !control.checkable ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - (control.checkable ? indicator.width + control.spacing : 0)
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -69,7 +67,7 @@ T.MenuItem {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [indicator]
indicator: Image {
diff --git a/src/imports/controls/universal/RadioButton.qml b/src/imports/controls/universal/RadioButton.qml
index 95e55db9..a391d670 100644
--- a/src/imports/controls/universal/RadioButton.qml
+++ b/src/imports/controls/universal/RadioButton.qml
@@ -42,13 +42,11 @@ T.RadioButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
spacing: 8
@@ -98,12 +96,10 @@ T.RadioButton {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -114,5 +110,5 @@ T.RadioButton {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/SpinBox.qml b/src/imports/controls/universal/SpinBox.qml
index c903baf4..cfb18391 100644
--- a/src/imports/controls/universal/SpinBox.qml
+++ b/src/imports/controls/universal/SpinBox.qml
@@ -79,6 +79,7 @@ T.SpinBox {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
+ readOnly: !control.editable
validator: control.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
diff --git a/src/imports/controls/universal/StackView.qml b/src/imports/controls/universal/StackView.qml
index b49c2dbb..cbc5665d 100644
--- a/src/imports/controls/universal/StackView.qml
+++ b/src/imports/controls/universal/StackView.qml
@@ -39,13 +39,13 @@ import Qt.labs.templates 1.0 as T
import Qt.labs.controls.universal 1.0
T.StackView {
- id: root
+ id: control
//! [popEnter]
popEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * -root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * -control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [popEnter]
@@ -60,7 +60,7 @@ T.StackView {
pushEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [pushEnter]
@@ -75,7 +75,7 @@ T.StackView {
replaceEnter: Transition {
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 200; easing.type: Easing.InQuint }
- NumberAnimation { property: "x"; from: (root.mirrored ? -0.3 : 0.3) * root.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
+ NumberAnimation { property: "x"; from: (control.mirrored ? -0.3 : 0.3) * control.width; to: 0; duration: 400; easing.type: Easing.OutCubic }
}
}
//! [replaceEnter]
diff --git a/src/imports/controls/universal/Switch.qml b/src/imports/controls/universal/Switch.qml
index 768291fc..dbbb3112 100644
--- a/src/imports/controls/universal/Switch.qml
+++ b/src/imports/controls/universal/Switch.qml
@@ -42,13 +42,11 @@ T.Switch {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- (label ? label.implicitWidth : 0) +
- (indicator ? indicator.implicitWidth : 0) +
- (label && indicator ? spacing : 0) + leftPadding + rightPadding)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- Math.max(label ? label.implicitHeight : 0,
+ Math.max(contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 5
spacing: 8
@@ -90,12 +88,10 @@ T.Switch {
}
//! [indicator]
- //! [label]
- label: Text {
- x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing)
- y: control.topPadding
- width: control.availableWidth - indicator.width - control.spacing
- height: control.availableHeight
+ //! [contentItem]
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
text: control.text
font: control.font
@@ -106,5 +102,5 @@ T.Switch {
color: !control.enabled ? control.Universal.baseLowColor : control.Universal.baseHighColor
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/TabButton.qml b/src/imports/controls/universal/TabButton.qml
index c736a87b..e49bfadd 100644
--- a/src/imports/controls/universal/TabButton.qml
+++ b/src/imports/controls/universal/TabButton.qml
@@ -42,20 +42,15 @@ T.TabButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 12 // PivotItemMargin
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
elide: Text.ElideRight
@@ -63,5 +58,5 @@ T.TabButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
}
diff --git a/src/imports/controls/universal/TextArea.qml b/src/imports/controls/universal/TextArea.qml
index 255f5774..80d62cf4 100644
--- a/src/imports/controls/universal/TextArea.qml
+++ b/src/imports/controls/universal/TextArea.qml
@@ -72,7 +72,7 @@ T.TextArea {
font: control.font
color: !control.enabled ? control.Universal.chromeDisabledLowColor :
control.activeFocus ? control.Universal.chromeBlackMediumLowColor : control.Universal.baseMediumColor
- visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
diff --git a/src/imports/controls/universal/TextField.qml b/src/imports/controls/universal/TextField.qml
index fe9e071d..288dad02 100644
--- a/src/imports/controls/universal/TextField.qml
+++ b/src/imports/controls/universal/TextField.qml
@@ -73,7 +73,7 @@ T.TextField {
font: control.font
color: !control.enabled ? control.Universal.chromeDisabledLowColor :
control.activeFocus ? control.Universal.chromeBlackMediumLowColor : control.Universal.baseMediumColor
- visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
+ visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
horizontalAlignment: control.horizontalAlignment
verticalAlignment: control.verticalAlignment
elide: Text.ElideRight
diff --git a/src/imports/controls/universal/ToolButton.qml b/src/imports/controls/universal/ToolButton.qml
index a8fa8bd5..57d5d045 100644
--- a/src/imports/controls/universal/ToolButton.qml
+++ b/src/imports/controls/universal/ToolButton.qml
@@ -42,22 +42,17 @@ T.ToolButton {
id: control
implicitWidth: Math.max(background ? background.implicitWidth : 0,
- label ? label.implicitWidth + leftPadding + rightPadding : 0)
+ contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
- label ? label.implicitHeight + topPadding + bottomPadding : 0)
- baselineOffset: label ? label.y + label.baselineOffset : 0
+ contentItem.implicitHeight + topPadding + bottomPadding)
+ baselineOffset: contentItem.y + contentItem.baselineOffset
padding: 6
property bool useSystemFocusVisuals: true
- //! [label]
- label: Text {
- x: control.leftPadding
- y: control.topPadding
- width: control.availableWidth
- height: control.availableHeight
-
+ //! [contentItem]
+ contentItem: Text {
text: control.text
font: control.font
color: control.enabled ? control.Universal.baseHighColor : control.Universal.baseLowColor
@@ -65,7 +60,7 @@ T.ToolButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
- //! [label]
+ //! [contentItem]
//! [background]
background: Rectangle {
diff --git a/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h b/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
index 6b15bc8d..628db5b2 100644
--- a/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
+++ b/src/imports/controls/universal/qquickuniversalfocusrectangle_p.h
@@ -57,9 +57,9 @@ class QQuickUniversalFocusRectangle : public QQuickPaintedItem
Q_OBJECT
public:
- QQuickUniversalFocusRectangle(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalFocusRectangle(QQuickItem *parent = nullptr);
- void paint(QPainter *painter) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter) override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalprogressring.cpp b/src/imports/controls/universal/qquickuniversalprogressring.cpp
index 2fe66047..38931525 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressring.cpp
@@ -53,11 +53,11 @@ class QQuickUniversalProgressRingAnimatorJob : public QQuickAnimatorJob
public:
QQuickUniversalProgressRingAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
struct Phase {
@@ -73,7 +73,7 @@ private:
Phase m_phases[PhaseCount];
};
-QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(Q_NULLPTR)
+QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(nullptr)
{
m_phases[0] = Phase(433, -110, 10, QEasingCurve::BezierSpline);
m_phases[1] = Phase(767, 10, 93, QEasingCurve::Linear );
@@ -121,7 +121,7 @@ void QQuickUniversalProgressRingAnimatorJob::updateCurrentTime(int time)
if (visible) {
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_phases[phaseIndex].duration + begin)
break;
remain -= m_phases[phaseIndex].duration;
@@ -153,7 +153,7 @@ void QQuickUniversalProgressRingAnimatorJob::writeBack()
void QQuickUniversalProgressRingAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickUniversalProgressRingAnimatorJob::afterNodeSync()
@@ -191,11 +191,12 @@ int QQuickUniversalProgressRing::count() const
void QQuickUniversalProgressRing::setCount(int count)
{
- if (m_count != count) {
- m_count = count;
- update();
- emit countChanged();
- }
+ if (m_count == count)
+ return;
+
+ m_count = count;
+ update();
+ emit countChanged();
}
QColor QQuickUniversalProgressRing::color() const
@@ -205,11 +206,12 @@ QColor QQuickUniversalProgressRing::color() const
void QQuickUniversalProgressRing::setColor(const QColor &color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
diff --git a/src/imports/controls/universal/qquickuniversalprogressring_p.h b/src/imports/controls/universal/qquickuniversalprogressring_p.h
index 1d484e3a..f32beb54 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring_p.h
+++ b/src/imports/controls/universal/qquickuniversalprogressring_p.h
@@ -60,7 +60,7 @@ class QQuickUniversalProgressRing : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- QQuickUniversalProgressRing(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalProgressRing(QQuickItem *parent = nullptr);
int count() const;
void setCount(int count);
@@ -73,7 +73,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
int m_count;
@@ -85,11 +85,11 @@ class QQuickUniversalProgressRingAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickUniversalProgressRingAnimator(QObject *parent = Q_NULLPTR);
+ QQuickUniversalProgressRingAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
index 39ce1b5c..1ae5b371 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
@@ -62,11 +62,11 @@ class QQuickUniversalProgressStripAnimatorJob : public QQuickAnimatorJob
public:
QQuickUniversalProgressStripAnimatorJob();
- void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE;
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
- void writeBack() Q_DECL_OVERRIDE;
- void nodeWasDestroyed() Q_DECL_OVERRIDE;
- void afterNodeSync() Q_DECL_OVERRIDE;
+ void initialize(QQuickAnimatorController *controller) override;
+ void updateCurrentTime(int time) override;
+ void writeBack() override;
+ void nodeWasDestroyed() override;
+ void afterNodeSync() override;
private:
struct Phase {
@@ -82,7 +82,7 @@ private:
Phase m_ellipsePhases[PhaseCount];
};
-QQuickUniversalProgressStripAnimatorJob::QQuickUniversalProgressStripAnimatorJob() : m_node(Q_NULLPTR)
+QQuickUniversalProgressStripAnimatorJob::QQuickUniversalProgressStripAnimatorJob() : m_node(nullptr)
{
m_borderPhases[0] = Phase( 500, -50, 0);
m_borderPhases[1] = Phase(1500, 0, 0);
@@ -148,7 +148,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
if (visible) {
{
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_borderPhases[phaseIndex].duration + begin)
break;
remain -= m_borderPhases[phaseIndex].duration;
@@ -171,7 +171,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
curve.addCubicBezierSegment(QPointF(0.4, 0.0), QPointF(0.6, 1.0), QPointF(1.0, 1.0));
int phaseIndex, remain = time, elapsed = 0;
- for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) {
+ for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) {
if (remain <= m_ellipsePhases[phaseIndex].duration + begin)
break;
remain -= m_ellipsePhases[phaseIndex].duration;
@@ -203,7 +203,7 @@ void QQuickUniversalProgressStripAnimatorJob::writeBack()
void QQuickUniversalProgressStripAnimatorJob::nodeWasDestroyed()
{
- m_node = Q_NULLPTR;
+ m_node = nullptr;
}
void QQuickUniversalProgressStripAnimatorJob::afterNodeSync()
@@ -241,11 +241,12 @@ QColor QQuickUniversalProgressStrip::color() const
void QQuickUniversalProgressStrip::setColor(const QColor &color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip_p.h b/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
index b61e73c6..1b2c729d 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip_p.h
@@ -59,7 +59,7 @@ class QQuickUniversalProgressStrip : public QQuickItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
public:
- QQuickUniversalProgressStrip(QQuickItem *parent = Q_NULLPTR);
+ QQuickUniversalProgressStrip(QQuickItem *parent = nullptr);
QColor color() const;
void setColor(const QColor &color);
@@ -68,7 +68,7 @@ Q_SIGNALS:
void colorChanged();
protected:
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
QColor m_color;
@@ -79,11 +79,11 @@ class QQuickUniversalProgressStripAnimator : public QQuickAnimator
Q_OBJECT
public:
- QQuickUniversalProgressStripAnimator(QObject *parent = Q_NULLPTR);
+ QQuickUniversalProgressStripAnimator(QObject *parent = nullptr);
protected:
- QString propertyName() const Q_DECL_OVERRIDE;
- QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE;
+ QString propertyName() const override;
+ QQuickAnimatorJob *createJob() const override;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp
index 2f9c86cb..17a214f4 100644
--- a/src/imports/controls/universal/qquickuniversalstyle.cpp
+++ b/src/imports/controls/universal/qquickuniversalstyle.cpp
@@ -154,27 +154,30 @@ QQuickUniversalStyle::Theme QQuickUniversalStyle::theme() const
void QQuickUniversalStyle::setTheme(Theme theme)
{
m_hasTheme = true;
- if (m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickUniversalStyle::inheritTheme(Theme theme)
{
- if (!m_hasTheme && m_theme != theme) {
- m_theme = theme;
- propagateTheme();
- emit themeChanged();
- emit paletteChanged();
- }
+ if (m_hasTheme || m_theme == theme)
+ return;
+
+ m_theme = theme;
+ propagateTheme();
+ emit themeChanged();
+ emit paletteChanged();
}
void QQuickUniversalStyle::propagateTheme()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child);
if (universal)
universal->inheritTheme(m_theme);
@@ -183,11 +186,12 @@ void QQuickUniversalStyle::propagateTheme()
void QQuickUniversalStyle::resetTheme()
{
- if (m_hasTheme) {
- m_hasTheme = false;
- QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
- inheritTheme(universal ? universal->theme() : DefaultTheme);
- }
+ if (!m_hasTheme)
+ return;
+
+ m_hasTheme = false;
+ QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
+ inheritTheme(universal ? universal->theme() : DefaultTheme);
}
QVariant QQuickUniversalStyle::accent() const
@@ -220,25 +224,28 @@ void QQuickUniversalStyle::setAccent(const QVariant &var)
}
m_hasAccent = true;
- if (m_accent != accent) {
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_accent == accent)
+ return;
+
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickUniversalStyle::inheritAccent(QRgb accent)
{
- if (!m_hasAccent && m_accent != accent) {
- m_accent = accent;
- propagateAccent();
- emit accentChanged();
- }
+ if (m_hasAccent || m_accent == accent)
+ return;
+
+ m_accent = accent;
+ propagateAccent();
+ emit accentChanged();
}
void QQuickUniversalStyle::propagateAccent()
{
- foreach (QQuickStyle *child, childStyles()) {
+ const auto styles = childStyles();
+ for (QQuickStyle *child : styles) {
QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(child);
if (universal)
universal->inheritAccent(m_accent);
@@ -247,11 +254,12 @@ void QQuickUniversalStyle::propagateAccent()
void QQuickUniversalStyle::resetAccent()
{
- if (m_hasAccent) {
- m_hasAccent = false;
- QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
- inheritAccent(universal ? universal->m_accent : DefaultAccent);
- }
+ if (!m_hasAccent)
+ return;
+
+ m_hasAccent = false;
+ QQuickUniversalStyle *universal = qobject_cast<QQuickUniversalStyle *>(parentStyle());
+ inheritAccent(universal ? universal->m_accent : DefaultAccent);
}
QColor QQuickUniversalStyle::altHighColor() const
diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h
index 00a04c65..bba1876d 100644
--- a/src/imports/controls/universal/qquickuniversalstyle_p.h
+++ b/src/imports/controls/universal/qquickuniversalstyle_p.h
@@ -87,7 +87,7 @@ class QQuickUniversalStyle : public QQuickStyle
Q_PROPERTY(QColor listMediumColor READ listMediumColor NOTIFY paletteChanged FINAL)
public:
- explicit QQuickUniversalStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickUniversalStyle(QObject *parent = nullptr);
static QQuickUniversalStyle *qmlAttachedProperties(QObject *object);
@@ -190,7 +190,7 @@ Q_SIGNALS:
void paletteChanged();
protected:
- void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE;
+ void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) override;
private:
void init();
diff --git a/src/imports/controls/universal/qquickuniversaltheme_p.h b/src/imports/controls/universal/qquickuniversaltheme_p.h
index 20243917..809d7a89 100644
--- a/src/imports/controls/universal/qquickuniversaltheme_p.h
+++ b/src/imports/controls/universal/qquickuniversaltheme_p.h
@@ -61,7 +61,7 @@ public:
~QQuickUniversalTheme();
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
+ const QFont *font(Font type = SystemFont) const override;
private:
QFont systemFont;
diff --git a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
index b3a82781..51a71ea1 100644
--- a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
@@ -36,18 +36,21 @@
#include <QtQml/qqmlextensionplugin.h>
#include "qquickuniversalfocusrectangle_p.h"
-#include "qquickuniversalimageprovider_p.h"
#include "qquickuniversalprogressring_p.h"
#include "qquickuniversalprogressstrip_p.h"
#include "qquickuniversalstyle_p.h"
#include "qquickuniversaltheme_p.h"
#include <QtGui/private/qguiapplication_p.h>
+#include <QtLabsControls/private/qquickcolorimageprovider_p.h>
#include <QtLabsControls/private/qquickstyleselector_p.h>
static inline void initResources()
{
Q_INIT_RESOURCE(qtlabsuniversalstyleplugin);
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_controls_universal);
+#endif
}
QT_BEGIN_NAMESPACE
@@ -58,14 +61,20 @@ class QtLabsUniversalStylePlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsUniversalStylePlugin(QObject *parent = nullptr);
~QtLabsUniversalStylePlugin();
- void registerTypes(const char *uri) Q_DECL_OVERRIDE;
- void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE;
+ void registerTypes(const char *uri) override;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
private:
QQuickProxyTheme *theme;
};
+QtLabsUniversalStylePlugin::QtLabsUniversalStylePlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
QtLabsUniversalStylePlugin::~QtLabsUniversalStylePlugin()
{
if (theme) {
@@ -91,8 +100,7 @@ void QtLabsUniversalStylePlugin::initializeEngine(QQmlEngine *engine, const char
}
}
- initResources();
- engine->addImageProvider(QStringLiteral("universal"), new QQuickUniversalImageProvider);
+ engine->addImageProvider(QStringLiteral("universal"), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/Qt/labs/controls/universal/images")));
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickUniversalFocusRectangle>(import, 1, 0, "FocusRectangle");
diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri
index c7717d78..965228cb 100644
--- a/src/imports/controls/universal/universal.pri
+++ b/src/imports/controls/universal/universal.pri
@@ -34,7 +34,6 @@ QML_FILES += \
HEADERS += \
$$PWD/qquickuniversalfocusrectangle_p.h \
- $$PWD/qquickuniversalimageprovider_p.h \
$$PWD/qquickuniversalprogressring_p.h \
$$PWD/qquickuniversalprogressstrip_p.h \
$$PWD/qquickuniversalstyle_p.h \
@@ -42,7 +41,6 @@ HEADERS += \
SOURCES += \
$$PWD/qquickuniversalfocusrectangle.cpp \
- $$PWD/qquickuniversalimageprovider.cpp \
$$PWD/qquickuniversalprogressring.cpp \
$$PWD/qquickuniversalprogressstrip.cpp \
$$PWD/qquickuniversalstyle.cpp \
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index 05491643..229a194e 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -22,7 +22,6 @@ Module {
Property { name: "autoExclusive"; type: "bool" }
Property { name: "autoRepeat"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
- Property { name: "label"; type: "QQuickItem"; isPointer: true }
Signal { name: "pressed" }
Signal { name: "released" }
Signal { name: "canceled" }
@@ -38,6 +37,7 @@ Module {
exports: ["Qt.labs.templates/ApplicationWindow 1.0"]
exportMetaObjectRevisions: [0]
attachedType: "QQuickApplicationWindowAttached"
+ Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
Property { name: "activeFocusControl"; type: "QQuickItem"; isReadonly: true; isPointer: true }
@@ -180,7 +180,11 @@ Module {
Property { name: "spacing"; type: "double" }
Property { name: "locale"; type: "QLocale" }
Property { name: "mirrored"; type: "bool"; isReadonly: true }
+ Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "hovered"; type: "bool"; isReadonly: true }
+ Property { name: "hoverEnabled"; type: "bool" }
+ Property { name: "wheelEnabled"; type: "bool" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
}
@@ -230,7 +234,6 @@ Module {
prototype: "QQuickPane"
exports: ["Qt.labs.templates/Frame 1.0"]
exportMetaObjectRevisions: [0]
- Property { name: "frame"; type: "QQuickItem"; isPointer: true }
}
Component {
name: "QQuickGroupBox"
@@ -574,6 +577,7 @@ Module {
Property { name: "to"; type: "int" }
Property { name: "value"; type: "int" }
Property { name: "stepSize"; type: "int" }
+ Property { name: "editable"; type: "bool" }
Property { name: "validator"; type: "QValidator"; isPointer: true }
Property { name: "textFromValue"; type: "QJSValue" }
Property { name: "valueFromText"; type: "QJSValue" }
@@ -701,6 +705,14 @@ Module {
prototype: "QQuickContainer"
exports: ["Qt.labs.templates/TabBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickTabButton"
@@ -1006,6 +1018,8 @@ Module {
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"
@@ -1117,6 +1131,7 @@ Module {
revision: 2
Parameter { name: "text"; type: "string" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "inputMethodQuery"
revision: 4
@@ -1269,6 +1284,7 @@ Module {
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" }
@@ -1324,6 +1340,7 @@ Module {
revision: 3
Parameter { name: "delay"; type: "int" }
}
+ Signal { name: "preeditTextChanged"; revision: 7 }
Signal {
name: "activeFocusOnPressChanged"
Parameter { name: "activeFocusOnPress"; type: "bool" }
@@ -1380,6 +1397,7 @@ Module {
revision: 3
Parameter { name: "position"; type: "int" }
}
+ Method { name: "clear"; revision: 7 }
Method {
name: "positionAt"
Parameter { name: "args"; type: "QQmlV4Function"; isPointer: true }
@@ -1418,6 +1436,14 @@ Module {
prototype: "QQuickFrame"
exports: ["Qt.labs.templates/ToolBar 1.0"]
exportMetaObjectRevisions: [0]
+ Enum {
+ name: "Position"
+ values: {
+ "Header": 0,
+ "Footer": 1
+ }
+ }
+ Property { name: "position"; type: "Position" }
}
Component {
name: "QQuickToolButton"
diff --git a/src/imports/templates/qtlabstemplatesplugin.cpp b/src/imports/templates/qtlabstemplatesplugin.cpp
index fd5060d4..bdf35802 100644
--- a/src/imports/templates/qtlabstemplatesplugin.cpp
+++ b/src/imports/templates/qtlabstemplatesplugin.cpp
@@ -75,6 +75,13 @@
#include <QtLabsTemplates/private/qquicktoolbutton_p.h>
#include <QtLabsTemplates/private/qquicktumbler_p.h>
+static inline void initResources()
+{
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_templates);
+#endif
+}
+
QT_BEGIN_NAMESPACE
class QtLabsTemplatesPlugin: public QQmlExtensionPlugin
@@ -83,9 +90,15 @@ class QtLabsTemplatesPlugin: public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
+ QtLabsTemplatesPlugin(QObject *parent = nullptr);
void registerTypes(const char *uri);
};
+QtLabsTemplatesPlugin::QtLabsTemplatesPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
void QtLabsTemplatesPlugin::registerTypes(const char *uri)
{
qmlRegisterType<QQuickAbstractButton>(uri, 1, 0, "AbstractButton");
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp
index 95afc09d..8e5b59d2 100644
--- a/src/templates/qquickabstractbutton.cpp
+++ b/src/templates/qquickabstractbutton.cpp
@@ -55,7 +55,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
\instantiates QQuickAbstractButton
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief The base of all button controls.
+ \brief Base type of all button controls.
AbstractButton provides the interface for controls with button-like
behavior; for example, push buttons and checkable controls like
@@ -107,8 +107,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() :
pressed(false), checked(false), checkable(false), highlighted(false), autoExclusive(false), autoRepeat(false), wasHeld(false),
- holdTimer(0), delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton),
- label(Q_NULLPTR), indicator(Q_NULLPTR), group(Q_NULLPTR)
+ holdTimer(0), delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), indicator(nullptr), group(nullptr)
{
}
@@ -169,7 +168,7 @@ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
if (group)
return qobject_cast<QQuickAbstractButton *>(group->checkedButton());
- QList<QQuickAbstractButton *> buttons = findExclusiveButtons();
+ const QList<QQuickAbstractButton *> buttons = findExclusiveButtons();
// TODO: A singular QRadioButton can be unchecked, which seems logical,
// because there's nothing to be exclusive with. However, a RadioButton
// from QtQuick.Controls 1.x can never be unchecked, which is the behavior
@@ -177,13 +176,13 @@ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
// gives the QRadioButton behavior. Notice that tst_radiobutton.qml needs
// to be updated.
if (!autoExclusive /*|| buttons.count() == 1*/)
- return Q_NULLPTR;
+ return nullptr;
- foreach (QQuickAbstractButton *button, buttons) {
+ for (QQuickAbstractButton *button : buttons) {
if (button->isChecked() && button != q)
return button;
}
- return checked ? const_cast<QQuickAbstractButton *>(q) : Q_NULLPTR;
+ return checked ? const_cast<QQuickAbstractButton *>(q) : nullptr;
}
QList<QQuickAbstractButton *> QQuickAbstractButtonPrivate::findExclusiveButtons() const
@@ -198,7 +197,8 @@ QList<QQuickAbstractButton *> QQuickAbstractButtonPrivate::findExclusiveButtons(
buttons += button;
}
} else if (parentItem) {
- foreach (QQuickItem *child, parentItem->childItems()) {
+ const auto childItems = parentItem->childItems();
+ for (QQuickItem *child : childItems) {
QQuickAbstractButton *button = qobject_cast<QQuickAbstractButton *>(child);
if (button && button->autoExclusive() && !QQuickAbstractButtonPrivate::get(button)->group)
buttons += button;
@@ -234,9 +234,9 @@ QQuickAbstractButton::~QQuickAbstractButton()
This property holds a textual description of the button.
\note The text is used for accessibility purposes, so it makes sense to
- set a textual description even if the label item is an image.
+ set a textual description even if the content item is an image.
- \sa label
+ \sa contentItem
*/
QString QQuickAbstractButton::text() const
{
@@ -247,11 +247,12 @@ QString QQuickAbstractButton::text() const
void QQuickAbstractButton::setText(const QString &text)
{
Q_D(QQuickAbstractButton);
- if (d->text != text) {
- d->text = text;
- setAccessibleName(text);
- emit textChanged();
- }
+ if (d->text == text)
+ return;
+
+ d->text = text;
+ setAccessibleName(text);
+ emit textChanged();
}
/*!
@@ -268,11 +269,12 @@ bool QQuickAbstractButton::isPressed() const
void QQuickAbstractButton::setPressed(bool isPressed)
{
Q_D(QQuickAbstractButton);
- if (d->pressed != isPressed) {
- d->pressed = isPressed;
- setAccessibleProperty("pressed", isPressed);
- emit pressedChanged();
- }
+ if (d->pressed == isPressed)
+ return;
+
+ d->pressed = isPressed;
+ setAccessibleProperty("pressed", isPressed);
+ emit pressedChanged();
}
/*!
@@ -289,15 +291,16 @@ bool QQuickAbstractButton::isChecked() const
void QQuickAbstractButton::setChecked(bool checked)
{
Q_D(QQuickAbstractButton);
+ if (d->checked == checked)
+ return;
+
if (checked && !d->checkable)
setCheckable(true);
- if (d->checked != checked) {
- d->checked = checked;
- setAccessibleProperty("checked", checked);
- checkStateSet();
- emit checkedChanged();
- }
+ d->checked = checked;
+ setAccessibleProperty("checked", checked);
+ checkStateSet();
+ emit checkedChanged();
}
/*!
@@ -314,11 +317,12 @@ bool QQuickAbstractButton::isCheckable() const
void QQuickAbstractButton::setCheckable(bool checkable)
{
Q_D(QQuickAbstractButton);
- if (d->checkable != checkable) {
- d->checkable = checkable;
- setAccessibleProperty("checkable", checkable);
- emit checkableChanged();
- }
+ if (d->checkable == checkable)
+ return;
+
+ d->checkable = checkable;
+ setAccessibleProperty("checkable", checkable);
+ emit checkableChanged();
}
/*!
@@ -340,10 +344,11 @@ bool QQuickAbstractButton::isHighlighted() const
void QQuickAbstractButton::setHighlighted(bool highlighted)
{
Q_D(QQuickAbstractButton);
- if (highlighted != d->highlighted) {
- d->highlighted = highlighted;
- emit highlightedChanged();
- }
+ if (highlighted == d->highlighted)
+ return;
+
+ d->highlighted = highlighted;
+ emit highlightedChanged();
}
/*!
@@ -369,10 +374,11 @@ bool QQuickAbstractButton::autoExclusive() const
void QQuickAbstractButton::setAutoExclusive(bool exclusive)
{
Q_D(QQuickAbstractButton);
- if (d->autoExclusive != exclusive) {
- d->autoExclusive = exclusive;
- emit autoExclusiveChanged();
- }
+ if (d->autoExclusive == exclusive)
+ return;
+
+ d->autoExclusive = exclusive;
+ emit autoExclusiveChanged();
}
/*!
@@ -392,11 +398,12 @@ bool QQuickAbstractButton::autoRepeat() const
void QQuickAbstractButton::setAutoRepeat(bool repeat)
{
Q_D(QQuickAbstractButton);
- if (d->autoRepeat != repeat) {
- d->stopPressRepeat();
- d->autoRepeat = repeat;
- emit autoRepeatChanged();
- }
+ if (d->autoRepeat == repeat)
+ return;
+
+ d->stopPressRepeat();
+ d->autoRepeat = repeat;
+ emit autoRepeatChanged();
}
/*!
@@ -413,41 +420,17 @@ QQuickItem *QQuickAbstractButton::indicator() const
void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
{
Q_D(QQuickAbstractButton);
- if (d->indicator != indicator) {
- delete d->indicator;
- d->indicator = indicator;
- if (indicator) {
- if (!indicator->parentItem())
- indicator->setParentItem(this);
- indicator->setAcceptedMouseButtons(Qt::LeftButton);
- }
- emit indicatorChanged();
- }
-}
-
-/*!
- \qmlproperty Item Qt.labs.controls::AbstractButton::label
-
- This property holds the label item.
-
- \sa text
-*/
-QQuickItem *QQuickAbstractButton::label() const
-{
- Q_D(const QQuickAbstractButton);
- return d->label;
-}
-
-void QQuickAbstractButton::setLabel(QQuickItem *label)
-{
- Q_D(QQuickAbstractButton);
- if (d->label != label) {
- delete d->label;
- d->label = label;
- if (label && !label->parentItem())
- label->setParentItem(this);
- emit labelChanged();
+ if (d->indicator == indicator)
+ return;
+
+ delete d->indicator;
+ d->indicator = indicator;
+ if (indicator) {
+ if (!indicator->parentItem())
+ indicator->setParentItem(this);
+ indicator->setAcceptedMouseButtons(Qt::LeftButton);
}
+ emit indicatorChanged();
}
/*!
diff --git a/src/templates/qquickabstractbutton_p.h b/src/templates/qquickabstractbutton_p.h
index f3020bc3..9469e706 100644
--- a/src/templates/qquickabstractbutton_p.h
+++ b/src/templates/qquickabstractbutton_p.h
@@ -65,10 +65,9 @@ class Q_LABSTEMPLATES_EXPORT QQuickAbstractButton : public QQuickControl
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
- Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL)
public:
- explicit QQuickAbstractButton(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickAbstractButton(QQuickItem *parent = nullptr);
~QQuickAbstractButton();
QString text() const;
@@ -95,9 +94,6 @@ public:
QQuickItem *indicator() const;
void setIndicator(QQuickItem *indicator);
- QQuickItem *label() const;
- void setLabel(QQuickItem *label);
-
public Q_SLOTS:
void toggle();
@@ -116,27 +112,26 @@ Q_SIGNALS:
void autoExclusiveChanged();
void autoRepeatChanged();
void indicatorChanged();
- void labelChanged();
protected:
QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent);
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void focusOutEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void timerEvent(QTimerEvent *event) override;
virtual void checkStateSet();
virtual void nextCheckState();
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickabstractbutton_p_p.h b/src/templates/qquickabstractbutton_p_p.h
index cdc77f19..409fd52e 100644
--- a/src/templates/qquickabstractbutton_p_p.h
+++ b/src/templates/qquickabstractbutton_p_p.h
@@ -91,7 +91,6 @@ public:
int repeatTimer;
QPointF pressPoint;
Qt::MouseButton repeatButton;
- QQuickItem *label;
QQuickItem *indicator;
QQuickButtonGroup *group;
};
diff --git a/src/templates/qquickapplicationwindow.cpp b/src/templates/qquickapplicationwindow.cpp
index 9a9e5460..f0a009ff 100644
--- a/src/templates/qquickapplicationwindow.cpp
+++ b/src/templates/qquickapplicationwindow.cpp
@@ -39,6 +39,8 @@
#include "qquickcontrol_p_p.h"
#include "qquicktextarea_p.h"
#include "qquicktextfield_p.h"
+#include "qquicktoolbar_p.h"
+#include "qquicktabbar_p.h"
#include <QtCore/private/qobject_p.h>
#include <QtQuick/private/qquickitem_p.h>
@@ -97,17 +99,18 @@ class QQuickApplicationWindowPrivate : public QQuickItemChangeListener
public:
QQuickApplicationWindowPrivate()
: complete(false)
- , contentItem(Q_NULLPTR)
- , header(Q_NULLPTR)
- , footer(Q_NULLPTR)
- , overlay(Q_NULLPTR)
- , activeFocusControl(Q_NULLPTR)
+ , background(nullptr)
+ , contentItem(nullptr)
+ , header(nullptr)
+ , footer(nullptr)
+ , overlay(nullptr)
+ , activeFocusControl(nullptr)
{ }
void relayout();
- void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE;
- void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
void updateFont(const QFont &);
inline void setFont_helper(const QFont &f) {
@@ -121,6 +124,7 @@ public:
void setActiveFocusControl(QQuickItem *item);
bool complete;
+ QQuickItem *background;
QQuickItem *contentItem;
QQuickItem *header;
QQuickItem *footer;
@@ -165,6 +169,18 @@ void QQuickApplicationWindowPrivate::relayout()
p->widthValid = false;
}
}
+
+ if (background) {
+ QQuickItemPrivate *p = QQuickItemPrivate::get(background);
+ if (!p->widthValid && qFuzzyIsNull(background->x())) {
+ background->setWidth(q->width());
+ p->widthValid = false;
+ }
+ if (!p->heightValid && qFuzzyIsNull(background->y())) {
+ background->setHeight(q->height());
+ p->heightValid = false;
+ }
+ }
}
void QQuickApplicationWindowPrivate::itemImplicitWidthChanged(QQuickItem *item)
@@ -229,11 +245,50 @@ QQuickApplicationWindow::~QQuickApplicationWindow()
}
/*!
+ \qmlproperty Item Qt.labs.controls::ApplicationWindow::background
+
+ This property holds the background item.
+
+ The background item is stacked under the \l {contentItem}{content item},
+ but above the \l {Window::color}{background color} of the window.
+
+ \note If the background item has no explicit size specified, it automatically
+ follows the control's size. In most cases, there is no need to specify
+ width or height for a background item.
+*/
+QQuickItem *QQuickApplicationWindow::background() const
+{
+ Q_D(const QQuickApplicationWindow);
+ return d->background;
+}
+
+void QQuickApplicationWindow::setBackground(QQuickItem *background)
+{
+ Q_D(QQuickApplicationWindow);
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(QQuickWindow::contentItem());
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->relayout();
+ }
+ emit backgroundChanged();
+}
+
+/*!
\qmlproperty Item Qt.labs.controls::ApplicationWindow::header
This property holds the window header item. The header item is positioned to
the top, and resized to the width of the window. The default value is \c null.
+ \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.
+
\sa footer, Page::header
*/
QQuickItem *QQuickApplicationWindow::header() const
@@ -245,23 +300,28 @@ QQuickItem *QQuickApplicationWindow::header() const
void QQuickApplicationWindow::setHeader(QQuickItem *header)
{
Q_D(QQuickApplicationWindow);
- if (d->header != header) {
- if (d->header) {
- QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->header->setParentItem(Q_NULLPTR);
- }
- d->header = header;
- if (header) {
- header->setParentItem(contentItem());
- QQuickItemPrivate *p = QQuickItemPrivate::get(header);
- p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(header->z()))
- header->setZ(1);
- if (isComponentComplete())
- d->relayout();
- }
- emit headerChanged();
+ if (d->header == header)
+ return;
+
+ if (d->header) {
+ QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
+ d->header->setParentItem(nullptr);
+ }
+ d->header = header;
+ if (header) {
+ header->setParentItem(contentItem());
+ QQuickItemPrivate *p = QQuickItemPrivate::get(header);
+ p->addItemChangeListener(d, 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();
}
+ emit headerChanged();
}
/*!
@@ -270,6 +330,9 @@ void QQuickApplicationWindow::setHeader(QQuickItem *header)
This property holds the window footer item. The footer item is positioned to
the bottom, and resized to the width of the window. The default value is \c null.
+ \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.
+
\sa header, Page::footer
*/
QQuickItem *QQuickApplicationWindow::footer() const
@@ -281,23 +344,28 @@ QQuickItem *QQuickApplicationWindow::footer() const
void QQuickApplicationWindow::setFooter(QQuickItem *footer)
{
Q_D(QQuickApplicationWindow);
- if (d->footer != footer) {
- if (d->footer) {
- QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->footer->setParentItem(Q_NULLPTR);
- }
- d->footer = footer;
- if (footer) {
- footer->setParentItem(contentItem());
- QQuickItemPrivate *p = QQuickItemPrivate::get(footer);
- p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(footer->z()))
- footer->setZ(1);
- if (isComponentComplete())
- d->relayout();
- }
- emit footerChanged();
+ if (d->footer == footer)
+ return;
+
+ if (d->footer) {
+ QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
+ d->footer->setParentItem(nullptr);
+ }
+ d->footer = footer;
+ if (footer) {
+ footer->setParentItem(contentItem());
+ QQuickItemPrivate *p = QQuickItemPrivate::get(footer);
+ p->addItemChangeListener(d, 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();
}
+ emit footerChanged();
}
/*!
@@ -483,7 +551,7 @@ class QQuickApplicationWindowAttachedPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickApplicationWindowAttached)
public:
- QQuickApplicationWindowAttachedPrivate() : window(Q_NULLPTR) { }
+ QQuickApplicationWindowAttachedPrivate() : window(nullptr) { }
void windowChange(QQuickWindow *wnd);
@@ -561,7 +629,7 @@ QQuickApplicationWindow *QQuickApplicationWindowAttached::window() const
QQuickItem *QQuickApplicationWindowAttached::contentItem() const
{
Q_D(const QQuickApplicationWindowAttached);
- return d->window ? d->window->contentItem() : Q_NULLPTR;
+ return d->window ? d->window->contentItem() : nullptr;
}
/*!
@@ -578,7 +646,7 @@ QQuickItem *QQuickApplicationWindowAttached::contentItem() const
QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
{
Q_D(const QQuickApplicationWindowAttached);
- return d->window ? d->window->activeFocusControl() : Q_NULLPTR;
+ return d->window ? d->window->activeFocusControl() : nullptr;
}
/*!
@@ -592,7 +660,7 @@ QQuickItem *QQuickApplicationWindowAttached::activeFocusControl() const
QQuickItem *QQuickApplicationWindowAttached::header() const
{
Q_D(const QQuickApplicationWindowAttached);
- return d->window ? d->window->header() : Q_NULLPTR;
+ return d->window ? d->window->header() : nullptr;
}
/*!
@@ -606,7 +674,7 @@ QQuickItem *QQuickApplicationWindowAttached::header() const
QQuickItem *QQuickApplicationWindowAttached::footer() const
{
Q_D(const QQuickApplicationWindowAttached);
- return d->window ? d->window->footer() : Q_NULLPTR;
+ return d->window ? d->window->footer() : nullptr;
}
/*!
@@ -619,7 +687,7 @@ QQuickItem *QQuickApplicationWindowAttached::footer() const
QQuickOverlay *QQuickApplicationWindowAttached::overlay() const
{
Q_D(const QQuickApplicationWindowAttached);
- return d->window ? d->window->overlay() : Q_NULLPTR;
+ return d->window ? d->window->overlay() : nullptr;
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickapplicationwindow_p.h b/src/templates/qquickapplicationwindow_p.h
index f62ddee3..87105040 100644
--- a/src/templates/qquickapplicationwindow_p.h
+++ b/src/templates/qquickapplicationwindow_p.h
@@ -63,6 +63,7 @@ class QQuickApplicationWindowAttachedPrivate;
class Q_LABSTEMPLATES_EXPORT QQuickApplicationWindow : public QQuickWindowQmlImpl
{
Q_OBJECT
+ Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickItem *contentItem READ contentItem CONSTANT FINAL)
Q_PROPERTY(QQmlListProperty<QObject> data READ contentData FINAL)
Q_PROPERTY(QQuickItem *activeFocusControl READ activeFocusControl NOTIFY activeFocusControlChanged FINAL)
@@ -74,9 +75,12 @@ class Q_LABSTEMPLATES_EXPORT QQuickApplicationWindow : public QQuickWindowQmlImp
Q_CLASSINFO("DefaultProperty", "data")
public:
- explicit QQuickApplicationWindow(QWindow *parent = Q_NULLPTR);
+ explicit QQuickApplicationWindow(QWindow *parent = nullptr);
~QQuickApplicationWindow();
+ QQuickItem *background() const;
+ void setBackground(QQuickItem *background);
+
QQuickItem *contentItem() const;
QQmlListProperty<QObject> contentData();
@@ -101,6 +105,7 @@ public:
static QQuickApplicationWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
+ void backgroundChanged();
void activeFocusControlChanged();
void headerChanged();
void footerChanged();
@@ -109,9 +114,9 @@ Q_SIGNALS:
protected:
bool isComponentComplete() const;
- void classBegin() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
+ void classBegin() override;
+ void componentComplete() override;
+ void resizeEvent(QResizeEvent *event) override;
private:
Q_DISABLE_COPY(QQuickApplicationWindow)
@@ -131,7 +136,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickApplicationWindowAttached : public QObject
Q_PROPERTY(QQuickOverlay *overlay READ overlay NOTIFY overlayChanged FINAL)
public:
- explicit QQuickApplicationWindowAttached(QObject *parent = Q_NULLPTR);
+ explicit QQuickApplicationWindowAttached(QObject *parent = nullptr);
QQuickApplicationWindow *window() const;
QQuickItem *contentItem() const;
diff --git a/src/templates/qquickbusyindicator.cpp b/src/templates/qquickbusyindicator.cpp
index 381ac5c7..3cfd96cb 100644
--- a/src/templates/qquickbusyindicator.cpp
+++ b/src/templates/qquickbusyindicator.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickBusyIndicator
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-indicators
- \brief A busy indicator.
+ \brief Indicates activity while content is being loaded.
\image qtlabscontrols-busyindicator.gif
@@ -98,10 +98,11 @@ bool QQuickBusyIndicator::isRunning() const
void QQuickBusyIndicator::setRunning(bool running)
{
Q_D(QQuickBusyIndicator);
- if (d->running != running) {
- d->running = running;
- emit runningChanged();
- }
+ if (d->running == running)
+ return;
+
+ d->running = running;
+ emit runningChanged();
}
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/templates/qquickbusyindicator_p.h b/src/templates/qquickbusyindicator_p.h
index 8be19d5c..e5e72044 100644
--- a/src/templates/qquickbusyindicator_p.h
+++ b/src/templates/qquickbusyindicator_p.h
@@ -60,7 +60,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickBusyIndicator : public QQuickControl
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged FINAL)
public:
- explicit QQuickBusyIndicator(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickBusyIndicator(QQuickItem *parent = nullptr);
bool isRunning() const;
void setRunning(bool running);
@@ -70,7 +70,7 @@ Q_SIGNALS:
protected:
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickbutton.cpp b/src/templates/qquickbutton.cpp
index 1e40ec05..d193e68d 100644
--- a/src/templates/qquickbutton.cpp
+++ b/src/templates/qquickbutton.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickButton
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A button control.
+ \brief A push-button control that can be clicked by the user.
\image qtlabscontrols-button.gif
diff --git a/src/templates/qquickbutton_p.h b/src/templates/qquickbutton_p.h
index 83d22fb8..12c3667c 100644
--- a/src/templates/qquickbutton_p.h
+++ b/src/templates/qquickbutton_p.h
@@ -57,10 +57,10 @@ class Q_LABSTEMPLATES_EXPORT QQuickButton : public QQuickAbstractButton
Q_OBJECT
public:
- explicit QQuickButton(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickButton(QQuickItem *parent = nullptr);
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
};
QT_END_NAMESPACE
diff --git a/src/templates/qquickbuttongroup.cpp b/src/templates/qquickbuttongroup.cpp
index 0865277e..5f0ec6b1 100644
--- a/src/templates/qquickbuttongroup.cpp
+++ b/src/templates/qquickbuttongroup.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickButtonGroup
\inqmlmodule Qt.labs.controls
\ingroup utilities
- \brief An exclusive group of checkable controls.
+ \brief A mutually-exclusive group of checkable controls.
ButtonGroup is a non-visual, mutually exclusive group of buttons.
It is used with controls such as RadioButton, where only one of the options
@@ -129,7 +129,7 @@ class QQuickButtonGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickButtonGroup)
public:
- QQuickButtonGroupPrivate() : checkedButton(Q_NULLPTR) { }
+ QQuickButtonGroupPrivate() : checkedButton(nullptr) { }
void clear();
void updateCurrent();
@@ -145,8 +145,8 @@ public:
void QQuickButtonGroupPrivate::clear()
{
- foreach (QQuickAbstractButton *button, buttons) {
- QQuickAbstractButtonPrivate::get(button)->group = Q_NULLPTR;
+ for (QQuickAbstractButton *button : qAsConst(buttons)) {
+ QQuickAbstractButtonPrivate::get(button)->group = nullptr;
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, this, &QQuickButtonGroupPrivate::updateCurrent);
}
buttons.clear();
@@ -184,7 +184,7 @@ void QQuickButtonGroupPrivate::buttons_clear(QQmlListProperty<QQuickAbstractButt
if (!p->buttons.isEmpty()) {
p->clear();
QQuickButtonGroup *q = static_cast<QQuickButtonGroup *>(prop->object);
- q->setCheckedButton(Q_NULLPTR);
+ q->setCheckedButton(nullptr);
emit q->buttonsChanged();
}
}
@@ -221,14 +221,15 @@ QQuickAbstractButton *QQuickButtonGroup::checkedButton() const
void QQuickButtonGroup::setCheckedButton(QQuickAbstractButton *checkedButton)
{
Q_D(QQuickButtonGroup);
- if (d->checkedButton != checkedButton) {
- if (d->checkedButton)
- d->checkedButton->setChecked(false);
- d->checkedButton = checkedButton;
- if (checkedButton)
- checkedButton->setChecked(true);
- emit checkedButtonChanged();
- }
+ if (d->checkedButton == checkedButton)
+ return;
+
+ if (d->checkedButton)
+ d->checkedButton->setChecked(false);
+ d->checkedButton = checkedButton;
+ if (checkedButton)
+ checkedButton->setChecked(true);
+ emit checkedButtonChanged();
}
/*!
@@ -312,11 +313,11 @@ void QQuickButtonGroup::removeButton(QQuickAbstractButton *button)
if (!button || !d->buttons.contains(button))
return;
- QQuickAbstractButtonPrivate::get(button)->group = Q_NULLPTR;
+ QQuickAbstractButtonPrivate::get(button)->group = nullptr;
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, d, &QQuickButtonGroupPrivate::updateCurrent);
if (d->checkedButton == button)
- setCheckedButton(Q_NULLPTR);
+ setCheckedButton(nullptr);
d->buttons.removeOne(button);
emit buttonsChanged();
@@ -325,7 +326,7 @@ void QQuickButtonGroup::removeButton(QQuickAbstractButton *button)
class QQuickButtonGroupAttachedPrivate : public QObjectPrivate
{
public:
- QQuickButtonGroupAttachedPrivate() : group(Q_NULLPTR) { }
+ QQuickButtonGroupAttachedPrivate() : group(nullptr) { }
QQuickButtonGroup *group;
};
@@ -366,14 +367,15 @@ QQuickButtonGroup *QQuickButtonGroupAttached::group() const
void QQuickButtonGroupAttached::setGroup(QQuickButtonGroup *group)
{
Q_D(QQuickButtonGroupAttached);
- if (d->group != group) {
- if (d->group)
- d->group->removeButton(qobject_cast<QQuickAbstractButton*>(parent()));
- d->group = group;
- if (group)
- group->addButton(qobject_cast<QQuickAbstractButton*>(parent()));
- emit groupChanged();
- }
+ if (d->group == group)
+ return;
+
+ if (d->group)
+ d->group->removeButton(qobject_cast<QQuickAbstractButton*>(parent()));
+ d->group = group;
+ if (group)
+ group->addButton(qobject_cast<QQuickAbstractButton*>(parent()));
+ emit groupChanged();
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickbuttongroup_p.h b/src/templates/qquickbuttongroup_p.h
index 6210079d..5863e70b 100644
--- a/src/templates/qquickbuttongroup_p.h
+++ b/src/templates/qquickbuttongroup_p.h
@@ -66,7 +66,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickButtonGroup : public QObject
Q_PROPERTY(QQmlListProperty<QQuickAbstractButton> buttons READ buttons NOTIFY buttonsChanged FINAL)
public:
- explicit QQuickButtonGroup(QObject *parent = Q_NULLPTR);
+ explicit QQuickButtonGroup(QObject *parent = nullptr);
~QQuickButtonGroup();
static QQuickButtonGroupAttached *qmlAttachedProperties(QObject *object);
@@ -95,7 +95,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickButtonGroupAttached : public QObject
Q_PROPERTY(QQuickButtonGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL)
public:
- explicit QQuickButtonGroupAttached(QObject *parent = Q_NULLPTR);
+ explicit QQuickButtonGroupAttached(QObject *parent = nullptr);
QQuickButtonGroup *group() const;
void setGroup(QQuickButtonGroup *group);
diff --git a/src/templates/qquickcheckbox.cpp b/src/templates/qquickcheckbox.cpp
index 644e151e..945fbc42 100644
--- a/src/templates/qquickcheckbox.cpp
+++ b/src/templates/qquickcheckbox.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickCheckBox
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A check box control.
+ \brief An option button that can be checked or unchecked.
CheckBox presents an option button that can be toggled on (checked) or
off (unchecked). Check boxes are typically used to select one or more
@@ -121,10 +121,11 @@ bool QQuickCheckBox::isTristate() const
void QQuickCheckBox::setTristate(bool tristate)
{
Q_D(QQuickCheckBox);
- if (d->tristate != tristate) {
- d->tristate = tristate;
- emit tristateChanged();
- }
+ if (d->tristate == tristate)
+ return;
+
+ d->tristate = tristate;
+ emit tristateChanged();
}
/*!
@@ -148,16 +149,18 @@ Qt::CheckState QQuickCheckBox::checkState() const
void QQuickCheckBox::setCheckState(Qt::CheckState state)
{
Q_D(QQuickCheckBox);
+ if (d->checkState == state)
+ return;
+
if (!d->tristate && state == Qt::PartiallyChecked)
setTristate(true);
- if (d->checkState != state) {
- bool wasChecked = isChecked();
- d->checked = state != Qt::Unchecked;
- d->checkState = state;
- emit checkStateChanged();
- if (d->checked != wasChecked)
- emit checkedChanged();
- }
+
+ bool wasChecked = isChecked();
+ d->checked = state != Qt::Unchecked;
+ d->checkState = state;
+ emit checkStateChanged();
+ if (d->checked != wasChecked)
+ emit checkedChanged();
}
QFont QQuickCheckBox::defaultFont() const
diff --git a/src/templates/qquickcheckbox_p.h b/src/templates/qquickcheckbox_p.h
index 4c0d505f..e3dcf76e 100644
--- a/src/templates/qquickcheckbox_p.h
+++ b/src/templates/qquickcheckbox_p.h
@@ -61,7 +61,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickCheckBox : public QQuickAbstractButton
Q_PROPERTY(Qt::CheckState checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL)
public:
- explicit QQuickCheckBox(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickCheckBox(QQuickItem *parent = nullptr);
bool isTristate() const;
void setTristate(bool tristate);
@@ -74,13 +74,13 @@ Q_SIGNALS:
void checkStateChanged();
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
- void checkStateSet() Q_DECL_OVERRIDE;
- void nextCheckState() Q_DECL_OVERRIDE;
+ void checkStateSet() override;
+ void nextCheckState() override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickcombobox.cpp b/src/templates/qquickcombobox.cpp
index 229201c5..75492924 100644
--- a/src/templates/qquickcombobox.cpp
+++ b/src/templates/qquickcombobox.cpp
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickComboBox
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-input
- \brief A combo box control.
+ \brief A combined button and popup list taking minimal space.
\image qtlabscontrols-combobox.png
@@ -123,7 +123,7 @@ class QQuickComboBoxDelegateModel : public QQmlDelegateModel
{
public:
explicit QQuickComboBoxDelegateModel(QQuickComboBox *combo);
- QString stringValue(int index, const QString &role) Q_DECL_OVERRIDE;
+ QString stringValue(int index, const QString &role) override;
private:
QQuickComboBox *combo;
@@ -155,8 +155,8 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate
public:
QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false),
- highlightedIndex(-1), currentIndex(-1), delegateModel(Q_NULLPTR),
- delegate(Q_NULLPTR), popup(Q_NULLPTR) { }
+ highlightedIndex(-1), currentIndex(-1), delegateModel(nullptr),
+ delegate(nullptr), popup(nullptr) { }
bool isPopupVisible() const;
void showPopup();
@@ -227,7 +227,7 @@ void QQuickComboBoxPrivate::togglePopup(bool accept)
void QQuickComboBoxPrivate::itemClicked()
{
Q_Q(QQuickComboBox);
- int index = delegateModel->indexOf(q->sender(), Q_NULLPTR);
+ int index = delegateModel->indexOf(q->sender(), nullptr);
if (index != -1) {
setHighlightedIndex(index);
emit q->highlighted(index);
@@ -302,10 +302,11 @@ void QQuickComboBoxPrivate::decrease()
void QQuickComboBoxPrivate::setHighlightedIndex(int index)
{
Q_Q(QQuickComboBox);
- if (highlightedIndex != index) {
- highlightedIndex = index;
- emit q->highlightedIndexChanged();
- }
+ if (highlightedIndex == index)
+ return;
+
+ highlightedIndex = index;
+ emit q->highlightedIndexChanged();
}
void QQuickComboBoxPrivate::createDelegateModel()
@@ -348,7 +349,7 @@ void QQuickComboBoxPrivate::createDelegateModel()
QQuickComboBox::QQuickComboBox(QQuickItem *parent) :
QQuickControl(*(new QQuickComboBoxPrivate), parent)
{
- setActiveFocusOnTab(true);
+ setFocusPolicy(Qt::StrongFocus);
setFlag(QQuickItem::ItemIsFocusScope);
setAcceptedMouseButtons(Qt::LeftButton);
}
@@ -357,7 +358,7 @@ QQuickComboBox::~QQuickComboBox()
{
Q_D(QQuickComboBox);
delete d->popup;
- d->popup = Q_NULLPTR;
+ d->popup = nullptr;
}
/*!
@@ -403,15 +404,16 @@ void QQuickComboBox::setModel(const QVariant& m)
if (model.userType() == qMetaTypeId<QJSValue>())
model = model.value<QJSValue>().toVariant();
- if (d->model != model) {
- d->model = model;
- d->createDelegateModel();
- if (isComponentComplete()) {
- setCurrentIndex(count() > 0 ? 0 : -1);
- d->updateCurrentText();
- }
- emit modelChanged();
+ if (d->model == model)
+ return;
+
+ d->model = model;
+ d->createDelegateModel();
+ if (isComponentComplete()) {
+ setCurrentIndex(count() > 0 ? 0 : -1);
+ d->updateCurrentText();
}
+ emit modelChanged();
}
/*!
@@ -440,10 +442,11 @@ bool QQuickComboBox::isPressed() const
void QQuickComboBox::setPressed(bool pressed)
{
Q_D(QQuickComboBox);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ emit pressedChanged();
}
/*!
@@ -476,12 +479,13 @@ int QQuickComboBox::currentIndex() const
void QQuickComboBox::setCurrentIndex(int index)
{
Q_D(QQuickComboBox);
- if (d->currentIndex != index) {
- d->currentIndex = index;
- emit currentIndexChanged();
- if (isComponentComplete())
- d->updateCurrentText();
- }
+ if (d->currentIndex == index)
+ return;
+
+ d->currentIndex = index;
+ emit currentIndexChanged();
+ if (isComponentComplete())
+ d->updateCurrentText();
}
/*!
@@ -527,19 +531,21 @@ void QQuickComboBox::setDisplayText(const QString &text)
{
Q_D(QQuickComboBox);
d->hasDisplayText = true;
- if (d->displayText != text) {
- d->displayText = text;
- emit displayTextChanged();
- }
+ if (d->displayText == text)
+ return;
+
+ d->displayText = text;
+ emit displayTextChanged();
}
void QQuickComboBox::resetDisplayText()
{
Q_D(QQuickComboBox);
- if (d->hasDisplayText) {
- d->hasDisplayText = false;
- d->updateCurrentText();
- }
+ if (!d->hasDisplayText)
+ return;
+
+ d->hasDisplayText = false;
+ d->updateCurrentText();
}
/*!
@@ -558,12 +564,13 @@ QString QQuickComboBox::textRole() const
void QQuickComboBox::setTextRole(const QString &role)
{
Q_D(QQuickComboBox);
- if (d->textRole != role) {
- d->textRole = role;
- if (isComponentComplete())
- d->updateCurrentText();
- emit textRoleChanged();
- }
+ if (d->textRole == role)
+ return;
+
+ d->textRole = role;
+ if (isComponentComplete())
+ d->updateCurrentText();
+ emit textRoleChanged();
}
/*!
@@ -582,14 +589,15 @@ QQmlComponent *QQuickComboBox::delegate() const
void QQuickComboBox::setDelegate(QQmlComponent* delegate)
{
Q_D(QQuickComboBox);
- if (d->delegate != delegate) {
- delete d->delegate;
- d->delegate = delegate;
- QQmlDelegateModel *delegateModel = qobject_cast<QQmlDelegateModel*>(d->delegateModel);
- if (delegateModel)
- delegateModel->setDelegate(d->delegate);
- emit delegateChanged();
- }
+ if (d->delegate == delegate)
+ return;
+
+ delete d->delegate;
+ d->delegate = delegate;
+ QQmlDelegateModel *delegateModel = qobject_cast<QQmlDelegateModel*>(d->delegateModel);
+ if (delegateModel)
+ delegateModel->setDelegate(d->delegate);
+ emit delegateChanged();
}
/*!
@@ -608,13 +616,14 @@ QQuickPopup *QQuickComboBox::popup() const
void QQuickComboBox::setPopup(QQuickPopup *popup)
{
Q_D(QQuickComboBox);
- if (d->popup != popup) {
- delete d->popup;
- if (popup)
- popup->setClosePolicy(QQuickPopup::OnEscape | QQuickPopup::OnPressOutsideParent);
- d->popup = popup;
- emit popupChanged();
- }
+ if (d->popup == popup)
+ return;
+
+ delete d->popup;
+ if (popup)
+ popup->setClosePolicy(QQuickPopup::OnEscape | QQuickPopup::OnPressOutsideParent);
+ d->popup = popup;
+ emit popupChanged();
}
/*!
@@ -696,6 +705,28 @@ int QQuickComboBox::find(const QString &text, Qt::MatchFlags flags) const
return -1;
}
+/*!
+ \qmlmethod void Qt.labs.controls::ComboBox::increase()
+
+ Select next value.
+*/
+void QQuickComboBox::increase()
+{
+ Q_D(QQuickComboBox);
+ d->increase();
+}
+
+/*!
+ \qmlmethod void Qt.labs.controls::ComboBox::decrease()
+
+ Select previous value.
+*/
+void QQuickComboBox::decrease()
+{
+ Q_D(QQuickComboBox);
+ d->decrease();
+}
+
void QQuickComboBox::focusOutEvent(QFocusEvent *event)
{
Q_D(QQuickComboBox);
@@ -787,8 +818,6 @@ void QQuickComboBox::mouseReleaseEvent(QMouseEvent *event)
QQuickControl::mouseReleaseEvent(event);
if (d->pressed) {
setPressed(false);
- if (!d->isPopupVisible())
- forceActiveFocus(Qt::MouseFocusReason);
d->togglePopup(false);
}
}
@@ -799,6 +828,20 @@ void QQuickComboBox::mouseUngrabEvent()
setPressed(false);
}
+void QQuickComboBox::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QQuickComboBox);
+ QQuickControl::wheelEvent(event);
+ if (d->wheelEnabled && !d->isPopupVisible()) {
+ const int oldIndex = d->currentIndex;
+ if (event->angleDelta().y() > 0)
+ d->decrease();
+ else
+ d->increase();
+ event->setAccepted(d->currentIndex != oldIndex);
+ }
+}
+
void QQuickComboBox::componentComplete()
{
Q_D(QQuickComboBox);
diff --git a/src/templates/qquickcombobox_p.h b/src/templates/qquickcombobox_p.h
index 1d8f498a..23def3c8 100644
--- a/src/templates/qquickcombobox_p.h
+++ b/src/templates/qquickcombobox_p.h
@@ -72,7 +72,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickComboBox : public QQuickControl
Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL)
public:
- explicit QQuickComboBox(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickComboBox(QQuickItem *parent = nullptr);
~QQuickComboBox();
int count() const;
@@ -106,6 +106,9 @@ public:
Q_INVOKABLE QString textAt(int index) const;
Q_INVOKABLE int find(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly) const;
+public Q_SLOTS:
+ void increase();
+ void decrease();
Q_SIGNALS:
void countChanged();
@@ -124,17 +127,18 @@ Q_SIGNALS:
void highlighted(int index);
protected:
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
-
- void componentComplete() Q_DECL_OVERRIDE;
-
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ void focusOutEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void wheelEvent(QWheelEvent *event) override;
+
+ void componentComplete() override;
+
+ QFont defaultFont() const override;
private:
Q_DISABLE_COPY(QQuickComboBox)
diff --git a/src/templates/qquickcontainer.cpp b/src/templates/qquickcontainer.cpp
index 841eae8a..12b330f6 100644
--- a/src/templates/qquickcontainer.cpp
+++ b/src/templates/qquickcontainer.cpp
@@ -64,7 +64,7 @@ static QQuickItem *effectiveContentItem(QQuickItem *item)
return item;
}
-QQuickContainerPrivate::QQuickContainerPrivate() : contentModel(Q_NULLPTR), currentIndex(-1), updatingCurrent(false)
+QQuickContainerPrivate::QQuickContainerPrivate() : contentModel(nullptr), currentIndex(-1), updatingCurrent(false)
{
}
@@ -155,7 +155,7 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
}
QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed | QQuickItemPrivate::Parent);
- item->setParentItem(Q_NULLPTR);
+ item->setParentItem(nullptr);
contentModel->remove(index);
q->itemRemoved(index, item);
@@ -184,7 +184,7 @@ void QQuickContainerPrivate::itemParentChanged(QQuickItem *item, QQuickItem *par
{
// remove dynamically unparented items (eg. by a Repeater)
if (!parent)
- removeItem(contentModel->indexOf(item, Q_NULLPTR), item);
+ removeItem(contentModel->indexOf(item, nullptr), item);
}
void QQuickContainerPrivate::itemSiblingOrderChanged(QQuickItem *)
@@ -194,14 +194,14 @@ void QQuickContainerPrivate::itemSiblingOrderChanged(QQuickItem *)
QList<QQuickItem *> siblings = effectiveContentItem(contentItem)->childItems();
for (int i = 0; i < siblings.count(); ++i) {
QQuickItem* sibling = siblings.at(i);
- int index = contentModel->indexOf(sibling, Q_NULLPTR);
+ int index = contentModel->indexOf(sibling, nullptr);
q->moveItem(index, i);
}
}
void QQuickContainerPrivate::itemDestroyed(QQuickItem *item)
{
- int index = contentModel->indexOf(item, Q_NULLPTR);
+ int index = contentModel->indexOf(item, nullptr);
if (index != -1)
removeItem(index, item);
}
@@ -215,7 +215,7 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) {
QQuickItemPrivate::get(item)->addItemChangeListener(p, QQuickItemPrivate::SiblingOrder);
item->setParentItem(effectiveContentItem(p->contentItem));
- } else if (p->contentModel->indexOf(item, Q_NULLPTR) == -1) {
+ } else if (p->contentModel->indexOf(item, nullptr) == -1) {
q->addItem(item);
}
} else {
@@ -333,7 +333,7 @@ void QQuickContainer::insertItem(int index, QQuickItem *item)
if (index < 0 || index > count)
index = count;
- int oldIndex = d->contentModel->indexOf(item, Q_NULLPTR);
+ int oldIndex = d->contentModel->indexOf(item, nullptr);
if (oldIndex != -1) {
if (oldIndex < index)
--index;
@@ -442,11 +442,12 @@ int QQuickContainer::currentIndex() const
void QQuickContainer::setCurrentIndex(int index)
{
Q_D(QQuickContainer);
- if (d->currentIndex != index) {
- d->currentIndex = index;
- emit currentIndexChanged();
- emit currentItemChanged();
- }
+ if (d->currentIndex == index)
+ return;
+
+ d->currentIndex = index;
+ emit currentIndexChanged();
+ emit currentItemChanged();
}
/*!
@@ -465,7 +466,7 @@ void QQuickContainer::itemChange(ItemChange change, const ItemChangeData &data)
Q_D(QQuickContainer);
QQuickControl::itemChange(change, data);
if (change == QQuickItem::ItemChildAddedChange && isComponentComplete() && data.item != d->background && data.item != d->contentItem) {
- if (!QQuickItemPrivate::get(data.item)->isTransparentForPositioner() && d->contentModel->indexOf(data.item, Q_NULLPTR) == -1)
+ if (!QQuickItemPrivate::get(data.item)->isTransparentForPositioner() && d->contentModel->indexOf(data.item, nullptr) == -1)
addItem(data.item);
}
}
diff --git a/src/templates/qquickcontainer_p.h b/src/templates/qquickcontainer_p.h
index 83476f66..e11d5716 100644
--- a/src/templates/qquickcontainer_p.h
+++ b/src/templates/qquickcontainer_p.h
@@ -67,7 +67,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickContainer : public QQuickControl
Q_CLASSINFO("DefaultProperty", "contentData")
public:
- explicit QQuickContainer(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickContainer(QQuickItem *parent = nullptr);
~QQuickContainer();
int count() const;
@@ -96,8 +96,8 @@ Q_SIGNALS:
protected:
QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent);
- void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE;
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
virtual bool isContent(QQuickItem *item) const;
virtual void itemAdded(int index, QQuickItem *item);
diff --git a/src/templates/qquickcontainer_p_p.h b/src/templates/qquickcontainer_p_p.h
index 6eb79c88..8c1d470c 100644
--- a/src/templates/qquickcontainer_p_p.h
+++ b/src/templates/qquickcontainer_p_p.h
@@ -71,10 +71,10 @@ public:
void _q_currentIndexChanged();
- void itemChildAdded(QQuickItem *item, QQuickItem *child) Q_DECL_OVERRIDE;
- void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE;
- void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE;
- void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemChildAdded(QQuickItem *item, QQuickItem *child) override;
+ void itemSiblingOrderChanged(QQuickItem *item) override;
+ void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
+ void itemDestroyed(QQuickItem *item) override;
static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj);
static int contentData_count(QQmlListProperty<QObject> *prop);
diff --git a/src/templates/qquickcontrol.cpp b/src/templates/qquickcontrol.cpp
index 0e14bc37..ae6180ad 100644
--- a/src/templates/qquickcontrol.cpp
+++ b/src/templates/qquickcontrol.cpp
@@ -37,6 +37,7 @@
#include "qquickcontrol_p.h"
#include "qquickcontrol_p_p.h"
+#include <QtGui/qstylehints.h>
#include <QtGui/qguiapplication.h>
#include "qquicklabel_p.h"
#include "qquicklabel_p_p.h"
@@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE
\inherits Item
\instantiates QQuickControl
\inqmlmodule Qt.labs.controls
- \brief A user interface control.
+ \brief The base type of user interface controls.
Control is the base type of user interface controls.
@@ -70,9 +71,10 @@ QT_BEGIN_NAMESPACE
*/
QQuickControlPrivate::QQuickControlPrivate() :
- hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false),
- padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), spacing(0), focusReason(Qt::OtherFocusReason),
- background(Q_NULLPTR), contentItem(Q_NULLPTR), accessibleAttached(Q_NULLPTR)
+ hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false), hovered(false), wheelEnabled(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)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -296,7 +298,8 @@ void QQuickControlPrivate::updateFont(const QFont &f)
void QQuickControlPrivate::updateFontRecur(QQuickItem *item, const QFont &f)
{
- foreach (QQuickItem *child, item->childItems()) {
+ const auto childItems = item->childItems();
+ for (QQuickItem *child : childItems) {
if (QQuickControl *control = qobject_cast<QQuickControl *>(child))
QQuickControlPrivate::get(control)->resolveFont();
else if (QQuickLabel *label = qobject_cast<QQuickLabel *>(child))
@@ -710,7 +713,8 @@ void QQuickControlPrivate::updateLocale(const QLocale &l, bool e)
void QQuickControlPrivate::updateLocaleRecur(QQuickItem *item, const QLocale &l)
{
- foreach (QQuickItem *child, item->childItems()) {
+ const auto childItems = item->childItems();
+ for (QQuickItem *child : childItems) {
if (QQuickControl *control = qobject_cast<QQuickControl *>(child))
QQuickControlPrivate::get(control)->updateLocale(l, false);
else
@@ -743,6 +747,37 @@ bool QQuickControl::isMirrored() const
}
/*!
+ \qmlproperty enumeration Qt.labs.controls::Control::focusPolicy
+
+ This property determines the way the control accepts focus.
+
+ \value Qt.TabFocus The control accepts focus by tabbing.
+ \value Qt.ClickFocus The control accepts focus by clicking.
+ \value Qt.StrongFocus The control accepts focus by both tabbing and clicking.
+ \value Qt.WheelFocus The control accepts focus by tabbing, clicking, and using the mouse wheel.
+ \value Qt.NoFocus The control does not accept focus.
+*/
+Qt::FocusPolicy QQuickControl::focusPolicy() const
+{
+ Q_D(const QQuickControl);
+ uint policy = d->focusPolicy;
+ if (activeFocusOnTab())
+ policy |= Qt::TabFocus;
+ return static_cast<Qt::FocusPolicy>(policy);
+}
+
+void QQuickControl::setFocusPolicy(Qt::FocusPolicy policy)
+{
+ Q_D(QQuickControl);
+ if (d->focusPolicy == policy)
+ return;
+
+ d->focusPolicy = policy;
+ setActiveFocusOnTab(policy & Qt::TabFocus);
+ emit focusPolicyChanged();
+}
+
+/*!
\qmlproperty enumeration Qt.labs.controls::Control::focusReason
\readonly
@@ -771,10 +806,79 @@ Qt::FocusReason QQuickControl::focusReason() const
void QQuickControl::setFocusReason(Qt::FocusReason reason)
{
Q_D(QQuickControl);
- if (d->focusReason != reason) {
- d->focusReason = reason;
- emit focusReasonChanged();
- }
+ if (d->focusReason == reason)
+ return;
+
+ d->focusReason = reason;
+ emit focusReasonChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.controls::Control::hovered
+ \readonly
+
+ This property holds whether the control is hovered.
+
+ \sa hoverEnabled
+*/
+bool QQuickControl::isHovered() const
+{
+ Q_D(const QQuickControl);
+ return d->hovered;
+}
+
+void QQuickControl::setHovered(bool hovered)
+{
+ Q_D(QQuickControl);
+ if (hovered == d->hovered)
+ return;
+
+ d->hovered = hovered;
+ emit hoveredChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.controls::Control::hoverEnabled
+
+ This property determines whether the control accepts hover events. The default value is \c false.
+
+ \sa hovered
+*/
+bool QQuickControl::isHoverEnabled() const
+{
+ Q_D(const QQuickControl);
+ return d->hoverEnabled;
+}
+
+void QQuickControl::setHoverEnabled(bool enabled)
+{
+ Q_D(QQuickControl);
+ if (enabled == d->hoverEnabled)
+ return;
+
+ setAcceptHoverEvents(enabled);
+ emit hoverEnabledChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.controls::Control::wheelEnabled
+
+ This property determines whether the control handles wheel events. The default value is \c false.
+*/
+bool QQuickControl::isWheelEnabled() const
+{
+ Q_D(const QQuickControl);
+ return d->wheelEnabled;
+}
+
+void QQuickControl::setWheelEnabled(bool enabled)
+{
+ Q_D(QQuickControl);
+ if (d->wheelEnabled == enabled)
+ return;
+
+ d->wheelEnabled = enabled;
+ emit wheelEnabledChanged();
}
/*!
@@ -795,18 +899,19 @@ QQuickItem *QQuickControl::background() const
void QQuickControl::setBackground(QQuickItem *background)
{
Q_D(QQuickControl);
- if (d->background != background) {
- delete d->background;
- d->background = background;
- if (background) {
- background->setParentItem(this);
- if (qFuzzyIsNull(background->z()))
- background->setZ(-1);
- if (isComponentComplete())
- d->resizeBackground();
- }
- emit backgroundChanged();
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->resizeBackground();
}
+ emit backgroundChanged();
}
/*!
@@ -825,18 +930,19 @@ QQuickItem *QQuickControl::contentItem() const
void QQuickControl::setContentItem(QQuickItem *item)
{
Q_D(QQuickControl);
- if (d->contentItem != item) {
- contentItemChange(item, d->contentItem);
- delete d->contentItem;
- d->contentItem = item;
- if (item) {
- if (!item->parentItem())
- item->setParentItem(this);
- if (isComponentComplete())
- d->resizeContent();
- }
- emit contentItemChanged();
+ if (d->contentItem == item)
+ return;
+
+ contentItemChange(item, d->contentItem);
+ delete d->contentItem;
+ d->contentItem = item;
+ if (item) {
+ if (!item->parentItem())
+ item->setParentItem(this);
+ if (isComponentComplete())
+ d->resizeContent();
}
+ emit contentItemChanged();
}
void QQuickControl::componentComplete()
@@ -869,8 +975,26 @@ void QQuickControl::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+void QQuickControl::hoverEnterEvent(QHoverEvent *event)
+{
+ Q_D(QQuickControl);
+ setHovered(d->hoverEnabled);
+ event->setAccepted(d->hoverEnabled);
+}
+
+void QQuickControl::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_D(QQuickControl);
+ setHovered(false);
+ event->setAccepted(d->hoverEnabled);
+}
+
void QQuickControl::mousePressEvent(QMouseEvent *event)
{
+ Q_D(QQuickControl);
+ if ((d->focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease())
+ forceActiveFocus(Qt::MouseFocusReason);
+
event->accept();
}
@@ -881,9 +1005,22 @@ void QQuickControl::mouseMoveEvent(QMouseEvent *event)
void QQuickControl::mouseReleaseEvent(QMouseEvent *event)
{
+ Q_D(QQuickControl);
+ if ((d->focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && QGuiApplication::styleHints()->setFocusOnTouchRelease())
+ forceActiveFocus(Qt::MouseFocusReason);
+
event->accept();
}
+void QQuickControl::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QQuickControl);
+ if ((d->focusPolicy & Qt::WheelFocus) == Qt::WheelFocus)
+ forceActiveFocus(Qt::MouseFocusReason);
+
+ event->setAccepted(d->wheelEnabled);
+}
+
void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickControl);
diff --git a/src/templates/qquickcontrol_p.h b/src/templates/qquickcontrol_p.h
index 413fb7f4..e232dd73 100644
--- a/src/templates/qquickcontrol_p.h
+++ b/src/templates/qquickcontrol_p.h
@@ -70,12 +70,16 @@ class Q_LABSTEMPLATES_EXPORT QQuickControl : public QQuickItem
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL)
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL)
Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL)
+ Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged FINAL)
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
+ Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL)
+ Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled 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)
public:
- explicit QQuickControl(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickControl(QQuickItem *parent = nullptr);
QFont font() const;
void setFont(const QFont &);
@@ -114,9 +118,21 @@ public:
bool isMirrored() const;
+ Qt::FocusPolicy focusPolicy() const;
+ void setFocusPolicy(Qt::FocusPolicy policy);
+
Qt::FocusReason focusReason() const;
void setFocusReason(Qt::FocusReason reason);
+ bool isHovered() const;
+ void setHovered(bool hovered);
+
+ bool isHoverEnabled() const;
+ void setHoverEnabled(bool enabled);
+
+ bool isWheelEnabled() const;
+ void setWheelEnabled(bool enabled);
+
QQuickItem *background() const;
void setBackground(QQuickItem *background);
@@ -135,7 +151,11 @@ Q_SIGNALS:
void spacingChanged();
void localeChanged();
void mirroredChanged();
+ void focusPolicyChanged();
void focusReasonChanged();
+ void hoveredChanged();
+ void hoverEnabledChanged();
+ void wheelEnabledChanged();
void backgroundChanged();
void contentItemChanged();
@@ -144,17 +164,20 @@ protected:
QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent);
- void componentComplete() Q_DECL_OVERRIDE;
+ void componentComplete() override;
- void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
+ 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;
+ void wheelEvent(QWheelEvent *event) override;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
virtual void mirrorChange();
virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding);
diff --git a/src/templates/qquickcontrol_p_p.h b/src/templates/qquickcontrol_p_p.h
index d7821ec7..c6e405e6 100644
--- a/src/templates/qquickcontrol_p_p.h
+++ b/src/templates/qquickcontrol_p_p.h
@@ -77,7 +77,7 @@ public:
return control->d_func();
}
- void mirrorChange() Q_DECL_OVERRIDE;
+ void mirrorChange() override;
void setTopPadding(qreal value, bool reset = false);
void setLeftPadding(qreal value, bool reset = false);
@@ -88,8 +88,8 @@ public:
void resizeContent();
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
void updateFont(const QFont &);
@@ -112,6 +112,8 @@ public:
bool hasRightPadding;
bool hasBottomPadding;
bool hasLocale;
+ bool hovered;
+ bool wheelEnabled;
qreal padding;
qreal topPadding;
qreal leftPadding;
@@ -119,6 +121,7 @@ public:
qreal bottomPadding;
qreal spacing;
QLocale locale;
+ Qt::FocusPolicy focusPolicy;
Qt::FocusReason focusReason;
QQuickItem *background;
QQuickItem *contentItem;
diff --git a/src/templates/qquickdial.cpp b/src/templates/qquickdial.cpp
index 8d6e655a..e1083b35 100644
--- a/src/templates/qquickdial.cpp
+++ b/src/templates/qquickdial.cpp
@@ -92,7 +92,7 @@ public:
stepSize(0),
pressed(false),
snapMode(QQuickDial::NoSnap),
- handle(Q_NULLPTR)
+ handle(nullptr)
{
}
@@ -143,14 +143,15 @@ void QQuickDialPrivate::setPosition(qreal pos)
{
Q_Q(QQuickDial);
pos = qBound<qreal>(0.0, pos, 1.0);
- if (!qFuzzyCompare(position, pos)) {
- position = pos;
+ if (qFuzzyCompare(position, pos))
+ return;
- angle = startAngle + position * qAbs(endAngle - startAngle);
+ position = pos;
- emit q->positionChanged();
- emit q->angleChanged();
- }
+ angle = startAngle + position * qAbs(endAngle - startAngle);
+
+ emit q->positionChanged();
+ emit q->angleChanged();
}
void QQuickDialPrivate::updatePosition()
@@ -184,13 +185,14 @@ qreal QQuickDial::from() const
void QQuickDial::setFrom(qreal from)
{
Q_D(QQuickDial);
- if (!qFuzzyCompare(d->from, from)) {
- d->from = from;
- emit fromChanged();
- if (isComponentComplete()) {
- setValue(d->value);
- d->updatePosition();
- }
+ if (qFuzzyCompare(d->from, from))
+ return;
+
+ d->from = from;
+ emit fromChanged();
+ if (isComponentComplete()) {
+ setValue(d->value);
+ d->updatePosition();
}
}
@@ -211,13 +213,14 @@ qreal QQuickDial::to() const
void QQuickDial::setTo(qreal to)
{
Q_D(QQuickDial);
- if (!qFuzzyCompare(d->to, to)) {
- d->to = to;
- emit toChanged();
- if (isComponentComplete()) {
- setValue(d->value);
- d->updatePosition();
- }
+ if (qFuzzyCompare(d->to, to))
+ return;
+
+ d->to = to;
+ emit toChanged();
+ if (isComponentComplete()) {
+ setValue(d->value);
+ d->updatePosition();
}
}
@@ -245,11 +248,12 @@ void QQuickDial::setValue(qreal value)
if (isComponentComplete())
value = d->from > d->to ? qBound(d->to, value, d->from) : qBound(d->from, value, d->to);
- if (!qFuzzyCompare(d->value, value)) {
- d->value = value;
- d->updatePosition();
- emit valueChanged();
- }
+ if (qFuzzyCompare(d->value, value))
+ return;
+
+ d->value = value;
+ d->updatePosition();
+ emit valueChanged();
}
/*!
@@ -304,10 +308,11 @@ qreal QQuickDial::stepSize() const
void QQuickDial::setStepSize(qreal step)
{
Q_D(QQuickDial);
- if (!qFuzzyCompare(d->stepSize, step)) {
- d->stepSize = step;
- emit stepSizeChanged();
- }
+ if (qFuzzyCompare(d->stepSize, step))
+ return;
+
+ d->stepSize = step;
+ emit stepSizeChanged();
}
/*!
@@ -334,10 +339,11 @@ QQuickDial::SnapMode QQuickDial::snapMode() const
void QQuickDial::setSnapMode(SnapMode mode)
{
Q_D(QQuickDial);
- if (d->snapMode != mode) {
- d->snapMode = mode;
- emit snapModeChanged();
- }
+ if (d->snapMode == mode)
+ return;
+
+ d->snapMode = mode;
+ emit snapModeChanged();
}
/*!
@@ -367,11 +373,12 @@ bool QQuickDial::isPressed() const
void QQuickDial::setPressed(bool pressed)
{
Q_D(QQuickDial);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- setAccessibleProperty("pressed", pressed);
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ setAccessibleProperty("pressed", pressed);
+ emit pressedChanged();
}
/*!
@@ -420,12 +427,13 @@ QQuickItem *QQuickDial::handle() const
void QQuickDial::setHandle(QQuickItem *handle)
{
Q_D(QQuickDial);
- if (handle != d->handle) {
- d->handle = handle;
- if (d->handle && !d->handle->parentItem())
- d->handle->setParentItem(this);
- emit handleChanged();
- }
+ if (handle == d->handle)
+ return;
+
+ d->handle = handle;
+ if (d->handle && !d->handle->parentItem())
+ d->handle->setParentItem(this);
+ emit handleChanged();
}
void QQuickDial::keyPressEvent(QKeyEvent *event)
diff --git a/src/templates/qquickdial_p.h b/src/templates/qquickdial_p.h
index 19d37547..2fd2f649 100644
--- a/src/templates/qquickdial_p.h
+++ b/src/templates/qquickdial_p.h
@@ -71,7 +71,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickDial : public QQuickControl
Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
public:
- explicit QQuickDial(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickDial(QQuickItem *parent = nullptr);
qreal from() const;
void setFrom(qreal from);
@@ -121,18 +121,18 @@ Q_SIGNALS:
void handleChanged();
protected:
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void mirrorChange() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void mirrorChange() override;
+ void componentComplete() override;
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickdrawer.cpp b/src/templates/qquickdrawer.cpp
index 5f3d95c9..a28d11a6 100644
--- a/src/templates/qquickdrawer.cpp
+++ b/src/templates/qquickdrawer.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-navigation
\ingroup qtlabscontrols-containers
- \brief A side panel control.
+ \brief Provides a swipe-based side panel.
Drawer provides a swipe-based side panel, similar to those often used in
touch interfaces to provide a central location for navigation.
@@ -97,14 +97,14 @@ class QQuickDrawerPrivate : public QQuickControlPrivate, public QQuickItemChange
public:
QQuickDrawerPrivate() : edge(Qt::LeftEdge), offset(0), position(0),
- content(Q_NULLPTR), animation(Q_NULLPTR) { }
+ content(nullptr), animation(nullptr) { }
void updateContent();
bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
- void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) override;
Qt::Edge edge;
qreal offset;
@@ -290,12 +290,13 @@ Qt::Edge QQuickDrawer::edge() const
void QQuickDrawer::setEdge(Qt::Edge edge)
{
Q_D(QQuickDrawer);
- if (d->edge != edge) {
- d->edge = edge;
- if (isComponentComplete())
- d->updateContent();
- emit edgeChanged();
- }
+ if (d->edge == edge)
+ return;
+
+ d->edge = edge;
+ if (isComponentComplete())
+ d->updateContent();
+ emit edgeChanged();
}
/*!
@@ -315,12 +316,13 @@ void QQuickDrawer::setPosition(qreal position)
{
Q_D(QQuickDrawer);
position = qBound<qreal>(0.0, position, 1.0);
- if (!qFuzzyCompare(d->position, position)) {
- d->position = position;
- if (isComponentComplete())
- d->updateContent();
- emit positionChanged();
- }
+ if (qFuzzyCompare(d->position, position))
+ return;
+
+ d->position = position;
+ if (isComponentComplete())
+ d->updateContent();
+ emit positionChanged();
}
@@ -338,20 +340,21 @@ QQuickItem *QQuickDrawer::contentItem() const
void QQuickDrawer::setContentItem(QQuickItem *item)
{
Q_D(QQuickDrawer);
- if (d->content != item) {
- if (d->content) {
- QQuickItemPrivate::get(d->content)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- delete d->content;
- }
- d->content = item;
- if (item) {
- item->setParentItem(this);
- QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- if (isComponentComplete())
- d->updateContent();
- }
- emit contentItemChanged();
+ if (d->content == item)
+ return;
+
+ if (d->content) {
+ QQuickItemPrivate::get(d->content)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ delete d->content;
}
+ d->content = item;
+ if (item) {
+ item->setParentItem(this);
+ QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ if (isComponentComplete())
+ d->updateContent();
+ }
+ emit contentItemChanged();
}
/*!
@@ -371,15 +374,16 @@ QQuickPropertyAnimation *QQuickDrawer::animation() const
void QQuickDrawer::setAnimation(QQuickPropertyAnimation *animation)
{
Q_D(QQuickDrawer);
- if (d->animation != animation) {
- delete d->animation;
- d->animation = animation;
- if (animation) {
- animation->setTargetObject(this);
- animation->setProperty(QStringLiteral("position"));
- }
- emit animationChanged();
+ if (d->animation == animation)
+ return;
+
+ delete d->animation;
+ d->animation = animation;
+ if (animation) {
+ animation->setTargetObject(this);
+ animation->setProperty(QStringLiteral("position"));
}
+ emit animationChanged();
}
/*!
diff --git a/src/templates/qquickdrawer_p.h b/src/templates/qquickdrawer_p.h
index f953b0fd..39f1802a 100644
--- a/src/templates/qquickdrawer_p.h
+++ b/src/templates/qquickdrawer_p.h
@@ -66,7 +66,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickDrawer : public QQuickControl
Q_CLASSINFO("DefaultProperty", "contentItem")
public:
- explicit QQuickDrawer(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickDrawer(QQuickItem *parent = nullptr);
Qt::Edge edge() const;
void setEdge(Qt::Edge edge);
@@ -92,13 +92,13 @@ Q_SIGNALS:
void animationChanged();
protected:
- bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void componentComplete() override;
virtual qreal positionAt(const QPointF &point) const;
diff --git a/src/templates/qquickframe.cpp b/src/templates/qquickframe.cpp
index 67dfe256..6b0a08ac 100644
--- a/src/templates/qquickframe.cpp
+++ b/src/templates/qquickframe.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickFrame
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-containers
- \brief A frame control.
+ \brief A logical group of controls within a visual frame.
Frame is used to layout a logical group of controls together, within a
visual frame. Frame does not provide a layout of its own, but requires
@@ -65,10 +65,6 @@ QT_BEGIN_NAMESPACE
\sa {Customizing Frame}, {Container Controls}
*/
-QQuickFramePrivate::QQuickFramePrivate() : frame(Q_NULLPTR)
-{
-}
-
QQuickFrame::QQuickFrame(QQuickItem *parent) :
QQuickPane(*(new QQuickFramePrivate), parent)
{
@@ -79,29 +75,4 @@ QQuickFrame::QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent) :
{
}
-/*!
- \qmlproperty Item Qt.labs.controls::Frame::frame
-
- This property holds the visual frame item.
-
- \sa {Customizing Frame}
-*/
-QQuickItem *QQuickFrame::frame() const
-{
- Q_D(const QQuickFrame);
- return d->frame;
-}
-
-void QQuickFrame::setFrame(QQuickItem *frame)
-{
- Q_D(QQuickFrame);
- if (d->frame != frame) {
- delete d->frame;
- d->frame = frame;
- if (frame && !frame->parentItem())
- frame->setParentItem(this);
- emit frameChanged();
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/templates/qquickframe_p.h b/src/templates/qquickframe_p.h
index 0bfd63e8..8c35b859 100644
--- a/src/templates/qquickframe_p.h
+++ b/src/templates/qquickframe_p.h
@@ -57,16 +57,9 @@ class QQuickFramePrivate;
class Q_LABSTEMPLATES_EXPORT QQuickFrame : public QQuickPane
{
Q_OBJECT
- Q_PROPERTY(QQuickItem *frame READ frame WRITE setFrame NOTIFY frameChanged FINAL)
public:
- explicit QQuickFrame(QQuickItem *parent = Q_NULLPTR);
-
- QQuickItem *frame() const;
- void setFrame(QQuickItem *frame);
-
-Q_SIGNALS:
- void frameChanged();
+ explicit QQuickFrame(QQuickItem *parent = nullptr);
protected:
QQuickFrame(QQuickFramePrivate &dd, QQuickItem *parent);
diff --git a/src/templates/qquickframe_p_p.h b/src/templates/qquickframe_p_p.h
index 3d570572..4e0f16f6 100644
--- a/src/templates/qquickframe_p_p.h
+++ b/src/templates/qquickframe_p_p.h
@@ -56,12 +56,6 @@ class QQuickFrame;
class Q_LABSTEMPLATES_EXPORT QQuickFramePrivate : public QQuickPanePrivate
{
- Q_DECLARE_PUBLIC(QQuickFrame)
-
-public:
- QQuickFramePrivate();
-
- QQuickItem *frame;
};
QT_END_NAMESPACE
diff --git a/src/templates/qquickgroupbox.cpp b/src/templates/qquickgroupbox.cpp
index 84944987..33f7c672 100644
--- a/src/templates/qquickgroupbox.cpp
+++ b/src/templates/qquickgroupbox.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickGroupBox
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-containers
- \brief A group box control.
+ \brief A frame with a logical group of controls.
GroupBox is used to layout a logical group of controls together, within
a titled visual frame. GroupBox does not provide a layout of its own, but
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
class QQuickGroupBoxPrivate : public QQuickFramePrivate
{
public:
- QQuickGroupBoxPrivate() : label(Q_NULLPTR) { }
+ QQuickGroupBoxPrivate() : label(nullptr) { }
QString title;
QQuickItem *label;
@@ -108,10 +108,11 @@ QString QQuickGroupBox::title() const
void QQuickGroupBox::setTitle(const QString &title)
{
Q_D(QQuickGroupBox);
- if (d->title != title) {
- d->title = title;
- emit titleChanged();
- }
+ if (d->title == title)
+ return;
+
+ d->title = title;
+ emit titleChanged();
}
/*!
@@ -130,13 +131,14 @@ QQuickItem *QQuickGroupBox::label() const
void QQuickGroupBox::setLabel(QQuickItem *label)
{
Q_D(QQuickGroupBox);
- if (d->label != label) {
- delete d->label;
- d->label = label;
- if (label && !label->parentItem())
- label->setParentItem(this);
- emit labelChanged();
- }
+ if (d->label == label)
+ return;
+
+ delete d->label;
+ d->label = label;
+ if (label && !label->parentItem())
+ label->setParentItem(this);
+ emit labelChanged();
}
QFont QQuickGroupBox::defaultFont() const
diff --git a/src/templates/qquickgroupbox_p.h b/src/templates/qquickgroupbox_p.h
index b81d6534..81ba58ab 100644
--- a/src/templates/qquickgroupbox_p.h
+++ b/src/templates/qquickgroupbox_p.h
@@ -61,7 +61,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickGroupBox : public QQuickFrame
Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL)
public:
- explicit QQuickGroupBox(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickGroupBox(QQuickItem *parent = nullptr);
QString title() const;
void setTitle(const QString &title);
@@ -74,7 +74,7 @@ Q_SIGNALS:
void labelChanged();
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
private:
Q_DISABLE_COPY(QQuickGroupBox)
diff --git a/src/templates/qquickitemdelegate.cpp b/src/templates/qquickitemdelegate.cpp
index 98364fad..ab5e1925 100644
--- a/src/templates/qquickitemdelegate.cpp
+++ b/src/templates/qquickitemdelegate.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
\inherits AbstractButton
\instantiates QQuickItemDelegate
\inqmlmodule Qt.labs.controls
- \brief An item delegate.
+ \brief A standard view item that can be used in various views and controls.
ItemDelegate presents a standard view item. It can be used as a delegate
in various views and controls, such as \l ListView and \l ComboBox.
diff --git a/src/templates/qquickitemdelegate_p.h b/src/templates/qquickitemdelegate_p.h
index 1be909d7..24d90c20 100644
--- a/src/templates/qquickitemdelegate_p.h
+++ b/src/templates/qquickitemdelegate_p.h
@@ -59,13 +59,13 @@ class Q_LABSTEMPLATES_EXPORT QQuickItemDelegate : public QQuickAbstractButton
Q_OBJECT
public:
- explicit QQuickItemDelegate(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickItemDelegate(QQuickItem *parent = nullptr);
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquicklabel.cpp b/src/templates/qquicklabel.cpp
index 13ff3a6e..e9fb274d 100644
--- a/src/templates/qquicklabel.cpp
+++ b/src/templates/qquicklabel.cpp
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickLabel
\inqmlmodule Qt.labs.controls
\ingroup text
- \brief A text label.
+ \brief A text label with inherited styling and font.
Label extends \l Text with styling and \l {Control::font}{font}
inheritance. The default colors and font are style specific. Label
@@ -83,7 +83,7 @@ QQuickLabel::~QQuickLabel()
}
QQuickLabelPrivate::QQuickLabelPrivate()
- : background(Q_NULLPTR), accessibleAttached(Q_NULLPTR)
+ : background(nullptr), accessibleAttached(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -195,16 +195,17 @@ QQuickItem *QQuickLabel::background() const
void QQuickLabel::setBackground(QQuickItem *background)
{
Q_D(QQuickLabel);
- if (d->background != background) {
- delete d->background;
- d->background = background;
- if (background) {
- background->setParentItem(this);
- if (qFuzzyIsNull(background->z()))
- background->setZ(-1);
- }
- emit backgroundChanged();
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
}
+ emit backgroundChanged();
}
void QQuickLabel::classBegin()
diff --git a/src/templates/qquicklabel_p.h b/src/templates/qquicklabel_p.h
index 26f72840..7bb09d1b 100644
--- a/src/templates/qquicklabel_p.h
+++ b/src/templates/qquicklabel_p.h
@@ -62,7 +62,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickLabel : public QQuickText
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
public:
- explicit QQuickLabel(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickLabel(QQuickItem *parent = nullptr);
~QQuickLabel();
QFont font() const;
@@ -76,10 +76,10 @@ Q_SIGNALS:
void backgroundChanged();
protected:
- void classBegin() Q_DECL_OVERRIDE;
+ void classBegin() override;
- void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
private:
Q_DISABLE_COPY(QQuickLabel)
diff --git a/src/templates/qquicklabel_p_p.h b/src/templates/qquicklabel_p_p.h
index a4e9f4e5..9d0ff05c 100644
--- a/src/templates/qquicklabel_p_p.h
+++ b/src/templates/qquicklabel_p_p.h
@@ -78,8 +78,8 @@ public:
void _q_textChanged(const QString &text);
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
QQuickItem *background;
diff --git a/src/templates/qquickmenu.cpp b/src/templates/qquickmenu.cpp
index 0ea0caba..13f90546 100644
--- a/src/templates/qquickmenu.cpp
+++ b/src/templates/qquickmenu.cpp
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickMenu
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-menus
- \brief A menu control.
+ \brief A menu control that can be used as a context menu or popup menu.
\image qtlabscontrols-menu.png
@@ -92,8 +92,8 @@ QT_BEGIN_NAMESPACE
*/
QQuickMenuPrivate::QQuickMenuPrivate() :
- contentModel(Q_NULLPTR),
- dummyFocusItem(Q_NULLPTR),
+ contentModel(nullptr),
+ dummyFocusItem(nullptr),
ignoreActiveFocusChanges(false)
{
Q_Q(QQuickMenu);
@@ -125,7 +125,7 @@ void QQuickMenuPrivate::removeItem(int index, QQuickItem *item)
contentData.removeOne(item);
QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed | QQuickItemPrivate::Parent);
- item->setParentItem(Q_NULLPTR);
+ item->setParentItem(nullptr);
contentModel->remove(index);
}
@@ -161,7 +161,7 @@ void QQuickMenuPrivate::itemParentChanged(QQuickItem *item, QQuickItem *parent)
{
// remove dynamically unparented items (eg. by a Repeater)
if (!parent)
- removeItem(contentModel->indexOf(item, Q_NULLPTR), item);
+ removeItem(contentModel->indexOf(item, nullptr), item);
}
void QQuickMenuPrivate::itemSiblingOrderChanged(QQuickItem *)
@@ -171,14 +171,14 @@ void QQuickMenuPrivate::itemSiblingOrderChanged(QQuickItem *)
QList<QQuickItem *> siblings = contentItem->childItems();
for (int i = 0; i < siblings.count(); ++i) {
QQuickItem* sibling = siblings.at(i);
- int index = contentModel->indexOf(sibling, Q_NULLPTR);
+ int index = contentModel->indexOf(sibling, nullptr);
q->moveItem(index, i);
}
}
void QQuickMenuPrivate::itemDestroyed(QQuickItem *item)
{
- int index = contentModel->indexOf(item, Q_NULLPTR);
+ int index = contentModel->indexOf(item, nullptr);
if (index != -1)
removeItem(index, item);
}
@@ -193,7 +193,7 @@ void QQuickMenuPrivate::onItemPressed()
{
Q_Q(QQuickMenu);
QQuickItem *item = qobject_cast<QQuickItem*>(q->sender());
- int itemIndex = contentModel->indexOf(item, Q_NULLPTR);
+ int itemIndex = contentModel->indexOf(item, nullptr);
Q_ASSERT(itemIndex != -1);
if (!contentItem->property("currentIndex").isValid())
@@ -215,7 +215,7 @@ void QQuickMenuPrivate::onItemActiveFocusChanged()
if (!contentItem->property("currentIndex").isValid())
return;
- int indexOfItem = contentModel->indexOf(item, Q_NULLPTR);
+ int indexOfItem = contentModel->indexOf(item, nullptr);
contentItem->setProperty("currentIndex", indexOfItem);
}
@@ -265,7 +265,7 @@ void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObj
if (QQuickItemPrivate::get(item)->isTransparentForPositioner()) {
QQuickItemPrivate::get(item)->addItemChangeListener(p, QQuickItemPrivate::SiblingOrder);
item->setParentItem(p->contentItem);
- } else if (p->contentModel->indexOf(item, Q_NULLPTR) == -1) {
+ } else if (p->contentModel->indexOf(item, nullptr) == -1) {
q->addItem(item);
QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem *>(item);
@@ -342,7 +342,7 @@ void QQuickMenu::insertItem(int index, QQuickItem *item)
if (index < 0 || index > count)
index = count;
- int oldIndex = d->contentModel->indexOf(item, Q_NULLPTR);
+ int oldIndex = d->contentModel->indexOf(item, nullptr);
if (oldIndex != -1) {
if (oldIndex < index)
--index;
diff --git a/src/templates/qquickmenu_p.h b/src/templates/qquickmenu_p.h
index b70ca49f..9ed3f45c 100644
--- a/src/templates/qquickmenu_p.h
+++ b/src/templates/qquickmenu_p.h
@@ -67,7 +67,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickMenu : public QQuickPopup
Q_CLASSINFO("DefaultProperty", "contentData")
public:
- explicit QQuickMenu(QObject *parent = Q_NULLPTR);
+ explicit QQuickMenu(QObject *parent = nullptr);
Q_INVOKABLE QQuickItem *itemAt(int index) const;
Q_INVOKABLE void addItem(QQuickItem *item);
@@ -82,16 +82,16 @@ public:
void setTitle(QString &title);
protected:
- void componentComplete() Q_DECL_OVERRIDE;
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ void componentComplete() override;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
+ bool eventFilter(QObject *object, QEvent *event) override;
Q_SIGNALS:
void titleChanged();
protected:
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif // QT_NO_ACCESSIBILITY
private:
diff --git a/src/templates/qquickmenu_p_p.h b/src/templates/qquickmenu_p_p.h
index 4c2aed16..366dbc35 100644
--- a/src/templates/qquickmenu_p_p.h
+++ b/src/templates/qquickmenu_p_p.h
@@ -73,11 +73,11 @@ public:
void resizeItem(QQuickItem *item);
void resizeItems();
- void itemChildAdded(QQuickItem *item, QQuickItem *child) Q_DECL_OVERRIDE;
- void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE;
- void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE;
- void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE;
- void itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void itemChildAdded(QQuickItem *item, QQuickItem *child) override;
+ 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 onItemPressed();
void onItemActiveFocusChanged();
diff --git a/src/templates/qquickmenuitem_p.h b/src/templates/qquickmenuitem_p.h
index 91d1e91e..812597be 100644
--- a/src/templates/qquickmenuitem_p.h
+++ b/src/templates/qquickmenuitem_p.h
@@ -59,16 +59,16 @@ class Q_LABSTEMPLATES_EXPORT QQuickMenuItem : public QQuickAbstractButton
Q_OBJECT
public:
- explicit QQuickMenuItem(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickMenuItem(QQuickItem *parent = nullptr);
Q_SIGNALS:
void triggered();
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickoverlay.cpp b/src/templates/qquickoverlay.cpp
index dd9d2c5d..acee3187 100644
--- a/src/templates/qquickoverlay.cpp
+++ b/src/templates/qquickoverlay.cpp
@@ -109,7 +109,7 @@ void QQuickOverlayPrivate::resizeBackground()
}
QQuickOverlayPrivate::QQuickOverlayPrivate() :
- background(Q_NULLPTR),
+ background(nullptr),
modalPopups(0)
{
}
@@ -132,19 +132,20 @@ QQuickItem *QQuickOverlay::background() const
void QQuickOverlay::setBackground(QQuickItem *background)
{
Q_D(QQuickOverlay);
- if (d->background != background) {
- delete d->background;
- d->background = background;
- if (background) {
- background->setOpacity(0.0);
- background->setParentItem(this);
- if (qFuzzyIsNull(background->z()))
- background->setZ(-1);
- if (isComponentComplete())
- d->resizeBackground();
- }
- emit backgroundChanged();
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setOpacity(0.0);
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->resizeBackground();
}
+ emit backgroundChanged();
}
void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
@@ -152,7 +153,7 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
Q_D(QQuickOverlay);
QQuickItem::itemChange(change, data);
- QQuickPopup *popup = Q_NULLPTR;
+ QQuickPopup *popup = nullptr;
if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(data.item);
if (drawer) {
@@ -196,52 +197,26 @@ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &old
d->resizeBackground();
}
-void QQuickOverlay::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::keyReleaseEvent(QKeyEvent *event)
+bool QQuickOverlay::event(QEvent *event)
{
Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::mousePressEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
- emit pressed();
-
- for (int i = d->popups.count() - 1; i >= 0; --i) {
- if (QQuickPopupPrivate::get(d->popups.at(i))->tryClose(this, event))
- break;
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ emit pressed();
+ break;
+ case QEvent::MouseButtonRelease:
+ emit released();
+ break;
+ default:
+ break;
}
-}
-void QQuickOverlay::mouseMoveEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
-}
-
-void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
- emit released();
-
- for (int i = d->popups.count() - 1; i >= 0; --i) {
- if (QQuickPopupPrivate::get(d->popups.at(i))->tryClose(this, event))
- break;
+ for (auto it = d->popups.rbegin(), end = d->popups.rend(); it != end; ++it) {
+ if ((*it)->overlayEvent(this, event))
+ return true;
}
-}
-void QQuickOverlay::wheelEvent(QWheelEvent *event)
-{
- Q_D(QQuickOverlay);
- event->setAccepted(d->modalPopups > 0);
+ return QQuickItem::event(event);
}
bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
@@ -255,26 +230,18 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
while (item->parentItem() != this)
item = item->parentItem();
- bool modalBlocked = false;
- const QQuickItemPrivate *priv = QQuickItemPrivate::get(this);
- const QList<QQuickItem *> &sortedChildren = priv->paintOrderChildItems();
- for (int i = sortedChildren.count() - 1; i >= 0; --i) {
- QQuickItem *popupItem = sortedChildren[i];
+ const QList<QQuickItem *> sortedChildren = d->paintOrderChildItems();
+ for (auto it = sortedChildren.rbegin(), end = sortedChildren.rend(); it != end; ++it) {
+ QQuickItem *popupItem = *it;
if (popupItem == item)
break;
QQuickPopup *popup = qobject_cast<QQuickPopup *>(popupItem->parent());
- if (popup) {
- QQuickPopup::ClosePolicy policy = popup->closePolicy();
- if (policy.testFlag(QQuickPopup::OnPressOutside) || policy.testFlag(QQuickPopup::OnPressOutsideParent))
- popup->close();
-
- if (!modalBlocked && popup->isModal())
- modalBlocked = true;
- }
+ if (popup && popup->overlayEvent(item, event))
+ return true;
}
- return modalBlocked;
+ return false;
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickoverlay_p.h b/src/templates/qquickoverlay_p.h
index 6a4d56b3..33e008c5 100644
--- a/src/templates/qquickoverlay_p.h
+++ b/src/templates/qquickoverlay_p.h
@@ -61,7 +61,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickOverlay : public QQuickItem
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
public:
- explicit QQuickOverlay(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickOverlay(QQuickItem *parent = nullptr);
QQuickItem *background() const;
void setBackground(QQuickItem *background);
@@ -72,16 +72,11 @@ Q_SIGNALS:
void released();
protected:
- void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) Q_DECL_OVERRIDE;
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
+ void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) override;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
- bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ bool childMouseEventFilter(QQuickItem *item, QEvent *event) override;
private:
Q_DISABLE_COPY(QQuickOverlay)
diff --git a/src/templates/qquickpage.cpp b/src/templates/qquickpage.cpp
index 6a65e7c4..a4225028 100644
--- a/src/templates/qquickpage.cpp
+++ b/src/templates/qquickpage.cpp
@@ -36,6 +36,8 @@
#include "qquickpage_p.h"
#include "qquickcontrol_p_p.h"
+#include "qquicktoolbar_p.h"
+#include "qquicktabbar_p.h"
#include <QtQuick/private/qquickitemchangelistener_p.h>
@@ -47,7 +49,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPage
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-containers
- \brief A page control.
+ \brief A control that makes it convenient to add a header and footer to a page.
Page is a container control which makes it convenient to add
a \l header and \l footer item to a page.
@@ -91,14 +93,14 @@ public:
void relayout();
- void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE;
- void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
QQuickItem *header;
QQuickItem *footer;
};
-QQuickPagePrivate::QQuickPagePrivate() : header(Q_NULLPTR), footer(Q_NULLPTR)
+QQuickPagePrivate::QQuickPagePrivate() : header(nullptr), footer(nullptr)
{
}
@@ -148,6 +150,9 @@ QQuickPage::QQuickPage(QQuickItem *parent) :
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.
+
\sa footer, ApplicationWindow::header
*/
QQuickItem *QQuickPage::header() const
@@ -159,23 +164,28 @@ QQuickItem *QQuickPage::header() const
void QQuickPage::setHeader(QQuickItem *header)
{
Q_D(QQuickPage);
- if (d->header != header) {
- if (d->header) {
- QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->header->setParentItem(Q_NULLPTR);
- }
- d->header = header;
- if (header) {
- header->setParentItem(this);
- QQuickItemPrivate *p = QQuickItemPrivate::get(header);
- p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(header->z()))
- header->setZ(1);
- if (isComponentComplete())
- d->relayout();
- }
- emit headerChanged();
+ if (d->header == header)
+ return;
+
+ if (d->header) {
+ QQuickItemPrivate::get(d->header)->removeItemChangeListener(d, 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::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();
}
+ emit headerChanged();
}
/*!
@@ -184,6 +194,9 @@ 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.
+
\sa header, ApplicationWindow::footer
*/
QQuickItem *QQuickPage::footer() const
@@ -195,23 +208,28 @@ QQuickItem *QQuickPage::footer() const
void QQuickPage::setFooter(QQuickItem *footer)
{
Q_D(QQuickPage);
- if (d->footer != footer) {
- if (d->footer) {
- QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- d->footer->setParentItem(Q_NULLPTR);
- }
- d->footer = footer;
- if (footer) {
- footer->setParentItem(this);
- QQuickItemPrivate *p = QQuickItemPrivate::get(footer);
- p->addItemChangeListener(d, QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight);
- if (qFuzzyIsNull(footer->z()))
- footer->setZ(1);
- if (isComponentComplete())
- d->relayout();
- }
- emit footerChanged();
+ if (d->footer == footer)
+ return;
+
+ if (d->footer) {
+ QQuickItemPrivate::get(d->footer)->removeItemChangeListener(d, 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::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();
}
+ emit footerChanged();
}
/*!
@@ -225,7 +243,7 @@ void QQuickPage::setFooter(QQuickItem *footer)
QQmlListProperty<QObject> QQuickPage::contentData()
{
Q_D(QQuickPage);
- return QQmlListProperty<QObject>(d->contentItem, Q_NULLPTR,
+ return QQmlListProperty<QObject>(d->contentItem, nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -242,7 +260,7 @@ QQmlListProperty<QObject> QQuickPage::contentData()
QQmlListProperty<QQuickItem> QQuickPage::contentChildren()
{
Q_D(QQuickPage);
- return QQmlListProperty<QQuickItem>(d->contentItem, Q_NULLPTR,
+ return QQmlListProperty<QQuickItem>(d->contentItem, nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
diff --git a/src/templates/qquickpage_p.h b/src/templates/qquickpage_p.h
index 157f0507..c21bb0ac 100644
--- a/src/templates/qquickpage_p.h
+++ b/src/templates/qquickpage_p.h
@@ -65,7 +65,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickPage : public QQuickControl
Q_CLASSINFO("DefaultProperty", "contentData")
public:
- explicit QQuickPage(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickPage(QQuickItem *parent = nullptr);
QQuickItem *header() const;
void setHeader(QQuickItem *header);
@@ -82,12 +82,12 @@ Q_SIGNALS:
void contentChildrenChanged();
protected:
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE;
+ 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;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickpageindicator.cpp b/src/templates/qquickpageindicator.cpp
index a360627e..1035085e 100644
--- a/src/templates/qquickpageindicator.cpp
+++ b/src/templates/qquickpageindicator.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPageIndicator
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-indicators
- \brief A page indicator control.
+ \brief Indicates the currently active page.
PageIndicator is used to indicate the currently active page
in a container of multiple pages. PageIndicator consists of
@@ -70,7 +70,7 @@ class QQuickPageIndicatorPrivate : public QQuickControlPrivate, public QQuickIte
public:
QQuickPageIndicatorPrivate() : count(0), currentIndex(0),
- interactive(false), delegate(Q_NULLPTR), pressedItem(Q_NULLPTR)
+ interactive(false), delegate(nullptr), pressedItem(nullptr)
{
}
@@ -91,7 +91,7 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
{
Q_Q(const QQuickPageIndicator);
if (!contentItem || !q->contains(pos))
- return Q_NULLPTR;
+ return nullptr;
QPointF contentPos = q->mapToItem(contentItem, pos);
QQuickItem *item = contentItem->childAt(contentPos.x(), contentPos.y());
@@ -102,8 +102,9 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
// find the nearest
qreal distance = qInf();
- QQuickItem *nearest = Q_NULLPTR;
- foreach (QQuickItem *child, contentItem->childItems()) {
+ QQuickItem *nearest = nullptr;
+ const auto childItems = contentItem->childItems();
+ for (QQuickItem *child : childItems) {
if (QQuickItemPrivate::get(child)->isTransparentForPositioner())
continue;
@@ -122,7 +123,7 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const
void QQuickPageIndicatorPrivate::updatePressed(bool pressed, const QPoint &pos)
{
QQuickItem *prevItem = pressedItem;
- pressedItem = pressed ? itemAt(pos) : Q_NULLPTR;
+ pressedItem = pressed ? itemAt(pos) : nullptr;
if (prevItem != pressedItem) {
setContextProperty(prevItem, QStringLiteral("pressed"), false);
setContextProperty(pressedItem, QStringLiteral("pressed"), pressed);
@@ -164,10 +165,11 @@ int QQuickPageIndicator::count() const
void QQuickPageIndicator::setCount(int count)
{
Q_D(QQuickPageIndicator);
- if (d->count != count) {
- d->count = count;
- emit countChanged();
- }
+ if (d->count == count)
+ return;
+
+ d->count = count;
+ emit countChanged();
}
/*!
@@ -184,10 +186,11 @@ int QQuickPageIndicator::currentIndex() const
void QQuickPageIndicator::setCurrentIndex(int index)
{
Q_D(QQuickPageIndicator);
- if (d->currentIndex != index) {
- d->currentIndex = index;
- emit currentIndexChanged();
- }
+ if (d->currentIndex == index)
+ return;
+
+ d->currentIndex = index;
+ emit currentIndexChanged();
}
/*!
@@ -208,11 +211,12 @@ bool QQuickPageIndicator::isInteractive() const
void QQuickPageIndicator::setInteractive(bool interactive)
{
Q_D(QQuickPageIndicator);
- if (d->interactive != interactive) {
- d->interactive = interactive;
- setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton);
- emit interactiveChanged();
- }
+ if (d->interactive == interactive)
+ return;
+
+ d->interactive = interactive;
+ setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton);
+ emit interactiveChanged();
}
/*!
@@ -235,10 +239,11 @@ QQmlComponent *QQuickPageIndicator::delegate() const
void QQuickPageIndicator::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickPageIndicator);
- if (d->delegate != delegate) {
- d->delegate = delegate;
- emit delegateChanged();
- }
+ if (d->delegate == delegate)
+ return;
+
+ d->delegate = delegate;
+ emit delegateChanged();
}
void QQuickPageIndicator::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
diff --git a/src/templates/qquickpageindicator_p.h b/src/templates/qquickpageindicator_p.h
index 487b4d6e..b776cbb6 100644
--- a/src/templates/qquickpageindicator_p.h
+++ b/src/templates/qquickpageindicator_p.h
@@ -64,7 +64,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickPageIndicator : public QQuickControl
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
- explicit QQuickPageIndicator(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickPageIndicator(QQuickItem *parent = nullptr);
int count() const;
void setCount(int count);
@@ -85,15 +85,15 @@ Q_SIGNALS:
void delegateChanged();
protected:
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickpane.cpp b/src/templates/qquickpane.cpp
index 9bedb150..e8eeccdb 100644
--- a/src/templates/qquickpane.cpp
+++ b/src/templates/qquickpane.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPane
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-containers
- \brief A pane control.
+ \brief Provides a background matching with the application style and theme.
Pane provides a background color that matches with the application style
and theme. Pane does not provide a layout of its own, but requires you to
@@ -101,10 +101,11 @@ qreal QQuickPane::contentWidth() const
void QQuickPane::setContentWidth(qreal width)
{
Q_D(QQuickPane);
- if (d->contentWidth != width) {
- d->contentWidth = width;
- emit contentWidthChanged();
- }
+ if (qFuzzyCompare(d->contentWidth, width))
+ return;
+
+ d->contentWidth = width;
+ emit contentWidthChanged();
}
/*!
@@ -125,10 +126,11 @@ qreal QQuickPane::contentHeight() const
void QQuickPane::setContentHeight(qreal height)
{
Q_D(QQuickPane);
- if (d->contentHeight != height) {
- d->contentHeight = height;
- emit contentHeightChanged();
- }
+ if (qFuzzyCompare(d->contentHeight, height))
+ return;
+
+ d->contentHeight = height;
+ emit contentHeightChanged();
}
/*!
@@ -142,7 +144,7 @@ void QQuickPane::setContentHeight(qreal height)
QQmlListProperty<QObject> QQuickPane::contentData()
{
Q_D(QQuickPane);
- return QQmlListProperty<QObject>(d->contentItem, Q_NULLPTR,
+ return QQmlListProperty<QObject>(d->contentItem, nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -159,7 +161,7 @@ QQmlListProperty<QObject> QQuickPane::contentData()
QQmlListProperty<QQuickItem> QQuickPane::contentChildren()
{
Q_D(QQuickPane);
- return QQmlListProperty<QQuickItem>(d->contentItem, Q_NULLPTR,
+ return QQmlListProperty<QQuickItem>(d->contentItem, nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
diff --git a/src/templates/qquickpane_p.h b/src/templates/qquickpane_p.h
index e599f55f..51039f32 100644
--- a/src/templates/qquickpane_p.h
+++ b/src/templates/qquickpane_p.h
@@ -65,7 +65,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickPane : public QQuickControl
Q_CLASSINFO("DefaultProperty", "contentData")
public:
- explicit QQuickPane(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickPane(QQuickItem *parent = nullptr);
qreal contentWidth() const;
void setContentWidth(qreal width);
@@ -84,10 +84,10 @@ Q_SIGNALS:
protected:
QQuickPane(QQuickPanePrivate &dd, QQuickItem *parent);
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickpopup.cpp b/src/templates/qquickpopup.cpp
index 36d98813..ff58ab83 100644
--- a/src/templates/qquickpopup.cpp
+++ b/src/templates/qquickpopup.cpp
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPopup
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-popups
- \brief A popup control.
+ \brief The base type of popup-like user interface controls.
Popup is the base type of popup-like user interface controls. It can be
used with Window or ApplicationWindow.
@@ -105,11 +105,14 @@ QQuickPopupPrivate::QQuickPopupPrivate()
: QObjectPrivate()
, focus(false)
, modal(false)
+ , visible(false)
, complete(false)
, hasTopMargin(false)
, hasLeftMargin(false)
, hasRightMargin(false)
, hasBottomMargin(false)
+ , x(0)
+ , y(0)
, margins(0)
, topMargin(0)
, leftMargin(0)
@@ -118,10 +121,10 @@ QQuickPopupPrivate::QQuickPopupPrivate()
, contentWidth(0)
, contentHeight(0)
, closePolicy(QQuickPopup::OnEscape)
- , parentItem(Q_NULLPTR)
- , enter(Q_NULLPTR)
- , exit(Q_NULLPTR)
- , popupItem(Q_NULLPTR)
+ , parentItem(nullptr)
+ , enter(nullptr)
+ , exit(nullptr)
+ , popupItem(nullptr)
, positioner(this)
, transitionManager(this)
{
@@ -158,17 +161,60 @@ bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
return false;
}
+void QQuickPopupPrivate::prepareEnterTransition(bool notify)
+{
+ Q_Q(QQuickPopup);
+ QQuickWindow *quickWindow = q->window();
+ if (!quickWindow) {
+ qmlInfo(q) << "cannot find any window to open popup in.";
+ return;
+ }
+
+ QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(quickWindow);
+ if (!applicationWindow) {
+ quickWindow->installEventFilter(q);
+ popupItem->setZ(10001); // DefaultWindowDecoration+1
+ popupItem->setParentItem(quickWindow->contentItem());
+ } else {
+ popupItem->setParentItem(applicationWindow->overlay());
+ }
+
+ if (notify)
+ emit q->aboutToShow();
+ visible = true;
+ popupItem->setVisible(true);
+ positioner.setParentItem(parentItem);
+ emit q->visibleChanged();
+}
+
+void QQuickPopupPrivate::prepareExitTransition()
+{
+ Q_Q(QQuickPopup);
+ QQuickWindow *quickWindow = q->window();
+ if (quickWindow && !qobject_cast<QQuickApplicationWindow *>(quickWindow))
+ quickWindow->removeEventFilter(q);
+ if (focus)
+ popupItem->setFocus(false);
+ emit q->aboutToHide();
+}
+
void QQuickPopupPrivate::finalizeEnterTransition()
{
if (focus)
popupItem->setFocus(true);
}
-void QQuickPopupPrivate::finalizeExitTransition()
+void QQuickPopupPrivate::finalizeExitTransition(bool hide)
{
- positioner.setParentItem(Q_NULLPTR);
- popupItem->setParentItem(Q_NULLPTR);
- popupItem->setVisible(false);
+ Q_Q(QQuickPopup);
+ positioner.setParentItem(nullptr);
+ if (hide) {
+ popupItem->setParentItem(nullptr);
+ popupItem->setVisible(false);
+ }
+
+ visible = false;
+ emit q->visibleChanged();
}
QMarginsF QQuickPopupPrivate::getMargins() const
@@ -236,8 +282,8 @@ class QQuickPopupItemPrivate : public QQuickControlPrivate
public:
QQuickPopupItemPrivate(QQuickPopup *popup);
- void implicitWidthChanged() Q_DECL_OVERRIDE;
- void implicitHeightChanged() Q_DECL_OVERRIDE;
+ void implicitWidthChanged() override;
+ void implicitHeightChanged() override;
QQuickPopup *popup;
};
@@ -260,7 +306,7 @@ void QQuickPopupItemPrivate::implicitHeightChanged()
}
QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
- QQuickControl(*(new QQuickPopupItemPrivate(popup)), Q_NULLPTR)
+ QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr)
{
setParent(popup);
setVisible(false);
@@ -268,6 +314,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
setAcceptedMouseButtons(Qt::AllButtons);
}
+bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
+{
+ Q_D(QQuickPopupItem);
+ return d->popup->childMouseEventFilter(child, event);
+}
+
void QQuickPopupItem::focusInEvent(QFocusEvent *event)
{
Q_D(QQuickPopupItem);
@@ -347,9 +399,6 @@ void QQuickPopupItem::itemChange(ItemChange change, const ItemChangeData &data)
Q_D(QQuickPopupItem);
QQuickControl::itemChange(change, data);
switch (change) {
- case ItemVisibleHasChanged:
- emit d->popup->visibleChanged();
- break;
case ItemActiveFocusHasChanged:
emit d->popup->activeFocusChanged();
break;
@@ -377,9 +426,7 @@ QAccessible::Role QQuickPopupItem::accessibleRole() const
#endif // QT_NO_ACCESSIBILITY
QQuickPopupPositioner::QQuickPopupPositioner(QQuickPopupPrivate *popup) :
- m_x(0),
- m_y(0),
- m_parentItem(Q_NULLPTR),
+ m_parentItem(nullptr),
m_popup(popup)
{
}
@@ -392,34 +439,6 @@ QQuickPopupPositioner::~QQuickPopupPositioner()
}
}
-qreal QQuickPopupPositioner::x() const
-{
- return m_x;
-}
-
-void QQuickPopupPositioner::setX(qreal x)
-{
- if (m_x != x) {
- m_x = x;
- if (m_popup->popupItem->isVisible())
- repositionPopup();
- }
-}
-
-qreal QQuickPopupPositioner::y() const
-{
- return m_y;
-}
-
-void QQuickPopupPositioner::setY(qreal y)
-{
- if (m_y != y) {
- m_y = y;
- if (m_popup->popupItem->isVisible())
- repositionPopup();
- }
-}
-
QQuickItem *QQuickPopupPositioner::parentItem() const
{
return m_parentItem;
@@ -444,13 +463,13 @@ void QQuickPopupPositioner::setParentItem(QQuickItem *parent)
addAncestorListeners(parent->parentItem());
if (m_popup->popupItem->isVisible())
- repositionPopup();
+ m_popup->reposition();
}
void QQuickPopupPositioner::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
{
if (m_popup->popupItem->isVisible())
- repositionPopup();
+ m_popup->reposition();
}
void QQuickPopupPositioner::itemParentChanged(QQuickItem *, QQuickItem *parent)
@@ -468,29 +487,30 @@ void QQuickPopupPositioner::itemDestroyed(QQuickItem *item)
{
Q_ASSERT(m_parentItem == item);
- m_parentItem = Q_NULLPTR;
+ m_parentItem = nullptr;
QQuickItemPrivate::get(item)->removeItemChangeListener(this, ItemChangeTypes);
removeAncestorListeners(item->parentItem());
}
-void QQuickPopupPositioner::repositionPopup()
+void QQuickPopupPrivate::reposition()
{
- const qreal w = m_popup->popupItem->width();
- const qreal h = m_popup->popupItem->height();
- const qreal iw = m_popup->popupItem->implicitWidth();
- const qreal ih = m_popup->popupItem->implicitHeight();
+ Q_Q(QQuickPopup);
+ const qreal w = popupItem->width();
+ const qreal h = popupItem->height();
+ const qreal iw = popupItem->implicitWidth();
+ const qreal ih = popupItem->implicitHeight();
bool adjusted = false;
- QRectF rect(m_x, m_y, iw > 0 ? iw : w, ih > 0 ? ih : h);
- if (m_parentItem) {
- rect = m_parentItem->mapRectToScene(rect);
+ QRectF rect(x, y, iw > 0 ? iw : w, ih > 0 ? ih : h);
+ if (parentItem) {
+ rect = parentItem->mapRectToScene(rect);
- QQuickWindow *window = m_parentItem->window();
+ QQuickWindow *window = q->window();
if (window) {
- const QRectF bounds = QRectF(0, 0, window->width(), window->height()).marginsRemoved(m_popup->getMargins());
+ const QRectF bounds = QRectF(0, 0, window->width(), window->height()).marginsRemoved(getMargins());
if (rect.top() < bounds.top() || rect.bottom() > bounds.bottom()) {
// if the popup doesn't fit inside the window, try flipping it around (below <-> above)
- const QRectF flipped = m_parentItem->mapRectToScene(QRectF(m_x, m_parentItem->height() - m_y - rect.height(), rect.width(), rect.height()));
+ const QRectF flipped = parentItem->mapRectToScene(QRectF(x, parentItem->height() - y - rect.height(), rect.width(), rect.height()));
if (flipped.top() >= bounds.top() && flipped.bottom() < bounds.bottom()) {
adjusted = true;
rect = flipped;
@@ -513,9 +533,9 @@ void QQuickPopupPositioner::repositionPopup()
}
}
- m_popup->popupItem->setPosition(rect.topLeft());
+ popupItem->setPosition(rect.topLeft());
if (adjusted && ih > 0)
- m_popup->popupItem->setHeight(rect.height());
+ popupItem->setHeight(rect.height());
}
void QQuickPopupPositioner::removeAncestorListeners(QQuickItem *item)
@@ -568,18 +588,20 @@ void QQuickPopupTransitionManager::transitionEnter()
{
if (state == Enter && isRunning())
return;
- QList<QQuickStateAction> actions;
+
state = Enter;
- transition(actions, popup->enter, popup->popupItem);
+ popup->prepareEnterTransition();
+ transition(popup->enterActions, popup->enter, popup->q_func());
}
void QQuickPopupTransitionManager::transitionExit()
{
if (state == Exit && isRunning())
return;
- QList<QQuickStateAction> actions;
+
state = Exit;
- transition(actions, popup->exit, popup->popupItem);
+ popup->prepareExitTransition();
+ transition(popup->exitActions, popup->exit, popup->q_func());
}
void QQuickPopupTransitionManager::finished()
@@ -609,7 +631,7 @@ QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent)
QQuickPopup::~QQuickPopup()
{
Q_D(QQuickPopup);
- d->positioner.setParentItem(Q_NULLPTR);
+ d->positioner.setParentItem(nullptr);
delete d->popupItem;
}
@@ -621,30 +643,11 @@ QQuickPopup::~QQuickPopup()
void QQuickPopup::open()
{
Q_D(QQuickPopup);
- if (d->popupItem->isVisible())
+ if (d->visible)
return;
- QQuickWindow *window = Q_NULLPTR;
- if (d->parentItem)
- window = d->parentItem->window();
- if (!window) {
- qmlInfo(this) << "cannot find any window to open popup in.";
- return;
- }
-
- QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(window);
- if (!applicationWindow) {
- window->installEventFilter(this);
- d->popupItem->setZ(10001); // DefaultWindowDecoration+1
- d->popupItem->setParentItem(window->contentItem());
- } else {
- d->popupItem->setParentItem(applicationWindow->overlay());
- }
-
- emit aboutToShow();
- d->popupItem->setVisible(true);
- d->positioner.setParentItem(d->parentItem);
- d->transitionManager.transitionEnter();
+ if (d->complete)
+ d->transitionManager.transitionEnter();
}
/*!
@@ -655,19 +658,11 @@ void QQuickPopup::open()
void QQuickPopup::close()
{
Q_D(QQuickPopup);
- if (!d->popupItem->isVisible())
+ if (!d->visible)
return;
- if (d->parentItem) {
- QQuickWindow *window = d->parentItem->window();
- if (!qobject_cast<QQuickApplicationWindow *>(window)) {
- window->removeEventFilter(this);
- }
- }
-
- d->popupItem->setFocus(false);
- emit aboutToHide();
- d->transitionManager.transitionExit();
+ if (d->complete)
+ d->transitionManager.transitionExit();
}
/*!
@@ -678,13 +673,19 @@ void QQuickPopup::close()
qreal QQuickPopup::x() const
{
Q_D(const QQuickPopup);
- return d->positioner.x();
+ return d->x;
}
void QQuickPopup::setX(qreal x)
{
Q_D(QQuickPopup);
- d->positioner.setX(x);
+ if (qFuzzyCompare(d->x, x))
+ return;
+
+ d->x = x;
+ if (d->popupItem->isVisible())
+ d->reposition();
+ emit xChanged();
}
/*!
@@ -695,13 +696,19 @@ void QQuickPopup::setX(qreal x)
qreal QQuickPopup::y() const
{
Q_D(const QQuickPopup);
- return d->positioner.y();
+ return d->y;
}
void QQuickPopup::setY(qreal y)
{
Q_D(QQuickPopup);
- d->positioner.setY(y);
+ if (qFuzzyCompare(d->y, y))
+ return;
+
+ d->y = y;
+ if (d->popupItem->isVisible())
+ d->reposition();
+ emit yChanged();
}
/*!
@@ -823,10 +830,11 @@ qreal QQuickPopup::contentWidth() const
void QQuickPopup::setContentWidth(qreal width)
{
Q_D(QQuickPopup);
- if (d->contentWidth != width) {
- d->contentWidth = width;
- emit contentWidthChanged();
- }
+ if (qFuzzyCompare(d->contentWidth, width))
+ return;
+
+ d->contentWidth = width;
+ emit contentWidthChanged();
}
/*!
@@ -847,10 +855,11 @@ qreal QQuickPopup::contentHeight() const
void QQuickPopup::setContentHeight(qreal height)
{
Q_D(QQuickPopup);
- if (d->contentHeight != height) {
- d->contentHeight = height;
- emit contentHeightChanged();
- }
+ if (qFuzzyCompare(d->contentHeight, height))
+ return;
+
+ d->contentHeight = height;
+ emit contentHeightChanged();
}
/*!
@@ -1152,6 +1161,15 @@ void QQuickPopup::resetBottomPadding()
d->popupItem->resetBottomPadding();
}
+QQuickWindow *QQuickPopup::window() const
+{
+ Q_D(const QQuickPopup);
+ if (!d->parentItem)
+ return nullptr;
+
+ return d->parentItem->window();
+}
+
QQuickItem *QQuickPopup::popupItem() const
{
Q_D(const QQuickPopup);
@@ -1172,16 +1190,17 @@ QQuickItem *QQuickPopup::parentItem() const
void QQuickPopup::setParentItem(QQuickItem *parent)
{
Q_D(QQuickPopup);
- if (d->parentItem != parent) {
- d->parentItem = parent;
- if (d->positioner.parentItem())
- d->positioner.setParentItem(parent);
- if (parent) {
- QQuickControlPrivate::updateFontRecur(d->popupItem, QQuickControlPrivate::naturalControlFont(parent));
- QQuickControlPrivate::updateLocaleRecur(d->popupItem, QQuickControlPrivate::calcLocale(parent));
- }
- emit parentChanged();
+ if (d->parentItem == parent)
+ return;
+
+ d->parentItem = parent;
+ if (d->positioner.parentItem())
+ d->positioner.setParentItem(parent);
+ if (parent) {
+ QQuickControlPrivate::updateFontRecur(d->popupItem, QQuickControlPrivate::naturalControlFont(parent));
+ QQuickControlPrivate::updateLocaleRecur(d->popupItem, QQuickControlPrivate::calcLocale(parent));
}
+ emit parentChanged();
}
/*!
@@ -1242,7 +1261,7 @@ void QQuickPopup::setContentItem(QQuickItem *item)
QQmlListProperty<QObject> QQuickPopup::contentData()
{
Q_D(QQuickPopup);
- return QQmlListProperty<QObject>(d->popupItem->contentItem(), Q_NULLPTR,
+ return QQmlListProperty<QObject>(d->popupItem->contentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -1259,7 +1278,7 @@ QQmlListProperty<QObject> QQuickPopup::contentData()
QQmlListProperty<QQuickItem> QQuickPopup::contentChildren()
{
Q_D(QQuickPopup);
- return QQmlListProperty<QQuickItem>(d->popupItem->contentItem(), Q_NULLPTR,
+ return QQmlListProperty<QQuickItem>(d->popupItem->contentItem(), nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
@@ -1346,7 +1365,7 @@ void QQuickPopup::setModal(bool modal)
bool QQuickPopup::isVisible() const
{
Q_D(const QQuickPopup);
- return d->popupItem->isVisible();
+ return d->visible && d->popupItem->isVisible();
}
void QQuickPopup::setVisible(bool visible)
@@ -1492,18 +1511,16 @@ void QQuickPopup::setExit(QQuickTransition *transition)
emit exitChanged();
}
-/*!
- \qmlproperty list<Object> Qt.labs.controls::Popup::data
- \default
-
- This property holds the list of data.
+bool QQuickPopup::filtersChildMouseEvents() const
+{
+ Q_D(const QQuickPopup);
+ return d->popupItem->filtersChildMouseEvents();
+}
- \sa Item::data
-*/
-QQmlListProperty<QObject> QQuickPopup::data()
+void QQuickPopup::setFiltersChildMouseEvents(bool filter)
{
Q_D(QQuickPopup);
- return QQuickItemPrivate::get(d->popupItem)->data();
+ d->popupItem->setFiltersChildMouseEvents(filter);
}
void QQuickPopup::classBegin()
@@ -1516,6 +1533,8 @@ void QQuickPopup::componentComplete()
d->complete = true;
if (!parentItem())
setParentItem(qobject_cast<QQuickItem *>(parent()));
+ if (d->visible)
+ d->transitionManager.transitionEnter();
}
bool QQuickPopup::isComponentComplete() const
@@ -1526,28 +1545,16 @@ bool QQuickPopup::isComponentComplete() const
bool QQuickPopup::eventFilter(QObject *object, QEvent *event)
{
- Q_D(QQuickPopup);
- Q_UNUSED(object);
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- if (d->modal)
- event->setAccepted(true);
- if (QQuickWindow *window = qobject_cast<QQuickWindow *>(object)) {
- if (d->tryClose(window->contentItem(), static_cast<QMouseEvent *>(event)))
- return true;
- }
- return false;
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::MouseMove:
- case QEvent::Wheel:
- if (d->modal)
- event->setAccepted(true);
- return false;
- default:
- return false;
- }
+ if (QQuickWindow *window = qobject_cast<QQuickWindow *>(object))
+ return overlayEvent(window->contentItem(), event);
+ return false;
+}
+
+bool QQuickPopup::childMouseEventFilter(QQuickItem *child, QEvent *event)
+{
+ Q_UNUSED(child);
+ Q_UNUSED(event);
+ return false;
}
void QQuickPopup::focusInEvent(QFocusEvent *event)
@@ -1601,6 +1608,30 @@ void QQuickPopup::mouseUngrabEvent()
{
}
+bool QQuickPopup::overlayEvent(QQuickItem *item, QEvent *event)
+{
+ Q_D(QQuickPopup);
+ switch (event->type()) {
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::MouseMove:
+ case QEvent::Wheel:
+ if (d->modal)
+ event->accept();
+ return d->modal;
+
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ if (d->modal)
+ event->accept();
+ d->tryClose(item, static_cast<QMouseEvent *>(event));
+ return d->modal;
+
+ default:
+ return false;
+ }
+}
+
void QQuickPopup::wheelEvent(QWheelEvent *event)
{
event->accept();
@@ -1616,7 +1647,7 @@ void QQuickPopup::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
void QQuickPopup::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
Q_D(QQuickPopup);
- d->positioner.repositionPopup();
+ d->reposition();
if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) {
emit widthChanged();
emit availableWidthChanged();
@@ -1632,7 +1663,7 @@ void QQuickPopup::marginsChange(const QMarginsF &newMargins, const QMarginsF &ol
Q_D(QQuickPopup);
Q_UNUSED(newMargins);
Q_UNUSED(oldMargins);
- d->positioner.repositionPopup();
+ d->reposition();
}
void QQuickPopup::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding)
diff --git a/src/templates/qquickpopup_p.h b/src/templates/qquickpopup_p.h
index b818ea7f..fa394638 100644
--- a/src/templates/qquickpopup_p.h
+++ b/src/templates/qquickpopup_p.h
@@ -63,6 +63,7 @@
QT_BEGIN_NAMESPACE
class QQuickItem;
+class QQuickWindow;
class QQuickPopupPrivate;
class QQuickTransition;
class QQuickTransform;
@@ -111,7 +112,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickPopup : public QObject, public QQmlParserStat
Q_CLASSINFO("DefaultProperty", "contentData")
public:
- explicit QQuickPopup(QObject *parent = Q_NULLPTR);
+ explicit QQuickPopup(QObject *parent = nullptr);
~QQuickPopup();
qreal x() const;
@@ -186,6 +187,7 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
+ QQuickWindow *window() const;
QQuickItem *popupItem() const;
QQuickItem *parentItem() const;
@@ -251,7 +253,8 @@ public:
QQuickTransition *exit() const;
void setExit(QQuickTransition *transition);
- QQmlListProperty<QObject> data();
+ bool filtersChildMouseEvents() const;
+ void setFiltersChildMouseEvents(bool filter);
public Q_SLOTS:
void open();
@@ -300,11 +303,12 @@ Q_SIGNALS:
protected:
QQuickPopup(QQuickPopupPrivate &dd, QObject *parent);
- void classBegin() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void classBegin() override;
+ void componentComplete() override;
bool isComponentComplete() const;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *object, QEvent *event) override;
+ virtual bool childMouseEventFilter(QQuickItem *child, QEvent *event);
virtual void focusInEvent(QFocusEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
@@ -314,6 +318,7 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mouseUngrabEvent();
+ virtual bool overlayEvent(QQuickItem *item, QEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem);
@@ -329,6 +334,7 @@ private:
Q_DISABLE_COPY(QQuickPopup)
Q_DECLARE_PRIVATE(QQuickPopup)
friend class QQuickPopupItem;
+ friend class QQuickOverlay;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPopup::ClosePolicy)
diff --git a/src/templates/qquickpopup_p_p.h b/src/templates/qquickpopup_p_p.h
index 017949cd..efb95bff 100644
--- a/src/templates/qquickpopup_p_p.h
+++ b/src/templates/qquickpopup_p_p.h
@@ -73,7 +73,7 @@ public:
void transitionExit();
protected:
- void finished() Q_DECL_OVERRIDE;
+ void finished() override;
private:
enum TransitionState {
@@ -92,24 +92,25 @@ public:
explicit QQuickPopupItem(QQuickPopup *popup);
protected:
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
-
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE;
- void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) Q_DECL_OVERRIDE;
+ bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void wheelEvent(QWheelEvent *event) override;
+
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
+ void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
@@ -122,17 +123,9 @@ public:
explicit QQuickPopupPositioner(QQuickPopupPrivate *popup);
~QQuickPopupPositioner();
- qreal x() const;
- void setX(qreal x);
-
- qreal y() const;
- void setY(qreal y);
-
QQuickItem *parentItem() const;
void setParentItem(QQuickItem *parent);
- void repositionPopup();
-
protected:
void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
void itemParentChanged(QQuickItem *, QQuickItem *parent);
@@ -145,8 +138,6 @@ private:
bool isAncestor(QQuickItem *item) const;
- qreal m_x;
- qreal m_y;
QQuickItem *m_parentItem;
QQuickPopupPrivate *m_popup;
};
@@ -165,9 +156,12 @@ public:
void init();
bool tryClose(QQuickItem *item, QMouseEvent *event);
+ virtual void reposition();
- void finalizeEnterTransition();
- void finalizeExitTransition();
+ virtual void prepareEnterTransition(bool notify = true);
+ virtual void prepareExitTransition();
+ virtual void finalizeEnterTransition();
+ virtual void finalizeExitTransition(bool hide = true);
QMarginsF getMargins() const;
@@ -178,11 +172,14 @@ public:
bool focus;
bool modal;
+ bool visible;
bool complete;
bool hasTopMargin;
bool hasLeftMargin;
bool hasRightMargin;
bool hasBottomMargin;
+ qreal x;
+ qreal y;
qreal margins;
qreal topMargin;
qreal leftMargin;
@@ -196,7 +193,11 @@ public:
QQuickTransition *exit;
QQuickPopupItem *popupItem;
QQuickPopupPositioner positioner;
+ QList<QQuickStateAction> enterActions;
+ QList<QQuickStateAction> exitActions;
QQuickPopupTransitionManager transitionManager;
+
+ friend class QQuickPopupTransitionManager;
};
QT_END_NAMESPACE
diff --git a/src/templates/qquickpressandholdhelper.cpp b/src/templates/qquickpressandholdhelper.cpp
index 29b3bb0a..6f3ddcbc 100644
--- a/src/templates/qquickpressandholdhelper.cpp
+++ b/src/templates/qquickpressandholdhelper.cpp
@@ -45,10 +45,10 @@
QT_BEGIN_NAMESPACE
QQuickPressAndHoldHelper::QQuickPressAndHoldHelper()
- : control(Q_NULLPTR)
+ : control(nullptr)
, longPress(false)
, pressAndHoldSignalIndex(-1)
- , delayedMousePressEvent(Q_NULLPTR)
+ , delayedMousePressEvent(nullptr)
{ }
void QQuickPressAndHoldHelper::mousePressEvent(QMouseEvent *event)
@@ -91,7 +91,7 @@ void QQuickPressAndHoldHelper::timerEvent(QTimerEvent *)
mev.setAccepted(true);
// Use fast signal invocation since we already got its index
QQuickMouseEvent *mevPtr = &mev;
- void *args[] = { Q_NULLPTR, &mevPtr };
+ void *args[] = { nullptr, &mevPtr };
QMetaObject::metacall(control, QMetaObject::InvokeMetaMethod, pressAndHoldSignalIndex, args);
if (!mev.isAccepted())
longPress = false;
diff --git a/src/templates/qquickprogressbar.cpp b/src/templates/qquickprogressbar.cpp
index 972654ad..8596128f 100644
--- a/src/templates/qquickprogressbar.cpp
+++ b/src/templates/qquickprogressbar.cpp
@@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickProgressBar
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-indicators
- \brief A progress bar control.
+ \brief Indicates the progress of an operation.
ProgressBar indicates the progress of an operation.
@@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE
class QQuickProgressBarPrivate : public QQuickControlPrivate
{
public:
- QQuickProgressBarPrivate() : from(0), to(1.0), value(0), indeterminate(false), indicator(Q_NULLPTR)
+ QQuickProgressBarPrivate() : from(0), to(1.0), value(0), indeterminate(false), indicator(nullptr)
{
}
@@ -102,14 +102,15 @@ qreal QQuickProgressBar::from() const
void QQuickProgressBar::setFrom(qreal from)
{
Q_D(QQuickProgressBar);
- if (!qFuzzyCompare(d->from, from)) {
- d->from = from;
- emit fromChanged();
- emit positionChanged();
- emit visualPositionChanged();
- if (isComponentComplete())
- setValue(d->value);
- }
+ if (qFuzzyCompare(d->from, from))
+ return;
+
+ d->from = from;
+ emit fromChanged();
+ emit positionChanged();
+ emit visualPositionChanged();
+ if (isComponentComplete())
+ setValue(d->value);
}
/*!
@@ -128,14 +129,15 @@ qreal QQuickProgressBar::to() const
void QQuickProgressBar::setTo(qreal to)
{
Q_D(QQuickProgressBar);
- if (!qFuzzyCompare(d->to, to)) {
- d->to = to;
- emit toChanged();
- emit positionChanged();
- emit visualPositionChanged();
- if (isComponentComplete())
- setValue(d->value);
- }
+ if (qFuzzyCompare(d->to, to))
+ return;
+
+ d->to = to;
+ emit toChanged();
+ emit positionChanged();
+ emit visualPositionChanged();
+ if (isComponentComplete())
+ setValue(d->value);
}
/*!
@@ -157,12 +159,13 @@ void QQuickProgressBar::setValue(qreal value)
if (isComponentComplete())
value = d->from > d->to ? qBound(d->to, value, d->from) : qBound(d->from, value, d->to);
- if (!qFuzzyCompare(d->value, value)) {
- d->value = value;
- emit valueChanged();
- emit positionChanged();
- emit visualPositionChanged();
- }
+ if (qFuzzyCompare(d->value, value))
+ return;
+
+ d->value = value;
+ emit valueChanged();
+ emit positionChanged();
+ emit visualPositionChanged();
}
/*!
@@ -219,10 +222,11 @@ bool QQuickProgressBar::isIndeterminate() const
void QQuickProgressBar::setIndeterminate(bool indeterminate)
{
Q_D(QQuickProgressBar);
- if (d->indeterminate != indeterminate) {
- d->indeterminate = indeterminate;
- emit indeterminateChanged();
- }
+ if (d->indeterminate == indeterminate)
+ return;
+
+ d->indeterminate = indeterminate;
+ emit indeterminateChanged();
}
/*!
@@ -241,13 +245,14 @@ QQuickItem *QQuickProgressBar::indicator() const
void QQuickProgressBar::setIndicator(QQuickItem *indicator)
{
Q_D(QQuickProgressBar);
- if (d->indicator != indicator) {
- delete d->indicator;
- d->indicator = indicator;
- if (indicator && !indicator->parentItem())
- indicator->setParentItem(this);
- emit indicatorChanged();
- }
+ if (d->indicator == indicator)
+ return;
+
+ delete d->indicator;
+ d->indicator = indicator;
+ if (indicator && !indicator->parentItem())
+ indicator->setParentItem(this);
+ emit indicatorChanged();
}
void QQuickProgressBar::mirrorChange()
diff --git a/src/templates/qquickprogressbar_p.h b/src/templates/qquickprogressbar_p.h
index f94c718e..1bf21b41 100644
--- a/src/templates/qquickprogressbar_p.h
+++ b/src/templates/qquickprogressbar_p.h
@@ -66,7 +66,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickProgressBar : public QQuickControl
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
public:
- explicit QQuickProgressBar(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickProgressBar(QQuickItem *parent = nullptr);
qreal from() const;
void setFrom(qreal from);
@@ -96,11 +96,11 @@ Q_SIGNALS:
void indicatorChanged();
protected:
- void mirrorChange() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void mirrorChange() override;
+ void componentComplete() override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickradiobutton.cpp b/src/templates/qquickradiobutton.cpp
index 7d7a64aa..e14427f9 100644
--- a/src/templates/qquickradiobutton.cpp
+++ b/src/templates/qquickradiobutton.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickRadioButton
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A radio button control.
+ \brief An option button that can be toggled on or off.
RadioButton presents an option button that can be toggled on (checked) or
off (unchecked). Radio buttons are typically used to select one option
diff --git a/src/templates/qquickradiobutton_p.h b/src/templates/qquickradiobutton_p.h
index 7d664864..2b9821aa 100644
--- a/src/templates/qquickradiobutton_p.h
+++ b/src/templates/qquickradiobutton_p.h
@@ -57,13 +57,13 @@ class Q_LABSTEMPLATES_EXPORT QQuickRadioButton : public QQuickAbstractButton
Q_OBJECT
public:
- explicit QQuickRadioButton(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickRadioButton(QQuickItem *parent = nullptr);
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
};
diff --git a/src/templates/qquickrangeslider.cpp b/src/templates/qquickrangeslider.cpp
index 69529f65..6dcd7fcb 100644
--- a/src/templates/qquickrangeslider.cpp
+++ b/src/templates/qquickrangeslider.cpp
@@ -87,7 +87,7 @@ public:
isPendingValue(false),
pendingValue(0),
position(0),
- handle(Q_NULLPTR),
+ handle(nullptr),
slider(slider),
pressed(false)
{
@@ -224,35 +224,36 @@ QQuickItem *QQuickRangeSliderNode::handle() const
void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
{
Q_D(QQuickRangeSliderNode);
- if (d->handle != handle) {
- delete d->handle;
- d->handle = handle;
- if (handle) {
- if (!handle->parentItem())
- handle->setParentItem(d->slider);
-
- QQuickItem *firstHandle = d->slider->first()->handle();
- QQuickItem *secondHandle = d->slider->second()->handle();
- if (firstHandle && secondHandle) {
- // The order of property assignments in QML is undefined,
- // but we need the first handle to be before the second due
- // to focus order constraints, so check for that here.
- const QList<QQuickItem *> childItems = d->slider->childItems();
- const int firstIndex = childItems.indexOf(firstHandle);
- const int secondIndex = childItems.indexOf(secondHandle);
- if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
- firstHandle->stackBefore(secondHandle);
- // Ensure we have some way of knowing which handle is above
- // the other when it comes to mouse presses, and also that
- // they are rendered in the correct order.
- secondHandle->setZ(secondHandle->z() + 1);
- }
- }
+ if (d->handle == handle)
+ return;
- handle->setActiveFocusOnTab(true);
+ delete d->handle;
+ d->handle = handle;
+ if (handle) {
+ if (!handle->parentItem())
+ handle->setParentItem(d->slider);
+
+ QQuickItem *firstHandle = d->slider->first()->handle();
+ QQuickItem *secondHandle = d->slider->second()->handle();
+ if (firstHandle && secondHandle) {
+ // The order of property assignments in QML is undefined,
+ // but we need the first handle to be before the second due
+ // to focus order constraints, so check for that here.
+ const QList<QQuickItem *> childItems = d->slider->childItems();
+ const int firstIndex = childItems.indexOf(firstHandle);
+ const int secondIndex = childItems.indexOf(secondHandle);
+ if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
+ firstHandle->stackBefore(secondHandle);
+ // Ensure we have some way of knowing which handle is above
+ // the other when it comes to mouse presses, and also that
+ // they are rendered in the correct order.
+ secondHandle->setZ(secondHandle->z() + 1);
+ }
}
- emit handleChanged();
+
+ handle->setActiveFocusOnTab(true);
}
+ emit handleChanged();
}
bool QQuickRangeSliderNode::isPressed() const
@@ -264,11 +265,12 @@ bool QQuickRangeSliderNode::isPressed() const
void QQuickRangeSliderNode::setPressed(bool pressed)
{
Q_D(QQuickRangeSliderNode);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- d->slider->setAccessibleProperty("pressed", pressed || d->slider->second()->isPressed());
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ d->slider->setAccessibleProperty("pressed", pressed || d->slider->second()->isPressed());
+ emit pressedChanged();
}
void QQuickRangeSliderNode::increase()
@@ -297,11 +299,11 @@ public:
from(defaultFrom),
to(defaultTo),
stepSize(0),
- first(Q_NULLPTR),
- second(Q_NULLPTR),
+ first(nullptr),
+ second(nullptr),
orientation(Qt::Horizontal),
snapMode(QQuickRangeSlider::NoSnap),
- track(Q_NULLPTR)
+ track(nullptr)
{
}
@@ -552,10 +554,11 @@ qreal QQuickRangeSlider::stepSize() const
void QQuickRangeSlider::setStepSize(qreal step)
{
Q_D(QQuickRangeSlider);
- if (!qFuzzyCompare(d->stepSize, step)) {
- d->stepSize = step;
- emit stepSizeChanged();
- }
+ if (qFuzzyCompare(d->stepSize, step))
+ return;
+
+ d->stepSize = step;
+ emit stepSizeChanged();
}
/*!
@@ -579,10 +582,11 @@ QQuickRangeSlider::SnapMode QQuickRangeSlider::snapMode() const
void QQuickRangeSlider::setSnapMode(SnapMode mode)
{
Q_D(QQuickRangeSlider);
- if (d->snapMode != mode) {
- d->snapMode = mode;
- emit snapModeChanged();
- }
+ if (d->snapMode == mode)
+ return;
+
+ d->snapMode = mode;
+ emit snapModeChanged();
}
/*!
@@ -603,10 +607,11 @@ Qt::Orientation QQuickRangeSlider::orientation() const
void QQuickRangeSlider::setOrientation(Qt::Orientation orientation)
{
Q_D(QQuickRangeSlider);
- if (d->orientation != orientation) {
- d->orientation = orientation;
- emit orientationChanged();
- }
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged();
}
/*!
@@ -625,13 +630,14 @@ QQuickItem *QQuickRangeSlider::track() const
void QQuickRangeSlider::setTrack(QQuickItem *track)
{
Q_D(QQuickRangeSlider);
- if (d->track != track) {
- delete d->track;
- d->track = track;
- if (track && !track->parentItem())
- track->setParentItem(this);
- emit trackChanged();
- }
+ if (d->track == track)
+ return;
+
+ delete d->track;
+ d->track = track;
+ if (track && !track->parentItem())
+ track->setParentItem(this);
+ emit trackChanged();
}
/*!
@@ -715,7 +721,7 @@ void QQuickRangeSlider::keyPressEvent(QKeyEvent *event)
QQuickControl::keyPressEvent(event);
QQuickRangeSliderNode *focusNode = d->first->handle()->hasActiveFocus()
- ? d->first : (d->second->handle()->hasActiveFocus() ? d->second : Q_NULLPTR);
+ ? d->first : (d->second->handle()->hasActiveFocus() ? d->second : nullptr);
if (!focusNode)
return;
@@ -766,8 +772,8 @@ void QQuickRangeSlider::mousePressEvent(QMouseEvent *event)
QQuickItem *secondHandle = d->second->handle();
const bool firstHit = firstHandle && firstHandle->contains(mapToItem(firstHandle, d->pressPoint));
const bool secondHit = secondHandle && secondHandle->contains(mapToItem(secondHandle, d->pressPoint));
- QQuickRangeSliderNode *hitNode = Q_NULLPTR;
- QQuickRangeSliderNode *otherNode = Q_NULLPTR;
+ QQuickRangeSliderNode *hitNode = nullptr;
+ QQuickRangeSliderNode *otherNode = nullptr;
if (firstHit && secondHit) {
// choose highest
@@ -825,7 +831,7 @@ void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event)
setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->pos().y() - d->pressPoint.y(), Qt::YAxis, event));
}
if (keepMouseGrab()) {
- QQuickRangeSliderNode *pressedNode = d->first->isPressed() ? d->first : (d->second->isPressed() ? d->second : Q_NULLPTR);
+ QQuickRangeSliderNode *pressedNode = d->first->isPressed() ? d->first : (d->second->isPressed() ? d->second : nullptr);
if (pressedNode) {
qreal pos = positionAt(this, pressedNode->handle(), event->pos());
if (d->snapMode == SnapAlways)
@@ -844,7 +850,7 @@ void QQuickRangeSlider::mouseReleaseEvent(QMouseEvent *event)
if (!keepMouseGrab())
return;
- QQuickRangeSliderNode *pressedNode = d->first->isPressed() ? d->first : (d->second->isPressed() ? d->second : Q_NULLPTR);
+ QQuickRangeSliderNode *pressedNode = d->first->isPressed() ? d->first : (d->second->isPressed() ? d->second : nullptr);
if (!pressedNode)
return;
diff --git a/src/templates/qquickrangeslider_p.h b/src/templates/qquickrangeslider_p.h
index 4cf6ffd6..d81ab98a 100644
--- a/src/templates/qquickrangeslider_p.h
+++ b/src/templates/qquickrangeslider_p.h
@@ -68,7 +68,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickRangeSlider : public QQuickControl
Q_PROPERTY(QQuickItem *track READ track WRITE setTrack NOTIFY trackChanged FINAL)
public:
- explicit QQuickRangeSlider(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickRangeSlider(QQuickItem *parent = nullptr);
qreal from() const;
void setFrom(qreal from);
@@ -109,18 +109,18 @@ Q_SIGNALS:
void trackChanged();
protected:
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void mirrorChange() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void mirrorChange() override;
+ void componentComplete() override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickscrollbar.cpp b/src/templates/qquickscrollbar.cpp
index 86d4e290..a99a409e 100644
--- a/src/templates/qquickscrollbar.cpp
+++ b/src/templates/qquickscrollbar.cpp
@@ -83,7 +83,7 @@ class QQuickScrollBarPrivate : public QQuickControlPrivate
public:
QQuickScrollBarPrivate() : size(0), position(0), offset(0),
active(false), pressed(false), moving(false),
- orientation(Qt::Vertical), handle(Q_NULLPTR)
+ orientation(Qt::Vertical), handle(nullptr)
{
}
@@ -116,7 +116,7 @@ QQuickScrollBarAttached *QQuickScrollBar::qmlAttachedProperties(QObject *object)
return new QQuickScrollBarAttached(flickable);
qWarning() << "ScrollBar must be attached to a Flickable" << object;
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -135,10 +135,11 @@ qreal QQuickScrollBar::size() const
void QQuickScrollBar::setSize(qreal size)
{
Q_D(QQuickScrollBar);
- if (!qFuzzyCompare(d->size, size)) {
- d->size = size;
- emit sizeChanged();
- }
+ if (qFuzzyCompare(d->size, size))
+ return;
+
+ d->size = size;
+ emit sizeChanged();
}
/*!
@@ -157,10 +158,11 @@ qreal QQuickScrollBar::position() const
void QQuickScrollBar::setPosition(qreal position)
{
Q_D(QQuickScrollBar);
- if (!qFuzzyCompare(d->position, position)) {
- d->position = position;
- emit positionChanged();
- }
+ if (qFuzzyCompare(d->position, position))
+ return;
+
+ d->position = position;
+ emit positionChanged();
}
/*!
@@ -178,10 +180,11 @@ bool QQuickScrollBar::isActive() const
void QQuickScrollBar::setActive(bool active)
{
Q_D(QQuickScrollBar);
- if (d->active != active) {
- d->active = active;
- emit activeChanged();
- }
+ if (d->active == active)
+ return;
+
+ d->active = active;
+ emit activeChanged();
}
/*!
@@ -198,12 +201,13 @@ bool QQuickScrollBar::isPressed() const
void QQuickScrollBar::setPressed(bool pressed)
{
Q_D(QQuickScrollBar);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- setAccessibleProperty("pressed", pressed);
- setActive(d->pressed || d->moving);
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ setAccessibleProperty("pressed", pressed);
+ setActive(d->pressed || d->moving);
+ emit pressedChanged();
}
/*!
@@ -224,10 +228,11 @@ Qt::Orientation QQuickScrollBar::orientation() const
void QQuickScrollBar::setOrientation(Qt::Orientation orientation)
{
Q_D(QQuickScrollBar);
- if (d->orientation != orientation) {
- d->orientation = orientation;
- emit orientationChanged();
- }
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged();
}
/*!
@@ -246,13 +251,14 @@ QQuickItem *QQuickScrollBar::handle() const
void QQuickScrollBar::setHandle(QQuickItem *handle)
{
Q_D(QQuickScrollBar);
- if (d->handle != handle) {
- delete d->handle;
- d->handle = handle;
- if (handle && !handle->parentItem())
- handle->setParentItem(this);
- emit handleChanged();
- }
+ if (d->handle == handle)
+ return;
+
+ delete d->handle;
+ d->handle = handle;
+ if (handle && !handle->parentItem())
+ handle->setParentItem(this);
+ emit handleChanged();
}
void QQuickScrollBar::mousePressEvent(QMouseEvent *event)
@@ -309,7 +315,7 @@ QAccessible::Role QQuickScrollBar::accessibleRole() const
class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
public:
- QQuickScrollBarAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { }
+ QQuickScrollBarAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(nullptr), vertical(nullptr) { }
void activateHorizontal();
void activateVertical();
@@ -319,7 +325,7 @@ public:
void layoutHorizontal(bool move = true);
void layoutVertical(bool move = true);
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
QQuickFlickable *flickable;
QQuickScrollBar *horizontal;
@@ -436,40 +442,41 @@ QQuickScrollBar *QQuickScrollBarAttached::horizontal() const
void QQuickScrollBarAttached::setHorizontal(QQuickScrollBar *horizontal)
{
Q_D(QQuickScrollBarAttached);
- if (d->horizontal != horizontal) {
- if (d->horizontal) {
- QQuickItemPrivate::get(d->horizontal)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- QObjectPrivate::disconnect(d->horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal);
- QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal)));
- disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal)));
- }
-
- d->horizontal = horizontal;
-
- if (horizontal) {
- if (!horizontal->parentItem())
- horizontal->setParentItem(d->flickable);
- horizontal->setOrientation(Qt::Horizontal);
-
- QQuickItemPrivate::get(horizontal)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- QObjectPrivate::connect(horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal);
- QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal)));
- connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal)));
-
- d->layoutHorizontal();
- horizontal->setSize(area->property("widthRatio").toReal());
- horizontal->setPosition(area->property("xPosition").toReal());
- }
- emit horizontalChanged();
+ if (d->horizontal == horizontal)
+ return;
+
+ if (d->horizontal) {
+ QQuickItemPrivate::get(d->horizontal)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ QObjectPrivate::disconnect(d->horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal);
+ QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal)));
+ disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal)));
}
+
+ d->horizontal = horizontal;
+
+ if (horizontal) {
+ if (!horizontal->parentItem())
+ horizontal->setParentItem(d->flickable);
+ horizontal->setOrientation(Qt::Horizontal);
+
+ QQuickItemPrivate::get(horizontal)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ QObjectPrivate::connect(horizontal, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollHorizontal);
+ QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollBarAttachedPrivate::activateHorizontal);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal)));
+ connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal)));
+
+ d->layoutHorizontal();
+ horizontal->setSize(area->property("widthRatio").toReal());
+ horizontal->setPosition(area->property("xPosition").toReal());
+ }
+ emit horizontalChanged();
}
/*!
@@ -493,40 +500,41 @@ QQuickScrollBar *QQuickScrollBarAttached::vertical() const
void QQuickScrollBarAttached::setVertical(QQuickScrollBar *vertical)
{
Q_D(QQuickScrollBarAttached);
- if (d->vertical != vertical) {
- if (d->vertical) {
- QQuickItemPrivate::get(d->vertical)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- QObjectPrivate::disconnect(d->vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical);
- QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal)));
- disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal)));
- }
-
- d->vertical = vertical;
-
- if (vertical) {
- if (!vertical->parentItem())
- vertical->setParentItem(d->flickable);
- vertical->setOrientation(Qt::Vertical);
-
- QQuickItemPrivate::get(vertical)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- QObjectPrivate::connect(vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical);
- QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal)));
- connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal)));
-
- d->layoutVertical();
- vertical->setSize(area->property("heightRatio").toReal());
- vertical->setPosition(area->property("yPosition").toReal());
- }
- emit verticalChanged();
+ if (d->vertical == vertical)
+ return;
+
+ if (d->vertical) {
+ QQuickItemPrivate::get(d->vertical)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ QObjectPrivate::disconnect(d->vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical);
+ QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal)));
+ disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal)));
+ }
+
+ d->vertical = vertical;
+
+ if (vertical) {
+ if (!vertical->parentItem())
+ vertical->setParentItem(d->flickable);
+ vertical->setOrientation(Qt::Vertical);
+
+ QQuickItemPrivate::get(vertical)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ QObjectPrivate::connect(vertical, &QQuickScrollBar::positionChanged, d, &QQuickScrollBarAttachedPrivate::scrollVertical);
+ QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollBarAttachedPrivate::activateVertical);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal)));
+ connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal)));
+
+ d->layoutVertical();
+ vertical->setSize(area->property("heightRatio").toReal());
+ vertical->setPosition(area->property("yPosition").toReal());
}
+ emit verticalChanged();
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickscrollbar_p.h b/src/templates/qquickscrollbar_p.h
index b944f92a..6eb8b798 100644
--- a/src/templates/qquickscrollbar_p.h
+++ b/src/templates/qquickscrollbar_p.h
@@ -67,7 +67,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickScrollBar : public QQuickControl
Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
public:
- explicit QQuickScrollBar(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickScrollBar(QQuickItem *parent = nullptr);
static QQuickScrollBarAttached *qmlAttachedProperties(QObject *object);
@@ -99,15 +99,15 @@ Q_SIGNALS:
void handleChanged();
protected:
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
virtual qreal positionAt(const QPoint &point) const;
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickscrollindicator.cpp b/src/templates/qquickscrollindicator.cpp
index 4dc04141..2aba3c89 100644
--- a/src/templates/qquickscrollindicator.cpp
+++ b/src/templates/qquickscrollindicator.cpp
@@ -82,7 +82,7 @@ class QQuickScrollIndicatorPrivate : public QQuickControlPrivate
{
public:
QQuickScrollIndicatorPrivate() : size(0), position(0),
- active(false), orientation(Qt::Vertical), indicator(Q_NULLPTR)
+ active(false), orientation(Qt::Vertical), indicator(nullptr)
{
}
@@ -105,7 +105,7 @@ QQuickScrollIndicatorAttached *QQuickScrollIndicator::qmlAttachedProperties(QObj
return new QQuickScrollIndicatorAttached(flickable);
qWarning() << "ScrollIndicator must be attached to a Flickable" << object;
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -124,10 +124,11 @@ qreal QQuickScrollIndicator::size() const
void QQuickScrollIndicator::setSize(qreal size)
{
Q_D(QQuickScrollIndicator);
- if (!qFuzzyCompare(d->size, size)) {
- d->size = size;
- emit sizeChanged();
- }
+ if (qFuzzyCompare(d->size, size))
+ return;
+
+ d->size = size;
+ emit sizeChanged();
}
/*!
@@ -146,10 +147,11 @@ qreal QQuickScrollIndicator::position() const
void QQuickScrollIndicator::setPosition(qreal position)
{
Q_D(QQuickScrollIndicator);
- if (!qFuzzyCompare(d->position, position)) {
- d->position = position;
- emit positionChanged();
- }
+ if (qFuzzyCompare(d->position, position))
+ return;
+
+ d->position = position;
+ emit positionChanged();
}
/*!
@@ -167,10 +169,11 @@ bool QQuickScrollIndicator::isActive() const
void QQuickScrollIndicator::setActive(bool active)
{
Q_D(QQuickScrollIndicator);
- if (d->active != active) {
- d->active = active;
- emit activeChanged();
- }
+ if (d->active == active)
+ return;
+
+ d->active = active;
+ emit activeChanged();
}
/*!
@@ -191,10 +194,11 @@ Qt::Orientation QQuickScrollIndicator::orientation() const
void QQuickScrollIndicator::setOrientation(Qt::Orientation orientation)
{
Q_D(QQuickScrollIndicator);
- if (d->orientation != orientation) {
- d->orientation = orientation;
- emit orientationChanged();
- }
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged();
}
/*!
@@ -213,19 +217,20 @@ QQuickItem *QQuickScrollIndicator::indicator() const
void QQuickScrollIndicator::setIndicator(QQuickItem *indicator)
{
Q_D(QQuickScrollIndicator);
- if (d->indicator != indicator) {
- delete d->indicator;
- d->indicator = indicator;
- if (indicator && !indicator->parentItem())
- indicator->setParentItem(this);
- emit indicatorChanged();
- }
+ if (d->indicator == indicator)
+ return;
+
+ delete d->indicator;
+ d->indicator = indicator;
+ if (indicator && !indicator->parentItem())
+ indicator->setParentItem(this);
+ emit indicatorChanged();
}
class QQuickScrollIndicatorAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
public:
- QQuickScrollIndicatorAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(Q_NULLPTR), vertical(Q_NULLPTR) { }
+ QQuickScrollIndicatorAttachedPrivate(QQuickFlickable *flickable) : flickable(flickable), horizontal(nullptr), vertical(nullptr) { }
void activateHorizontal();
void activateVertical();
@@ -233,7 +238,7 @@ public:
void layoutHorizontal(bool move = true);
void layoutVertical(bool move = true);
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
QQuickFlickable *flickable;
QQuickScrollIndicator *horizontal;
@@ -318,38 +323,39 @@ QQuickScrollIndicator *QQuickScrollIndicatorAttached::horizontal() const
void QQuickScrollIndicatorAttached::setHorizontal(QQuickScrollIndicator *horizontal)
{
Q_D(QQuickScrollIndicatorAttached);
- if (d->horizontal != horizontal) {
- if (d->horizontal) {
- QQuickItemPrivate::get(d->horizontal)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal)));
- disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal)));
- }
-
- d->horizontal = horizontal;
-
- if (horizontal) {
- if (!horizontal->parentItem())
- horizontal->setParentItem(d->flickable);
- horizontal->setOrientation(Qt::Horizontal);
-
- QQuickItemPrivate::get(horizontal)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal)));
- connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal)));
-
- d->layoutHorizontal();
- horizontal->setSize(area->property("widthRatio").toReal());
- horizontal->setPosition(area->property("xPosition").toReal());
- }
- emit horizontalChanged();
+ if (d->horizontal == horizontal)
+ return;
+
+ if (d->horizontal) {
+ QQuickItemPrivate::get(d->horizontal)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ disconnect(area, SIGNAL(widthRatioChanged(qreal)), d->horizontal, SLOT(setSize(qreal)));
+ disconnect(area, SIGNAL(xPositionChanged(qreal)), d->horizontal, SLOT(setPosition(qreal)));
}
+
+ d->horizontal = horizontal;
+
+ if (horizontal) {
+ if (!horizontal->parentItem())
+ horizontal->setParentItem(d->flickable);
+ horizontal->setOrientation(Qt::Horizontal);
+
+ QQuickItemPrivate::get(horizontal)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingHorizontallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateHorizontal);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal)));
+ connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal)));
+
+ d->layoutHorizontal();
+ horizontal->setSize(area->property("widthRatio").toReal());
+ horizontal->setPosition(area->property("xPosition").toReal());
+ }
+ emit horizontalChanged();
}
/*!
@@ -373,38 +379,39 @@ QQuickScrollIndicator *QQuickScrollIndicatorAttached::vertical() const
void QQuickScrollIndicatorAttached::setVertical(QQuickScrollIndicator *vertical)
{
Q_D(QQuickScrollIndicatorAttached);
- if (d->vertical != vertical) {
- if (d->vertical) {
- QQuickItemPrivate::get(d->vertical)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal)));
- disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal)));
- }
-
- d->vertical = vertical;
-
- if (vertical) {
- if (!vertical->parentItem())
- vertical->setParentItem(d->flickable);
- vertical->setOrientation(Qt::Vertical);
-
- QQuickItemPrivate::get(vertical)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
- QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical);
-
- // TODO: export QQuickFlickableVisibleArea
- QObject *area = d->flickable->property("visibleArea").value<QObject *>();
- connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal)));
- connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal)));
-
- d->layoutVertical();
- vertical->setSize(area->property("heightRatio").toReal());
- vertical->setPosition(area->property("yPosition").toReal());
- }
- emit verticalChanged();
+ if (d->vertical == vertical)
+ return;
+
+ if (d->vertical) {
+ QQuickItemPrivate::get(d->vertical)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
+ QObjectPrivate::disconnect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ disconnect(area, SIGNAL(heightRatioChanged(qreal)), d->vertical, SLOT(setSize(qreal)));
+ disconnect(area, SIGNAL(yPositionChanged(qreal)), d->vertical, SLOT(setPosition(qreal)));
+ }
+
+ d->vertical = vertical;
+
+ if (vertical) {
+ if (!vertical->parentItem())
+ vertical->setParentItem(d->flickable);
+ vertical->setOrientation(Qt::Vertical);
+
+ QQuickItemPrivate::get(vertical)->updateOrAddGeometryChangeListener(d, QQuickItemPrivate::SizeChange);
+ QObjectPrivate::connect(d->flickable, &QQuickFlickable::movingVerticallyChanged, d, &QQuickScrollIndicatorAttachedPrivate::activateVertical);
+
+ // TODO: export QQuickFlickableVisibleArea
+ QObject *area = d->flickable->property("visibleArea").value<QObject *>();
+ connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal)));
+ connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal)));
+
+ d->layoutVertical();
+ vertical->setSize(area->property("heightRatio").toReal());
+ vertical->setPosition(area->property("yPosition").toReal());
}
+ emit verticalChanged();
}
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/templates/qquickscrollindicator_p.h b/src/templates/qquickscrollindicator_p.h
index 1f5f07b7..15002700 100644
--- a/src/templates/qquickscrollindicator_p.h
+++ b/src/templates/qquickscrollindicator_p.h
@@ -66,7 +66,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickScrollIndicator : public QQuickControl
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
public:
- explicit QQuickScrollIndicator(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickScrollIndicator(QQuickItem *parent = nullptr);
static QQuickScrollIndicatorAttached *qmlAttachedProperties(QObject *object);
@@ -95,7 +95,7 @@ Q_SIGNALS:
protected:
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickslider.cpp b/src/templates/qquickslider.cpp
index fac8fb50..395725eb 100644
--- a/src/templates/qquickslider.cpp
+++ b/src/templates/qquickslider.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickSlider
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-input
- \brief A slider control.
+ \brief Selects a value by sliding a handle along a track.
\image qtlabscontrols-slider.gif
@@ -80,7 +80,7 @@ class QQuickSliderPrivate : public QQuickControlPrivate
public:
QQuickSliderPrivate() : from(0), to(1), value(0), position(0), stepSize(0), pressed(false),
orientation(Qt::Horizontal), snapMode(QQuickSlider::NoSnap),
- handle(Q_NULLPTR), track(Q_NULLPTR)
+ handle(nullptr), track(nullptr)
{
}
@@ -147,11 +147,12 @@ void QQuickSliderPrivate::setPosition(qreal pos)
{
Q_Q(QQuickSlider);
pos = qBound<qreal>(0.0, pos, 1.0);
- if (!qFuzzyCompare(position, pos)) {
- position = pos;
- emit q->positionChanged();
- emit q->visualPositionChanged();
- }
+ if (qFuzzyCompare(position, pos))
+ return;
+
+ position = pos;
+ emit q->positionChanged();
+ emit q->visualPositionChanged();
}
void QQuickSliderPrivate::updatePosition()
@@ -185,13 +186,14 @@ qreal QQuickSlider::from() const
void QQuickSlider::setFrom(qreal from)
{
Q_D(QQuickSlider);
- if (!qFuzzyCompare(d->from, from)) {
- d->from = from;
- emit fromChanged();
- if (isComponentComplete()) {
- setValue(d->value);
- d->updatePosition();
- }
+ if (qFuzzyCompare(d->from, from))
+ return;
+
+ d->from = from;
+ emit fromChanged();
+ if (isComponentComplete()) {
+ setValue(d->value);
+ d->updatePosition();
}
}
@@ -211,13 +213,14 @@ qreal QQuickSlider::to() const
void QQuickSlider::setTo(qreal to)
{
Q_D(QQuickSlider);
- if (!qFuzzyCompare(d->to, to)) {
- d->to = to;
- emit toChanged();
- if (isComponentComplete()) {
- setValue(d->value);
- d->updatePosition();
- }
+ if (qFuzzyCompare(d->to, to))
+ return;
+
+ d->to = to;
+ emit toChanged();
+ if (isComponentComplete()) {
+ setValue(d->value);
+ d->updatePosition();
}
}
@@ -244,11 +247,12 @@ void QQuickSlider::setValue(qreal value)
if (isComponentComplete())
value = d->from > d->to ? qBound(d->to, value, d->from) : qBound(d->from, value, d->to);
- if (!qFuzzyCompare(d->value, value)) {
- d->value = value;
- d->updatePosition();
- emit valueChanged();
- }
+ if (qFuzzyCompare(d->value, value))
+ return;
+
+ d->value = value;
+ d->updatePosition();
+ emit valueChanged();
}
/*!
@@ -307,10 +311,11 @@ qreal QQuickSlider::stepSize() const
void QQuickSlider::setStepSize(qreal step)
{
Q_D(QQuickSlider);
- if (!qFuzzyCompare(d->stepSize, step)) {
- d->stepSize = step;
- emit stepSizeChanged();
- }
+ if (qFuzzyCompare(d->stepSize, step))
+ return;
+
+ d->stepSize = step;
+ emit stepSizeChanged();
}
/*!
@@ -334,10 +339,11 @@ QQuickSlider::SnapMode QQuickSlider::snapMode() const
void QQuickSlider::setSnapMode(SnapMode mode)
{
Q_D(QQuickSlider);
- if (d->snapMode != mode) {
- d->snapMode = mode;
- emit snapModeChanged();
- }
+ if (d->snapMode == mode)
+ return;
+
+ d->snapMode = mode;
+ emit snapModeChanged();
}
/*!
@@ -354,11 +360,12 @@ bool QQuickSlider::isPressed() const
void QQuickSlider::setPressed(bool pressed)
{
Q_D(QQuickSlider);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- setAccessibleProperty("pressed", pressed);
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ setAccessibleProperty("pressed", pressed);
+ emit pressedChanged();
}
/*!
@@ -379,10 +386,11 @@ Qt::Orientation QQuickSlider::orientation() const
void QQuickSlider::setOrientation(Qt::Orientation orientation)
{
Q_D(QQuickSlider);
- if (d->orientation != orientation) {
- d->orientation = orientation;
- emit orientationChanged();
- }
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ emit orientationChanged();
}
/*!
@@ -401,13 +409,14 @@ QQuickItem *QQuickSlider::handle() const
void QQuickSlider::setHandle(QQuickItem *handle)
{
Q_D(QQuickSlider);
- if (d->handle != handle) {
- delete d->handle;
- d->handle = handle;
- if (handle && !handle->parentItem())
- handle->setParentItem(this);
- emit handleChanged();
- }
+ if (d->handle == handle)
+ return;
+
+ delete d->handle;
+ d->handle = handle;
+ if (handle && !handle->parentItem())
+ handle->setParentItem(this);
+ emit handleChanged();
}
/*!
@@ -426,13 +435,14 @@ QQuickItem *QQuickSlider::track() const
void QQuickSlider::setTrack(QQuickItem *track)
{
Q_D(QQuickSlider);
- if (d->track != track) {
- delete d->track;
- d->track = track;
- if (track && !track->parentItem())
- track->setParentItem(this);
- emit trackChanged();
- }
+ if (d->track == track)
+ return;
+
+ delete d->track;
+ d->track = track;
+ if (track && !track->parentItem())
+ track->setParentItem(this);
+ emit trackChanged();
}
/*!
@@ -555,6 +565,20 @@ void QQuickSlider::mouseUngrabEvent()
setPressed(false);
}
+void QQuickSlider::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QQuickSlider);
+ 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 QQuickSlider::mirrorChange()
{
QQuickControl::mirrorChange();
diff --git a/src/templates/qquickslider_p.h b/src/templates/qquickslider_p.h
index 663ad684..a6231d09 100644
--- a/src/templates/qquickslider_p.h
+++ b/src/templates/qquickslider_p.h
@@ -70,7 +70,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickSlider : public QQuickControl
Q_PROPERTY(QQuickItem *track READ track WRITE setTrack NOTIFY trackChanged FINAL)
public:
- explicit QQuickSlider(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickSlider(QQuickItem *parent = nullptr);
qreal from() const;
void setFrom(qreal from);
@@ -127,18 +127,20 @@ Q_SIGNALS:
void trackChanged();
protected:
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void mirrorChange() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void wheelEvent(QWheelEvent *event) override;
+
+ void mirrorChange() override;
+ void componentComplete() override;
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickspinbox.cpp b/src/templates/qquickspinbox.cpp
index 255715e1..78a2d245 100644
--- a/src/templates/qquickspinbox.cpp
+++ b/src/templates/qquickspinbox.cpp
@@ -56,13 +56,14 @@ static const int AUTO_REPEAT_INTERVAL = 100;
\instantiates QQuickSpinBox
\inqmlmodule Qt.labs.controls
\ingroup input
- \brief A spinbox control.
+ \brief A spinbox control that allows the user from a set of preset values.
\image qtlabscontrols-spinbox.png
SpinBox allows the user to choose an integer value by clicking the up
- or down indicator buttons, by pressing up or down on the keyboard, or
- by entering a text value in the input field.
+ or down indicator buttons, or by pressing up or down on the keyboard.
+ Optionally, SpinBox can be also made \l editable, so the user can enter
+ a text value in the input field.
By default, SpinBox provides discrete values in the range of \c [0-99]
with a \l stepSize of \c 1.
@@ -90,8 +91,8 @@ class QQuickSpinBoxPrivate : public QQuickControlPrivate
Q_DECLARE_PUBLIC(QQuickSpinBox)
public:
- QQuickSpinBoxPrivate() : from(0), to(99), value(0), stepSize(1),
- delayTimer(0), repeatTimer(0), up(Q_NULLPTR), down(Q_NULLPTR), validator(Q_NULLPTR) { }
+ QQuickSpinBoxPrivate() : editable(false), from(0), to(99), value(0), stepSize(1),
+ delayTimer(0), repeatTimer(0), up(nullptr), down(nullptr), validator(nullptr) { }
int boundValue(int value) const;
void updateValue();
@@ -107,6 +108,7 @@ public:
bool handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event);
bool handleMouseUngrabEvent(QQuickItem *child);
+ bool editable;
int from;
int to;
int value;
@@ -260,12 +262,13 @@ int QQuickSpinBox::from() const
void QQuickSpinBox::setFrom(int from)
{
Q_D(QQuickSpinBox);
- if (d->from != from) {
- d->from = from;
- emit fromChanged();
- if (isComponentComplete())
- setValue(d->value);
- }
+ if (d->from == from)
+ return;
+
+ d->from = from;
+ emit fromChanged();
+ if (isComponentComplete())
+ setValue(d->value);
}
/*!
@@ -284,12 +287,13 @@ int QQuickSpinBox::to() const
void QQuickSpinBox::setTo(int to)
{
Q_D(QQuickSpinBox);
- if (d->to != to) {
- d->to = to;
- emit toChanged();
- if (isComponentComplete())
- setValue(d->value);
- }
+ if (d->to == to)
+ return;
+
+ d->to = to;
+ emit toChanged();
+ if (isComponentComplete())
+ setValue(d->value);
}
/*!
@@ -309,10 +313,11 @@ void QQuickSpinBox::setValue(int value)
if (isComponentComplete())
value = d->boundValue(value);
- if (d->value != value) {
- d->value = value;
- emit valueChanged();
- }
+ if (d->value == value)
+ return;
+
+ d->value = value;
+ emit valueChanged();
}
/*!
@@ -331,21 +336,45 @@ int QQuickSpinBox::stepSize() const
void QQuickSpinBox::setStepSize(int step)
{
Q_D(QQuickSpinBox);
- if (d->stepSize != step) {
- d->stepSize = step;
- emit stepSizeChanged();
- }
+ if (d->stepSize == step)
+ return;
+
+ d->stepSize = step;
+ emit stepSizeChanged();
+}
+
+/*!
+ \qmlproperty bool Qt.labs.controls::SpinBox::editable
+
+ This property holds whether the spinbox is editable. The default value is \c false.
+
+ \sa validator
+*/
+bool QQuickSpinBox::isEditable() const
+{
+ Q_D(const QQuickSpinBox);
+ return d->editable;
+}
+
+void QQuickSpinBox::setEditable(bool editable)
+{
+ Q_D(QQuickSpinBox);
+ if (d->editable == editable)
+ return;
+
+ d->editable = editable;
+ emit editableChanged();
}
/*!
\qmlproperty Validator Qt.labs.controls::SpinBox::validator
- This property holds the input text validator. By default, SpinBox uses
- \l IntValidator to accept input of integer numbers.
+ This property holds the input text validator for editable spinboxes. By
+ default, SpinBox uses \l IntValidator to accept input of integer numbers.
\snippet SpinBox.qml validator
- \sa textFromValue, valueFromText, {Control::locale}{locale}
+ \sa editable, textFromValue, valueFromText, {Control::locale}{locale}
*/
QValidator *QQuickSpinBox::validator() const
{
@@ -356,10 +385,11 @@ QValidator *QQuickSpinBox::validator() const
void QQuickSpinBox::setValidator(QValidator *validator)
{
Q_D(QQuickSpinBox);
- if (d->validator != validator) {
- d->validator = validator;
- emit validatorChanged();
- }
+ if (d->validator == validator)
+ return;
+
+ d->validator = validator;
+ emit validatorChanged();
}
/*!
@@ -597,6 +627,19 @@ void QQuickSpinBox::timerEvent(QTimerEvent *event)
}
}
+void QQuickSpinBox::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QQuickSpinBox);
+ QQuickControl::wheelEvent(event);
+ if (d->wheelEnabled) {
+ const int oldValue = d->value;
+ const QPointF angle = event->angleDelta();
+ const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / QWheelEvent::DefaultDeltasPerStep;
+ setValue(oldValue + qRound(d->effectiveStepSize() * delta));
+ event->setAccepted(d->value != oldValue);
+ }
+}
+
void QQuickSpinBox::itemChange(ItemChange change, const ItemChangeData &value)
{
Q_D(QQuickSpinBox);
@@ -622,7 +665,7 @@ QAccessible::Role QQuickSpinBox::accessibleRole() const
class QQuickSpinButtonPrivate : public QObjectPrivate
{
public:
- QQuickSpinButtonPrivate() : pressed(false), indicator(Q_NULLPTR) { }
+ QQuickSpinButtonPrivate() : pressed(false), indicator(nullptr) { }
bool pressed;
QQuickItem *indicator;
};
@@ -641,10 +684,11 @@ bool QQuickSpinButton::isPressed() const
void QQuickSpinButton::setPressed(bool pressed)
{
Q_D(QQuickSpinButton);
- if (d->pressed != pressed) {
- d->pressed = pressed;
- emit pressedChanged();
- }
+ if (d->pressed == pressed)
+ return;
+
+ d->pressed = pressed;
+ emit pressedChanged();
}
QQuickItem *QQuickSpinButton::indicator() const
@@ -656,16 +700,17 @@ QQuickItem *QQuickSpinButton::indicator() const
void QQuickSpinButton::setIndicator(QQuickItem *indicator)
{
Q_D(QQuickSpinButton);
- if (d->indicator != indicator) {
- delete d->indicator;
- d->indicator = indicator;
- if (indicator) {
- if (!indicator->parentItem())
- indicator->setParentItem(static_cast<QQuickItem *>(parent()));
- indicator->setAcceptedMouseButtons(Qt::LeftButton);
- }
- emit indicatorChanged();
+ if (d->indicator == indicator)
+ return;
+
+ delete d->indicator;
+ d->indicator = indicator;
+ if (indicator) {
+ if (!indicator->parentItem())
+ indicator->setParentItem(static_cast<QQuickItem *>(parent()));
+ indicator->setAcceptedMouseButtons(Qt::LeftButton);
}
+ emit indicatorChanged();
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickspinbox_p.h b/src/templates/qquickspinbox_p.h
index c7d1f6c6..60df92bb 100644
--- a/src/templates/qquickspinbox_p.h
+++ b/src/templates/qquickspinbox_p.h
@@ -65,6 +65,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickSpinBox : public QQuickControl
Q_PROPERTY(int to READ to WRITE setTo NOTIFY toChanged FINAL)
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged FINAL)
Q_PROPERTY(int stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
+ Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged FINAL)
Q_PROPERTY(QValidator *validator READ validator WRITE setValidator NOTIFY validatorChanged FINAL)
Q_PROPERTY(QJSValue textFromValue READ textFromValue WRITE setTextFromValue NOTIFY textFromValueChanged FINAL)
Q_PROPERTY(QJSValue valueFromText READ valueFromText WRITE setValueFromText NOTIFY valueFromTextChanged FINAL)
@@ -72,7 +73,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickSpinBox : public QQuickControl
Q_PROPERTY(QQuickSpinButton *down READ down CONSTANT FINAL)
public:
- explicit QQuickSpinBox(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickSpinBox(QQuickItem *parent = nullptr);
int from() const;
void setFrom(int from);
@@ -86,6 +87,9 @@ public:
int stepSize() const;
void setStepSize(int step);
+ bool isEditable() const;
+ void setEditable(bool editable);
+
QValidator *validator() const;
void setValidator(QValidator *validator);
@@ -107,25 +111,27 @@ Q_SIGNALS:
void toChanged();
void valueChanged();
void stepSizeChanged();
+ void editableChanged();
void validatorChanged();
void textFromValueChanged();
void valueFromTextChanged();
protected:
- bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
-
- void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
+ bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseUngrabEvent() override;
+ void timerEvent(QTimerEvent *event) override;
+ void wheelEvent(QWheelEvent *event) override;
+
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquickstackview.cpp b/src/templates/qquickstackview.cpp
index bfa01e72..70194257 100644
--- a/src/templates/qquickstackview.cpp
+++ b/src/templates/qquickstackview.cpp
@@ -278,7 +278,7 @@ QQuickStackView::~QQuickStackView()
{
Q_D(QQuickStackView);
if (d->transitioner) {
- d->transitioner->setChangeListener(Q_NULLPTR);
+ d->transitioner->setChangeListener(nullptr);
delete d->transitioner;
}
qDeleteAll(d->removals);
@@ -290,7 +290,7 @@ QQuickStackAttached *QQuickStackView::qmlAttachedProperties(QObject *object)
QQuickItem *item = qobject_cast<QQuickItem *>(object);
if (!item) {
qmlInfo(object) << "StackView must be attached to an Item";
- return Q_NULLPTR;
+ return nullptr;
}
return new QQuickStackAttached(item);
}
@@ -347,7 +347,7 @@ QQuickItem *QQuickStackView::get(int index, LoadBehavior behavior)
element->load(this);
return element->item;
}
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -373,7 +373,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
QJSValue func(callback);
QQmlEngine *engine = qmlEngine(this);
if (!engine || !func.isCallable()) // TODO: warning?
- return Q_NULLPTR;
+ return nullptr;
for (int i = d->elements.count() - 1; i >= 0; --i) {
QQuickStackElement *element = d->elements.at(i);
@@ -386,7 +386,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
}
}
- return Q_NULLPTR;
+ return nullptr;
}
/*!
@@ -457,7 +457,7 @@ void QQuickStackView::push(QQmlV4Function *args)
return;
}
- QQuickStackElement *exit = Q_NULLPTR;
+ QQuickStackElement *exit = nullptr;
if (!d->elements.isEmpty())
exit = d->elements.top();
@@ -541,7 +541,7 @@ void QQuickStackView::pop(QQmlV4Function *args)
operation = static_cast<Operation>(lastArg->toInt32());
}
- QQuickItem *previousItem = Q_NULLPTR;
+ QQuickItem *previousItem = nullptr;
if (d->popElements(enter)) {
if (exit)
@@ -624,7 +624,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
if (lastArg->isInt32())
operation = static_cast<Operation>(lastArg->toInt32());
- QQuickStackElement *target = Q_NULLPTR;
+ QQuickStackElement *target = nullptr;
QV4::ScopedValue firstArg(scope, (*args)[0]);
if (firstArg->isNull())
target = d->elements.value(0);
@@ -639,7 +639,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
}
int depth = d->elements.count();
- QQuickStackElement* exit = Q_NULLPTR;
+ QQuickStackElement* exit = nullptr;
if (!d->elements.isEmpty())
exit = d->elements.pop();
@@ -667,7 +667,7 @@ void QQuickStackView::replace(QQmlV4Function *args)
void QQuickStackView::clear()
{
Q_D(QQuickStackView);
- d->setCurrentItem(Q_NULLPTR);
+ d->setCurrentItem(nullptr);
qDeleteAll(d->elements);
d->elements.clear();
emit depthChanged();
@@ -710,17 +710,18 @@ QQuickTransition *QQuickStackView::popEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->removeDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPopEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->removeDisplacedTransition != enter) {
- d->transitioner->removeDisplacedTransition = enter;
- emit popEnterChanged();
- }
+ if (d->transitioner->removeDisplacedTransition == enter)
+ return;
+
+ d->transitioner->removeDisplacedTransition = enter;
+ emit popEnterChanged();
}
/*!
@@ -736,17 +737,18 @@ QQuickTransition *QQuickStackView::popExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->removeTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPopExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->removeTransition != exit) {
- d->transitioner->removeTransition = exit;
- emit popExitChanged();
- }
+ if (d->transitioner->removeTransition == exit)
+ return;
+
+ d->transitioner->removeTransition = exit;
+ emit popExitChanged();
}
/*!
@@ -762,17 +764,18 @@ QQuickTransition *QQuickStackView::pushEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->addTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPushEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->addTransition != enter) {
- d->transitioner->addTransition = enter;
- emit pushEnterChanged();
- }
+ if (d->transitioner->addTransition == enter)
+ return;
+
+ d->transitioner->addTransition = enter;
+ emit pushEnterChanged();
}
/*!
@@ -788,17 +791,18 @@ QQuickTransition *QQuickStackView::pushExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->addDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setPushExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->addDisplacedTransition != exit) {
- d->transitioner->addDisplacedTransition = exit;
- emit pushExitChanged();
- }
+ if (d->transitioner->addDisplacedTransition == exit)
+ return;
+
+ d->transitioner->addDisplacedTransition = exit;
+ emit pushExitChanged();
}
/*!
@@ -814,17 +818,18 @@ QQuickTransition *QQuickStackView::replaceEnter() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->moveTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setReplaceEnter(QQuickTransition *enter)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->moveTransition != enter) {
- d->transitioner->moveTransition = enter;
- emit replaceEnterChanged();
- }
+ if (d->transitioner->moveTransition == enter)
+ return;
+
+ d->transitioner->moveTransition = enter;
+ emit replaceEnterChanged();
}
/*!
@@ -840,17 +845,18 @@ QQuickTransition *QQuickStackView::replaceExit() const
Q_D(const QQuickStackView);
if (d->transitioner)
return d->transitioner->moveDisplacedTransition;
- return Q_NULLPTR;
+ return nullptr;
}
void QQuickStackView::setReplaceExit(QQuickTransition *exit)
{
Q_D(QQuickStackView);
d->ensureTransitioner();
- if (d->transitioner->moveDisplacedTransition != exit) {
- d->transitioner->moveDisplacedTransition = exit;
- emit replaceExitChanged();
- }
+ if (d->transitioner->moveDisplacedTransition == exit)
+ return;
+
+ d->transitioner->moveDisplacedTransition = exit;
+ emit replaceExitChanged();
}
void QQuickStackView::componentComplete()
@@ -858,7 +864,7 @@ void QQuickStackView::componentComplete()
QQuickControl::componentComplete();
Q_D(QQuickStackView);
- QQuickStackElement *element = Q_NULLPTR;
+ QQuickStackElement *element = nullptr;
if (QObject *o = d->initialItem.value<QObject *>())
element = QQuickStackElement::fromObject(o, this);
else if (d->initialItem.canConvert<QString>())
@@ -875,7 +881,7 @@ void QQuickStackView::geometryChanged(const QRectF &newGeometry, const QRectF &o
QQuickControl::geometryChanged(newGeometry, oldGeometry);
Q_D(QQuickStackView);
- foreach (QQuickStackElement *element, d->elements) {
+ for (QQuickStackElement *element : qAsConst(d->elements)) {
if (element->item) {
if (!element->widthValid)
element->item->setWidth(newGeometry.width());
@@ -903,11 +909,11 @@ void QQuickStackAttachedPrivate::itemParentChanged(QQuickItem *item, QQuickItem
{
Q_Q(QQuickStackAttached);
int oldIndex = element ? element->index : -1;
- QQuickStackView *oldView = element ? element->view : Q_NULLPTR;
+ QQuickStackView *oldView = element ? element->view : nullptr;
QQuickStackView::Status oldStatus = element ? element->status : QQuickStackView::Inactive;
QQuickStackView *newView = qobject_cast<QQuickStackView *>(parent);
- element = newView ? QQuickStackViewPrivate::get(newView)->findElement(item) : Q_NULLPTR;
+ element = newView ? QQuickStackViewPrivate::get(newView)->findElement(item) : nullptr;
int newIndex = element ? element->index : -1;
QQuickStackView::Status newStatus = element ? element->status : QQuickStackView::Inactive;
@@ -958,7 +964,7 @@ int QQuickStackAttached::index() const
QQuickStackView *QQuickStackAttached::view() const
{
Q_D(const QQuickStackAttached);
- return d->element ? d->element->view : Q_NULLPTR;
+ return d->element ? d->element->view : nullptr;
}
/*!
diff --git a/src/templates/qquickstackview_p.cpp b/src/templates/qquickstackview_p.cpp
index 101f1f68..f03ff7fc 100644
--- a/src/templates/qquickstackview_p.cpp
+++ b/src/templates/qquickstackview_p.cpp
@@ -63,15 +63,15 @@ public:
QQuickStackIncubator(QQuickStackElement *element) : QQmlIncubator(Synchronous), element(element) { }
protected:
- void setInitialState(QObject *object) Q_DECL_OVERRIDE { element->incubate(object); }
+ void setInitialState(QObject *object) override { element->incubate(object); }
private:
QQuickStackElement *element;
};
-QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(Q_NULLPTR),
+QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(nullptr),
index(-1), init(false), removal(false), ownItem(false), ownComponent(false), widthValid(false), heightValid(false),
- context(Q_NULLPTR), component(Q_NULLPTR), incubator(Q_NULLPTR), view(Q_NULLPTR),
+ context(nullptr), component(nullptr), incubator(nullptr), view(nullptr),
status(QQuickStackView::Inactive)
{
}
@@ -86,9 +86,9 @@ QQuickStackElement::~QQuickStackElement()
if (item) {
if (ownItem) {
- item->setParentItem(Q_NULLPTR);
+ item->setParentItem(nullptr);
item->deleteLater();
- item = Q_NULLPTR;
+ item = nullptr;
} else {
item->setVisible(false);
if (item->parentItem() != originalParent) {
@@ -96,7 +96,7 @@ QQuickStackElement::~QQuickStackElement()
} else {
QQuickStackAttached *attached = attachedStackObject(this);
if (attached)
- QQuickStackAttachedPrivate::get(attached)->itemParentChanged(item, Q_NULLPTR);
+ QQuickStackAttachedPrivate::get(attached)->itemParentChanged(item, nullptr);
}
}
}
@@ -188,32 +188,35 @@ void QQuickStackElement::initialize()
void QQuickStackElement::setIndex(int value)
{
- if (index != value) {
- index = value;
- QQuickStackAttached *attached = attachedStackObject(this);
- if (attached)
- emit attached->indexChanged();
- }
+ if (index == value)
+ return;
+
+ index = value;
+ QQuickStackAttached *attached = attachedStackObject(this);
+ if (attached)
+ emit attached->indexChanged();
}
void QQuickStackElement::setView(QQuickStackView *value)
{
- if (view != value) {
- view = value;
- QQuickStackAttached *attached = attachedStackObject(this);
- if (attached)
- emit attached->viewChanged();
- }
+ if (view == value)
+ return;
+
+ view = value;
+ QQuickStackAttached *attached = attachedStackObject(this);
+ if (attached)
+ emit attached->viewChanged();
}
void QQuickStackElement::setStatus(QQuickStackView::Status value)
{
- if (status != value) {
- status = value;
- QQuickStackAttached *attached = attachedStackObject(this);
- if (attached)
- emit attached->statusChanged();
- }
+ if (status == value)
+ return;
+
+ status = value;
+ QQuickStackAttached *attached = attachedStackObject(this);
+ if (attached)
+ emit attached->statusChanged();
}
void QQuickStackElement::transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget)
@@ -249,22 +252,23 @@ void QQuickStackElement::startTransition(QQuickItemViewTransitioner *transitione
void QQuickStackElement::itemDestroyed(QQuickItem *)
{
- item = Q_NULLPTR;
+ item = nullptr;
}
-QQuickStackViewPrivate::QQuickStackViewPrivate() : busy(false), currentItem(Q_NULLPTR), transitioner(Q_NULLPTR)
+QQuickStackViewPrivate::QQuickStackViewPrivate() : busy(false), currentItem(nullptr), transitioner(nullptr)
{
}
void QQuickStackViewPrivate::setCurrentItem(QQuickItem *item)
{
Q_Q(QQuickStackView);
- if (currentItem != item) {
- currentItem = item;
- if (item)
- item->setVisible(true);
- emit q->currentItemChanged();
- }
+ if (currentItem == item)
+ return;
+
+ currentItem = item;
+ if (item)
+ item->setVisible(true);
+ emit q->currentItemChanged();
}
static bool initProperties(QQuickStackElement *element, const QV4::Value &props, QQmlV4Function *args)
@@ -322,19 +326,19 @@ QList<QQuickStackElement *> QQuickStackViewPrivate::parseElements(QQmlV4Function
QQuickStackElement *QQuickStackViewPrivate::findElement(QQuickItem *item) const
{
if (item) {
- foreach (QQuickStackElement *e, elements) {
+ for (QQuickStackElement *e : qAsConst(elements)) {
if (e->item == item)
return e;
}
}
- return Q_NULLPTR;
+ return nullptr;
}
QQuickStackElement *QQuickStackViewPrivate::findElement(const QV4::Value &value) const
{
if (const QV4::QObjectWrapper *o = value.as<QV4::QObjectWrapper>())
return findElement(qobject_cast<QQuickItem *>(o->object()));
- return Q_NULLPTR;
+ return nullptr;
}
QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &value)
@@ -344,14 +348,14 @@ QQuickStackElement *QQuickStackViewPrivate::createElement(const QV4::Value &valu
return QQuickStackElement::fromString(s->toQString(), q);
if (const QV4::QObjectWrapper *o = value.as<QV4::QObjectWrapper>())
return QQuickStackElement::fromObject(o->object(), q);
- return Q_NULLPTR;
+ return nullptr;
}
bool QQuickStackViewPrivate::pushElements(const QList<QQuickStackElement *> &elems)
{
Q_Q(QQuickStackView);
if (!elems.isEmpty()) {
- foreach (QQuickStackElement *e, elems) {
+ for (QQuickStackElement *e : elems) {
e->setIndex(elements.count());
elements += e;
}
@@ -536,11 +540,12 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition
void QQuickStackViewPrivate::setBusy(bool b)
{
Q_Q(QQuickStackView);
- if (busy != b) {
- busy = b;
- q->setFiltersChildMouseEvents(busy);
- emit q->busyChanged();
- }
+ if (busy == b)
+ return;
+
+ busy = b;
+ q->setFiltersChildMouseEvents(busy);
+ emit q->busyChanged();
}
QT_END_NAMESPACE
diff --git a/src/templates/qquickstackview_p.h b/src/templates/qquickstackview_p.h
index 6b78b50a..34a430e7 100644
--- a/src/templates/qquickstackview_p.h
+++ b/src/templates/qquickstackview_p.h
@@ -73,7 +73,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickStackView : public QQuickControl
Q_PROPERTY(QQuickTransition *replaceExit READ replaceExit WRITE setReplaceExit NOTIFY replaceExitChanged FINAL)
public:
- explicit QQuickStackView(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickStackView(QQuickItem *parent = nullptr);
~QQuickStackView();
static QQuickStackAttached *qmlAttachedProperties(QObject *object);
@@ -145,9 +145,9 @@ Q_SIGNALS:
void replaceExitChanged();
protected:
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ bool childMouseEventFilter(QQuickItem *, QEvent *) override;
private:
Q_DISABLE_COPY(QQuickStackView)
@@ -164,7 +164,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickStackAttached : public QObject
Q_PROPERTY(QQuickStackView::Status status READ status NOTIFY statusChanged FINAL)
public:
- explicit QQuickStackAttached(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickStackAttached(QQuickItem *parent = nullptr);
~QQuickStackAttached();
int index() const;
diff --git a/src/templates/qquickstackview_p_p.h b/src/templates/qquickstackview_p_p.h
index d14c6326..93d08034 100644
--- a/src/templates/qquickstackview_p_p.h
+++ b/src/templates/qquickstackview_p_p.h
@@ -82,7 +82,7 @@ public:
bool prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds);
void startTransition(QQuickItemViewTransitioner *transitioner);
- void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemDestroyed(QQuickItem *item) override;
int index;
bool init;
@@ -129,7 +129,7 @@ public:
void replaceTransition(QQuickStackElement *enter, QQuickStackElement *exit, const QRectF &viewBounds, bool immediate);
void completeTransition(QQuickStackElement *element, QQuickTransition *transition);
- void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) Q_DECL_OVERRIDE;
+ void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
void setBusy(bool busy);
bool busy;
@@ -145,7 +145,7 @@ class QQuickStackAttachedPrivate : public QObjectPrivate, public QQuickItemChang
Q_DECLARE_PUBLIC(QQuickStackAttached)
public:
- QQuickStackAttachedPrivate() : element(Q_NULLPTR) { }
+ QQuickStackAttachedPrivate() : element(nullptr) { }
static QQuickStackAttachedPrivate *get(QQuickStackAttached *attached)
{
diff --git a/src/templates/qquickswipeview.cpp b/src/templates/qquickswipeview.cpp
index c33163fe..ec51da49 100644
--- a/src/templates/qquickswipeview.cpp
+++ b/src/templates/qquickswipeview.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-navigation
\ingroup qtlabscontrols-containers
- \brief A swipe view control.
+ \brief Enables the user to navigate pages by swiping sideways.
SwipeView provides a swipe-based navigation model.
@@ -126,7 +126,7 @@ QQuickSwipeViewAttached *QQuickSwipeView::qmlAttachedProperties(QObject *object)
QQuickItem *item = qobject_cast<QQuickItem *>(object);
if (!item) {
qWarning() << "SwipeView: attached properties must be accessed from within a child item";
- return Q_NULLPTR;
+ return nullptr;
}
return new QQuickSwipeViewAttached(item);
@@ -179,7 +179,7 @@ class QQuickSwipeViewAttachedPrivate : public QObjectPrivate, public QQuickItemC
public:
QQuickSwipeViewAttachedPrivate(QQuickItem *item) :
item(item),
- swipeView(Q_NULLPTR),
+ swipeView(nullptr),
index(-1),
isCurrent(false)
{
@@ -190,9 +190,9 @@ public:
void updateView(QQuickItem *parent);
- void itemChildAdded(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
- void itemChildRemoved(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
- void itemParentChanged(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
+ void itemChildAdded(QQuickItem *, QQuickItem *) override;
+ void itemChildRemoved(QQuickItem *, QQuickItem *) override;
+ void itemParentChanged(QQuickItem *, QQuickItem *) override;
void updateIndex();
void updateIsCurrent();
@@ -212,7 +212,7 @@ public:
void QQuickSwipeViewAttachedPrivate::updateIndex()
{
- setIndex(swipeView ? QQuickSwipeViewPrivate::get(swipeView)->contentModel->indexOf(item, Q_NULLPTR) : -1);
+ setIndex(swipeView ? QQuickSwipeViewPrivate::get(swipeView)->contentModel->indexOf(item, nullptr) : -1);
}
void QQuickSwipeViewAttachedPrivate::updateIsCurrent()
@@ -256,20 +256,22 @@ void QQuickSwipeViewAttachedPrivate::setView(QQuickSwipeView *view)
void QQuickSwipeViewAttachedPrivate::setIsCurrent(bool current)
{
- if (current != isCurrent) {
- isCurrent = current;
- Q_Q(QQuickSwipeViewAttached);
- emit q->isCurrentItemChanged();
- }
+ if (current == isCurrent)
+ return;
+
+ isCurrent = current;
+ Q_Q(QQuickSwipeViewAttached);
+ emit q->isCurrentItemChanged();
}
void QQuickSwipeViewAttachedPrivate::setIndex(int i)
{
- if (i != index) {
- index = i;
- Q_Q(QQuickSwipeViewAttached);
- emit q->indexChanged();
- }
+ if (i == index)
+ return;
+
+ index = i;
+ Q_Q(QQuickSwipeViewAttached);
+ emit q->indexChanged();
}
void QQuickSwipeViewAttachedPrivate::updateView(QQuickItem *parent)
@@ -279,7 +281,7 @@ void QQuickSwipeViewAttachedPrivate::updateView(QQuickItem *parent)
// - A non-visual or weird type like TestCase, when child items are created from components
// wherein the attached properties are used
// - null, when the item was removed with removeItem()
- QQuickSwipeView *view = Q_NULLPTR;
+ QQuickSwipeView *view = nullptr;
if (parent) {
view = qobject_cast<QQuickSwipeView*>(parent);
if (!view) {
diff --git a/src/templates/qquickswipeview_p.h b/src/templates/qquickswipeview_p.h
index bf733c7b..7a649300 100644
--- a/src/templates/qquickswipeview_p.h
+++ b/src/templates/qquickswipeview_p.h
@@ -60,13 +60,13 @@ class Q_LABSTEMPLATES_EXPORT QQuickSwipeView : public QQuickContainer
Q_OBJECT
public:
- explicit QQuickSwipeView(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickSwipeView(QQuickItem *parent = nullptr);
static QQuickSwipeViewAttached *qmlAttachedProperties(QObject *object);
protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void itemAdded(int index, QQuickItem *item) Q_DECL_OVERRIDE;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemAdded(int index, QQuickItem *item) override;
private:
Q_DISABLE_COPY(QQuickSwipeView)
diff --git a/src/templates/qquickswitch.cpp b/src/templates/qquickswitch.cpp
index 05422d8d..79d9735c 100644
--- a/src/templates/qquickswitch.cpp
+++ b/src/templates/qquickswitch.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickSwitch
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A switch control.
+ \brief An option button that can be toggled on or off.
\image qtlabscontrols-switch.gif
@@ -188,11 +188,12 @@ void QQuickSwitch::setPosition(qreal position)
{
Q_D(QQuickSwitch);
position = qBound<qreal>(0.0, position, 1.0);
- if (d->position != position) {
- d->position = position;
- emit positionChanged();
- emit visualPositionChanged();
- }
+ if (qFuzzyCompare(d->position, position))
+ return;
+
+ d->position = position;
+ emit positionChanged();
+ emit visualPositionChanged();
}
/*!
diff --git a/src/templates/qquickswitch_p.h b/src/templates/qquickswitch_p.h
index 94d0d601..ee8f49f8 100644
--- a/src/templates/qquickswitch_p.h
+++ b/src/templates/qquickswitch_p.h
@@ -61,7 +61,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickSwitch : public QQuickAbstractButton
Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
public:
- explicit QQuickSwitch(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickSwitch(QQuickItem *parent = nullptr);
qreal position() const;
void setPosition(qreal position);
@@ -73,8 +73,8 @@ Q_SIGNALS:
void visualPositionChanged();
protected:
- void mirrorChange() Q_DECL_OVERRIDE;
- bool childMouseEventFilter(QQuickItem *child, QEvent *event) Q_DECL_OVERRIDE;
+ void mirrorChange() override;
+ bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
virtual qreal positionAt(const QPoint &point) const;
diff --git a/src/templates/qquicktabbar.cpp b/src/templates/qquicktabbar.cpp
index 58d68058..00567019 100644
--- a/src/templates/qquicktabbar.cpp
+++ b/src/templates/qquicktabbar.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-navigation
\ingroup qtlabscontrols-containers
- \brief A tab bar control.
+ \brief A bar with icons allowing to switch between different views or subtasks.
TabBar provides a tab-based navigation model.
@@ -69,11 +69,19 @@ class QQuickTabBarPrivate : public QQuickContainerPrivate
Q_DECLARE_PUBLIC(QQuickTabBar)
public:
+ QQuickTabBarPrivate();
+
void updateCurrentItem();
void updateCurrentIndex();
void updateLayout();
+
+ QQuickTabBar::Position position;
};
+QQuickTabBarPrivate::QQuickTabBarPrivate() : position(QQuickTabBar::Header)
+{
+}
+
void QQuickTabBarPrivate::updateCurrentItem()
{
QQuickTabButton *button = qobject_cast<QQuickTabButton *>(contentModel->get(currentIndex));
@@ -86,7 +94,7 @@ void QQuickTabBarPrivate::updateCurrentIndex()
Q_Q(QQuickTabBar);
QQuickTabButton *button = qobject_cast<QQuickTabButton *>(q->sender());
if (button && button->isChecked())
- q->setCurrentIndex(contentModel->indexOf(button, Q_NULLPTR));
+ q->setCurrentIndex(contentModel->indexOf(button, nullptr));
}
void QQuickTabBarPrivate::updateLayout()
@@ -117,6 +125,38 @@ QQuickTabBar::QQuickTabBar(QQuickItem *parent) :
QObjectPrivate::connect(this, &QQuickTabBar::currentIndexChanged, d, &QQuickTabBarPrivate::updateCurrentItem);
}
+/*!
+ \qmlproperty enumeration Qt.labs.controls::TabBar::position
+
+ This property holds the position of the tab bar.
+
+ \note If the tab bar is assigned as a header or footer of ApplicationWindow
+ or Page, the appropriate position is set automatically.
+
+ Possible values:
+ \value TabBar.Header The tab bar is at the top, as a window or page header.
+ \value TabBar.Footer The tab bar is at the bottom, as a window or page footer.
+
+ The default value is style-specific.
+
+ \sa ApplicationWindow::header, ApplicationWindow::footer, Page::header, Page::footer
+*/
+QQuickTabBar::Position QQuickTabBar::position() const
+{
+ Q_D(const QQuickTabBar);
+ return d->position;
+}
+
+void QQuickTabBar::setPosition(Position position)
+{
+ Q_D(QQuickTabBar);
+ if (d->position == position)
+ return;
+
+ d->position = position;
+ emit positionChanged();
+}
+
void QQuickTabBar::updatePolish()
{
Q_D(QQuickTabBar);
diff --git a/src/templates/qquicktabbar_p.h b/src/templates/qquicktabbar_p.h
index 7d6f674c..abfd4dc9 100644
--- a/src/templates/qquicktabbar_p.h
+++ b/src/templates/qquicktabbar_p.h
@@ -57,20 +57,33 @@ class QQuickTabBarPrivate;
class Q_LABSTEMPLATES_EXPORT QQuickTabBar : public QQuickContainer
{
Q_OBJECT
+ Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL)
public:
- explicit QQuickTabBar(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickTabBar(QQuickItem *parent = nullptr);
+
+ enum Position {
+ Header,
+ Footer
+ };
+ Q_ENUM(Position)
+
+ Position position() const;
+ void setPosition(Position position);
+
+Q_SIGNALS:
+ void positionChanged();
protected:
- void updatePolish() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- bool isContent(QQuickItem *item) const Q_DECL_OVERRIDE;
- void itemAdded(int index, QQuickItem *item) Q_DECL_OVERRIDE;
- void itemRemoved(int index, QQuickItem *item) Q_DECL_OVERRIDE;
+ void updatePolish() override;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) 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 Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
private:
diff --git a/src/templates/qquicktabbutton.cpp b/src/templates/qquicktabbutton.cpp
index a70dcbe1..58eb9b85 100644
--- a/src/templates/qquicktabbutton.cpp
+++ b/src/templates/qquicktabbutton.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickTabButton
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-navigation
- \brief A tab button control.
+ \brief A tab button control that can be found on a TabBar.
\image qtlabscontrols-tabbutton.png
diff --git a/src/templates/qquicktabbutton_p.h b/src/templates/qquicktabbutton_p.h
index c02a206f..07a020e5 100644
--- a/src/templates/qquicktabbutton_p.h
+++ b/src/templates/qquicktabbutton_p.h
@@ -57,13 +57,13 @@ class Q_LABSTEMPLATES_EXPORT QQuickTabButton : public QQuickAbstractButton
Q_OBJECT
public:
- explicit QQuickTabButton(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickTabButton(QQuickItem *parent = nullptr);
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
};
diff --git a/src/templates/qquicktextarea.cpp b/src/templates/qquicktextarea.cpp
index 05b1b9a7..85e1a9ec 100644
--- a/src/templates/qquicktextarea.cpp
+++ b/src/templates/qquicktextarea.cpp
@@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE
*/
QQuickTextAreaPrivate::QQuickTextAreaPrivate()
- : background(Q_NULLPTR), focusReason(Qt::OtherFocusReason), accessibleAttached(Q_NULLPTR)
+ : background(nullptr), focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -249,18 +249,19 @@ QQuickItem *QQuickTextArea::background() const
void QQuickTextArea::setBackground(QQuickItem *background)
{
Q_D(QQuickTextArea);
- if (d->background != background) {
- delete d->background;
- d->background = background;
- if (background) {
- background->setParentItem(this);
- if (qFuzzyIsNull(background->z()))
- background->setZ(-1);
- if (isComponentComplete())
- d->resizeBackground();
- }
- emit backgroundChanged();
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->resizeBackground();
}
+ emit backgroundChanged();
}
/*!
@@ -277,14 +278,15 @@ QString QQuickTextArea::placeholderText() const
void QQuickTextArea::setPlaceholderText(const QString &text)
{
Q_D(QQuickTextArea);
- if (d->placeholder != text) {
- d->placeholder = text;
+ if (d->placeholder == text)
+ return;
+
+ d->placeholder = text;
#ifndef QT_NO_ACCESSIBILITY
- if (d->accessibleAttached)
- d->accessibleAttached->setDescription(text);
+ if (d->accessibleAttached)
+ d->accessibleAttached->setDescription(text);
#endif
- emit placeholderTextChanged();
- }
+ emit placeholderTextChanged();
}
/*!
@@ -315,10 +317,11 @@ Qt::FocusReason QQuickTextArea::focusReason() const
void QQuickTextArea::setFocusReason(Qt::FocusReason reason)
{
Q_D(QQuickTextArea);
- if (d->focusReason != reason) {
- d->focusReason = reason;
- emit focusReasonChanged();
- }
+ if (d->focusReason == reason)
+ return;
+
+ d->focusReason = reason;
+ emit focusReasonChanged();
}
void QQuickTextArea::classBegin()
diff --git a/src/templates/qquicktextarea_p.h b/src/templates/qquicktextarea_p.h
index acf67359..623dc952 100644
--- a/src/templates/qquicktextarea_p.h
+++ b/src/templates/qquicktextarea_p.h
@@ -68,7 +68,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickTextArea : public QQuickTextEdit
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
public:
- explicit QQuickTextArea(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickTextArea(QQuickItem *parent = nullptr);
~QQuickTextArea();
QFont font() const;
@@ -93,18 +93,18 @@ Q_SIGNALS:
void pressAndHold(QQuickMouseEvent *event);
protected:
- void classBegin() Q_DECL_OVERRIDE;
-
- void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE;
-
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void classBegin() override;
+
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
+
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void timerEvent(QTimerEvent *event) override;
private:
Q_DISABLE_COPY(QQuickTextArea)
diff --git a/src/templates/qquicktextarea_p_p.h b/src/templates/qquicktextarea_p_p.h
index 2a16e5cc..35dd704d 100644
--- a/src/templates/qquicktextarea_p_p.h
+++ b/src/templates/qquicktextarea_p_p.h
@@ -78,17 +78,17 @@ public:
void resizeBackground();
void resolveFont();
- qreal getImplicitWidth() const Q_DECL_OVERRIDE;
- qreal getImplicitHeight() const Q_DECL_OVERRIDE;
+ qreal getImplicitWidth() const override;
+ qreal getImplicitHeight() const override;
- void implicitWidthChanged() Q_DECL_OVERRIDE;
- void implicitHeightChanged() Q_DECL_OVERRIDE;
+ void implicitWidthChanged() override;
+ void implicitHeightChanged() override;
void _q_readOnlyChanged(bool isReadOnly);
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
QQuickItem *background;
diff --git a/src/templates/qquicktextfield.cpp b/src/templates/qquicktextfield.cpp
index c3070614..6efc0a66 100644
--- a/src/templates/qquicktextfield.cpp
+++ b/src/templates/qquicktextfield.cpp
@@ -91,9 +91,9 @@ QT_BEGIN_NAMESPACE
*/
QQuickTextFieldPrivate::QQuickTextFieldPrivate()
- : background(Q_NULLPTR)
+ : background(nullptr)
, focusReason(Qt::OtherFocusReason)
- , accessibleAttached(Q_NULLPTR)
+ , accessibleAttached(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -274,18 +274,19 @@ QQuickItem *QQuickTextField::background() const
void QQuickTextField::setBackground(QQuickItem *background)
{
Q_D(QQuickTextField);
- if (d->background != background) {
- delete d->background;
- d->background = background;
- if (background) {
- background->setParentItem(this);
- if (qFuzzyIsNull(background->z()))
- background->setZ(-1);
- if (isComponentComplete())
- d->resizeBackground();
- }
- emit backgroundChanged();
+ if (d->background == background)
+ return;
+
+ delete d->background;
+ d->background = background;
+ if (background) {
+ background->setParentItem(this);
+ if (qFuzzyIsNull(background->z()))
+ background->setZ(-1);
+ if (isComponentComplete())
+ d->resizeBackground();
}
+ emit backgroundChanged();
}
/*!
@@ -302,14 +303,15 @@ QString QQuickTextField::placeholderText() const
void QQuickTextField::setPlaceholderText(const QString &text)
{
Q_D(QQuickTextField);
- if (d->placeholder != text) {
- d->placeholder = text;
+ if (d->placeholder == text)
+ return;
+
+ d->placeholder = text;
#ifndef QT_NO_ACCESSIBILITY
- if (d->accessibleAttached)
- d->accessibleAttached->setDescription(text);
+ if (d->accessibleAttached)
+ d->accessibleAttached->setDescription(text);
#endif
- emit placeholderTextChanged();
- }
+ emit placeholderTextChanged();
}
/*!
@@ -340,10 +342,11 @@ Qt::FocusReason QQuickTextField::focusReason() const
void QQuickTextField::setFocusReason(Qt::FocusReason reason)
{
Q_D(QQuickTextField);
- if (d->focusReason != reason) {
- d->focusReason = reason;
- emit focusReasonChanged();
- }
+ if (d->focusReason == reason)
+ return;
+
+ d->focusReason = reason;
+ emit focusReasonChanged();
}
void QQuickTextField::classBegin()
diff --git a/src/templates/qquicktextfield_p.h b/src/templates/qquicktextfield_p.h
index 23658cc6..ee5f3470 100644
--- a/src/templates/qquicktextfield_p.h
+++ b/src/templates/qquicktextfield_p.h
@@ -68,7 +68,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickTextField : public QQuickTextInput
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
public:
- explicit QQuickTextField(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickTextField(QQuickItem *parent = nullptr);
~QQuickTextField();
QFont font() const;
@@ -93,18 +93,18 @@ Q_SIGNALS:
void pressAndHold(QQuickMouseEvent *mouse);
protected:
- void classBegin() Q_DECL_OVERRIDE;
-
- void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) Q_DECL_OVERRIDE;
-
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void classBegin() override;
+
+ void itemChange(ItemChange change, const ItemChangeData &value) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override;
+
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void timerEvent(QTimerEvent *event) override;
private:
Q_DISABLE_COPY(QQuickTextField)
diff --git a/src/templates/qquicktextfield_p_p.h b/src/templates/qquicktextfield_p_p.h
index 29b01f15..3f799a5f 100644
--- a/src/templates/qquicktextfield_p_p.h
+++ b/src/templates/qquicktextfield_p_p.h
@@ -78,18 +78,18 @@ public:
void resizeBackground();
void resolveFont();
- qreal getImplicitWidth() const Q_DECL_OVERRIDE;
- qreal getImplicitHeight() const Q_DECL_OVERRIDE;
+ qreal getImplicitWidth() const override;
+ qreal getImplicitHeight() const override;
- void implicitWidthChanged() Q_DECL_OVERRIDE;
- void implicitHeightChanged() Q_DECL_OVERRIDE;
+ void implicitWidthChanged() override;
+ void implicitHeightChanged() override;
void _q_readOnlyChanged(bool isReadOnly);
void _q_echoModeChanged(QQuickTextField::EchoMode echoMode);
#ifndef QT_NO_ACCESSIBILITY
- void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE;
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ void accessibilityActiveChanged(bool active) override;
+ QAccessible::Role accessibleRole() const override;
#endif
QQuickItem *background;
diff --git a/src/templates/qquicktoolbar.cpp b/src/templates/qquicktoolbar.cpp
index 882834e3..6bc8f4d9 100644
--- a/src/templates/qquicktoolbar.cpp
+++ b/src/templates/qquicktoolbar.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquicktoolbar_p.h"
+#include "qquickframe_p_p.h"
QT_BEGIN_NAMESPACE
@@ -44,7 +45,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickToolBar
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-containers
- \brief A tool bar control.
+ \brief A container with context-sensitive controls.
ToolBar is a container of application-wide and context sensitive
actions and controls, such as navigation buttons and search fields.
@@ -91,11 +92,51 @@ QT_BEGIN_NAMESPACE
\sa ApplicationWindow, ToolButton, {Customizing ToolBar}, {Container Controls}
*/
+class QQuickToolBarPrivate : public QQuickFramePrivate
+{
+public:
+ QQuickToolBarPrivate() : position(QQuickToolBar::Header) { }
+
+ QQuickToolBar::Position position;
+};
+
QQuickToolBar::QQuickToolBar(QQuickItem *parent) :
- QQuickFrame(parent)
+ QQuickFrame(*(new QQuickToolBarPrivate), parent)
{
}
+/*!
+ \qmlproperty enumeration Qt.labs.controls::ToolBar::position
+
+ This property holds the position of the toolbar.
+
+ \note If the toolbar is assigned as a header or footer of ApplicationWindow
+ or Page, the appropriate position is set automatically.
+
+ Possible values:
+ \value ToolBar.Header The toolbar is at the top, as a window or page header.
+ \value ToolBar.Footer The toolbar is at the bottom, as a window or page footer.
+
+ The default value is style-specific.
+
+ \sa ApplicationWindow::header, ApplicationWindow::footer, Page::header, Page::footer
+*/
+QQuickToolBar::Position QQuickToolBar::position() const
+{
+ Q_D(const QQuickToolBar);
+ return d->position;
+}
+
+void QQuickToolBar::setPosition(Position position)
+{
+ Q_D(QQuickToolBar);
+ if (d->position == position)
+ return;
+
+ d->position = position;
+ emit positionChanged();
+}
+
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role QQuickToolBar::accessibleRole() const
{
diff --git a/src/templates/qquicktoolbar_p.h b/src/templates/qquicktoolbar_p.h
index 501f74c7..f6625847 100644
--- a/src/templates/qquicktoolbar_p.h
+++ b/src/templates/qquicktoolbar_p.h
@@ -52,17 +52,36 @@
QT_BEGIN_NAMESPACE
+class QQuickToolBarPrivate;
+
class Q_LABSTEMPLATES_EXPORT QQuickToolBar : public QQuickFrame
{
Q_OBJECT
+ Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL)
public:
- explicit QQuickToolBar(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickToolBar(QQuickItem *parent = nullptr);
+
+ enum Position {
+ Header,
+ Footer
+ };
+ Q_ENUM(Position)
+
+ Position position() const;
+ void setPosition(Position position);
+
+Q_SIGNALS:
+ void positionChanged();
protected:
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::Role accessibleRole() const Q_DECL_OVERRIDE;
+ QAccessible::Role accessibleRole() const override;
#endif
+
+private:
+ Q_DISABLE_COPY(QQuickToolBar)
+ Q_DECLARE_PRIVATE(QQuickToolBar)
};
QT_END_NAMESPACE
diff --git a/src/templates/qquicktoolbutton.cpp b/src/templates/qquicktoolbutton.cpp
index 775eedd1..d04358f5 100644
--- a/src/templates/qquicktoolbutton.cpp
+++ b/src/templates/qquicktoolbutton.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickToolButton
\inqmlmodule Qt.labs.controls
\ingroup qtlabscontrols-buttons
- \brief A tool button control.
+ \brief A button with a layout suitable for a ToolBar.
ToolButton is functionally similar to \l Button, but provides a look that
is more suitable within a \l ToolBar.
diff --git a/src/templates/qquicktoolbutton_p.h b/src/templates/qquicktoolbutton_p.h
index 25f2134d..a4b4d227 100644
--- a/src/templates/qquicktoolbutton_p.h
+++ b/src/templates/qquicktoolbutton_p.h
@@ -57,10 +57,10 @@ class Q_LABSTEMPLATES_EXPORT QQuickToolButton : public QQuickButton
Q_OBJECT
public:
- explicit QQuickToolButton(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickToolButton(QQuickItem *parent = nullptr);
protected:
- QFont defaultFont() const Q_DECL_OVERRIDE;
+ QFont defaultFont() const override;
};
QT_END_NAMESPACE
diff --git a/src/templates/qquicktumbler.cpp b/src/templates/qquicktumbler.cpp
index c5b3f676..38447f6b 100644
--- a/src/templates/qquicktumbler.cpp
+++ b/src/templates/qquicktumbler.cpp
@@ -77,7 +77,7 @@ class QQuickTumblerPrivate : public QQuickControlPrivate, public QQuickItemChang
public:
QQuickTumblerPrivate() :
- delegate(Q_NULLPTR),
+ delegate(nullptr),
visibleItemCount(3)
{
}
@@ -93,8 +93,8 @@ public:
void _q_updateItemHeights();
void _q_updateItemWidths();
- void itemChildAdded(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
- void itemChildRemoved(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
+ void itemChildAdded(QQuickItem *, QQuickItem *) override;
+ void itemChildRemoved(QQuickItem *, QQuickItem *) override;
};
static QList<QQuickItem *> contentItemChildItems(QQuickItem *contentItem)
@@ -126,7 +126,7 @@ namespace {
else if (contentType == ListViewContentItem)
return qobject_cast<QQuickFlickable*>(rootContentItem)->contentItem();
- return Q_NULLPTR;
+ return nullptr;
}
static inline ContentItemType contentItemType(QQuickItem *rootContentItem)
@@ -158,7 +158,8 @@ void QQuickTumblerPrivate::_q_updateItemHeights()
// which doesn't affect them, only their getters.
Q_Q(const QQuickTumbler);
const qreal itemHeight = delegateHeight(q);
- foreach (QQuickItem *childItem, contentItemChildItems(contentItem))
+ const auto items = contentItemChildItems(contentItem);
+ for (QQuickItem *childItem : items)
childItem->setHeight(itemHeight);
}
@@ -166,7 +167,8 @@ void QQuickTumblerPrivate::_q_updateItemWidths()
{
Q_Q(const QQuickTumbler);
const qreal availableWidth = q->availableWidth();
- foreach (QQuickItem *childItem, contentItemChildItems(contentItem))
+ const auto items = contentItemChildItems(contentItem);
+ for (QQuickItem *childItem : items)
childItem->setWidth(availableWidth);
}
@@ -211,10 +213,11 @@ QVariant QQuickTumbler::model() const
void QQuickTumbler::setModel(const QVariant &model)
{
Q_D(QQuickTumbler);
- if (model != d->model) {
- d->model = model;
- emit modelChanged();
- }
+ if (model == d->model)
+ return;
+
+ d->model = model;
+ emit modelChanged();
}
/*!
@@ -255,7 +258,7 @@ void QQuickTumbler::setCurrentIndex(int currentIndex)
QQuickItem *QQuickTumbler::currentItem() const
{
Q_D(const QQuickTumbler);
- return d->contentItem ? d->contentItem->property("currentItem").value<QQuickItem*>() : Q_NULLPTR;
+ return d->contentItem ? d->contentItem->property("currentItem").value<QQuickItem*>() : nullptr;
}
/*!
@@ -272,10 +275,11 @@ QQmlComponent *QQuickTumbler::delegate() const
void QQuickTumbler::setDelegate(QQmlComponent *delegate)
{
Q_D(QQuickTumbler);
- if (delegate != d->delegate) {
- d->delegate = delegate;
- emit delegateChanged();
- }
+ if (delegate == d->delegate)
+ return;
+
+ d->delegate = delegate;
+ emit delegateChanged();
}
/*!
@@ -293,11 +297,12 @@ int QQuickTumbler::visibleItemCount() const
void QQuickTumbler::setVisibleItemCount(int visibleItemCount)
{
Q_D(QQuickTumbler);
- if (visibleItemCount != d->visibleItemCount) {
- d->visibleItemCount = visibleItemCount;
- d->_q_updateItemHeights();
- emit visibleItemCountChanged();
- }
+ if (visibleItemCount == d->visibleItemCount)
+ return;
+
+ d->visibleItemCount = visibleItemCount;
+ d->_q_updateItemHeights();
+ emit visibleItemCountChanged();
}
QQuickTumblerAttached *QQuickTumbler::qmlAttachedProperties(QObject *object)
@@ -305,7 +310,7 @@ QQuickTumblerAttached *QQuickTumbler::qmlAttachedProperties(QObject *object)
QQuickItem *delegateItem = qobject_cast<QQuickItem *>(object);
if (!delegateItem) {
qWarning() << "Tumbler: attached properties of Tumbler must be accessed from within a delegate item";
- return Q_NULLPTR;
+ return nullptr;
}
return new QQuickTumblerAttached(delegateItem);
@@ -398,7 +403,7 @@ class QQuickTumblerAttachedPrivate : public QObjectPrivate, public QQuickItemCha
Q_DECLARE_PUBLIC(QQuickTumblerAttached)
public:
QQuickTumblerAttachedPrivate(QQuickItem *delegateItem) :
- tumbler(Q_NULLPTR),
+ tumbler(nullptr),
index(-1),
displacement(1)
{
@@ -427,9 +432,9 @@ public:
~QQuickTumblerAttachedPrivate() {
}
- void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void itemChildAdded(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
- void itemChildRemoved(QQuickItem *, QQuickItem *) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void itemChildAdded(QQuickItem *, QQuickItem *) override;
+ void itemChildRemoved(QQuickItem *, QQuickItem *) override;
void _q_calculateDisplacement();
@@ -472,8 +477,9 @@ void QQuickTumblerAttachedPrivate::_q_calculateDisplacement()
const int previousDisplacement = displacement;
displacement = 0;
+ const int count = tumbler->count();
// This can happen in tests, so it may happen in normal usage too.
- if (tumbler->count() == 0)
+ if (count == 0)
return;
ContentItemType contentType = contentItemType(tumbler->contentItem());
@@ -485,12 +491,12 @@ void QQuickTumblerAttachedPrivate::_q_calculateDisplacement()
if (contentType == PathViewContentItem) {
offset = tumbler->contentItem()->property("offset").toReal();
- displacement = tumbler->count() - index - offset;
+ displacement = count - index - offset;
int halfVisibleItems = tumbler->visibleItemCount() / 2 + 1;
if (displacement > halfVisibleItems)
- displacement -= tumbler->count();
+ displacement -= count;
else if (displacement < -halfVisibleItems)
- displacement += tumbler->count();
+ displacement += count;
} else {
const qreal contentY = tumbler->contentItem()->property("contentY").toReal();
const qreal delegateH = delegateHeight(tumbler);
diff --git a/src/templates/qquicktumbler_p.h b/src/templates/qquicktumbler_p.h
index ad57acbb..6c329496 100644
--- a/src/templates/qquicktumbler_p.h
+++ b/src/templates/qquicktumbler_p.h
@@ -68,7 +68,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickTumbler : public QQuickControl
Q_PROPERTY(int visibleItemCount READ visibleItemCount WRITE setVisibleItemCount NOTIFY visibleItemCountChanged FINAL)
public:
- explicit QQuickTumbler(QQuickItem *parent = Q_NULLPTR);
+ explicit QQuickTumbler(QQuickItem *parent = nullptr);
~QQuickTumbler();
QVariant model() const;
@@ -97,10 +97,10 @@ Q_SIGNALS:
void visibleItemCountChanged();
protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
- void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void componentComplete() override;
+ void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
+ void keyPressEvent(QKeyEvent *event) override;
private:
Q_DISABLE_COPY(QQuickTumbler)
diff --git a/sync.profile b/sync.profile
index ae91c340..df83dc81 100644
--- a/sync.profile
+++ b/sync.profile
@@ -15,6 +15,5 @@
"qtbase" => "",
"qtxmlpatterns" => "",
"qtdeclarative" => "",
- "qtquickcontrols" => "",
"qtgraphicaleffects" => ""
);
diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
index 08ecdda2..93601359 100644
--- a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
+++ b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
@@ -143,6 +143,7 @@ Item {
SpinBox {
id: spinbox
objectName: "spinbox"
+ editable: true
value: 50
}
// StackView
diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
index c618a2d5..951611f2 100644
--- a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
+++ b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
@@ -60,11 +60,9 @@ private slots:
void allControls();
void textControls();
+
private:
QQmlEngine engine;
- bool qt_tab_all_controls() {
- return QGuiApplication::styleHints()->tabFocusBehavior() == Qt::TabFocusAllControls;
- }
};
tst_activeFocusOnTab::tst_activeFocusOnTab()
@@ -82,8 +80,7 @@ void tst_activeFocusOnTab::cleanup()
void tst_activeFocusOnTab::allControls()
{
- if (!qt_tab_all_controls())
- QSKIP("This platform iterates only text controls. Cannot test iterating all controls.");
+ QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusAllControls);
QQuickView *window = new QQuickView(0);
window->setBaseSize(QSize(800,600));
@@ -428,12 +425,13 @@ void tst_activeFocusOnTab::allControls()
QVERIFY(item->hasActiveFocus());
delete window;
+
+ QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusBehavior(-1));
}
void tst_activeFocusOnTab::textControls()
{
- if (qt_tab_all_controls())
- QSKIP("This platform iterates all controls. Cannot test iterating text controls only.");
+ QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusTextControls);
QQuickView *window = new QQuickView(0);
window->setBaseSize(QSize(800,600));
@@ -487,6 +485,8 @@ void tst_activeFocusOnTab::textControls()
QVERIFY(item->hasActiveFocus());
delete window;
+
+ QGuiApplication::styleHints()->setTabFocusBehavior(Qt::TabFocusBehavior(-1));
}
QTEST_MAIN(tst_activeFocusOnTab)
diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp
index d2937a6d..f78d1f66 100644
--- a/tests/auto/applicationwindow/tst_applicationwindow.cpp
+++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp
@@ -420,7 +420,7 @@ void tst_applicationwindow::attachedProperties()
QCOMPARE(childItem->property("attached_footer").value<QQuickItem *>(), childAppWindow->footer());
QCOMPARE(childItem->property("attached_overlay").value<QQuickItem *>(), childAppWindow->overlay());
- childControl->setParentItem(Q_NULLPTR);
+ childControl->setParentItem(nullptr);
QVERIFY(!childControl->window());
QVERIFY(!childControl->property("attached_window").value<QQuickApplicationWindow *>());
QVERIFY(!childControl->property("attached_contentItem").value<QQuickItem *>());
@@ -429,7 +429,7 @@ void tst_applicationwindow::attachedProperties()
QVERIFY(!childControl->property("attached_footer").value<QQuickItem *>());
QVERIFY(!childControl->property("attached_overlay").value<QQuickItem *>());
- childItem->setParentItem(Q_NULLPTR);
+ childItem->setParentItem(nullptr);
QVERIFY(!childItem->window());
QVERIFY(!childItem->property("attached_window").value<QQuickApplicationWindow *>());
QVERIFY(!childItem->property("attached_contentItem").value<QQuickItem *>());
@@ -507,7 +507,7 @@ public:
{ QGuiApplicationPrivate::platform_theme = this; }
~TestTheme() { QGuiApplicationPrivate::platform_theme = theme(); }
- const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE
+ const QFont *font(Font type = SystemFont) const override
{
Q_UNUSED(type);
return &m_font;
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index ec9d4111..25ee9176 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,7 +1,6 @@
TEMPLATE = subdirs
SUBDIRS += \
accessibility \
- activeFocusOnTab \
applicationwindow \
calendar \
controls \
@@ -13,3 +12,7 @@ SUBDIRS += \
snippets \
styles \
universal
+
+# QTBUG-50295
+!linux: SUBDIRS += \
+ activeFocusOnTab
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index 45fad8cb..4127fbf2 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -228,7 +228,7 @@ TestCase {
function test_baseline() {
var control = button.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml
index 4efc7223..7e0c88e4 100644
--- a/tests/auto/controls/data/tst_checkbox.qml
+++ b/tests/auto/controls/data/tst_checkbox.qml
@@ -421,7 +421,7 @@ TestCase {
function test_baseline() {
var control = checkBox.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index b112f20c..6e593967 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.2
+//import QtQuick.Window 2.2
import QtTest 1.0
import Qt.labs.controls 1.0
@@ -46,10 +47,12 @@ TestCase {
id: testCase
width: 200
height: 200
+// visible: true
+// when: windowShown
name: "ComboBox"
ApplicationWindow {
- id: window
+ id: applicationWindow
visible: true
width: 400
height: 400
@@ -74,11 +77,6 @@ TestCase {
}
}
- function initTestCase() {
- window.requestActivate()
- tryCompare(window, "active", true)
- }
-
function init() {
verify(!activatedSpy.target)
compare(activatedSpy.count, 0)
@@ -96,7 +94,7 @@ TestCase {
}
function test_defaults() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
compare(control.count, 0)
@@ -112,7 +110,7 @@ TestCase {
}
function test_array() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
var items = [ "Banana", "Apple", "Coconut" ]
@@ -138,7 +136,7 @@ TestCase {
}
function test_objects() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
var items = [
@@ -168,7 +166,7 @@ TestCase {
}
function test_number() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
control.model = 10
@@ -201,7 +199,7 @@ TestCase {
}
function test_listModel() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
control.model = listmodel
@@ -245,7 +243,7 @@ TestCase {
}
function test_textRole(data) {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
control.model = data.model
@@ -273,7 +271,7 @@ TestCase {
}
function test_textAt() {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
control.model = ["Apple", "Orange", "Banana"]
@@ -315,7 +313,7 @@ TestCase {
}
function test_find(data) {
- var control = comboBox.createObject(window.contentItem)
+ var control = comboBox.createObject(testCase)
verify(control)
control.model = ["Banana", "banana", "Coconut", "Apple", "Cocomuffin"]
@@ -325,10 +323,20 @@ TestCase {
control.destroy()
}
- function test_arrowKeys() {
- var control = comboBox.createObject(window.contentItem, {model: 3})
+ function test_arrowKeys_data() {
+ return [
+// { tag: "Window", window: testCase.Window.window },
+ { tag: "ApplicationWindow", window: applicationWindow }
+ ]
+ }
+
+ function test_arrowKeys(data) {
+ var control = comboBox.createObject(data.window.contentItem, {model: 3})
verify(control)
+ data.window.requestActivate()
+ tryCompare(data.window, "active", true)
+
activatedSpy.target = control
verify(activatedSpy.valid)
@@ -456,22 +464,35 @@ TestCase {
function test_keys_data() {
return [
- { tag: "space-space", key1: Qt.Key_Space, key2: Qt.Key_Space, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
- { tag: "space-enter", key1: Qt.Key_Space, key2: Qt.Key_Enter, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
- { tag: "space-return", key1: Qt.Key_Space, key2: Qt.Key_Return, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
- { tag: "space-escape", key1: Qt.Key_Space, key2: Qt.Key_Escape, showPopup: true, showPress: true, hidePopup: true, hidePress: false },
- { tag: "space-0", key1: Qt.Key_Space, key2: Qt.Key_0, showPopup: true, showPress: true, hidePopup: false, hidePress: false },
-
- { tag: "enter-enter", key1: Qt.Key_Enter, key2: Qt.Key_Enter, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
- { tag: "return-return", key1: Qt.Key_Return, key2: Qt.Key_Return, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
- { tag: "escape-escape", key1: Qt.Key_Escape, key2: Qt.Key_Escape, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+// { tag: "Window: space-space", window: testCase.Window.window, key1: Qt.Key_Space, key2: Qt.Key_Space, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+// { tag: "Window: space-enter", window: testCase.Window.window, key1: Qt.Key_Space, key2: Qt.Key_Enter, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+// { tag: "Window: space-return", window: testCase.Window.window, key1: Qt.Key_Space, key2: Qt.Key_Return, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+// { tag: "Window: space-escape", window: testCase.Window.window, key1: Qt.Key_Space, key2: Qt.Key_Escape, showPopup: true, showPress: true, hidePopup: true, hidePress: false },
+// { tag: "Window: space-0", window: testCase.Window.window, key1: Qt.Key_Space, key2: Qt.Key_0, showPopup: true, showPress: true, hidePopup: false, hidePress: false },
+// { tag: "Window: enter-enter", window: testCase.Window.window, key1: Qt.Key_Enter, key2: Qt.Key_Enter, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+// { tag: "Window: return-return", window: testCase.Window.window, key1: Qt.Key_Return, key2: Qt.Key_Return, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+// { tag: "Window: escape-escape", window: testCase.Window.window, key1: Qt.Key_Escape, key2: Qt.Key_Escape, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+
+ { tag: "ApplicationWindow: space-space", window: applicationWindow, key1: Qt.Key_Space, key2: Qt.Key_Space, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+ { tag: "ApplicationWindow: space-enter", window: applicationWindow, key1: Qt.Key_Space, key2: Qt.Key_Enter, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+ { tag: "ApplicationWindow: space-return", window: applicationWindow, key1: Qt.Key_Space, key2: Qt.Key_Return, showPopup: true, showPress: true, hidePopup: true, hidePress: true },
+ { tag: "ApplicationWindow: space-escape", window: applicationWindow, key1: Qt.Key_Space, key2: Qt.Key_Escape, showPopup: true, showPress: true, hidePopup: true, hidePress: false },
+ { tag: "ApplicationWindow: space-0", window: applicationWindow, key1: Qt.Key_Space, key2: Qt.Key_0, showPopup: true, showPress: true, hidePopup: false, hidePress: false },
+ { tag: "ApplicationWindow: enter-enter", window: applicationWindow, key1: Qt.Key_Enter, key2: Qt.Key_Enter, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+ { tag: "ApplicationWindow: return-return", window: applicationWindow, key1: Qt.Key_Return, key2: Qt.Key_Return, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
+ { tag: "ApplicationWindow: escape-escape", window: applicationWindow, key1: Qt.Key_Escape, key2: Qt.Key_Escape, showPopup: false, showPress: false, hidePopup: true, hidePress: false },
]
}
function test_keys(data) {
- var control = comboBox.createObject(window.contentItem, {model: 3})
+ var control = comboBox.createObject(data.window.contentItem, {model: 3})
verify(control)
+ data.window.requestActivate()
+ tryCompare(data.window, "active", true)
+
+ waitForRendering(control)
+
control.forceActiveFocus()
verify(control.activeFocus)
@@ -497,8 +518,15 @@ TestCase {
control.destroy()
}
- function test_popup() {
- var control = comboBox.createObject(window.contentItem, {model: 3})
+ function test_popup_data() {
+ return [
+// { tag: "Window", window: testCase.Window.window },
+ { tag: "ApplicationWindow", window: applicationWindow }
+ ]
+ }
+
+ function test_popup(data) {
+ var control = comboBox.createObject(data.window.contentItem, {model: 3})
verify(control)
// show below
@@ -516,7 +544,7 @@ TestCase {
tryCompare(control.popup, "visible", false)
// show above
- control.y = window.height - control.height
+ control.y = data.window.height - control.height
mousePress(control)
compare(control.pressed, true)
compare(control.popup.visible, false)
@@ -528,10 +556,20 @@ TestCase {
control.destroy()
}
- function test_mouse() {
- var control = comboBox.createObject(window.contentItem, {model: 3})
+ function test_mouse_data() {
+ return [
+// { tag: "Window", window: testCase.Window.window },
+ { tag: "ApplicationWindow", window: applicationWindow }
+ ]
+ }
+
+ function test_mouse(data) {
+ var control = comboBox.createObject(data.window.contentItem, {model: 3})
verify(control)
+ data.window.requestActivate()
+ tryCompare(data.window, "active", true)
+
activatedSpy.target = control
verify(activatedSpy.valid)
@@ -571,18 +609,29 @@ TestCase {
control.destroy()
}
- function test_focus() {
- var control = comboBox.createObject(window.contentItem, {model: 3})
+ function test_focus_data() {
+ return [
+// { tag: "Window", window: testCase.Window.window },
+ { tag: "ApplicationWindow", window: applicationWindow }
+ ]
+ }
+
+ function test_focus(data) {
+ var control = comboBox.createObject(data.window.contentItem, {model: 3})
verify(control)
+ data.window.requestActivate()
+ tryCompare(data.window, "active", true)
+
+ waitForRendering(control)
+
// click - gain focus - show popup
mouseClick(control)
verify(control.activeFocus)
compare(control.popup.visible, true)
// lose focus - hide popup
- window.contentItem.forceActiveFocus()
- verify(window.contentItem.activeFocus)
+ control.focus = false
verify(!control.activeFocus)
tryCompare(control.popup, "visible", false)
@@ -671,16 +720,13 @@ TestCase {
}
function test_font() { // QTBUG_50984
- var control = component.createObject(window.contentItem)
+ var control = component.createObject(applicationWindow.contentItem)
verify(control)
verify(control.button)
verify(control.combobox)
waitForRendering(control)
- control.forceActiveFocus()
- verify(control.activeFocus)
-
compare(control.font.pixelSize, 30)
compare(control.button.font.pixelSize, 20)
compare(control.combobox.font.pixelSize, 30)
@@ -717,4 +763,27 @@ TestCase {
control.destroy()
}
+
+ function test_wheel(data) {
+ var control = comboBox.createObject(applicationWindow.contentItem, {model: 2, wheelEnabled: true})
+ verify(control)
+
+ var delta = 120
+
+ mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta)
+ compare(control.currentIndex, 1)
+
+ // reached bounds -> no change
+ mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta)
+ compare(control.currentIndex, 1)
+
+ mouseWheel(control, control.width / 2, control.height / 2, delta, delta)
+ compare(control.currentIndex, 0)
+
+ // reached bounds -> no change
+ mouseWheel(control, control.width / 2, control.height / 2, delta, delta)
+ compare(control.currentIndex, 0)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index 7fe61064..9d63f429 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -56,6 +56,11 @@ TestCase {
T.Control { }
}
+ Component {
+ id: button
+ T.Button { }
+ }
+
SignalSpy {
id: mirroredSpy
signalName: "mirroredChanged"
@@ -849,4 +854,65 @@ TestCase {
control.destroy()
}
+
+ function test_focusPolicy() {
+ var control = button.createObject(testCase, {width: 100, height: 100})
+ verify(control)
+
+ // Qt.TabFocus vs. Item::activeFocusOnTab
+ control.activeFocusOnTab = true
+ compare(control.focusPolicy, Qt.TabFocus)
+ control.activeFocusOnTab = false
+ compare(control.focusPolicy, Qt.NoFocus)
+
+ control.focusPolicy = Qt.TabFocus
+ compare(control.focusPolicy, Qt.TabFocus)
+ compare(control.activeFocusOnTab, true)
+
+ // Qt.ClickFocus
+ mouseClick(control)
+ verify(!control.activeFocus)
+
+ control.focusPolicy = Qt.ClickFocus
+ compare(control.focusPolicy, Qt.ClickFocus)
+
+ mouseClick(control)
+ verify(control.activeFocus)
+
+ control.focus = false
+ verify(!control.activeFocus)
+
+ // Qt.WheelFocus
+ mouseWheel(control, control.width / 2, control.height / 2, 10)
+ verify(!control.activeFocus)
+
+ control.focusPolicy = Qt.WheelFocus
+ compare(control.focusPolicy, Qt.WheelFocus)
+
+ mouseWheel(control, control.width / 2, control.height / 2, 10)
+ verify(control.activeFocus)
+
+ control.destroy()
+ }
+
+ function test_hover() {
+ var control = component.createObject(testCase, {width: 100, height: 100})
+ verify(control)
+
+ compare(control.hovered, false)
+ compare(control.hoverEnabled, false)
+
+ mouseMove(control, control.width / 2, control.height / 2)
+ compare(control.hovered, false)
+
+ control.hoverEnabled = true
+
+ mouseMove(control, control.width / 2, control.height / 2)
+ compare(control.hovered, true)
+
+ mouseMove(control, -10, -10)
+ compare(control.hovered, false)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_itemdelegate.qml b/tests/auto/controls/data/tst_itemdelegate.qml
index e2f78ac5..f2fd3794 100644
--- a/tests/auto/controls/data/tst_itemdelegate.qml
+++ b/tests/auto/controls/data/tst_itemdelegate.qml
@@ -58,7 +58,7 @@ TestCase {
function test_baseline() {
var control = itemDelegate.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_menuitem.qml b/tests/auto/controls/data/tst_menuitem.qml
index 8581a43f..8c9bc71b 100644
--- a/tests/auto/controls/data/tst_menuitem.qml
+++ b/tests/auto/controls/data/tst_menuitem.qml
@@ -58,7 +58,7 @@ TestCase {
function test_baseline() {
var control = menuItem.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
index d4cdf0ad..1b105f08 100644
--- a/tests/auto/controls/data/tst_radiobutton.qml
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -312,7 +312,7 @@ TestCase {
function test_baseline() {
var control = radioButton.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 53e2fb8f..7b38f440 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -471,4 +471,51 @@ TestCase {
control.destroy()
}
+
+ 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 = slider.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_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index cdea8b66..e76725b6 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -87,6 +87,7 @@ TestCase {
compare(control.to, 99)
compare(control.value, 0)
compare(control.stepSize, 1)
+ compare(control.editable, false)
compare(control.up.pressed, false)
compare(control.down.pressed, false)
@@ -326,4 +327,62 @@ TestCase {
control.destroy()
}
+
+ function test_editable() {
+ var control = spinBox.createObject(testCase)
+ verify(control)
+
+ control.contentItem.forceActiveFocus()
+ compare(control.contentItem.activeFocus, true)
+
+ compare(control.editable, false)
+ control.contentItem.selectAll()
+ keyClick(Qt.Key_5)
+ keyClick(Qt.Key_Return)
+ compare(control.value, 0)
+
+ control.editable = true
+ compare(control.editable, true)
+ control.contentItem.selectAll()
+ keyClick(Qt.Key_5)
+ keyClick(Qt.Key_Return)
+ compare(control.value, 5)
+
+ control.destroy()
+ }
+
+ function test_wheel(data) {
+ var control = spinBox.createObject(testCase, {wheelEnabled: true})
+ verify(control)
+
+ var delta = 120
+
+ compare(control.value, 0)
+
+ mouseWheel(control, control.width / 2, control.height / 2, delta, delta)
+ compare(control.value, 1)
+
+ control.stepSize = 2
+
+ mouseWheel(control, control.width / 2, control.height / 2, delta, delta)
+ compare(control.value, 3)
+
+ control.stepSize = 10
+
+ mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta)
+ compare(control.value, 0)
+
+ control.stepSize = 5
+
+ mouseWheel(control, control.width / 2, control.height / 2, delta, delta)
+ compare(control.value, 5)
+
+ mouseWheel(control, control.width / 2, control.height / 2, 0.5 * delta, 0.5 * delta)
+ compare(control.value, 8)
+
+ mouseWheel(control, control.width / 2, control.height / 2, -delta, -delta)
+ compare(control.value, 3)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index 13924ed0..7443f330 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -260,7 +260,7 @@ TestCase {
function test_baseline() {
var control = swtch.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_tabbutton.qml b/tests/auto/controls/data/tst_tabbutton.qml
index 3a817cfd..f755c081 100644
--- a/tests/auto/controls/data/tst_tabbutton.qml
+++ b/tests/auto/controls/data/tst_tabbutton.qml
@@ -85,7 +85,7 @@ TestCase {
function test_baseline() {
var control = tabButton.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml
index 63a87ec2..6c03f18c 100644
--- a/tests/auto/controls/data/tst_toolbutton.qml
+++ b/tests/auto/controls/data/tst_toolbutton.qml
@@ -173,7 +173,7 @@ TestCase {
function test_baseline() {
var control = toolButton.createObject(testCase)
verify(control)
- compare(control.baselineOffset, control.label.y + control.label.baselineOffset)
+ compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
}
diff --git a/tests/auto/pressandhold/data/dependencies.qml b/tests/auto/pressandhold/data/dependencies.qml
new file mode 100644
index 00000000..13690bbc
--- /dev/null
+++ b/tests/auto/pressandhold/data/dependencies.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.6
+import Qt.labs.controls 1.0
+
+Control { }
diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp
index 8c4cf673..f61c9f56 100644
--- a/tests/auto/pressandhold/tst_pressandhold.cpp
+++ b/tests/auto/pressandhold/tst_pressandhold.cpp
@@ -37,13 +37,14 @@
#include <QtTest>
#include <QtQuick>
-// TODO: add QStyleHints::setMousePressAndHoldInterval() to speedup the test
-
class tst_PressAndHold : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
void pressAndHold_data();
void pressAndHold();
@@ -51,6 +52,16 @@ private slots:
void keepSelection();
};
+void tst_PressAndHold::initTestCase()
+{
+ QGuiApplication::styleHints()->setMousePressAndHoldInterval(100);
+}
+
+void tst_PressAndHold::cleanupTestCase()
+{
+ QGuiApplication::styleHints()->setMousePressAndHoldInterval(-1);
+}
+
void tst_PressAndHold::pressAndHold_data()
{
QTest::addColumn<QByteArray>("data");
diff --git a/tests/auto/sanity/data/dependencies.qml b/tests/auto/sanity/data/dependencies.qml
new file mode 100644
index 00000000..13690bbc
--- /dev/null
+++ b/tests/auto/sanity/data/dependencies.qml
@@ -0,0 +1,4 @@
+import QtQuick 2.6
+import Qt.labs.controls 1.0
+
+Control { }
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index bc114d62..7f438721 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -267,14 +267,18 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt
// the engine's import path. This way we can use QQmlComponent to load each QML file
// for benchmarking.
- QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
+ QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
foreach (const QFileInfo &entry, entries) {
QString name = entry.baseName();
if (!skiplist.contains(name)) {
foreach (const QString &importPath, engine->importPathList()) {
- QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName());
+ QString name = entry.dir().dirName() + "/" + entry.fileName();
+ QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName();
if (QFile::exists(filePath)) {
- QTest::newRow(qPrintable(entry.dir().dirName() + "/" + entry.fileName())) << QUrl::fromLocalFile(filePath);
+ QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
+ break;
+ } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) {
+ QTest::newRow(qPrintable(name)) << QUrl(filePath);
break;
}
}
@@ -305,10 +309,10 @@ void tst_Sanity::attachedObjects()
void tst_Sanity::attachedObjects_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/calendar");
- addTestRows(&engine, "/controls");
- addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle");
- addTestRows(&engine, "/controls/universal");
+ addTestRows(&engine, "calendar");
+ addTestRows(&engine, "controls");
+ addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle");
+ addTestRows(&engine, "controls/universal");
}
QTEST_MAIN(tst_Sanity)
diff --git a/tests/auto/snippets/data/dependencies.qml b/tests/auto/snippets/data/dependencies.qml
new file mode 100644
index 00000000..15fa1a9a
--- /dev/null
+++ b/tests/auto/snippets/data/dependencies.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.6
+import QtQuick.Layouts 1.3
+import Qt.labs.controls 1.0
+import Qt.labs.calendar 1.0
+
+Control { }
diff --git a/tests/auto/styles/data/dependencies.qml b/tests/auto/styles/data/dependencies.qml
new file mode 100644
index 00000000..310fbf40
--- /dev/null
+++ b/tests/auto/styles/data/dependencies.qml
@@ -0,0 +1,7 @@
+import QtTest 1.0
+import QtQuick 2.6
+import Qt.labs.controls 1.0
+import Qt.labs.controls.material 1.0
+import Qt.labs.controls.universal 1.0
+
+Control { }
diff --git a/tests/auto/styles/tst_styles.cpp b/tests/auto/styles/tst_styles.cpp
index b45366b6..fad28d85 100644
--- a/tests/auto/styles/tst_styles.cpp
+++ b/tests/auto/styles/tst_styles.cpp
@@ -62,6 +62,8 @@ int main(int argc, char *argv[])
process.start(argv[0], app.arguments().mid(1));
process.waitForFinished();
+ if (process.exitStatus() != QProcess::NormalExit)
+ return -1;
failures += process.exitCode();
}
diff --git a/tests/benchmarks/creationtime/data/dependencies.qml b/tests/benchmarks/creationtime/data/dependencies.qml
new file mode 100644
index 00000000..65fb0414
--- /dev/null
+++ b/tests/benchmarks/creationtime/data/dependencies.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.6
+import Qt.labs.controls 1.0
+import Qt.labs.controls.material 1.0
+import Qt.labs.controls.universal 1.0
+import Qt.labs.calendar 1.0
+
+Control { }
diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp
index 2a61b0ea..927dd17d 100644
--- a/tests/benchmarks/creationtime/tst_creationtime.cpp
+++ b/tests/benchmarks/creationtime/tst_creationtime.cpp
@@ -78,15 +78,19 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt
// the engine's import path. This way we can use QQmlComponent to load each QML file
// for benchmarking.
- QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
+ QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
foreach (const QFileInfo &entry, entries) {
QString name = entry.baseName();
if (!skiplist.contains(name)) {
foreach (const QString &importPath, engine->importPathList()) {
- QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName());
+ QString name = entry.dir().dirName() + "/" + entry.fileName();
+ QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName();
if (QFile::exists(filePath)) {
QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
break;
+ } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) {
+ QTest::newRow(qPrintable(name)) << QUrl(filePath);
+ break;
}
}
}
@@ -117,7 +121,7 @@ void tst_CreationTime::controls()
void tst_CreationTime::controls_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls");
+ addTestRows(&engine, "controls");
}
void tst_CreationTime::material()
@@ -129,7 +133,7 @@ void tst_CreationTime::material()
void tst_CreationTime::material_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle");
+ addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle");
}
void tst_CreationTime::universal()
@@ -141,7 +145,7 @@ void tst_CreationTime::universal()
void tst_CreationTime::universal_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls/universal");
+ addTestRows(&engine, "controls/universal");
}
void tst_CreationTime::calendar()
@@ -153,7 +157,7 @@ void tst_CreationTime::calendar()
void tst_CreationTime::calendar_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/calendar");
+ addTestRows(&engine, "calendar");
}
QTEST_MAIN(tst_CreationTime)
diff --git a/tests/benchmarks/objectcount/data/dependencies.qml b/tests/benchmarks/objectcount/data/dependencies.qml
new file mode 100644
index 00000000..65fb0414
--- /dev/null
+++ b/tests/benchmarks/objectcount/data/dependencies.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.6
+import Qt.labs.controls 1.0
+import Qt.labs.controls.material 1.0
+import Qt.labs.controls.universal 1.0
+import Qt.labs.calendar 1.0
+
+Control { }
diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp
index b479b0e2..51a968d0 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 1.3 as C1; import Qt.labs.controls 1.0 as C2; Row { C1.Button {} C2.Button {} }", QUrl());
+ component.setData("import QtQuick 2.0; import Qt.labs.controls 1.0; Item { Button {} }", QUrl());
delete component.create();
}
@@ -118,15 +118,19 @@ static void addTestRows(QQmlEngine *engine, const QString &targetPath, const QSt
// the engine's import path. This way we can use QQmlComponent to load each QML file
// for benchmarking.
- QFileInfoList entries = QDir(QQC2_IMPORT_PATH + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
+ QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + targetPath).entryInfoList(QStringList("*.qml"), QDir::Files);
foreach (const QFileInfo &entry, entries) {
QString name = entry.baseName();
if (!skiplist.contains(name)) {
foreach (const QString &importPath, engine->importPathList()) {
- QString filePath = QDir(importPath + "/Qt/labs/" + targetPath).absoluteFilePath(entry.fileName());
+ QString name = entry.dir().dirName() + "/" + entry.fileName();
+ QString filePath = importPath + "/Qt/labs/" + targetPath + "/" + entry.fileName();
if (QFile::exists(filePath)) {
QTest::newRow(qPrintable(name)) << QUrl::fromLocalFile(filePath);
break;
+ } else if (QFile::exists(QQmlFile::urlToLocalFileOrQrc(filePath))) {
+ QTest::newRow(qPrintable(name)) << QUrl(filePath);
+ break;
}
}
}
@@ -161,7 +165,7 @@ void tst_ObjectCount::calendar()
void tst_ObjectCount::calendar_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/calendar");
+ addTestRows(&engine, "calendar");
}
void tst_ObjectCount::controls()
@@ -173,7 +177,7 @@ void tst_ObjectCount::controls()
void tst_ObjectCount::controls_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls");
+ addTestRows(&engine, "controls");
}
void tst_ObjectCount::material()
@@ -185,7 +189,7 @@ void tst_ObjectCount::material()
void tst_ObjectCount::material_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls/material", QStringList() << "Ripple" << "SliderHandle");
+ addTestRows(&engine, "controls/material", QStringList() << "Ripple" << "SliderHandle");
}
void tst_ObjectCount::universal()
@@ -197,7 +201,7 @@ void tst_ObjectCount::universal()
void tst_ObjectCount::universal_data()
{
QTest::addColumn<QUrl>("url");
- addTestRows(&engine, "/controls/universal");
+ addTestRows(&engine, "controls/universal");
}
QTEST_MAIN(tst_ObjectCount)
diff --git a/tests/manual/gifs/eventcapturer.cpp b/tests/manual/gifs/eventcapturer.cpp
index 5b5905cd..83e1c76b 100644
--- a/tests/manual/gifs/eventcapturer.cpp
+++ b/tests/manual/gifs/eventcapturer.cpp
@@ -69,7 +69,7 @@
EventCapturer::EventCapturer(QObject *parent) :
QObject(parent),
- mEventSource(Q_NULLPTR),
+ mEventSource(nullptr),
mStopCaptureKey(Qt::Key_Escape),
mMoveEventTrimFlags(TrimNone),
mDuration(0),
diff --git a/tests/manual/gifs/eventcapturer.h b/tests/manual/gifs/eventcapturer.h
index b1f2b4ff..7982d6e9 100644
--- a/tests/manual/gifs/eventcapturer.h
+++ b/tests/manual/gifs/eventcapturer.h
@@ -74,7 +74,7 @@ public:
QVector<CapturedEvent> capturedEvents() const;
protected:
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *object, QEvent *event) override;
private slots:
void stopCapturing();
diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp
index 3ba33552..134ece2e 100644
--- a/tests/manual/gifs/gifrecorder.cpp
+++ b/tests/manual/gifs/gifrecorder.cpp
@@ -64,8 +64,8 @@ namespace {
}
GifRecorder::GifRecorder() :
- QObject(Q_NULLPTR),
- mWindow(Q_NULLPTR),
+ QObject(nullptr),
+ mWindow(nullptr),
mHighQuality(false),
mRecordingDuration(0),
mRecordCursor(false),
@@ -83,7 +83,7 @@ GifRecorder::GifRecorder() :
void GifRecorder::setRecordingDuration(int duration)
{
QVERIFY2(duration >= 1, qPrintable(QString::fromLatin1("Recording duration %1 must be larger than 1 second").arg(duration)));
- QVERIFY2(duration < 10, qPrintable(QString::fromLatin1("Recording duration %1 must be less than 10 seconds").arg(duration)));
+ QVERIFY2(duration < 20, qPrintable(QString::fromLatin1("Recording duration %1 must be less than 20 seconds").arg(duration)));
mRecordingDuration = duration;
}
diff --git a/tests/manual/viewinqwidget/main.cpp b/tests/manual/viewinqwidget/main.cpp
index ff949544..3611e071 100644
--- a/tests/manual/viewinqwidget/main.cpp
+++ b/tests/manual/viewinqwidget/main.cpp
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
const QUrl gallerySource(QLatin1String("qrc:/gallery.qml"));
QQmlApplicationEngine engine(gallerySource);
- QObject *root = engine.rootObjects().value(0, Q_NULLPTR);
+ QObject *root = engine.rootObjects().value(0, nullptr);
if (!root || !root->isWindowType()) {
qWarning() << "Load error" << gallerySource;
return 1;