summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-03-25 08:04:58 +0100
committerSergio Ahumada <sergio.ahumada@digia.com>2013-03-25 08:34:20 +0100
commit1d6b43c44b68d1983a77a7368c6cfff78f2d4cd0 (patch)
treeb5d752c2ded6c4ee2c3e32cee7aabe88bb881a44
parent716ca066c7f07371aaae79029c60996bc6e57118 (diff)
parent2e52c497f205460ee61e6f6940849c057adc7adb (diff)
downloadqtquickcontrols-1d6b43c44b68d1983a77a7368c6cfff78f2d4cd0.tar.gz
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle Conflicts: src/qtdesktop/CheckBox.qml src/qtdesktop/doc/qtdesktopcomponents.qdocconf Change-Id: Ic3799053a18b0a3f97e251354ad8433438b08a7a
-rw-r--r--.gitignore4
-rw-r--r--.qmake.conf2
-rw-r--r--LGPL_EXCEPTION.txt22
-rw-r--r--LICENSE.FDL450
-rw-r--r--LICENSE.GPL674
-rw-r--r--LICENSE.LGPL514
-rw-r--r--README2
-rw-r--r--examples/ApplicationTemplate/ApplicationTemplate.pro (renamed from examples/ApplicationTemplate/application.pro)0
-rw-r--r--examples/ApplicationTemplate/main.cpp6
-rw-r--r--examples/ApplicationTemplate/qml/main.qml29
-rw-r--r--examples/basiclayouts/basiclayouts.qmlproject16
-rw-r--r--examples/basiclayouts/main.qml149
-rw-r--r--examples/examples.pro9
-rw-r--r--examples/gallery/content/ChildWindow.qml39
-rw-r--r--examples/gallery/content/Controls.qml66
-rw-r--r--examples/gallery/content/ImageViewer.qml58
-rw-r--r--examples/gallery/content/ModelView.qml22
-rw-r--r--examples/gallery/content/Panel.qml18
-rw-r--r--examples/gallery/content/RangeTab.qml121
-rw-r--r--examples/gallery/content/Styles.qml71
-rw-r--r--examples/gallery/gallery.pro10
-rw-r--r--examples/gallery/main.qml189
-rw-r--r--examples/splitters/main.qml33
-rw-r--r--examples/splitters/splitters.pro4
-rw-r--r--examples/splitters/splitters.qmlproject16
-rw-r--r--examples/tableview/main.qml289
-rw-r--r--examples/tableview/tableview.pro4
-rw-r--r--examples/text/example.html79
-rw-r--r--examples/text/qml/images/editcopy.pngbin0 -> 1468 bytes
-rw-r--r--examples/text/qml/images/editcut.pngbin0 -> 1512 bytes
-rw-r--r--examples/text/qml/images/editpaste.pngbin0 -> 1906 bytes
-rw-r--r--examples/text/qml/images/editredo.pngbin0 -> 1752 bytes
-rw-r--r--examples/text/qml/images/editundo.pngbin0 -> 1746 bytes
-rw-r--r--examples/text/qml/images/exportpdf.pngbin0 -> 1215 bytes
-rw-r--r--examples/text/qml/images/filenew.pngbin0 -> 1172 bytes
-rw-r--r--examples/text/qml/images/fileopen.pngbin0 -> 2168 bytes
-rw-r--r--examples/text/qml/images/fileprint.pngbin0 -> 2087 bytes
-rw-r--r--examples/text/qml/images/filesave.pngbin0 -> 1206 bytes
-rw-r--r--examples/text/qml/images/logo32.pngbin0 -> 1410 bytes
-rw-r--r--examples/text/qml/images/textbold.pngbin0 -> 1611 bytes
-rw-r--r--examples/text/qml/images/textcenter.pngbin0 -> 1404 bytes
-rw-r--r--examples/text/qml/images/textitalic.pngbin0 -> 1164 bytes
-rw-r--r--examples/text/qml/images/textjustify.pngbin0 -> 1257 bytes
-rw-r--r--examples/text/qml/images/textleft.pngbin0 -> 1235 bytes
-rw-r--r--examples/text/qml/images/textright.pngbin0 -> 1406 bytes
-rw-r--r--examples/text/qml/images/textunder.pngbin0 -> 1183 bytes
-rw-r--r--examples/text/qml/images/zoomin.pngbin0 -> 1696 bytes
-rw-r--r--examples/text/qml/images/zoomout.pngbin0 -> 1662 bytes
-rw-r--r--examples/text/qml/main.qml261
-rw-r--r--examples/text/resources.qrc26
-rw-r--r--examples/text/src/documenthandler.cpp284
-rw-r--r--examples/text/src/documenthandler.h165
-rw-r--r--examples/text/src/main.cpp72
-rw-r--r--examples/text/src/src.pri9
-rw-r--r--examples/text/text.pro16
-rw-r--r--examples/touch/content/AndroidDelegate.qml10
-rw-r--r--examples/touch/content/ButtonPage.qml42
-rw-r--r--examples/touch/content/ProgressBarPage.qml22
-rw-r--r--examples/touch/content/SliderPage.qml47
-rw-r--r--examples/touch/content/TabBarPage.qml22
-rw-r--r--examples/touch/content/TextInputPage.qml27
-rw-r--r--examples/touch/main.qml16
-rw-r--r--examples/touch/touch.pro10
-rw-r--r--header.BSD5
-rw-r--r--qtquickcontrols.pro (renamed from qtdesktopcomponents.pro)2
-rw-r--r--src/controls/ApplicationWindow.qml183
-rw-r--r--src/controls/Button.qml (renamed from src/qtdesktop/Button.qml)57
-rw-r--r--src/controls/CheckBox.qml186
-rw-r--r--src/controls/ComboBox.qml200
-rw-r--r--src/controls/GroupBox.qml197
-rw-r--r--src/controls/Label.qml (renamed from src/qtdesktop/Label.qml)50
-rw-r--r--src/controls/Menu.qml326
-rw-r--r--src/controls/MenuBar.qml214
-rw-r--r--src/controls/PageAnimation.qml (renamed from src/qtdesktop/PageAnimation.qml)6
-rw-r--r--src/controls/PageStack.qml (renamed from src/qtdesktop/PageStack.qml)133
-rw-r--r--src/controls/PageTransition.qml (renamed from src/qtdesktop/PageTransition.qml)16
-rw-r--r--src/controls/ProgressBar.qml140
-rw-r--r--src/controls/RadioButton.qml (renamed from src/qtdesktop/RadioButton.qml)56
-rw-r--r--src/controls/ScrollView.qml286
-rw-r--r--src/controls/Slider.qml (renamed from src/qtdesktop/Slider.qml)185
-rw-r--r--src/controls/SpinBox.qml333
-rw-r--r--src/controls/SplitView.qml417
-rw-r--r--src/controls/StatusBar.qml (renamed from src/qtdesktop/StatusBar.qml)37
-rw-r--r--src/controls/Tab.qml (renamed from src/qtdesktop/Tab.qml)32
-rw-r--r--src/controls/TabView.qml218
-rw-r--r--src/controls/TableView.qml690
-rw-r--r--src/controls/TableViewColumn.qml (renamed from src/qtdesktop/TableColumn.qml)49
-rw-r--r--src/controls/TextArea.qml (renamed from src/qtdesktop/TextArea.qml)433
-rw-r--r--src/controls/TextField.qml591
-rw-r--r--src/controls/ToolBar.qml (renamed from src/qtdesktop/ToolBar.qml)48
-rw-r--r--src/controls/ToolButton.qml (renamed from src/qtdesktop/ToolButton.qml)58
-rw-r--r--src/controls/controls.pro39
-rw-r--r--src/controls/doc/images/placeholder.pngbin0 -> 9878 bytes
-rw-r--r--src/controls/doc/images/tableview.pngbin0 -> 55512 bytes
-rw-r--r--src/controls/doc/qtquickcontrols.qdocconf84
-rw-r--r--src/controls/doc/src/applicationwindow.qdoc31
-rw-r--r--src/controls/doc/src/containers.qdoc31
-rw-r--r--src/controls/doc/src/controls.qdoc31
-rw-r--r--src/controls/doc/src/indicators.qdoc31
-rw-r--r--src/controls/doc/src/menus.qdoc31
-rw-r--r--src/controls/doc/src/navigation.qdoc31
-rw-r--r--src/controls/doc/src/qtquickcontrols-examples.qdoc (renamed from src/qtdesktop/doc/src/qtdesktopcomponents-examples.qdoc)4
-rw-r--r--src/controls/doc/src/qtquickcontrols-index.qdoc (renamed from src/qtdesktop/doc/src/qtdesktopcomponents-index.qdoc)32
-rw-r--r--src/controls/doc/src/qtquickcontrols-overview.qdoc (renamed from src/qtdesktop/doc/src/qtdesktopcomponents-overview.qdoc)4
-rw-r--r--src/controls/doc/src/qtquickcontrols.qdoc (renamed from src/qtdesktop/doc/src/qtdesktopcomponents.qdoc)8
-rw-r--r--src/controls/doc/src/styles.qdoc (renamed from src/qtdesktop/doc/src/styles.qdoc)8
-rw-r--r--src/controls/doc/src/views.qdoc31
-rw-r--r--src/controls/plugin.cpp100
-rw-r--r--src/controls/plugin.json (renamed from src/qtdesktop/styleplugin.json)0
-rw-r--r--src/controls/plugin.pri23
-rw-r--r--src/controls/plugin_p.h61
-rw-r--r--src/controls/plugins.qmltypes163
-rw-r--r--src/controls/qmldir (renamed from src/qtdesktop/qmldir)23
-rw-r--r--src/controls/qtaction.cpp361
-rw-r--r--src/controls/qtaction_p.h148
-rw-r--r--src/controls/qtexclusivegroup.cpp252
-rw-r--r--src/controls/qtexclusivegroup_p.h88
-rw-r--r--src/controls/qtmenu.cpp597
-rw-r--r--src/controls/qtmenu_p.h169
-rw-r--r--src/controls/qtmenubar.cpp138
-rw-r--r--src/controls/qtmenubar_p.h99
-rw-r--r--src/controls/qtmenuitem.cpp607
-rw-r--r--src/controls/qtmenuitem_p.h241
-rw-r--r--src/controls/qtmenuitemcontainer_p.h100
-rw-r--r--src/controls/qtmenupopupwindow.cpp231
-rw-r--r--src/controls/qtmenupopupwindow_p.h97
-rw-r--r--src/controls/qtstack.cpp164
-rw-r--r--src/controls/qtstack_p.h103
-rw-r--r--src/experimental/Dial.qml (renamed from src/qtdesktop/Dial.qml)53
-rw-r--r--src/experimental/Dialog.qml (renamed from src/qtdesktop/Dialog.qml)15
-rw-r--r--src/experimental/experimental.pro7
-rw-r--r--src/experimental/qmldir3
-rw-r--r--src/layouts/.gitattributes1
-rw-r--r--src/layouts/layouts.pro26
-rw-r--r--src/layouts/plugin.cpp70
-rw-r--r--src/layouts/plugin.json1
-rw-r--r--src/layouts/plugins.qmltypesbin0 -> 3554 bytes
-rw-r--r--src/layouts/qgridlayoutengine.cpp1683
-rw-r--r--src/layouts/qgridlayoutengine_p.h560
-rw-r--r--src/layouts/qlayoutpolicy.cpp136
-rw-r--r--src/layouts/qlayoutpolicy_p.h180
-rw-r--r--src/layouts/qmldir3
-rw-r--r--src/layouts/qquickgridlayoutengine_p.h338
-rw-r--r--src/layouts/qquicklayout.cpp233
-rw-r--r--src/layouts/qquicklayout_p.h216
-rw-r--r--src/layouts/qquicklinearlayout.cpp433
-rw-r--r--src/layouts/qquicklinearlayout_p.h201
-rw-r--r--src/private/AbstractCheckable.qml150
-rw-r--r--src/private/BasicButton.qml195
-rw-r--r--src/private/Control.qml (renamed from src/qtdesktop/Frame.qml)64
-rw-r--r--src/private/FocusFrame.qml58
-rw-r--r--src/private/ModalPopupBehavior.qml (renamed from src/qtdesktop/private/ModalPopupBehavior.qml)11
-rw-r--r--src/private/PageSlideTransition.qml (renamed from src/qtdesktop/private/PageSlideTransition.qml)13
-rw-r--r--src/private/PageStack.js68
-rw-r--r--src/private/ScrollBar.qml (renamed from src/qtdesktop/private/ScrollBar.qml)128
-rw-r--r--src/private/ScrollViewHelper.qml183
-rw-r--r--src/private/TabBar.qml (renamed from src/qtdesktop/private/TabBar.qml)57
-rw-r--r--src/private/private.pro42
-rw-r--r--src/private/privateplugin.json1
-rw-r--r--src/private/qmldir10
-rw-r--r--src/private/qprivateplugin.cpp68
-rw-r--r--src/private/qprivateplugin_p.h59
-rw-r--r--src/private/qquickcomponentsprivate.cpp69
-rw-r--r--src/private/qquickcomponentsprivate_p.h65
-rw-r--r--src/private/qrangemodel.cpp (renamed from src/qtdesktop/qrangemodel.cpp)70
-rw-r--r--src/private/qrangemodel_p.h (renamed from src/qtdesktop/qrangemodel_p.h)61
-rw-r--r--src/private/qrangemodel_p_p.h (renamed from src/qtdesktop/qrangemodel_p_p.h)61
-rw-r--r--src/private/qstyleitem.cpp (renamed from src/qtdesktop/qstyleitem.cpp)421
-rw-r--r--src/private/qstyleitem_p.h (renamed from src/qtdesktop/qstyleitem_p.h)107
-rw-r--r--src/private/qwheelarea.cpp204
-rw-r--r--src/private/qwheelarea_p.h (renamed from src/qtdesktop/qwheelarea_p.h)60
-rw-r--r--src/qtdesktop/ApplicationWindow.qml130
-rw-r--r--src/qtdesktop/ButtonColumn.qml91
-rw-r--r--src/qtdesktop/ButtonRow.qml89
-rw-r--r--src/qtdesktop/CheckBox.qml154
-rw-r--r--src/qtdesktop/ComboBox.qml136
-rw-r--r--src/qtdesktop/ContextMenu.qml130
-rw-r--r--src/qtdesktop/GroupBox.qml106
-rw-r--r--src/qtdesktop/Page.qml98
-rw-r--r--src/qtdesktop/ProgressBar.qml91
-rw-r--r--src/qtdesktop/ScrollArea.qml147
-rw-r--r--src/qtdesktop/SpinBox.qml249
-rw-r--r--src/qtdesktop/SplitterColumn.qml167
-rw-r--r--src/qtdesktop/SplitterRow.qml167
-rw-r--r--src/qtdesktop/TabFrame.qml149
-rw-r--r--src/qtdesktop/TableView.qml663
-rw-r--r--src/qtdesktop/TextField.qml781
-rw-r--r--src/qtdesktop/doc/qtdesktopcomponents.qdocconf59
-rw-r--r--src/qtdesktop/plugins.qmltypes451
-rw-r--r--src/qtdesktop/private/BasicButton.qml110
-rw-r--r--src/qtdesktop/private/ButtonBehavior.qml61
-rw-r--r--src/qtdesktop/private/ButtonGroup.js141
-rw-r--r--src/qtdesktop/private/PageStack.js67
-rw-r--r--src/qtdesktop/private/ScrollAreaHelper.qml123
-rw-r--r--src/qtdesktop/private/Splitter.qml471
-rw-r--r--src/qtdesktop/qdesktopitem.cpp89
-rw-r--r--src/qtdesktop/qdesktopitem_p.h88
-rw-r--r--src/qtdesktop/qfiledialogitem.cpp328
-rw-r--r--src/qtdesktop/qfiledialogitem_p.h140
-rw-r--r--src/qtdesktop/qpagestatus.h69
-rw-r--r--src/qtdesktop/qquickcomponentsprivate.cpp66
-rw-r--r--src/qtdesktop/qquickcomponentsprivate_p.h66
-rw-r--r--src/qtdesktop/qquicklayout.cpp199
-rw-r--r--src/qtdesktop/qquicklayout_p.h137
-rw-r--r--src/qtdesktop/qquicklayoutengine.cpp294
-rw-r--r--src/qtdesktop/qquicklayoutengine_p.h92
-rw-r--r--src/qtdesktop/qquicklinearlayout.cpp262
-rw-r--r--src/qtdesktop/qquicklinearlayout_p.h118
-rw-r--r--src/qtdesktop/qstyleplugin.cpp130
-rw-r--r--src/qtdesktop/qstyleplugin_p.h65
-rw-r--r--src/qtdesktop/qtaction.cpp211
-rw-r--r--src/qtdesktop/qtaction_p.h139
-rw-r--r--src/qtdesktop/qtdesktop.pro64
-rw-r--r--src/qtdesktop/qtexclusivegroup.cpp110
-rw-r--r--src/qtdesktop/qtexclusivegroup_p.h74
-rw-r--r--src/qtdesktop/qtmenu.cpp245
-rw-r--r--src/qtdesktop/qtmenu_p.h129
-rw-r--r--src/qtdesktop/qtmenubar.cpp104
-rw-r--r--src/qtdesktop/qtmenubar_p.h96
-rw-r--r--src/qtdesktop/qtmenuitem.cpp172
-rw-r--r--src/qtdesktop/qtmenuitem_p.h134
-rw-r--r--src/qtdesktop/qtsplitterbase.cpp104
-rw-r--r--src/qtdesktop/qtsplitterbase_p.h130
-rw-r--r--src/qtdesktop/qwheelarea.cpp191
-rw-r--r--src/qtdesktop/styleplugin.pri40
-rw-r--r--src/src.pro4
-rw-r--r--src/styles/ButtonStyle.qml72
-rw-r--r--src/styles/CheckBoxStyle.qml68
-rw-r--r--src/styles/ComboBoxStyle.qml42
-rw-r--r--src/styles/Desktop/ButtonStyle.qml27
-rw-r--r--src/styles/Desktop/CheckBoxStyle.qml78
-rw-r--r--src/styles/Desktop/ComboBoxStyle.qml86
-rw-r--r--src/styles/Desktop/FrameStyle.qml49
-rw-r--r--src/styles/Desktop/GroupBoxStyle.qml34
-rw-r--r--src/styles/Desktop/MenuBarStyle.qml71
-rw-r--r--src/styles/Desktop/MenuStyle.qml95
-rw-r--r--src/styles/Desktop/ProgressBarStyle.qml40
-rw-r--r--src/styles/Desktop/RadioButtonStyle.qml70
-rw-r--r--src/styles/Desktop/ScrollAreaStyle.qml56
-rw-r--r--src/styles/Desktop/ScrollBarStyle.qml11
-rw-r--r--src/styles/Desktop/SliderStyle.qml41
-rw-r--r--src/styles/Desktop/SpinBoxStyle.qml139
-rw-r--r--src/styles/Desktop/TabViewStyle.qml (renamed from src/styles/Desktop/TabFrameStyle.qml)56
-rw-r--r--src/styles/Desktop/TextFieldStyle.qml76
-rw-r--r--src/styles/Desktop/ToolBarStyle.qml9
-rw-r--r--src/styles/Desktop/ToolButtonStyle.qml41
-rw-r--r--src/styles/FrameStyle.qml61
-rw-r--r--src/styles/GroupBoxStyle.qml34
-rw-r--r--src/styles/MenuBarStyle.qml72
-rw-r--r--src/styles/MenuStyle.qml (renamed from tests/manual/FileDialogTest.qml)90
-rw-r--r--src/styles/ProgressBarStyle.qml37
-rw-r--r--src/styles/RadioButtonStyle.qml84
-rw-r--r--src/styles/ScrollAreaStyle.qml55
-rw-r--r--src/styles/ScrollBarStyle.qml15
-rw-r--r--src/styles/Settings.js40
-rw-r--r--src/styles/SliderStyle.qml59
-rw-r--r--src/styles/SpinBoxStyle.qml111
-rw-r--r--src/styles/Style.qml49
-rw-r--r--src/styles/TabViewStyle.qml (renamed from src/styles/TabFrameStyle.qml)16
-rw-r--r--src/styles/TextFieldStyle.qml62
-rw-r--r--src/styles/ToolBarStyle.qml15
-rw-r--r--src/styles/ToolButtonStyle.qml13
-rw-r--r--src/styles/qmldir7
-rw-r--r--src/styles/styles.pro15
-rw-r--r--sync.profile8
-rw-r--r--tests/auto/activeFocusOnTab/activeFocusOnTab.pro12
-rw-r--r--tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml206
-rw-r--r--tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp427
-rw-r--r--tests/auto/auto.pro3
-rw-r--r--tests/auto/controls/controls.pro41
-rw-r--r--tests/auto/controls/data/rangemodel/rangemodel.qml (renamed from tests/auto/qtdesktop/data/rangemodel/rangemodel.qml)6
-rw-r--r--tests/auto/controls/data/shortcut/shortcuts.qml (renamed from tests/auto/qtdesktop/data/shortcut/shortcuts.qml)8
-rw-r--r--tests/auto/controls/data/tableview/table1_qobjectmodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml)10
-rw-r--r--tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml)10
-rw-r--r--tests/auto/controls/data/tableview/table3_qobjectlist.qml (renamed from tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml)10
-rw-r--r--tests/auto/controls/data/tableview/table4_qstringlist.qml (renamed from tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml)10
-rw-r--r--tests/auto/controls/data/tableview/table5_listmodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table5_listmodel.qml)8
-rw-r--r--tests/auto/controls/data/tableview/table6_countmodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table6_countmodel.qml)8
-rw-r--r--tests/auto/controls/data/tableview/table7_arraymodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml)8
-rw-r--r--tests/auto/controls/data/tableview/table8_itemmodel.qml (renamed from tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml)8
-rw-r--r--tests/auto/controls/data/tst_applicationwindow.qml58
-rw-r--r--tests/auto/controls/data/tst_button.qml101
-rw-r--r--tests/auto/controls/data/tst_checkbox.qml223
-rw-r--r--tests/auto/controls/data/tst_combobox.qml83
-rw-r--r--tests/auto/controls/data/tst_groupbox.qml104
-rw-r--r--tests/auto/controls/data/tst_label.qml54
-rw-r--r--tests/auto/controls/data/tst_menu.qml220
-rw-r--r--tests/auto/controls/data/tst_menubar.qml54
-rw-r--r--tests/auto/controls/data/tst_pagestack.qml77
-rw-r--r--tests/auto/controls/data/tst_progressbar.qml118
-rw-r--r--tests/auto/controls/data/tst_radiobutton.qml175
-rw-r--r--tests/auto/controls/data/tst_rangemodel.qml (renamed from tests/auto/qtdesktop/data/tst_rangemodel.qml)4
-rw-r--r--tests/auto/controls/data/tst_rowlayout.qml243
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml108
-rw-r--r--tests/auto/controls/data/tst_shortcuts.qml (renamed from tests/auto/qtdesktop/data/tst_shortcuts.qml)19
-rw-r--r--tests/auto/controls/data/tst_slider.qml78
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml316
-rw-r--r--tests/auto/controls/data/tst_splitview.qml66
-rw-r--r--tests/auto/controls/data/tst_stack.qml (renamed from tests/auto/qtdesktop/data/tst_button.qml)28
-rw-r--r--tests/auto/controls/data/tst_statusbar.qml55
-rw-r--r--tests/auto/controls/data/tst_tab.qml55
-rw-r--r--tests/auto/controls/data/tst_tableview.qml (renamed from tests/auto/qtdesktop/data/tst_tableview.qml)32
-rw-r--r--tests/auto/controls/data/tst_tableviewcolumn.qml55
-rw-r--r--tests/auto/controls/data/tst_tabview.qml119
-rw-r--r--tests/auto/controls/data/tst_textarea.qml62
-rw-r--r--tests/auto/controls/data/tst_textfield.qml246
-rw-r--r--tests/auto/controls/data/tst_toolbar.qml55
-rw-r--r--tests/auto/controls/data/tst_toolbutton.qml55
-rw-r--r--tests/auto/controls/tst_controls.cpp (renamed from tests/auto/qtdesktop/tst_qtdesktop.cpp)6
-rw-r--r--tests/auto/qtdesktop/data/tst_spinbox.qml193
-rw-r--r--tests/auto/qtdesktop/qtdesktop.pro22
-rw-r--r--tests/auto/shared/util.cpp138
-rw-r--r--tests/auto/shared/util.h111
-rw-r--r--tests/auto/shared/util.pri8
-rw-r--r--tests/auto/shared/visualtestutil.cpp76
-rw-r--r--tests/auto/shared/visualtestutil.h117
-rw-r--r--tests/auto/testplugin/QtDesktopTest/qmldir2
-rw-r--r--tests/auto/testplugin/QtQuickControlsTests/qmldir2
-rw-r--r--tests/auto/testplugin/README.txt11
-rw-r--r--tests/auto/testplugin/testcppmodels.h53
-rw-r--r--tests/auto/testplugin/testplugin.cpp54
-rw-r--r--tests/auto/testplugin/testplugin.h63
-rw-r--r--tests/auto/testplugin/testplugin.pro4
-rw-r--r--tests/manual/ContextMenu.qml12
-rw-r--r--tests/manual/Dialog.qml8
-rw-r--r--tests/manual/Layout.qml920
-rw-r--r--tests/manual/PageStack.qml44
-rw-r--r--tests/manual/SplitterGallery.qml106
-rw-r--r--tests/manual/WindowContextMenu.qml16
-rw-r--r--tests/manual/images/checkered.pngbin0 -> 258 bytes
-rw-r--r--tests/manual/images/testIcon.pngbin0 -> 3826 bytes
-rw-r--r--tests/manual/keynavigation.qml8
-rw-r--r--tests/manual/scrollview/main.qml187
-rw-r--r--tests/manual/splitter.qml13
-rw-r--r--tests/manual/stretching.qml12
-rw-r--r--tests/manual/stretchingcustom.qml12
-rw-r--r--tests/manual/tableviewmodels/main.cpp55
-rw-r--r--tests/manual/tableviewmodels/qml/main.qml24
-rw-r--r--tests/manual/tableviewmodels/testmodel.cpp63
-rw-r--r--tests/manual/tableviewmodels/testmodel.h55
-rw-r--r--tests/manual/testbench/content/Components.qml131
-rw-r--r--tests/manual/testbench/content/PropertyLayouts.qml169
-rw-r--r--tests/manual/testbench/main.qml420
-rw-r--r--tests/manual/testbench/testbench.qmlproject16
-rw-r--r--tests/shared/qt_quick_controls_quicktest.h (renamed from tests/shared/qtdc_quicktest.h)18
-rw-r--r--tools/qmlwidget/main.cpp55
346 files changed, 25059 insertions, 12326 deletions
diff --git a/.gitignore b/.gitignore
index 39f08cf8..1ec36178 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,10 @@
# This file is used to ignore files which are generated in the Qt build system
# ----------------------------------------------------------------------------
+examples/ApplicationTemplate/application
+examples/text/text
+tests/auto/controls/tst_controls
+tests/auto/qtdesktop/tst_qtdesktop
callgrind.out.*
pcviewer.cfg
diff --git a/.qmake.conf b/.qmake.conf
index 42ba8e45..f5a422c1 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1 +1,3 @@
load(qt_build_config)
+
+MODULE_VERSION = 5.1.0
diff --git a/LGPL_EXCEPTION.txt b/LGPL_EXCEPTION.txt
new file mode 100644
index 00000000..7e2e30ff
--- /dev/null
+++ b/LGPL_EXCEPTION.txt
@@ -0,0 +1,22 @@
+Digia Qt LGPL Exception version 1.1
+
+As an additional permission to the GNU Lesser General Public License version
+2.1, the object code form of a "work that uses the Library" may incorporate
+material from a header file that is part of the Library. You may distribute
+such object code under terms of your choice, provided that:
+ (i) the header files of the Library have not been modified; and
+ (ii) the incorporated material is limited to numerical parameters, data
+ structure layouts, accessors, macros, inline functions and
+ templates; and
+ (iii) you comply with the terms of Section 6 of the GNU Lesser General
+ Public License version 2.1.
+
+Moreover, you may apply this exception to a modified version of the Library,
+provided that such modification does not involve copying material from the
+Library into the modified Library's header files unless such material is
+limited to (i) numerical parameters; (ii) data structure layouts;
+(iii) accessors; and (iv) small macros, templates and inline functions of
+five lines or less in length.
+
+Furthermore, you are not required to apply this additional permission to a
+modified version of the Library.
diff --git a/LICENSE.FDL b/LICENSE.FDL
new file mode 100644
index 00000000..938bb8da
--- /dev/null
+++ b/LICENSE.FDL
@@ -0,0 +1,450 @@
+ GNU Free Documentation License
+ Version 1.3, 3 November 2008
+
+
+ Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+ <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+0. PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document "free" in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of "copyleft", which means that derivative
+works of the document must themselves be free in the same sense. It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does. But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book. We recommend this License
+principally for works whose purpose is instruction or reference.
+
+
+1. APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License. Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein. The "Document", below,
+refers to any such manual or work. Any member of the public is a
+licensee, and is addressed as "you". You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A "Modified Version" of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A "Secondary Section" is a named appendix or a front-matter section of
+the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall
+subject (or to related matters) and contains nothing that could fall
+directly within that overall subject. (Thus, if the Document is in
+part a textbook of mathematics, a Secondary Section may not explain
+any mathematics.) The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The "Invariant Sections" are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License. If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant. The Document may contain zero
+Invariant Sections. If the Document does not identify any Invariant
+Sections then there are none.
+
+The "Cover Texts" are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License. A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A "Transparent" copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters. A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text. A copy that is not "Transparent" is called "Opaque".
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, LaTeX input format, SGML
+or XML using a publicly available DTD, and standard-conforming simple
+HTML, PostScript or PDF designed for human modification. Examples of
+transparent image formats include PNG, XCF and JPG. Opaque formats
+include proprietary formats that can be read and edited only by
+proprietary word processors, SGML or XML for which the DTD and/or
+processing tools are not generally available, and the
+machine-generated HTML, PostScript or PDF produced by some word
+processors for output purposes only.
+
+The "Title Page" means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page. For works in
+formats which do not have any title page as such, "Title Page" means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+The "publisher" means any person or entity that distributes copies of
+the Document to the public.
+
+A section "Entitled XYZ" means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language. (Here XYZ stands for a
+specific section name mentioned below, such as "Acknowledgements",
+"Dedications", "Endorsements", or "History".) To "Preserve the Title"
+of such a section when you modify the Document means that it remains a
+section "Entitled XYZ" according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document. These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+2. VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no
+other conditions whatsoever to those of this License. You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute. However, you may accept
+compensation in exchange for copies. If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+
+3. COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover. Both covers must also clearly and legibly identify
+you as the publisher of these copies. The front cover must present
+the full title with all words of the title equally prominent and
+visible. You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to
+give them a chance to provide you with an updated version of the
+Document.
+
+
+4. MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it. In addition, you must do these things in the Modified Version:
+
+A. Use in the Title Page (and on the covers, if any) a title distinct
+ from that of the Document, and from those of previous versions
+ (which should, if there were any, be listed in the History section
+ of the Document). You may use the same title as a previous version
+ if the original publisher of that version gives permission.
+B. List on the Title Page, as authors, one or more persons or entities
+ responsible for authorship of the modifications in the Modified
+ Version, together with at least five of the principal authors of the
+ Document (all of its principal authors, if it has fewer than five),
+ unless they release you from this requirement.
+C. State on the Title page the name of the publisher of the
+ Modified Version, as the publisher.
+D. Preserve all the copyright notices of the Document.
+E. Add an appropriate copyright notice for your modifications
+ adjacent to the other copyright notices.
+F. Include, immediately after the copyright notices, a license notice
+ giving the public permission to use the Modified Version under the
+ terms of this License, in the form shown in the Addendum below.
+G. Preserve in that license notice the full lists of Invariant Sections
+ and required Cover Texts given in the Document's license notice.
+H. Include an unaltered copy of this License.
+I. Preserve the section Entitled "History", Preserve its Title, and add
+ to it an item stating at least the title, year, new authors, and
+ publisher of the Modified Version as given on the Title Page. If
+ there is no section Entitled "History" in the Document, create one
+ stating the title, year, authors, and publisher of the Document as
+ given on its Title Page, then add an item describing the Modified
+ Version as stated in the previous sentence.
+J. Preserve the network location, if any, given in the Document for
+ public access to a Transparent copy of the Document, and likewise
+ the network locations given in the Document for previous versions
+ it was based on. These may be placed in the "History" section.
+ You may omit a network location for a work that was published at
+ least four years before the Document itself, or if the original
+ publisher of the version it refers to gives permission.
+K. For any section Entitled "Acknowledgements" or "Dedications",
+ Preserve the Title of the section, and preserve in the section all
+ the substance and tone of each of the contributor acknowledgements
+ and/or dedications given therein.
+L. Preserve all the Invariant Sections of the Document,
+ unaltered in their text and in their titles. Section numbers
+ or the equivalent are not considered part of the section titles.
+M. Delete any section Entitled "Endorsements". Such a section
+ may not be included in the Modified Version.
+N. Do not retitle any existing section to be Entitled "Endorsements"
+ or to conflict in title with any Invariant Section.
+O. Preserve any Warranty Disclaimers.
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant. To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled "Endorsements", provided it contains
+nothing but endorsements of your Modified Version by various
+parties--for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version. Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity. If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+
+5. COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy. If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled "History"
+in the various original documents, forming one section Entitled
+"History"; likewise combine any sections Entitled "Acknowledgements",
+and any sections Entitled "Dedications". You must delete all sections
+Entitled "Endorsements".
+
+
+6. COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other
+documents released under this License, and replace the individual
+copies of this License in the various documents with a single copy
+that is included in the collection, provided that you follow the rules
+of this License for verbatim copying of each of the documents in all
+other respects.
+
+You may extract a single document from such a collection, and
+distribute it individually under this License, provided you insert a
+copy of this License into the extracted document, and follow this
+License in all other respects regarding verbatim copying of that
+document.
+
+
+7. AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an "aggregate" if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+
+8. TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections. You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers. In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled "Acknowledgements",
+"Dedications", or "History", the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+
+9. TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
+
+
+10. FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions of the
+GNU Free Documentation License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in
+detail to address new problems or concerns. See
+http://www.gnu.org/copyleft/.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License "or any later version" applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation. If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation. If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+11. RELICENSING
+
+"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works. A
+public wiki that anybody can edit is an example of such a server. A
+"Massive Multiauthor Collaboration" (or "MMC") contained in the site
+means any set of copyrightable works thus published on the MMC site.
+
+"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+"Incorporate" means to publish or republish a Document, in whole or in
+part, as part of another Document.
+
+An MMC is "eligible for relicensing" if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole or
+in part into the MMC, (1) had no cover texts or invariant sections, and
+(2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
+
+ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+ Copyright (c) YEAR YOUR NAME.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the "with...Texts." line with this:
+
+ with the Invariant Sections being LIST THEIR TITLES, with the
+ Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
diff --git a/LICENSE.GPL b/LICENSE.GPL
new file mode 100644
index 00000000..94a9ed02
--- /dev/null
+++ b/LICENSE.GPL
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/LICENSE.LGPL b/LICENSE.LGPL
new file mode 100644
index 00000000..3788d79e
--- /dev/null
+++ b/LICENSE.LGPL
@@ -0,0 +1,514 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+
+ The Qt Toolkit is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ Contact: http://www.qt-project.org/legal
+
+ You may use, distribute and copy the Qt GUI Toolkit under the terms of
+ GNU Lesser General Public License version 2.1, which is displayed below.
+
+-------------------------------------------------------------------------
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/README b/README
index f0294c01..692e8a4c 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
ABOUT
-This project aims to deliver widgets/components for Desktop usage on Qt Quick.
+This project aims to deliver widgets/controls functionality with Qt Quick.
Some more information can be found on the following blog entries:
diff --git a/examples/ApplicationTemplate/application.pro b/examples/ApplicationTemplate/ApplicationTemplate.pro
index d623dff9..d623dff9 100644
--- a/examples/ApplicationTemplate/application.pro
+++ b/examples/ApplicationTemplate/ApplicationTemplate.pro
diff --git a/examples/ApplicationTemplate/main.cpp b/examples/ApplicationTemplate/main.cpp
index e53c1340..ef8dd804 100644
--- a/examples/ApplicationTemplate/main.cpp
+++ b/examples/ApplicationTemplate/main.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,6 +38,7 @@
**
****************************************************************************/
+
#include <QtWidgets/QApplication>
#include <QtQml>
#include <QtQuick/QQuickView>
@@ -59,6 +60,7 @@ int main(int argc, char *argv[])
qWarning("Error: Your root item has to be a Window.");
return -1;
}
+ QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
window->show();
return app.exec();
}
diff --git a/examples/ApplicationTemplate/qml/main.qml b/examples/ApplicationTemplate/qml/main.qml
index 23795f52..0c92e9ca 100644
--- a/examples/ApplicationTemplate/qml/main.qml
+++ b/examples/ApplicationTemplate/qml/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,7 +38,12 @@
**
****************************************************************************/
-import QtDesktop 1.0
+
+
+
+
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
ApplicationWindow {
width: 640
@@ -48,13 +53,12 @@ ApplicationWindow {
menuBar: MenuBar {
Menu {
- text: "Menu 1"
- MenuItem { text: "Item 1" }
- MenuItem { text: "Item 2" }
+ title: "File"
+ MenuItem { text: "Quit"; onTriggered: Qt.quit() }
}
Menu {
- text: "Menu 2"
- MenuItem { text: "Item 3" }
+ title: "Help"
+ MenuItem { text: "About..."; enabled: false }
}
}
@@ -65,17 +69,16 @@ ApplicationWindow {
}
}
- SplitterRow {
+ SplitView {
anchors.fill: parent
- handleWidth: 1
TableView {
- frame: false
+ frameVisible: false
highlightOnFocus: false
model: 40
- TableColumn { title: "Left Column" }
+ TableViewColumn { title: "Left Column" }
}
TextArea {
- frame: false
+ frameVisible: false
highlightOnFocus: false
text: "Hello World"
}
diff --git a/examples/basiclayouts/basiclayouts.qmlproject b/examples/basiclayouts/basiclayouts.qmlproject
new file mode 100644
index 00000000..e5a8bf02
--- /dev/null
+++ b/examples/basiclayouts/basiclayouts.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/basiclayouts/main.qml b/examples/basiclayouts/main.qml
new file mode 100644
index 00000000..d2b37204
--- /dev/null
+++ b/examples/basiclayouts/main.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+ApplicationWindow {
+ title: "Basic layouts"
+ property int margin: 11
+ minimumWidth: mainLayout.implicitWidth + 2 * margin
+ minimumHeight: mainLayout.implicitHeight + 2 * margin
+ width: minimumWidth
+ height: minimumHeight
+
+ ColumnLayout {
+ id: mainLayout
+ anchors.fill: parent
+ anchors.margins: margin
+ spacing: 6
+ GroupBox {
+ id: rowBox
+ title: "Row layout"
+ contentWidth: rowLayout.implicitWidth
+ contentHeight: rowLayout.implicitHeight
+ Layout.fillWidth: true
+
+ RowLayout {
+ id: rowLayout
+ spacing: 6
+ anchors.fill: parent
+ Button {
+ text: "Button 1"
+ }
+ Button {
+ text: "Button 2"
+ }
+ Button {
+ text: "Button 3"
+ }
+ Button {
+ text: "Button 4"
+ }
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ GroupBox {
+ id: gridBox
+ title: "Grid layout"
+ contentWidth: gridLayout.implicitWidth
+ contentHeight: gridLayout.implicitHeight
+ Layout.fillWidth: true
+
+ GridLayout {
+ id: gridLayout
+ rowSpacing: 6
+ columnSpacing: 6
+ anchors.fill: parent
+ Label {
+ text: "Line 1"
+ Layout.row: 0
+ Layout.column: 0
+ }
+ Label {
+ text: "Line 2"
+ Layout.row: 1
+ Layout.column: 0
+ }
+ Label {
+ text: "Line 3"
+ Layout.row: 2
+ Layout.column: 0
+ }
+ TextField {
+ Layout.row: 0
+ Layout.column: 1
+ }
+ TextField {
+ Layout.row: 1
+ Layout.column: 1
+ }
+ TextField {
+ Layout.row: 2
+ Layout.column: 1
+ }
+ TextArea {
+ text: "This widget spans over three rows in the grid layout"
+ Layout.row: 0
+ Layout.column: 2
+ Layout.rowSpan: 3
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+ }
+ TextField {
+ id: t3
+ placeholderText: "This is a placeholder for a TextField"
+ width: 200
+ height: 400
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+ }
+}
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 00000000..772bc8b7
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ ApplicationTemplate \
+ gallery \
+ splitters \
+ tableview \
+ text \
+ touch
diff --git a/examples/gallery/content/ChildWindow.qml b/examples/gallery/content/ChildWindow.qml
index 77daba8d..c4094209 100644
--- a/examples/gallery/content/ChildWindow.qml
+++ b/examples/gallery/content/ChildWindow.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,13 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Window 2.1
+import QtQuick.Controls 1.0
Window {
id: window1
@@ -59,18 +64,6 @@ Window {
anchors.top: parent.top
width: parent.width
horizontalAlignment: Text.AlignHCenter
-
- text: {
- if (Desktop.screenCount == 1) {
- "You have only a single screen.\nThe dimensions of your screen are: " + Desktop.screenWidth + " x " + Desktop.screenHeight;
- } else {
- var text = "You have " + Desktop.screenCount + " screens.\nThe dimensions of your screens are: "
- for(var i=0; i<Desktop.screenCount; i++) {
- text += "\n" + Desktop.screenGeometry(i).width + " x " + Desktop.screenGeometry(i).height
- }
- return text;
- }
- }
}
Text {
@@ -79,14 +72,6 @@ Window {
anchors.top: dimensionsText.bottom
width: parent.width
horizontalAlignment: Text.AlignHCenter
-
- text: {
- var text = "The available dimensions of your screens are: "
- for(var i=0; i<Desktop.screenCount; i++) {
- text += "\n" + Desktop.availableGeometry(i).width + " x " + Desktop.availableGeometry(i).height
- }
- return text;
- }
}
Text {
@@ -111,7 +96,7 @@ Window {
text:"Maximize"
width: 98
tooltip:"Press me, to maximize this window again"
- onClicked: window1.windowState = Qt.WindowMaximized;
+ onClicked: window1.visibility = Window.Maximized;
}
Button {
anchors.horizontalCenter: closeText.horizontalCenter
@@ -120,7 +105,7 @@ Window {
text:"Normalize"
width: 98
tooltip:"Press me, to normalize this window again"
- onClicked: window1.windowState = Qt.WindowNoState;
+ onClicked: window1.visibility = Window.Windowed;
}
Button {
anchors.horizontalCenter: closeText.horizontalCenter
@@ -129,7 +114,7 @@ Window {
text:"Minimize"
width: 98
tooltip:"Press me, to minimize this window again"
- onClicked: window1.windowState = Qt.WindowMinimized;
+ onClicked: window1.visibility = Window.Minimized;
}
}
}
diff --git a/examples/gallery/content/Controls.qml b/examples/gallery/content/Controls.qml
index a3d273ed..c0c1ff58 100644
--- a/examples/gallery/content/Controls.qml
+++ b/examples/gallery/content/Controls.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,16 +38,20 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
Item {
id: flickable
anchors.fill: parent
enabled: enabledCheck.checked
- property string tabPosition: tabPositionGroup.checkedButton == r2 ? "South" : "North"
+ property int tabPosition: tabPositionGroup.current === r2 ? Qt.BottomEdge : Qt.TopEdge
Row {
id: contentRow
@@ -55,6 +59,7 @@ Item {
anchors.margins: 8
spacing: 16
Column {
+ id: firstColumn
spacing: 9
Row {
spacing:8
@@ -63,20 +68,18 @@ Item {
text: "Button 1"
width: 96
tooltip:"This is an interesting tool tip"
- KeyNavigation.tab: button2
}
Button {
id:button2
text:"Button 2"
width:96
- KeyNavigation.tab: combo
}
}
ComboBox {
id: combo;
model: choices;
width: parent.width;
- KeyNavigation.tab: t1
+ currentIndex: 2
}
Row {
spacing: 8
@@ -86,19 +89,16 @@ Item {
minimumValue: -50
value: -20
-
- KeyNavigation.tab: t2
}
SpinBox {
id: t2
width:97
- KeyNavigation.tab: t3
}
}
TextField {
id: t3
- KeyNavigation.tab: slider
placeholderText: "This is a placeholder for a TextField"
+ width: 200
}
ProgressBar {
// normalize value [0.0 .. 1.0]
@@ -111,30 +111,36 @@ Item {
id: slider
value: 0.5
tickmarksEnabled: tickmarkCheck.checked
- KeyNavigation.tab: frameCheckbox
}
}
Column {
id: rightcol
spacing: 12
+ anchors {
+ top: parent.top
+ bottom: parent.bottom
+ }
+
GroupBox {
id: group1
title: "CheckBox"
width: area.width
- adjustToContentSize: true
- ButtonRow {
- exclusive: false
+ Row {
CheckBox {
id: frameCheckbox
text: "Text frame"
checked: true
- KeyNavigation.tab: tickmarkCheck
+ width: 100
}
CheckBox {
id: tickmarkCheck
text: "Tickmarks"
+ checked: false
+ }
+ CheckBox {
+ id: wrapCheck
+ text: "Word wrap"
checked: true
- KeyNavigation.tab: r1
}
}
}
@@ -142,29 +148,31 @@ Item {
id: group2
title:"Tab Position"
width: area.width
- adjustToContentSize: true
- ButtonRow {
- id: tabPositionGroup
- exclusive: true
+ ExclusiveGroup { id: tabPositionGroup }
+ Row {
RadioButton {
id: r1
- text: "North"
- KeyNavigation.tab: r2
+ text: "Top"
checked: true
+ exclusiveGroup: tabPositionGroup
+ width: 100
}
RadioButton {
id: r2
- text: "South"
- KeyNavigation.tab: area
+ text: "Bottom"
+ exclusiveGroup: tabPositionGroup
}
}
}
TextArea {
id: area
- frame: frameCheckbox.checked
+ frameVisible: frameCheckbox.checked
text: loremIpsum + loremIpsum
- KeyNavigation.tab: button1
+ wrapMode: wrapCheck.checked ? TextEdit.WordWrap : TextEdit.NoWrap
+ width: contentRow.width - firstColumn.width - contentRow.spacing
+ height: parent.height - group1.height - group2.height - 2 * parent.spacing
+ anchors { right: parent.right }
}
}
}
diff --git a/examples/gallery/content/ImageViewer.qml b/examples/gallery/content/ImageViewer.qml
new file mode 100644
index 00000000..0b045bf6
--- /dev/null
+++ b/examples/gallery/content/ImageViewer.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Window 2.1
+
+Window {
+ id: imageViewer
+ minimumWidth: viewerImage.width
+ minimumHeight: viewerImage.height
+ function open(source) {
+ viewerImage.source = source
+ width = viewerImage.implicitWidth + 20
+ height = viewerImage.implicitHeight + 20
+ title = source
+ visible = true
+ }
+ Image {
+ id: viewerImage
+ anchors.centerIn: parent
+ }
+}
diff --git a/examples/gallery/content/ModelView.qml b/examples/gallery/content/ModelView.qml
index babb7030..237604e5 100644
--- a/examples/gallery/content/ModelView.qml
+++ b/examples/gallery/content/ModelView.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,16 +38,20 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-//import QtQuick.XmlListModel 2.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+//import QtQuick.XmlListModel 2.1
Item {
id: root
width: 600
height: 300
anchors.fill: parent
- anchors.margins: styleitem.style == "mac" ? 12 : 0
+ anchors.margins: Qt.platform.os === "mac" ? 12 : 0
// XmlListModel {
// id: flickerModel
@@ -72,17 +76,17 @@ Item {
model: dummyModel
anchors.fill: parent
- TableColumn {
+ TableViewColumn {
role: "title"
title: "Title"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "credit"
title: "Credit"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "imagesource"
title: "Image source"
width: 200
diff --git a/examples/gallery/content/Panel.qml b/examples/gallery/content/Panel.qml
index bd70439d..bdb10f83 100644
--- a/examples/gallery/content/Panel.qml
+++ b/examples/gallery/content/Panel.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,12 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
Rectangle {
id:root
@@ -47,8 +51,8 @@ Rectangle {
width: 540
height: 340
color:"#c3c3c3"
- ScrollArea {
- frame:false
+ ScrollView {
+ frameVisible: false
anchors.fill: parent
Item {
@@ -83,7 +87,7 @@ Rectangle {
anchors.left: parent.left
anchors.top: parent.top
width: show ? 160 : 40
- height:parent.height
+ height:root.height
Behavior on width { NumberAnimation { easing.type: Easing.OutSine ; duration: 250 } }
property bool show: false
border.left: 0;
diff --git a/examples/gallery/content/RangeTab.qml b/examples/gallery/content/RangeTab.qml
deleted file mode 100644
index 5c8a4821..00000000
--- a/examples/gallery/content/RangeTab.qml
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-Row {
- anchors.fill: parent
- anchors.margins:16
- spacing:16
-
- Column {
- spacing:12
-
- GroupBox {
- title: "Animation options"
- adjustToContentSize: true
- ButtonRow {
- exclusive: false
- CheckBox {
- id:fade
- text: "Fade on hover"
- }
- CheckBox {
- id: scale
- text: "Scale on hover"
- }
- }
- }
- Row {
- spacing: 20
- Column {
- spacing: 10
- Button {
- width:200
- text: "Push button"
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- Slider {
- value: 0.5
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- Slider {
- id : slider1
- value: 50
- tickmarksEnabled: false
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- ProgressBar {
- value: 0.5
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- ProgressBar {
- indeterminate: true
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- }
- Dial{
- width: 120
- height: 120
- scale: scale.checked && containsMouse ? 1.1 : 1
- opacity: !fade.checked || containsMouse ? 1 : 0.5
- Behavior on scale { NumberAnimation { easing.type: Easing.OutCubic ; duration: 120} }
- Behavior on opacity { NumberAnimation { easing.type: Easing.OutCubic ; duration: 220} }
- }
- }
- }
-}
-
diff --git a/examples/gallery/content/Styles.qml b/examples/gallery/content/Styles.qml
index 3f3ea1fe..73c710bc 100644
--- a/examples/gallery/content/Styles.qml
+++ b/examples/gallery/content/Styles.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,15 +38,28 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Dialogs 1.0
Item {
id: root
width: 300
height: 200
+ ColorDialog {
+ id: colorDialog
+ color: "#afe"
+ property color last: "#afe"
+ onRejected: color = last
+ onVisibleChanged: if (visible) last = color
+ }
+
Column {
anchors.margins: 20
anchors.horizontalCenter: parent.horizontalCenter
@@ -56,8 +69,9 @@ Item {
Row {
spacing: 8
Button {
- text: "Push me"
- style: ButtonStyle { backgroundColor: "#afe" }
+ text: "Set color…"
+ style: ButtonStyle { backgroundColor: colorDialog.color }
+ onClicked: colorDialog.open()
}
Button {
text: "Push me"
@@ -71,7 +85,7 @@ Item {
Row {
spacing: 8
TextField {
- style: TextFieldStyle { backgroundColor: "#afe" }
+ style: TextFieldStyle { backgroundColor: colorDialog.color }
}
TextField {
style: TextFieldStyle { backgroundColor: "#eee" }
@@ -83,7 +97,7 @@ Item {
Row {
spacing: 8
SpinBox {
- style: SpinBoxStyle { backgroundColor: "#afe" }
+ style: SpinBoxStyle { backgroundColor: colorDialog.color }
}
SpinBox {
style: SpinBoxStyle { backgroundColor: "#eee" }
@@ -99,7 +113,7 @@ Item {
value: 50
maximumValue: 100
width: 100
- style: SliderStyle { backgroundColor: "#afe"}
+ style: SliderStyle { backgroundColor: colorDialog.color}
}
Slider {
value: 50
@@ -121,7 +135,7 @@ Item {
value: 50
maximumValue: 100
width: 100
- style: ProgressBarStyle{ backgroundColor: "#afe" }
+ style: ProgressBarStyle{ backgroundColor: colorDialog.color }
}
ProgressBar {
value: 50
@@ -138,14 +152,26 @@ Item {
}
Row {
- TabFrame {
+ spacing: 8
+ CheckBox {
+ text: "CheckBox"
+ style: CheckBoxStyle{}
+ }
+ RadioButton {
+ style: RadioButtonStyle{}
+ text: "RadioButton"
+ }
+ }
+
+ Row {
+ TabView {
width: 400
height: 30
Tab { title: "One" ; Item {}}
Tab { title: "Two" ; Item {}}
Tab { title: "Three" ; Item {}}
Tab { title: "Four" ; Item {}}
- style: tabFrameStyle
+ style: tabViewStyle
}
}
}
@@ -153,9 +179,9 @@ Item {
// Style delegates:
property Component buttonStyle: ButtonStyle {
- implicitHeight: 20
- implicitWidth: 100
background: Rectangle {
+ implicitHeight: 20
+ implicitWidth: 100
color: control.pressed ? "darkGray" : "lightGray"
antialiasing: true
border.color: "gray"
@@ -164,9 +190,9 @@ Item {
}
property Component textfieldStyle: TextFieldStyle {
- implicitWidth: 100
- implicitHeight: 20
background: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 20
color: "#f0f0f0"
antialiasing: true
border.color: "gray"
@@ -175,9 +201,6 @@ Item {
}
property Component sliderStyle: SliderStyle {
- implicitWidth: 100
- implicitHeight: 20
-
handle: Rectangle {
width: 14
height: 14
@@ -189,6 +212,9 @@ Item {
background: Rectangle {
height: 8
+ implicitWidth: 100
+ implicitHeight: 20
+
antialiasing: true
color: "darkGray"
border.color: "gray"
@@ -219,7 +245,8 @@ Item {
radius: height/2
}
}
- property Component tabFrameStyle: TabFrameStyle {
+
+ property Component tabViewStyle: TabViewStyle {
tabOverlap: 16
leftMargin: 12
@@ -232,7 +259,7 @@ Item {
anchors.fill: parent
anchors.topMargin: -4
border.color: "#898989"
- Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" }
+ Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" }
}
}
tab: Item {
diff --git a/examples/gallery/gallery.pro b/examples/gallery/gallery.pro
new file mode 100644
index 00000000..82f8b3e2
--- /dev/null
+++ b/examples/gallery/gallery.pro
@@ -0,0 +1,10 @@
+TEMPLATE = aux
+
+OTHER_FILES += \
+ main.qml \
+ content/ChildWindow.qml \
+ content/Controls.qml \
+ content/ImageViewer.qml \
+ content/ModelView.qml \
+ content/Panel.qml \
+ content/Styles.qml
diff --git a/examples/gallery/main.qml b/examples/gallery/main.qml
index b332e280..aff3cb4c 100644
--- a/examples/gallery/main.qml
+++ b/examples/gallery/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtQuick.Dialogs 1.0
import "content"
ApplicationWindow {
@@ -55,15 +61,21 @@ ApplicationWindow {
"incididunt ut labore et dolore magna aliqua.\n Ut enim ad minim veniam, quis nostrud "+
"exercitation ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. ";
+ ImageViewer { id: imageViewer }
+
+ FileDialog {
+ id: fileDialog
+ nameFilters: [ "Image files (*.png *.jpg)" ]
+ onAccepted: imageViewer.open(fileUrl)
+ }
+
ToolBar {
id: toolbar
width: parent.width
- height: 40
RowLayout {
spacing: 2
anchors.verticalCenter: parent.verticalCenter
ToolButton {
- iconName: "window-new"
iconSource: "images/window-new.png"
anchors.verticalCenter: parent.verticalCenter
onClicked: window1.visible = !window1.visible
@@ -71,81 +83,129 @@ ApplicationWindow {
tooltip: "Toggle visibility of the second window"
}
ToolButton {
- iconName: "document-open"
- iconSource: "images/document-open.png"
- anchors.verticalCenter: parent.verticalCenter
- onClicked: fileDialogLoad.open()
- tooltip: "(Pretend to) open a file"
+ action: openAction
}
ToolButton {
- iconName: "document-save-as"
iconSource: "images/document-save-as.png"
anchors.verticalCenter: parent.verticalCenter
- onClicked: fileDialogSave.open()
tooltip: "(Pretend to) save as..."
}
}
- FileDialog {
- id: fileDialogLoad
- folder: "/tmp"
- title: "Choose a file to open"
- selectMultiple: true
- nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ]
-
- onAccepted: { console.log("Accepted: " + filePaths) }
- }
-
- FileDialog {
- id: fileDialogSave
- folder: "/tmp"
- title: "Save as..."
- modal: true
- selectExisting: false
-
- onAccepted: { console.log("Accepted: " + filePath) }
- }
-
ChildWindow { id: window1 }
Action {
id: openAction
- text: "Open"
+ text: "&Open"
shortcut: "Ctrl+O"
- onTriggered: fileDialogLoad.open();
+ iconSource: "images/document-open.png"
+ onTriggered: fileDialog.open()
+ tooltip: "open an image"
}
Action {
id: copyAction
- text: "Copy"
+ text: "&Copy"
shortcut: "Ctrl+C"
iconName: "edit-copy"
+ enabled: (!!activeFocusItem && !!activeFocusItem["copy"])
+ onTriggered: activeFocusItem.copy()
}
Action {
id: cutAction
- text: "Cut"
+ text: "Cu&t"
shortcut: "Ctrl+X"
iconName: "edit-cut"
+ enabled: (!!activeFocusItem && !!activeFocusItem["cut"])
+ onTriggered: activeFocusItem.cut()
}
Action {
id: pasteAction
- text: "Paste"
+ text: "&Paste"
shortcut: "Ctrl+V"
iconName: "edit-paste"
+ enabled: (!!activeFocusItem && !!activeFocusItem["paste"])
+ onTriggered: activeFocusItem.paste()
}
- ContextMenu {
+ ExclusiveGroup {
+ id: textFormatGroup
+
+ Action {
+ id: a1
+ text: "Align Left"
+ checkable: true
+ Component.onCompleted: checked = true
+ }
+
+ Action {
+ id: a2
+ text: "Center"
+ checkable: true
+ }
+
+ Action {
+ id: a3
+ text: "Align Right"
+ checkable: true
+ }
+ }
+
+ Menu {
id: editmenu
- MenuItem { text: "Copy" ; iconName: "edit-copy" }
- MenuItem { text: "Cut" ; iconName: "edit-cut" }
- MenuItem { text: "Paste" ; iconName: "edit-paste" }
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator {}
+ Menu {
+ title: "Text Format"
+ MenuItem { action: a1 }
+ MenuItem { action: a2 }
+ MenuItem { action: a3 }
+ MenuSeparator { }
+ MenuItem { text: "Allow Hyphenation"; checkable: true }
+ MenuSeparator { }
+ Menu {
+ title: "More Stuff"
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator { }
+ Menu {
+ title: "More Stuff"
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator { }
+ Menu {
+ title: "More Stuff"
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator { }
+ Menu {
+ title: "More Stuff"
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ }
+ }
+ }
+ }
+ }
+ Menu {
+ title: "Font Style"
+ MenuItem { text: "Bold"; checkable: true }
+ MenuItem { text: "Italic"; checkable: true }
+ MenuItem { text: "Underline"; checkable: true }
+ }
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
- onPressed: editmenu.showPopup(mouseX, mouseY)
+ onPressed: editmenu.popup()
}
CheckBox {
@@ -159,12 +219,8 @@ ApplicationWindow {
menuBar: MenuBar {
Menu {
- text: "File"
- MenuItem {
- text: "Open"
- shortcut: "Ctrl+O"
- onTriggered: fileDialogLoad.open();
- }
+ title: "&File"
+ MenuItem { action: openAction }
MenuItem {
text: "Close"
shortcut: "Ctrl+Q"
@@ -172,19 +228,30 @@ ApplicationWindow {
}
}
Menu {
- text: "Edit"
+ title: "&Edit"
+ MenuItem { action: cutAction }
+ MenuItem { action: copyAction }
+ MenuItem { action: pasteAction }
+ MenuSeparator { }
MenuItem {
- text: "Copy"
+ text: "Do Nothing"
+ shortcut: "Ctrl+E,Shift+Ctrl+X"
+ enabled: false
}
MenuItem {
- text: "Paste"
+ text: "Not Even There"
+ shortcut: "Ctrl+E,Shift+Ctrl+Y"
+ visible: false
+ }
+ Menu {
+ title: "Me Neither"
+ visible: false
}
}
}
SystemPalette {id: syspal}
- StyleItem{ id: styleitem}
color: syspal.window
ListModel {
id: choices
@@ -194,30 +261,28 @@ ApplicationWindow {
ListElement { text: "Coconut" }
}
- TabFrame {
+ TabView {
id:frame
enabled: enabledCheck.checked
- position: controlPage.tabPosition
+ tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge
anchors.top: toolbar.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
- anchors.margins: styleitem.style == "mac" ? 12 : 0
+ anchors.margins: Qt.platform.os === "mac" ? 12 : 2
+
Tab {
+ id: controlPage
title: "Control"
- Controls { id: controlPage }
+ Controls { }
}
Tab {
title: "Itemviews"
ModelView { }
}
Tab {
- title: "Range"
- RangeTab { }
- }
- Tab {
title: "Styles"
- Styles { anchors.fill: parent}
+ Styles { anchors.fill: parent }
}
Tab {
title: "Sidebar"
diff --git a/examples/splitters/main.qml b/examples/splitters/main.qml
index d259f454..f035e644 100644
--- a/examples/splitters/main.qml
+++ b/examples/splitters/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,33 +38,46 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
ApplicationWindow {
width: 600
height: 400
- SplitterRow {
+ SplitView {
anchors.fill: parent
Rectangle {
id: column
width: 200
- Splitter.minimumWidth: 100
+ Layout.minimumWidth: 100
+ Layout.maximumWidth: 300
color: "lightsteelblue"
}
- handleWidth: 1
+ Rectangle {
+ id: column1
+ width: 200
+ Layout.minimumWidth: 100
+ Layout.maximumWidth: 300
+ color: "lightsteelblue"
+ }
- SplitterColumn {
- id: column2
+ SplitView {
+ orientation: Qt.Vertical
+ Layout.fillWidth: true
Rectangle {
id: row1
height: 200
color: "lightblue"
- Splitter.minimumHeight: 1
+ Layout.minimumHeight: 1
}
Rectangle {
diff --git a/examples/splitters/splitters.pro b/examples/splitters/splitters.pro
new file mode 100644
index 00000000..8b88e385
--- /dev/null
+++ b/examples/splitters/splitters.pro
@@ -0,0 +1,4 @@
+TEMPLATE = aux
+
+OTHER_FILES += \
+ main.qml
diff --git a/examples/splitters/splitters.qmlproject b/examples/splitters/splitters.qmlproject
new file mode 100644
index 00000000..e5a8bf02
--- /dev/null
+++ b/examples/splitters/splitters.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/tableview/main.qml b/examples/tableview/main.qml
index 7471fd92..8b5de6ef 100644
--- a/examples/tableview/main.qml
+++ b/examples/tableview/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,12 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
import QtQuick.XmlListModel 2.0
Rectangle {
@@ -112,12 +116,13 @@ Rectangle {
anchors.bottom: parent.bottom
anchors.margins: 8
- TabFrame {
+ TabView {
id:frame
focus:true
- enabled: toolbar.enabled
+ enabled: enabledCheck.checked
+
+ property int margins: Qt.platform.os === "mac" ? 16 : 0
- property int margins : styleitem.style == "mac" ? 16 : 0
height: parent.height - 34
anchors.right: parent.right
anchors.left: parent.left
@@ -131,38 +136,38 @@ Rectangle {
anchors.fill: parent
anchors.margins: 12
- TableColumn {
+ TableViewColumn {
role: "title"
title: "Title"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "credit"
title: "Credit"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "imagesource"
title: "Image source"
width: 200
visible: true
}
- frame: frameCheckbox.checked
+ frameVisible: frameCheckbox.checked
headerVisible: headerCheckbox.checked
sortIndicatorVisible: sortableCheckbox.checked
- alternateRowColor: alternateCheckbox.checked
+ alternatingRowColors: alternateCheckbox.checked
}
}
Tab {
- title: "Multivalue "
+ title: "Multivalue"
TableView {
model: nestedModel
anchors.fill: parent
anchors.margins: 12
- TableColumn {
+ TableViewColumn {
role: "attributes"
title: "Text and Color"
width: 220
@@ -186,14 +191,14 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
elide: itemElideMode
text: itemValue.get(0).description
- color: itemForeground
+ color: itemTextColor
}
}
- frame: frameCheckbox.checked
+ frameVisible: frameCheckbox.checked
headerVisible: headerCheckbox.checked
sortIndicatorVisible: sortableCheckbox.checked
- alternateRowColor: alternateCheckbox.checked
+ alternatingRowColors: alternateCheckbox.checked
}
}
Tab {
@@ -203,165 +208,169 @@ Rectangle {
model: largeModel
anchors.margins: 12
anchors.fill: parent
- TableColumn {
+ TableViewColumn {
role: "name"
title: "Name"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "age"
title: "Age"
width: 120
}
- TableColumn {
+ TableViewColumn {
role: "gender"
title: "Gender"
width: 120
}
- frame: frameCheckbox.checked
+ frameVisible: frameCheckbox.checked
headerVisible: headerCheckbox.checked
sortIndicatorVisible: sortableCheckbox.checked
- alternateRowColor: alternateCheckbox.checked
+ alternatingRowColors: alternateCheckbox.checked
}
}
Tab {
title: "Delegates"
+ Item {
+ anchors.fill: parent
- ListModel {
- id: delegatemenu
- ListElement { text: "Shiny delegate" }
- ListElement { text: "Scale selected" }
- ListElement { text: "Editable items" }
- }
- Component {
- id: delegate1
- Item {
- clip: true
- Text {
- width: parent.width
- anchors.margins: 4
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue ? itemValue : ""
- color: itemForeground
- }
+ ListModel {
+ id: delegatemenu
+ ListElement { text: "Shiny delegate" }
+ ListElement { text: "Scale selected" }
+ ListElement { text: "Editable items" }
}
- }
- Component {
- id: slickRowDelegate
- Rectangle { color: itemAlternateBackground ? "#cef" : "white" }
- }
-
- Component {
- id: delegate2
- Item {
- height: itemSelected? 60 : 20
- Behavior on height{ NumberAnimation{} }
- Text {
- width: parent.width
- anchors.margins: 4
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue ? itemValue : ""
- color: itemForeground
+ Component {
+ id: delegate1
+ Item {
+ clip: true
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: itemElideMode
+ text: itemValue ? itemValue : ""
+ color: itemTextColor
+ }
}
}
- }
- Component {
- id: editableDelegate
- Item {
- Text {
- width: parent.width
- anchors.margins: 4
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue ? itemValue : ""
- color: itemForeground
- visible: !itemSelected
- }
- Loader { // Initialize text editor lazily to improve performance
- anchors.fill: parent
- anchors.margins: 4
- property string modelText: itemValue
- property string editorText: item ? item.text : itemValue
- onEditorTextChanged: model.setProperty(rowIndex, role, editorText)
- sourceComponent: itemSelected ? editor : null
- Component {id: editor ; TextInput{ color: itemForeground ; text: modelText} }
- }
+ Component {
+ id: slickRowDelegate
+ Rectangle { color: alternateBackground ? "#cef" : "white" }
}
- }
- TableView {
- model: largeModel
- anchors.margins: 12
- anchors.fill:parent
- frame: frameCheckbox.checked
- headerVisible: headerCheckbox.checked
- sortIndicatorVisible: sortableCheckbox.checked
- alternateRowColor: alternateCheckbox.checked
- TableColumn {
- role: "name"
- title: "Name"
- width: 120
- }
- TableColumn {
- role: "age"
- title: "Age"
- width: 120
- }
- TableColumn {
- role: "sex"
- title: "Sex"
- width: 120
+ Component {
+ id: delegate2
+ Item {
+ height: itemSelected? 60 : 20
+ Behavior on height{ NumberAnimation{} }
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: itemElideMode
+ text: itemValue ? itemValue : ""
+ color: itemTextColor
+ }
+ }
}
- headerDelegate: BorderImage{
- source: "images/header.png"
- border{left:2;right:2;top:2;bottom:2}
- Text {
- text: itemValue
- anchors.centerIn:parent
- color:"#333"
+ Component {
+ id: editableDelegate
+ Item {
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: itemElideMode
+ text: itemValue ? itemValue : ""
+ color: itemTextColor
+ visible: !itemSelected
+ }
+ Loader { // Initialize text editor lazily to improve performance
+ anchors.fill: parent
+ anchors.margins: 4
+ property string modelText: itemValue
+ property string editorText: item ? item.text : itemValue
+ onEditorTextChanged: model.setProperty(rowIndex, role, editorText)
+ sourceComponent: itemSelected ? editor : null
+ Component {id: editor ; TextInput{ color: itemTextColor ; text: modelText} }
+ }
}
}
+ TableView {
+ model: largeModel
+ anchors.margins: 12
+ anchors.fill:parent
+ frameVisible: frameCheckbox.checked
+ headerVisible: headerCheckbox.checked
+ sortIndicatorVisible: sortableCheckbox.checked
+ alternatingRowColors: alternateCheckbox.checked
+
+ TableViewColumn {
+ role: "name"
+ title: "Name"
+ width: 120
+ }
+ TableViewColumn {
+ role: "age"
+ title: "Age"
+ width: 120
+ }
+ TableViewColumn {
+ role: "sex"
+ title: "Sex"
+ width: 120
+ }
- rowDelegate: Rectangle {
- height: 20
- color: itemSelected ? "#448" : (itemAlternateBackground ? "#eee" : "#fff")
- border.color:"#ccc"
- border.width: 1
- anchors.left: parent.left
- anchors.leftMargin: -2
- anchors.rightMargin: -1
- BorderImage{
- id: selected
- anchors.fill: parent
- source: "images/selectedrow.png"
- visible: itemSelected
- border{left:2; right:2; top:2; bottom:2}
- SequentialAnimation {
- running: true; loops: Animation.Infinite
- NumberAnimation { target:selected; property: "opacity"; to: 1.0; duration: 900}
- NumberAnimation { target:selected; property: "opacity"; to: 0.5; duration: 900}
+ headerDelegate: BorderImage{
+ source: "images/header.png"
+ border{left:2;right:2;top:2;bottom:2}
+ Text {
+ text: itemValue
+ anchors.centerIn:parent
+ color:"#333"
}
}
- }
- itemDelegate: {
- switch (delegateChooser.selectedIndex) {
- case 0:
- return delegate1
- case 1:
- return delegate2
- case 2:
- return editableDelegate
+ rowDelegate: Rectangle {
+ height: 20
+ color: rowSelected ? "#448" : (alternateBackground ? "#eee" : "#fff")
+ border.color:"#ccc"
+ border.width: 1
+ anchors.left: parent ? parent.left : undefined
+ anchors.leftMargin: -2
+ anchors.rightMargin: -1
+ BorderImage{
+ id: selected
+ anchors.fill: parent
+ source: "images/selectedrow.png"
+ visible: rowSelected
+ border{left:2; right:2; top:2; bottom:2}
+ SequentialAnimation {
+ running: true; loops: Animation.Infinite
+ NumberAnimation { target:selected; property: "opacity"; to: 1.0; duration: 900}
+ NumberAnimation { target:selected; property: "opacity"; to: 0.5; duration: 900}
+ }
+ }
+ }
+
+ itemDelegate: {
+ switch (delegateChooser.selectedIndex) {
+ case 0:
+ return delegate1
+ case 1:
+ return delegate2
+ case 2:
+ return editableDelegate
+ }
}
}
}
diff --git a/examples/tableview/tableview.pro b/examples/tableview/tableview.pro
new file mode 100644
index 00000000..8b88e385
--- /dev/null
+++ b/examples/tableview/tableview.pro
@@ -0,0 +1,4 @@
+TEMPLATE = aux
+
+OTHER_FILES += \
+ main.qml
diff --git a/examples/text/example.html b/examples/text/example.html
new file mode 100644
index 00000000..0560897b
--- /dev/null
+++ b/examples/text/example.html
@@ -0,0 +1,79 @@
+<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
+<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt; font-weight:600;">QTextEdit</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">If you are viewing this document in the <span style=" font-style:italic;">textedit</span> example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment. </p>
+<p style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:18pt; font-weight:600;"><span style=" font-size:16pt;">Font and Paragraph Styles</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit supports </span><span style=" font-size:11pt; font-weight:600;">bold</span><span style=" font-size:11pt;">, </span><span style=" font-size:11pt; font-style:italic;">italic</span><span style=" font-size:11pt;">, and </span><span style=" font-size:11pt; text-decoration: underline;">underlined</span><span style=" font-size:11pt;"> font styles, and can display </span><span style=" font-size:11pt; font-weight:600; color:#00007f;">multicolored</span><span style=" font-size:11pt;"> </span><span style=" font-size:11pt; font-weight:600; color:#aa0000;">text</span><span style=" font-size:11pt;">. Font families such as </span><span style=" font-family:'Times'; font-size:11pt; font-weight:600;">Times New Roman</span><span style=" font-size:11pt;"> and </span><span style=" font-family:'Courier'; font-size:11pt; font-weight:600;">Courier</span><span style=" font-size:11pt;"> can also be used directly. </span><span style=" font-size:11pt; font-style:italic;">If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.</p>
+<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try changing the alignment of some text and resize the editor to see how the text layout changes.</span> </p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">Lists</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Different kinds of lists can be included in rich text documents. Standard bullet lists can be nested, using different symbols for each level of the list: </span></p>
+<ul style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Disc symbols are typically used for top-level list items. </li></ul>
+<ul type=circle style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Circle symbols can be used to distinguish between items in lower-level lists.</li></ul>
+<ul type=square style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Square symbols provide a reasonable alternative to discs and circles. </li></ul>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure: </p>
+<ol style="-qt-list-indent: 1;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction</li>
+<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Tools </li></ol>
+<ol type=a style="-qt-list-indent: 2;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Assistant</li>
+<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Designer</li>
+<ol type=A style="-qt-list-indent: 3;"><li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Form Editor</li>
+<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Component Architecture</li></ol>
+<li style=" font-size:11pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Qt Linguist</li></ol>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">The list will automatically be renumbered if you add or remove items. <span style=" font-style:italic;">Try adding new sections to the above list or removing existing item to see the numbers change.</span> </p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
+<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Images</span></p>
+<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them. </span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><img src="qrc:qml/images/logo32.png" /><span style=" font-style:italic;"> Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Tables</span></p>
+<p align="justify" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;"><span style=" font-size:11pt; font-weight:400;">QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns. </span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
+<table border="1" align="center" width="90%" cellspacing="0" cellpadding="4">
+<tr>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> </p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Development Tools </span></p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Programming Techniques </span></p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Graphical User Interfaces </span></p></td></tr>
+<tr>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">9:00 - 11:00 </span></p></td>
+<td colspan="3">
+<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Introduction to <span style=" font-style:italic;">Qt </span></p></td></tr>
+<tr>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">11:00 - 13:00 </span></p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Using <span style=" font-style:italic;">qmake</span> </p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Object-oriented Programming </p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Layouts in <span style=" font-style:italic;">Qt</span> </p></td></tr>
+<tr>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">13:00 - 15:00 </span></p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Designer</span> Tutorial </p></td>
+<td rowspan="2">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Extreme Programming </p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Writing Custom Styles </p></td></tr>
+<tr>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">15:00 - 17:00 </span></p></td>
+<td>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Qt Linguist</span> and Internationalization </p></td>
+<td></td></tr></table>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"></p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt; font-style:italic;">Try adding text to the cells in the table and experiment with the alignment of the paragraphs.</p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Hyperlinks</span></p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;">QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in </span><span style=" font-size:11pt; font-style:italic;">Qt Assistant</span><span style=" font-size:11pt;">. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programatically.</span></p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-size:16pt; font-weight:600;">Undo and Redo</span></p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;">Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.</p>
+<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><span style=" font-style:italic;">Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.</span> </p></body></html>
diff --git a/examples/text/qml/images/editcopy.png b/examples/text/qml/images/editcopy.png
new file mode 100644
index 00000000..f5513644
--- /dev/null
+++ b/examples/text/qml/images/editcopy.png
Binary files differ
diff --git a/examples/text/qml/images/editcut.png b/examples/text/qml/images/editcut.png
new file mode 100644
index 00000000..a784fd57
--- /dev/null
+++ b/examples/text/qml/images/editcut.png
Binary files differ
diff --git a/examples/text/qml/images/editpaste.png b/examples/text/qml/images/editpaste.png
new file mode 100644
index 00000000..64c0b2d6
--- /dev/null
+++ b/examples/text/qml/images/editpaste.png
Binary files differ
diff --git a/examples/text/qml/images/editredo.png b/examples/text/qml/images/editredo.png
new file mode 100644
index 00000000..8875bf24
--- /dev/null
+++ b/examples/text/qml/images/editredo.png
Binary files differ
diff --git a/examples/text/qml/images/editundo.png b/examples/text/qml/images/editundo.png
new file mode 100644
index 00000000..a3bd5e0b
--- /dev/null
+++ b/examples/text/qml/images/editundo.png
Binary files differ
diff --git a/examples/text/qml/images/exportpdf.png b/examples/text/qml/images/exportpdf.png
new file mode 100644
index 00000000..ebb44e6b
--- /dev/null
+++ b/examples/text/qml/images/exportpdf.png
Binary files differ
diff --git a/examples/text/qml/images/filenew.png b/examples/text/qml/images/filenew.png
new file mode 100644
index 00000000..d3882c7b
--- /dev/null
+++ b/examples/text/qml/images/filenew.png
Binary files differ
diff --git a/examples/text/qml/images/fileopen.png b/examples/text/qml/images/fileopen.png
new file mode 100644
index 00000000..fc06c5ec
--- /dev/null
+++ b/examples/text/qml/images/fileopen.png
Binary files differ
diff --git a/examples/text/qml/images/fileprint.png b/examples/text/qml/images/fileprint.png
new file mode 100644
index 00000000..10ca56c8
--- /dev/null
+++ b/examples/text/qml/images/fileprint.png
Binary files differ
diff --git a/examples/text/qml/images/filesave.png b/examples/text/qml/images/filesave.png
new file mode 100644
index 00000000..b41ecf53
--- /dev/null
+++ b/examples/text/qml/images/filesave.png
Binary files differ
diff --git a/examples/text/qml/images/logo32.png b/examples/text/qml/images/logo32.png
new file mode 100644
index 00000000..5f91e987
--- /dev/null
+++ b/examples/text/qml/images/logo32.png
Binary files differ
diff --git a/examples/text/qml/images/textbold.png b/examples/text/qml/images/textbold.png
new file mode 100644
index 00000000..38400bd1
--- /dev/null
+++ b/examples/text/qml/images/textbold.png
Binary files differ
diff --git a/examples/text/qml/images/textcenter.png b/examples/text/qml/images/textcenter.png
new file mode 100644
index 00000000..2ef5b2ee
--- /dev/null
+++ b/examples/text/qml/images/textcenter.png
Binary files differ
diff --git a/examples/text/qml/images/textitalic.png b/examples/text/qml/images/textitalic.png
new file mode 100644
index 00000000..0170ee26
--- /dev/null
+++ b/examples/text/qml/images/textitalic.png
Binary files differ
diff --git a/examples/text/qml/images/textjustify.png b/examples/text/qml/images/textjustify.png
new file mode 100644
index 00000000..39cd6c1a
--- /dev/null
+++ b/examples/text/qml/images/textjustify.png
Binary files differ
diff --git a/examples/text/qml/images/textleft.png b/examples/text/qml/images/textleft.png
new file mode 100644
index 00000000..83a66d55
--- /dev/null
+++ b/examples/text/qml/images/textleft.png
Binary files differ
diff --git a/examples/text/qml/images/textright.png b/examples/text/qml/images/textright.png
new file mode 100644
index 00000000..e7c04645
--- /dev/null
+++ b/examples/text/qml/images/textright.png
Binary files differ
diff --git a/examples/text/qml/images/textunder.png b/examples/text/qml/images/textunder.png
new file mode 100644
index 00000000..968bac5e
--- /dev/null
+++ b/examples/text/qml/images/textunder.png
Binary files differ
diff --git a/examples/text/qml/images/zoomin.png b/examples/text/qml/images/zoomin.png
new file mode 100644
index 00000000..d46f5aff
--- /dev/null
+++ b/examples/text/qml/images/zoomin.png
Binary files differ
diff --git a/examples/text/qml/images/zoomout.png b/examples/text/qml/images/zoomout.png
new file mode 100644
index 00000000..46326566
--- /dev/null
+++ b/examples/text/qml/images/zoomout.png
Binary files differ
diff --git a/examples/text/qml/main.qml b/examples/text/qml/main.qml
new file mode 100644
index 00000000..dd8b1848
--- /dev/null
+++ b/examples/text/qml/main.qml
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtQuick.Dialogs 1.0
+import org.qtproject.example 1.0
+
+ApplicationWindow {
+ width: 640
+ height: 480
+ minimumWidth: 400
+ minimumHeight: 300
+
+ title: document.documentTitle + " - Text Editor Example"
+
+ Action {
+ id: cut
+ text: "Cut"
+ shortcut: "ctrl+x"
+ iconSource: "images/editcut.png"
+ iconName: "edit-cut"
+ }
+
+ Action {
+ id: copy
+ text: "Copy"
+ shortcut: "Ctrl+C"
+ iconSource: "images/editcopy.png"
+ iconName: "edit-copy"
+ onTriggered: console.log("Ctrl C pressed - in action...")
+ }
+
+ Action {
+ id: paste
+ text: "Paste"
+ shortcut: "ctrl+v"
+ iconSource: "qrc:images/editpaste.png"
+ iconName: "edit-paste"
+ }
+
+ Action {
+ id: alignLeft
+ text: "&Left"
+ iconSource: "images/textleft.png"
+ iconName: "format-justify-left"
+ shortcut: "ctrl+l"
+ onTriggered: document.alignment = Qt.AlignLeft
+ checkable: true
+ checked: document.alignment == Qt.AlignLeft
+ }
+ Action {
+ id: alignCenter
+ text: "C&enter"
+ iconSource: "images/textcenter.png"
+ iconName: "format-justify-center"
+ onTriggered: document.alignment = Qt.AlignCenter
+ checkable: true
+ checked: document.alignment == Qt.AlignCenter
+ }
+ Action {
+ id: alignRight
+ text: "&Right"
+ iconSource: "images/textright.png"
+ iconName: "format-justify-right"
+ onTriggered: document.alignment = Qt.AlignRight
+ checkable: true
+ checked: document.alignment == Qt.AlignRight
+ }
+ Action {
+ id: alignJustify
+ text: "&Justify"
+ iconSource: "images/textjustify.png"
+ iconName: "format-justify-fill"
+ onTriggered: document.alignment = Qt.AlignJustify
+ checkable: true
+ checked: document.alignment == Qt.AlignJustify
+ }
+
+ Action {
+ id: bold
+ text: "&Bold"
+ iconSource: "images/textbold.png"
+ iconName: "format-text-bold"
+ onTriggered: document.bold = !document.bold
+ checkable: true
+ checked: document.bold
+ }
+ Action {
+ id: italic
+ text: "&Italic"
+ iconSource: "images/textitalic.png"
+ iconName: "format-text-italic"
+ onTriggered: document.italic = !document.italic
+ checkable: true
+ checked: document.italic
+ }
+ Action {
+ id: underline
+ text: "&Underline"
+ iconSource: "images/textunder.png"
+ iconName: "format-text-underline"
+ onTriggered: document.underline = !document.underline
+ checkable: true
+ checked: document.underline
+ }
+ Action {
+ id: color
+ text: "&Color ..."
+ iconSource: "images/textcolor.png"
+ iconName: "format-text-color"
+ }
+
+ FileDialog {
+ id: file
+ nameFilters: ["Text files (*.txt)", "HTML files (*.html)"]
+ onAccepted: document.fileUrl = fileUrl
+ }
+
+ Action {
+ id: fileOpen
+ iconSource: "images/fileopen.png"
+ iconName: "document-open"
+ text: "Open"
+ onTriggered: file.open()
+ }
+
+ menuBar: MenuBar {
+ Menu {
+ title: "&File"
+ MenuItem { action: fileOpen }
+ MenuItem { text: "Quit"; onTriggered: Qt.quit() }
+ }
+ Menu {
+ title: "&Edit"
+ MenuItem { action: copy }
+ MenuItem { action: cut }
+ MenuItem { action: paste }
+ }
+ Menu {
+ title: "F&ormat"
+ MenuItem { action: bold }
+ MenuItem { action: italic }
+ MenuItem { action: underline }
+ MenuSeparator {}
+ MenuItem { action: alignLeft }
+ MenuItem { action: alignCenter }
+ MenuItem { action: alignRight }
+ MenuItem { action: alignJustify }
+ MenuSeparator {}
+ MenuItem { action: color }
+ }
+ Menu {
+ title: "&Help"
+ MenuItem { text: "About..." }
+ MenuItem { text: "About Qt" }
+ }
+ }
+
+ toolBar: ToolBar {
+ id: mainToolBar
+ width: parent.width
+ RowLayout {
+ anchors.fill: parent
+ spacing: 1
+ ToolButton { action: fileOpen }
+
+ Item { width: 4 }
+ ToolButton { action: copy }
+ ToolButton { action: cut }
+ ToolButton { action: paste }
+ Item { width: 4 }
+ ToolButton { action: bold }
+ ToolButton { action: italic }
+ ToolButton { action: underline }
+
+ Item { width: 4 }
+ ToolButton { action: alignLeft }
+ ToolButton { action: alignCenter }
+ ToolButton { action: alignRight }
+ ToolButton { action: alignJustify }
+ Item { Layout.fillWidth: true }
+ }
+ }
+ ToolBar {
+ id: secondaryToolBar
+ width: parent.width
+
+ RowLayout {
+ anchors.fill: parent
+ anchors.margins: 4
+ ComboBox {
+ model: document.defaultFontSizes
+ onCurrentTextChanged: document.fontSize = currentText
+ currentIndex: document.defaultFontSizes.indexOf(document.fontSize + "")
+ }
+ TextField { id: fontEdit; enabled: false }
+ Item { Layout.fillWidth: true }
+ }
+ }
+
+ TextArea {
+ Accessible.name: "document"
+ id: textArea
+ width: parent.width
+ anchors.top: secondaryToolBar.bottom
+ anchors.bottom: parent.bottom
+ text: document.text
+ textFormat: Qt.RichText
+ Component.onCompleted: forceActiveFocus()
+ }
+
+ DocumentHandler {
+ id: document
+ target: textArea
+ cursorPosition: textArea.cursorPosition
+ selectionStart: textArea.selectionStart
+ selectionEnd: textArea.selectionEnd
+ onCurrentFontChanged: {
+ fontEdit.text = currentFont.family
+ }
+ }
+}
diff --git a/examples/text/resources.qrc b/examples/text/resources.qrc
new file mode 100644
index 00000000..e67fac6a
--- /dev/null
+++ b/examples/text/resources.qrc
@@ -0,0 +1,26 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>qml/main.qml</file>
+ <file>qml/images/logo32.png</file>
+ <file>qml/images/editcopy.png</file>
+ <file>qml/images/editcut.png</file>
+ <file>qml/images/editpaste.png</file>
+ <file>qml/images/editredo.png</file>
+ <file>qml/images/editundo.png</file>
+ <file>qml/images/exportpdf.png</file>
+ <file>qml/images/filenew.png</file>
+ <file>qml/images/fileopen.png</file>
+ <file>qml/images/fileprint.png</file>
+ <file>qml/images/filesave.png</file>
+ <file>qml/images/textbold.png</file>
+ <file>qml/images/textcenter.png</file>
+ <file>qml/images/textitalic.png</file>
+ <file>qml/images/textjustify.png</file>
+ <file>qml/images/textleft.png</file>
+ <file>qml/images/textright.png</file>
+ <file>qml/images/textunder.png</file>
+ <file>qml/images/zoomin.png</file>
+ <file>qml/images/zoomout.png</file>
+ <file>example.html</file>
+</qresource>
+</RCC>
diff --git a/examples/text/src/documenthandler.cpp b/examples/text/src/documenthandler.cpp
new file mode 100644
index 00000000..48b6d033
--- /dev/null
+++ b/examples/text/src/documenthandler.cpp
@@ -0,0 +1,284 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "documenthandler.h"
+
+#include <QtGui/QTextDocument>
+#include <QtGui/QTextCursor>
+#include <QtGui/QFontDatabase>
+#include <QtCore/QFileInfo>
+
+DocumentHandler::DocumentHandler()
+ : m_target(0)
+ , m_doc(0)
+ , m_cursorPosition(-1)
+ , m_selectionStart(0)
+ , m_selectionEnd(0)
+{
+ setFileUrl(QUrl("qrc:/example.html"));
+}
+
+void DocumentHandler::setTarget(QQuickItem *target)
+{
+ m_doc = 0;
+ m_target = target;
+ if (!m_target)
+ return;
+
+ QVariant doc = m_target->property("textDocument");
+ if (doc.canConvert<QQuickTextDocument*>()) {
+ QQuickTextDocument *qqdoc = doc.value<QQuickTextDocument*>();
+ if (qqdoc)
+ m_doc = qqdoc->textDocument();
+ }
+ emit targetChanged();
+}
+
+void DocumentHandler::setFileUrl(const QUrl &arg)
+{
+ if (m_fileUrl != arg) {
+ m_fileUrl = arg;
+ QString fileName = QQmlFile::urlToLocalFileOrQrc(arg);
+ if (QFile::exists(fileName)) {
+ QFile file(fileName);
+ if (file.open(QFile::ReadOnly)) {
+ QByteArray data = file.readAll();
+ QTextCodec *codec = QTextCodec::codecForHtml(data);
+ setText(codec->toUnicode(data));
+ if (m_doc)
+ m_doc->setModified(false);
+ if (fileName.isEmpty())
+ m_documentTitle = QStringLiteral("untitled.txt");
+ else
+ m_documentTitle = QFileInfo(fileName).fileName();
+
+ emit textChanged();
+ emit documentTitleChanged();
+ }
+ }
+ emit fileUrlChanged();
+ }
+}
+
+QString DocumentHandler::documentTitle() const
+{
+ return m_documentTitle;
+}
+
+void DocumentHandler::setDocumentTitle(QString arg)
+{
+ if (m_documentTitle != arg) {
+ m_documentTitle = arg;
+ emit documentTitleChanged();
+ }
+}
+
+void DocumentHandler::setText(const QString &arg)
+{
+ if (m_text != arg) {
+ m_text = arg;
+ emit textChanged();
+ }
+}
+
+QUrl DocumentHandler::fileUrl() const
+{
+ return m_fileUrl;
+}
+
+QString DocumentHandler::text() const
+{
+ return m_text;
+}
+
+void DocumentHandler::setCursorPosition(int position)
+{
+ if (position == m_cursorPosition)
+ return;
+
+ m_cursorPosition = position;
+
+ emit currentFontChanged();
+ emit alignmentChanged();
+ emit boldChanged();
+ emit italicChanged();
+ emit underlineChanged();
+ emit fontSizeChanged();
+}
+
+QTextCursor DocumentHandler::textCursor() const
+{
+ QTextCursor cursor = QTextCursor(m_doc);
+ if (m_selectionStart != m_selectionEnd) {
+ cursor.setPosition(m_selectionStart);
+ cursor.setPosition(m_selectionEnd, QTextCursor::KeepAnchor);
+ } else {
+ cursor.setPosition(m_cursorPosition);
+ }
+ return cursor;
+}
+
+void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
+{
+ QTextCursor cursor = textCursor();
+ if (!cursor.hasSelection())
+ cursor.select(QTextCursor::WordUnderCursor);
+ cursor.mergeCharFormat(format);
+}
+
+void DocumentHandler::setSelectionStart(int position)
+{
+ m_selectionStart = position;
+// emit selectionStartChanged();
+}
+
+void DocumentHandler::setSelectionEnd(int position)
+{
+ m_selectionEnd = position;
+// emit selectionEndChanged();
+}
+
+void DocumentHandler::setAlignment(Qt::Alignment a)
+{
+ QTextBlockFormat fmt;
+ fmt.setAlignment((Qt::Alignment) a);
+ QTextCursor cursor = QTextCursor(m_doc);
+ cursor.setPosition(m_selectionStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(m_selectionEnd, QTextCursor::KeepAnchor);
+ cursor.mergeBlockFormat(fmt);
+ emit alignmentChanged();
+}
+
+Qt::Alignment DocumentHandler::alignment() const
+{
+// if (!m_doc || m_doc->isEmpty() || m_cursorPosition < 0)
+// return Qt::AlignLeft;
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull() || cursor.blockNumber() == 0)
+ return Qt::AlignLeft;
+ return textCursor().blockFormat().alignment();
+}
+
+bool DocumentHandler::bold() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull() || cursor.blockNumber() == 0)
+ return false;
+ return textCursor().charFormat().fontWeight() == QFont::Bold;
+}
+
+bool DocumentHandler::italic() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull() || cursor.blockNumber() == 0)
+ return false;
+ return textCursor().charFormat().fontItalic();
+}
+
+bool DocumentHandler::underline() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull() || cursor.blockNumber() == 0)
+ return false;
+ return textCursor().charFormat().fontUnderline();
+}
+
+void DocumentHandler::setBold(bool arg)
+{
+ QTextCharFormat fmt;
+ fmt.setFontWeight(arg ? QFont::Bold : QFont::Normal);
+ mergeFormatOnWordOrSelection(fmt);
+ emit boldChanged();
+}
+
+void DocumentHandler::setItalic(bool arg)
+{
+ QTextCharFormat fmt;
+ fmt.setFontItalic(arg);
+ mergeFormatOnWordOrSelection(fmt);
+ emit italicChanged();
+}
+
+void DocumentHandler::setUnderline(bool arg)
+{
+ QTextCharFormat fmt;
+ fmt.setFontUnderline(arg);
+ mergeFormatOnWordOrSelection(fmt);
+ emit underlineChanged();
+}
+
+int DocumentHandler::fontSize() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return 0;
+ QTextCharFormat format = cursor.charFormat();
+ return format.font().pointSize();
+}
+
+void DocumentHandler::setFontSize(int arg)
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return;
+ QTextCharFormat format;
+ format.setFontPointSize(arg);
+ mergeFormatOnWordOrSelection(format);
+ emit fontSizeChanged();
+}
+
+QFont DocumentHandler::currentFont() const
+{
+ QTextCursor cursor = textCursor();
+ if (cursor.isNull())
+ return QFont();
+ QTextCharFormat format = cursor.charFormat();
+ return format.font();
+}
+
+QStringList DocumentHandler::defaultFontSizes() const
+{
+ // uhm... this is quite ugly
+ QStringList sizes;
+ QFontDatabase db;
+ foreach (int size, db.standardSizes())
+ sizes.append(QString::number(size));
+ return sizes;
+}
diff --git a/examples/text/src/documenthandler.h b/examples/text/src/documenthandler.h
new file mode 100644
index 00000000..c60bc1d5
--- /dev/null
+++ b/examples/text/src/documenthandler.h
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOCUMENTHANDLER_H
+#define DOCUMENTHANDLER_H
+
+#include <QQuickTextDocument>
+
+#include <QtGui/QTextCharFormat>
+#include <QtCore/QTextCodec>
+
+#include <qqmlfile.h>
+
+QT_BEGIN_NAMESPACE
+class QTextDocument;
+QT_END_NAMESPACE
+
+class DocumentHandler : public QObject
+{
+ Q_OBJECT
+
+ Q_ENUMS(HAlignment)
+
+ Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
+
+ Q_PROPERTY(QFont currentFont READ currentFont NOTIFY currentFontChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+
+ Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
+
+ Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
+
+ Q_PROPERTY(QStringList defaultFontSizes READ defaultFontSizes NOTIFY defaultFontSizesChanged)
+
+ Q_PROPERTY(QUrl fileUrl READ fileUrl WRITE setFileUrl NOTIFY fileUrlChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle NOTIFY documentTitleChanged)
+
+public:
+ DocumentHandler();
+
+ QQuickItem *target() { return m_target; }
+
+ void setTarget(QQuickItem *target);
+
+ void setCursorPosition(int position);
+ void setSelectionStart(int position);
+ void setSelectionEnd(int position);
+
+ int cursorPosition() const { return m_cursorPosition; }
+ int selectionStart() const { return m_selectionStart; }
+ int selectionEnd() const { return m_selectionEnd; }
+
+ QFont currentFont() const;
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment a);
+
+ bool bold() const;
+ bool italic() const;
+ bool underline() const;
+ int fontSize() const;
+
+ QStringList defaultFontSizes() const;
+ QUrl fileUrl() const;
+ QString text() const;
+
+ QString documentTitle() const;
+
+public Q_SLOTS:
+ void setBold(bool arg);
+ void setItalic(bool arg);
+ void setUnderline(bool arg);
+ void setFontSize(int arg);
+
+ void setFileUrl(const QUrl &arg);
+ void setText(const QString &arg);
+
+ void setDocumentTitle(QString arg);
+
+Q_SIGNALS:
+ void targetChanged();
+ void cursorPositionChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
+
+ void currentFontChanged();
+ void alignmentChanged();
+
+ void boldChanged();
+ void italicChanged();
+ void underlineChanged();
+
+ void fontSizeChanged();
+ void defaultFontSizesChanged();
+
+ void fileUrlChanged();
+
+ void textChanged();
+ void documentTitleChanged();
+
+private:
+ QTextCursor textCursor() const;
+ void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
+
+ QQuickItem *m_target;
+ QTextDocument *m_doc;
+
+ int m_cursorPosition;
+ int m_selectionStart;
+ int m_selectionEnd;
+
+ QFont m_font;
+ bool m_bold;
+ bool m_italic;
+ bool m_underline;
+ int m_fontSize;
+ QUrl m_fileUrl;
+ QString m_text;
+ QString m_documentTitle;
+};
+
+#endif
diff --git a/examples/text/src/main.cpp b/examples/text/src/main.cpp
new file mode 100644
index 00000000..0fc064dc
--- /dev/null
+++ b/examples/text/src/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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 <QtWidgets/QApplication>
+#include <QtQml>
+#include <QtQuick/QQuickView>
+#include <QtCore/QString>
+
+#include "documenthandler.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QQmlEngine engine;
+
+ qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
+
+ QQmlComponent component(&engine);
+ component.loadUrl(QUrl("qrc:/qml/main.qml"));
+ if ( !component.isReady() ) {
+ qWarning("%s", qPrintable(component.errorString()));
+ return -1;
+ }
+ QObject *topLevel = component.create();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
+ if ( !window ) {
+ qWarning("Error: Your root item has to be a Window.");
+ return -1;
+ }
+
+ QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
+ window->show();
+ return app.exec();
+}
diff --git a/examples/text/src/src.pri b/examples/text/src/src.pri
new file mode 100644
index 00000000..2b89cd62
--- /dev/null
+++ b/examples/text/src/src.pri
@@ -0,0 +1,9 @@
+SOURCES += \
+ $$PWD/documenthandler.cpp \
+ $$PWD/main.cpp
+
+
+HEADERS += \
+ $$PWD/documenthandler.h
+
+
diff --git a/examples/text/text.pro b/examples/text/text.pro
new file mode 100644
index 00000000..8b36231a
--- /dev/null
+++ b/examples/text/text.pro
@@ -0,0 +1,16 @@
+QT += widgets qml quick
+CONFIG += console
+TARGET = text
+
+include(src/src.pri)
+
+OTHER_FILES += \
+ qml/main.qml
+
+RESOURCES += \
+ resources.qrc
+
+MOC_DIR = ./.moc
+OBJECTS_DIR = ./.obj
+UI_DIR = ./.ui
+RCC_DIR = ./.rcc
diff --git a/examples/touch/content/AndroidDelegate.qml b/examples/touch/content/AndroidDelegate.qml
index 08f8b562..36a439a8 100644
--- a/examples/touch/content/AndroidDelegate.qml
+++ b/examples/touch/content/AndroidDelegate.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,7 +38,11 @@
**
****************************************************************************/
-import QtQuick 2.0
+
+
+
+
+import QtQuick 2.1
Item {
id: root
diff --git a/examples/touch/content/ButtonPage.qml b/examples/touch/content/ButtonPage.qml
index 06b983db..cc5925ce 100644
--- a/examples/touch/content/ButtonPage.qml
+++ b/examples/touch/content/ButtonPage.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,11 +38,17 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
-Page {
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
@@ -88,17 +94,19 @@ Page {
Component {
id: touchStyle
ButtonStyle {
- implicitHeight: 50
- implicitWidth: 320
- background: BorderImage {
- anchors.fill: parent
- antialiasing: true
- border.bottom: 8
- border.top: 8
- border.left: 8
- border.right: 8
- anchors.margins: control.pressed ? -4 : 0
- source: control.pressed ? "../images/button_pressed.png" : "../images/button_default.png"
+ background: Item {
+ implicitHeight: 50
+ implicitWidth: 320
+ BorderImage {
+ anchors.fill: parent
+ antialiasing: true
+ border.bottom: 8
+ border.top: 8
+ border.left: 8
+ border.right: 8
+ anchors.margins: control.pressed ? -4 : 0
+ source: control.pressed ? "../images/button_pressed.png" : "../images/button_default.png"
+ }
}
foregroundColor: "white"
font.pixelSize: 23
diff --git a/examples/touch/content/ProgressBarPage.qml b/examples/touch/content/ProgressBarPage.qml
index f8885a42..86a46b69 100644
--- a/examples/touch/content/ProgressBarPage.qml
+++ b/examples/touch/content/ProgressBarPage.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,11 +38,17 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
-Page {
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
@@ -90,9 +96,9 @@ Page {
Component {
id: touchStyle
ProgressBarStyle {
- implicitHeight: 15
- implicitWidth: 300
background: Rectangle {
+ implicitHeight: 15
+ implicitWidth: 400
color: "#444"
opacity: 0.8
Rectangle {
diff --git a/examples/touch/content/SliderPage.qml b/examples/touch/content/SliderPage.qml
index e14ecaa5..8d9ff0b1 100644
--- a/examples/touch/content/SliderPage.qml
+++ b/examples/touch/content/SliderPage.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,11 +38,18 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
-Page {
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ width: parent.width
+ height: parent.height
+
Column {
spacing: 12
anchors.centerIn: parent
@@ -68,8 +75,6 @@ Page {
Component {
id: touchStyle
SliderStyle {
- implicitHeight: 50
- implicitWidth: 400
handle: Rectangle {
width: 30
height: 30
@@ -77,17 +82,23 @@ Page {
antialiasing: true
color: Qt.lighter("#468bb7", 1.2)
}
- background: Rectangle {
- implicitHeight: 8
- implicitWidth: 300
- color: "#444"
- opacity: 0.8
+
+ background: Item {
+ implicitHeight: 50
+ implicitWidth: 400
Rectangle {
- antialiasing: true
- radius: 1
- color: "#468bb7"
- height: parent.height
- width: parent.width * control.value / control.maximumValue
+ height: 8
+ width: parent.width
+ anchors.verticalCenter: parent.verticalCenter
+ color: "#444"
+ opacity: 0.8
+ Rectangle {
+ antialiasing: true
+ radius: 1
+ color: "#468bb7"
+ height: parent.height
+ width: parent.width * control.value / control.maximumValue
+ }
}
}
}
diff --git a/examples/touch/content/TabBarPage.qml b/examples/touch/content/TabBarPage.qml
index ae4a73b8..41de7822 100644
--- a/examples/touch/content/TabBarPage.qml
+++ b/examples/touch/content/TabBarPage.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,13 +38,19 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
-Page {
- TabFrame {
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ width: parent.width
+ height: parent.height
+
+ TabView {
anchors.fill: parent
style: touchStyle
Tab {
@@ -63,7 +69,7 @@ Page {
Component {
id: touchStyle
- TabFrameStyle {
+ TabViewStyle {
tabBarAlignment: "center"
frame: Item { }
tab: Item {
diff --git a/examples/touch/content/TextInputPage.qml b/examples/touch/content/TextInputPage.qml
index 3174c1b7..3f408d47 100644
--- a/examples/touch/content/TextInputPage.qml
+++ b/examples/touch/content/TextInputPage.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,11 +38,17 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
-Page {
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+
+Item {
+ width: parent.width
+ height: parent.height
property real progress: 0
SequentialAnimation on progress {
@@ -72,19 +78,20 @@ Page {
TextField {
anchors.margins: 20
- text: "Disabled Text input"
+ text: "Readonly Text input"
style: touchStyle
+ readOnly: true
}
}
Component {
id: touchStyle
TextFieldStyle {
- implicitHeight: 50
- implicitWidth: 320
foregroundColor: "white"
font.pixelSize: 28
- background: Item{
+ background: Item {
+ implicitHeight: 50
+ implicitWidth: 320
BorderImage {
source: "../images/textinput.png"
border.left: 8
diff --git a/examples/touch/main.qml b/examples/touch/main.qml
index 6a26b9d5..2546b7da 100644
--- a/examples/touch/main.qml
+++ b/examples/touch/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,12 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+
+
+
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
import "content"
ApplicationWindow {
@@ -129,7 +133,9 @@ ApplicationWindow {
id: pageStack
anchors.fill: parent
- initialPage: Page {
+ initialPage: Item {
+ width: parent.width
+ height: parent.height
ListView {
model: pageModel
anchors.fill: parent
diff --git a/examples/touch/touch.pro b/examples/touch/touch.pro
new file mode 100644
index 00000000..f81aa058
--- /dev/null
+++ b/examples/touch/touch.pro
@@ -0,0 +1,10 @@
+TEMPLATE = aux
+
+OTHER_FILES += \
+ main.qml \
+ content/AndroidDelegate.qml \
+ content/ButtonPage.qml \
+ content/ProgressBarPage.qml \
+ content/SliderPage.qml \
+ content/TabBarPage.qml \
+ content/TextInputPage.qml
diff --git a/header.BSD b/header.BSD
index 4d0e8b3d..763c49f6 100644
--- a/header.BSD
+++ b/header.BSD
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the FOO module of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,4 +37,3 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
diff --git a/qtdesktopcomponents.pro b/qtquickcontrols.pro
index 289b0181..bc5ed5e8 100644
--- a/qtdesktopcomponents.pro
+++ b/qtquickcontrols.pro
@@ -2,5 +2,5 @@ load(qt_parts)
# We need accessibility
!contains(QT_CONFIG, accessibility) {
- error("Building Qt without accessibility is not supported for desktop components.")
+ error("Building Qt without accessibility is not supported for qt quick controls.")
}
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
new file mode 100644
index 00000000..48d5ffeb
--- /dev/null
+++ b/src/controls/ApplicationWindow.qml
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.Window 2.1
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype ApplicationWindow
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup applicationwindow
+ \brief Provides a top-level application window.
+
+ ApplicationWindow is a \l Window, but adds convenience for positioning items
+ such as \l MenuBar, \l ToolBar, and \l StatusBar in a platform independent
+ manner.
+
+ \code
+ ApplicationWindow {
+ id: window
+ menuBar: MenuBar {
+ Menu { MenuItem {...} }
+ Menu { MenuItem {...} }
+ }
+
+ toolBar: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+ ToolButton {...}
+ }
+ }
+
+ TabView {
+ id: myContent
+ anchors.fill: parent
+ ...
+ }
+ }
+ \endcode
+*/
+
+Window {
+ id: root
+
+ width: 320
+ height: 240
+
+ /*!
+ \qmlproperty MenuBar ApplicationWindow::menuBar
+
+ This property holds the \l MenuBar.
+
+ By default, this value is not set.
+ */
+ property MenuBar menuBar: null
+
+ /*!
+ \qmlproperty Item ApplicationWindow::toolBar
+
+ This property holds the toolbar \l Item.
+
+ It can be set to any Item type but is generally used with \l ToolBar.
+
+ By default, this value is not set. When you set the toolbar item, it will
+ be anchored automatically into the application window.
+ */
+ property Item toolBar
+
+ /*!
+ \qmlproperty Item ApplicationWindow::statusBar
+
+ This property holds the status bar \l Item.
+
+ It can be set to any Item type but is generally used with \l StatusBar.
+
+ By default, this value is not set. When you set the status bar item, it
+ will be anchored automatically into the application window.
+ */
+ property Item statusBar
+
+ /*! \internal */
+ onToolBarChanged: { if (toolBar) { toolBar.parent = toolBarArea } }
+
+ /*! \internal */
+ onStatusBarChanged: { if (statusBar) { statusBar.parent = statusBarArea } }
+
+ /*! \internal */
+ default property alias data: contentArea.data
+
+ color: syspal.window
+
+ SystemPalette {id: syspal}
+
+ Item {
+ id: backgroundItem
+ anchors.fill: parent
+
+ Row {
+ id: toolBarArea
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
+
+ Item {
+ id: contentArea
+ anchors.top: toolBarArea.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: statusBarArea.top
+ }
+
+ Row {
+ id: statusBarArea
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
+
+ onVisibleChanged: if (visible && menuBar) menuBar.__parentWindow = root
+
+ states: State {
+ name: "hasMenuBar"
+ when: menuBar && !menuBar.__isNative
+
+ ParentChange {
+ target: menuBar.__contentItem
+ parent: backgroundItem
+ }
+
+ PropertyChanges {
+ target: menuBar.__contentItem
+ x: 0
+ y: 0
+ width: backgroundItem.width
+ }
+
+ AnchorChanges {
+ target: toolBarArea
+ anchors.top: menuBar.__contentItem.bottom
+ }
+ }
+ }
+}
diff --git a/src/qtdesktop/Button.qml b/src/controls/Button.qml
index 06cae159..6872a143 100644
--- a/src/qtdesktop/Button.qml
+++ b/src/controls/Button.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,45 +38,54 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import "private"
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
import "Styles/Settings.js" as Settings
/*!
- \qmltype Button
- \inqmlmodule QtDesktop 1.0
- \brief A normal button
+ \qmltype Button
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief A push button with a text label.
- A normal command button. Similar to the QPushButton widget.
+ The push button is perhaps the most commonly used widget in any graphical
+ user interface. Pushing (or clicking) a button commands the computer to
+ perform some action or to answer a question. Common examples of buttons are
+ OK, Apply, Cancel, Close, Yes, No, and Help buttons.
- The push button is perhaps the most commonly used widget in any graphical user interface.
- Push (click) a button to command the computer to perform some action, or to answer a question.
- Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.
+ Button is similar to the QPushButton widget.
*/
BasicButton {
id: button
+
/*! This property holds whether the push button is the default button.
- Default buttons decide what happens when the user presses enter in a dialog without giving a button explicit focus.
- Note : This property is currently ignored by Dialog
+ Default buttons decide what happens when the user presses enter in a
+ dialog without giving a button explicit focus. \note This property is
+ ignored by Dialog.
+
+ The default value is \c false.
*/
- property bool defaultbutton: false
+ property bool isDefault: false
- /*! This property holds the style hints. Style hints are special properties that only affect specific themes or styles
- An example of a styleHint can be: styleHints: "small" */
- property var styleHints: []
+ /*! This property holds the text shown on the button. If the button has no
+ text, the \l text property will be an empty string.
- /*! This property holds the text shown on the button.
- If the button has no text, the \l text property will be an empty string. */
+ The default value is the empty string.
+ */
property string text
- /*! This property holds the icon shown on the button.
- If the button has no icon, the \l iconSource property will be an empty string. */
+ /*! This property holds the icon shown on the button. If the button has no
+ icon, the \l iconSource property will be an empty string.
+
+ The default value is the empty string.
+ */
property url iconSource
+ activeFocusOnTab: true
+
Accessible.name: text
- style: Qt.createComponent(Settings.THEME_PATH + "/ButtonStyle.qml", button)
+ style: Qt.createComponent(Settings.THEME_PATH + "/ButtonStyle.qml", button)
}
-
diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml
new file mode 100644
index 00000000..16357533
--- /dev/null
+++ b/src/controls/CheckBox.qml
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype CheckBox
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief A checkbox with a text label.
+
+ A CheckBox is an option button that can be toggled on (checked) or off
+ (unchecked). Checkboxes are typically used to represent features in an
+ application that can be enabled or disabled without affecting others.
+
+ The state of the checkbox can be set with the \l {AbstractCheckable::checked}{checked} property.
+
+ In addition to the checked and unchecked states, there is a third state:
+ partially checked. This state indicates that the
+ regular checked/unchecked state can not be determined; generally because of
+ other states that affect the checkbox. This state is useful when several
+ child nodes are selected in a treeview, for example.
+
+ The partially checked state can be made available to the user by setting
+ \l partiallyCheckedEnabled to \c true, or set directly by setting
+ \l checkedState to \c Qt.PartiallyChecked. \l checkedState behaves
+ identically to \l {AbstractCheckable::checked}{checked} when \l partiallyCheckedEnabled
+ is \c false; setting one will appropriately set the other.
+
+ The text of the label shown next to the checkbox can be set with the
+ \l {AbstractCheckable::text}{text} property.
+
+ \qml
+ Column {
+ CheckBox {
+ text: qsTr("Breakfast")
+ }
+ CheckBox {
+ text: qsTr("Lunch")
+ }
+ CheckBox {
+ text: qsTr("Dinner")
+ }
+ }
+ \endqml
+
+ Whenever a CheckBox is clicked, it emits the \l {AbstractCheckable::clicked}{clicked()} signal.
+*/
+
+AbstractCheckable {
+ id: checkBox
+
+ /*!
+ \qmlproperty enumeration CheckBox::checkedState
+
+ This property indicates the current checked state of the checkbox.
+
+ Possible values:
+ \c Qt.UnChecked - The checkbox is not checked (default).
+ \c Qt.Checked - The checkbox is checked.
+ \c Qt.PartiallyChecked - The checkbox is in a partially checked (or
+ "mixed") state.
+
+ The \l {AbstractCheckable::checked}{checked} property also determines whether
+ this property is \c Qt.Checked or \c Qt.UnChecked, and vice versa.
+ */
+ property int checkedState: checked ? Qt.Checked : Qt.Unchecked
+
+ /*!
+ This property determines whether the \c Qt.PartiallyChecked state is
+ available.
+
+ A checkbox may be in a partially checked state when the regular checked
+ state can not be determined.
+
+ Setting \l checkedState to \c Qt.PartiallyChecked will implicitly set
+ this property to \c true.
+
+ If this property is \c true, \l {AbstractCheckable::checked}{checked} will be \c false.
+
+ By default, this property is \c false.
+ */
+ property bool partiallyCheckedEnabled: false
+
+ /*!
+ \internal
+ True if onCheckedChanged should be ignored because we were reacting
+ to onCheckedStateChanged.
+ */
+ property bool __ignoreChecked: false
+
+ style: Qt.createComponent(Settings.THEME_PATH + "/CheckBoxStyle.qml", checkBox)
+
+ activeFocusOnTab: true
+
+ Accessible.role: Accessible.CheckBox
+ Accessible.name: text
+
+ __cycleStatesHandler: __cycleCheckBoxStates
+
+ /*! \internal */
+ onCheckedChanged: {
+ if (!__ignoreChecked)
+ checkedState = checked ? Qt.Checked : Qt.Unchecked;
+ }
+
+ /*! \internal */
+ onCheckedStateChanged: {
+ __ignoreChecked = true;
+ if (checkedState === Qt.PartiallyChecked) {
+ partiallyCheckedEnabled = true;
+ checked = false;
+ } else {
+ checked = checkedState === Qt.Checked;
+ }
+ __ignoreChecked = false;
+ }
+
+ /*! \internal */
+ onPartiallyCheckedEnabledChanged: {
+ if (exclusiveGroup && partiallyCheckedEnabled) {
+ console.warn("Cannot have partially checked boxes in an ExclusiveGroup.");
+ }
+ }
+
+ /*! \internal */
+ onExclusiveGroupChanged: {
+ if (exclusiveGroup && partiallyCheckedEnabled) {
+ console.warn("Cannot have partially checked boxes in an ExclusiveGroup.");
+ }
+ }
+
+ /*! \internal */
+ function __cycleCheckBoxStates() {
+ if (!partiallyCheckedEnabled) {
+ checked = !checked;
+ } else {
+ switch (checkedState) {
+ case Qt.Unchecked: checkedState = Qt.Checked; break;
+ case Qt.Checked: checkedState = Qt.PartiallyChecked; break;
+ case Qt.PartiallyChecked: checkedState = Qt.Unchecked; break;
+ }
+ }
+ }
+}
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
new file mode 100644
index 00000000..aace7369
--- /dev/null
+++ b/src/controls/ComboBox.qml
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype ComboBox
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief ComboBox is a combined button and popup or drop-down list.
+
+ Add items to the comboBox by assigning it a ListModel, or a list of strings to the \l model property.
+
+ \qml
+ ComboBox {
+ width: 200
+ model: [ "Banana", "Apple", "Coconut" ]
+ }
+ \endqml
+
+ Example 2:
+
+ \qml
+ ComboBox {
+ model: ListModel {
+ id: cbItems
+ ListElement { text: "Banana"; color: "Yellow" }
+ ListElement { text: "Apple"; color: "Green" }
+ ListElement { text: "Coconut"; color: "Brown" }
+ }
+ width: 200
+ onCurrentIndexChanged: console.debug(currentText + ", " + cbItems.get(currentIndex).color)
+ }
+ \endqml
+*/
+
+Control {
+ id: comboBox
+
+ /*! The model to populate the ComboBox from. */
+ property alias model: popupItems.model
+ property string textRole: ""
+
+ /*! The index of the currently selected item in the ComboBox. */
+ property alias currentIndex: popup.__selectedIndex
+ /*! The text of the currently selected item in the ComboBox. */
+ readonly property alias currentText: popup.selectedText
+
+ /* \internal */
+ readonly property bool __pressed: mouseArea.pressed && mouseArea.containsMouse || popup.__popupVisible
+ /* \internal */
+ property alias __containsMouse: mouseArea.containsMouse
+
+ style: Qt.createComponent(Settings.THEME_PATH + "/ComboBoxStyle.qml", comboBox)
+
+ activeFocusOnTab: true
+
+ Accessible.role: Accessible.ComboBox
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onPressedChanged: if (pressed) popup.show()
+ }
+
+ StyleItem { id: styleItem }
+
+ Component.onCompleted: {
+ if (currentIndex === -1)
+ currentIndex = 0
+ if (styleItem.style == "mac") {
+ popup.x -= 10
+ popup.y += 4
+ popup.__font.pointSize = 13
+ }
+
+ popup.ready = true
+ popup.resolveTextValue(textRole)
+ }
+
+ onTextRoleChanged: popup.resolveTextValue(textRole)
+
+ Menu {
+ id: popup
+
+ style: isPopup ? __style.popupStyle : __style.dropDownStyle
+
+ readonly property string selectedText: items[__selectedIndex] ? items[__selectedIndex].text : ""
+ property string textRole: ""
+
+ property bool ready: false
+ property bool isPopup: comboBox.__panel.popup
+
+ property int x: 0
+ property int y: isPopup ? 0 : comboBox.height
+ __minimumWidth: comboBox.width
+ __visualItem: comboBox
+
+ property ExclusiveGroup eg: ExclusiveGroup { id: eg }
+
+ Instantiator {
+ id: popupItems
+ active: popup.ready
+ MenuItem {
+ text: popup.textRole === "" ? modelData :
+ (model[popup.textRole] || "")
+ checkable: true
+ exclusiveGroup: eg
+ }
+ onObjectAdded: popup.insertItem(index, object)
+ onObjectRemoved: popup.removeItem(object)
+ }
+
+ function resolveTextValue(initialTextRole) {
+ if (!ready || !model)
+ return;
+
+ var modelMayHaveRoles = model["get"] !== undefined
+ textRole = initialTextRole
+ if (textRole === "" && modelMayHaveRoles && model.get(0)) {
+ // No text role set, check whether model has a suitable role
+ // If 'text' is found, or there's only one role, pick that.
+ var listElement = model.get(0)
+ var roleName = ""
+ var roleCount = 0
+ for (var role in listElement) {
+ if (role === "text") {
+ roleName = role
+ break
+ } else if (!roleName) {
+ roleName = role
+ }
+ ++roleCount
+ }
+ if (roleCount > 1 && roleName !== "text") {
+ console.warn("No suitable 'textRole' found for ComboBox.")
+ } else {
+ textRole = roleName
+ }
+ }
+ }
+
+ function show() {
+ if (items[__selectedIndex])
+ items[__selectedIndex].checked = true
+ __currentIndex = comboBox.currentIndex
+ __popup(x, y, isPopup ? __selectedIndex : 0)
+ }
+ }
+
+ // The key bindings below will only be in use when popup is
+ // not visible. Otherwise, native popup key handling will take place:
+ Keys.onSpacePressed: {
+ if (!popup.popupVisible)
+ popup.show()
+ }
+ Keys.onUpPressed: { if (currentIndex > 0) currentIndex-- }
+ Keys.onDownPressed: { if (currentIndex < popupItems.count - 1) currentIndex++ }
+}
diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml
new file mode 100644
index 00000000..36b86fc3
--- /dev/null
+++ b/src/controls/GroupBox.qml
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype GroupBox
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief GroupBox provides a group box frame with a title.
+
+ A group box provides a frame, a title on top and displays various other controls inside itself. Group boxes can also be checkable.
+
+ Child controls in checkable group boxes are enabled or disabled depending on whether or not the group box is checked.
+
+ You can minimize the space consumption of a group box by enabling the flat property.
+ In most styles, enabling this property results in the removal of the left, right and bottom edges of the frame.
+
+ GroupBox doesn't automatically lay out the child controls (which are often \l{CheckBox}{CheckBoxes} or \l{RadioButton}{RadioButtons} but can be any controls).
+ The following example shows how we can set up a GroupBox with a column:
+
+ \qml
+ GroupBox {
+ title: qsTr("Package selection")
+ Column {
+ CheckBox {
+ text: qsTr("Update system")
+ }
+ CheckBox {
+ text: qsTr("Update applications")
+ }
+ CheckBox {
+ text: qsTr("Update documentation")
+ }
+ }
+ }
+ \endqml
+
+ \note The default size of the GroupBox is calculated based on the size of its children. If you need to use anchors
+ inside a GroupBox, it is recommended to specify a width and height to the GroupBox or to add an intermediate Item
+ inside the GroupBox.
+*/
+
+Item {
+ id: groupbox
+
+ /*!
+ This property holds the group box title text.
+
+ There is no default title text.
+ */
+ property string title
+
+ /*!
+ This property holds whether the group box is painted flat or has a frame.
+
+ A group box usually consists of a surrounding frame with a title at the top.
+ If this property is enabled, only the top part of the frame is drawn in most styles;
+ otherwise, the whole frame is drawn.
+
+ By default, this property is disabled, i.e., group boxes are not flat unless explicitly specified.
+
+ \note In some styles, flat and non-flat group boxes have similar representations and may not be as
+ distinguishable as they are in other styles.
+ */
+ property bool flat: false
+
+ /*!
+ This property holds whether the group box has a checkbox in its title.
+
+ If this property is true, the group box displays its title using a checkbox in place of an ordinary label.
+ If the checkbox is checked, the group box's children are enabled; otherwise, they are disabled and inaccessible.
+
+ By default, group boxes are not checkable.
+ */
+ property bool checkable: false
+
+ /*!
+ \qmlproperty bool GroupBox::checked
+
+ This property holds whether the group box is checked.
+
+ If the group box is checkable, it is displayed with a check box. If the check box is checked, the group
+ box's children are enabled; otherwise, the children are disabled and are inaccessible to the user.
+
+ By default, checkable group boxes are also checked.
+ */
+ property alias checked: check.checked
+
+ /*!
+ This property holds the width of the content.
+ */
+ property real contentWidth: content.childrenRect.width
+
+ /*!
+ This property holds the height of the content.
+ */
+ property real contentHeight: content.childrenRect.height
+
+ /*! \internal */
+ property Component __style: Qt.createComponent(Settings.THEME_PATH + "/GroupBoxStyle.qml", groupbox)
+
+ /*! \internal */
+ default property alias data: content.data
+
+ /*! \internal */
+ property alias __checkbox: check
+
+ implicitWidth: Math.max(200, (loader.item ? loader.item.implicitWidth: 0) )
+ implicitHeight: (loader.item ? loader.item.implicitHeight : 0)
+
+ Accessible.role: Accessible.Grouping
+ Accessible.name: title
+
+ activeFocusOnTab: false
+
+ Loader {
+ id: loader
+ property alias control: groupbox
+ anchors.fill: parent
+ property int topMargin: (title.length > 0 || checkable ? 16 : 0) + content.margin
+ property int bottomMargin: 4
+ property int leftMargin: 4
+ property int rightMargin: 4
+ sourceComponent: styleLoader.item ? styleLoader.item.panel : null
+ onLoaded: item.z = -1
+ Loader {
+ id: styleLoader
+ sourceComponent: __style
+ }
+ }
+
+ CheckBox {
+ id: check
+ checked: true
+ text: groupbox.title
+ visible: checkable
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: loader.topMargin
+ style: CheckBoxStyle { panel: Item{} }
+ }
+
+ Item {
+ id:content
+ z: 1
+ focus: true
+ property int margin: styleLoader.item ? styleLoader.item.margin : 0
+ anchors.topMargin: loader.topMargin
+ anchors.leftMargin: margin
+ anchors.rightMargin: margin
+ anchors.bottomMargin: margin
+ anchors.fill: parent
+ enabled: (!groupbox.checkable || groupbox.checked)
+ }
+}
diff --git a/src/qtdesktop/Label.qml b/src/controls/Label.qml
index 6f2076ea..db6de97f 100644
--- a/src/qtdesktop/Label.qml
+++ b/src/controls/Label.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,17 +38,53 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
/*!
\qmltype Label
- \inqmlmodule QtDesktop 1.0
- \brief Label is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief A text label.
+
+ In addition to the normal \l Text element, Label follows the font and
+ color scheme of the system.
+ Use the \c text property to assign a text to the label. For other properties
+ check \l Text.
+
+ A simple label looks like this:
+ \qml
+ Label {
+ text: "Hello world"
+ }
+ \endqml
+
+ You can use the properties of \l Text to change the appearance
+ of the text as desired:
+ \qml
+ Label {
+ text: "Hello world"
+ font.pixelSize: 22
+ font.italic: true
+ color: "steelblue"
+ }
+ \endqml
+
+ \sa Text, TextField, TextEdit
*/
Text {
+ /*!
+ \qmlproperty string Label::text
+
+ The text to display. Use this property to get and set it.
+ */
+
id: label
- font.pixelSize: 11
color: pal.text
- SystemPalette {id:pal}
+ activeFocusOnTab: false
+ renderType: Text.NativeRendering
+ SystemPalette {
+ id: pal
+ colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
}
diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml
new file mode 100644
index 00000000..6c2d3cc4
--- /dev/null
+++ b/src/controls/Menu.qml
@@ -0,0 +1,326 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype Menu
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup menus
+ \brief Provides a menu component for use in menu bars, as context menu,
+ and other popup menus.
+
+ \code
+ Menu {
+ title: "Edit"
+
+ MenuItem {
+ text: "Cut"
+ shortcut: "Ctrl+X"
+ onTriggered: ...
+ }
+
+ MenuItem {
+ text: "Copy"
+ shortcut: "Ctrl+C"
+ onTriggered: ...
+ }
+
+ MenuItem {
+ text: "Paste"
+ shortcut: "Ctrl+V"
+ onTriggered: ...
+ }
+
+ MenuSeparator { }
+
+ Menu {
+ title: "More Stuff"
+
+ MenuItem {
+ text: "Do Nothing"
+ }
+ }
+ }
+ \endcode
+
+ The main uses for menus:
+ \list
+ \li
+ as a \e top-level menu in a \l MenuBar
+ \li
+ as a \e submenu inside another menu
+ \li
+ as a standalone or \e context menu
+ \endlist
+
+ Note that some properties, such as \c enabled, \c text, or \c iconSource,
+ only make sense in a particular use case of the menu.
+
+ \sa MenuBar, MenuItem, MenuSeparator
+*/
+
+MenuPrivate {
+ id: root
+
+ /*! \internal
+ \omit
+ See qtmenu.cpp.
+ \endomit
+ */
+ function addMenu(title) {
+ if (!__selfComponent)
+ __selfComponent = Qt.createComponent("Menu.qml", root)
+ var submenu = __selfComponent.createObject(__selfComponent, { "title": title })
+ root.insertItem(items.length, submenu)
+ return submenu
+ }
+
+ /*! \internal */
+ property Component __selfComponent: null
+
+ /*! \internal */
+ property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuStyle.qml", root)
+
+ /*! \internal */
+ property var __menuBar: null
+ /*! \internal */
+ property int __currentIndex: -1
+ /*! \internal */
+ on__MenuClosed: __currentIndex = -1
+
+ /*! \internal */
+ __contentItem: Loader {
+ sourceComponent: __menuComponent
+ active: !root.__isNative && root.__popupVisible
+ focus: true
+ }
+
+ /*! \internal */
+ property Component __menuComponent: Loader {
+ id: menuFrameLoader
+
+ property Style __style: styleLoader.item
+ property Component menuItemStyle: __style ? __style.menuItem : null
+
+ property var control: root
+ property alias contentWidth: column.width
+ property alias contentHeight: column.height
+
+ property int subMenuXPos: width + (item && item["subMenuOverlap"] || 0)
+
+ visible: status === Loader.Ready
+ sourceComponent: __style ? __style.frame : undefined
+
+ Loader {
+ id: styleLoader
+ active: !root.isNative
+ sourceComponent: root.style
+ onStatusChanged: {
+ if (status === Loader.Error)
+ console.error("Failed to load Style for", root)
+ }
+ }
+
+ focus: true
+ Keys.forwardTo: __menuBar ? [__menuBar] : []
+ Keys.onEscapePressed: root.__dismissMenu()
+
+ Keys.onDownPressed: {
+ if (root.__currentIndex < 0) {
+ root.__currentIndex = 0
+ return
+ }
+
+ for (var i = root.__currentIndex + 1;
+ i < root.items.length && !canBeHovered(i); i++)
+ ;
+ }
+
+ Keys.onUpPressed: {
+ for (var i = root.__currentIndex - 1;
+ i >= 0 && !canBeHovered(i); i--)
+ ;
+ }
+
+ function canBeHovered(index) {
+ var item = itemsRepeater.itemAt(index)
+ if (!item["isSeparator"] && item.enabled) {
+ root.__currentIndex = index
+ return true
+ }
+ return false
+ }
+
+ Keys.onLeftPressed: {
+ if (root.__parentMenu)
+ __closeMenu()
+ }
+
+ Keys.onRightPressed: {
+ var item = itemsRepeater.itemAt(root.__currentIndex)
+ if (item && item.isSubmenu) {
+ item.showSubMenu(true)
+ item.menuItem.__currentIndex = 0
+ }
+ }
+
+ Keys.onSpacePressed: menuFrameLoader.triggerAndDismiss()
+ Keys.onReturnPressed: menuFrameLoader.triggerAndDismiss()
+ Keys.onEnterPressed: menuFrameLoader.triggerAndDismiss()
+
+ function triggerAndDismiss() {
+ var item = itemsRepeater.itemAt(root.__currentIndex)
+ if (item && !item.isSeparator) {
+ root.__dismissMenu()
+ if (!item.isSubmenu)
+ item.menuItem.trigger()
+ }
+ }
+
+ Binding {
+ // Make sure the styled frame is in the background
+ target: menuFrameLoader.item
+ property: "z"
+ value: menuMouseArea.z - 1
+ }
+
+ MouseArea {
+ id: menuMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.AllButtons
+
+ onPositionChanged: updateCurrentItem(mouse)
+ onReleased: menuFrameLoader.triggerAndDismiss()
+ onExited: {
+ if (currentItem && !currentItem.menuItem.__popupVisible) {
+ currentItem = null
+ root.__currentIndex = -1
+ }
+ }
+
+ property Item currentItem: null
+
+ function updateCurrentItem(mouse) {
+ var pos = mapToItem(column, mouse.x, mouse.y)
+ if (!currentItem || !currentItem.contains(Qt.point(pos.x - currentItem.x, pos.y - currentItem.y))) {
+ if (currentItem && !pressed && currentItem.isSubmenu)
+ currentItem.closeSubMenu()
+ currentItem = column.childAt(pos.x, pos.y)
+ if (currentItem) {
+ root.__currentIndex = currentItem.menuItemIndex
+ if (currentItem.isSubmenu && !currentItem.menuItem.__popupVisible)
+ currentItem.showSubMenu(false)
+ } else {
+ root.__currentIndex = -1
+ }
+ }
+ }
+
+ // Each menu item has its own mouse area, and for events to be
+ // propagated to the menu mouse area, they need to be embedded.
+ Column {
+ id: column
+
+ Repeater {
+ id: itemsRepeater
+ model: root.items
+
+ Loader {
+ id: menuItemLoader
+
+ property var menuItem: modelData
+ readonly property bool isSeparator: !!menuItem && menuItem.type === MenuItemType.Separator
+ readonly property bool isSubmenu: !!menuItem && menuItem.type === MenuItemType.Menu
+ property bool selected: !isSeparator && root.__currentIndex === index
+ property string text: isSubmenu ? menuItem.title : !isSeparator ? menuItem.text : ""
+
+ property int menuItemIndex: index
+
+ sourceComponent: menuFrameLoader.menuItemStyle
+ enabled: visible && !isSeparator && !!menuItem && menuItem.enabled
+ visible: menuItem.visible
+ active: visible
+
+ function showSubMenu(immediately) {
+ if (immediately) {
+ if (root.__currentIndex === menuItemIndex)
+ menuItem.__popup(menuFrameLoader.subMenuXPos, 0, -1)
+ } else {
+ openMenuTimer.start()
+ }
+ }
+
+ Timer {
+ id: openMenuTimer
+ interval: 50
+ onTriggered: menuItemLoader.showSubMenu(true)
+ }
+
+ function closeSubMenu() { closeMenuTimer.start() }
+
+ Timer {
+ id: closeMenuTimer
+ interval: 1
+ onTriggered: {
+ if (root.__currentIndex !== menuItemIndex)
+ menuItem.__closeMenu()
+ }
+ }
+
+ Component.onCompleted: menuItem.__visualItem = menuItemLoader
+ }
+ }
+
+ onWidthChanged: {
+ for (var i = 0; i < children.length; i++) {
+ var item = children[i]["item"]
+ if (item)
+ item.implicitWidth = Math.max(root.__minimumWidth, implicitWidth)
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml
new file mode 100644
index 00000000..43ff1562
--- /dev/null
+++ b/src/controls/MenuBar.qml
@@ -0,0 +1,214 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype MenuBar
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup menus
+ \brief Provides a horizontal menu bar.
+
+ \code
+ MenuBar {
+ Menu {
+ title: "File"
+ MenuItem { text: "Open..." }
+ MenuItem { text: "Close" }
+ }
+
+ Menu {
+ title: "Edit"
+ MenuItem { text: "Cut" }
+ MenuItem { text: "Copy" }
+ MenuItem { text: "Paste" }
+ }
+ }
+ \endcode
+
+ \sa ApplicationWindow::menuBar
+*/
+
+MenuBarPrivate {
+ id: root
+
+ /*! \internal */
+ property Component style: Qt.createComponent(Settings.THEME_PATH + "/MenuBarStyle.qml", root)
+
+ /*! \internal */
+ __contentItem: Loader {
+ id: topLoader
+ sourceComponent: __menuBarComponent
+ active: !root.__isNative
+ focus: true
+ }
+
+ /*! \internal */
+ property Component __menuBarComponent: Loader {
+ id: menuBarLoader
+
+ property Style __style: styleLoader.item
+ property Component menuItemStyle: __style ? __style.menuItem : null
+
+ property var control: root
+ onStatusChanged: if (status === Loader.Error) console.error("Failed to load panel for", root)
+
+ visible: status === Loader.Ready
+ active: !root.isNative
+ sourceComponent: __style ? __style.frame : undefined
+
+ Loader {
+ id: styleLoader
+ sourceComponent: root.style
+ onStatusChanged: {
+ if (status === Loader.Error)
+ console.error("Failed to load Style for", root)
+ }
+ }
+
+ property int openedMenuIndex: -1
+ property bool preselectMenuItem: false
+ property alias contentHeight: row.height
+
+ Binding {
+ // Make sure the styled menu bar is in the background
+ target: menuBarLoader.item
+ property: "z"
+ value: menuMouseArea.z - 1
+ }
+
+ focus: openedMenuIndex !== -1
+
+ Keys.onLeftPressed: {
+ if (openedMenuIndex > 0) {
+ preselectMenuItem = true
+ openedMenuIndex--
+ }
+ }
+
+ Keys.onRightPressed: {
+ if (openedMenuIndex < root.menus.length - 1) {
+ preselectMenuItem = true
+ openedMenuIndex++
+ }
+ }
+
+ MouseArea {
+ id: menuMouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+
+ onPositionChanged: updateCurrentItem(mouse, false)
+ onPressed: {
+ if (updateCurrentItem(mouse)) {
+ menuBarLoader.preselectMenuItem = false
+ menuBarLoader.openedMenuIndex = currentItem.menuItemIndex
+ }
+ }
+ onExited: hoveredItem = null
+
+ property Item currentItem: null
+ property Item hoveredItem: null
+ function updateCurrentItem(mouse) {
+ var pos = mapToItem(row, mouse.x, mouse.y)
+ if (!hoveredItem || !hoveredItem.contains(Qt.point(pos.x - currentItem.x, pos.y - currentItem.y))) {
+ hoveredItem = row.childAt(pos.x, pos.y)
+ if (!hoveredItem)
+ return false;
+ currentItem = hoveredItem
+ if (menuBarLoader.openedMenuIndex !== -1) {
+ menuBarLoader.preselectMenuItem = false
+ menuBarLoader.openedMenuIndex = currentItem.menuItemIndex
+ }
+ }
+ return true;
+ }
+
+ Row {
+ id: row
+
+ Repeater {
+ id: itemsRepeater
+ model: root.menus
+ Loader {
+ id: menuItemLoader
+
+ property var menuItem: modelData
+ property bool selected: menuMouseArea.hoveredItem === menuItemLoader
+ property bool sunken: menuItem.__popupVisible || menuBarLoader.openedMenuIndex === index
+
+ sourceComponent: menuBarLoader.menuItemStyle
+ property int menuItemIndex: index
+
+ Connections {
+ target: menuBarLoader
+ onOpenedMenuIndexChanged: {
+ if (menuBarLoader.openedMenuIndex === index) {
+ menuItem.__popup(0, menuBarLoader.height, 0)
+ if (menuBarLoader.preselectMenuItem)
+ menuItem.__currentIndex = 0
+ } else {
+ menuItem.__closeMenu()
+ }
+ }
+ }
+
+ Connections {
+ target: menuItem
+ onPopupVisibleChanged: {
+ if (!menuItem.__popupVisible && menuBarLoader.openedMenuIndex === index)
+ menuBarLoader.openedMenuIndex = -1
+ }
+ }
+
+ Component.onCompleted: {
+ menuItem.__visualItem = menuItemLoader
+ menuItem.__menuBar = menuBarLoader
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/qtdesktop/PageAnimation.qml b/src/controls/PageAnimation.qml
index ace0e2e4..2e9c3f0f 100644
--- a/src/qtdesktop/PageAnimation.qml
+++ b/src/controls/PageAnimation.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
ParallelAnimation {
id: root
diff --git a/src/qtdesktop/PageStack.qml b/src/controls/PageStack.qml
index 7eade6db..388a766e 100644
--- a/src/qtdesktop/PageStack.qml
+++ b/src/controls/PageStack.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,18 +38,18 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-
-import "private"
-import "private/PageStack.js" as JSArray
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Private/PageStack.js" as JSArray
/*!
- \qmlclass QtDesktop.PageStack
+ \qmltype PageStack
\inherits Item
- \inqmlmodule QtDesktop
+ \ingroup views
+ \inqmlmodule QtQuick.Controls 1.0
- \brief The central component for building page-based applications
+ \brief Provides a stack-based navigation model.
PageStack implements a stack-based navigation model for an application.
A stack-based navigation model means that "pages" (discrete views of information)
@@ -57,16 +57,7 @@ import "private/PageStack.js" as JSArray
deeper into the application page hierarchy. Similarily, the user can return back to
previous pages at a later point, which from a stack point of view means popping pages from the
top of the stack and re-activating them (make them visible on screen).
-
- Pages can - but do not have to - use \l{Page} as the root item.
- \l{Page} defines a contract for how the page and the page stack works together.
- Namely the page can be notified when it becomes active or inactive
- through the \l{Page::status} {Page.status} property. Status will be
- \c PageStatus.Activating when a
- page is transitioning into being the current page on screen, and \c PageStatus.Active
- once the transition stops. When it leaves the screen, it will be
- \c PageStatus.Deactivating, and then \c PageStatus.Inactive. When the page is
- inactive, it will be hidden.
+ The \l Stack attached property provides information about items pushed onto a stack.
\section1 Using PageStack in an Application
Using the PageStack in the application is typically a simple matter of adding
@@ -154,9 +145,9 @@ import "private/PageStack.js" as JSArray
\l{http://doc.qt.nokia.com/latest/qml-component.html}{Component}. To push it, you assign it
to a property "page" inside a property list, and send it as argument to \l{PageStack::push}{push}:
- \qml
- pageStack.push({page: yourPage})
- \endqml
+ \code
+ pageStack.push({page: yourPage})
+ \endcode
The list can contain several properties that controls how the page should be pushed:
\list
@@ -181,9 +172,9 @@ import "private/PageStack.js" as JSArray
If the only argument needed is "page", you can also, as a short-hand
notation, do:
- \qml
+ \code
pageStack.push(yourPage).
- \endqml
+ \endcode
You can push several pages in one go by using an array of property lists. This is
optimizing compared to pushing pages one by one, since PageStack then can load only the
@@ -191,9 +182,9 @@ import "private/PageStack.js" as JSArray
the current page (which happends when the stack is popped). The following example shows how
to push an array of pages:
- \qml
- pageStack.push([{page: yourPage1}, {page: yourPage2}])
- \endqml
+ \code
+ pageStack.push([{page: yourPage1}, {page: yourPage2}])
+ \endcode
If inline pages/items are pushed, the page gets re-parented into an internal
container in the PageStack. When the page is later popped off, it gets
@@ -211,9 +202,9 @@ import "private/PageStack.js" as JSArray
its about to become the current page (in case of an inline item). This normally happends when
the page is pushed. The following example shows how this can be done:
- \qml
+ \code
pageStack.push({page: examplePage, properties: {fgcolor: "red", bgcolor: "blue"}});
- \endqml
+ \endcode
Note that if a page is declared in an item that is destroyed - even if a component
was used - then that page also gets destroyed.
@@ -234,17 +225,17 @@ import "private/PageStack.js" as JSArray
Popping the page off the top of the stack at this point would not result in further
deactivation since the page is not active.
- There is a \l{Page::status}{status} property that tracks the lifecycle. The value of status is
- an enumeration with values \c PageStatus.Inactive, \c PageStatus.Activating, \c PageStatus.Active
- and \c PageStatus.Deactivating. Combined with the normal \c Component.onComplete and
+ There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The value of status is
+ an enumeration with values \c Stack.Inactive, \c Stack.Activating, \c Stack.Active
+ and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and
\c Component.onDestruction signals the entire lifecycle is thus:
\list
\li Created: Component.onCompleted()
- \li Activating: onStatusChanged (status is PageStatus.Activating)
- \li Acivated: onStatusChanged (status is PageStatus.Active)
- \li Deactivating: onStatusChanged (status is PageStatus.Deactivating)
- \li Deactivated: onStatusChanged (status is PageStatus.Inactive)
+ \li Activating: Stack.onStatusChanged (Stack.status is Stack.Activating)
+ \li Acivated: Stack.onStatusChanged (Stack.status is Stack.Active)
+ \li Deactivating: Stack.onStatusChanged (Stack.status is Stack.Deactivating)
+ \li Deactivated: Stack.onStatusChanged (Stack.status is Stack.Inactive)
\li Destruction: Component.onDestruction()
\endlist
@@ -262,19 +253,19 @@ import "private/PageStack.js" as JSArray
the bottom of the stack if null is given as the target page, the code works well even in the
case that no matching page was found.
- \qml
+ \code
pageStack.pop(pageStack.find(function(page) {
return page.name == "foo";
}));
- \endqml
+ \endcode
You can also get to a page in the page stack using get(index). You should use
this function if your page depends on another page in the stack, as the function will
ensure that the page at the given index gets loaded before it is returned.
- \qml
+ \code
previousPage = pageStack.get(myPage.index - 1));
- \endqml
+ \endcode
\section1 Transitions
@@ -372,22 +363,22 @@ import "private/PageStack.js" as JSArray
\endqml
A single Page can also override the transition to use when itself is pushed or popped. This can
- be done by just assigning another PageTransition object to \l{Page::pageTransition}{Page.pageTransition}.
+ be done by just assigning another PageTransition object to \l{Stack::pageTransition}{Stack.pageTransition}.
\section2 Advanced usage
After PageStack finds the correct transition to use (it first checks
- \l{Page::pageTransition}{Page.pageTransition}, then \l {PageStack::pageTransition}{pageTransition})
+ \l{Stack::pageTransition}{Stack.pageTransition}, then \l {PageStack::pageTransition}{pageTransition})
it calls \l {PageTransition::getAnimation(properties)}{PageTransition.getAnimation(properties)}.
The base implementation of this function just looks for a property named \c properties.name inside
itself (root), which is how it finds \c {property Component pushAnimation} in the examples above.
- \qml
+ \code
function getAnimation(properties)
{
return root[properties.name]
}
- \endqml
+ \endcode
You can override this function for your transition if you need extra logic to decide which
animation to run. You could for example introspect the pages, and return different animations
@@ -459,13 +450,13 @@ import "private/PageStack.js" as JSArray
Item {
id: root
- /*! \qmlproperty int QtQuickComponents.Mt1.0::PageStack::depth
+ /*! \qmlproperty int PageStack::depth
\readonly
The number of pages currently pushed onto the stack.
*/
readonly property alias depth: root.__depth
- /*! \qmlproperty Item QtQuickComponents.Mt1.0::PageStack::currentPage
+ /*! \qmlproperty Item PageStack::currentPage
\readonly
The currently top-most page in the stack.
*/
@@ -485,7 +476,7 @@ Item {
\endlist
\sa push
*/
- property variant initialPage: null
+ property var initialPage: null
/*! \readonly
\a busy is \c true if a page transition is running, and \c false otherwise. */
@@ -493,7 +484,7 @@ Item {
/*! The animations to use for page transitions.
For better understanding on how to apply custom page transitions, read \l{Transitions}.
- \sa {Page::animations}{Page.transitions} */
+ \sa {Stack::animations}{Stack.transitions} */
property PageTransition pageTransition: PageSlideTransition {}
/*! Pushes a page onto the stack. The function takes a property list as argument, which
@@ -765,6 +756,7 @@ Item {
__currentPage = null
}
+ /*! \internal */
function __recursionGuard(use)
{
if (use && __guard) {
@@ -866,11 +858,9 @@ Item {
// Mark the page as no longer part of the PageStack. It
// might reenter on pop if pushed several times:
page.visible = false
- __setPageStatus(page, PageStatus.Inactive)
- if (page.hasOwnProperty("__pageStack"))
- page.__pageStack = null
- if (page.hasOwnProperty("__index"))
- page.__index = -1
+ __setPageStatus(page, Stack.Inactive)
+ page.Stack.__pageStack = null
+ page.Stack.__index = -1
if (element.originalParent)
page.parent = element.originalParent
}
@@ -878,8 +868,7 @@ Item {
/*! \internal */
function __setPageStatus(page, status) {
- if (page.hasOwnProperty("__status"))
- page.__status = status
+ page.Stack.__status = status
}
/*! \internal */
@@ -887,7 +876,7 @@ Item {
{
// Animate page in "outElement" out, and page in "inElement" in. Set a guard to protect
// the user from pushing new pages on signals that will fire while preparing for the transition
- // (e.g Page.onCompleted, Page.onStatusChanged, Page.onIndexChanged etc). Otherwise, we will enter
+ // (e.g Stack.onCompleted, Stack.onStatusChanged, Stack.onIndexChanged etc). Otherwise, we will enter
// this function several times, which causes the pages to be half-way updated.
if (__currentTransition)
__currentTransition.animation.complete()
@@ -899,17 +888,15 @@ Item {
// Since a page can be pushed several times, we need to update its properties:
enterPage.parent = root
- if (enterPage.hasOwnProperty("__pageStack"))
- enterPage.__pageStack = root
- if (enterPage.hasOwnProperty("__index"))
- enterPage.__index = transition.inElement.index
+ enterPage.Stack.__pageStack = root
+ enterPage.Stack.__index = transition.inElement.index
__currentPage = enterPage
if (!transition.outElement) {
// A transition consists of two pages, but we got just one. So just show the page:
enterPage.visible = true
- __setPageStatus(enterPage, PageStatus.Activating)
- __setPageStatus(enterPage, PageStatus.Active)
+ __setPageStatus(enterPage, Stack.Activating)
+ __setPageStatus(enterPage, Stack.Active)
return
}
@@ -918,9 +905,9 @@ Item {
if (enterPage === exitPage)
return
- __searchForAnimationIn(transition.transitionElement.page, transition)
+ __searchForAnimationIn(transition.transitionElement.page.Stack.pageTransition, transition)
if (!transition.animation)
- __searchForAnimationIn(root, transition)
+ __searchForAnimationIn(root.pageTransition, transition)
if (!transition.animation) {
console.warn("Warning: PageStack: no", transition.name, "found!")
return
@@ -930,9 +917,9 @@ Item {
console.warn("Warning: PageStack: cannot transition a page that is anchored!")
__currentTransition = transition
- __setPageStatus(exitPage, PageStatus.Deactivating)
+ __setPageStatus(exitPage, Stack.Deactivating)
enterPage.visible = true
- __setPageStatus(enterPage, PageStatus.Activating)
+ __setPageStatus(enterPage, Stack.Activating)
transition.animation.runningChanged.connect(animationFinished)
transition.animation.start()
// NB! For empty animations, "animationFinished" is already
@@ -944,15 +931,14 @@ Item {
/*! \internal */
function __searchForAnimationIn(obj, transition)
{
- var t = obj.pageTransition
- if (t) {
- transition.pageTransition = t
+ if (obj) {
+ transition.pageTransition = obj
transition.properties = {
"name":transition.name,
"enterPage":transition.enterPage,
"exitPage":transition.exitPage,
"immediate":transition.immediate }
- var anim = t.getAnimation(transition.properties)
+ var anim = obj.getAnimation(transition.properties)
if (anim.createObject) {
anim = anim.createObject(null, transition.properties)
anim.runningChanged.connect(function(){ if (anim.running === false) anim.destroy() })
@@ -969,8 +955,8 @@ Item {
__currentTransition.animation.runningChanged.disconnect(animationFinished)
__currentTransition.exitPage.visible = false
- __setPageStatus(__currentTransition.exitPage, PageStatus.Inactive);
- __setPageStatus(__currentTransition.enterPage, PageStatus.Active);
+ __setPageStatus(__currentTransition.exitPage, Stack.Inactive);
+ __setPageStatus(__currentTransition.enterPage, Stack.Active);
__currentTransition.properties.animation = __currentTransition.animation
__currentTransition.pageTransition.cleanupAnimation(__currentTransition.properties)
@@ -989,4 +975,3 @@ Item {
}
}
}
-
diff --git a/src/qtdesktop/PageTransition.qml b/src/controls/PageTransition.qml
index 7a0e11bd..bb212b0c 100644
--- a/src/qtdesktop/PageTransition.qml
+++ b/src/controls/PageTransition.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,18 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
+/*!
+ \qmltype PageTransition
+ \inqmlmodule QtQuick.Controls 1.0
+
+ \brief The component for managing page transitions.
+
+ See the documentation for the \l {QtQuick.Controls1::PageStack} {PageStack}
+ component.
+
+*/
QtObject {
id: root
diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml
new file mode 100644
index 00000000..38193654
--- /dev/null
+++ b/src/controls/ProgressBar.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype ProgressBar
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief A progress indicator.
+
+ The ProgressBar is used to give an indication of the progress of an operation.
+ \l value is updated regularly and must be between \l minimumValue and \l maximumValue.
+
+*/
+
+Control {
+ id: progressbar
+
+ /*! This property holds the progress bar's current value.
+ Attempting to change the current value to one outside the minimum-maximum
+ range has no effect on the current value.
+ The default value is \c 0
+ */
+ property real value: 0
+
+ /*! This property is the progress bar's minimum value
+ The \l value is clamped to this value.
+ The default value is \c 0
+ */
+ property real minimumValue: 0
+
+ /*! This property is the progress bar's maximum value
+ The \l value is clamped to this value.
+ If maximumValue is smaller than \l minimumValue, \l minimumValue will be enforced.
+ The default value is \c 1
+ */
+ property real maximumValue: 1
+
+ /*! This property toggles indeterminate mode.
+ When the actual progress is unknown, use this option.
+ The progress bar will be animated as a busy indicator instead.
+ The default value is \c false
+ */
+ property bool indeterminate: false
+
+ /*! \qmlproperty enumeration orientation
+
+ This property holds the orientation of the progress bar.
+
+ \list
+ \li Qt.Horizontal - Horizontal orientation. (Default)
+ \li Qt.Vertical - Vertical orientation.
+ \endlist
+ */
+ property int orientation: Qt.Horizontal
+
+ /*! \internal */
+ style: Qt.createComponent(Settings.THEME_PATH + "/ProgressBarStyle.qml", progressbar)
+
+ /*! \internal */
+ property bool __initialized: false
+ /*! \internal */
+ onMaximumValueChanged: setValue(value)
+ /*! \internal */
+ onMinimumValueChanged: setValue(value)
+ /*! \internal */
+ onValueChanged: if (__initialized) setValue(value)
+ /*! \internal */
+ Component.onCompleted: {
+ __initialized = true;
+ setValue(value)
+ }
+
+ activeFocusOnTab: false
+
+ Accessible.role: Accessible.ProgressBar
+ Accessible.name: value
+
+ implicitWidth: orientation === Qt.Horizontal ? 200 : (__panel ? __panel.implicitHeight : 0)
+ implicitHeight: orientation === Qt.Horizontal ? (__panel ? __panel.implicitHeight : 0) : 200
+
+ /* \internal */
+ function setValue(v) {
+ var newval = parseFloat(v)
+ if (!isNaN(newval)) {
+ // we give minimumValue priority over maximum if they are inconsistent
+ if (newval > maximumValue) {
+ if (maximumValue >= minimumValue)
+ newval = maximumValue;
+ else
+ newval = minimumValue
+ } else if (v < minimumValue) {
+ newval = minimumValue
+ }
+ if (value !== newval)
+ value = newval
+ }
+ }
+}
diff --git a/src/qtdesktop/RadioButton.qml b/src/controls/RadioButton.qml
index e031fe9b..87f57257 100644
--- a/src/qtdesktop/RadioButton.qml
+++ b/src/controls/RadioButton.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,22 +38,56 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
import "Styles/Settings.js" as Settings
-// jb : Size should not depend on background, we should make it consistent
-
/*!
\qmltype RadioButton
- \inqmlmodule QtDesktop 1.0
- \brief RadioButton is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief A radio button with a text label.
+
+ A RadioButton is an option button that can be switched on (checked) or off
+ (unchecked). Radio buttons typically present the user with a "one of many"
+ choice. In a group of radio buttons, only one radio button at a time can be
+ checked; if the user selects another button, the previously selected button
+ is switched off.
+
+ \qml
+ GroupBox {
+ title: qsTr("Search")
+ Column {
+ ExclusiveGroup { id: group }
+ RadioButton {
+ text: qsTr("From top")
+ exclusiveGroup: group
+ checked: true
+ }
+ RadioButton {
+ text: qsTr("From cursor")
+ exclusiveGroup: group
+ }
+ }
+ }
+ \endqml
*/
-CheckBox {
- id: radiobutton
+AbstractCheckable {
+ id: radioButton
+
+ activeFocusOnTab: true
Accessible.role: Accessible.RadioButton
- style: Qt.createComponent(Settings.THEME_PATH + "/RadioButtonStyle.qml", radiobutton)
+ /*!
+ The style that should be applied to the radio button. Custom style
+ components can be created with:
+
+ \codeline Qt.createComponent("path/to/style.qml", radioButtonId);
+ */
+ style: Qt.createComponent(Settings.THEME_PATH + "/RadioButtonStyle.qml", radioButton)
+
+ __cycleStatesHandler: function() { checked = !checked; }
}
diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml
new file mode 100644
index 00000000..b0722e0f
--- /dev/null
+++ b/src/controls/ScrollView.qml
@@ -0,0 +1,286 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype ScrollView
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief The ScrollView class provides a scrolling view onto another Item.
+
+ A ScrollView can be used either instead of a \l Flickable or to decorate an
+ existing Flickable. Depending on the platform it will add scroll bars and
+ a content frame.
+
+ Only one Item can be a direct child of the ScrollView and the child is implicitly anchored
+ to fill the scroll view.
+
+ Example:
+ \code
+ ScrollView {
+ Image { imageSource: "largeImage.png" }
+ }
+ \endcode
+
+ In the previous example the Image item will implicitly get scroll behavior as if it was
+ used within a \l Flickable. The width and height of the child item will be used to
+ define the size of the content area.
+
+ Example:
+ \code
+ ScrollView {
+ ListView {
+ ...
+ }
+ }
+ \endcode
+
+ In this case the content size of the ScrollView will simply mirror that of its contained
+ \l flickableItem.
+
+*/
+
+FocusScope {
+ id: root
+ implicitWidth: 200
+ implicitHeight: 100
+
+ /*!
+ This property tells the scroll view if it should render
+ a frame around it's content.
+
+ The default value is \c false
+ */
+ property bool frameVisible: false
+
+ /*!
+ This property controls if there should be a highlight
+ around the frame when the ScrollView has input focus.
+
+ The default value is \c false
+
+ \note This property is only applicable on some platforms, such
+ as Mac OS.
+ */
+ property bool highlightOnFocus: false
+
+ /*!
+ \qmlproperty Item ScrollView::viewport
+
+ The viewport determines the current "window" on to the contentItem.
+ In other words it clips it and the size of the viewport tells you
+ how much of the content area is visible.
+ */
+ property alias viewport: viewportItem
+
+ /*!
+ \qmlproperty Item ScrollView::flickableItem
+
+ The flickableItem of the ScrollView. If the contentItem provided
+ to the ScrollView is a Flickable, it will be the \l contentItem.
+ */
+ readonly property alias flickableItem: internal.flickableItem
+
+ /*!
+ The contentItem of the ScrollView. This is set by the user.
+
+ Note that the definition of contentItem is somewhat different to that
+ of a Flickable, where the contentItem is implicitly created.
+ */
+ default property Item contentItem
+
+ /*! \internal */
+ property Item __scroller: scroller
+ /*! \internal */
+ property int __scrollBarTopMargin: 0
+ /*! \internal */
+ property alias horizontalScrollBar: scroller.horizontalScrollBar
+ /*! \internal */
+ property alias verticalScrollBar: scroller.verticalScrollBar
+
+ activeFocusOnTab: true
+
+ /*! \internal */
+ onContentItemChanged: {
+
+ if (contentItem.hasOwnProperty("contentY") && // Check if flickable
+ contentItem.hasOwnProperty("contentHeight")) {
+ internal.flickableItem = contentItem // "Use content if it is a flickable
+ } else {
+ internal.flickableItem = flickableComponent.createObject(internal)
+ contentItem.parent = internal.flickableItem.contentItem
+ }
+ internal.flickableItem.parent = viewportItem
+ internal.flickableItem.anchors.fill = viewportItem
+ }
+
+
+ children: Item {
+ id: internal
+
+ property Flickable flickableItem
+
+ Binding {
+ target: flickableItem
+ property: "contentHeight"
+ when: contentItem !== flickableItem
+ value: contentItem ? contentItem.height : 0
+ }
+
+ Binding {
+ target: flickableItem
+ when: contentItem !== flickableItem
+ property: "contentWidth"
+ value: contentItem ? contentItem.width : 0
+ }
+
+ Connections {
+ target: flickableItem
+
+ onContentYChanged: {
+ scroller.blockUpdates = true
+ scroller.verticalScrollBar.value = flickableItem.contentY
+ scroller.blockUpdates = false
+ }
+
+ onContentXChanged: {
+ scroller.blockUpdates = true
+ scroller.horizontalScrollBar.value = flickableItem.contentX
+ scroller.blockUpdates = false
+ }
+
+ }
+
+ anchors.fill: parent
+
+ Component {
+ id: flickableComponent
+ Flickable {}
+ }
+
+ WheelArea {
+ id: wheelArea
+ parent: flickableItem
+
+ // ### Note this is needed due to broken mousewheel behavior in Flickable.
+
+ anchors.fill: parent
+
+ property int acceleration: 40
+ property int flickThreshold: 20
+ property double speedThreshold: 3
+ property double ignored: 0.001 // ## flick() does not work with 0 yVelocity
+ property int maxFlick: 400
+
+ property bool horizontalRecursionGuard: false
+ property bool verticalRecursionGuard: false
+
+ horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0
+ verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height : 0
+
+ Connections {
+ target: flickableItem
+ onContentYChanged: {
+ wheelArea.verticalRecursionGuard = true
+ wheelArea.verticalValue = flickableItem.contentY
+ wheelArea.verticalRecursionGuard = false
+ }
+ onContentXChanged: {
+ wheelArea.horizontalRecursionGuard = true
+ wheelArea.horizontalValue = flickableItem.contentX
+ wheelArea.horizontalRecursionGuard = false
+ }
+ }
+
+ onVerticalValueChanged: {
+ if (!verticalRecursionGuard) {
+ if (flickableItem.contentY < flickThreshold && verticalDelta > speedThreshold) {
+ flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
+ } else if (flickableItem.contentY > flickableItem.contentHeight
+ - flickThreshold - viewport.height && verticalDelta < -speedThreshold) {
+ flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
+ } else {
+ flickableItem.contentY = verticalValue
+ }
+ }
+ }
+
+ onHorizontalValueChanged: {
+ if (!horizontalRecursionGuard)
+ flickableItem.contentX = horizontalValue
+ }
+ }
+
+ ScrollViewHelper {
+ id: scroller
+ anchors.fill: parent
+ property int frameWidth: frameVisible ? styleitem.pixelMetric("defaultframewidth") : 0
+ property bool outerFrame: !frameVisible || !styleitem.styleHint("frameOnlyAroundContents")
+ property int scrollBarSpacing: outerFrame ? 0 : styleitem.pixelMetric("scrollbarspacing")
+ property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
+ verticalScrollBar.width + scrollBarSpacing : 0
+ property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
+ horizontalScrollBar.height + scrollBarSpacing : 0
+
+ StyleItem {
+ id: styleitem
+ elementType: "frame"
+ sunken: true
+ visible: frameVisible
+ anchors.fill: parent
+ anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset
+ anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset
+ }
+
+ Item {
+ id: viewportItem
+ anchors.fill: styleitem
+ anchors.margins: scroller.frameWidth
+ anchors.rightMargin: scroller.frameWidth + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0)
+ anchors.bottomMargin: scroller.frameWidth + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0)
+ clip: true
+ }
+ }
+ FocusFrame { visible: highlightOnFocus && area.activeFocus }
+ }
+}
diff --git a/src/qtdesktop/Slider.qml b/src/controls/Slider.qml
index 4d6a1ba8..bb2102ff 100644
--- a/src/qtdesktop/Slider.qml
+++ b/src/controls/Slider.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,74 +38,169 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
import "Styles/Settings.js" as Settings
-// jens: ContainsMouse breaks drag functionality
-
/*!
\qmltype Slider
- \inqmlmodule QtDesktop 1.0
- \brief Slider is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief Slider provides a vertical or horizontal slider control.
+
+ The slider is the classic control for providing a bounded value. It lets
+ the user move a slider handle along a horizontal or vertical groove
+ and translates the handle's position into a value within the legal range.
+
+ \code
+ Slider {
+ onValueChanged: print(value)
+ }
+ \endcode
+
+ The Slider value is by default in the range [0, 1]. If integer values are
+ needed, you can set the \l stepSize.
*/
-Item {
+Control {
id: slider
- // Common API
+ /*!
+ \qmlproperty enumeration Slider::orientation
+
+ This property holds the layout orientation of the slider.
+ The default value is \c Qt.Horizontal
+ */
property int orientation: Qt.Horizontal
+
+ /*!
+ \qmlproperty double Slider::minimumValue
+
+ This property holds the minimum value of the Slider
+ The default value is \c 0.0
+ */
property alias minimumValue: range.minimumValue
+
+ /*!
+ \qmlproperty double Slider::maximumValue
+
+ This property holds the maximum value of the Slider
+ The default value is \c 1.0
+ */
property alias maximumValue: range.maximumValue
+
+ /*! \internal */
property alias inverted: range.inverted
+
+
+ /*!
+ \qmlproperty bool Slider::updateValueWhileDragging
+
+ This property indicates if the current \l value should update while
+ the user is moving the slider handle or only when the button has been released.
+ The property can for instance be used if changing the slider value can be
+ time consuming.
+
+ The default value is \c true
+ */
property bool updateValueWhileDragging: true
+
+ /*!
+ \qmlproperty bool Slider::pressed
+
+ This property indicates if slider handle is currently being pressed
+ */
property alias pressed: mouseArea.pressed
+
+ /*!
+ \qmlproperty double Slider::stepSize
+
+ This property indicates the slider step size.
+
+ A value of 0 indicates that the value of the slider operates in a
+ continuous range between \l minimumValue and \l maximumValue.
+
+ Any non 0 value indicates a discrete stepSize. The following example
+ will generate a slider with integer values in the range [0-5]
+
+ \qml
+ Slider {
+ maximumValue: 5.0
+ stepSize: 1.0
+ }
+ \endqml
+
+ The default value is \c 0
+ */
property alias stepSize: range.stepSize
- property alias hoverEnabled: mouseArea.hoverEnabled
+
+ /*!
+ \qmlproperty double Slider::value
+
+ This property holds the current value of the Slider
+ The default value is \c 0.0
+ */
property alias value: range.value
- // Destop API
- property bool containsMouse: mouseArea.containsMouse
+ /*!
+ \qmlproperty bool Slider::activeFocusOnPress
+
+ This property indicates if the Slider should receive active focus when
+ pressed.
+ */
property bool activeFocusOnPress: false
+
+ /*!
+ \qmlproperty bool Slider::tickmarksEnabled
+
+ This property indicates if the Slider should display tickmarks
+ at step intervals.
+
+ The default value is \c false
+ */
property bool tickmarksEnabled: false
- property string tickPosition: "Below" // "Above", "Below", "BothSides"
+
+ /*! \internal */
+ property bool __containsMouse: mouseArea.containsMouse
+
+ /*! \internal */
+ property bool __horizontal: orientation === Qt.Horizontal
+
+ activeFocusOnTab: true
Accessible.role: Accessible.Slider
Accessible.name: value
- // Reimplement this function to control how the value is shown in the
- // indicator.
+ /*!
+ \qmlmethod Slider::formatValue
+
+ This method returns the current slider value in a way that is more suitable
+ for user display, such as the \l value rounded to only two decimal places.
+
+ By default this function returns the nearest \c int value.
+ */
+
function formatValue(v) {
return Math.round(v);
}
- property var styleHints:[]
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/SliderStyle.qml", slider)
+ /* \internal */
+ style: Qt.createComponent(Settings.THEME_PATH + "/SliderStyle.qml", slider)
Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0
Keys.onLeftPressed: value -= (maximumValue - minimumValue)/10.0
- implicitWidth: loader.item ? loader.item.implicitWidth : 0
- implicitHeight: loader.item ? loader.item.implicitHeight : 0
-
RangeModel {
id: range
minimumValue: 0.0
maximumValue: 1.0
value: 0
stepSize: 0.0
- inverted: false
+ inverted: __horizontal ? false : true
positionAtMinimum: 0
- positionAtMaximum: slider.width
- }
-
- Loader {
- id: loader
- sourceComponent: style
- anchors.fill: parent
- property var control: slider
- function positionForValue(value) { return range.positionForValue(value) }
+ positionAtMaximum: __horizontal ? slider.width : slider.height
}
Item { id: fakeHandle }
@@ -120,31 +215,28 @@ Item {
height: parent.height
drag.target: fakeHandle
- drag.axis: Drag.XAxis
+ drag.axis: __horizontal ? Drag.XAxis : Drag.YAxis
drag.minimumX: range.positionAtMinimum
drag.maximumX: range.positionAtMaximum
onPressed: {
- if (activeFocusOnPress)
- slider.focus = true;
+ if (slider.activeFocusOnPress)
+ slider.forceActiveFocus();
// Clamp the value
- var newX = Math.max(mouse.x, drag.minimumX);
- newX = Math.min(newX, drag.maximumX);
-
- // Debounce the press: a press event inside the handler will not
- // change its position, the user needs to drag it.
-
- // Note this really messes up things for scrollbar
- // if (Math.abs(newX - fakeHandle.x) > handleLoader.width / 2)
- range.position = newX;
+ var current = __horizontal ? mouse.x : mouse.y
+ var minimum = __horizontal ? drag.minimumX : drag.minimumY
+ var maximum = __horizontal ? drag.maximumX : drag.maximumY
+ var newVal = Math.max(current, minimum);
+ newVal = Math.min(newVal, maximum);
+ range.position = newVal;
}
onReleased: {
// If we don't update while dragging, this is the only
// moment that the range is updated.
if (!slider.updateValueWhileDragging)
- range.position = fakeHandle.x;
+ range.position = __horizontal ? fakeHandle.x : fakeHandle.y;
}
}
@@ -157,7 +249,7 @@ Item {
when: updateValueWhileDragging || !mouseArea.pressed
target: range
property: "position"
- value: fakeHandle.x
+ value: __horizontal ? fakeHandle.x : fakeHandle.y
}
// During the drag, we simply ignore position set from the range, this
@@ -166,11 +258,10 @@ Item {
Binding {
when: !mouseArea.drag.active
target: fakeHandle
- property: "x"
+ property: __horizontal ? "x" : "y"
value: range.position
}
-
WheelArea {
id: wheelarea
anchors.fill: parent
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
new file mode 100644
index 00000000..de836b24
--- /dev/null
+++ b/src/controls/SpinBox.qml
@@ -0,0 +1,333 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype SpinBox
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief SpinBox provides a spin box control.
+
+ SpinBox allows the user to choose a value by clicking the up/down buttons or pressing up/down on the keyboard to increase/decrease
+ the value currently displayed. The user can also type the value in manually.
+
+ By default the SpinBox provides discrete values in the range [0-99] with a \l stepSize of 1 and 0 \l decimals.
+
+ \code
+ SpinBox {
+ id: spinbox
+ }
+ \endcode
+
+ Note that if you require decimal values you will need to set the \l decimals to a non 0 value.
+
+ \code
+ SpinBox {
+ id: spinbox
+ decimals: 2
+ }
+ \endcode
+
+*/
+
+Control {
+ id: spinbox
+
+ /*!
+ The value of this SpinBox, clamped to \l minimumValue and \l maximumValue.
+
+ The default value is \c 0
+ */
+ property real value: 0
+
+ /*!
+ The minimum value of the SpinBox range.
+ The \l value is clamped to this value.
+
+ The default value is \c 0
+ */
+ property real minimumValue: 0
+
+ /*!
+ The maximum value of the SpinBox range.
+ The \l value is clamped to this value. If maximumValue is smaller than
+ \l minimumValue, \l minimumValue will be enforced.
+
+ The default value is \c 99
+ */
+ property real maximumValue: 99
+
+ /*!
+ The amount by which the \l value is incremented/decremented when a
+ spin button is pressed.
+
+ The default value is 1.0.
+ */
+ property real stepSize: 1.0
+
+ /*! The suffix for the value. I.e "cm" */
+ property string suffix
+
+ /*! The prefix for the value. I.e "$" */
+ property string prefix
+
+ /*! This property indicates the amount of decimals.
+ Note that if you enter more decimals than specified, they will
+ be truncated to the specified amount of decimal places.
+ The default value is \c 0
+ */
+ property int decimals: 0
+
+ /*! \qmlproperty font SpinBox::font
+
+ This property indicates the current font used by the SpinBox.
+ */
+ property alias font: input.font
+
+ /*! This property indicates if the Spinbox should get active
+ focus when pressed.
+ The default value is \c true
+ */
+ property bool activeFocusOnPress: true
+
+ /*! \internal */
+ style: Qt.createComponent(Settings.THEME_PATH + "/SpinBoxStyle.qml", spinbox)
+
+ /*! \internal */
+ function __increment() {
+ input.setValue(input.text)
+ value += stepSize
+ if (value > maximumValue)
+ value = maximumValue
+ input.text = value.toFixed(decimals)
+ }
+
+ /*! \internal */
+ function __decrement() {
+ input.setValue(input.text)
+ value -= stepSize
+ if (value < minimumValue)
+ value = minimumValue
+ input.text = value.toFixed(decimals)
+ }
+
+ /*! \internal */
+ property bool __initialized: false
+ /*! \internal */
+ readonly property bool __upEnabled: value != maximumValue;
+ /*! \internal */
+ readonly property bool __downEnabled: value != minimumValue;
+ /*! \internal */
+ readonly property alias __upPressed: mouseUp.pressed
+ /*! \internal */
+ readonly property alias __downPressed: mouseDown.pressed
+ /*! \internal */
+ property alias __upHovered: mouseUp.containsMouse
+ /*! \internal */
+ property alias __downHovered: mouseDown.containsMouse
+ /*! \internal */
+ property alias __containsMouse: mouseArea.containsMouse
+ /*! \internal */
+ property alias __text: input.text
+ /*! \internal */
+ readonly property int __contentHeight: Math.max(input.implicitHeight, 20)
+ /*! \internal */
+ readonly property int __contentWidth: suffixItem.implicitWidth +
+ Math.max(maxSizeHint.implicitWidth,
+ minSizeHint.implicitWidth) +
+ prefixItem.implicitWidth
+ Text {
+ id: maxSizeHint
+ text: maximumValue.toFixed(decimals)
+ font: input.font
+ visible: false
+ }
+
+ Text {
+ id: minSizeHint
+ text: minimumValue.toFixed(decimals)
+ font: input.font
+ visible: false
+ }
+
+ /*! \internal */
+ onDecimalsChanged: input.setValue(value)
+ /*! \internal */
+ onMaximumValueChanged: input.setValue(value)
+ /*! \internal */
+ onMinimumValueChanged: input.setValue(value)
+ /*! \internal */
+ Component.onCompleted: {
+ __initialized = true;
+ input.setValue(value)
+ }
+
+ /*! \internal */
+ onValueChanged: if (__initialized) input.setValue(value)
+
+ activeFocusOnTab: true
+
+ Accessible.name: input.text
+ Accessible.role: Accessible.SpinBox
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onPressed: if (activeFocusOnPress) input.forceActiveFocus()
+ }
+
+ Row {
+ id: textLayout
+ anchors.fill: parent
+ spacing: 1
+ clip: true
+ anchors.leftMargin: __panel ? __panel.leftMargin : 0
+ anchors.topMargin: __panel ? __panel.topMargin : 0
+ anchors.rightMargin: __panel ? __panel.rightMargin: 0
+ anchors.bottomMargin: __panel ? __panel.bottomMargin: 0
+
+ Text {
+ id: prefixItem
+ text: prefix
+ color: __panel ? __panel.foregroundColor : "black"
+ anchors.verticalCenter: parent.verticalCenter
+ renderType: Text.NativeRendering
+ }
+
+ TextInput {
+ id: input
+ anchors.verticalCenter: parent.verticalCenter
+ activeFocusOnPress: spinbox.activeFocusOnPress
+ function setValue(v) {
+ var newval = parseFloat(v)
+
+ if (!isNaN(newval)) {
+ // we give minimumValue priority over maximum if they are inconsistent
+ if (newval > maximumValue && maximumValue >= minimumValue)
+ newval = maximumValue
+ else if (v < minimumValue)
+ newval = minimumValue
+ newval = newval.toFixed(decimals)
+ spinbox.value = parseFloat(newval)
+ input.text = newval
+ } else {
+ input.text = parseFloat(spinbox.value)
+ }
+ }
+
+ horizontalAlignment: __panel ? __panel.horizontalTextAlignment : Qt.AlignLeft
+ verticalAlignment: __panel ? __panel.verticalTextAlignment : Qt.AlignVCenter
+ selectByMouse: true
+
+ validator: DoubleValidator { bottom: minimumValue; top: maximumValue; }
+ onAccepted: setValue(input.text)
+ color: __panel ? __panel.foregroundColor : "black"
+ selectionColor: __panel ? __panel.selectionColor : "black"
+ selectedTextColor: __panel ? __panel.selectedTextColor : "black"
+
+ opacity: parent.enabled ? 1 : 0.5
+ renderType: Text.NativeRendering
+ }
+ Text {
+ id: suffixItem
+ text: suffix
+ color: __panel ? __panel.foregroundColor : "black"
+ anchors.verticalCenter: parent.verticalCenter
+ renderType: Text.NativeRendering
+ }
+ }
+
+ // Spinbox increment button
+
+ MouseArea {
+ id: mouseUp
+ hoverEnabled: true
+
+ property var upRect: __panel ? __panel.upRect : null
+
+ anchors.left: parent.left
+ anchors.top: parent.top
+
+ anchors.leftMargin: upRect ? upRect.x : 0
+ anchors.topMargin: upRect ? upRect.y : 0
+
+ width: upRect ? upRect.width : 0
+ height: upRect ? upRect.height : 0
+
+ onClicked: __increment()
+
+ property bool autoincrement: false;
+ onReleased: autoincrement = false
+ Timer { running: mouseUp.pressed; interval: 350 ; onTriggered: mouseUp.autoincrement = true }
+ Timer { running: mouseUp.autoincrement; interval: 60 ; repeat: true ; onTriggered: __increment() }
+ }
+
+ // Spinbox decrement button
+
+ MouseArea {
+ id: mouseDown
+ hoverEnabled: true
+
+ onClicked: __decrement()
+ property var downRect: __panel ? __panel.downRect : null
+
+ anchors.left: parent.left
+ anchors.top: parent.top
+
+ anchors.leftMargin: downRect ? downRect.x : 0
+ anchors.topMargin: downRect ? downRect.y : 0
+
+ width: downRect ? downRect.width : 0
+ height: downRect ? downRect.height : 0
+
+ property bool autoincrement: false;
+ onReleased: autoincrement = false
+ Timer { running: mouseDown.pressed; interval: 350 ; onTriggered: mouseDown.autoincrement = true }
+ Timer { running: mouseDown.autoincrement; interval: 60 ; repeat: true ; onTriggered: __decrement() }
+ }
+
+ Keys.onUpPressed: __increment()
+ Keys.onDownPressed: __decrement()
+}
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml
new file mode 100644
index 00000000..64a9430a
--- /dev/null
+++ b/src/controls/SplitView.qml
@@ -0,0 +1,417 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtQuick.Controls.Private 1.0 as Private
+
+/*!
+ \qmltype SplitView
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief SplitView is a component that lays out items horizontally or
+ vertically with a draggable splitter between each item.
+
+ SplitView is a control that lays out items horizontally or
+ vertically with a draggable splitter between each item.
+
+ There will always be one (and only one) item in the SplitView that is 'expanding'.
+ Being expanding means that the item will get all the remaining space when other
+ items have been laid out according to their own width and height.
+ By default, the last visible child of the SplitView will be expanding, but
+ this can be changed by setting Layout.fillWidth to \c true.
+ Since the expanding item will automatically be resized to fit the extra space, it
+ will ignore explicit assignments to width and height.
+
+ A handle can belong to the item on the left/top side, or the right/bottom side, of the
+ handle. Which one depends on the expanding item. If the expanding item is to the right
+ of the handle, the handle will belong to the item on the left. If it is to the left, it
+ will belong to the item on the right. This will again control which item that gets resized
+ when the user drags a handle, and which handle that gets hidden when an item is told to hide.
+
+ SplitView supports setting attached Layout properties on child items, which means that you
+ can control minimumWidth, minimumHeight, maximumWidth and maximumHeight (in addition
+ to fillWidth/fillHeight) for each child.
+
+ Example:
+
+ To create a SplitView with three items, and let
+ the center item be expanding, one could do the following:
+
+ \qml
+ SplitView {
+ anchors.fill: parent
+ orientation: Qt.Horizontal
+
+ Rectangle {
+ width: 200
+ Layout.maximumWidth: 400
+ color: "gray"
+ }
+ Rectangle {
+ id: centerItem
+ Layout.minimumWidth: 50
+ Layout.fillWidth: true
+ color: "darkgray"
+ }
+ Rectangle {
+ width: 200
+ color: "gray"
+ }
+ }
+ \endqml
+*/
+
+Item {
+ id: root
+
+ /*!
+ \qmlproperty enumeration SplitView::orientation
+
+ This property holds the orientation of the split view.
+ The value can be either \c Qt.Horizontal or \c Qt.Vertical.
+ The default value is \c Qt.Horizontal.
+ */
+ property int orientation: Qt.Horizontal
+
+ /*!
+ This property holds the delegate that will be instantiated between each
+ child item. Inside the delegate, the following properties are available:
+ \list
+ \li int \c handleIndex - specifies the index of the splitter handle. The handle
+ between the first and the second item will get index 0,
+ the next handle index 1 etc.
+ \li bool \c pressed: the handle is being pressed.
+ \li bool \c resizing: the handle is being dragged.
+ \endlist
+ */
+ property Component handleDelegate: Rectangle {
+ width: 1
+ height: 1
+ color: Qt.darker(pal.window, 1.5)
+ }
+
+ /*!
+ This propery is \c true when the user is resizing any of the items by
+ dragging on the splitter handles.
+ */
+ property bool resizing: false
+
+ /*! \internal */
+ default property alias __contents: contents.data
+ /*! \internal */
+ property alias __items: splitterItems.children
+ /*! \internal */
+ property alias __handles: splitterHandles.children
+
+ clip: true
+ Component.onCompleted: d.init()
+ /*! \internal */
+ onWidthChanged: d.updateLayout()
+ /*! \internal */
+ onHeightChanged: d.updateLayout()
+
+ SystemPalette { id: pal }
+
+ QtObject {
+ id: d
+ property bool horizontal: orientation == Qt.Horizontal
+ property string minimum: horizontal ? "minimumWidth" : "minimumHeight"
+ property string maximum: horizontal ? "maximumWidth" : "maximumHeight"
+ property string offset: horizontal ? "x" : "y"
+ property string otherOffset: horizontal ? "y" : "x"
+ property string size: horizontal ? "width" : "height"
+ property string otherSize: horizontal ? "height" : "width"
+
+ property int expandingIndex: -1
+ property bool updateLayoutGuard: true
+
+ function init()
+ {
+ for (var i=0; i<__contents.length; ++i) {
+ var item = __contents[i];
+ if (!item.hasOwnProperty("x"))
+ continue
+
+ if (splitterItems.children.length > 0)
+ handleLoader.createObject(splitterHandles, {"handleIndex":splitterItems.children.length - 1})
+ item.parent = splitterItems
+ i-- // item was removed from list
+ item.widthChanged.connect(d.updateLayout)
+ item.heightChanged.connect(d.updateLayout)
+ item.Layout.maximumWidthChanged.connect(d.updateLayout)
+ item.Layout.minimumWidthChanged.connect(d.updateLayout)
+ item.Layout.maximumHeightChanged.connect(d.updateLayout)
+ item.Layout.minimumHeightChanged.connect(d.updateLayout)
+ item.visibleChanged.connect(d.updateExpandingIndex)
+ item.Layout.fillWidthChanged.connect(d.updateExpandingIndex)
+ item.Layout.fillHeightChanged.connect(d.updateExpandingIndex)
+ }
+
+ d.updateLayoutGuard = false
+ d.updateExpandingIndex()
+ }
+
+ function updateExpandingIndex()
+ {
+ if (!lastItem.visible)
+ return
+ var policy = (root.orientation === Qt.Horizontal) ? "fillWidth" : "fillHeight"
+ for (var i=0; i<__items.length-1; ++i) {
+ if (__items[i].Layout[policy] === true)
+ break;
+ }
+
+ d.expandingIndex = i
+ d.updateLayout()
+ }
+
+ function accumulatedSize(firstIndex, lastIndex, includeExpandingMinimum)
+ {
+ // Go through items and handles, and
+ // calculate their acummulated width.
+ var w = 0
+ for (var i=firstIndex; i<lastIndex; ++i) {
+ var item = __items[i]
+ if (item.visible) {
+ if (i !== d.expandingIndex)
+ w += item[d.size];
+ else if (includeExpandingMinimum && item.Layout[minimum] !== undefined)
+ w += item.Layout[minimum]
+
+ var handle = __handles[i]
+ if (handle)
+ w += handle[d.size]
+ }
+ }
+ return w
+ }
+
+ function updateLayout()
+ {
+ // This function will reposition both handles and
+ // items according to the their width/height:
+ if (__items.length === 0)
+ return;
+ if (!lastItem.visible)
+ return;
+ if (d.updateLayoutGuard === true)
+ return
+ d.updateLayoutGuard = true
+
+ // Ensure all items within their min/max:
+ for (var i=0; i<__items.length; ++i) {
+ if (i !== d.expandingIndex) {
+ var item = __items[i];
+ if (item.Layout[maximum] !== undefined) {
+ if (item[d.size] > item.Layout[maximum])
+ item[d.size] = item.Layout[maximum]
+ }
+ if (item.Layout[minimum] !== undefined) {
+ if (item[d.size] < item.Layout[minimum])
+ item[d.size] = item.Layout[minimum]
+ }
+ }
+ }
+
+ // Set size of expanding item to remaining available space:
+ var expandingItem = __items[expandingIndex]
+ var min = expandingItem.Layout[minimum] !== undefined ? expandingItem.Layout[minimum] : 0
+ expandingItem[d.size] = Math.max(min, root[d.size] - d.accumulatedSize(0, __items.length, false))
+
+ // Then, position items and handles according to their width:
+ var lastVisibleItem, lastVisibleHandle, handle
+ var implicitSize = min - expandingItem[d.size]
+
+ for (i=0; i<__items.length; ++i) {
+ // Position item to the right of the previous visible handle:
+ item = __items[i];
+ if (item.visible) {
+ item[d.offset] = lastVisibleHandle ? lastVisibleHandle[d.offset] + lastVisibleHandle[d.size] : 0
+ item[d.otherOffset] = 0
+ item[d.otherSize] = root[d.otherSize]
+ implicitSize += item[d.size]
+ lastVisibleItem = item
+
+ handle = __handles[i]
+ if (handle) {
+ handle[d.offset] = lastVisibleItem[d.offset] + Math.max(0, lastVisibleItem[d.size])
+ handle[d.otherOffset] = 0
+ handle[d.otherSize] = root[d.otherSize]
+ implicitSize += handle[d.size]
+ lastVisibleHandle = handle
+ }
+ }
+ }
+
+ if (root.orientation === Qt.horizontal) {
+ root.implicitWidth = implicitSize
+ root.implicitHeight = 0
+ } else {
+ root.implicitWidth = 0
+ root.implicitHeight = implicitSize
+ }
+
+ d.updateLayoutGuard = false
+ }
+ }
+
+ Component {
+ id: handleLoader
+ Loader {
+ id: itemHandle
+ property int handleIndex: -1
+ property alias containsMouse: mouseArea.containsMouse
+ property alias pressed: mouseArea.pressed
+ property bool resizing: mouseArea.drag.active
+
+ visible: __items[handleIndex + ((d.expandingIndex >= handleIndex) ? 0 : 1)].visible
+ sourceComponent: handleDelegate
+ onWidthChanged: d.updateLayout()
+ onHeightChanged: d.updateLayout()
+ onXChanged: moveHandle()
+ onYChanged: moveHandle()
+ onResizingChanged: root.resizing = resizing
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ anchors.leftMargin: (parent.width <= 1) ? -2 : 0
+ anchors.rightMargin: (parent.width <= 1) ? -2 : 0
+ anchors.topMargin: (parent.height <= 1) ? -2 : 0
+ anchors.bottomMargin: (parent.height <= 1) ? -2 : 0
+ hoverEnabled: true
+ drag.target: parent
+ drag.axis: root.orientation === Qt.Horizontal ? Drag.XAxis : Drag.YAxis
+ cursorShape: root.orientation === Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor
+ }
+
+ function moveHandle() {
+ // Moving the handle means resizing an item. Which one,
+ // left or right, depends on where the expanding item is.
+ // 'updateLayout' will override in case new width violates max/min.
+ // And 'updateLayout will be triggered when an item changes width.
+ if (d.updateLayoutGuard)
+ return
+
+ var leftHandle, leftItem, rightItem, rightHandle
+ var leftEdge, rightEdge, newWidth, leftStopX, rightStopX
+ var i
+
+ if (d.expandingIndex > handleIndex) {
+ // Resize item to the left.
+ // Ensure that the handle is not crossing other handles. So
+ // find the first visible handle to the left to determine the left edge:
+ leftEdge = 0
+ for (i=handleIndex-1; i>=0; --i) {
+ leftHandle = __handles[i]
+ if (leftHandle.visible) {
+ leftEdge = leftHandle[d.offset] + leftHandle[d.size]
+ break;
+ }
+ }
+
+ // Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX
+ var min = d.accumulatedSize(handleIndex+1, __items.length, true)
+ rightStopX = root[d.size] - min - itemHandle[d.size]
+ leftStopX = Math.max(leftEdge, itemHandle[d.offset])
+ itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset]))
+
+ newWidth = itemHandle[d.offset] - leftEdge
+ leftItem = __items[handleIndex]
+ // The next line will trigger 'updateLayout':
+ leftItem[d.size] = newWidth
+ } else {
+ // Resize item to the right.
+ // Ensure that the handle is not crossing other handles. So
+ // find the first visible handle to the right to determine the right edge:
+ rightEdge = root[d.size]
+ for (i=handleIndex+1; i<__handles.length; ++i) {
+ rightHandle = __handles[i]
+ if (rightHandle.visible) {
+ rightEdge = rightHandle[d.offset]
+ break;
+ }
+ }
+
+ // Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX
+ min = d.accumulatedSize(0, handleIndex+1, true)
+ leftStopX = min - itemHandle[d.size]
+ rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset])
+ itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX))
+
+ newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size])
+ rightItem = __items[handleIndex+1]
+ // The next line will trigger 'updateLayout':
+ rightItem[d.size] = newWidth
+ }
+ }
+ }
+ }
+
+ Item {
+ id: contents
+ visible: false
+ anchors.fill: parent
+ }
+ Item {
+ id: splitterItems
+ anchors.fill: parent
+ }
+ Item {
+ id: splitterHandles
+ anchors.fill: parent
+ }
+
+ Item {
+ id: lastItem
+ onVisibleChanged: d.updateExpandingIndex()
+ }
+
+ Component.onDestruction: {
+ for (var i=0; i<splitterItems.children.length; ++i) {
+ var item = splitterItems.children[i];
+ item.visibleChanged.disconnect(d.updateExpandingIndex)
+ item.Layout.fillWidthChanged.disconnect(d.updateExpandingIndex)
+ item.Layout.fillHeightChanged.disconnect(d.updateExpandingIndex)
+ }
+ }
+}
diff --git a/src/qtdesktop/StatusBar.qml b/src/controls/StatusBar.qml
index f668150a..b3987cb4 100644
--- a/src/qtdesktop/StatusBar.qml
+++ b/src/controls/StatusBar.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,19 +38,40 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype StatusBar
- \inqmlmodule QtDesktop 1.0
- \brief StatusBar is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup applicationwindow
+ \brief Contains status information in your app.
+
+ The common way of using StatusBar is in relation to \l ApplicationWindow.
+
+ Note that the StatusBar does not provide a layout of its own, but requires
+ you to position its contents, for instance by creating a \l Row.
+
+ \code
+ ApplicationWindow {
+ statusBar: StatusBar {
+ Label {
+ text: "Read Only"
+ anchors.centerIn: parent
+ }
+ }
+ }
+ \endcode
*/
Item {
- width: parent ? parent.width : 200
- height: 24
+ id: statusbar
+ implicitHeight: 20
+ implicitWidth: parent ? parent.width : style.implicitWidth
+ activeFocusOnTab: false
StyleItem {
+ id: style
anchors.fill: parent
elementType: "statusbar"
}
diff --git a/src/qtdesktop/Tab.qml b/src/controls/Tab.qml
index b27a29f5..3c86cc3c 100644
--- a/src/qtdesktop/Tab.qml
+++ b/src/controls/Tab.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,17 +38,33 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
/*!
\qmltype Tab
- \inqmlmodule QtDesktop 1.0
- \brief Tab is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup viewaddons
+ \brief Tab represents the content of a tab in a TabView.
+
+ A Tab item inherits from Loader and provides a similar
+ api.
*/
-Item {
- id:tab
+Loader {
+ id: tab
anchors.fill: parent
+
+ /*! This property holds the title of the tab. */
property string title
- property int contentMargin
+ Accessible.role: Accessible.PageTab
+ active: false
+ visible: false
+
+ activeFocusOnTab: false
+
+ /*! \internal */
+ onVisibleChanged: if (visible) active = true
+
+ /*! \internal */
+ default property alias component: tab.sourceComponent
}
diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml
new file mode 100644
index 00000000..bd0ed4f1
--- /dev/null
+++ b/src/controls/TabView.qml
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype TabView
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief A control that allows the user to select one of multiple stacked items.
+
+*/
+
+FocusScope {
+ id: root
+ implicitWidth: 150
+ implicitHeight: 150
+
+ /*! The current tab index */
+ property int currentIndex: 0
+
+ /*! The current tab count */
+ property int count: 0
+
+ /*! The visibility of the tab frame around contents */
+ property bool frameVisible: true
+
+ /*! The visibility of the tab bar */
+ property bool tabsVisible: true
+
+ /*!
+ \qmlproperty enumeration TabView::tabPosition
+
+ \list
+ \li Qt.TopEdge (default)
+ \li Qt.BottomEdge
+ \endlist
+ */
+ property int tabPosition: Qt.TopEdge
+
+ /*! \internal */
+ default property alias data: stack.data
+
+ /*! Adds a new tab page with title with and optional Component.
+ \return the newly added tab
+ */
+ function addTab(title, component) {
+ var tab = tabcomp.createObject(this);
+ tab.sourceComponent = component
+ __tabs.push(tab)
+ tab.parent = stack
+ tab.title = title
+ __setOpacities()
+ return tab
+ }
+
+ /*! Inserts a new tab with title at index, with an optional Component.
+ \return the newly added tab
+ */
+ function insertTab(index, title, component) {
+ var tab = tabcomp.createObject(this);
+ tab.sourceComponent = component
+ tab.parent = stack
+ tab.title = title
+ __tabs.splice(index, 0, tab);
+ __setOpacities()
+ return tab
+ }
+
+ /*! Removes and destroys a tab at the given index */
+ function removeTab(index) {
+ var tab = __tabs[index]
+ __tabs.splice(index, 1);
+ tab.destroy()
+ if (currentIndex > 0)
+ currentIndex--
+ __setOpacities()
+ }
+
+ /*! Returns the \l Tab item at index */
+ function tabAt(index) {
+ return __tabs[index]
+ }
+
+ /*! \internal */
+ property var __tabs: new Array()
+
+ /*! \internal */
+ property Component style: Qt.createComponent(Settings.THEME_PATH + "/TabViewStyle.qml", root)
+
+ /*! \internal */
+ property var __styleItem: loader.item
+
+ /*! \internal */
+ onCurrentIndexChanged: __setOpacities()
+
+ /*! \internal */
+ function __setOpacities() {
+ for (var i = 0; i < __tabs.length; ++i) {
+ var child = __tabs[i];
+ child.visible = (i == currentIndex ? true : false)
+ }
+ count = __tabs.length
+ }
+
+ activeFocusOnTab: false
+
+ Component {
+ id: tabcomp
+ Tab {}
+ }
+
+ TabBar {
+ id: tabbarItem
+ tabView: root
+ style: loader.item
+ anchors.top: parent.top
+ anchors.left: root.left
+ anchors.right: root.right
+ }
+
+ Loader {
+ id: loader
+ z: tabbarItem.z - 1
+ sourceComponent: style
+ property var control: root
+ }
+
+ Loader {
+ id: frameLoader
+ z: tabbarItem.z - 1
+
+ anchors.fill: parent
+ anchors.topMargin: tabbarItem && tabsVisible && tabPosition == Qt.TopEdge ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0
+ anchors.bottomMargin: tabbarItem && tabsVisible && tabPosition == Qt.BottomEdge ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0
+ sourceComponent: frameVisible && loader.item ? loader.item.frame : null
+ property var control: root
+
+ Item {
+ id: stack
+
+ anchors.fill: parent
+ anchors.margins: (frameVisible ? frameWidth : 0)
+ anchors.topMargin: anchors.margins + (style =="mac" ? 6 : 0)
+ anchors.bottomMargin: anchors.margins + (style =="mac" ? 6 : 0)
+
+ property int frameWidth
+ property string style
+ property int baseOverlap
+
+ /*! \internal */
+ Component.onCompleted: {
+ for (var i = 0 ; i < stack.children.length ; ++i) {
+ if (stack.children[i].Accessible.role === Accessible.PageTab)
+ __tabs.push(stack.children[i])
+ }
+ __setOpacities()
+ }
+ }
+ onLoaded: { item.z = -1 }
+ }
+
+ states: [
+ State {
+ name: "Bottom"
+ when: tabPosition == Qt.BottomEdge && tabbarItem != undefined
+ PropertyChanges {
+ target: tabbarItem
+ anchors.topMargin: tabbarItem.height
+ }
+ AnchorChanges {
+ target: tabbarItem
+ anchors.top: undefined
+ anchors.bottom: root.bottom
+ }
+ }
+ ]
+}
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml
new file mode 100644
index 00000000..7da97ef8
--- /dev/null
+++ b/src/controls/TableView.qml
@@ -0,0 +1,690 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype TableView
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief Provides a list view with scroll bars, styling and header sections.
+
+ \image tableview.png
+
+ A TableView is similar to \l ListView and adds scroll bars, selection and
+ resizable header sections. As with \l ListView, data for each row is provided through a \l model:
+
+ \code
+ ListModel {
+ id: libraryModel
+ ListElement{ title: "A Masterpiece" ; author: "Gabriel" }
+ ListElement{ title: "Brilliance" ; author: "Jens" }
+ ListElement{ title: "Outstanding" ; author: "Frederik" }
+ }
+ \endcode
+
+ You provide title and size of a column header
+ by adding a \l TableViewColumn to the default \l header property
+ as demonstrated below.
+ \code
+
+ TableView {
+ TableViewColumn{ role: "title" ; title: "Title" ; width: 100 }
+ TableViewColumn{ role: "author" ; title: "Author" ; width: 200 }
+ model: libraryModel
+ }
+ \endcode
+
+ The header sections are attached to values in the \l model by defining
+ the model role they attach to. Each property in the model, will
+ then be shown in their corresponding column.
+
+ You can customize the look by overriding the \l itemDelegate,
+ \l rowDelegate or \l headerDelegate properties.
+
+ The view itself does not provide sorting. This has to
+ be done on the model itself. However you can provide sorting
+ on the model and enable sort indicators on headers.
+
+\list
+ \li sortColumnIndex - The index of the current sort column
+ \li sortIndicatorVisible - If the sort indicator should be enabled
+ \li sortIndicatorOrder - Qt.AscendingOrder or Qt.DescendingOrder depending on state
+\endlist
+*/
+
+ScrollView {
+ id: root
+
+ /*! \qmlproperty model TableView::model
+ This property holds the model providing data for the table view.
+
+ The model provides the set of data that is used to create the items in the view.
+ Models can be created directly in QML using ListModel, XmlListModel or VisualItemModel,
+ or provided by C++ model classes. \sa ListView::model
+
+ Example model:
+
+ \code
+ model: ListModel {
+ ListElement{ column1: "value 1" ; column2: "value 2" }
+ ListElement{ column1: "value 3" ; column2: "value 4" }
+ }
+ \endcode
+ \sa {qml-data-models}{Data Models}
+ */
+ property var model
+
+ /*! This property is set to \c true if the view alternates the row color.
+ The default value is \c true. */
+ property bool alternatingRowColors: true
+
+ /*! This property determines if the header is visible.
+ The default value is \c true. */
+ property bool headerVisible: true
+
+ /*! This property defines a delegate to draw a specific cell.
+
+ In the item delegate you have access to the following special properties:
+ \list
+ \li itemSelected - if the item is currently selected
+ \li itemValue - the value or text for this item
+ \li itemTextColor - the default text color for an item
+ \li rowIndex - the index of the row
+ \li columnIndex - the index of the column
+ \li itemElideMode - the elide mode of the column
+ \li itemTextAlignment - the horizontal text alignment of the column
+ \endlist
+ Example:
+ \code
+ itemDelegate: Item {
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ color: itemTextColor
+ elide: itemElideMode
+ text: itemValue
+ }
+ }
+ \endcode */
+ property Component itemDelegate: standardDelegate
+
+ /*! This property defines a delegate to draw a row.
+
+ In the row delegate you have access to the following special properties:
+ \list
+ \li alternateBackground - if the row uses the alternate background color
+ \li rowSelected - if the row is currently selected
+ \li index - the index of the row
+ \endlist
+ */
+ property Component rowDelegate: rowDelegate
+
+ /*! \qmlproperty color TableView::backgroundColor
+
+ This property sets the background color of the viewport.
+ The default value is the base color of the SystemPalette. */
+ property alias backgroundColor: colorRect.color
+
+ /*! This property defines a delegate to draw a header. */
+ property Component headerDelegate: headerDelegate
+
+ /*! Index of the current sort column.
+ The default value is \c 0. */
+ property int sortColumnIndex
+
+ /*! This property shows or hides the sort indicator
+ The default value is \c false.
+ \note The view itself does not sort the data. */
+ property bool sortIndicatorVisible: false
+
+ /*! This sets the sorting order of the sort indicator
+ The allowed values are:
+ \list
+ \li Qt.AscendingOrder - the default
+ \li Qt.DescendingOrder
+ \endlist */
+ property string sortIndicatorOrder: Qt.AscendingOrder
+
+ /*! \qmlproperty list<TableViewColumn> TableView::columns
+ This property contains the TableViewColumn items */
+ default property alias columns: listView.columnheader
+
+ /*! \qmlproperty Component TableView::contentHeader
+ This is the content header of the TableView */
+ property alias contentHeader: listView.header
+
+ /*! \qmlproperty Component TableView::contentFooter
+ This is the content footer of the TableView */
+ property alias contentFooter: listView.footer
+
+ /*! \qmlproperty Item TableView::currentRowItem
+ This is the current item of the TableView */
+ property alias currentRowItem: listView.currentItem
+
+ /*! \qmlproperty int TableView::rowCount
+ The current number of rows */
+ property alias rowCount: listView.count
+
+ /*! The current number of columns */
+ property int columnCount: columns.length
+
+ /*! \qmlproperty string TableView::section.property
+ \qmlproperty enumeration TableView::section.criteria
+ \qmlproperty Component TableView::section.delegate
+ \qmlproperty enumeration TableView::section.labelPositioning
+ These properties determine the section labels.
+ \sa ListView::section */
+ property alias section: listView.section
+
+ /*! \qmlproperty int TableView::currentRow
+ The current row index of the view. */
+ property alias currentRow: listView.currentIndex
+
+ /*! \qmlsignal TableView::activated()
+ Emitted when a new row is selected by the user. */
+ signal activated
+
+ Accessible.role: Accessible.Table
+
+ width: 200
+ height: 200
+
+ frameVisible: true
+ __scrollBarTopMargin: styleitem.style == "mac" ? headerrow.height : 0
+
+ /*! \internal */
+ function __decrementCurrentIndex() {
+ __scroller.blockUpdates = true;
+ listView.decrementCurrentIndex();
+ __scroller.blockUpdates = false;
+ }
+
+ /*! \internal */
+ function __incrementCurrentIndex() {
+ __scroller.blockUpdates = true;
+ listView.incrementCurrentIndex();
+ __scroller.blockUpdates = false;
+ }
+
+ ListView {
+ id: listView
+ anchors.topMargin: tableHeader.height
+ anchors.fill: parent
+
+ flickableDirection: Flickable.HorizontalFlick
+ SystemPalette {
+ id: palette
+ colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
+
+ Rectangle {
+ id: colorRect
+ parent: viewport
+ anchors.fill: parent
+ color: palette.base
+ z: -1
+ }
+
+ StyleItem {
+ id: itemstyle
+ elementType: "item"
+ visible: false
+ }
+
+ MouseArea {
+ id: mousearea
+
+ anchors.fill: listView
+
+ property bool autoincrement: false
+ property bool autodecrement: false
+
+ onReleased: {
+ autoincrement = false
+ autodecrement = false
+ }
+
+ // Handle vertical scrolling whem dragging mouse outside boundraries
+ Timer { running: mousearea.autoincrement && __scroller.verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: __incrementCurrentIndex()}
+ Timer { running: mousearea.autodecrement && __scroller.verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: __decrementCurrentIndex()}
+
+ onPositionChanged: {
+ if (mouseY > listView.height && pressed) {
+ if (autoincrement) return;
+ autodecrement = false;
+ autoincrement = true;
+ } else if (mouseY < 0 && pressed) {
+ if (autodecrement) return;
+ autoincrement = false;
+ autodecrement = true;
+ } else {
+ autoincrement = false;
+ autodecrement = false;
+ }
+ var y = Math.min(flickableItem.contentY + listView.height - 5, Math.max(mouseY + flickableItem.contentY, flickableItem.contentY));
+ var newIndex = listView.indexAt(0, y);
+ if (newIndex >= 0)
+ listView.currentIndex = listView.indexAt(0, y);
+ }
+
+ onPressed: {
+ listView.forceActiveFocus()
+ var x = Math.min(flickableItem.contentWidth - 5, Math.max(mouseX + flickableItem.contentX, 0))
+ var y = Math.min(flickableItem.contentHeight - 5, Math.max(mouseY + flickableItem.contentY, 0))
+ listView.currentIndex = listView.indexAt(x, y)
+ }
+
+ onDoubleClicked: { root.activated() }
+
+ // Note by prevent stealing we are keeping the flickable from
+ // eating our mouse press events
+ preventStealing: true
+ }
+
+ // Fills extra rows with alternate color
+ Column {
+ id: rowfiller
+ property int rowHeight: flickableItem.contentHeight/count
+ property int paddedRowCount: height/rowHeight
+ property int count: flickableItem.count
+ y: flickableItem.contentHeight
+ width: parent.width
+ visible: flickableItem.contentHeight > 0 && alternatingRowColors
+ height: viewport.height - flickableItem.contentHeight
+ Repeater {
+ model: visible ? parent.paddedRowCount : 0
+ Loader {
+ width: rowfiller.width
+ height: rowfiller.rowHeight
+ sourceComponent: root.rowDelegate
+ property bool alternateBackground: (index + rowCount) % 2 === 1
+ property bool rowSelected: false
+ property var model: listView.model
+ property var modelData: null
+ }
+ }
+ }
+
+ property list<TableViewColumn> columnheader
+ highlightFollowsCurrentItem: true
+ model: root.model
+
+ Keys.onUpPressed: root.__decrementCurrentIndex()
+ Keys.onDownPressed: root.__incrementCurrentIndex()
+
+ Keys.onPressed: {
+ if (event.key === Qt.Key_PageUp) {
+ verticalScrollBar.value = __scroller.verticalScrollBar.value - listView.height
+ } else if (event.key === Qt.Key_PageDown)
+ verticalScrollBar.value = __scroller.verticalScrollBar.value + listView.height
+ }
+
+ Keys.onReturnPressed: root.activated();
+
+ delegate: Item {
+ id: rowitem
+ width: row.width
+ height: rowstyle.height
+
+ property int rowIndex: model.index
+ property bool alternateBackground: alternatingRowColors && rowIndex % 2 == 1
+ property var itemModelData: typeof modelData == "undefined" ? null : modelData
+ property var itemModel: model
+
+ Loader {
+ id: rowstyle
+ // row delegate
+ sourceComponent: root.rowDelegate
+ // Row fills the view width regardless of item size
+ // But scrollbar should not adjust to it
+ width: parent.width + __scroller.horizontalScrollBar.width
+ x: flickableItem.contentX
+
+ // these properties are exposed to the row delegate
+ property bool alternateBackground: rowitem.alternateBackground
+ property bool rowSelected: rowitem.ListView.isCurrentItem
+ property int index: rowitem.rowIndex
+ property var model: listView.model
+ property var modelData: rowitem.itemModelData
+ property var itemModel: rowitem.itemModel
+ }
+ Row {
+ id: row
+ anchors.left: parent.left
+ height: parent.height
+ Repeater {
+ id: repeater
+ model: root.columns.length
+ Loader {
+ id: itemDelegateLoader
+ width: columns[index].width
+ height: parent ? parent.height : 0
+ visible: columns[index].visible
+ sourceComponent: columns[index].delegate ? columns[index].delegate : itemDelegate
+
+ // these properties are exposed to the item delegate
+ property var model: listView.model
+ property var modelData: itemModelData
+
+ property var itemValue: __getValue()
+ property bool itemSelected: rowitem.ListView.isCurrentItem
+ property color itemTextColor: itemSelected ? rowstyleitem.highlightedTextColor : rowstyleitem.textColor
+ property int rowIndex: rowitem.rowIndex
+ property int columnIndex: index
+ property int itemElideMode: columns[index].elideMode
+ property int itemTextAlignment: columns[index].horizontalAlignment
+
+ function __getValue() {
+ var role = columns[index].role
+ if (role.length && itemModel.hasOwnProperty(role))
+ return itemModel[role] // Qml ListModel and QAbstractItemModel
+ else if (modelData != undefined && modelData.hasOwnProperty(role))
+ return modelData[role] // QObjectList / QObject
+ else if (modelData != undefined)
+ return modelData // Models without role
+ else
+ return ""
+ }
+ }
+ }
+ onWidthChanged: listView.contentWidth = width
+ }
+ }
+
+ Text{ id:text }
+
+ Item {
+ id: tableHeader
+ clip: true
+ parent: __scroller
+ visible: headerVisible
+ anchors.top: parent.top
+ anchors.margins: viewport.anchors.margins
+ anchors.rightMargin: __scroller.frameWidth +
+ (__scroller.outerFrame && __scrollBarTopMargin ? 0 : __scroller.verticalScrollBar.width
+ + __scroller.scrollBarSpacing)
+
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ height: headerVisible ? headerrow.height : 0
+
+ Behavior on height { NumberAnimation{ duration: 80 } }
+
+ Row {
+ id: headerrow
+ x: -listView.contentX
+
+ Repeater {
+ id: repeater
+
+ property int targetIndex: -1
+ property int dragIndex: -1
+
+ model: columns.length
+
+ delegate: Item {
+ z:-index
+ width: columns[index].width
+ visible: columns[index].visible
+ height: headerStyle.height
+
+ Loader {
+ id: headerStyle
+ sourceComponent: root.headerDelegate
+ anchors.left: parent.left
+ anchors.right: parent.right
+ property string itemValue: columns[index].title
+ property string itemSort: (sortIndicatorVisible && index == sortColumnIndex) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
+ property bool itemPressed: headerClickArea.pressed
+ property bool itemContainsMouse: headerClickArea.containsMouse
+ property string itemPosition: columns.length === 1 ? "only" :
+ index===columns.length-1 ? "end" :
+ index===0 ? "beginning" : ""
+ }
+ Rectangle{
+ id: targetmark
+ width: parent.width
+ height:parent.height
+ opacity: (index == repeater.targetIndex && repeater.targetIndex != repeater.dragIndex) ? 0.5 : 0
+ Behavior on opacity { NumberAnimation{duration:160}}
+ color: palette.highlight
+ }
+
+ MouseArea{
+ id: headerClickArea
+ drag.axis: Qt.YAxis
+ hoverEnabled: true
+ anchors.fill: parent
+ onClicked: {
+ if (sortColumnIndex == index)
+ sortIndicatorOrder = sortIndicatorOrder == Qt.AscendingOrder ? Qt.DescendingOrder : Qt.AscendingOrder
+ sortColumnIndex = index
+ }
+ // Here we handle moving header sections
+ // NOTE: the direction is different from the master branch
+ // so this indicates that I am using an invalid assumption on item ordering
+ onPositionChanged: {
+ if (pressed) { // only do this while dragging
+ for (var h = columns.length-1 ; h >= 0 ; --h) {
+ if (drag.target.x > headerrow.children[h].x) {
+ repeater.targetIndex = h
+ break
+ }
+ }
+ }
+ }
+
+ onPressed: {
+ repeater.dragIndex = index
+ draghandle.x = parent.x
+ }
+
+ onReleased: {
+ if (repeater.targetIndex >= 0 && repeater.targetIndex != index ) {
+ // Rearrange the header sections
+ var items = new Array
+ for (var i = 0 ; i< columns.length ; ++i)
+ items.push(columns[i])
+ items.splice(index, 1);
+ items.splice(repeater.targetIndex, 0, columns[index]);
+ columns = items
+ if (sortColumnIndex == index)
+ sortColumnIndex = repeater.targetIndex
+ }
+ repeater.targetIndex = -1
+ }
+ drag.maximumX: 1000
+ drag.minimumX: -1000
+ drag.target: draghandle
+ }
+
+ Loader {
+ id: draghandle
+ property string itemValue: columns[index].title
+ property string itemSort: (sortIndicatorVisible && index == sortColumnIndex) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : "";
+ property bool itemPressed: headerClickArea.pressed
+ property bool itemContainsMouse: headerClickArea.containsMouse
+ property string itemPosition
+
+ parent: tableHeader
+ width: columns[index].width
+ height: parent.height
+ sourceComponent: root.headerDelegate
+ visible: headerClickArea.pressed
+ opacity: 0.5
+ }
+
+
+ MouseArea {
+ id: headerResizeHandle
+ property int offset: 0
+ property int minimumSize: 20
+ anchors.rightMargin: -width/2
+ width: 16 ; height: parent.height
+ anchors.right: parent.right
+ onPositionChanged: {
+ var newHeaderWidth = columns[index].width + (mouseX - offset)
+ columns[index].width = Math.max(minimumSize, newHeaderWidth)
+ }
+ property bool found:false
+
+ onDoubleClicked: {
+ var row
+ var minWidth = 0
+ var listdata = listView.children[0]
+ for (row = 0 ; row < listdata.children.length ; ++row){
+ var item = listdata.children[row+1]
+ if (item && item.children[1] && item.children[1].children[index] &&
+ item.children[1].children[index].children[0].hasOwnProperty("implicitWidth"))
+ minWidth = Math.max(minWidth, item.children[1].children[index].children[0].implicitWidth)
+ }
+ if (minWidth)
+ columns[index].width = minWidth
+ }
+ onPressedChanged: if (pressed) offset=mouseX
+ cursorShape: Qt.SplitHCursor
+ }
+ }
+ }
+ }
+ Loader {
+ id: loader
+ property string itemValue
+ property string itemSort
+ property bool itemPressed
+ property bool itemContainsMouse
+ property string itemPosition
+
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.bottom: headerrow.bottom
+ anchors.rightMargin: -2
+ sourceComponent: root.headerDelegate
+ width: root.width - headerrow.width + 2
+ visible: root.columns.length
+ z:-1
+ }
+
+ Component {
+ id: standardDelegate
+ Item {
+ height: Math.max(16, styleitem.implicitHeight)
+ property int implicitWidth: sizehint.paintedWidth + 4
+ Text {
+ id: label
+ objectName: "label"
+ width: parent.width
+ anchors.margins: 6
+ font: itemstyle.font
+ anchors.left: parent.left
+ anchors.right: parent.right
+ horizontalAlignment: itemTextAlignment
+ anchors.verticalCenter: parent.verticalCenter
+ elide: itemElideMode
+ text: itemValue != undefined ? itemValue : ""
+ color: itemTextColor
+ renderType: Text.NativeRendering
+ }
+ Text {
+ id: sizehint
+ font: label.font
+ text: itemValue ? itemValue : ""
+ visible: false
+ }
+ }
+ }
+
+ Component {
+ id: nativeDelegate
+ // This gives more native styling, but might be less performant
+ StyleItem {
+ elementType: "item"
+ text: itemValue
+ selected: itemSelected
+ active: root.activeFocus
+ }
+ }
+
+ Component {
+ id: headerDelegate
+ StyleItem {
+ elementType: "header"
+ activeControl: itemSort
+ raised: true
+ sunken: itemPressed
+ text: itemValue
+ hover: itemContainsMouse
+ hints: itemPosition
+ }
+ }
+
+ Component {
+ id: rowDelegate
+ StyleItem {
+ id: rowstyle
+ elementType: "itemrow"
+ activeControl: alternateBackground ? "alternate" : ""
+ selected: rowSelected ? true : false
+ height: Math.max(16, styleitem.implicitHeight)
+ active: root.activeFocus
+ }
+ }
+
+ StyleItem {
+ id: styleitem
+ elementType: "header"
+ visible:false
+ contentWidth: 16
+ contentHeight: font.pixelSize
+ }
+
+ StyleItem {
+ id: rowstyleitem
+ property color textColor: styleHint("textColor")
+ property color highlightedTextColor: styleHint("highlightedTextColor")
+ elementType: "item"
+ visible: false
+ }
+ }
+ }
+}
diff --git a/src/qtdesktop/TableColumn.qml b/src/controls/TableViewColumn.qml
index 9bf95bf2..fe83561e 100644
--- a/src/qtdesktop/TableColumn.qml
+++ b/src/controls/TableViewColumn.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,21 +38,54 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
/*!
- \qmltype TableColumn
- \inqmlmodule QtDesktop 1.0
- \brief TableColumn is doing bla...bla...
+ \qmltype TableViewColumn
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup viewitems
+ \brief Used to define columns in a \l TableView.
*/
QtObject {
+ /*! The title text of the column. */
property string title
+
+ /*! The model \c role of the column. */
property string role
+
+ /*! The current width of the column
+ The default value depends on platform. */
property int width: 160
- property int x
+
+ /*! The visible status of the column. */
property bool visible: true
+
+ /*! \qmlproperty enumeration TableViewColumn::elideMode
+ The text elide mode of the column.
+ Allowed values are:
+ \list
+ \li Text.ElideNone
+ \li Text.ElideLeft
+ \li Text.ElideMiddle
+ \li Text.ElideRight - the default
+ \endlist
+ \sa {QtQuick2::}{Text::elide} */
property int elideMode: Text.ElideRight
- property int textAlignment: Text.AlignLeft
+
+ /*! \qmlproperty enumeration TableViewColumn::horizontalAlignment
+ The horizontal text alignment of the column.
+ Allowed values are:
+ \list
+ \li Text.AlignLeft - the default
+ \li Text.AligntRight
+ \li Text.AlignHCenter
+ \li Text.AlignJustify
+ \endlist
+ \sa {QtQuick2::}{Text::horizontalAlignment} */
+ property int horizontalAlignment: Text.AlignLeft
+
+ /*! The delegate of the column. This can be used to set the
+ \l TableView::itemDelegate for a specific column. */
property Component delegate
}
diff --git a/src/qtdesktop/TextArea.qml b/src/controls/TextArea.qml
index 865be9ff..c34315c3 100644
--- a/src/qtdesktop/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,12 +38,13 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype TextArea
- \inqmlmodule QtDesktop 1.0
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
\brief TextArea displays multiple lines of editable formatted text.
It can display both plain and rich text. For example:
@@ -52,12 +53,9 @@ import QtDesktop 1.0
TextArea {
width: 240
text: "<b>Hello</b> <i>World!</i>"
- focus: true
}
\endqml
- Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus.
-
Clipboard support is provided by the cut(), copy(), and paste() functions, and the selection can
be handled in a traditional "mouse" mechanism by setting selectByMouse, or handled completely
from QML by manipulating selectionStart and selectionEnd, or using selectAll() or selectWord().
@@ -68,11 +66,11 @@ import QtDesktop 1.0
\sa TextField, TextEdit
*/
-ScrollArea {
+ScrollView {
id: area
/*!
- \qmlproperty bool TextArea::::activeFocusOnPress
+ \qmlproperty bool TextArea::activeFocusOnPress
Whether the TextEdit should gain active focus on a mouse press. By default this is
set to true.
@@ -80,107 +78,57 @@ ScrollArea {
property alias activeFocusOnPress: edit.activeFocusOnPress
/*!
- \qmlproperty url TextArea::::baseUrl
+ \qmlproperty url TextArea::baseUrl
This property specifies a base URL which is used to resolve relative URLs
within the text.
- The default value is the url of the QML file instantiating the TextEdit item.
+ The default value is the url of the QML file instantiating the TextArea item.
*/
property alias baseUrl: edit.baseUrl
/*!
- \qmlproperty bool TextArea::::canPaste
+ \qmlproperty bool TextArea::canPaste
- Returns true if the TextEdit is writable and the content of the clipboard is
- suitable for pasting into the TextEdit.
+ Returns true if the TextArea is writable and the content of the clipboard is
+ suitable for pasting into the TextArea.
*/
- property alias canPaste: edit.canPaste
+ readonly property alias canPaste: edit.canPaste
/*!
- \qmlproperty bool TextArea::::canRedo
+ \qmlproperty bool TextArea::canRedo
- Returns true if the TextEdit is writable and there are \l {undo}{undone}
+ Returns true if the TextArea is writable and there are \l {undo}{undone}
operations that can be redone.
*/
- property alias canRedo: edit.canRedo
+ readonly property alias canRedo: edit.canRedo
/*!
- \qmlproperty bool TextArea::::canUndo
+ \qmlproperty bool TextArea::canUndo
- Returns true if the TextEdit is writable and there are previous operations
+ Returns true if the TextArea is writable and there are previous operations
that can be undone.
*/
- property alias canUndo: edit.canUndo
+ readonly property alias canUndo: edit.canUndo
/*!
- \qmlproperty color TextArea::::color
+ \qmlproperty color TextArea::textColor
The text color.
\qml
- // green text using hexadecimal notation
- TextEdit { color: "#00FF00" }
- \endqml
-
- \qml
- // steelblue text using SVG color name
- TextEdit { color: "steelblue" }
+ TextArea { color: "orange" }
\endqml
*/
- property alias color: edit.color
-
- /*!
- \qmlproperty Component TextArea::cursorDelegate
- The delegate for the cursor in the TextEdit.
-
- If you set a cursorDelegate for a TextEdit, this delegate will be used for
- drawing the cursor instead of the standard cursor. An instance of the
- delegate will be created and managed by the text edit when a cursor is
- needed, and the x and y properties of delegate instance will be set so as
- to be one pixel before the top left of the current character.
-
- Note that the root item of the delegate component must be a QQuickItem or
- QQuickItem derived item.
- */
- property alias cursorDelegate: edit.cursorDelegate
+ property alias textColor: edit.color
/*!
\qmlproperty int TextArea::cursorPosition
- The position of the cursor in the TextEdit.
+ The position of the cursor in the TextArea.
*/
property alias cursorPosition: edit.cursorPosition
- /*!
- \qmlproperty rectangle TextArea::cursorRectangle
-
- The rectangle where the standard text cursor is rendered
- within the text edit. Read-only.
-
- The position and height of a custom cursorDelegate are updated to follow the cursorRectangle
- automatically when it changes. The width of the delegate is unaffected by changes in the
- cursor rectangle.
- */
- property alias cursorRectangle: edit.cursorRectangle
-
- /*!
- \qmlproperty bool TextArea::cursorVisible
- The document margins of the TextEdit.
- */
- property alias cursorVisible: edit.cursorVisible
-
- /*!
- \qmlproperty bool TextArea::documentMargins
- If true the text edit shows a cursor.
-
- This property is set and unset when the text edit gets active focus, but it can also
- be set directly (useful, for example, if a KeyProxy might forward keys to it).
- */
-
- property int documentMargins: 4
-
- /*!
- \qmlproperty font TextArea::font
+ /*! \qmlproperty font TextArea::font
The font of the TextArea.
*/
@@ -188,51 +136,49 @@ ScrollArea {
/*!
\qmlproperty enumeration TextArea::horizontalAlignment
- \qmlproperty enumeration TextArea::verticalAlignment
- \qmlproperty enumeration TextArea::effectiveHorizontalAlignment
- Sets the horizontal and vertical alignment of the text within the TextEdit item's
- width and height. By default, the text alignment follows the natural alignment
- of the text, for example text that is read from left to right will be aligned to
- the left.
+ Sets the alignment of the text within the TextArea item's width.
- Valid values for \c horizontalAlignment are:
+ By default, the horizontal text alignment follows the natural alignment of the text,
+ for example text that is read from left to right will be aligned to the left.
+
+ The valid values for \c horizontalAlignment are:
\list
- \li TextEdit.AlignLeft (default)
+ \li TextEdit.AlignLeft (Default)
\li TextEdit.AlignRight
\li TextEdit.AlignHCenter
- \li TextEdit.AlignJustify
- \endlist
-
- Valid values for \c verticalAlignment are:
- \list
- \li TextEdit.AlignTop (default)
- \li TextEdit.AlignBottom
- \li TextEdit.AlignVCenter
\endlist
When using the attached property LayoutMirroring::enabled to mirror application
layouts, the horizontal alignment of text will also be mirrored. However, the property
\c horizontalAlignment will remain unchanged. To query the effective horizontal alignment
- of TextEdit, use the read-only property \c effectiveHorizontalAlignment.
+ of TextArea, use the read-only property \c effectiveHorizontalAlignment.
*/
property alias horizontalAlignment: edit.horizontalAlignment
- property alias verticalAlignment: edit.verticalAlignment
- property alias effectiveHorizontalAlignment: edit.effectiveHorizontalAlignment
/*!
- \qmlproperty bool TextArea::inputMethodComposing
+ \qmlproperty enumeration TextArea::effectiveHorizontalAlignment
+ Gets the effective horizontal alignment of the text within the TextArea item's width.
- This property holds whether the TextEdit has partial text input from an
- input method.
+ To set/get the default horizontal alignment of TextArea, use the property \c horizontalAlignment.
- While it is composing an input method may rely on mouse or key events from
- the TextEdit to edit or commit the partial text. This property can be used
- to determine when to disable events handlers that may interfere with the
- correct operation of an input method.
*/
- property alias inputMethodComposing: edit.inputMethodComposing
+ readonly property alias effectiveHorizontalAlignment: edit.effectiveHorizontalAlignment
+
+ /*!
+ \qmlproperty enumeration TextArea::verticalAlignment
+
+ Sets the alignment of the text within the TextArea item's height.
+
+ The valid values for \c verticalAlignment are:
+ \list
+ \li TextEdit.AlignTop
+ \li TextEdit.AlignBottom
+ \li TextEdit.AlignVCenter (Default)
+ \endlist
+ */
+ property alias verticalAlignment: edit.verticalAlignment
/*!
\qmlproperty enumeration TextArea::inputMethodHints
@@ -242,6 +188,8 @@ ScrollArea {
The value is a bit-wise combination of flags or Qt.ImhNone if no hints are set.
+ The default value is \c Qt.ImhNone.
+
Flags that alter behavior are:
\list
@@ -282,113 +230,44 @@ ScrollArea {
/*!
\qmlproperty int TextArea::length
- Returns the total number of plain text characters in the TextEdit item.
+ Returns the total number of plain text characters in the TextArea item.
As this number doesn't include any formatting markup it may not be the same as the
length of the string returned by the \l text property.
This property can be faster than querying the length the \l text property as it doesn't
- require any copying or conversion of the TextEdit's internal string data.
+ require any copying or conversion of the TextArea's internal string data.
*/
- property alias length: edit.length
+ readonly property alias length: edit.length
/*!
\qmlproperty int TextArea::lineCount
- Returns the total number of lines in the textEdit item.
- */
- property alias lineCount: edit.lineCount
-
- /*!
- \qmlproperty enumeration TextArea::mouseSelectionMode
-
- Specifies how text should be selected using a mouse.
-
- \list
- \li TextEdit.SelectCharacters - The selection is updated with individual characters. (Default)
- \li TextEdit.SelectWords - The selection is updated with whole words.
- \endlist
-
- This property only applies when \l selectByMouse is true.
- */
- property alias mouseSelectionMode: edit.mouseSelectionMode
-
- /*!
- \qmlproperty bool TextArea::persistentSelection
-
- Whether the TextEdit should keep the selection visible when it loses active focus to another
- item in the scene. By default this is set to true;
+ Returns the total number of lines in the TextArea item.
*/
- property alias persistentSelection: edit.persistentSelection
+ readonly property alias lineCount: edit.lineCount
/*!
\qmlproperty bool TextArea::readOnly
- Whether the user can interact with the TextEdit item. If this
- property is set to true the text cannot be edited by user interaction.
-
- By default this property is false.
- */
- property alias readOnly: edit.readOnly
-
- /*!
- \qmlproperty enumeration TextArea::renderType
-
- Override the default rendering type for this component.
+ Whether the user can interact with the TextArea item.
- Supported render types are:
- \list
- \li Text.QtRendering - the default
- \li Text.NativeRendering
- \endlist
+ The difference from a disabled text field is that it will appear
+ to be active and text can be selected and copied.
- Select Text.NativeRendering if you prefer text to look native on the target platform and do
- not require advanced features such as transformation of the text. Using such features in
- combination with the NativeRendering render type will lend poor and sometimes pixelated
- results.
- */
- property alias renderType: edit.renderType
+ If this property is set to true the text cannot be edited by user interaction.
- /*!
- \qmlproperty bool TextArea::selectByMouse
-
- Defaults to false.
-
- If true, the user can use the mouse to select text in some
- platform-specific way. Note that for some platforms this may
- not be an appropriate interaction (eg. may conflict with how
- the text needs to behave inside a Flickable.
+ By default this property is \c false.
*/
- property alias selectByMouse: edit.selectByMouse
+ property alias readOnly: edit.readOnly
/*!
\qmlproperty string TextArea::selectedText
This read-only property provides the text currently selected in the
text edit.
-
- It is equivalent to the following snippet, but is faster and easier
- to use.
- \code
- //myTextEdit is the id of the TextEdit
- myTextEdit.text.toString().substring(myTextEdit.selectionStart, myTextEdit.selectionEnd);
- \endcode
- */
- property alias selectedText: edit.selectedText
-
- /*!
- \qmlproperty color TextArea::selectedTextColor
-
- The selected text color, used in selections.
- */
- property alias selectedTextColor: edit.selectedTextColor
-
- /*!
- \qmlproperty color TextArea::selectionColor
-
- The text highlight color, used behind selections.
*/
- property alias selectionColor: edit.selectionColor
+ readonly property alias selectedText: edit.selectedText
/*!
\qmlproperty int TextArea::selectionEnd
@@ -400,7 +279,7 @@ ScrollArea {
\sa selectionStart, cursorPosition, selectedText
*/
- property alias selectionEnd: edit.selectionEnd
+ readonly property alias selectionEnd: edit.selectionEnd
/*!
\qmlproperty int TextArea::selectionStart
@@ -412,23 +291,23 @@ ScrollArea {
\sa selectionEnd, cursorPosition, selectedText
*/
- property alias selectionStart: edit.selectionStart
+ readonly property alias selectionStart: edit.selectionStart
/*!
\qmlproperty bool TextArea::tabChangesFocus
This property holds whether Tab changes focus or is accepted as input.
- Defaults to false.
+ Defaults to \c false.
*/
property bool tabChangesFocus: false
/*!
\qmlproperty string TextArea::text
- The text to display. If the text format is AutoText the text edit will
+ The text to display. If the text format is AutoText the text edit will
automatically determine whether the text should be treated as
- rich text. This determination is made using Qt::mightBeRichText().
+ rich text. This determination is made using Qt::mightBeRichText().
*/
property alias text: edit.text
@@ -445,21 +324,14 @@ ScrollArea {
The default is TextEdit.PlainText. If the text format is TextEdit.AutoText the text edit
will automatically determine whether the text should be treated as
- rich text. This determination is made using Qt::mightBeRichText().
+ rich text. This determination is made using Qt::mightBeRichText().
*/
property alias textFormat: edit.textFormat
/*!
- \qmlproperty real TextArea::textMargin
-
- The margin, in pixels, around the text in the TextEdit.
- */
- property alias textMargin: edit.textMargin
-
- /*!
\qmlproperty enumeration TextArea::wrapMode
- Set this property to wrap the text to the TextEdit item's width.
+ Set this property to wrap the text to the TextArea item's width.
The text will only wrap if an explicit width has been set.
\list
@@ -469,11 +341,38 @@ ScrollArea {
\li TextEdit.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
\endlist
- The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap.
+ The default is \c TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap.
*/
property alias wrapMode: edit.wrapMode
/*!
+ \qmlproperty bool TextArea::selectByMouse
+
+ This property determines if the user can select the text with the
+ mouse.
+
+ The default value is \c true.
+ */
+ property alias selectByMouse: edit.selectByMouse
+
+ /*!
+ \qmlproperty bool TextArea::selectByKeyboard
+
+ This property determines if the user can select the text with the
+ keyboard.
+
+ If set to \c true, the user can use the keyboard to select the text
+ even if the editor is read-only. If set to \c false, the user cannot
+ use the keyboard to select the text even if the editor is editable.
+
+ The default value is \c true when the editor is editable,
+ and \c false when read-only.
+
+ \sa readOnly
+ */
+ property alias selectByKeyboard: edit.selectByKeyboard
+
+ /*!
\qmlsignal TextArea::linkActivated(string link)
This signal is emitted when the user clicks on a link embedded in the text.
@@ -488,7 +387,9 @@ ScrollArea {
Appends \a string as a new line to the end of the text area.
*/
function append (string) {
- text += "\n" + string
+ if (length)
+ string = "\n" + string
+ text += string
verticalScrollBar.value = verticalScrollBar.maximumValue
}
@@ -697,72 +598,122 @@ ScrollArea {
edit.undo();
}
- color: syspal.base
+ /*!
+ \qmlproperty color TextArea::backgroundColor
+
+ This property sets the background color of the viewport.
+
+ The default value is the base color of the SystemPalette.
+ */
+ property alias backgroundColor: colorRect.color
+
+ /*! \internal */
+ property int documentMargins: 4
+
width: 280
height: 120
- contentWidth: edit.paintedWidth + (2 * documentMargins)
- highlightOnFocus: true
- frame: true
+
+ flickableItem.contentWidth: edit.paintedWidth + (2 * documentMargins)
+ frameVisible: true
+
+ activeFocusOnTab: true
Accessible.role: Accessible.EditableText
- // FIXME: probably implement text interface
- Accessible.name: text
+
+ /*!
+ \qmlproperty textDocument TextArea::textDocument
+
+ This property exposes the \l QTextDocument of this TextArea.
+ \sa TextEdit::textDocument
+ */
+ property alias textDocument: edit.textDocument
TextEdit {
- MouseArea {
+ id: edit
+ focus: true
+
+ SystemPalette {
+ id: palette
+ colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
+
+ Rectangle {
+ id: colorRect
+ parent: viewport
anchors.fill: parent
- cursorShape: Qt.IBeamCursor
- acceptedButtons: Qt.NoButton
+ color: palette.base
+ z: -1
+ }
+
+ property bool recursionGuard: false
+
+ function doLayout() {
+ if (!recursionGuard) {
+ recursionGuard = true
+ if (wrapMode == TextEdit.NoWrap) {
+ horizontalScrollBar.visible = edit.paintedWidth + (2 * documentMargins) > area.viewport.width
+ edit.width = edit.paintedWidth + (2 * documentMargins)
+ } else {
+ horizontalScrollBar.visible = false
+ edit.width = area.viewport.width - (2 * documentMargins)
+ }
+ edit.height = Math.max(area.viewport.height - (2 * documentMargins), paintedHeight + (2 * documentMargins))
+ recursionGuard = false
+ }
}
+
+ Connections {
+ target: area.viewport
+ onWidthChanged: edit.doLayout()
+ onHeightChanged: edit.doLayout()
+ }
+ onPaintedWidthChanged: edit.doLayout()
+ onPaintedHeightChanged: edit.doLayout()
+ onWrapModeChanged: edit.doLayout()
+
renderType: Text.NativeRendering
- id: edit
- selectionColor: syspal.highlight
- selectedTextColor: syspal.highlightedText
- wrapMode: TextEdit.WordWrap;
- width: area.viewportWidth - (2 * documentMargins)
+ color: palette.text
+ selectionColor: palette.highlight
+ selectedTextColor: palette.highlightedText
+ wrapMode: TextEdit.WordWrap
x: documentMargins
y: documentMargins
- // height has to be big enough to handle mouse focus
- height: Math.max(area.height, paintedHeight)
selectByMouse: true
readOnly: false
- color: syspal.text
-
- SystemPalette {
- id: syspal
- colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
- }
KeyNavigation.priority: KeyNavigation.BeforeItem
KeyNavigation.tab: area.tabChangesFocus ? area.KeyNavigation.tab : null
KeyNavigation.backtab: area.tabChangesFocus ? area.KeyNavigation.backtab : null
- onContentSizeChanged: {
- area.contentWidth = paintedWidth + (2 * documentMargins)
- }
-
- // keep textcursor within scrollarea
+ // keep textcursor within scroll view
onCursorPositionChanged: {
- if (cursorRectangle.y >= area.contentY + area.viewportHeight - 1.5*cursorRectangle.height - documentMargins)
- area.contentY = cursorRectangle.y - area.viewportHeight + 1.5*cursorRectangle.height + documentMargins
- else if (cursorRectangle.y < area.contentY)
- area.contentY = cursorRectangle.y
-
- if (cursorRectangle.x >= area.contentX + area.viewportWidth - documentMargins) {
- area.contentX = cursorRectangle.x - area.viewportWidth + documentMargins
- } else if (cursorRectangle.x < area.contentX)
- area.contentX = cursorRectangle.x
+ if (cursorRectangle.y >= flickableItem.contentY + viewport.height - 1.5*cursorRectangle.height - documentMargins)
+ flickableItem.contentY = cursorRectangle.y - viewport.height + 1.5*cursorRectangle.height + documentMargins
+ else if (cursorRectangle.y < flickableItem.contentY)
+ flickableItem.contentY = cursorRectangle.y
+
+ if (cursorRectangle.x >= flickableItem.contentX + viewport.width - documentMargins) {
+ flickableItem.contentX = cursorRectangle.x - viewport.width + documentMargins
+ } else if (cursorRectangle.x < flickableItem.contentX)
+ flickableItem.contentX = cursorRectangle.x
}
-
onLinkActivated: area.linkActivated(link)
+
+ MouseArea {
+ parent: area.viewport
+ anchors.fill: parent
+ cursorShape: Qt.IBeamCursor
+ acceptedButtons: Qt.NoButton
+ }
}
Keys.onPressed: {
if (event.key == Qt.Key_PageUp) {
- verticalValue = verticalValue - area.height
+ verticalScrollBar.value -= area.height
} else if (event.key == Qt.Key_PageDown)
- verticalValue = verticalValue + area.height
+ verticalScrollBar.value += area.height
}
+
}
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
new file mode 100644
index 00000000..3163adda
--- /dev/null
+++ b/src/controls/TextField.qml
@@ -0,0 +1,591 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import "Styles"
+import "Styles/Settings.js" as Settings
+
+/*!
+ \qmltype TextField
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief Displays a single line of editable plain text.
+
+ TextField is used to accept a line of text input. Input constraints can be
+ placed on a TextField item (for example, through a \l validator or \l
+ inputMask). Setting \l echoMode to an appropriate value enables
+ TextField to be used for a password input field.
+
+ \sa TextArea, TextInput
+*/
+
+Control {
+ id: textfield
+
+ /*!
+ \qmlproperty bool TextField::acceptableInput
+
+ Returns \c true if the text field contains acceptable
+ text.
+
+ If a validator or input mask was set, this property will return \c
+ true if the current text satisfies the validator or mask as
+ a final string (not as an intermediate string).
+
+ The default value is \c true.
+
+ \sa validator, inputMask, accepted
+
+ */
+ readonly property alias acceptableInput: textInput.acceptableInput // read only
+
+ /*!
+ \qmlproperty bool TextField::activeFocusOnPress
+
+ This property is set to \c true if the TextField should gain active
+ focus on a mouse press.
+
+ The default value is \c true.
+ */
+ property alias activeFocusOnPress: textInput.activeFocusOnPress
+
+ /*!
+ \qmlproperty bool TextField::canPaste
+
+ Returns \c true if the TextField is writable and the content of the
+ clipboard is suitable for pasting into the TextField.
+ */
+ readonly property alias canPaste: textInput.canPaste
+
+ /*!
+ \qmlproperty bool TextField::canRedo
+
+ Returns \c true if the TextField is writable and there are \l
+ {undo}{undone} operations that can be redone.
+ */
+ readonly property alias canRedo: textInput.canRedo
+
+ /*!
+ \qmlproperty bool TextField::canUndo
+
+ Returns \c true if the TextField is writable and there are previous
+ operations that can be undone.
+ */
+ readonly property alias canUndo: textInput.canUndo
+
+ /*!
+ \qmlproperty color TextField::textColor
+
+ This property holds the text color.
+ */
+ property alias textColor: textInput.color
+
+ /*!
+ \qmlproperty int TextField::cursorPosition
+
+ This property holds the position of the cursor in the TextField.
+ */
+ property alias cursorPosition: textInput.cursorPosition
+
+ /*!
+ \qmlproperty string TextField::displayText
+
+ This property holds the text displayed in the TextField.
+
+ If \l echoMode is set to TextInput::Normal, this holds the
+ same value as the TextField::text property. Otherwise,
+ this property holds the text visible to the user, while
+ the \l text property holds the actual entered text.
+ */
+ readonly property alias displayText: textInput.displayText
+
+ /*!
+ \qmlproperty enumeration TextField::echoMode
+
+ Specifies how the text should be displayed in the
+ TextField.
+
+ The possible modes are:
+ \list
+ \li TextInput.Normal - Displays the text as it is. (Default)
+ \li TextInput.Password - Displays asterisks instead of characters.
+ \li TextInput.NoEcho - Displays nothing.
+ \li TextInput.PasswordEchoOnEdit - Displays characters as they are
+ entered while editing, otherwise displays asterisks.
+ \endlist
+ */
+ property alias echoMode: textInput.echoMode
+
+ /*!
+ \qmlproperty font TextField::font
+
+ Sets the font of the TextField.
+ */
+ property alias font: textInput.font
+
+ /*!
+ \qmlproperty enumeration TextField::horizontalAlignment
+
+ Sets the alignment of the text within the TextField item's width.
+
+ By default, the horizontal text alignment follows the natural alignment
+ of the text, for example text that is read from left to right will be
+ aligned to the left.
+
+ The possible alignment values are:
+ \list
+ \li TextInput.AlignLeft
+ \li TextInput.AlignRight
+ \li TextInput.AlignHCenter
+ \endlist
+
+ When using the attached property, LayoutMirroring::enabled, to mirror
+ application layouts, the horizontal alignment of text will also be
+ mirrored. However, the property \c horizontalAlignment will remain
+ unchanged. To query the effective horizontal alignment of TextField, use
+ the read-only property \c effectiveHorizontalAlignment.
+ */
+ property alias horizontalAlignment: textInput.horizontalAlignment
+
+ /*!
+ \qmlproperty enumeration TextField::effectiveHorizontalAlignment
+
+ Gets the effective horizontal alignment of the text within the TextField
+ item's width.
+
+ \l horizontalAlignment contains the default horizontal alignment.
+
+ \sa horizontalAlignment
+
+ */
+ readonly property alias effectiveHorizontalAlignment: textInput.effectiveHorizontalAlignment
+
+ /*!
+ \qmlproperty enumeration TextField::verticalAlignment
+
+ Sets the alignment of the text within the TextField item's height.
+
+ The possible alignment values are
+ \list
+ \li TextInput.AlignTop
+ \li TextInput.AlignBottom
+ \li TextInput.AlignVCenter (default).
+ \endlist
+ */
+ property alias verticalAlignment: textInput.verticalAlignment
+
+ /*!
+ \qmlproperty string TextField::inputMask
+
+ Sets an input mask on the TextField, restricting the allowable text
+ inputs. See QLineEdit::inputMask for further details, as the exact same
+ mask strings are used by TextField.
+
+ \sa acceptableInput, validator
+ */
+ property alias inputMask: textInput.inputMask
+
+ /*!
+ \qmlproperty enumeration TextField::inputMethodHints
+
+ Provides hints to the input method about the expected content of the
+ text field and how it should operate.
+
+ The value is a bit-wise combination of flags, or \c Qt.ImhNone if no
+ hints are set.
+
+ The default value is \c Qt.ImhNone.
+
+ Flags that alter behavior are:
+
+ \list
+ \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.
+ This is automatically set when setting echoMode to \c TextInput.Password.
+ \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method
+ in any persistent storage like predictive user dictionary.
+ \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case
+ when a sentence ends.
+ \li Qt.ImhPreferNumbers - Numbers are preferred (but not required).
+ \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).
+ \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).
+ \li Qt.ImhNoPredictiveText - Do not use predictive text (for example, dictionary lookup) while typing.
+
+ \li Qt.ImhDate - The text editor functions as a date field.
+ \li Qt.ImhTime - The text editor functions as a time field.
+ \endlist
+
+ Flags that restrict input (exclusive flags) are:
+
+ \list
+ \li Qt.ImhDigitsOnly - Only digits are allowed.
+ \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.
+ \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed.
+ \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed.
+ \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.
+ \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.
+ \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.
+ \endlist
+
+ Masks:
+ \list
+ \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.
+ \endlist
+ */
+ property alias inputMethodHints: textInput.inputMethodHints
+
+ /*!
+ \qmlproperty int TextField::length
+
+ Returns the total number of characters in the TextField item.
+
+ If the TextField has an input mask, the length will include mask
+ characters and may differ from the length of the string returned by the
+ \l text property.
+
+ This property can be faster than querying the length the \l text
+ property as it doesn't require any copying or conversion of the
+ TextField's internal string data.
+ */
+ readonly property alias length: textInput.length
+
+ /*!
+ \qmlproperty int TextField::maximumLength
+
+ This property holds the maximum permitted length of the text in the
+ TextField.
+
+ If the text is too long, it is truncated at the limit.
+ */
+ property alias maximumLength: textInput.maximumLength
+
+ /*!
+ \qmlproperty string TextField::placeholderText
+
+ This property contains the text that is shown in the text field when the
+ text field is empty and has no focus.
+ */
+ property alias placeholderText: placeholderTextComponent.text
+
+ /*!
+ \qmlproperty bool TextField::readOnly
+
+ Sets whether user input can modify the contents of the TextField. Read-
+ only is different from a disabled text field in that the text field will
+ appear to be active and text can still be selected and copied.
+
+ If readOnly is set to \c true, then user input will not affect the text.
+ Any bindings or attempts to set the text property will still
+ work, however.
+ */
+ property alias readOnly: textInput.readOnly
+
+ /*!
+ \qmlproperty string TextField::selectedText
+
+ Provides the text currently selected in the text input.
+
+ It is equivalent to the following snippet, but is faster and easier
+ to use.
+
+ \code
+ myTextField.text.toString().substring(myTextField.selectionStart, myTextField.selectionEnd);
+ \endcode
+ */
+ readonly property alias selectedText: textInput.selectedText
+
+ /*!
+ \qmlproperty int TextField::selectionEnd
+
+ The cursor position after the last character in the current selection.
+
+ This property is read-only. To change the selection, use
+ select(start,end), selectAll(), or selectWord().
+
+ \sa selectionStart, cursorPosition, selectedText
+ */
+ readonly property alias selectionEnd: textInput.selectionEnd
+
+ /*!
+ \qmlproperty int TextField::selectionStart
+
+ The cursor position before the first character in the current selection.
+
+ This property is read-only. To change the selection, use select(start,end),
+ selectAll(), or selectWord().
+
+ \sa selectionEnd, cursorPosition, selectedText
+ */
+ readonly property alias selectionStart: textInput.selectionStart
+
+ /*!
+ \qmlproperty string TextField::text
+
+ This property contains the text in the TextField.
+ */
+ property alias text: textInput.text
+
+ /*!
+ \qmlproperty Validator TextField::validator
+
+ Allows you to set a validator on the TextField. When a validator is set
+ the TextField will only accept input which leaves the text property in
+ an intermediate state. The accepted signal will only be sent
+ if the text is in an acceptable state when enter is pressed.
+
+ Currently supported validators are \l{QtQuick2::IntValidator},
+ \l{QtQuick2::DoubleValidator}, and \l{QtQuick2::RegExpValidator}. An
+ example of using validators is shown below, which allows input of
+ integers between 11 and 31 into the text input:
+
+ \code
+ import QtQuick 2.1
+ import QtQuick.Controls 1.0
+
+ TextField {
+ validator: IntValidator {bottom: 11; top: 31;}
+ focus: true
+ }
+ \endcode
+
+ \sa acceptableInput, inputMask, accepted
+ */
+ property alias validator: textInput.validator
+
+ /*!
+ \qmlsignal TextField::accepted()
+
+ This signal is emitted when the Return or Enter key is pressed.
+ Note that if there is a \l validator or \l inputMask set on the text
+ field, the signal will only be emitted if the input is in an acceptable
+ state.
+ */
+ signal accepted()
+
+ /*!
+ \qmlmethod TextField::copy()
+
+ Copies the currently selected text to the system clipboard.
+ */
+ function copy() {
+ textInput.copy()
+ }
+
+ /*!
+ \qmlmethod TextField::cut()
+
+ Moves the currently selected text to the system clipboard.
+ */
+ function cut() {
+ textInput.cut()
+ }
+
+ /*!
+ \qmlmethod TextField::deselect()
+
+ Removes active text selection.
+ */
+ function deselect() {
+ textInput.deselect();
+ }
+
+ /*!
+ \qmlmethod string TextField::getText(int start, int end)
+
+ Removes the section of text that is between the \a start and \a end
+ positions from the TextField.
+ */
+ function getText(start, end) {
+ return textInput.getText(start, end);
+ }
+
+ /*!
+ \qmlmethod TextField::insert(int position, string text)
+
+ Inserts \a text into the TextField at \a position.
+ */
+ function insert(position, text) {
+ textInput.insert(position, text);
+ }
+
+ /*!
+ \qmlmethod bool TextField::isRightToLeft(int start, int end)
+
+ Returns \c true if the natural reading direction of the editor text
+ found between positions \a start and \a end is right to left.
+ */
+ function isRightToLeft(start, end) {
+ return textInput.isRightToLeft(start, end);
+ }
+
+ /*!
+ \qmlmethod TextField::paste()
+
+ Replaces the currently selected text by the contents of the system
+ clipboard.
+ */
+ function paste() {
+ textInput.paste()
+ }
+
+ /*!
+ \qmlmethod TextField::redo()
+
+ Performs the last operation if redo is \l {canRedo}{available}.
+ */
+ function redo() {
+ textInput.redo();
+ }
+
+ /*!
+ \qmlmethod TextField::select(int start, int end)
+
+ Causes the text from \a start to \a end to be selected.
+
+ If either start or end is out of range, the selection is not changed.
+
+ After calling select, selectionStart will become the lesser
+ and selectionEnd will become the greater (regardless of the order passed
+ to this method).
+
+ \sa selectionStart, selectionEnd
+ */
+ function select(start, end) {
+ textInput.select(start, end)
+ }
+
+ /*!
+ \qmlmethod TextField::selectAll()
+
+ Causes all text to be selected.
+ */
+ function selectAll() {
+ textInput.selectAll()
+ }
+
+ /*!
+ \qmlmethod TextField::selectWord()
+
+ Causes the word closest to the current cursor position to be selected.
+ */
+ function selectWord() {
+ textInput.selectWord()
+ }
+
+ /*!
+ \qmlmethod TextField::undo()
+
+ Reverts the last operation if undo is \l {canUndo}{available}. undo()
+ deselects any current selection and updates the selection start to the
+ current cursor position.
+ */
+ function undo() {
+ textInput.undo();
+ }
+
+ /*! \internal */
+ property alias __containsMouse: mouseArea.containsMouse
+
+ /*! \internal */
+ property alias __contentHeight: textInput.contentHeight
+
+ /*! \internal */
+ property alias __contentWidth: textInput.contentWidth
+
+ /*! \internal */
+ style: Qt.createComponent(Settings.THEME_PATH + "/TextFieldStyle.qml", textInput)
+
+ /*! \internal */
+ onFocusChanged: {
+ if (textfield.activeFocus)
+ textInput.forceActiveFocus();
+ }
+
+ activeFocusOnTab: true
+
+ Accessible.name: text
+ Accessible.role: Accessible.EditableText
+ Accessible.description: placeholderText
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: Qt.IBeamCursor
+ onClicked: textfield.forceActiveFocus()
+ }
+
+ TextInput {
+ id: textInput
+ selectByMouse: true
+ selectionColor: __panel ? __panel.selectionColor : "darkred"
+ selectedTextColor: __panel ? __panel.selectedTextColor : "white"
+
+ font: __panel ? __panel.font : font
+ anchors.leftMargin: __panel ? __panel.leftMargin : 0
+ anchors.topMargin: __panel ? __panel.topMargin : 0
+ anchors.rightMargin: __panel ? __panel.rightMargin : 0
+ anchors.bottomMargin: __panel ? __panel.bottomMargin : 0
+
+ anchors.fill: parent
+ verticalAlignment: Text.AlignVCenter
+
+ color: __panel ? __panel.foregroundColor : "darkgray"
+ clip: true
+ renderType: Text.NativeRendering
+
+ onAccepted: textfield.accepted()
+ }
+
+ Text {
+ id: placeholderTextComponent
+ anchors.fill: textInput
+ font: textInput.font
+ horizontalAlignment: textInput.horizontalAlignment
+ verticalAlignment: textInput.verticalAlignment
+ opacity: !textInput.text.length && !textInput.activeFocus ? 1 : 0
+ color: __panel ? __panel.placeholderTextColor : "darkgray"
+ clip: true
+ elide: Text.ElideRight
+ renderType: Text.NativeRendering
+ Behavior on opacity { NumberAnimation { duration: 90 } }
+ }
+}
diff --git a/src/qtdesktop/ToolBar.qml b/src/controls/ToolBar.qml
index d27a20f2..5463eb3c 100644
--- a/src/qtdesktop/ToolBar.qml
+++ b/src/controls/ToolBar.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,20 +38,44 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype ToolBar
- \inqmlmodule QtDesktop 1.0
- \brief ToolBar is doing bla...bla...
-*/
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup applicationwindow
+ \brief Contains ToolButton and related controls.
+
+ The common way of using ToolBar is in relation to \l ApplicationWindow. It
+ provides styling and is generally designed to work well with ToolButton as
+ well as other controls.
-StyleItem {
- id: toolbar
- width: parent ? parent.width : 200
- height: implicitHeight
- elementType: "toolbar"
+ Note that the ToolBar does not provide a layout of its own, but requires you
+ to position its contents, for instance by creating a Row.
+
+ \code
+ ApplicationWindow {
+ toolBar: ToolBar {
+ Row {
+ ToolButton { ... }
+ ToolButton { ... }
+ ToolButton { ... }
+ }
+ }
+ }
+ \endcode
+*/
+Item {
+ implicitHeight: Math.max(childrenRect.height, toolbar.implicitHeight)
+ implicitWidth: parent ? parent.width : toolbar.implicitWidth
+ activeFocusOnTab: false
Accessible.role: Accessible.ToolBar
+ StyleItem {
+ id: toolbar
+ anchors.fill: parent
+ elementType: "toolbar"
+ }
}
diff --git a/src/qtdesktop/ToolButton.qml b/src/controls/ToolButton.qml
index e2c73496..445ab96b 100644
--- a/src/qtdesktop/ToolButton.qml
+++ b/src/controls/ToolButton.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,43 +38,45 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import "private" as Private
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
import "Styles/Settings.js" as Settings
/*!
\qmltype ToolButton
- \inqmlmodule QtDesktop 1.0
- \brief ToolButton is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup applicationwindow
+ \brief Provides a button type that is typically used within a ToolBar.
+
+ ToolButton is functionally similar to \l Button, but can provide a look that is more
+ suitable within a \l ToolBar.
+
+ \code
+ ToolButton {
+ iconSource: "edit-cut.png"
+ }
+ \endcode
*/
-Private.BasicButton {
+BasicButton {
id: button
- property string iconName
+ /*! The image label source as file name or resource. */
property url iconSource
+
+ /*! The image label source as theme name.
+ When an icon from the platform icon theme is found, this takes
+ precedence over iconSource.
+ */
+ property url iconName
+
+ /*! The label text. */
property string text
- style: Qt.createComponent(Settings.THEME_PATH + "/ToolButtonStyle.qml", button)
+ activeFocusOnTab: true
- Image {
- id: themeIcon
- anchors.centerIn: parent
- opacity: enabled ? 1 : 0.5
- antialiasing: true
- sourceSize.width: iconSize
- //property string iconPath: "image://desktoptheme/" + button.iconName
- property int iconSize: 24 //(backgroundItem && backgroundItem.style === "mac" && button.styleHint.indexOf("segmented") !== -1) ? 16 : 24
- //source: iconPath // backgroundItem && backgroundItem.hasThemeIcon(iconName) ? iconPath : ""
- fillMode: Image.PreserveAspectFit
- Image {
- // Use fallback icon
- anchors.centerIn: parent
- sourceSize: parent.sourceSize
- visible: (themeIcon.status != Image.Ready)
- source: visible ? button.iconSource : ""
- }
- }
Accessible.name: text
+
+ style: Qt.createComponent(Settings.THEME_PATH + "/ToolButtonStyle.qml", button)
}
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
new file mode 100644
index 00000000..51716652
--- /dev/null
+++ b/src/controls/controls.pro
@@ -0,0 +1,39 @@
+TARGET = plugin
+TARGETPATH = QtQuick/Controls
+
+QT += qml quick widgets gui-private core-private
+
+QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf
+
+QML_FILES = \
+ ApplicationWindow.qml \
+ Button.qml \
+ CheckBox.qml \
+ ComboBox.qml \
+ GroupBox.qml \
+ Label.qml \
+ MenuBar.qml \
+ Menu.qml \
+ PageAnimation.qml \
+ PageStack.qml \
+ PageTransition.qml \
+ ProgressBar.qml \
+ RadioButton.qml \
+ ScrollView.qml \
+ Slider.qml \
+ SpinBox.qml \
+ SplitView.qml \
+ StatusBar.qml \
+ Tab.qml \
+ TabView.qml \
+ TableView.qml \
+ TableViewColumn.qml \
+ TextArea.qml \
+ TextField.qml \
+ ToolBar.qml \
+ ToolButton.qml
+
+include(plugin.pri)
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/controls/doc/images/placeholder.png b/src/controls/doc/images/placeholder.png
new file mode 100644
index 00000000..c64ff5bd
--- /dev/null
+++ b/src/controls/doc/images/placeholder.png
Binary files differ
diff --git a/src/controls/doc/images/tableview.png b/src/controls/doc/images/tableview.png
new file mode 100644
index 00000000..e7e5e27d
--- /dev/null
+++ b/src/controls/doc/images/tableview.png
Binary files differ
diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf
new file mode 100644
index 00000000..6716c038
--- /dev/null
+++ b/src/controls/doc/qtquickcontrols.qdocconf
@@ -0,0 +1,84 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+
+# Name of the project.
+project = QtQuickControls
+description = Qt Quick Controls Documentation
+
+depends = qtqml qtquick qtwidgets qtdoc
+
+# Directories in which to search for files to document and images.
+# By default set to the root directory of the project for sources
+# and headers and qdoc will therefore generate output for each file.
+# Images should be placed in <rootdir>/dic/images and examples in
+# <rootdir>/examples.
+# Paths are relative to the location of this file.
+
+exampledirs += ../../../examples/
+
+headerdirs += ../
+
+sourcedirs += ../
+
+sources += ../../private/qstyleitem.cpp \
+ ../../private/AbstractCheckable.qml \
+ ../../private/BasicButton.qml \
+ ../../private/FocusFrame.qml \
+ ../../private/ModalPopupBehavior.qml \
+ ../../private/PageSlideTransition.qml \
+ ../../private/ScrollBar.qml \
+ ../../private/TabBar.qml \
+ ../../private/Control.qml \
+ ../../styles/Style.qml \
+ ../../styles/ButtonStyle.qml \
+ ../../styles/CheckBoxStyle.qml \
+ ../../styles/ComboBoxStyle.qml \
+ ../../styles/GroupBoxStyle.qml \
+ ../../styles/MenuBarStyle.qml \
+ ../../styles/ProgressBarStyle.qml \
+ ../../styles/RadioButtonStyle.qml \
+ ../../styles/ScrollBarStyle.qml \
+ ../../styles/SliderStyle.qml \
+ ../../styles/SpinBoxStyle.qml \
+ ../../styles/TabViewStyle.qml \
+ ../../styles/TextFieldStyle.qml \
+ ../../styles/ToolBarStyle.qml \
+ ../../styles/ToolButtonStyle.qml
+
+imagedirs += images
+
+# The following parameters are for creating a qhp file, the qhelpgenerator
+# program can convert the qhp file into a qch file which can be opened in
+# Qt Assistant and/or Qt Creator.
+
+# Defines the name of the project. You cannot use operators (+, =, -) in
+# the name. Properties for this project are set using a qhp.<projectname>.property
+# format.
+qhp.projects = qtquickcontrols
+
+# Sets the name of the output qhp file.
+qhp.qtquickcontrols.file = qtquickcontrols.qhp
+
+# Namespace for the output file. This namespace is used to distinguish between
+# different documentation files in Creator/Assistant.
+qhp.qtquickcontrols.namespace = qtquickcontrols.100
+
+# Title for the package, will be the main title for the package in
+# Assistant/Creator.
+qhp.qtquickcontrols.indexTitle = Qt Quick Controls
+
+# Extra files to add to the output which are not linked to from anywhere
+# using a qdoc \l command.
+#qhp.qtquickcontrols.extraFiles = style/qtquickcontrols.css
+
+# Only update the name of the project for the next variables.
+qhp.qtquickcontrols.virtualFolder = qtquickcontrols
+
+qhp.qtquickcontrols.subprojects = qtquickcontrolsqmltypes styleqmltypes
+qhp.qtquickcontrols.subprojects.qtquickcontrolsqmltypes.title = Qt Quick Controls QML Types
+qhp.qtquickcontrols.subprojects.qtquickcontrolsqmltypes.indexTitle = Qt Quick Controls QML Types
+qhp.qtquickcontrols.subprojects.qtquickcontrolsqmltypes.selectors = class fake:headerfile
+qhp.qtquickcontrols.subprojects.qtquickcontrolsqmltypes.sortPages = true
+qhp.qtquickcontrols.subprojects.styleqmltypes.title = Styles QML Types
+qhp.qtquickcontrols.subprojects.styleqmltypes.indexTitle = Qt Quick Controls Styles QML Types
+qhp.qtquickcontrols.subprojects.styleqmltypes.selectors = class fake:headerfile
+qhp.qtquickcontrols.subprojects.styleqmltypes.sortPages = true
diff --git a/src/controls/doc/src/applicationwindow.qdoc b/src/controls/doc/src/applicationwindow.qdoc
new file mode 100644
index 00000000..f9e2d97f
--- /dev/null
+++ b/src/controls/doc/src/applicationwindow.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group applicationwindow
+ \title Application Window
+*/
diff --git a/src/controls/doc/src/containers.qdoc b/src/controls/doc/src/containers.qdoc
new file mode 100644
index 00000000..6a0ab02d
--- /dev/null
+++ b/src/controls/doc/src/containers.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group containers
+ \title Layout and Containers
+*/
diff --git a/src/controls/doc/src/controls.qdoc b/src/controls/doc/src/controls.qdoc
new file mode 100644
index 00000000..d1e4d052
--- /dev/null
+++ b/src/controls/doc/src/controls.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group controls
+ \title Buttons and Controls
+*/
diff --git a/src/controls/doc/src/indicators.qdoc b/src/controls/doc/src/indicators.qdoc
new file mode 100644
index 00000000..f31dec9e
--- /dev/null
+++ b/src/controls/doc/src/indicators.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group indicators
+ \title Status Indicators
+*/
diff --git a/src/controls/doc/src/menus.qdoc b/src/controls/doc/src/menus.qdoc
new file mode 100644
index 00000000..ae8554ea
--- /dev/null
+++ b/src/controls/doc/src/menus.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group menus
+ \title Application Menus
+*/
diff --git a/src/controls/doc/src/navigation.qdoc b/src/controls/doc/src/navigation.qdoc
new file mode 100644
index 00000000..b1bd8ef8
--- /dev/null
+++ b/src/controls/doc/src/navigation.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group navigation
+ \title Application Navigation
+*/
diff --git a/src/qtdesktop/doc/src/qtdesktopcomponents-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc
index cfc2ba90..04fa1f4a 100644
--- a/src/qtdesktop/doc/src/qtdesktopcomponents-examples.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc
@@ -26,8 +26,8 @@
****************************************************************************/
/*!
- \group qtdesktopcomponents_examples
+ \group qtquickcontrols_examples
\ingroup all-examples
- \title Qt Desktop Components Examples
+ \title Qt Quick Controls Examples
\brief Demonstrates the ... functionality provided by Qt.
*/
diff --git a/src/qtdesktop/doc/src/qtdesktopcomponents-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc
index 4d420e6f..25b61c38 100644
--- a/src/qtdesktop/doc/src/qtdesktopcomponents-index.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-index.qdoc
@@ -26,37 +26,45 @@
****************************************************************************/
/*!
- \page qtdesktopcomponents-index.html
- \title Qt Desktop Components
+ \page qtquickcontrols-index.html
+ \title Qt Quick Controls
- \brief The Qt Desktop Components module is an add-on module of Qt.
-
- This is just a demo page.
+ \brief The Qt Quick Controls module is an add-on module of Qt.
\section1 Getting started
- The QML types can be imported into your applciation using the following import statement in your \c {.qml} file.
+ The QML types can be imported into your application using the following import statement in your \c {.qml} file.
\code
- import QtDesktop 1.0
- import QtDesktop.Styles 1.0
+ import QtQuick.Controls 1.0
\endcode
+ \section1 Application Window
+ Components used to describe the basic window properties of an application.
+ \annotatedlist applicationwindow
+
+ \section1 Navigation and Views
+ Views typically let the user manage or present other components in a layout.
+ \annotatedlist views
+
+ \section1 Controls
+ Controls are typically items that are used to present or receive input from the user.
+ \annotatedlist controls
+
\section1 Related information
\section2 Guides
\list
- \li \l{Qt Desktop Components Overview}
+ \li \l{Qt Quick Controls Overview}
\endlist
\section2 Reference
\list
- \li \l{Qt Desktop QML Types}{Qt Desktop QML Types}
- \li \l{Qt Desktop Styles QML Types}{Qt Desktop Styles QML Types}
+ \li \l{Qt Quick Controls QML Types}{Qt Quick Controls QML Types}
\endlist
\section2 Examples
\list
- \li \l{Qt Desktop Components Examples}
+ \li \l{Qt Quick Controls Examples}
\endlist
*/
diff --git a/src/qtdesktop/doc/src/qtdesktopcomponents-overview.qdoc b/src/controls/doc/src/qtquickcontrols-overview.qdoc
index 9350f675..82da0b22 100644
--- a/src/qtdesktop/doc/src/qtdesktopcomponents-overview.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-overview.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \page qtdesktopcomponents-overview.html
- \title Qt Desktop Components Overview
+ \page qtquickcontrols-overview.html
+ \title Qt Quick Controls Overview
\brief A set of APIs for working with ...
*/
diff --git a/src/qtdesktop/doc/src/qtdesktopcomponents.qdoc b/src/controls/doc/src/qtquickcontrols.qdoc
index ac8bbc8b..ddbfc5d6 100644
--- a/src/qtdesktop/doc/src/qtdesktopcomponents.qdoc
+++ b/src/controls/doc/src/qtquickcontrols.qdoc
@@ -26,16 +26,16 @@
****************************************************************************/
/*!
- \qmlmodule QtDesktop 1
- \title Qt Desktop QML Types
+ \qmlmodule QtQuick.Controls 1
+ \title Qt Quick Controls QML Types
\ingroup qmlmodules
- \brief Provides QML types for qt desktop components support.
+ \brief Provides QML types for qt quick controls support.
This is just a demo page.
\section1 Overview
- The QML types for Qt Desktop Components support the basic use cases such as:
+ The QML types for Qt Quick Controls support the basic use cases such as:
\list
\li sth 1,
\li sth 2,
diff --git a/src/qtdesktop/doc/src/styles.qdoc b/src/controls/doc/src/styles.qdoc
index 4dfed970..36dc302f 100644
--- a/src/qtdesktop/doc/src/styles.qdoc
+++ b/src/controls/doc/src/styles.qdoc
@@ -26,16 +26,16 @@
****************************************************************************/
/*!
- \qmlmodule QtDesktop.Styles 1
- \title Qt Desktop Styles QML Types
+ \qmlmodule QtQuick.Controls.Styles 1
+ \title Qt Quick Controls Styles QML Types
\ingroup qmlmodules
- \brief Provides QML types for qt desktop components styles support.
+ \brief Provides QML types for qt quick controls styles support.
This is just a demo page.
\section1 Overview
- The QML types for Qt Desktop Components Styles support the basic use cases such as:
+ The QML types for Qt Quick Controls Styles support the basic use cases such as:
\list
\li sth 1,
\li sth 2,
diff --git a/src/controls/doc/src/views.qdoc b/src/controls/doc/src/views.qdoc
new file mode 100644
index 00000000..cda1e38e
--- /dev/null
+++ b/src/controls/doc/src/views.qdoc
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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$
+**
+****************************************************************************/
+
+/*!
+ \group views
+ \title Application Navigation and Views
+*/
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
new file mode 100644
index 00000000..50c8fe69
--- /dev/null
+++ b/src/controls/plugin.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "plugin_p.h"
+#include "qtaction_p.h"
+#include "qtexclusivegroup_p.h"
+#include "qtmenu_p.h"
+#include "qtmenubar_p.h"
+#include "qtstack_p.h"
+
+#include <qimage.h>
+#include <qqml.h>
+#include <qqmlengine.h>
+#include <qqmlextensionplugin.h>
+#include <qquickimageprovider.h>
+#include <qquickwindow.h>
+
+QT_BEGIN_NAMESPACE
+
+// Load icons from desktop theme
+class DesktopIconProvider : public QQuickImageProvider
+{
+public:
+ DesktopIconProvider()
+ : QQuickImageProvider(QQuickImageProvider::Pixmap)
+ {
+ }
+
+ QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
+ {
+ Q_UNUSED(requestedSize);
+ Q_UNUSED(size);
+ int pos = id.lastIndexOf('/');
+ QString iconName = id.right(id.length() - pos);
+ int width = requestedSize.width();
+ return QIcon::fromTheme(iconName).pixmap(width);
+ }
+};
+
+void StylePlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<QtAction>(uri, 1, 0, "Action");
+ qmlRegisterType<QtExclusiveGroup>(uri, 1, 0, "ExclusiveGroup");
+ qmlRegisterType<QtMenu>(uri, 1, 0, "MenuPrivate");
+ qmlRegisterType<QtMenuBar>(uri, 1, 0, "MenuBarPrivate");
+ qmlRegisterType<QtMenuItem>(uri, 1, 0, "MenuItem");
+ qmlRegisterUncreatableType<QtMenuItemType>(uri, 1, 0, "MenuItemType",
+ QLatin1String("Do not create objects of type MenuItemType"));
+ qmlRegisterType<QtMenuSeparator>(uri, 1, 0, "MenuSeparator");
+ qmlRegisterUncreatableType<QtMenuBase>(uri, 1, 0, "MenuBase",
+ QLatin1String("Do not create objects of type MenuBase"));
+
+ qmlRegisterUncreatableType<QtStack>(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack"));
+}
+
+void StylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ Q_UNUSED(uri);
+ engine->addImageProvider("desktoptheme", new DesktopIconProvider);
+}
+
+QT_END_NAMESPACE
diff --git a/src/qtdesktop/styleplugin.json b/src/controls/plugin.json
index 0967ef42..0967ef42 100644
--- a/src/qtdesktop/styleplugin.json
+++ b/src/controls/plugin.json
diff --git a/src/controls/plugin.pri b/src/controls/plugin.pri
new file mode 100644
index 00000000..82f42ea3
--- /dev/null
+++ b/src/controls/plugin.pri
@@ -0,0 +1,23 @@
+HEADERS += \
+ $$PWD/plugin_p.h \
+ $$PWD/qtaction_p.h \
+ $$PWD/qtexclusivegroup_p.h \
+ $$PWD/qtmenu_p.h \
+ $$PWD/qtmenubar_p.h \
+ $$PWD/qtmenuitem_p.h \
+ $$PWD/qtmenuitemcontainer_p.h \
+ $$PWD/qtmenupopupwindow_p.h \
+ $$PWD/qtstack_p.h
+
+SOURCES += \
+ $$PWD/plugin.cpp \
+ $$PWD/qtaction.cpp \
+ $$PWD/qtexclusivegroup.cpp \
+ $$PWD/qtmenu.cpp \
+ $$PWD/qtmenubar.cpp \
+ $$PWD/qtmenuitem.cpp \
+ $$PWD/qtmenupopupwindow.cpp \
+ $$PWD/qtstack.cpp
+
+OTHER_FILES += \
+ $$PWD/plugin.json
diff --git a/src/controls/plugin_p.h b/src/controls/plugin_p.h
new file mode 100644
index 00000000..53b47d16
--- /dev/null
+++ b/src/controls/plugin_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLEPLUGIN_P_H
+#define QSTYLEPLUGIN_P_H
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class StylePlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtquickcontrols.QQmlExtensionInterface" FILE "plugin.json")
+public:
+ void registerTypes(const char *uri);
+ void initializeEngine(QQmlEngine *engine, const char *uri);
+};
+
+QT_END_NAMESPACE
+
+#endif // QSTYLEPLUGIN_P_H
diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes
new file mode 100644
index 00000000..1cfb3477
--- /dev/null
+++ b/src/controls/plugins.qmltypes
@@ -0,0 +1,163 @@
+import QtQuick.tooling 1.1
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated with the command 'qmlplugindump QtQuick.Controls 1.0'.
+
+Module {
+ Component {
+ name: "QPageStatus"
+ prototype: "QObject"
+ exports: ["PageStatus 1.0"]
+ Enum {
+ name: "PageStatus"
+ values: {
+ "Inactive": 0,
+ "Deactivating": 1,
+ "Activating": 2,
+ "Active": 3
+ }
+ }
+ }
+ Component {
+ name: "QtAction"
+ prototype: "QObject"
+ exports: ["Action 1.0"]
+ Property { name: "text"; type: "string" }
+ Property { name: "iconSource"; type: "QUrl" }
+ Property { name: "iconName"; type: "string" }
+ Property { name: "__icon"; type: "QVariant"; isReadonly: true }
+ Property { name: "tooltip"; type: "string" }
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "checkable"; type: "bool" }
+ Property { name: "checked"; type: "bool" }
+ Property { name: "exclusiveGroup"; type: "QtExclusiveGroup"; isPointer: true }
+ Property { name: "shortcut"; type: "string" }
+ Signal { name: "triggered" }
+ Signal {
+ name: "toggled"
+ Parameter { type: "bool" }
+ }
+ Signal {
+ name: "shortcutChanged"
+ Parameter { name: "shortcut"; type: "string" }
+ }
+ Signal { name: "iconChanged" }
+ Signal {
+ name: "tooltipChanged"
+ Parameter { name: "arg"; type: "string" }
+ }
+ Method { name: "trigger" }
+ }
+ Component {
+ name: "QtExclusiveGroup"
+ prototype: "QObject"
+ exports: ["ExclusiveGroup 1.0"]
+ Property { name: "current"; type: "QObject"; isPointer: true }
+ Method {
+ name: "bindCheckable"
+ Parameter { name: "o"; type: "QObject"; isPointer: true }
+ }
+ Method {
+ name: "unbindCheckable"
+ Parameter { name: "o"; type: "QObject"; isPointer: true }
+ }
+ }
+ Component {
+ name: "QtMenu"
+ defaultProperty: "items"
+ prototype: "QtMenuText"
+ exports: ["MenuPrivate 1.0"]
+ Property { name: "items"; type: "QtMenuBase"; isList: true; isReadonly: true }
+ Property { name: "selectedIndex"; type: "int" }
+ Property { name: "model"; type: "QVariant" }
+ Property { name: "__popupVisible"; type: "bool"; isReadonly: true }
+ Property { name: "__contentItem"; type: "QQuickItem"; isPointer: true }
+ Property { name: "__minimumWidth"; type: "int" }
+ Property { name: "__font"; type: "QFont" }
+ Signal {
+ name: "modelChanged"
+ Parameter { name: "newModel"; type: "QVariant" }
+ }
+ Signal { name: "__menuClosed" }
+ Signal { name: "popupVisibleChanged" }
+ Method { name: "__closeMenu" }
+ Method { name: "__dismissMenu" }
+ Method { name: "popup" }
+ Method {
+ name: "addItem"
+ type: "QtMenuItem*"
+ Parameter { name: "text"; type: "string" }
+ }
+ Method { name: "clear" }
+ Method {
+ name: "__popup"
+ Parameter { name: "x"; type: "double" }
+ Parameter { name: "y"; type: "double" }
+ Parameter { name: "atActionIndex"; type: "int" }
+ }
+ Method {
+ name: "__popup"
+ Parameter { name: "x"; type: "double" }
+ Parameter { name: "y"; type: "double" }
+ }
+ Method {
+ name: "__modelTextAt"
+ type: "string"
+ Parameter { name: "index"; type: "int" }
+ }
+ Method { name: "__modelCount"; type: "int" }
+ Method { name: "__hasNativeModel"; type: "bool" }
+ }
+ Component {
+ name: "QtMenuBar"
+ defaultProperty: "menus"
+ prototype: "QObject"
+ exports: ["MenuBarPrivate 1.0"]
+ Property { name: "menus"; type: "QtMenu"; isList: true; isReadonly: true }
+ Property { name: "__contentItem"; type: "QQuickItem"; isPointer: true }
+ Property { name: "__parentWindow"; type: "QQuickWindow"; isPointer: true }
+ Property { name: "__isNative"; type: "bool"; isReadonly: true }
+ Signal { name: "contentItemChanged" }
+ }
+ Component {
+ name: "QtMenuBase"
+ prototype: "QObject"
+ exports: ["MenuBase 1.0"]
+ Property { name: "visible"; type: "bool" }
+ Property { name: "__parentMenu"; type: "QtMenu"; isReadonly: true; isPointer: true }
+ Property { name: "__isNative"; type: "bool"; isReadonly: true }
+ Property { name: "__visualItem"; type: "QQuickItem"; isPointer: true }
+ }
+ Component {
+ name: "QtMenuItem"
+ prototype: "QtMenuText"
+ exports: ["MenuItem 1.0"]
+ Property { name: "checkable"; type: "bool" }
+ Property { name: "checked"; type: "bool" }
+ Property { name: "exclusiveGroup"; type: "QtExclusiveGroup"; isPointer: true }
+ Property { name: "shortcut"; type: "string" }
+ Property { name: "action"; type: "QtAction"; isPointer: true }
+ Signal { name: "triggered" }
+ Signal {
+ name: "toggled"
+ Parameter { name: "checked"; type: "bool" }
+ }
+ Method { name: "trigger" }
+ }
+ Component {
+ name: "QtMenuSeparator"
+ prototype: "QtMenuBase"
+ exports: ["MenuSeparator 1.0"]
+ }
+ Component {
+ name: "QtMenuText"
+ prototype: "QtMenuBase"
+ Property { name: "text"; type: "string" }
+ Property { name: "enabled"; type: "bool" }
+ Property { name: "iconSource"; type: "QUrl" }
+ Property { name: "iconName"; type: "string" }
+ Property { name: "__icon"; type: "QVariant"; isReadonly: true }
+ }
+}
diff --git a/src/qtdesktop/qmldir b/src/controls/qmldir
index a8ebc6b3..be9fff4f 100644
--- a/src/qtdesktop/qmldir
+++ b/src/controls/qmldir
@@ -1,35 +1,28 @@
-module QtDesktop
-plugin styleplugin
+module QtQuick.Controls
+plugin plugin
ApplicationWindow 1.0 ApplicationWindow.qml
Button 1.0 Button.qml
-ButtonRow 1.0 ButtonRow.qml
-ButtonColumn 1.0 ButtonColumn.qml
CheckBox 1.0 CheckBox.qml
ComboBox 1.0 ComboBox.qml
-ContextMenu 1.0 ContextMenu.qml
-Dial 1.0 Dial.qml
-Dialog 1.0 Dialog.qml
-Frame 1.0 Frame.qml
GroupBox 1.0 GroupBox.qml
Label 1.0 Label.qml
-Page 1.0 Page.qml
+MenuBar 1.0 MenuBar.qml
+Menu 1.0 Menu.qml
PageAnimation 1.0 PageAnimation.qml
PageStack 1.0 PageStack.qml
PageTransition 1.0 PageTransition.qml
ProgressBar 1.0 ProgressBar.qml
RadioButton 1.0 RadioButton.qml
-ScrollArea 1.0 ScrollArea.qml
+ScrollView 1.0 ScrollView.qml
Slider 1.0 Slider.qml
SpinBox 1.0 SpinBox.qml
-SplitterRow 1.0 SplitterRow.qml
-SplitterColumn 1.0 SplitterColumn.qml
+SplitView 1.0 SplitView.qml
StatusBar 1.0 StatusBar.qml
Tab 1.0 Tab.qml
-TabFrame 1.0 TabFrame.qml
+TabView 1.0 TabView.qml
TableView 1.0 TableView.qml
-TableColumn 1.0 TableColumn.qml
+TableViewColumn 1.0 TableViewColumn.qml
TextArea 1.0 TextArea.qml
TextField 1.0 TextField.qml
ToolBar 1.0 ToolBar.qml
ToolButton 1.0 ToolButton.qml
-
diff --git a/src/controls/qtaction.cpp b/src/controls/qtaction.cpp
new file mode 100644
index 00000000..1ed9a99c
--- /dev/null
+++ b/src/controls/qtaction.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtaction_p.h"
+#include "qtexclusivegroup_p.h"
+
+#include <private/qguiapplication_p.h>
+#include <qqmlfile.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Action
+ \instantiates QtAction
+ \inqmlmodule QtQuick.Controls 1.0
+ \brief Action provides an abstract user interface action that can be bound to items
+
+ In applications many common commands can be invoked via menus, toolbar buttons, and keyboard
+ shortcuts. Since the user expects each command to be performed in the same way, regardless of
+ the user interface used, it is useful to represent each command as an \e action.
+
+ An action can be bound to a menu item and a toolbar button, and it will automatically keep them in sync.
+ For example, in a word processor, if the user presses a Bold toolbar button, the Bold menu item will
+ automatically be checked.
+
+ QtQuick Controls supports actions in \l Button, \l ToolButton, and \l MenuItem.
+*/
+
+/*!
+ \qmlproperty string Action::text
+
+ Text for the action. This text will show as the button text, or
+ as title in a menu item.
+
+ Mnemonics are supported by prefixing the shortcut letter with \&.
+ For instance, \c "\&Open" will bind the \c Alt-O shortcut to the
+ \c "Open" menu item. Note that not all platforms support mnemonics.
+
+ Defaults to the empty string.
+*/
+
+/*!
+ \qmlproperty url Action::iconSource
+
+ Sets the icon file or resource url for the action. Defaults to the empty URL.
+*/
+
+/*!
+ \qmlproperty string Action::iconName
+
+ Sets the icon name for the action. This will pick the icon
+ with the given name from the current theme.
+
+ Defaults to the empty string.
+*/
+
+/*!
+ \qmlproperty string Action::tooltip
+
+ Tooltip to be shown when hovering the control bound to this action.
+ Not all controls support tooltips on all platforms, especially \l MenuItem.
+
+ Defaults to the empty string.
+*/
+
+/*!
+ \qmlproperty bool Action::enabled
+
+ Whether the action is enabled, and can be triggered. Defaults to \c true.
+
+ \sa tigger(), triggered()
+*/
+
+/*!
+ \qmlproperty bool Action::checkable
+
+ Whether the menu item can be checked, or toggled. Defaults to \c false.
+
+ \sa checked, exclusiveGroup
+*/
+
+/*!
+ \qmlproperty bool Action::checked
+
+ If the action is \l checkable, this property reflects its checked state. Defaults to \c false.
+ Its value is also false while \l checkable is false.
+
+ \sa toggled(), exclusiveGroup
+*/
+
+/*!
+ \qmlproperty ExclusiveGroup Action::exclusiveGroup
+
+ If an action is checkable, an \l ExclusiveGroup can be attached to it.
+ All the actions sharing the same exclusive group become mutually exclusive
+ selectable, meaning that only the last checked action will actually be checked.
+
+ Defaults to \c null, meaning no exclusive behavior is to be expected.
+
+ \sa checkable, checked
+*/
+
+/*!
+ \qmlproperty string Action::shortcut
+
+ Shortcut bound to the action. Defaults to the empty string.
+*/
+
+/*! \qmlsignal Action::triggered()
+
+ Emitted when either the menu item or its bound action have been activated.
+ You shouldn't need to emit this signal, use \l trigger() instead.
+*/
+
+/*! \qmlmethod Action::trigger()
+
+ Will emit the \l triggered() signal if the action is enabled. Will also emit the
+ \l toggled() signal if it is checkable.
+*/
+
+/*! \qmlsignal Action::toggled(checked)
+
+ Emitted whenever a action's \l checked property changes.
+ This usually happens at the same time as \l triggered().
+*/
+
+QtAction::QtAction(QObject *parent)
+ : QObject(parent)
+ , m_enabled(true)
+ , m_checkable(false)
+ , m_checked(false)
+{
+}
+
+QtAction::~QtAction()
+{
+ setShortcut(QString());
+ setMnemonicFromText(QString());
+ setExclusiveGroup(0);
+}
+
+void QtAction::setText(const QString &text)
+{
+ if (text == m_text)
+ return;
+ m_text = text;
+ setMnemonicFromText(m_text);
+ emit textChanged();
+}
+
+bool qShortcutContextMatcher(QObject *, Qt::ShortcutContext)
+{
+ // the context matching is only interesting for non window-wide shortcuts
+ // it might be interesting to check for the action's window being active
+ // we currently only support the window wide focus so we can safely ignore this
+ return true;
+}
+
+QString QtAction::shortcut() const
+{
+ return m_shortcut.toString(QKeySequence::NativeText);
+}
+
+void QtAction::setShortcut(const QString &arg)
+{
+ QKeySequence sequence = QKeySequence::fromString(arg);
+ if (sequence == m_shortcut)
+ return;
+
+ if (!m_shortcut.isEmpty())
+ QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, m_shortcut);
+
+ m_shortcut = sequence;
+
+ if (!m_shortcut.isEmpty()) {
+ Qt::ShortcutContext context = Qt::WindowShortcut;
+ QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, m_shortcut, context, qShortcutContextMatcher);
+ }
+ emit shortcutChanged(shortcut());
+}
+
+void QtAction::setMnemonicFromText(const QString &text)
+{
+ QKeySequence sequence = QKeySequence::mnemonic(text);
+ if (m_mnemonic == sequence)
+ return;
+
+ if (!m_mnemonic.isEmpty())
+ QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, m_mnemonic);
+
+ m_mnemonic = sequence;
+
+ if (!m_mnemonic.isEmpty()) {
+ Qt::ShortcutContext context = Qt::WindowShortcut;
+ QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, m_mnemonic, context, qShortcutContextMatcher);
+ }
+}
+
+void QtAction::setIconSource(const QUrl &iconSource)
+{
+ if (iconSource == m_iconSource)
+ return;
+
+ m_iconSource = iconSource;
+ if (m_iconName.isEmpty() || m_icon.isNull()) {
+ QString fileString = QQmlFile::urlToLocalFileOrQrc(iconSource);
+ m_icon = QIcon(fileString);
+
+ emit iconChanged();
+ }
+ emit iconSourceChanged();
+}
+
+QString QtAction::iconName() const
+{
+ return m_iconName;
+}
+
+void QtAction::setIconName(const QString &iconName)
+{
+ if (iconName == m_iconName)
+ return;
+ m_iconName = iconName;
+ m_icon = QIcon::fromTheme(m_iconName, QIcon(QQmlFile::urlToLocalFileOrQrc(m_iconSource)));
+ emit iconNameChanged();
+ emit iconChanged();
+}
+
+void QtAction::setTooltip(const QString &arg)
+{
+ if (m_tooltip != arg) {
+ m_tooltip = arg;
+ emit tooltipChanged(arg);
+ }
+}
+
+void QtAction::setEnabled(bool e)
+{
+ if (e == m_enabled)
+ return;
+ m_enabled = e;
+ emit enabledChanged();
+}
+
+void QtAction::setCheckable(bool c)
+{
+ if (c == m_checkable)
+ return;
+ m_checkable = c;
+ emit checkableChanged();
+
+ // Setting checkable to false will show checked as false, while setting checkable to
+ // true will reveal checked's value again. If checked's internal value is true, we send
+ // the signal to notify its visible value.
+ if (m_checked)
+ emit toggled(m_checkable);
+}
+
+void QtAction::setChecked(bool c)
+{
+ if (c == m_checked)
+ return;
+ m_checked = c;
+
+ // Its value shows as false while checkable is false. See also comment in setCheckable().
+ if (m_checkable)
+ emit toggled(m_checked);
+}
+
+QtExclusiveGroup *QtAction::exclusiveGroup() const
+{
+ return m_exclusiveGroup.data();
+}
+
+void QtAction::setExclusiveGroup(QtExclusiveGroup *eg)
+{
+ if (m_exclusiveGroup == eg)
+ return;
+
+ if (m_exclusiveGroup)
+ m_exclusiveGroup->unbindCheckable(this);
+ m_exclusiveGroup = eg;
+ if (m_exclusiveGroup)
+ m_exclusiveGroup->bindCheckable(this);
+
+ emit exclusiveGroupChanged();
+}
+
+bool QtAction::event(QEvent *e)
+{
+ if (!m_enabled)
+ return false;
+
+ if (e->type() != QEvent::Shortcut)
+ return false;
+
+ QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
+
+ Q_ASSERT_X(se->key() == m_shortcut || se->key() == m_mnemonic,
+ "QtAction::event",
+ "Received shortcut event from incorrect shortcut");
+ if (se->isAmbiguous()) {
+ qWarning("QtAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
+ return false;
+ }
+
+ trigger();
+
+ return true;
+}
+
+void QtAction::trigger()
+{
+ if (!m_enabled)
+ return;
+
+ if (m_checkable && !(m_checked && m_exclusiveGroup))
+ setChecked(!m_checked);
+
+ emit triggered();
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtaction_p.h b/src/controls/qtaction_p.h
new file mode 100644
index 00000000..afe74e44
--- /dev/null
+++ b/src/controls/qtaction_p.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTACTION_H
+#define QTACTION_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/qicon.h>
+#include <QtGui/qkeysequence.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtExclusiveGroup;
+
+class QtAction : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
+ Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
+ Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged)
+ Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
+
+ Q_PROPERTY(QtExclusiveGroup *exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup NOTIFY exclusiveGroupChanged)
+#ifndef QT_NO_SHORTCUT
+ Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged)
+#endif
+
+public:
+ explicit QtAction(QObject *parent = 0);
+ ~QtAction();
+
+ QString text() const { return m_text; }
+ void setText(const QString &text);
+
+ QString shortcut() const;
+ void setShortcut(const QString &shortcut);
+
+ void setMnemonicFromText(const QString &mnemonic);
+
+ QString iconName() const;
+ void setIconName(const QString &iconName);
+
+ QUrl iconSource() const { return m_iconSource; }
+ void setIconSource(const QUrl &iconSource);
+
+ QString tooltip() const { return m_tooltip; }
+ void setTooltip(const QString &tooltip);
+
+ bool isEnabled() const { return m_enabled; }
+ void setEnabled(bool e);
+
+ bool isCheckable() const { return m_checkable; }
+ void setCheckable(bool c);
+
+ bool isChecked() const { return m_checkable && m_checked; }
+ void setChecked(bool c);
+
+ QtExclusiveGroup *exclusiveGroup() const;
+ void setExclusiveGroup(QtExclusiveGroup *arg);
+
+ QIcon icon() const { return m_icon; }
+ QVariant iconVariant() const { return QVariant(m_icon); }
+ void setIcon(QIcon icon) { m_icon = icon; emit iconChanged(); }
+
+ bool event(QEvent *e);
+
+public Q_SLOTS:
+ void trigger();
+
+Q_SIGNALS:
+ void triggered();
+ void toggled(bool checked);
+
+ void textChanged();
+ void shortcutChanged(QString shortcut);
+
+ void iconChanged();
+ void iconNameChanged();
+ void iconSourceChanged();
+ void tooltipChanged(QString arg);
+ void enabledChanged();
+ void checkableChanged();
+
+ void exclusiveGroupChanged();
+
+private:
+ QString m_text;
+ QUrl m_iconSource;
+ QString m_iconName;
+ QIcon m_icon;
+ bool m_enabled;
+ bool m_checkable;
+ bool m_checked;
+ QPointer<QtExclusiveGroup> m_exclusiveGroup;
+ QKeySequence m_shortcut;
+ QKeySequence m_mnemonic;
+ QString m_tooltip;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTACTION_H
diff --git a/src/controls/qtexclusivegroup.cpp b/src/controls/qtexclusivegroup.cpp
new file mode 100644
index 00000000..11f84dd5
--- /dev/null
+++ b/src/controls/qtexclusivegroup.cpp
@@ -0,0 +1,252 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtexclusivegroup_p.h"
+
+#include <qvariant.h>
+#include <qdebug.h>
+#include "qtaction_p.h"
+
+#define CHECKED_PROPERTY "checked"
+
+QT_BEGIN_NAMESPACE
+
+static const char *checkableSignals[] = {
+ CHECKED_PROPERTY"Changed()",
+ "toggled(bool)",
+ "toggled()",
+ 0
+};
+
+static bool isChecked(const QObject *o)
+{
+ if (!o) return false;
+ QVariant checkedVariant = o->property(CHECKED_PROPERTY);
+ return checkedVariant.isValid() && checkedVariant.toBool();
+}
+
+/*!
+ \qmltype ExclusiveGroup
+ \instantiates QtExclusiveGroup
+ \inqmlmodule QtQuick.Controls 1.0
+ \brief ExclusiveGroup provides a way to declare several checkable controls as mutually exclusive.
+
+ ExclusiveGroup can contain several \l Action items, and those will automatically get their
+ \l Action::exclusiveGroup property assigned.
+
+ \code
+ ExclusiveGroup {
+ id: radioInputGroup
+
+ Action {
+ id: dabRadioInput
+ text: "DAB"
+ checkable: true
+ }
+
+ Action {
+ id: fmRadioInput
+ text: "FM"
+ checkable: true
+ }
+
+ Action {
+ id: amRadioInput
+ text: "AM"
+ checkable: true
+ }
+ }
+ \endcode
+
+ Several controls already support \l ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton.
+
+ Since \l ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup
+ property for other objects.
+
+ \code
+ ExclusiveGroup { id: textAlignmentGroup }
+
+ Menu {
+ MenuItem {
+ text: "Alignt Left"
+ checkable: true
+ exclusiveGroup: textAlignmentGroup
+ }
+ MenuItem {
+ text: "Alignt Right"
+ checkable: true
+ exclusiveGroup: textAlignmentGroup
+ }
+ MenuItem {
+ text: "Center"
+ checkable: true
+ exclusiveGroup: textAlignmentGroup
+ }
+ MenuItem {
+ text: "Justify"
+ checkable: true
+ exclusiveGroup: textAlignmentGroup
+ }
+ }
+ \endcode
+
+ \section1 Adding support to ExclusiveGroup
+
+ It is possible to add support for \l ExclusiveGroup for an object, or control. It should have a \c checked
+ property, and either a \c checkedChanged, \c toggled(), or \c toggled(bool) signal. It also needs
+ to be bound with \l ExclusiveGroup::bindCheckable(object) when its \l ExclusiveGroup ty[ped property is set.
+
+ \code
+ Item {
+ id: myItem
+
+ property bool checked: false
+ property ExclusiveGroup exclusiveGroup: null
+
+ onExclusiveGroupChanged: {
+ if (exclusiveGroup)
+ exclusiveGroup.bindCheckable(myItem)
+ }
+ }
+ \endcode
+
+ The example above shows the minimum necessary to add \l ExclusiveGroup support to any item.
+*/
+
+/*!
+ \qmlproperty object ExclusiveGroup::current
+
+ The currently selected object. Defaults to the first checked object bound to the \l ExclusiveGroup.
+ If there is none, then it defaults to \c null.
+*/
+
+/*!
+ \qmlmethod void ExclusiveGroup::bindCheckable(object)
+
+ Register \c object to the exclusive group.
+
+ You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
+
+ \sa ExclusiveGroup::unbindCheckable(object)
+*/
+
+/*!
+ \qmlmethod void ExclusiveGroup::unbindCheckable(object)
+
+ Unregister \c object from the exclusive group.
+
+ You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup.
+
+ \sa ExclusiveGroup::bindCheckable(object)
+*/
+
+QtExclusiveGroup::QtExclusiveGroup(QObject *parent)
+ : QObject(parent), m_current(0)
+{
+ int index = metaObject()->indexOfMethod("updateCurrent()");
+ m_updateCurrentMethod = metaObject()->method(index);
+}
+
+QQmlListProperty<QtAction> QtExclusiveGroup::actions()
+{
+ return QQmlListProperty<QtAction>(this, 0, &QtExclusiveGroup::append_actions, 0, 0, 0);
+}
+
+void QtExclusiveGroup::append_actions(QQmlListProperty<QtAction> *list, QtAction *action)
+{
+ if (QtExclusiveGroup *eg = qobject_cast<QtExclusiveGroup *>(list->object))
+ action->setExclusiveGroup(eg);
+}
+
+void QtExclusiveGroup::setCurrent(QObject * o)
+{
+ if (m_current == o)
+ return;
+
+ if (m_current)
+ m_current->setProperty(CHECKED_PROPERTY, QVariant(false));
+ m_current = o;
+ if (m_current)
+ m_current->setProperty(CHECKED_PROPERTY, QVariant(true));
+ emit currentChanged();
+}
+
+void QtExclusiveGroup::updateCurrent()
+{
+ QObject *checkable = sender();
+ if (isChecked(checkable))
+ setCurrent(checkable);
+}
+
+void QtExclusiveGroup::bindCheckable(QObject *o)
+{
+ for (const char **signalName = checkableSignals; *signalName; signalName++) {
+ int signalIndex = o->metaObject()->indexOfSignal(*signalName);
+ if (signalIndex != -1) {
+ QMetaMethod signalMethod = o->metaObject()->method(signalIndex);
+ connect(o, signalMethod, this, m_updateCurrentMethod, Qt::UniqueConnection);
+ connect(o, SIGNAL(destroyed(QObject*)), this, SLOT(unbindCheckable(QObject*)), Qt::UniqueConnection);
+ if (!m_current && isChecked(o))
+ setCurrent(o);
+ return;
+ }
+ }
+
+ qWarning() << "QtExclusiveGroup::bindCheckable(): Cannot bind to" << o;
+}
+
+void QtExclusiveGroup::unbindCheckable(QObject *o)
+{
+ if (m_current == o)
+ setCurrent(0);
+ for (const char **signalName = checkableSignals; *signalName; signalName++) {
+ int signalIndex = o->metaObject()->indexOfSignal(*signalName);
+ if (signalIndex != -1) {
+ QMetaMethod signalMethod = o->metaObject()->method(signalIndex);
+ if (disconnect(o, signalMethod, this, m_updateCurrentMethod)) {
+ disconnect(o, SIGNAL(destroyed(QObject*)), this, SLOT(unbindCheckable(QObject*)));
+ break;
+ }
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtexclusivegroup_p.h b/src/controls/qtexclusivegroup_p.h
new file mode 100644
index 00000000..04109b06
--- /dev/null
+++ b/src/controls/qtexclusivegroup_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXCLUSIVEGROUP_H
+#define QTEXCLUSIVEGROUP_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qmetaobject.h>
+#include <QtQml/qqmllist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtAction;
+
+class QtExclusiveGroup : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QObject *current READ current WRITE setCurrent NOTIFY currentChanged)
+ Q_PROPERTY(QQmlListProperty<QtAction> __actions READ actions)
+ Q_CLASSINFO("DefaultProperty", "__actions")
+
+public:
+ explicit QtExclusiveGroup(QObject *parent = 0);
+
+ QObject *current() const { return m_current; }
+ void setCurrent(QObject * o);
+
+ QQmlListProperty<QtAction> actions();
+
+public Q_SLOTS:
+ void bindCheckable(QObject *o);
+ void unbindCheckable(QObject *o);
+
+Q_SIGNALS:
+ void currentChanged();
+
+private Q_SLOTS:
+ void updateCurrent();
+
+private:
+ static void append_actions(QQmlListProperty<QtAction> *list, QtAction *action);
+
+ QObject * m_current;
+ QMetaMethod m_updateCurrentMethod;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTEXCLUSIVEGROUP_H
diff --git a/src/controls/qtmenu.cpp b/src/controls/qtmenu.cpp
new file mode 100644
index 00000000..dfed4e32
--- /dev/null
+++ b/src/controls/qtmenu.cpp
@@ -0,0 +1,597 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtmenu_p.h"
+#include "qtmenuitemcontainer_p.h"
+#include "qtaction_p.h"
+#include "qtmenupopupwindow_p.h"
+
+#include <qdebug.h>
+#include <qabstractitemmodel.h>
+#include <qcursor.h>
+#include <private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QtMenu
+ \internal
+ */
+
+/*!
+ \qmltype MenuPrivate
+ \instantiates QtMenu
+ \internal
+ \inqmlmodule QtQuick.Controls 1.0
+ */
+
+/*!
+ \qmlproperty list<Object> Menu::items
+ \default
+
+ The list of items in the menu.
+
+ \l Menu only accepts objects of type \l Menu, \l MenuItem, and \l MenuSeparator
+ as children. It also supports \l Instantiator objects as long as the insertion is
+ being done manually using \l insertItem().
+
+ \code
+ Menu {
+ id: recentFilesMenu
+
+ Instantiator {
+ model: recentFilesModel
+ MenuItem {
+ text: model.fileName
+ }
+ onObjectAdded: recentFilesMenu.insertItem(index, object)
+ onObjectRemoved: recentFilesMenu.removeItem(object)
+ }
+
+ MenuSeparator {
+ visible: recentFilesModel.count > 0
+ }
+
+ MenuItem {
+ text: "Clear menu"
+ enabled: recentFilesModel.count > 0
+ onTriggered: recentFilesModel.clear()
+ }
+ \endcode
+
+ Note that in this case, the \c index parameter passed to \l insertItem() is relative
+ to the position of the \l Instatiator in the menu, as opposed to absolute position
+ in the menu.
+
+ \sa MenuItem, MenuSeparator
+*/
+
+/*!
+ \qmlproperty bool Menu::visible
+
+ Whether the menu should be visible. This is only enabled when the menu is used as
+ a submenu. Its value defaults to \c true.
+*/
+
+/*!
+ \qmlproperty enumeration Menu::type
+
+ This property is read-only and constant, and its value is \l MenuItemType.Menu.
+*/
+
+/*!
+ \qmlproperty string Menu::title
+
+ Title for the menu as a submenu or in a menubar.
+
+ Mnemonics are supported by prefixing the shortcut letter with \&.
+ For instance, \c "\&File" will bind the \c Alt-F shortcut to the
+ \c "File" menu. Note that not all platforms support mnemonics.
+
+ Its value defaults to the empty string.
+*/
+
+/*!
+ \qmlproperty bool Menu::enabled
+
+ Whether the menu is enabled, and responsive to user interaction as a submenu.
+ Its value defaults to \c true.
+*/
+
+/*!
+ \qmlproperty url Menu::iconSource
+
+ Sets the icon file or resource url for the menu icon as a submenu.
+ Defaults to the empty URL.
+
+ \sa iconName
+*/
+
+/*!
+ \qmlproperty string Menu::iconName
+
+ Sets the icon name for the menu icon. This will pick the icon
+ with the given name from the current theme. Only works as a submenu.
+
+ Its value defaults to the empty string.
+
+ \sa iconSource
+*/
+
+/*!
+ \qmlmethod void Menu::popup()
+
+ Opens this menu under the mouse cursor.
+ It can block on some platforms, so test it accordingly.
+*/
+
+/*!
+ \qmlmethod MenuItem Menu::addItem(string text)
+
+ Adds an item to the menu. Returns the newly created \l MenuItem.
+*/
+
+/*!
+ \qmlmethod MenuSeparator Menu::addSeparator()
+
+ Adds a separator to the menu. Returns the newly created \l MenuSeparator.
+*/
+
+/*!
+ \qmlmethod Menu Menu::addMenu(string title)
+ Adds a submenu to the menu. Returns the newly created \l Menu.
+*/
+
+/*!
+ \qmlmethod void Menu::insertItem(int before, object item)
+
+ Inserts the \c item at the index \c before in the current menu.
+ In this case, \c item can be either a \l MenuItem, a \l MenuSeparator,
+ or a \l Menu.
+
+ \sa removeItem()
+*/
+
+/*!
+ \qmlmethod void Menu::removeItem(item)
+
+ Removes the \c item from the menu.
+ In this case, \c item can be either a \l MenuItem, a \l MenuSeparator,
+ or a \l Menu.
+
+ \sa insertItem()
+*/
+
+QtMenu::QtMenu(QObject *parent)
+ : QtMenuText(parent),
+ m_itemsCount(0),
+ m_selectedIndex(-1),
+ m_parentWindow(0),
+ m_minimumWidth(0),
+ m_popupWindow(0),
+ m_menuContentItem(0),
+ m_popupVisible(false),
+ m_containersCount(0)
+{
+ connect(this, SIGNAL(__textChanged()), this, SIGNAL(titleChanged()));
+
+ m_platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
+ if (m_platformMenu) {
+ connect(m_platformMenu, SIGNAL(aboutToHide()), this, SLOT(__closeMenu()));
+ if (platformItem())
+ platformItem()->setMenu(m_platformMenu);
+ }
+}
+
+QtMenu::~QtMenu()
+{
+ delete m_platformMenu;
+ m_platformMenu = 0;
+}
+
+void QtMenu::updateText()
+{
+ if (m_platformMenu)
+ m_platformMenu->setText(this->text());
+ QtMenuText::updateText();
+}
+
+void QtMenu::setMinimumWidth(int w)
+{
+ if (w == m_minimumWidth)
+ return;
+
+ m_minimumWidth = w;
+ if (m_platformMenu)
+ m_platformMenu->setMinimumWidth(w);
+}
+
+void QtMenu::setFont(const QFont &arg)
+{
+ if (m_platformMenu)
+ m_platformMenu->setFont(arg);
+}
+
+void QtMenu::setSelectedIndex(int index)
+{
+ if (m_selectedIndex == index)
+ return;
+
+ m_selectedIndex = index;
+ emit __selectedIndexChanged();
+}
+
+void QtMenu::updateSelectedIndex()
+{
+ if (QtMenuItem *menuItem = qobject_cast<QtMenuItem*>(sender())) {
+ int index = indexOfMenuItem(menuItem);
+ setSelectedIndex(index);
+ }
+}
+
+QtMenuItems QtMenu::menuItems()
+{
+ return QtMenuItems(this, 0, &QtMenu::append_menuItems, &QtMenu::count_menuItems,
+ &QtMenu::at_menuItems, &QtMenu::clear_menuItems);
+}
+
+QQuickWindow *QtMenu::findParentWindow()
+{
+ if (!m_parentWindow) {
+ QQuickItem *parentAsItem = qobject_cast<QQuickItem *>(parent());
+ m_parentWindow = visualItem() ? visualItem()->window() : // Menu as menu item case
+ parentAsItem ? parentAsItem->window() : 0; //Menu as context menu/popup case
+ }
+ return m_parentWindow;
+}
+
+void QtMenu::popup()
+{
+ QPoint mousePos = QCursor::pos();
+ if (QQuickWindow *parentWindow = findParentWindow())
+ mousePos = parentWindow->mapFromGlobal(mousePos);
+
+ __popup(mousePos.x(), mousePos.y());
+}
+
+void QtMenu::__popup(qreal x, qreal y, int atItemIndex)
+{
+ if (popupVisible())
+ __closeMenu();
+
+ setPopupVisible(true);
+
+ QtMenuBase *atItem = menuItemAtIndex(atItemIndex);
+
+ QQuickWindow *parentWindow = findParentWindow();
+
+ if (m_platformMenu) {
+ QPointF screenPosition(x, y);
+ if (visualItem())
+ screenPosition = visualItem()->mapToScene(screenPosition);
+ m_platformMenu->showPopup(parentWindow, screenPosition.toPoint(), atItem ? atItem->platformItem() : 0);
+ } else {
+ m_popupWindow = new QtMenuPopupWindow();
+ if (visualItem())
+ m_popupWindow->setParentItem(visualItem());
+ else
+ m_popupWindow->setParentWindow(parentWindow);
+ m_popupWindow->setMenuContentItem(m_menuContentItem);
+ m_popupWindow->setItemAt(atItem ? atItem->visualItem() : 0);
+
+ connect(m_popupWindow, SIGNAL(visibleChanged(bool)), this, SLOT(windowVisibleChanged(bool)));
+
+ m_popupWindow->setPosition(x, y);
+ m_popupWindow->show();
+ }
+}
+
+void QtMenu::setMenuContentItem(QQuickItem *item)
+{
+ if (m_menuContentItem != item)
+ m_menuContentItem = item;
+}
+
+void QtMenu::setPopupVisible(bool v)
+{
+ if (m_popupVisible != v) {
+ m_popupVisible = v;
+ emit popupVisibleChanged();
+ }
+}
+
+void QtMenu::__closeMenu()
+{
+ setPopupVisible(false);
+ if (m_popupWindow)
+ m_popupWindow->setVisible(false);
+ m_parentWindow = 0;
+ emit __menuClosed();
+}
+
+void QtMenu::__dismissMenu()
+{
+ QtMenuPopupWindow *topMenuWindow = m_popupWindow;
+ while (topMenuWindow) {
+ QtMenuPopupWindow *pw = qobject_cast<QtMenuPopupWindow *>(topMenuWindow->transientParent());
+ if (!pw)
+ topMenuWindow->dismissMenu();
+ topMenuWindow = pw;
+ }
+}
+
+void QtMenu::windowVisibleChanged(bool v)
+{
+ if (!v) {
+ if (qobject_cast<QtMenuPopupWindow *>(m_popupWindow->transientParent())) {
+ m_popupWindow->transientParent()->setMouseGrabEnabled(true);
+ m_popupWindow->transientParent()->setKeyboardGrabEnabled(true);
+ }
+ m_popupWindow->deleteLater();
+ m_popupWindow = 0;
+ __closeMenu();
+ }
+}
+
+void QtMenu::itemIndexToListIndex(int itemIndex, int *listIndex, int *containerIndex) const
+{
+ *listIndex = -1;
+ QtMenuItemContainer *container = 0;
+ while (itemIndex >= 0 && ++*listIndex < m_menuItems.count())
+ if ((container = qobject_cast<QtMenuItemContainer *>(m_menuItems[*listIndex])))
+ itemIndex -= container->items().count();
+ else
+ --itemIndex;
+
+ if (container)
+ *containerIndex = container->items().count() + itemIndex;
+ else
+ *containerIndex = -1;
+}
+
+int QtMenu::itemIndexForListIndex(int listIndex) const
+{
+ int index = 0;
+ int i = 0;
+ while (i < listIndex && i < m_menuItems.count())
+ if (QtMenuItemContainer *container = qobject_cast<QtMenuItemContainer *>(m_menuItems[i++]))
+ index += container->items().count();
+ else
+ ++index;
+
+ return index;
+}
+
+QtMenuBase *QtMenu::nextMenuItem(QtMenu::MenuItemIterator *it) const
+{
+ if (it->containerIndex != -1) {
+ QtMenuItemContainer *container = qobject_cast<QtMenuItemContainer *>(m_menuItems[it->index]);
+ if (++it->containerIndex < container->items().count())
+ return container->items()[it->containerIndex];
+ }
+
+ if (++it->index < m_menuItems.count()) {
+ if (QtMenuItemContainer *container = qobject_cast<QtMenuItemContainer *>(m_menuItems[it->index])) {
+ it->containerIndex = 0;
+ return container->items()[0];
+ } else {
+ it->containerIndex = -1;
+ return m_menuItems[it->index];
+ }
+ }
+
+ return 0;
+}
+
+QtMenuBase *QtMenu::menuItemAtIndex(int index) const
+{
+ if (0 <= index && index < m_itemsCount) {
+ if (!m_containersCount) {
+ return m_menuItems[index];
+ } else if (m_containersCount == 1 && m_menuItems.count() == 1) {
+ QtMenuItemContainer *container = qobject_cast<QtMenuItemContainer *>(m_menuItems[0]);
+ return container->items()[index];
+ } else {
+ int containerIndex;
+ int i;
+ itemIndexToListIndex(index, &i, &containerIndex);
+ if (containerIndex != -1) {
+ QtMenuItemContainer *container = qobject_cast<QtMenuItemContainer *>(m_menuItems[i]);
+ return container->items()[containerIndex];
+ } else {
+ return m_menuItems[i];
+ }
+ }
+ }
+
+ return 0;
+}
+
+bool QtMenu::contains(QtMenuBase *item)
+{
+ if (item->container())
+ return item->container()->items().contains(item);
+
+ return m_menuItems.contains(item);
+}
+
+int QtMenu::indexOfMenuItem(QtMenuBase *item) const
+{
+ if (!item)
+ return -1;
+ if (item->container()) {
+ int containerIndex = m_menuItems.indexOf(item->container());
+ if (containerIndex == -1)
+ return -1;
+ int index = item->container()->items().indexOf(item);
+ return index == -1 ? -1 : itemIndexForListIndex(containerIndex) + index;
+ } else {
+ int index = m_menuItems.indexOf(item);
+ return index == -1 ? -1 : itemIndexForListIndex(index);
+ }
+}
+
+QtMenuItem *QtMenu::addItem(QString title)
+{
+ QtMenuItem *item = new QtMenuItem(this);
+ item->setText(title);
+ insertItem(m_itemsCount, item);
+ return item;
+}
+
+QtMenuSeparator *QtMenu::addSeparator()
+{
+ QtMenuSeparator *item = new QtMenuSeparator(this);
+ insertItem(m_itemsCount, item);
+ return item;
+}
+
+void QtMenu::insertItem(int index, QtMenuBase *menuItem)
+{
+ if (!menuItem)
+ return;
+ int itemIndex;
+ if (m_containersCount) {
+ QtMenuItemContainer *container = menuItem->parent() != this ? m_containers[menuItem->parent()] : 0;
+ if (container) {
+ container->insertItem(index, menuItem);
+ itemIndex = itemIndexForListIndex(m_menuItems.indexOf(container)) + index;
+ } else {
+ itemIndex = itemIndexForListIndex(index);
+ m_menuItems.insert(itemIndex, menuItem);
+ }
+ } else {
+ itemIndex = index;
+ m_menuItems.insert(index, menuItem);
+ }
+
+ setupMenuItem(menuItem, itemIndex);
+ emit itemsChanged();
+}
+
+void QtMenu::removeItem(QtMenuBase *menuItem)
+{
+ if (!menuItem)
+ return;
+ menuItem->setParentMenu(0);
+
+ QtMenuItemContainer *container = menuItem->parent() != this ? m_containers[menuItem->parent()] : 0;
+ if (container)
+ container->removeItem(menuItem);
+ else
+ m_menuItems.removeOne(menuItem);
+
+ --m_itemsCount;
+ emit itemsChanged();
+}
+
+void QtMenu::clear()
+{
+ m_containers.clear();
+ m_containersCount = 0;
+
+ while (!m_menuItems.empty())
+ delete m_menuItems.takeFirst();
+ m_itemsCount = 0;
+}
+
+void QtMenu::setupMenuItem(QtMenuBase *item, int platformIndex)
+{
+ item->setParentMenu(this);
+ if (m_platformMenu) {
+ QPlatformMenuItem *before = 0;
+ if (platformIndex != -1)
+ before = m_platformMenu->menuItemAt(platformIndex);
+ m_platformMenu->insertMenuItem(item->platformItem(), before);
+ }
+ ++m_itemsCount;
+}
+
+void QtMenu::append_menuItems(QtMenuItems *list, QObject *o)
+{
+ if (QtMenu *menu = qobject_cast<QtMenu *>(list->object)) {
+ Q_ASSERT(o->parent() == menu);
+
+ if (QtMenuBase *menuItem = qobject_cast<QtMenuBase *>(o)) {
+ menu->m_menuItems.append(menuItem);
+ menu->setupMenuItem(menuItem);
+ } else {
+ QtMenuItemContainer *menuItemContainer = new QtMenuItemContainer(menu);
+ menu->m_menuItems.append(menuItemContainer);
+ menu->m_containers.insert(o, menuItemContainer);
+ menuItemContainer->setParentMenu(menu);
+ ++menu->m_containersCount;
+ foreach (QObject *child, o->children()) {
+ if (QtMenuBase *item = qobject_cast<QtMenuBase *>(child)) {
+ menuItemContainer->insertItem(-1, item);
+ menu->setupMenuItem(item);
+ }
+ }
+ }
+ }
+}
+
+int QtMenu::count_menuItems(QtMenuItems *list)
+{
+ if (QtMenu *menu = qobject_cast<QtMenu *>(list->object))
+ return menu->m_itemsCount;
+
+ return 0;
+}
+
+QObject *QtMenu::at_menuItems(QtMenuItems *list, int index)
+{
+ if (QtMenu *menu = qobject_cast<QtMenu *>(list->object))
+ return menu->menuItemAtIndex(index);
+
+ return 0;
+}
+
+void QtMenu::clear_menuItems(QtMenuItems *list)
+{
+ if (QtMenu *menu = qobject_cast<QtMenu *>(list->object))
+ menu->clear();
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtmenu_p.h b/src/controls/qtmenu_p.h
new file mode 100644
index 00000000..aa23bba2
--- /dev/null
+++ b/src/controls/qtmenu_p.h
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTMENU_P_H
+#define QTMENU_P_H
+
+#include "qtmenuitem_p.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qvariant.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmllist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformMenu;
+class QtMenuPopupWindow;
+class QtMenuItemContainer;
+class QQuickWindow;
+
+typedef QQmlListProperty<QObject> QtMenuItems;
+
+class QtMenu : public QtMenuText
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ text WRITE setText NOTIFY titleChanged)
+ Q_PROPERTY(QQmlListProperty<QObject> items READ menuItems NOTIFY itemsChanged)
+ Q_CLASSINFO("DefaultProperty", "items")
+
+ Q_PROPERTY(int __selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY __selectedIndexChanged)
+ Q_PROPERTY(bool __popupVisible READ popupVisible NOTIFY popupVisibleChanged)
+ Q_PROPERTY(QQuickItem *__contentItem READ menuContentItem WRITE setMenuContentItem)
+ Q_PROPERTY(int __minimumWidth READ minimumWidth WRITE setMinimumWidth)
+ Q_PROPERTY(QFont __font WRITE setFont)
+
+public:
+ Q_INVOKABLE void popup();
+ Q_INVOKABLE QtMenuItem *addItem(QString);
+ Q_INVOKABLE QtMenuSeparator *addSeparator();
+
+ Q_INVOKABLE void __popup(qreal x, qreal y, int atActionIndex = -1);
+
+public Q_SLOTS:
+ void insertItem(int, QtMenuBase *);
+ void removeItem(QtMenuBase *);
+ void clear();
+
+ void __closeMenu();
+ void __dismissMenu();
+
+Q_SIGNALS:
+ void itemsChanged();
+ void titleChanged();
+
+ void __selectedIndexChanged();
+ void __menuClosed();
+ void popupVisibleChanged();
+
+public:
+ QtMenu(QObject *parent = 0);
+ virtual ~QtMenu();
+
+ int selectedIndex() const { return m_selectedIndex; }
+ void setSelectedIndex(int index);
+
+ QtMenuItems menuItems();
+ QtMenuBase *menuItemAtIndex(int index) const;
+ bool contains(QtMenuBase *);
+ int indexOfMenuItem(QtMenuBase *) const;
+
+ QPlatformMenu *platformMenu() const { return m_platformMenu; }
+
+ int minimumWidth() const { return m_minimumWidth; }
+ void setMinimumWidth(int w);
+
+ void setFont(const QFont &font);
+
+ QQuickItem *menuContentItem() const { return m_menuContentItem; }
+ bool popupVisible() const { return m_popupVisible; }
+
+ QtMenuItemType::MenuItemType type() { return QtMenuItemType::Menu; }
+ bool isNative() { return m_platformMenu != 0; }
+
+protected Q_SLOTS:
+ void updateSelectedIndex();
+
+ void setMenuContentItem(QQuickItem *);
+ void setPopupVisible(bool);
+
+ void updateText();
+ void windowVisibleChanged(bool);
+
+private:
+ QQuickWindow *findParentWindow();
+
+ int itemIndexForListIndex(int listIndex) const;
+ void itemIndexToListIndex(int, int *, int *) const;
+
+ struct MenuItemIterator
+ {
+ MenuItemIterator(): index(-1), containerIndex(-1) {}
+ int index, containerIndex;
+ };
+
+ QtMenuBase *nextMenuItem(MenuItemIterator *) const;
+
+ static void append_menuItems(QtMenuItems *list, QObject *o);
+ static int count_menuItems(QtMenuItems *list);
+ static QObject *at_menuItems(QtMenuItems *list, int index);
+ static void clear_menuItems(QtMenuItems *list);
+ void setupMenuItem(QtMenuBase *item, int platformIndex = -1);
+
+ QPlatformMenu *m_platformMenu;
+ QList<QtMenuBase *> m_menuItems;
+ QHash<QObject *, QtMenuItemContainer *> m_containers;
+ int m_itemsCount;
+ int m_selectedIndex;
+ int m_highlightedIndex;
+ QQuickWindow *m_parentWindow;
+ int m_minimumWidth;
+ QtMenuPopupWindow *m_popupWindow;
+ QQuickItem * m_menuContentItem;
+ bool m_popupVisible;
+ int m_containersCount;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QtMenu)
+
+#endif // QTMENU_P_H
diff --git a/src/controls/qtmenubar.cpp b/src/controls/qtmenubar.cpp
new file mode 100644
index 00000000..a8e4827b
--- /dev/null
+++ b/src/controls/qtmenubar.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtmenubar_p.h"
+
+#include <private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <qquickwindow.h>
+
+QT_BEGIN_NAMESPACE
+
+
+/*!
+ \class QtMenuBar
+ \internal
+ */
+
+/*!
+ \qmltype MenuBarPrivate
+ \instantiates QtMenuBar
+ \internal
+ \inqmlmodule QtQuick.Controls 1.0
+ */
+
+/*!
+ \qmlproperty list<Menu> MenuBar::menus
+ \default
+
+ The list of menus in the menubar.
+
+ \sa Menu
+*/
+
+QtMenuBar::QtMenuBar(QObject *parent)
+ : QObject(parent), m_contentItem(0), m_parentWindow(0)
+{
+ m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
+}
+
+QtMenuBar::~QtMenuBar()
+{
+}
+
+QQmlListProperty<QtMenu> QtMenuBar::menus()
+{
+ return QQmlListProperty<QtMenu>(this, 0, &QtMenuBar::append_menu, &QtMenuBar::count_menu, &QtMenuBar::at_menu, 0);
+}
+
+bool QtMenuBar::isNative()
+{
+ return m_platformMenuBar != 0;
+}
+
+void QtMenuBar::setContentItem(QQuickItem *item)
+{
+ if (item != m_contentItem) {
+ m_contentItem = item;
+ emit contentItemChanged();
+ }
+}
+
+void QtMenuBar::setParentWindow(QQuickWindow *newParentWindow)
+{
+ if (newParentWindow != m_parentWindow) {
+ m_parentWindow = newParentWindow;
+ if (m_platformMenuBar)
+ m_platformMenuBar->handleReparent(m_parentWindow);
+ }
+}
+
+void QtMenuBar::append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu)
+{
+ if (QtMenuBar *menuBar = qobject_cast<QtMenuBar *>(list->object)) {
+ menu->setParent(menuBar);
+ menuBar->m_menus.append(menu);
+
+ if (menuBar->m_platformMenuBar)
+ menuBar->m_platformMenuBar->insertMenu(menu->platformMenu(), 0 /* append */);
+
+ emit menuBar->menusChanged();
+ }
+}
+
+int QtMenuBar::count_menu(QQmlListProperty<QtMenu> *list)
+{
+ if (QtMenuBar *menuBar = qobject_cast<QtMenuBar *>(list->object))
+ return menuBar->m_menus.size();
+ return 0;
+}
+
+QtMenu *QtMenuBar::at_menu(QQmlListProperty<QtMenu> *list, int index)
+{
+ QtMenuBar *menuBar = qobject_cast<QtMenuBar *>(list->object);
+ if (menuBar && 0 <= index && index < menuBar->m_menus.size())
+ return menuBar->m_menus[index];
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtmenubar_p.h b/src/controls/qtmenubar_p.h
new file mode 100644
index 00000000..9e353952
--- /dev/null
+++ b/src/controls/qtmenubar_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTMENUBAR_P_H
+#define QTMENUBAR_P_H
+
+#include "qtmenu_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtQuick/qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformMenuBar;
+class QQuickItem;
+
+class QtMenuBar: public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QQmlListProperty<QtMenu> menus READ menus NOTIFY menusChanged)
+ Q_CLASSINFO("DefaultProperty", "menus")
+
+ Q_PROPERTY(QQuickItem *__contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged)
+ Q_PROPERTY(QQuickWindow *__parentWindow READ parentWindow WRITE setParentWindow)
+ Q_PROPERTY(bool __isNative READ isNative CONSTANT)
+
+Q_SIGNALS:
+ void menusChanged();
+
+ void contentItemChanged();
+
+public:
+ QtMenuBar(QObject *parent = 0);
+ ~QtMenuBar();
+
+ QQmlListProperty<QtMenu> menus();
+
+ bool isNative();
+
+ QQuickItem *contentItem() const { return m_contentItem; }
+ void setContentItem(QQuickItem *);
+
+ QQuickWindow *parentWindow() const { return m_parentWindow; }
+ void setParentWindow(QQuickWindow *);
+
+private:
+ static void append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu);
+ static int count_menu(QQmlListProperty<QtMenu> *list);
+ static QtMenu *at_menu(QQmlListProperty<QtMenu> *list, int index);
+
+private:
+ QList<QtMenu *> m_menus;
+ QPlatformMenuBar *m_platformMenuBar;
+ QQuickItem *m_contentItem;
+ QQuickWindow *m_parentWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif //QTMENUBAR_P_H
diff --git a/src/controls/qtmenuitem.cpp b/src/controls/qtmenuitem.cpp
new file mode 100644
index 00000000..b82b25de
--- /dev/null
+++ b/src/controls/qtmenuitem.cpp
@@ -0,0 +1,607 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtmenuitem_p.h"
+#include "qtaction_p.h"
+#include "qtmenu_p.h"
+#include "qtmenuitemcontainer_p.h"
+
+#include <private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
+#include <QtGui/qpa/qplatformmenu.h>
+#include <qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+QtMenuBase::QtMenuBase(QObject *parent)
+ : QObject(parent), m_visible(true), m_parentMenu(0), m_container(0), m_visualItem(0)
+{
+ m_platformItem = QGuiApplicationPrivate::platformTheme()->createPlatformMenuItem();
+}
+
+QtMenuBase::~QtMenuBase()
+{
+ setParentMenu(0);
+ if (m_platformItem) {
+ delete m_platformItem;
+ m_platformItem = 0;
+ }
+}
+
+void QtMenuBase::setVisible(bool v)
+{
+ if (v != m_visible) {
+ m_visible = v;
+
+ if (m_platformItem) {
+ m_platformItem->setVisible(m_visible);
+ syncWithPlatformMenu();
+ }
+
+ emit visibleChanged();
+ }
+}
+
+QtMenu *QtMenuBase::parentMenu() const
+{
+ return m_parentMenu;
+}
+
+void QtMenuBase::setParentMenu(QtMenu *parentMenu)
+{
+ if (m_parentMenu && m_parentMenu->platformMenu())
+ m_parentMenu->platformMenu()->removeMenuItem(m_platformItem);
+
+ m_parentMenu = parentMenu;
+}
+
+QtMenuItemContainer *QtMenuBase::container() const
+{
+ return m_container;
+}
+
+void QtMenuBase::setContainer(QtMenuItemContainer *c)
+{
+ m_container = c;
+}
+
+void QtMenuBase::syncWithPlatformMenu()
+{
+ QtMenu *menu = parentMenu();
+ if (menu && menu->platformMenu() && platformItem()
+ && menu->contains(this)) // If not, it'll be added later and then sync'ed
+ menu->platformMenu()->syncMenuItem(platformItem());
+}
+
+QQuickItem *QtMenuBase::visualItem() const
+{
+ return m_visualItem;
+}
+
+void QtMenuBase::setVisualItem(QQuickItem *item)
+{
+ m_visualItem = item;
+}
+
+/*!
+ \qmltype MenuSeparator
+ \instantiates QtMenuSeparator
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup menus
+ \brief MenuSeparator provides a separator for items inside a menu.
+
+ \sa Menu, MenuItem
+*/
+
+/*!
+ \qmlproperty bool MenuSeparator::visible
+
+ Whether the menu separator should be visible.
+*/
+
+/*!
+ \qmlproperty enumeration MenuSeparator::type
+
+ This property is read-only and constant, and its value is \l MenuItemType.Separator.
+*/
+
+QtMenuSeparator::QtMenuSeparator(QObject *parent)
+ : QtMenuBase(parent)
+{
+ if (platformItem())
+ platformItem()->setIsSeparator(true);
+}
+
+QtMenuText::QtMenuText(QObject *parent)
+ : QtMenuBase(parent), m_action(new QtAction(this))
+{
+ connect(m_action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
+ connect(m_action, SIGNAL(textChanged()), this, SLOT(updateText()));
+ connect(m_action, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
+ connect(m_action, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
+ connect(m_action, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
+ connect(m_action, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged()));
+}
+
+QtMenuText::~QtMenuText()
+{
+ delete m_action;
+}
+
+bool QtMenuText::enabled() const
+{
+ return action()->isEnabled();
+}
+
+void QtMenuText::setEnabled(bool e)
+{
+ action()->setEnabled(e);
+}
+
+QString QtMenuText::text() const
+{
+ return m_action->text();
+}
+
+void QtMenuText::setText(const QString &t)
+{
+ m_action->setText(t);
+}
+
+QUrl QtMenuText::iconSource() const
+{
+ return m_action->iconSource();
+}
+
+void QtMenuText::setIconSource(const QUrl &iconSource)
+{
+ m_action->setIconSource(iconSource);
+}
+
+QString QtMenuText::iconName() const
+{
+ return m_action->iconName();
+}
+
+void QtMenuText::setIconName(const QString &iconName)
+{
+ m_action->setIconName(iconName);
+}
+
+QIcon QtMenuText::icon() const
+{
+ return m_action->icon();
+}
+
+void QtMenuText::updateText()
+{
+ if (platformItem()) {
+ platformItem()->setText(text());
+ syncWithPlatformMenu();
+ }
+ emit __textChanged();
+}
+
+void QtMenuText::updateEnabled()
+{
+ if (platformItem()) {
+ platformItem()->setEnabled(enabled());
+ syncWithPlatformMenu();
+ }
+ emit enabledChanged();
+}
+
+void QtMenuText::updateIcon()
+{
+ if (platformItem()) {
+ platformItem()->setIcon(icon());
+ syncWithPlatformMenu();
+ }
+ emit __iconChanged();
+}
+
+/*!
+ \qmltype MenuItem
+ \instantiates QtMenuItem
+ \ingroup menus
+ \inqmlmodule QtQuick.Controls 1.0
+ \brief MenuItem provides an item to add in a menu or a menu bar.
+
+ \code
+ Menu {
+ text: "Edit"
+
+ MenuItem {
+ text: "Cut"
+ shortcut: "Ctrl+X"
+ onTriggered: ...
+ }
+
+ MenuItem {
+ text: "Copy"
+ shortcut: "Ctrl+C"
+ onTriggered: ...
+ }
+
+ MenuItem {
+ text: "Paste"
+ shortcut: "Ctrl+V"
+ onTriggered: ...
+ }
+ }
+ \endcode
+
+ \sa MenuBar, Menu, MenuSeparator, Action
+*/
+
+/*!
+ \qmlproperty bool MenuItem::visible
+
+ Whether the menu item should be visible. Defaults to \c true.
+*/
+
+/*!
+ \qmlproperty enumeration MenuItem::type
+
+ This property is read-only and constant, and its value is \l MenuItemType.Item.
+*/
+
+/*!
+ \qmlproperty string MenuItem::text
+
+ Text for the menu item. Overrides the item's bound action \c text property.
+
+ Mnemonics are supported by prefixing the shortcut letter with \&.
+ For instance, \c "\&Open" will bind the \c Alt-O shortcut to the
+ \c "Open" menu item. Note that not all platforms support mnemonics.
+
+ Defaults to the empty string.
+
+ \sa Action::text
+*/
+
+/*!
+ \qmlproperty bool MenuItem::enabled
+
+ Whether the menu item is enabled, and responsive to user interaction. Defaults to \c true.
+*/
+
+/*!
+ \qmlproperty url MenuItem::iconSource
+
+ Sets the icon file or resource url for the \l MenuItem icon.
+ Overrides the item's bound action \c iconSource property. Defaults to the empty URL.
+
+ \sa iconName, Action::iconSource
+*/
+
+/*!
+ \qmlproperty string MenuItem::iconName
+
+ Sets the icon name for the \l MenuItem icon. This will pick the icon
+ with the given name from the current theme. Overrides the item's bound
+ action \c iconName property. Defaults to the empty string.
+
+ \sa iconSource, Action::iconName
+*/
+
+/*! \qmlsignal MenuItem::triggered()
+
+ Emitted when either the menu item or its bound action have been activated.
+
+ \sa trigger(), Action::triggered(), Action::toggled()
+*/
+
+/*! \qmlmethod MenuItem::trigger()
+
+ Manually trigger a menu item. Will also trigger the item's bound action.
+
+ \sa triggered(), Action::trigger()
+*/
+
+/*!
+ \qmlproperty string MenuItem::shortcut
+
+ Shorcut bound to the menu item. Defaults to the empty string.
+
+ \sa Action::shortcut
+*/
+
+/*!
+ \qmlproperty bool MenuItem::checkable
+
+ Whether the menu item can be checked, or toggled. Defaults to \c false.
+
+ \sa checked
+*/
+
+/*!
+ \qmlproperty bool MenuItem::checked
+
+ If the menu item is checkable, this property reflects its checked state. Defaults to \c false.
+
+ \sa checkable, Action::toggled()
+*/
+
+/*! \qmlproperty ExclusiveGroup MenuItem::exclusiveGroup
+
+ If a menu item is checkable, an \l ExclusiveGroup can be attached to it.
+ All the menu items sharing the same exclusive group, and by extension, any \l Action sharing it,
+ become mutually exclusive selectable, meaning that only the last checked menu item will
+ actually be checked.
+
+ Defaults to \c null, meaning no exclusive behavior is to be expected.
+
+ \sa checked, checkable
+*/
+
+/*! \qmlsignal MenuItem::toggled(checked)
+
+ Emitted whenever a menu item's \c checked property changes.
+ This usually happens at the same time as \l triggered().
+
+ \sa checked, triggered(), Action::triggered(), Action::toggled()
+*/
+
+/*!
+ \qmlproperty Action MenuItem::action
+
+ The action bound to this menu item. It will provide values for all the properties of the menu item.
+ However, it is possible to override the action's \c text, \c iconSource, and \c iconName
+ properties by just assigning these properties, allowing some customization.
+
+ In addition, the menu item \c triggered() and \c toggled() signals will not be emitted.
+ Instead, the action \c triggered() and \c toggled() signals will be.
+
+ Defaults to \c null, meaning no action is bound to the menu item.
+*/
+
+QtMenuItem::QtMenuItem(QObject *parent)
+ : QtMenuText(parent), m_boundAction(0)
+{
+ connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged()));
+
+ connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered()));
+ connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
+ if (platformItem())
+ connect(platformItem(), SIGNAL(activated()), this, SLOT(trigger()));
+}
+
+QtMenuItem::~QtMenuItem()
+{
+ unbindFromAction(m_boundAction);
+ if (platformItem())
+ disconnect(platformItem(), SIGNAL(activated()), this, SLOT(trigger()));
+}
+
+void QtMenuItem::setParentMenu(QtMenu *parentMenu)
+{
+ QtMenuText::setParentMenu(parentMenu);
+ if (parentMenu)
+ connect(this, SIGNAL(triggered()), parentMenu, SLOT(updateSelectedIndex()));
+}
+
+void QtMenuItem::bindToAction(QtAction *action)
+{
+ m_boundAction = action;
+
+ connect(m_boundAction, SIGNAL(destroyed(QObject*)), this, SLOT(unbindFromAction(QObject*)));
+
+ connect(m_boundAction, SIGNAL(triggered()), this, SIGNAL(triggered()));
+ connect(m_boundAction, SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
+ connect(m_boundAction, SIGNAL(exclusiveGroupChanged()), this, SIGNAL(exclusiveGroupChanged()));
+ connect(m_boundAction, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
+ connect(m_boundAction, SIGNAL(textChanged()), this, SLOT(updateText()));
+ connect(m_boundAction, SIGNAL(shortcutChanged(QString)), this, SLOT(updateShortcut()));
+ connect(m_boundAction, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ connect(m_boundAction, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
+ connect(m_boundAction, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
+ connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
+ connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged()));
+
+ if (m_boundAction->parent() != this) {
+ updateText();
+ updateShortcut();
+ updateEnabled();
+ updateIcon();
+ if (checkable())
+ updateChecked();
+ }
+}
+
+void QtMenuItem::unbindFromAction(QObject *o)
+{
+ if (!o)
+ return;
+
+ if (o == m_boundAction)
+ m_boundAction = 0;
+
+ QtAction *action = qobject_cast<QtAction *>(o);
+ if (!action)
+ return;
+
+ disconnect(action, SIGNAL(destroyed(QObject*)), this, SLOT(unbindFromAction(QObject*)));
+
+ disconnect(action, SIGNAL(triggered()), this, SIGNAL(triggered()));
+ disconnect(action, SIGNAL(toggled(bool)), this, SLOT(updateChecked()));
+ disconnect(action, SIGNAL(exclusiveGroupChanged()), this, SIGNAL(exclusiveGroupChanged()));
+ disconnect(action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled()));
+ disconnect(action, SIGNAL(textChanged()), this, SLOT(updateText()));
+ disconnect(action, SIGNAL(shortcutChanged(QString)), this, SLOT(updateShortcut()));
+ disconnect(action, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged()));
+ disconnect(action, SIGNAL(iconNameChanged()), this, SLOT(updateIcon()));
+ disconnect(action, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged()));
+ disconnect(action, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon()));
+ disconnect(action, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged()));
+}
+
+QtAction *QtMenuItem::action() const
+{
+ if (m_boundAction)
+ return m_boundAction;
+ return QtMenuText::action();
+}
+
+void QtMenuItem::setBoundAction(QtAction *a)
+{
+ if (a == m_boundAction)
+ return;
+
+ if (m_boundAction) {
+ if (m_boundAction->parent() == this)
+ delete m_boundAction;
+ else
+ unbindFromAction(m_boundAction);
+ }
+
+ bindToAction(a);
+ emit actionChanged();
+}
+
+QString QtMenuItem::text() const
+{
+ QString ownText = QtMenuText::text();
+ if (!ownText.isEmpty())
+ return ownText;
+ return m_boundAction ? m_boundAction->text() : QString();
+}
+
+QUrl QtMenuItem::iconSource() const
+{
+ QUrl ownIconSource = QtMenuText::iconSource();
+ if (!ownIconSource.isEmpty())
+ return ownIconSource;
+ return m_boundAction ? m_boundAction->iconSource() : QUrl();
+}
+
+QString QtMenuItem::iconName() const
+{
+ QString ownIconName = QtMenuText::iconName();
+ if (!ownIconName.isEmpty())
+ return ownIconName;
+ return m_boundAction ? m_boundAction->iconName() : QString();
+}
+
+QIcon QtMenuItem::icon() const
+{
+ QIcon ownIcon = QtMenuText::icon();
+ if (!ownIcon.isNull())
+ return ownIcon;
+ return m_boundAction ? m_boundAction->icon() : QIcon();
+}
+
+QString QtMenuItem::shortcut() const
+{
+ return action()->shortcut();
+}
+
+void QtMenuItem::setShortcut(const QString &shortcut)
+{
+ if (!m_boundAction)
+ action()->setShortcut(shortcut);
+}
+
+void QtMenuItem::updateShortcut()
+{
+ if (platformItem()) {
+ platformItem()->setShortcut(QKeySequence(shortcut()));
+ syncWithPlatformMenu();
+ }
+ emit shortcutChanged();
+}
+
+bool QtMenuItem::checkable() const
+{
+ return action()->isCheckable();
+}
+
+void QtMenuItem::setCheckable(bool checkable)
+{
+ if (!m_boundAction)
+ action()->setCheckable(checkable);
+}
+
+bool QtMenuItem::checked() const
+{
+ return action()->isChecked();
+}
+
+void QtMenuItem::setChecked(bool checked)
+{
+ if (!m_boundAction)
+ action()->setChecked(checked);
+}
+
+void QtMenuItem::updateChecked()
+{
+ bool checked = this->checked();
+ if (platformItem()) {
+ platformItem()->setChecked(checked);
+ syncWithPlatformMenu();
+ }
+
+ emit toggled(checked);
+}
+
+QtExclusiveGroup *QtMenuItem::exclusiveGroup() const
+{
+ return action()->exclusiveGroup();
+}
+
+void QtMenuItem::setExclusiveGroup(QtExclusiveGroup *eg)
+{
+ if (!m_boundAction)
+ action()->setExclusiveGroup(eg);
+}
+
+void QtMenuItem::setEnabled(bool enabled)
+{
+ if (!m_boundAction)
+ action()->setEnabled(enabled);
+}
+
+void QtMenuItem::trigger()
+{
+ action()->trigger();
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtmenuitem_p.h b/src/controls/qtmenuitem_p.h
new file mode 100644
index 00000000..4762d6e2
--- /dev/null
+++ b/src/controls/qtmenuitem_p.h
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTMENUITEM_P_H
+#define QTMENUITEM_P_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qicon.h>
+#include <QtQml/QQmlListProperty>
+
+QT_BEGIN_NAMESPACE
+
+class QUrl;
+class QPlatformMenuItem;
+class QQuickItem;
+class QtAction;
+class QtExclusiveGroup;
+class QtMenu;
+class QtMenuItemContainer;
+
+class QtMenuItemType
+{
+ Q_GADGET
+ Q_ENUMS(MenuItemType)
+
+public:
+ enum MenuItemType {
+ Separator,
+ Item,
+ Menu
+ };
+};
+
+class QtMenuBase: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(QtMenuItemType::MenuItemType type READ type CONSTANT)
+
+ Q_PROPERTY(QtMenu *__parentMenu READ parentMenu CONSTANT)
+ Q_PROPERTY(bool __isNative READ isNative CONSTANT)
+ Q_PROPERTY(QQuickItem *__visualItem READ visualItem WRITE setVisualItem)
+
+Q_SIGNALS:
+ void visibleChanged();
+
+public:
+ QtMenuBase(QObject *parent = 0);
+ ~QtMenuBase();
+
+ bool visible() const { return m_visible; }
+ void setVisible(bool);
+
+ QtMenu *parentMenu() const;
+ virtual void setParentMenu(QtMenu *parentMenu);
+
+ QtMenuItemContainer *container() const;
+ void setContainer(QtMenuItemContainer *);
+
+ inline QPlatformMenuItem *platformItem() { return m_platformItem; }
+ void syncWithPlatformMenu();
+
+ QQuickItem *visualItem() const;
+ void setVisualItem(QQuickItem *item);
+
+ virtual QtMenuItemType::MenuItemType type() { return QtMenuItemType::Item; }
+ virtual bool isNative() { return m_platformItem != 0; }
+
+private:
+ bool m_visible;
+ QtMenu *m_parentMenu;
+ QtMenuItemContainer *m_container;
+ QPlatformMenuItem *m_platformItem;
+ QPointer<QQuickItem> m_visualItem;
+};
+
+class QtMenuSeparator : public QtMenuBase
+{
+ Q_OBJECT
+public:
+ QtMenuSeparator(QObject *parent = 0);
+
+ QtMenuItemType::MenuItemType type() { return QtMenuItemType::Separator; }
+};
+
+class QtMenuText: public QtMenuBase
+{
+ Q_OBJECT
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
+ Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
+
+ Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY __iconChanged)
+
+Q_SIGNALS:
+ void enabledChanged();
+ void iconSourceChanged();
+ void iconNameChanged();
+
+ void __textChanged();
+ void __iconChanged();
+
+public:
+ QtMenuText(QObject *parent = 0);
+ ~QtMenuText();
+
+ bool enabled() const;
+ virtual void setEnabled(bool enabled);
+
+ virtual QString text() const;
+ void setText(const QString &text);
+
+ virtual QUrl iconSource() const;
+ void setIconSource(const QUrl &icon);
+ virtual QString iconName() const;
+ void setIconName(const QString &icon);
+
+ QVariant iconVariant() const { return QVariant(icon()); }
+
+protected:
+ virtual QIcon icon() const;
+ virtual QtAction *action() const { return m_action; }
+
+protected Q_SLOTS:
+ virtual void updateText();
+ void updateEnabled();
+ void updateIcon();
+
+private:
+ QtAction *m_action;
+};
+
+class QtMenuItem: public QtMenuText
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged)
+ Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled)
+ Q_PROPERTY(QtExclusiveGroup *exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup NOTIFY exclusiveGroupChanged)
+ Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged)
+ Q_PROPERTY(QtAction *action READ boundAction WRITE setBoundAction NOTIFY actionChanged)
+
+public Q_SLOTS:
+ void trigger();
+
+Q_SIGNALS:
+ void triggered();
+ void toggled(bool checked);
+
+ void textChanged();
+ void checkableChanged();
+ void exclusiveGroupChanged();
+ void shortcutChanged();
+ void actionChanged();
+
+public:
+ QtMenuItem(QObject *parent = 0);
+ ~QtMenuItem();
+
+ void setEnabled(bool enabled);
+
+ QString text() const;
+
+ QUrl iconSource() const;
+ QString iconName() const;
+
+ QtAction *boundAction() { return m_boundAction; }
+ void setBoundAction(QtAction *a);
+
+ QString shortcut() const;
+ void setShortcut(const QString &shortcut);
+
+ bool checkable() const;
+ void setCheckable(bool checkable);
+
+ bool checked() const;
+ void setChecked(bool checked);
+
+ QtExclusiveGroup *exclusiveGroup() const;
+ void setExclusiveGroup(QtExclusiveGroup *);
+
+ void setParentMenu(QtMenu *parentMenu);
+
+protected Q_SLOTS:
+ void updateShortcut();
+ void updateChecked();
+ void bindToAction(QtAction *action);
+ void unbindFromAction(QObject *action);
+
+protected:
+ QIcon icon() const;
+ QtAction *action() const;
+
+private:
+ QtAction *m_boundAction;
+};
+
+QT_END_NAMESPACE
+
+#endif //QTMENUITEM_P_H
diff --git a/src/controls/qtmenuitemcontainer_p.h b/src/controls/qtmenuitemcontainer_p.h
new file mode 100644
index 00000000..2dbad6c6
--- /dev/null
+++ b/src/controls/qtmenuitemcontainer_p.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTMENUITEMSCONTAINER_P_H
+#define QTMENUITEMSCONTAINER_P_H
+
+#include "qtmenuitem_p.h"
+#include <QtCore/qlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtMenuItemContainer : public QtMenuBase
+{
+ Q_OBJECT
+public:
+ explicit QtMenuItemContainer(QObject *parent = 0)
+ : QtMenuBase(parent)
+ { }
+
+ ~QtMenuItemContainer()
+ {
+ clear();
+ }
+
+ void insertItem(int index, QtMenuBase *item)
+ {
+ if (index == -1)
+ index = m_menuItems.count();
+ m_menuItems.insert(index, item);
+ item->setContainer(this);
+ }
+
+ void removeItem(QtMenuBase *item)
+ {
+ item->setParentMenu(0);
+ item->setContainer(0);
+ m_menuItems.removeOne(item);
+ }
+
+ const QList<QPointer<QtMenuBase> > &items()
+ {
+ return m_menuItems;
+ }
+
+ void clear()
+ {
+ while (!m_menuItems.empty()) {
+ QtMenuBase *item = m_menuItems.takeFirst();
+ if (item) {
+ item->setParentMenu(0);
+ item->setContainer(0);
+ }
+ }
+ }
+
+private:
+ QList<QPointer<QtMenuBase> > m_menuItems;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTMENUITEMCONTAINER_H
diff --git a/src/controls/qtmenupopupwindow.cpp b/src/controls/qtmenupopupwindow.cpp
new file mode 100644
index 00000000..a3f76aa0
--- /dev/null
+++ b/src/controls/qtmenupopupwindow.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtmenupopupwindow_p.h"
+#include "qtmenu_p.h"
+
+#include <qguiapplication.h>
+#include <qquickitem.h>
+#include <QtGui/QScreen>
+
+QT_BEGIN_NAMESPACE
+
+QtMenuPopupWindow::QtMenuPopupWindow(QWindow *parent) :
+ QQuickWindow(parent), m_mouseMoved(false), m_itemAt(0),
+ m_parentItem(0), m_menuContentItem(0)
+{
+ setFlags(Qt::Popup);
+ setModality(Qt::WindowModal);
+}
+
+void QtMenuPopupWindow::show()
+{
+ qreal posx = x();
+ qreal posy = y();
+ if (QQuickWindow *parentWindow = qobject_cast<QQuickWindow *>(transientParent())) {
+ if (m_parentItem) {
+ QPointF pos = m_parentItem->mapToItem(parentWindow->contentItem(), QPointF(posx, posy));
+ posx = pos.x();
+ posy = pos.y();
+ }
+
+ posx += parentWindow->geometry().left();
+ posy += parentWindow->geometry().top();
+ }
+
+ if (m_itemAt) {
+ QPointF pos = m_itemAt->position();
+ posx -= pos.x();
+ posy -= pos.y();
+ }
+
+ if (m_menuContentItem) {
+ qreal initialWidth = qMax(qreal(1), m_menuContentItem->width());
+ qreal initialHeight = qMax(qreal(1), m_menuContentItem->height());
+ setGeometry(posx, posy, initialWidth, initialHeight);
+ } else {
+ setPosition(posx, posy);
+ }
+
+ if (!qobject_cast<QtMenuPopupWindow *>(transientParent())) // No need for parent menu windows
+ if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent()))
+ if (QQuickItem *mg = w->mouseGrabberItem())
+ mg->ungrabMouse();
+
+ QQuickWindow::show();
+ setMouseGrabEnabled(true); // Needs to be done after calling show()
+ setKeyboardGrabEnabled(true);
+}
+
+void QtMenuPopupWindow::setParentItem(QQuickItem *item)
+{
+ m_parentItem = item;
+ if (m_parentItem)
+ setParentWindow(m_parentItem->window());
+}
+
+void QtMenuPopupWindow::setMenuContentItem(QQuickItem *contentItem)
+{
+ if (!contentItem)
+ return;
+
+ contentItem->setParentItem(this->contentItem());
+ connect(contentItem, SIGNAL(widthChanged()), this, SLOT(updateSize()));
+ connect(contentItem, SIGNAL(heightChanged()), this, SLOT(updateSize()));
+ m_menuContentItem = contentItem;
+}
+
+void QtMenuPopupWindow::setItemAt(QQuickItem *menuItem)
+{
+ if (m_itemAt) {
+ disconnect(m_itemAt, SIGNAL(xChanged()), this, SLOT(updatePosition()));
+ disconnect(m_itemAt, SIGNAL(yChanged()), this, SLOT(updatePosition()));
+ }
+
+ m_itemAt = menuItem;
+ if (menuItem) {
+ m_oldItemPos = menuItem->position().toPoint();
+ connect(menuItem, SIGNAL(xChanged()), this, SLOT(updatePosition()));
+ connect(menuItem, SIGNAL(yChanged()), this, SLOT(updatePosition()));
+ }
+}
+
+void QtMenuPopupWindow::setParentWindow(QQuickWindow *parentWindow)
+{
+ setTransientParent(parentWindow);
+ if (parentWindow) {
+ connect(parentWindow, SIGNAL(destroyed()), this, SLOT(dismissMenu()));
+ if (QtMenuPopupWindow *pw = qobject_cast<QtMenuPopupWindow *>(parentWindow))
+ connect(pw, SIGNAL(menuDismissed()), this, SLOT(dismissMenu()));
+ }
+}
+
+void QtMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
+{
+ QWindow *pw = transientParent();
+ if (!pw && m_parentItem )
+ pw = m_parentItem->window();
+ if (!pw)
+ pw = this;
+ QRect g = pw->screen()->availableVirtualGeometry();
+
+ if (posx + w > g.right()) {
+ if (qobject_cast<QtMenuPopupWindow *>(transientParent())) {
+ // reposition submenu window on the parent menu's left side
+ int submenuOverlap = pw->x() + pw->width() - posx;
+ posx -= pw->width() + w - 2 * submenuOverlap;
+ } else {
+ posx = g.right() - w;
+ }
+ } else {
+ posx = qMax(posx, g.left());
+ }
+
+ posy = qBound(g.top(), posy, g.bottom() - h);
+
+ QQuickWindow::setGeometry(posx, posy, w, h);
+}
+
+void QtMenuPopupWindow::dismissMenu()
+{
+ emit menuDismissed();
+ close();
+}
+
+void QtMenuPopupWindow::updateSize()
+{
+ QSize contentSize = contentItem()->childrenRect().size().toSize();
+ setGeometry(position().x(), position().y(), contentSize.width(), contentSize.height());
+}
+
+void QtMenuPopupWindow::updatePosition()
+{
+ QPointF newPos = position() + m_oldItemPos - m_itemAt->position();
+ setGeometry(newPos.x(), newPos.y(), width(), height());
+}
+
+void QtMenuPopupWindow::mouseMoveEvent(QMouseEvent *e)
+{
+ QRect rect = QRect(QPoint(), size());
+ m_mouseMoved = true;
+ if (rect.contains(e->pos()))
+ QQuickWindow::mouseMoveEvent(e);
+ else
+ forwardEventToTransientParent(e);
+}
+
+void QtMenuPopupWindow::mousePressEvent(QMouseEvent *e)
+{
+ QRect rect = QRect(QPoint(), size());
+ if (!rect.contains(e->pos()))
+ forwardEventToTransientParent(e);
+}
+
+void QtMenuPopupWindow::mouseReleaseEvent(QMouseEvent *e)
+{
+ QRect rect = QRect(QPoint(), size());
+ if (rect.contains(e->pos())) {
+ if (m_mouseMoved) {
+ QMouseEvent pe = QMouseEvent(QEvent::MouseButtonPress, e->pos(), e->button(), e->buttons(), e->modifiers());
+ QQuickWindow::mousePressEvent(&pe);
+ QQuickWindow::mouseReleaseEvent(e);
+ }
+ m_mouseMoved = true; // Initial mouse release counts as move.
+ } else {
+ forwardEventToTransientParent(e);
+ }
+}
+
+void QtMenuPopupWindow::forwardEventToTransientParent(QMouseEvent *e)
+{
+ if (!qobject_cast<QtMenuPopupWindow*>(transientParent())
+ && ((m_mouseMoved && e->type() == QEvent::MouseButtonRelease)
+ || e->type() == QEvent::MouseButtonPress)) {
+ // Clicked outside any menu
+ dismissMenu();
+ } else if (transientParent()) {
+ QPoint parentPos = transientParent()->mapFromGlobal(mapToGlobal(e->pos()));
+ QMouseEvent pe = QMouseEvent(e->type(), parentPos, e->button(), e->buttons(), e->modifiers());
+ QGuiApplication::sendEvent(transientParent(), &pe);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtmenupopupwindow_p.h b/src/controls/qtmenupopupwindow_p.h
new file mode 100644
index 00000000..8d432974
--- /dev/null
+++ b/src/controls/qtmenupopupwindow_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTMENUPOPUPWINDOW_H
+#define QTMENUPOPUPWINDOW_H
+
+#include <QtQuick/qquickwindow.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEvent;
+class QQuickItem;
+
+class QtMenuPopupWindow : public QQuickWindow
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuickItem *contentItem READ menuContentItem WRITE setMenuContentItem)
+ Q_CLASSINFO("DefaultProperty", "contentItem")
+ Q_PROPERTY(QQuickItem *parentItem READ parentItem WRITE setParentItem)
+public:
+ QtMenuPopupWindow(QWindow *parent = 0);
+
+ QQuickItem *menuContentItem() const { return m_menuContentItem; }
+ void setMenuContentItem(QQuickItem *contentItem);
+
+ void setItemAt(QQuickItem *menuItem);
+ void setParentWindow(QQuickWindow *parentWindow);
+ void setGeometry(int posx, int posy, int w, int h);
+
+ QQuickItem *parentItem() const { return m_parentItem; }
+ void setParentItem(QQuickItem *);
+
+public Q_SLOTS:
+ void show();
+ void dismissMenu();
+ void updateSize();
+ void updatePosition();
+
+Q_SIGNALS:
+ void menuDismissed();
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+
+private:
+ void forwardEventToTransientParent(QMouseEvent *);
+
+ bool m_mouseMoved;
+ QQuickItem *m_itemAt;
+ QPointF m_oldItemPos;
+ QQuickItem *m_parentItem;
+ QQuickItem *m_menuContentItem;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTMENUPOPUPWINDOW_H
diff --git a/src/controls/qtstack.cpp b/src/controls/qtstack.cpp
new file mode 100644
index 00000000..09f2c534
--- /dev/null
+++ b/src/controls/qtstack.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtstack_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype Stack
+ \instantiates QtStack
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup views
+ \brief Provides attached properties for items pushed onto a PageStack.
+
+ The Stack attached property provides information when an item becomes
+ active or inactive through the \l{Stack::status}{Stack.status} property.
+ Status will be \c Stack.Activating when an item is transitioning into
+ being the current item on the screen, and \c Stack.Active once the
+ transition stops. When it leaves the screen, it will be
+ \c Stack.Deactivating, and then \c Stack.Inactive.
+
+ \sa PageStack
+*/
+
+QtStack::QtStack(QObject *object)
+ : QObject(object),
+ m_index(-1),
+ m_status(Inactive),
+ m_pageStack(0),
+ m_pageTransition(0)
+{
+}
+
+QtStack *QtStack::qmlAttachedProperties(QObject *object)
+{
+ return new QtStack(object);
+}
+
+/*!
+ \readonly
+ \qmlproperty int Stack::index
+
+ This property holds the index of the item inside \l{pageStack}{PageStack},
+ so that \l{PageStack::get()}{pageStack.get(index)} will return the item itself.
+ If \l{Stack::pageStack}{pageStack} is \c null, \a index will be \c -1.
+*/
+int QtStack::index() const
+{
+ return m_index;
+}
+
+void QtStack::setIndex(int index)
+{
+ if (m_index != index) {
+ m_index = index;
+ emit indexChanged();
+ }
+}
+
+/*!
+ \readonly
+ \qmlproperty enumeration Stack::status
+
+ This property holds the status of the item. It can have one of the following values:
+ \list
+ \li \c Stack.Inactive: the item is not visible
+ \li \c Stack.Activating: the item is transitioning into becoming an active item on the stack
+ \li \c Stack.Active: the item is on top of the stack
+ \li \c Stack.Deactivating: the item is transitioning into becoming inactive
+ \endlist
+*/
+QtStack::Status QtStack::status() const
+{
+ return m_status;
+}
+
+void QtStack::setStatus(Status status)
+{
+ if (m_status != status) {
+ m_status = status;
+ emit statusChanged();
+ }
+}
+
+/*!
+ \readonly
+ \qmlproperty PageStack Stack::pageStack
+
+ This property holds the PageStack the item is in. If the item is not inside
+ a PageStack, \a pageStack will be \c null.
+*/
+QQuickItem *QtStack::pageStack() const
+{
+ return m_pageStack;
+}
+
+void QtStack::setPageStack(QQuickItem *pageStack)
+{
+ if (m_pageStack != pageStack) {
+ m_pageStack = pageStack;
+ emit pageStackChanged();
+ }
+}
+
+/*!
+ \qmlproperty PageTransition Stack::pageTransition
+
+ This property can be set to override the default animations used
+ during a page transition. To better understand how to use this
+ property, refer to the \l{PageStack#Transitions}{transition documentation} in PageStack.
+ \sa {PageStack::animations}{PageStack.animations}
+*/
+QObject *QtStack::pageTransition() const
+{
+ return m_pageTransition;
+}
+
+void QtStack::setPageTransition(QObject* pageTransition)
+{
+ if (m_pageTransition != pageTransition) {
+ m_pageTransition = pageTransition;
+ emit pageTransitionChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qtstack_p.h b/src/controls/qtstack_p.h
new file mode 100644
index 00000000..aa22bf8c
--- /dev/null
+++ b/src/controls/qtstack_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTSTACK_P_H
+#define QTSTACK_P_H
+
+#include <QtQuick/qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtStack : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ Q_PROPERTY(int __index READ index WRITE setIndex NOTIFY indexChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(Status __status READ status WRITE setStatus NOTIFY statusChanged)
+ Q_PROPERTY(QQuickItem* pageStack READ pageStack NOTIFY pageStackChanged)
+ Q_PROPERTY(QQuickItem* __pageStack READ pageStack WRITE setPageStack NOTIFY pageStackChanged)
+ Q_PROPERTY(QObject* pageTransition READ pageTransition WRITE setPageTransition NOTIFY pageTransitionChanged)
+ Q_ENUMS(Status)
+
+public:
+ QtStack(QObject *object = 0);
+
+ static QtStack *qmlAttachedProperties(QObject *object);
+
+ int index() const;
+ void setIndex(int index);
+
+ enum Status {
+ Inactive = 0,
+ Deactivating = 1,
+ Activating = 2,
+ Active = 3
+ };
+
+ Status status() const;
+ void setStatus(Status status);
+
+ QQuickItem *pageStack() const;
+ void setPageStack(QQuickItem *pageStack);
+
+ QObject *pageTransition() const;
+ void setPageTransition(QObject* pageTransition);
+
+signals:
+ void statusChanged();
+ void pageStackChanged();
+ void indexChanged();
+ void pageTransitionChanged();
+
+private:
+ int m_index;
+ Status m_status;
+ QQuickItem *m_pageStack;
+ QObject *m_pageTransition;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QtStack)
+QML_DECLARE_TYPEINFO(QtStack, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QTSTACK_P_H
diff --git a/src/qtdesktop/Dial.qml b/src/experimental/Dial.qml
index fa0df6df..2206f623 100644
--- a/src/qtdesktop/Dial.qml
+++ b/src/experimental/Dial.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,15 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-
-// jens: ContainsMouse breaks drag functionality
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype Dial
- \inqmlmodule QtDesktop 1.0
- \brief Dial is doing bla...bla...
+ \inqmlmodule QtQuick.Controls 1.0
+ \brief Dial provides a dial control.
*/
Item {
@@ -57,7 +56,6 @@ Item {
property alias maximumValue: range.maximumValue
property alias minimumValue: range.minimumValue
- property alias containsMouse: mouseArea.containsMouse
property alias value: range.value
property alias stepSize: range.stepSize
@@ -65,6 +63,9 @@ Item {
property bool tickmarksEnabled: false
property bool activeFocusOnPress: false
+ /* \internal */
+ property alias __containsMouse: mouseArea.containsMouse
+
Accessible.role: Accessible.Dial
Accessible.name: value
@@ -147,21 +148,21 @@ Item {
}
}
}
- WheelArea {
- id: wheelarea
- anchors.fill: parent
- horizontalMinimumValue: dial.minimumValue
- horizontalMaximumValue: dial.maximumValue
- verticalMinimumValue: dial.minimumValue
- verticalMaximumValue: dial.maximumValue
- property double step: (dial.maximumValue - dial.minimumValue)/100
-
- onVerticalWheelMoved: {
- value += verticalDelta/4*step
- }
-
- onHorizontalWheelMoved: {
- value += horizontalDelta/4*step
- }
- }
+// WheelArea { // move this to MouseArea::onWheel
+// id: wheelarea
+// anchors.fill: parent
+// horizontalMinimumValue: dial.minimumValue
+// horizontalMaximumValue: dial.maximumValue
+// verticalMinimumValue: dial.minimumValue
+// verticalMaximumValue: dial.maximumValue
+// property double step: (dial.maximumValue - dial.minimumValue)/100
+
+// onVerticalWheelMoved: {
+// value += verticalDelta/4*step
+// }
+
+// onHorizontalWheelMoved: {
+// value += horizontalDelta/4*step
+// }
+// }
}
diff --git a/src/qtdesktop/Dialog.qml b/src/experimental/Dialog.qml
index abbda95e..5dc933db 100644
--- a/src/qtdesktop/Dialog.qml
+++ b/src/experimental/Dialog.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,13 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Window 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Window 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype Dialog
- \inqmlmodule QtDesktop 1.0
+ \inqmlmodule QtQuick.Controls 1.0
\brief Dialog is doing bla...bla...
*/
@@ -147,7 +148,7 @@ Window {
property int role: acceptRole
visible: buttons & ok
text: "OK"
- defaultbutton: true
+ isDefault: true
onClicked: {
visible: dialog.visible = false
clickedButton = okbutton
diff --git a/src/experimental/experimental.pro b/src/experimental/experimental.pro
new file mode 100644
index 00000000..b0a91658
--- /dev/null
+++ b/src/experimental/experimental.pro
@@ -0,0 +1,7 @@
+TARGETPATH = QtQuick/Controls/Experimental
+
+QML_FILES = \
+ Dial.qml \
+ Dialog.qml
+
+load(qml_module)
diff --git a/src/experimental/qmldir b/src/experimental/qmldir
new file mode 100644
index 00000000..c9d4cc31
--- /dev/null
+++ b/src/experimental/qmldir
@@ -0,0 +1,3 @@
+module QtQuick.Controls.Experimental
+Dial 1.0 Dial.qml
+Dialog 1.0 Dialog.qml
diff --git a/src/layouts/.gitattributes b/src/layouts/.gitattributes
new file mode 100644
index 00000000..4f72c998
--- /dev/null
+++ b/src/layouts/.gitattributes
@@ -0,0 +1 @@
+*.qmltypes diff=text \ No newline at end of file
diff --git a/src/layouts/layouts.pro b/src/layouts/layouts.pro
new file mode 100644
index 00000000..20bcf20c
--- /dev/null
+++ b/src/layouts/layouts.pro
@@ -0,0 +1,26 @@
+CXX_MODULE = qml
+TARGET = qquicklayoutsplugin
+TARGETPATH = QtQuick/Layouts
+IMPORT_VERSION = 2.1
+
+QT *= qml-private quick-private v8-private gui-private core-private
+
+#QMAKE_DOCS = $$PWD/doc/qtquicklayouts.qdocconf
+
+SOURCES += plugin.cpp \
+ qlayoutpolicy.cpp \
+ qgridlayoutengine.cpp \
+ qquicklayout.cpp \
+ qquicklinearlayout.cpp
+
+HEADERS += \
+ qlayoutpolicy_p.h \
+ qgridlayoutengine_p.h \
+ qquickgridlayoutengine_p.h \
+ qquicklayout_p.h \
+ qquicklinearlayout_p.h
+
+OTHER_FILES += \
+$$PWD/plugin.json
+
+load(qml_plugin)
diff --git a/src/layouts/plugin.cpp b/src/layouts/plugin.cpp
new file mode 100644
index 00000000..8348d8a0
--- /dev/null
+++ b/src/layouts/plugin.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+
+#include "qquicklinearlayout_p.h"
+
+QT_BEGIN_NAMESPACE
+
+//![class decl]
+class QtQuickLayoutsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Layouts"));
+ Q_UNUSED(uri);
+
+ qmlRegisterType<QQuickRowLayout>(uri, 1, 0, "RowLayout");
+ qmlRegisterType<QQuickColumnLayout>(uri, 1, 0, "ColumnLayout");
+ qmlRegisterType<QQuickGridLayout>(uri, 1, 0, "GridLayout");
+ qmlRegisterUncreatableType<QQuickLayout>(uri, 1, 0, "Layout",
+ QLatin1String("Do not create objects of type Layout"));
+ }
+};
+//![class decl]
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
diff --git a/src/layouts/plugin.json b/src/layouts/plugin.json
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/src/layouts/plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/src/layouts/plugins.qmltypes b/src/layouts/plugins.qmltypes
new file mode 100644
index 00000000..dd3dc69f
--- /dev/null
+++ b/src/layouts/plugins.qmltypes
Binary files differ
diff --git a/src/layouts/qgridlayoutengine.cpp b/src/layouts/qgridlayoutengine.cpp
new file mode 100644
index 00000000..30c02c97
--- /dev/null
+++ b/src/layouts/qgridlayoutengine.cpp
@@ -0,0 +1,1683 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglobal.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include <math.h>
+
+//#include "qgraphicslayoutitem.h"
+#include "qgridlayoutengine_p.h"
+//#include "qstyleoption.h"
+#include "qvarlengtharray.h"
+
+#include <QtDebug>
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+template <typename T>
+static void insertOrRemoveItems(QVector<T> &items, int index, int delta)
+{
+ int count = items.count();
+ if (index < count) {
+ if (delta > 0) {
+ items.insert(index, delta, T());
+ } else if (delta < 0) {
+ items.remove(index, qMin(-delta, count - index));
+ }
+ }
+}
+
+static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired)
+{
+ Q_ASSERT(sumDesired != 0.0);
+ return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
+}
+
+static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize)
+{
+ if (descent < 0.0)
+ return -1.0;
+
+ Q_ASSERT(descent >= 0.0);
+ Q_ASSERT(ascent >= 0.0);
+ Q_ASSERT(targetSize >= ascent + descent);
+
+ qreal extra = targetSize - (ascent + descent);
+ return descent + (extra / 2.0);
+}
+
+static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which)
+{
+ qreal size1 = box1.q_sizes(which);
+ qreal size2 = box2.q_sizes(which);
+
+ if (which == MaximumSize) {
+ return size2 - size1;
+ } else {
+ return size1 - size2;
+ }
+}
+
+void QGridLayoutBox::add(const QGridLayoutBox &other, int stretch, qreal spacing)
+{
+ Q_ASSERT(q_minimumDescent < 0.0);
+
+ q_minimumSize += other.q_minimumSize + spacing;
+ q_preferredSize += other.q_preferredSize + spacing;
+ q_maximumSize += ((stretch == 0) ? other.q_preferredSize : other.q_maximumSize) + spacing;
+}
+
+void QGridLayoutBox::combine(const QGridLayoutBox &other)
+{
+ q_minimumDescent = qMax(q_minimumDescent, other.q_minimumDescent);
+ q_minimumAscent = qMax(q_minimumAscent, other.q_minimumAscent);
+
+ q_minimumSize = qMax(q_minimumAscent + q_minimumDescent,
+ qMax(q_minimumSize, other.q_minimumSize));
+ qreal maxMax;
+ if (q_maximumSize == FLT_MAX && other.q_maximumSize != FLT_MAX)
+ maxMax = other.q_maximumSize;
+ else if (other.q_maximumSize == FLT_MAX && q_maximumSize != FLT_MAX)
+ maxMax = q_maximumSize;
+ else
+ maxMax = qMax(q_maximumSize, other.q_maximumSize);
+
+ q_maximumSize = qMax(q_minimumSize, maxMax);
+ q_preferredSize = qBound(q_minimumSize, qMax(q_preferredSize, other.q_preferredSize),
+ q_maximumSize);
+}
+
+void QGridLayoutBox::normalize()
+{
+ q_maximumSize = qMax(qreal(0.0), q_maximumSize);
+ q_minimumSize = qBound(qreal(0.0), q_minimumSize, q_maximumSize);
+ q_preferredSize = qBound(q_minimumSize, q_preferredSize, q_maximumSize);
+ q_minimumDescent = qMin(q_minimumDescent, q_minimumSize);
+
+ Q_ASSERT((q_minimumDescent < 0.0) == (q_minimumAscent < 0.0));
+}
+
+#ifdef QT_DEBUG
+void QGridLayoutBox::dump(int indent) const
+{
+ qDebug("%*sBox (%g <= %g <= %g [%g/%g])", indent, "", q_minimumSize, q_preferredSize,
+ q_maximumSize, q_minimumAscent, q_minimumDescent);
+}
+#endif
+
+bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2)
+{
+ for (int i = 0; i < NSizes; ++i) {
+ if (box1.q_sizes(i) != box2.q_sizes(i))
+ return false;
+ }
+ return box1.q_minimumDescent == box2.q_minimumDescent
+ && box1.q_minimumAscent == box2.q_minimumAscent;
+}
+
+void QGridLayoutRowData::reset(int count)
+{
+ ignore.fill(false, count);
+ boxes.fill(QGridLayoutBox(), count);
+ multiCellMap.clear();
+ stretches.fill(0, count);
+ spacings.fill(0.0, count);
+ hasIgnoreFlag = false;
+}
+
+void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo)
+{
+ MultiCellMap::const_iterator i = multiCellMap.constBegin();
+ for (; i != multiCellMap.constEnd(); ++i) {
+ int start = i.key().first;
+ int span = i.key().second;
+ int end = start + span;
+ const QGridLayoutBox &box = i.value().q_box;
+ int stretch = i.value().q_stretch;
+
+ QGridLayoutBox totalBox = this->totalBox(start, end);
+ QVarLengthArray<QGridLayoutBox> extras(span);
+ QVarLengthArray<qreal> dummy(span);
+ QVarLengthArray<qreal> newSizes(span);
+
+ for (int j = 0; j < NSizes; ++j) {
+ qreal extra = compare(box, totalBox, j);
+ if (extra > 0.0) {
+ calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(),
+ 0, totalBox, rowInfo);
+
+ for (int k = 0; k < span; ++k)
+ extras[k].q_sizes(j) = newSizes[k];
+ }
+ }
+
+ for (int k = 0; k < span; ++k) {
+ boxes[start + k].combine(extras[k]);
+ if (stretch != 0)
+ stretches[start + k] = qMax(stretches[start + k], stretch);
+ }
+ }
+ multiCellMap.clear();
+}
+
+void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSize, qreal *positions,
+ qreal *sizes, qreal *descents,
+ const QGridLayoutBox &totalBox,
+ const QGridLayoutRowInfo &rowInfo)
+{
+ Q_ASSERT(end > start);
+
+ targetSize = qMax(totalBox.q_minimumSize, targetSize);
+
+ int n = end - start;
+ QVarLengthArray<qreal> newSizes(n);
+ QVarLengthArray<qreal> factors(n);
+ qreal sumFactors = 0.0;
+ int sumStretches = 0;
+ qreal sumAvailable;
+
+ for (int i = 0; i < n; ++i) {
+ if (stretches[start + i] > 0)
+ sumStretches += stretches[start + i];
+ }
+
+ if (targetSize < totalBox.q_preferredSize) {
+ stealBox(start, end, MinimumSize, positions, sizes);
+
+ sumAvailable = targetSize - totalBox.q_minimumSize;
+ if (sumAvailable > 0.0) {
+ qreal sumDesired = totalBox.q_preferredSize - totalBox.q_minimumSize;
+
+ for (int i = 0; i < n; ++i) {
+ if (ignore.testBit(start + i)) {
+ factors[i] = 0.0;
+ continue;
+ }
+
+ const QGridLayoutBox &box = boxes.at(start + i);
+ qreal desired = box.q_preferredSize - box.q_minimumSize;
+ factors[i] = growthFactorBelowPreferredSize(desired, sumAvailable, sumDesired);
+ sumFactors += factors[i];
+ }
+
+ for (int i = 0; i < n; ++i) {
+ Q_ASSERT(sumFactors > 0.0);
+ qreal delta = sumAvailable * factors[i] / sumFactors;
+ newSizes[i] = sizes[i] + delta;
+ }
+ }
+ } else {
+ bool isLargerThanMaximum = (targetSize > totalBox.q_maximumSize);
+ if (isLargerThanMaximum) {
+ stealBox(start, end, MaximumSize, positions, sizes);
+ sumAvailable = targetSize - totalBox.q_maximumSize;
+ } else {
+ stealBox(start, end, PreferredSize, positions, sizes);
+ sumAvailable = targetSize - totalBox.q_preferredSize;
+ }
+
+ if (sumAvailable > 0.0) {
+ qreal sumCurrentAvailable = sumAvailable;
+ bool somethingHasAMaximumSize = false;
+
+ qreal sumSizes = 0.0;
+ for (int i = 0; i < n; ++i)
+ sumSizes += sizes[i];
+
+ for (int i = 0; i < n; ++i) {
+ if (ignore.testBit(start + i)) {
+ newSizes[i] = 0.0;
+ factors[i] = 0.0;
+ continue;
+ }
+
+ const QGridLayoutBox &box = boxes.at(start + i);
+ qreal boxSize;
+
+ qreal desired;
+ if (isLargerThanMaximum) {
+ boxSize = box.q_maximumSize;
+ desired = rowInfo.boxes.value(start + i).q_maximumSize - boxSize;
+ } else {
+ boxSize = box.q_preferredSize;
+ desired = box.q_maximumSize - boxSize;
+ }
+ if (desired == 0.0) {
+ newSizes[i] = sizes[i];
+ factors[i] = 0.0;
+ } else {
+ Q_ASSERT(desired > 0.0);
+
+ int stretch = stretches[start + i];
+ if (sumStretches == 0) {
+ if (hasIgnoreFlag) {
+ factors[i] = (stretch < 0) ? 1.0 : 0.0;
+ } else {
+ factors[i] = (stretch < 0) ? sizes[i] : 0.0;
+ }
+ } else if (stretch == sumStretches) {
+ factors[i] = 1.0;
+ } else if (stretch <= 0) {
+ factors[i] = 0.0;
+ } else {
+ qreal ultimateSize;
+ qreal ultimateSumSizes;
+ qreal x = ((stretch * sumSizes)
+ - (sumStretches * boxSize))
+ / (sumStretches - stretch);
+ if (x >= 0.0) {
+ ultimateSize = boxSize + x;
+ ultimateSumSizes = sumSizes + x;
+ } else {
+ ultimateSize = boxSize;
+ ultimateSumSizes = (sumStretches * boxSize)
+ / stretch;
+ }
+
+ /*
+ We multiply these by 1.5 to give some space for a smooth transition
+ (at the expense of the stretch factors, which are not fully respected
+ during the transition).
+ */
+ ultimateSize = ultimateSize * 3 / 2;
+ ultimateSumSizes = ultimateSumSizes * 3 / 2;
+
+ qreal beta = ultimateSumSizes - sumSizes;
+ if (!beta) {
+ factors[i] = 1;
+ } else {
+ qreal alpha = qMin(sumCurrentAvailable, beta);
+ qreal ultimateFactor = (stretch * ultimateSumSizes / sumStretches)
+ - (boxSize);
+ qreal transitionalFactor = sumCurrentAvailable * (ultimateSize - boxSize) / beta;
+
+ factors[i] = ((alpha * ultimateFactor)
+ + ((beta - alpha) * transitionalFactor)) / beta;
+ }
+
+ }
+ sumFactors += factors[i];
+ if (desired < sumCurrentAvailable)
+ somethingHasAMaximumSize = true;
+
+ newSizes[i] = -1.0;
+ }
+ }
+
+ bool keepGoing = somethingHasAMaximumSize;
+ while (keepGoing) {
+ keepGoing = false;
+
+ for (int i = 0; i < n; ++i) {
+ if (newSizes[i] >= 0.0)
+ continue;
+
+ qreal maxBoxSize;
+ if (isLargerThanMaximum)
+ maxBoxSize = rowInfo.boxes.value(start + i).q_maximumSize;
+ else
+ maxBoxSize = boxes.at(start + i).q_maximumSize;
+
+ qreal avail = sumCurrentAvailable * factors[i] / sumFactors;
+ if (sizes[i] + avail >= maxBoxSize) {
+ newSizes[i] = maxBoxSize;
+ sumCurrentAvailable -= maxBoxSize - sizes[i];
+ sumFactors -= factors[i];
+ keepGoing = (sumCurrentAvailable > 0.0);
+ if (!keepGoing)
+ break;
+ }
+ }
+ }
+
+ for (int i = 0; i < n; ++i) {
+ if (newSizes[i] < 0.0) {
+ qreal delta = (sumFactors == 0.0) ? 0.0
+ : sumCurrentAvailable * factors[i] / sumFactors;
+ newSizes[i] = sizes[i] + delta;
+ }
+ }
+ }
+ }
+
+ if (sumAvailable > 0) {
+ qreal offset = 0;
+ for (int i = 0; i < n; ++i) {
+ qreal delta = newSizes[i] - sizes[i];
+ positions[i] += offset;
+ sizes[i] += delta;
+ offset += delta;
+ }
+
+#if 0 // some "pixel allocation"
+ int surplus = targetSize - (positions[n - 1] + sizes[n - 1]);
+ Q_ASSERT(surplus >= 0 && surplus <= n);
+
+ int prevSurplus = -1;
+ while (surplus > 0 && surplus != prevSurplus) {
+ prevSurplus = surplus;
+
+ int offset = 0;
+ for (int i = 0; i < n; ++i) {
+ const QGridLayoutBox &box = boxes.at(start + i);
+ int delta = (!ignore.testBit(start + i) && surplus > 0
+ && factors[i] > 0 && sizes[i] < box.q_maximumSize)
+ ? 1 : 0;
+
+ positions[i] += offset;
+ sizes[i] += delta;
+ offset += delta;
+ surplus -= delta;
+ }
+ }
+ Q_ASSERT(surplus == 0);
+#endif
+ }
+
+ if (descents) {
+ for (int i = 0; i < n; ++i) {
+ if (ignore.testBit(start + i))
+ continue;
+ const QGridLayoutBox &box = boxes.at(start + i);
+ descents[i] = fixedDescent(box.q_minimumDescent, box.q_minimumAscent, sizes[i]);
+ }
+ }
+}
+
+QGridLayoutBox QGridLayoutRowData::totalBox(int start, int end) const
+{
+ QGridLayoutBox result;
+ if (start < end) {
+ result.q_maximumSize = 0.0;
+ qreal nextSpacing = 0.0;
+ for (int i = start; i < end; ++i) {
+ result.add(boxes.at(i), stretches.at(i), nextSpacing);
+ nextSpacing = spacings.at(i);
+ }
+ }
+ return result;
+}
+
+void QGridLayoutRowData::stealBox(int start, int end, int which, qreal *positions, qreal *sizes)
+{
+ qreal offset = 0.0;
+ qreal nextSpacing = 0.0;
+
+ for (int i = start; i < end; ++i) {
+ qreal avail = 0.0;
+
+ if (!ignore.testBit(i)) {
+ const QGridLayoutBox &box = boxes.at(i);
+ avail = box.q_sizes(which);
+ offset += nextSpacing;
+ nextSpacing = spacings.at(i);
+ }
+
+ *positions++ = offset;
+ *sizes++ = avail;
+ offset += avail;
+ }
+}
+
+#ifdef QT_DEBUG
+void QGridLayoutRowData::dump(int indent) const
+{
+ qDebug("%*sData", indent, "");
+
+ for (int i = 0; i < ignore.count(); ++i) {
+ qDebug("%*s Row %d (stretch %d, spacing %g)", indent, "", i, stretches.at(i),
+ spacings.at(i));
+ if (ignore.testBit(i))
+ qDebug("%*s Ignored", indent, "");
+ boxes.at(i).dump(indent + 2);
+ }
+
+ MultiCellMap::const_iterator it = multiCellMap.constBegin();
+ while (it != multiCellMap.constEnd()) {
+ qDebug("%*s Multi-cell entry <%d, %d> (stretch %d)", indent, "", it.key().first,
+ it.key().second, it.value().q_stretch);
+ it.value().q_box.dump(indent + 2);
+ }
+}
+#endif
+
+QGridLayoutItem::QGridLayoutItem(/*QGridLayoutEngine *engine, */
+ int row, int column, int rowSpan, int columnSpan,
+ Qt::Alignment alignment)
+ : /*###q_engine(engine), q_layoutItem(layoutItem), */q_alignment(alignment)
+{
+ q_firstRows[Hor] = column;
+ q_firstRows[Ver] = row;
+ q_rowSpans[Hor] = columnSpan;
+ q_rowSpans[Ver] = rowSpan;
+ q_stretches[Hor] = -1;
+ q_stretches[Ver] = -1;
+
+ //q_engine->insertItem(this, itemAtIndex);###
+}
+
+QGridLayoutItem::~QGridLayoutItem()
+{
+}
+
+int QGridLayoutItem::firstRow(Qt::Orientation orientation) const
+{
+ return q_firstRows[orientation == Qt::Vertical];
+}
+
+int QGridLayoutItem::firstColumn(Qt::Orientation orientation) const
+{
+ return q_firstRows[orientation == Qt::Horizontal];
+}
+
+int QGridLayoutItem::lastRow(Qt::Orientation orientation) const
+{
+ return firstRow(orientation) + rowSpan(orientation) - 1;
+}
+
+int QGridLayoutItem::lastColumn(Qt::Orientation orientation) const
+{
+ return firstColumn(orientation) + columnSpan(orientation) - 1;
+}
+
+int QGridLayoutItem::rowSpan(Qt::Orientation orientation) const
+{
+ return q_rowSpans[orientation == Qt::Vertical];
+}
+
+int QGridLayoutItem::columnSpan(Qt::Orientation orientation) const
+{
+ return q_rowSpans[orientation == Qt::Horizontal];
+}
+
+void QGridLayoutItem::setFirstRow(int row, Qt::Orientation orientation)
+{
+ q_firstRows[orientation == Qt::Vertical] = row;
+}
+
+void QGridLayoutItem::setRowSpan(int rowSpan, Qt::Orientation orientation)
+{
+ q_rowSpans[orientation == Qt::Vertical] = rowSpan;
+}
+
+int QGridLayoutItem::stretchFactor(Qt::Orientation orientation) const
+{
+ int stretch = q_stretches[orientation == Qt::Vertical];
+ if (stretch >= 0)
+ return stretch;
+
+ QLayoutPolicy::Policy policy = sizePolicy(orientation);
+
+ if (policy & QLayoutPolicy::ExpandFlag) {
+ return 1;
+ } else if (policy & QLayoutPolicy::GrowFlag) {
+ return -1; // because we max it up
+ } else {
+ return 0;
+ }
+}
+
+void QGridLayoutItem::setStretchFactor(int stretch, Qt::Orientation orientation)
+{
+ Q_ASSERT(stretch >= 0); // ### deal with too big stretches
+ q_stretches[orientation == Qt::Vertical] = stretch;
+}
+
+QLayoutPolicy::ControlTypes QGridLayoutItem::controlTypes(LayoutSide /*side*/) const
+{
+ return QLayoutPolicy::DefaultType; //###
+}
+
+QGridLayoutBox QGridLayoutItem::box(Qt::Orientation orientation, qreal constraint) const
+{
+ QGridLayoutBox result;
+ QLayoutPolicy::Policy policy = sizePolicy(orientation);
+
+ if (orientation == Qt::Horizontal) {
+ QSizeF constraintSize(-1.0, constraint);
+
+ result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).width();
+
+ if (policy & QLayoutPolicy::ShrinkFlag) {
+ result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).width();
+ } else {
+ result.q_minimumSize = result.q_preferredSize;
+ }
+
+ if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)) {
+ result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).width();
+ } else {
+ result.q_maximumSize = result.q_preferredSize;
+ }
+ } else {
+ QSizeF constraintSize(constraint, -1.0);
+
+ result.q_preferredSize = sizeHint(Qt::PreferredSize, constraintSize).height();
+
+ if (policy & QLayoutPolicy::ShrinkFlag) {
+ result.q_minimumSize = sizeHint(Qt::MinimumSize, constraintSize).height();
+ } else {
+ result.q_minimumSize = result.q_preferredSize;
+ }
+
+ if (policy & (QLayoutPolicy::GrowFlag | QLayoutPolicy::ExpandFlag)) {
+ result.q_maximumSize = sizeHint(Qt::MaximumSize, constraintSize).height();
+ } else {
+ result.q_maximumSize = result.q_preferredSize;
+ }
+
+ result.q_minimumDescent = sizeHint(Qt::MinimumDescent, constraintSize).height();
+ if (result.q_minimumDescent >= 0.0)
+ result.q_minimumAscent = result.q_minimumSize - result.q_minimumDescent;
+ }
+ if (policy & QLayoutPolicy::IgnoreFlag)
+ result.q_preferredSize = result.q_minimumSize;
+
+ return result;
+}
+
+QRectF QGridLayoutItem::geometryWithin(qreal x, qreal y, qreal width, qreal height,
+ qreal rowDescent, Qt::Alignment align) const
+{
+ rowDescent = -1.0; // ### This disables the descent
+
+ QGridLayoutBox vBox = box(Qt::Vertical);
+ if (vBox.q_minimumDescent < 0.0 || rowDescent < 0.0) {
+ qreal cellWidth = width;
+ qreal cellHeight = height;
+
+
+ QSizeF size = effectiveMaxSize(QSizeF(-1,-1));
+ if (hasDynamicConstraint()) {
+ if (dynamicConstraintOrientation() == Qt::Vertical) {
+ if (size.width() > cellWidth)
+ size = effectiveMaxSize(QSizeF(cellWidth, -1));
+ } else if (size.height() > cellHeight) {
+ size = effectiveMaxSize(QSizeF(-1, cellHeight));
+ }
+ }
+ size = size.boundedTo(QSizeF(cellWidth, cellHeight));
+ width = size.width();
+ height = size.height();
+
+ switch (align & Qt::AlignHorizontal_Mask) {
+ case Qt::AlignHCenter:
+ x += (cellWidth - width)/2;
+ break;
+ case Qt::AlignRight:
+ x += cellWidth - width;
+ break;
+ default:
+ break;
+ }
+ switch (align & Qt::AlignVertical_Mask) {
+ case Qt::AlignVCenter:
+ y += (cellHeight - height)/2;
+ break;
+ case Qt::AlignBottom:
+ y += cellHeight - height;
+ break;
+ default:
+ break;
+ }
+ return QRectF(x, y, width, height);
+ } else {
+ qreal descent = vBox.q_minimumDescent;
+ qreal ascent = vBox.q_minimumSize - descent;
+ return QRectF(x, y + height - rowDescent - ascent, width, ascent + descent);
+ }
+}
+
+void QGridLayoutItem::transpose()
+{
+ qSwap(q_firstRows[Hor], q_firstRows[Ver]);
+ qSwap(q_rowSpans[Hor], q_rowSpans[Ver]);
+ qSwap(q_stretches[Hor], q_stretches[Ver]);
+}
+
+void QGridLayoutItem::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation)
+{
+ int oldFirstRow = firstRow(orientation);
+ if (oldFirstRow >= row) {
+ setFirstRow(oldFirstRow + delta, orientation);
+ } else if (lastRow(orientation) >= row) {
+ setRowSpan(rowSpan(orientation) + delta, orientation);
+ }
+}
+/*!
+ \internal
+ returns the effective maximumSize, will take the sizepolicy into
+ consideration. (i.e. if sizepolicy does not have QLayoutPolicy::Grow, then
+ maxSizeHint will be the preferredSize)
+ Note that effectiveSizeHint does not take sizePolicy into consideration,
+ (since it only evaluates the hints, as the name implies)
+*/
+QSizeF QGridLayoutItem::effectiveMaxSize(const QSizeF &constraint) const
+{
+ QSizeF size = constraint;
+ bool vGrow = (sizePolicy(Qt::Vertical) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag;
+ bool hGrow = (sizePolicy(Qt::Horizontal) & QLayoutPolicy::GrowFlag) == QLayoutPolicy::GrowFlag;
+ if (!vGrow || !hGrow) {
+ QSizeF pref = sizeHint(Qt::PreferredSize, constraint);
+ if (!vGrow)
+ size.setHeight(pref.height());
+ if (!hGrow)
+ size.setWidth(pref.width());
+ }
+
+ if (!size.isValid()) {
+ QSizeF maxSize = sizeHint(Qt::MaximumSize, size);
+ if (size.width() == -1)
+ size.setWidth(maxSize.width());
+ if (size.height() == -1)
+ size.setHeight(maxSize.height());
+ }
+ return size;
+}
+
+#ifdef QT_DEBUG
+void QGridLayoutItem::dump(int indent) const
+{
+ qDebug("%*s (%d, %d) %d x %d", indent, "", firstRow(), firstColumn(), //###
+ rowSpan(), columnSpan());
+
+ if (q_stretches[Hor] >= 0)
+ qDebug("%*s Horizontal stretch: %d", indent, "", q_stretches[Hor]);
+ if (q_stretches[Ver] >= 0)
+ qDebug("%*s Vertical stretch: %d", indent, "", q_stretches[Ver]);
+ if (q_alignment != 0)
+ qDebug("%*s Alignment: %x", indent, "", uint(q_alignment));
+ qDebug("%*s Horizontal size policy: %x Vertical size policy: %x",
+ indent, "", sizePolicy(Qt::Horizontal), sizePolicy(Qt::Vertical));
+}
+#endif
+
+void QGridLayoutRowInfo::insertOrRemoveRows(int row, int delta)
+{
+ count += delta;
+
+ insertOrRemoveItems(stretches, row, delta);
+ insertOrRemoveItems(spacings, row, delta);
+ insertOrRemoveItems(alignments, row, delta);
+ insertOrRemoveItems(boxes, row, delta);
+}
+
+#ifdef QT_DEBUG
+void QGridLayoutRowInfo::dump(int indent) const
+{
+ qDebug("%*sInfo (count: %d)", indent, "", count);
+ for (int i = 0; i < count; ++i) {
+ QString message;
+
+ if (stretches.value(i).value() >= 0)
+ message += QString::fromLatin1(" stretch %1").arg(stretches.value(i).value());
+ if (spacings.value(i).value() >= 0.0)
+ message += QString::fromLatin1(" spacing %1").arg(spacings.value(i).value());
+ if (alignments.value(i) != 0)
+ message += QString::fromLatin1(" alignment %1").arg(int(alignments.value(i)), 16);
+
+ if (!message.isEmpty() || boxes.value(i) != QGridLayoutBox()) {
+ qDebug("%*s Row %d:%s", indent, "", i, qPrintable(message));
+ if (boxes.value(i) != QGridLayoutBox())
+ boxes.value(i).dump(indent + 1);
+ }
+ }
+}
+#endif
+
+QGridLayoutEngine::QGridLayoutEngine()
+{
+ m_visualDirection = Qt::LeftToRight;
+ invalidate();
+}
+
+int QGridLayoutEngine::rowCount(Qt::Orientation orientation) const
+{
+ return q_infos[orientation == Qt::Vertical].count;
+}
+
+int QGridLayoutEngine::columnCount(Qt::Orientation orientation) const
+{
+ return q_infos[orientation == Qt::Horizontal].count;
+}
+
+int QGridLayoutEngine::itemCount() const
+{
+ return q_items.count();
+}
+
+QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const
+{
+ Q_ASSERT(index >= 0 && index < itemCount());
+ return q_items.at(index);
+}
+
+int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const
+{
+ ensureEffectiveFirstAndLastRows();
+ return q_cachedEffectiveFirstRows[orientation == Qt::Vertical];
+}
+
+int QGridLayoutEngine::effectiveLastRow(Qt::Orientation orientation) const
+{
+ ensureEffectiveFirstAndLastRows();
+ return q_cachedEffectiveLastRows[orientation == Qt::Vertical];
+}
+
+void QGridLayoutEngine::setSpacing(qreal spacing, Qt::Orientations orientations)
+{
+ Q_ASSERT(spacing >= 0.0);
+ if (orientations & Qt::Horizontal)
+ q_defaultSpacings[Hor].setUserValue(spacing);
+ if (orientations & Qt::Vertical)
+ q_defaultSpacings[Ver].setUserValue(spacing);
+
+ invalidate();
+}
+
+qreal QGridLayoutEngine::spacing(Qt::Orientation orientation, const QLayoutStyleInfo &/*styleInfo*/) const
+{
+ if (q_defaultSpacings[orientation == Qt::Vertical].isDefault()) {
+ /* ###
+ if (QStyle *style = styleInfo.style()) {
+ QStyleOption option;
+ option.initFrom(styleInfo.widget());
+ qreal defaultSpacing = (qreal)style->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutVerticalSpacing
+ : QStyle::PM_LayoutHorizontalSpacing, &option, styleInfo.widget());
+ q_defaultSpacings[orientation == Qt::Vertical].setCachedValue(defaultSpacing);
+ }
+ */
+ }
+ return q_defaultSpacings[orientation == Qt::Vertical].value();
+}
+
+void QGridLayoutEngine::setRowSpacing(int row, qreal spacing, Qt::Orientation orientation)
+{
+ Q_ASSERT(row >= 0);
+
+ QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ if (row >= rowInfo.spacings.count())
+ rowInfo.spacings.resize(row + 1);
+ if (spacing >= 0)
+ rowInfo.spacings[row].setUserValue(spacing);
+ else
+ rowInfo.spacings[row] = QLayoutParameter<qreal>();
+ invalidate();
+}
+
+qreal QGridLayoutEngine::rowSpacing(int row, Qt::Orientation orientation) const
+{
+ QLayoutParameter<qreal> spacing = q_infos[orientation == Qt::Vertical].spacings.value(row);
+ if (!spacing.isDefault())
+ return spacing.value();
+ return q_defaultSpacings[orientation == Qt::Vertical].value();
+}
+
+void QGridLayoutEngine::setRowStretchFactor(int row, int stretch, Qt::Orientation orientation)
+{
+ Q_ASSERT(row >= 0);
+ Q_ASSERT(stretch >= 0);
+
+ maybeExpandGrid(row, -1, orientation);
+
+ QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ if (row >= rowInfo.stretches.count())
+ rowInfo.stretches.resize(row + 1);
+ rowInfo.stretches[row].setUserValue(stretch);
+}
+
+int QGridLayoutEngine::rowStretchFactor(int row, Qt::Orientation orientation) const
+{
+ QStretchParameter stretch = q_infos[orientation == Qt::Vertical].stretches.value(row);
+ if (!stretch.isDefault())
+ return stretch.value();
+ return 0;
+}
+/*
+void QGridLayoutEngine::setStretchFactor(QGraphicsLayoutItem *layoutItem, int stretch,
+ Qt::Orientation orientation)
+{
+ Q_ASSERT(stretch >= 0);
+
+ if (QGridLayoutItem *item = findLayoutItem(layoutItem))
+ item->setStretchFactor(stretch, orientation);
+}
+
+int QGridLayoutEngine::stretchFactor(QGraphicsLayoutItem *layoutItem, Qt::Orientation orientation) const
+{
+ if (QGridLayoutItem *item = findLayoutItem(layoutItem))
+ return item->stretchFactor(orientation);
+ return 0;
+}
+*/
+void QGridLayoutEngine::setRowSizeHint(Qt::SizeHint which, int row, qreal size,
+ Qt::Orientation orientation)
+{
+ Q_ASSERT(row >= 0);
+ Q_ASSERT(size >= 0.0);
+
+ maybeExpandGrid(row, -1, orientation);
+
+ QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ if (row >= rowInfo.boxes.count())
+ rowInfo.boxes.resize(row + 1);
+ rowInfo.boxes[row].q_sizes(which) = size;
+}
+
+qreal QGridLayoutEngine::rowSizeHint(Qt::SizeHint which, int row, Qt::Orientation orientation) const
+{
+ return q_infos[orientation == Qt::Vertical].boxes.value(row).q_sizes(which);
+}
+
+void QGridLayoutEngine::setRowAlignment(int row, Qt::Alignment alignment,
+ Qt::Orientation orientation)
+{
+ Q_ASSERT(row >= 0);
+
+ maybeExpandGrid(row, -1, orientation);
+
+ QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ if (row >= rowInfo.alignments.count())
+ rowInfo.alignments.resize(row + 1);
+ rowInfo.alignments[row] = alignment;
+}
+
+Qt::Alignment QGridLayoutEngine::rowAlignment(int row, Qt::Orientation orientation) const
+{
+ Q_ASSERT(row >= 0);
+ return q_infos[orientation == Qt::Vertical].alignments.value(row);
+}
+
+Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layoutItem) const
+{
+ Qt::Alignment align = layoutItem->alignment();
+ if (!(align & Qt::AlignVertical_Mask)) {
+ // no vertical alignment, respect the row alignment
+ int y = layoutItem->firstRow();
+ align |= (rowAlignment(y, Qt::Vertical) & Qt::AlignVertical_Mask);
+ if (!(align & Qt::AlignVertical_Mask))
+ align |= Qt::AlignVCenter;
+ }
+ if (!(align & Qt::AlignHorizontal_Mask)) {
+ // no horizontal alignment, respect the column alignment
+ int x = layoutItem->firstColumn();
+ align |= (rowAlignment(x, Qt::Horizontal) & Qt::AlignHorizontal_Mask);
+ if (!(align & Qt::AlignHorizontal_Mask))
+ align |= Qt::AlignHCenter;
+ }
+
+ return align;
+}
+
+/*!
+ \internal
+ The \a index is only used by QGraphicsLinearLayout to ensure that itemAt() reflects the order
+ of visual arrangement. Strictly speaking it does not have to, but most people expect it to.
+ (And if it didn't we would have to add itemArrangedAt(int index) or something..)
+ */
+void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index)
+{
+ maybeExpandGrid(item->lastRow(), item->lastColumn());
+
+ if (index == -1)
+ q_items.append(item);
+ else
+ q_items.insert(index, item);
+
+ for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
+ for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
+ if (itemAt(i, j))
+ qWarning("QGridLayoutEngine::addItem: Cell (%d, %d) already taken", i, j);
+ setItemAt(i, j, item);
+ }
+ }
+}
+
+void QGridLayoutEngine::addItem(QGridLayoutItem *item)
+{
+ insertItem(item, -1);
+}
+
+void QGridLayoutEngine::removeItem(QGridLayoutItem *item)
+{
+ Q_ASSERT(q_items.contains(item));
+
+ invalidate();
+
+ for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
+ for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
+ if (itemAt(i, j) == item)
+ setItemAt(i, j, 0);
+ }
+ }
+
+ q_items.removeAll(item);
+}
+
+
+QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation orientation) const
+{
+ if (orientation == Qt::Horizontal)
+ qSwap(row, column);
+ if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount()))
+ return 0;
+ return q_grid.at((row * internalGridColumnCount()) + column);
+}
+
+void QGridLayoutEngine::invalidate()
+{
+ q_cachedEffectiveFirstRows[Hor] = -1;
+ q_cachedEffectiveFirstRows[Ver] = -1;
+ q_cachedEffectiveLastRows[Hor] = -1;
+ q_cachedEffectiveLastRows[Ver] = -1;
+ q_cachedDataForStyleInfo.invalidate();
+ q_cachedSize = QSizeF();
+ q_cachedConstraintOrientation = UnknownConstraint;
+}
+
+static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
+{
+ if (dir == Qt::RightToLeft)
+ geom->moveRight(contentsRect.right() - (geom->left() - contentsRect.left()));
+}
+
+void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QLayoutStyleInfo &styleInfo)
+{
+ if (rowCount() < 1 || columnCount() < 1)
+ return;
+
+ ensureGeometries(contentsGeometry.size(), styleInfo);
+
+ for (int i = q_items.count() - 1; i >= 0; --i) {
+ QGridLayoutItem *item = q_items.at(i);
+
+ qreal x = q_xx[item->firstColumn()];
+ qreal y = q_yy[item->firstRow()];
+ qreal width = q_widths[item->lastColumn()];
+ qreal height = q_heights[item->lastRow()];
+
+ if (item->columnSpan() != 1)
+ width += q_xx[item->lastColumn()] - x;
+ if (item->rowSpan() != 1)
+ height += q_yy[item->lastRow()] - y;
+
+ QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y,
+ width, height, q_descents[item->lastRow()], effectiveAlignment(item));
+ visualRect(&geom, visualDirection(), contentsGeometry);
+ item->setGeometry(geom);
+ }
+}
+
+// ### candidate for deletion
+QRectF QGridLayoutEngine::cellRect(const QRectF &contentsGeometry, int row, int column, int rowSpan,
+ int columnSpan, const QLayoutStyleInfo &styleInfo) const
+{
+ if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())
+ || rowSpan < 1 || columnSpan < 1)
+ return QRectF();
+
+ ensureGeometries(contentsGeometry.size(), styleInfo);
+
+ int lastColumn = qMax(column + columnSpan, columnCount()) - 1;
+ int lastRow = qMax(row + rowSpan, rowCount()) - 1;
+
+ qreal x = q_xx[column];
+ qreal y = q_yy[row];
+ qreal width = q_widths[lastColumn];
+ qreal height = q_heights[lastRow];
+
+ if (columnSpan != 1)
+ width += q_xx[lastColumn] - x;
+ if (rowSpan != 1)
+ height += q_yy[lastRow] - y;
+
+ return QRectF(contentsGeometry.x() + x, contentsGeometry.y() + y, width, height);
+}
+
+QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint,
+ const QLayoutStyleInfo &styleInfo) const
+{
+ QGridLayoutBox sizehint_totalBoxes[NOrientations];
+
+ bool sizeHintCalculated = false;
+
+ if (hasDynamicConstraint() && rowCount() > 0 && columnCount() > 0) {
+ if (constraintOrientation() == Qt::Vertical) {
+ //We have items whose height depends on their width
+ if (constraint.width() >= 0) {
+ if (q_cachedDataForStyleInfo != styleInfo)
+ ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo);
+ else
+ sizehint_totalBoxes[Hor] = q_totalBoxes[Hor];
+ QVector<qreal> sizehint_xx;
+ QVector<qreal> sizehint_widths;
+
+ sizehint_xx.resize(columnCount());
+ sizehint_widths.resize(columnCount());
+ qreal width = constraint.width();
+ //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as
+ //constraints to find the row heights
+ q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(),
+ 0, sizehint_totalBoxes[Hor], q_infos[Hor]);
+ ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo);
+ sizeHintCalculated = true;
+ }
+ } else {
+ if (constraint.height() >= 0) {
+ //We have items whose width depends on their height
+ ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo);
+ QVector<qreal> sizehint_yy;
+ QVector<qreal> sizehint_heights;
+
+ sizehint_yy.resize(rowCount());
+ sizehint_heights.resize(rowCount());
+ qreal height = constraint.height();
+ //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as
+ //constraints to find the column widths
+ q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(),
+ 0, sizehint_totalBoxes[Ver], q_infos[Ver]);
+ ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo);
+ sizeHintCalculated = true;
+ }
+ }
+ }
+
+ if (!sizeHintCalculated) {
+ //No items with height for width, so it doesn't matter which order we do these in
+ if (q_cachedDataForStyleInfo != styleInfo) {
+ ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo);
+ ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo);
+ } else {
+ sizehint_totalBoxes[Hor] = q_totalBoxes[Hor];
+ sizehint_totalBoxes[Ver] = q_totalBoxes[Ver];
+ }
+ }
+
+ switch (which) {
+ case Qt::MinimumSize:
+ return QSizeF(sizehint_totalBoxes[Hor].q_minimumSize, sizehint_totalBoxes[Ver].q_minimumSize);
+ case Qt::PreferredSize:
+ return QSizeF(sizehint_totalBoxes[Hor].q_preferredSize, sizehint_totalBoxes[Ver].q_preferredSize);
+ case Qt::MaximumSize:
+ return QSizeF(sizehint_totalBoxes[Hor].q_maximumSize, sizehint_totalBoxes[Ver].q_maximumSize);
+ case Qt::MinimumDescent:
+ return QSizeF(-1.0, sizehint_totalBoxes[Hor].q_minimumDescent); // ### doesn't work
+ default:
+ break;
+ }
+ return QSizeF();
+}
+
+QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) const
+{
+ Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal;
+ int row = (side == Top || side == Left) ? effectiveFirstRow(orientation)
+ : effectiveLastRow(orientation);
+ QLayoutPolicy::ControlTypes result = 0;
+
+ for (int column = columnCount(orientation) - 1; column >= 0; --column) {
+ if (QGridLayoutItem *item = itemAt(row, column, orientation))
+ result |= item->controlTypes(side);
+ }
+ return result;
+}
+
+void QGridLayoutEngine::transpose()
+{
+ invalidate();
+
+ for (int i = q_items.count() - 1; i >= 0; --i)
+ q_items.at(i)->transpose();
+
+ qSwap(q_defaultSpacings[Hor], q_defaultSpacings[Ver]);
+ qSwap(q_infos[Hor], q_infos[Ver]);
+
+ regenerateGrid();
+}
+
+void QGridLayoutEngine::setVisualDirection(Qt::LayoutDirection direction)
+{
+ m_visualDirection = direction;
+}
+
+Qt::LayoutDirection QGridLayoutEngine::visualDirection() const
+{
+ return m_visualDirection;
+}
+
+#ifdef QT_DEBUG
+void QGridLayoutEngine::dump(int indent) const
+{
+ qDebug("%*sEngine", indent, "");
+
+ qDebug("%*s Items (%d)", indent, "", q_items.count());
+ int i;
+ for (i = 0; i < q_items.count(); ++i)
+ q_items.at(i)->dump(indent + 2);
+
+ qDebug("%*s Grid (%d x %d)", indent, "", internalGridRowCount(),
+ internalGridColumnCount());
+ for (int row = 0; row < internalGridRowCount(); ++row) {
+ QString message = QLatin1String("[ ");
+ for (int column = 0; column < internalGridColumnCount(); ++column) {
+ message += QString::number(q_items.indexOf(itemAt(row, column))).rightJustified(3);
+ message += QLatin1Char(' ');
+ }
+ message += QLatin1Char(']');
+ qDebug("%*s %s", indent, "", qPrintable(message));
+ }
+
+ if (q_defaultSpacings[Hor].value() >= 0.0 || q_defaultSpacings[Ver].value() >= 0.0)
+ qDebug("%*s Default spacings: %g %g", indent, "", q_defaultSpacings[Hor].value(),
+ q_defaultSpacings[Ver].value());
+
+ qDebug("%*s Column and row info", indent, "");
+ q_infos[Hor].dump(indent + 2);
+ q_infos[Ver].dump(indent + 2);
+
+ qDebug("%*s Column and row data", indent, "");
+ q_columnData.dump(indent + 2);
+ q_rowData.dump(indent + 2);
+
+ qDebug("%*s Geometries output", indent, "");
+ QVector<qreal> *cellPos = &q_yy;
+ for (int pass = 0; pass < 2; ++pass) {
+ QString message;
+ for (i = 0; i < cellPos->count(); ++i) {
+ message += QLatin1String((message.isEmpty() ? "[" : ", "));
+ message += QString::number(cellPos->at(i));
+ }
+ message += QLatin1Char(']');
+ qDebug("%*s %s %s", indent, "", (pass == 0 ? "rows:" : "columns:"), qPrintable(message));
+ cellPos = &q_xx;
+ }
+}
+#endif
+
+void QGridLayoutEngine::maybeExpandGrid(int row, int column, Qt::Orientation orientation)
+{
+ invalidate(); // ### move out of here?
+
+ if (orientation == Qt::Horizontal)
+ qSwap(row, column);
+
+ if (row < rowCount() && column < columnCount())
+ return;
+
+ int oldGridRowCount = internalGridRowCount();
+ int oldGridColumnCount = internalGridColumnCount();
+
+ q_infos[Ver].count = qMax(row + 1, rowCount());
+ q_infos[Hor].count = qMax(column + 1, columnCount());
+
+ int newGridRowCount = internalGridRowCount();
+ int newGridColumnCount = internalGridColumnCount();
+
+ int newGridSize = newGridRowCount * newGridColumnCount;
+ if (newGridSize != q_grid.count()) {
+ q_grid.resize(newGridSize);
+
+ if (newGridColumnCount != oldGridColumnCount) {
+ for (int i = oldGridRowCount - 1; i >= 1; --i) {
+ for (int j = oldGridColumnCount - 1; j >= 0; --j) {
+ int oldIndex = (i * oldGridColumnCount) + j;
+ int newIndex = (i * newGridColumnCount) + j;
+
+ Q_ASSERT(newIndex > oldIndex);
+ q_grid[newIndex] = q_grid[oldIndex];
+ q_grid[oldIndex] = 0;
+ }
+ }
+ }
+ }
+}
+
+void QGridLayoutEngine::regenerateGrid()
+{
+ q_grid.fill(0);
+
+ for (int i = q_items.count() - 1; i >= 0; --i) {
+ QGridLayoutItem *item = q_items.at(i);
+
+ for (int j = item->firstRow(); j <= item->lastRow(); ++j) {
+ for (int k = item->firstColumn(); k <= item->lastColumn(); ++k) {
+ setItemAt(j, k, item);
+ }
+ }
+ }
+}
+
+void QGridLayoutEngine::setItemAt(int row, int column, QGridLayoutItem *item)
+{
+ Q_ASSERT(row >= 0 && row < rowCount());
+ Q_ASSERT(column >= 0 && column < columnCount());
+ q_grid[(row * internalGridColumnCount()) + column] = item;
+}
+
+void QGridLayoutEngine::insertOrRemoveRows(int row, int delta, Qt::Orientation orientation)
+{
+ int oldRowCount = rowCount(orientation);
+ Q_ASSERT(uint(row) <= uint(oldRowCount));
+
+ invalidate();
+
+ // appending rows (or columns) is easy
+ if (row == oldRowCount && delta > 0) {
+ maybeExpandGrid(oldRowCount + delta - 1, -1, orientation);
+ return;
+ }
+
+ q_infos[orientation == Qt::Vertical].insertOrRemoveRows(row, delta);
+
+ for (int i = q_items.count() - 1; i >= 0; --i)
+ q_items.at(i)->insertOrRemoveRows(row, delta, orientation);
+
+ q_grid.resize(internalGridRowCount() * internalGridColumnCount());
+ regenerateGrid();
+}
+
+void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData,
+ qreal *colPositions, qreal *colSizes,
+ Qt::Orientation orientation,
+ const QLayoutStyleInfo &styleInfo) const
+{
+ const int ButtonMask = QLayoutPolicy::ButtonBox | QLayoutPolicy::PushButton;
+ const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ const QGridLayoutRowInfo &columnInfo = q_infos[orientation == Qt::Horizontal];
+ LayoutSide top = (orientation == Qt::Vertical) ? Top : Left;
+ LayoutSide bottom = (orientation == Qt::Vertical) ? Bottom : Right;
+
+ //QStyle *style = styleInfo.style();
+ /*###
+ QStyleOption option;
+ option.initFrom(styleInfo.widget());
+ */
+ const QLayoutParameter<qreal> &defaultSpacing = q_defaultSpacings[orientation == Qt::Vertical];
+ qreal innerSpacing = 0.0;
+ /* ###
+ if (style)
+ innerSpacing = (qreal)style->pixelMetric(orientation == Qt::Vertical ? QStyle::PM_LayoutVerticalSpacing
+ : QStyle::PM_LayoutHorizontalSpacing,
+ &option, styleInfo.widget());
+ */
+ if (innerSpacing >= 0.0)
+ defaultSpacing.setCachedValue(innerSpacing);
+
+ for (int row = 0; row < rowInfo.count; ++row) {
+ bool rowIsEmpty = true;
+ bool rowIsIdenticalToPrevious = (row > 0);
+
+ for (int column = 0; column < columnInfo.count; ++column) {
+ QGridLayoutItem *item = itemAt(row, column, orientation);
+
+ if (rowIsIdenticalToPrevious && item != itemAt(row - 1, column, orientation))
+ rowIsIdenticalToPrevious = false;
+
+ if (item)
+ rowIsEmpty = false;
+ }
+
+ if ((rowIsEmpty || rowIsIdenticalToPrevious)
+ && rowInfo.spacings.value(row).isDefault()
+ && rowInfo.stretches.value(row).isDefault()
+ && rowInfo.boxes.value(row) == QGridLayoutBox())
+ rowData->ignore.setBit(row, true);
+
+ if (rowInfo.spacings.value(row).isUser()) {
+ rowData->spacings[row] = rowInfo.spacings.at(row).value();
+ } else if (!defaultSpacing.isDefault()) {
+ rowData->spacings[row] = defaultSpacing.value();
+ }
+
+ rowData->stretches[row] = rowInfo.stretches.value(row).value();
+ }
+
+ struct RowAdHocData {
+ int q_row;
+ unsigned int q_hasButtons : 8;
+ unsigned int q_hasNonButtons : 8;
+
+ inline RowAdHocData() : q_row(-1), q_hasButtons(false), q_hasNonButtons(false) {}
+ inline void init(int row) {
+ this->q_row = row;
+ q_hasButtons = false;
+ q_hasNonButtons = false;
+ }
+ inline bool hasOnlyButtons() const { return q_hasButtons && !q_hasNonButtons; }
+ inline bool hasOnlyNonButtons() const { return q_hasNonButtons && !q_hasButtons; }
+ };
+ RowAdHocData lastRowAdHocData;
+ RowAdHocData nextToLastRowAdHocData;
+ RowAdHocData nextToNextToLastRowAdHocData;
+
+ rowData->hasIgnoreFlag = false;
+ for (int row = 0; row < rowInfo.count; ++row) {
+ if (rowData->ignore.testBit(row))
+ continue;
+
+ QGridLayoutBox &rowBox = rowData->boxes[row];
+ if (styleInfo.isWindow()) {
+ nextToNextToLastRowAdHocData = nextToLastRowAdHocData;
+ nextToLastRowAdHocData = lastRowAdHocData;
+ lastRowAdHocData.init(row);
+ }
+
+ bool userRowStretch = rowInfo.stretches.value(row).isUser();
+ int &rowStretch = rowData->stretches[row];
+
+ bool hasIgnoreFlag = true;
+ for (int column = 0; column < columnInfo.count; ++column) {
+ QGridLayoutItem *item = itemAt(row, column, orientation);
+ if (item) {
+ int itemRow = item->firstRow(orientation);
+ int itemColumn = item->firstColumn(orientation);
+
+ if (itemRow == row && itemColumn == column) {
+ int itemStretch = item->stretchFactor(orientation);
+ if (!(item->sizePolicy(orientation) & QLayoutPolicy::IgnoreFlag))
+ hasIgnoreFlag = false;
+ int itemRowSpan = item->rowSpan(orientation);
+
+ int effectiveRowSpan = 1;
+ for (int i = 1; i < itemRowSpan; ++i) {
+ if (!rowData->ignore.testBit(i))
+ ++effectiveRowSpan;
+ }
+
+ QGridLayoutBox *box;
+ if (effectiveRowSpan == 1) {
+ box = &rowBox;
+ if (!userRowStretch && itemStretch != 0)
+ rowStretch = qMax(rowStretch, itemStretch);
+ } else {
+ QGridLayoutMultiCellData &multiCell =
+ rowData->multiCellMap[qMakePair(row, effectiveRowSpan)];
+ box = &multiCell.q_box;
+ multiCell.q_stretch = itemStretch;
+ }
+ // Items with constraints need to be passed the constraint
+ if (colSizes && colPositions && item->hasDynamicConstraint() && orientation == item->dynamicConstraintOrientation()) {
+ /* Get the width of the item by summing up the widths of the columns that it spans.
+ * We need to have already calculated the widths of the columns by calling
+ * q_columns->calculateGeometries() before hand and passing the value in the colSizes
+ * and colPositions parameters.
+ * The variable name is still colSizes even when it actually has the row sizes
+ */
+ qreal length = colSizes[item->lastColumn(orientation)];
+ if (item->columnSpan(orientation) != 1)
+ length += colPositions[item->lastColumn(orientation)] - colPositions[item->firstColumn(orientation)];
+ box->combine(item->box(orientation, length));
+ } else {
+ box->combine(item->box(orientation));
+ }
+
+ if (effectiveRowSpan == 1) {
+ QLayoutPolicy::ControlTypes controls = item->controlTypes(top);
+ if (controls & ButtonMask)
+ lastRowAdHocData.q_hasButtons = true;
+ if (controls & ~ButtonMask)
+ lastRowAdHocData.q_hasNonButtons = true;
+ }
+ }
+ }
+ }
+ if (row < rowInfo.boxes.count()) {
+ QGridLayoutBox rowBoxInfo = rowInfo.boxes.at(row);
+ rowBoxInfo.normalize();
+ rowBox.q_minimumSize = qMax(rowBox.q_minimumSize, rowBoxInfo.q_minimumSize);
+ rowBox.q_maximumSize = qMax(rowBox.q_minimumSize,
+ (rowBoxInfo.q_maximumSize != FLT_MAX ?
+ rowBoxInfo.q_maximumSize : rowBox.q_maximumSize));
+ rowBox.q_preferredSize = qBound(rowBox.q_minimumSize,
+ qMax(rowBox.q_preferredSize, rowBoxInfo.q_preferredSize),
+ rowBox.q_maximumSize);
+ }
+ if (hasIgnoreFlag)
+ rowData->hasIgnoreFlag = true;
+ }
+
+ /*
+ Heuristic: Detect button boxes that don't use QLayoutPolicy::ButtonBox.
+ This is somewhat ad hoc but it usually does the trick.
+ */
+ bool lastRowIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
+ && nextToLastRowAdHocData.hasOnlyNonButtons());
+ bool lastTwoRowsIsButtonBox = (lastRowAdHocData.hasOnlyButtons()
+ && nextToLastRowAdHocData.hasOnlyButtons()
+ && nextToNextToLastRowAdHocData.hasOnlyNonButtons()
+ && orientation == Qt::Vertical);
+
+ if (defaultSpacing.isDefault()) {
+ int prevRow = -1;
+ for (int row = 0; row < rowInfo.count; ++row) {
+ if (rowData->ignore.testBit(row))
+ continue;
+
+ if (prevRow != -1 && !rowInfo.spacings.value(prevRow).isUser()) {
+ qreal &rowSpacing = rowData->spacings[prevRow];
+ for (int column = 0; column < columnInfo.count; ++column) {
+ QGridLayoutItem *item1 = itemAt(prevRow, column, orientation);
+ QGridLayoutItem *item2 = itemAt(row, column, orientation);
+
+ if (item1 && item2 && item1 != item2) {
+ QLayoutPolicy::ControlTypes controls1 = item1->controlTypes(bottom);
+ QLayoutPolicy::ControlTypes controls2 = item2->controlTypes(top);
+
+ if (controls2 & QLayoutPolicy::PushButton) {
+ if ((row == nextToLastRowAdHocData.q_row && lastTwoRowsIsButtonBox)
+ || (row == lastRowAdHocData.q_row && lastRowIsButtonBox)) {
+ controls2 &= ~QLayoutPolicy::PushButton;
+ controls2 |= QLayoutPolicy::ButtonBox;
+ }
+ }
+
+ qreal spacing = styleInfo.combinedLayoutSpacing(controls1, controls2,
+ orientation);
+ if (orientation == Qt::Horizontal) {
+ qreal width1 = rowData->boxes.at(prevRow).q_minimumSize;
+ qreal width2 = rowData->boxes.at(row).q_minimumSize;
+ QRectF rect1 = item1->geometryWithin(0.0, 0.0, width1, FLT_MAX, -1.0, effectiveAlignment(item1));
+ QRectF rect2 = item2->geometryWithin(0.0, 0.0, width2, FLT_MAX, -1.0, effectiveAlignment(item2));
+ spacing -= (width1 - (rect1.x() + rect1.width())) + rect2.x();
+ } else {
+ const QGridLayoutBox &box1 = rowData->boxes.at(prevRow);
+ const QGridLayoutBox &box2 = rowData->boxes.at(row);
+ qreal height1 = box1.q_minimumSize;
+ qreal height2 = box2.q_minimumSize;
+ qreal rowDescent1 = fixedDescent(box1.q_minimumDescent,
+ box1.q_minimumAscent, height1);
+ qreal rowDescent2 = fixedDescent(box2.q_minimumDescent,
+ box2.q_minimumAscent, height2);
+ QRectF rect1 = item1->geometryWithin(0.0, 0.0, FLT_MAX, height1,
+ rowDescent1, effectiveAlignment(item1));
+ QRectF rect2 = item2->geometryWithin(0.0, 0.0, FLT_MAX, height2,
+ rowDescent2, effectiveAlignment(item2));
+ spacing -= (height1 - (rect1.y() + rect1.height())) + rect2.y();
+ }
+ rowSpacing = qMax(spacing, rowSpacing);
+ }
+ }
+ }
+ prevRow = row;
+ }
+ } else if (lastRowIsButtonBox || lastTwoRowsIsButtonBox) {
+ /*
+ Even for styles that define a uniform spacing, we cheat a
+ bit and use the window margin as the spacing. This
+ significantly improves the look of dialogs.
+ */
+ int prevRow = lastRowIsButtonBox ? nextToLastRowAdHocData.q_row
+ : nextToNextToLastRowAdHocData.q_row;
+ if (!defaultSpacing.isUser() && !rowInfo.spacings.value(prevRow).isUser()) {
+ qreal windowMargin = styleInfo.windowMargin(orientation);
+ qreal &rowSpacing = rowData->spacings[prevRow];
+ rowSpacing = qMax(windowMargin, rowSpacing);
+ }
+ }
+}
+
+void QGridLayoutEngine::ensureEffectiveFirstAndLastRows() const
+{
+ if (q_cachedEffectiveFirstRows[Hor] == -1 && !q_items.isEmpty()) {
+ int rowCount = this->rowCount();
+ int columnCount = this->columnCount();
+
+ q_cachedEffectiveFirstRows[Ver] = rowCount;
+ q_cachedEffectiveFirstRows[Hor] = columnCount;
+ q_cachedEffectiveLastRows[Ver] = -1;
+ q_cachedEffectiveLastRows[Hor] = -1;
+
+ for (int i = q_items.count() - 1; i >= 0; --i) {
+ const QGridLayoutItem *item = q_items.at(i);
+
+ for (int j = 0; j < NOrientations; ++j) {
+ Qt::Orientation orientation = (j == Hor) ? Qt::Horizontal : Qt::Vertical;
+ if (item->firstRow(orientation) < q_cachedEffectiveFirstRows[j])
+ q_cachedEffectiveFirstRows[j] = item->firstRow(orientation);
+ if (item->lastRow(orientation) > q_cachedEffectiveLastRows[j])
+ q_cachedEffectiveLastRows[j] = item->lastRow(orientation);
+ }
+ }
+ }
+}
+
+void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox,
+ qreal *colPositions, qreal *colSizes,
+ Qt::Orientation orientation,
+ const QLayoutStyleInfo &styleInfo) const
+{
+ rowData->reset(rowCount(orientation));
+ fillRowData(rowData, colPositions, colSizes, orientation, styleInfo);
+ const QGridLayoutRowInfo &rowInfo = q_infos[orientation == Qt::Vertical];
+ rowData->distributeMultiCells(rowInfo);
+ *totalBox = rowData->totalBox(0, rowCount(orientation));
+ //We have items whose width depends on their height
+}
+
+/**
+ returns false if the layout has contradicting constraints (i.e. some items with a horizontal
+ constraint and other items with a vertical constraint)
+ */
+bool QGridLayoutEngine::ensureDynamicConstraint() const
+{
+ if (q_cachedConstraintOrientation == UnknownConstraint) {
+ for (int i = q_items.count() - 1; i >= 0; --i) {
+ QGridLayoutItem *item = q_items.at(i);
+ if (item->hasDynamicConstraint()) {
+ Qt::Orientation itemConstraintOrientation = item->dynamicConstraintOrientation();
+ if (q_cachedConstraintOrientation == UnknownConstraint) {
+ q_cachedConstraintOrientation = itemConstraintOrientation;
+ } else if (q_cachedConstraintOrientation != itemConstraintOrientation) {
+ q_cachedConstraintOrientation = UnfeasibleConstraint;
+ qWarning("QGridLayoutEngine: Unfeasible, cannot mix horizontal and"
+ " vertical constraint in the same layout");
+ return false;
+ }
+ }
+ }
+ if (q_cachedConstraintOrientation == UnknownConstraint)
+ q_cachedConstraintOrientation = NoConstraint;
+ }
+ return true;
+}
+
+bool QGridLayoutEngine::hasDynamicConstraint() const
+{
+ if (!ensureDynamicConstraint())
+ return false;
+ return q_cachedConstraintOrientation != NoConstraint;
+}
+
+/*
+ * return value is only valid if hasConstraint() returns true
+ */
+Qt::Orientation QGridLayoutEngine::constraintOrientation() const
+{
+ (void)ensureDynamicConstraint();
+ return (Qt::Orientation)q_cachedConstraintOrientation;
+}
+
+void QGridLayoutEngine::ensureGeometries(const QSizeF &size,
+ const QLayoutStyleInfo &styleInfo) const
+{
+ if (q_cachedDataForStyleInfo == styleInfo && q_cachedSize == size)
+ return;
+
+ q_cachedDataForStyleInfo = styleInfo;
+ q_cachedSize = size;
+
+ q_xx.resize(columnCount());
+ q_widths.resize(columnCount());
+ q_yy.resize(rowCount());
+ q_heights.resize(rowCount());
+ q_descents.resize(rowCount());
+
+ if (constraintOrientation() != Qt::Horizontal) {
+ //We might have items whose width depends on their height
+ ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo);
+ //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as
+ //constraints to find the row heights
+ q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(),
+ 0, q_totalBoxes[Hor], q_infos[Hor] );
+ ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo);
+ //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data()
+ q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(),
+ q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]);
+ } else {
+ //We have items whose height depends on their width
+ ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo);
+ //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as
+ //constraints to find the column widths
+ q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(),
+ q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]);
+ ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo);
+ //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data()
+ q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(),
+ 0, q_totalBoxes[Hor], q_infos[Hor]);
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/layouts/qgridlayoutengine_p.h b/src/layouts/qgridlayoutengine_p.h
new file mode 100644
index 00000000..a1a874cf
--- /dev/null
+++ b/src/layouts/qgridlayoutengine_p.h
@@ -0,0 +1,560 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRIDLAYOUTENGINE_P_H
+#define QGRIDLAYOUTENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the graphics view layout classes. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qalgorithms.h"
+#include "qbitarray.h"
+#include "qlist.h"
+#include "qmap.h"
+#include "qpair.h"
+#include "qvector.h"
+#include <QtCore/qsize.h>
+#include <QtCore/qrect.h>
+#include "qlayoutpolicy_p.h"
+#include <float.h>
+#include "qdebug.h"
+QT_BEGIN_NAMESPACE
+
+//class QGraphicsLayoutItem;
+class QStyle;
+class QWidget;
+
+class QStyleOption;
+// ### FIX THIS GUY
+class QLayoutStyleInfo
+{
+public:
+ inline QLayoutStyleInfo()
+ : m_valid(true), m_option(0)
+ {
+ m_defaultSpacing[0] = m_defaultSpacing[1] = 6;
+ }
+
+
+ QStyleOption *styleOption() {
+ if (!m_option) {
+ /* ###
+ m_option = new QStyleOption;
+ option.initFrom(styleInfo.widget());
+ */
+ }
+ return m_option;
+ }
+
+ void invalidate() { m_valid = false; }
+ inline QStyle *style() const { return 0; }
+ inline QWidget *widget() const { return 0; }
+ inline bool operator==(const QLayoutStyleInfo &other) const
+ { return m_defaultSpacing[0] == other.m_defaultSpacing[0] && m_defaultSpacing[1] == other.m_defaultSpacing[1] && m_valid == other.m_valid;}
+ inline bool operator!=(const QLayoutStyleInfo &other) const
+ { return !(*this == other); }
+
+ inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){
+ if (spacing >= 0)
+ m_defaultSpacing[o - 1] = spacing;
+ }
+
+ inline qreal defaultSpacing(Qt::Orientation o) const {
+ return m_defaultSpacing[o - 1];
+ }
+
+ inline qreal perItemSpacing(QLayoutPolicy::ControlType /*control1*/,
+ QLayoutPolicy::ControlType /*control2*/,
+ Qt::Orientation /*orientation*/) const
+ {
+ return 6;
+ }
+
+ inline qreal windowMargin(Qt::Orientation orientation) const
+ {
+ qreal margin = -1;
+ Q_UNUSED(orientation);
+ /*
+ if (style()) {
+ margin = style()->pixelMetric(orientation == Qt::Vertical
+ ? QStyle::PM_LayoutBottomMargin
+ : QStyle::PM_LayoutRightMargin,
+ styleOption(), widget());
+ }
+ */
+ return margin;
+ }
+
+ inline qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes controls1,
+ QLayoutPolicy::ControlTypes controls2, Qt::Orientation orientation) const
+ {
+ qreal spacing = -1;
+ Q_UNUSED(controls1);
+ Q_UNUSED(controls2);
+ Q_UNUSED(orientation);
+ /* ###
+ if (style()) {
+ spacing = style()->combinedLayoutSpacing(controls1, controls2,
+ orientation, styleOption(),
+ widget());
+ }*/
+ return spacing;
+ }
+
+ bool isWindow() const {
+ // return option.state & QStyle::State_Window
+ return false;
+ }
+private:
+ bool m_valid;
+ qreal m_defaultSpacing[2];
+ QStyleOption *m_option;
+};
+
+
+// ### deal with Descent in a similar way
+enum {
+ MinimumSize = Qt::MinimumSize,
+ PreferredSize = Qt::PreferredSize,
+ MaximumSize = Qt::MaximumSize,
+ NSizes
+};
+
+// do not reorder
+enum {
+ Hor,
+ Ver,
+ NOrientations
+};
+
+// do not reorder
+enum LayoutSide {
+ Left,
+ Top,
+ Right,
+ Bottom
+};
+
+enum {
+ NoConstraint,
+ HorizontalConstraint, // Width depends on the height
+ VerticalConstraint, // Height depends on the width
+ UnknownConstraint, // need to update cache
+ UnfeasibleConstraint // not feasible, it be has some items with Vertical and others with Horizontal constraints
+};
+
+template <typename T>
+class QLayoutParameter
+{
+public:
+ enum State { Default, User, Cached };
+
+ inline QLayoutParameter() : q_value(T()), q_state(Default) {}
+ inline QLayoutParameter(T value, State state = Default) : q_value(value), q_state(state) {}
+
+ inline void setUserValue(T value) {
+ q_value = value;
+ q_state = User;
+ }
+ inline void setCachedValue(T value) const {
+ if (q_state != User) {
+ q_value = value;
+ q_state = Cached;
+ }
+ }
+ inline T value() const { return q_value; }
+ inline T value(T defaultValue) const { return isUser() ? q_value : defaultValue; }
+ inline bool isDefault() const { return q_state == Default; }
+ inline bool isUser() const { return q_state == User; }
+ inline bool isCached() const { return q_state == Cached; }
+
+private:
+ mutable T q_value;
+ mutable State q_state;
+};
+
+class QStretchParameter : public QLayoutParameter<int>
+{
+public:
+ QStretchParameter() : QLayoutParameter<int>(-1) {}
+
+};
+
+class QGridLayoutBox
+{
+public:
+ inline QGridLayoutBox()
+ : q_minimumSize(0), q_preferredSize(0), q_maximumSize(FLT_MAX),
+ q_minimumDescent(-1), q_minimumAscent(-1) {}
+
+ void add(const QGridLayoutBox &other, int stretch, qreal spacing);
+ void combine(const QGridLayoutBox &other);
+ void normalize();
+
+#ifdef QT_DEBUG
+ void dump(int indent = 0) const;
+#endif
+ // This code could use the union-struct-array trick, but a compiler
+ // bug prevents this from working.
+ qreal q_minimumSize;
+ qreal q_preferredSize;
+ qreal q_maximumSize;
+ qreal q_minimumDescent;
+ qreal q_minimumAscent;
+ inline qreal &q_sizes(int which)
+ {
+ qreal *t;
+ switch (which) {
+ case Qt::MinimumSize:
+ t = &q_minimumSize;
+ break;
+ case Qt::PreferredSize:
+ t = &q_preferredSize;
+ break;
+ case Qt::MaximumSize:
+ t = &q_maximumSize;
+ break;
+ case Qt::MinimumDescent:
+ t = &q_minimumDescent;
+ break;
+ case (Qt::MinimumDescent + 1):
+ t = &q_minimumAscent;
+ break;
+ default:
+ t = 0;
+ break;
+ }
+ return *t;
+ }
+ inline const qreal &q_sizes(int which) const
+ {
+ const qreal *t;
+ switch (which) {
+ case Qt::MinimumSize:
+ t = &q_minimumSize;
+ break;
+ case Qt::PreferredSize:
+ t = &q_preferredSize;
+ break;
+ case Qt::MaximumSize:
+ t = &q_maximumSize;
+ break;
+ case Qt::MinimumDescent:
+ t = &q_minimumDescent;
+ break;
+ case (Qt::MinimumDescent + 1):
+ t = &q_minimumAscent;
+ break;
+ default:
+ t = 0;
+ break;
+ }
+ return *t;
+ }
+};
+
+bool operator==(const QGridLayoutBox &box1, const QGridLayoutBox &box2);
+inline bool operator!=(const QGridLayoutBox &box1, const QGridLayoutBox &box2)
+ { return !operator==(box1, box2); }
+
+class QGridLayoutMultiCellData
+{
+public:
+ inline QGridLayoutMultiCellData() : q_stretch(-1) {}
+
+ QGridLayoutBox q_box;
+ int q_stretch;
+};
+
+typedef QMap<QPair<int, int>, QGridLayoutMultiCellData> MultiCellMap;
+
+class QGridLayoutRowInfo;
+
+class QGridLayoutRowData
+{
+public:
+ void reset(int count);
+ void distributeMultiCells(const QGridLayoutRowInfo &rowInfo);
+ void calculateGeometries(int start, int end, qreal targetSize, qreal *positions, qreal *sizes,
+ qreal *descents, const QGridLayoutBox &totalBox,
+ const QGridLayoutRowInfo &rowInfo);
+ QGridLayoutBox totalBox(int start, int end) const;
+ void stealBox(int start, int end, int which, qreal *positions, qreal *sizes);
+
+#ifdef QT_DEBUG
+ void dump(int indent = 0) const;
+#endif
+
+ QBitArray ignore; // ### rename q_
+ QVector<QGridLayoutBox> boxes;
+ MultiCellMap multiCellMap;
+ QVector<int> stretches;
+ QVector<qreal> spacings;
+ bool hasIgnoreFlag;
+};
+
+class QGridLayoutItem
+{
+public:
+ QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1,
+ Qt::Alignment alignment = 0);
+ virtual ~QGridLayoutItem();
+
+ inline int firstRow() const { return q_firstRows[Ver]; }
+ inline int firstColumn() const { return q_firstRows[Hor]; }
+ inline int rowSpan() const { return q_rowSpans[Ver]; }
+ inline int columnSpan() const { return q_rowSpans[Hor]; }
+ inline int lastRow() const { return firstRow() + rowSpan() - 1; }
+ inline int lastColumn() const { return firstColumn() + columnSpan() - 1; }
+
+ int firstRow(Qt::Orientation orientation) const;
+ int firstColumn(Qt::Orientation orientation) const;
+ int lastRow(Qt::Orientation orientation) const;
+ int lastColumn(Qt::Orientation orientation) const;
+ int rowSpan(Qt::Orientation orientation) const;
+ int columnSpan(Qt::Orientation orientation) const;
+ void setFirstRow(int row, Qt::Orientation orientation = Qt::Vertical);
+ void setRowSpan(int rowSpan, Qt::Orientation orientation = Qt::Vertical);
+
+ int stretchFactor(Qt::Orientation orientation) const;
+ void setStretchFactor(int stretch, Qt::Orientation orientation);
+
+ inline Qt::Alignment alignment() const { return q_alignment; }
+ inline void setAlignment(Qt::Alignment alignment) { q_alignment = alignment; }
+
+ virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const = 0;
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const = 0;
+
+ virtual void setGeometry(const QRectF &rect) = 0;
+ /*
+ returns true if the size policy returns true for either hasHeightForWidth()
+ or hasWidthForHeight()
+ */
+ virtual bool hasDynamicConstraint() const { return false; }
+ virtual Qt::Orientation dynamicConstraintOrientation() const { return Qt::Horizontal; }
+
+
+ QLayoutPolicy::ControlTypes controlTypes(LayoutSide side) const;
+
+ QGridLayoutBox box(Qt::Orientation orientation, qreal constraint = -1.0) const;
+ QRectF geometryWithin(qreal x, qreal y, qreal width, qreal height, qreal rowDescent, Qt::Alignment align) const;
+
+
+ void transpose();
+ void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical);
+ QSizeF effectiveMaxSize(const QSizeF &constraint) const;
+
+#ifdef QT_DEBUG
+ void dump(int indent = 0) const;
+#endif
+
+//private:
+ //###QGridLayoutEngine *q_engine; // ### needed?
+ int q_firstRows[NOrientations];
+ int q_rowSpans[NOrientations];
+ int q_stretches[NOrientations];
+ Qt::Alignment q_alignment;
+};
+
+class QGridLayoutRowInfo
+{
+public:
+ inline QGridLayoutRowInfo() : count(0) {}
+
+ void insertOrRemoveRows(int row, int delta);
+
+#ifdef QT_DEBUG
+ void dump(int indent = 0) const;
+#endif
+
+ int count;
+ QVector<QStretchParameter> stretches;
+ QVector<QLayoutParameter<qreal> > spacings;
+ QVector<Qt::Alignment> alignments;
+ QVector<QGridLayoutBox> boxes;
+};
+
+class QGridLayoutEngine
+{
+public:
+ QGridLayoutEngine();
+ inline ~QGridLayoutEngine() { qDeleteAll(q_items); }
+
+ int rowCount(Qt::Orientation orientation) const;
+ int columnCount(Qt::Orientation orientation) const;
+ inline int rowCount() const { return q_infos[Ver].count; }
+ inline int columnCount() const { return q_infos[Hor].count; }
+ // returns the number of items inserted, which may be less than (rowCount * columnCount)
+ int itemCount() const;
+ QGridLayoutItem *itemAt(int index) const;
+
+ int effectiveFirstRow(Qt::Orientation orientation = Qt::Vertical) const;
+ int effectiveLastRow(Qt::Orientation orientation = Qt::Vertical) const;
+
+ void setSpacing(qreal spacing, Qt::Orientations orientations);
+ qreal spacing(Qt::Orientation orientation, const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+ // ### setSpacingAfterRow(), spacingAfterRow()
+ void setRowSpacing(int row, qreal spacing, Qt::Orientation orientation = Qt::Vertical);
+ qreal rowSpacing(int row, Qt::Orientation orientation = Qt::Vertical) const;
+
+ void setRowStretchFactor(int row, int stretch, Qt::Orientation orientation = Qt::Vertical);
+ int rowStretchFactor(int row, Qt::Orientation orientation = Qt::Vertical) const;
+
+ //void setStretchFactor(QGraphicsLayoutItem *layoutItem, int stretch,
+ // Qt::Orientation orientation);
+ //int stretchFactor(QGraphicsLayoutItem *layoutItem, Qt::Orientation orientation) const;
+
+ void setRowSizeHint(Qt::SizeHint which, int row, qreal size,
+ Qt::Orientation orientation = Qt::Vertical);
+ qreal rowSizeHint(Qt::SizeHint which, int row,
+ Qt::Orientation orientation = Qt::Vertical) const;
+
+ void setRowAlignment(int row, Qt::Alignment alignment, Qt::Orientation orientation);
+ Qt::Alignment rowAlignment(int row, Qt::Orientation orientation) const;
+
+ //void setAlignment(QGraphicsLayoutItem *layoutItem, Qt::Alignment alignment);
+ //Qt::Alignment alignment(QGraphicsLayoutItem *layoutItem) const;
+ Qt::Alignment effectiveAlignment(const QGridLayoutItem *layoutItem) const;
+
+
+ void insertItem(QGridLayoutItem *item, int index);
+ void addItem(QGridLayoutItem *item);
+ void removeItem(QGridLayoutItem *item);
+ void deleteItems()
+ {
+ const QList<QGridLayoutItem *> oldItems = q_items;
+ q_items.clear(); // q_items are used as input when the grid is regenerated in removeRows
+ // The following calls to removeRows are suboptimal
+ int rows = rowCount(Qt::Vertical);
+ removeRows(0, rows, Qt::Vertical);
+ rows = rowCount(Qt::Horizontal);
+ removeRows(0, rows, Qt::Horizontal);
+ qDeleteAll(oldItems);
+ }
+
+ QGridLayoutItem *itemAt(int row, int column, Qt::Orientation orientation = Qt::Vertical) const;
+ inline void insertRow(int row, Qt::Orientation orientation = Qt::Vertical)
+ { insertOrRemoveRows(row, +1, orientation); }
+ inline void removeRows(int row, int count, Qt::Orientation orientation)
+ { insertOrRemoveRows(row, -count, orientation); }
+
+ void invalidate();
+ void setGeometries(const QRectF &contentsGeometry, const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo());
+ QRectF cellRect(const QRectF &contentsGeometry, int row, int column, int rowSpan, int columnSpan,
+ const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint,
+ const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+
+ // heightForWidth / widthForHeight support
+ QSizeF dynamicallyConstrainedSizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
+ bool ensureDynamicConstraint() const;
+ bool hasDynamicConstraint() const;
+ Qt::Orientation constraintOrientation() const;
+
+
+ QLayoutPolicy::ControlTypes controlTypes(LayoutSide side) const;
+ void transpose();
+ void setVisualDirection(Qt::LayoutDirection direction);
+ Qt::LayoutDirection visualDirection() const;
+#ifdef QT_DEBUG
+ void dump(int indent = 0) const;
+#endif
+
+//private:
+ static int grossRoundUp(int n) { return ((n + 2) | 0x3) - 2; }
+
+ void maybeExpandGrid(int row, int column, Qt::Orientation orientation = Qt::Vertical);
+ void regenerateGrid();
+ inline int internalGridRowCount() const { return grossRoundUp(rowCount()); }
+ inline int internalGridColumnCount() const { return grossRoundUp(columnCount()); }
+ void setItemAt(int row, int column, QGridLayoutItem *item);
+ void insertOrRemoveRows(int row, int delta, Qt::Orientation orientation = Qt::Vertical);
+ void fillRowData(QGridLayoutRowData *rowData,
+ qreal *colPositions, qreal *colSizes,
+ Qt::Orientation orientation = Qt::Vertical, const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+ void ensureEffectiveFirstAndLastRows() const;
+ void ensureColumnAndRowData(QGridLayoutRowData *rowData, QGridLayoutBox *totalBox,
+ qreal *colPositions, qreal *colSizes,
+ Qt::Orientation orientation,
+ const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+
+ void ensureGeometries(const QSizeF &size, const QLayoutStyleInfo &styleInfo = QLayoutStyleInfo()) const;
+
+ // User input
+ QVector<QGridLayoutItem *> q_grid;
+ QList<QGridLayoutItem *> q_items;
+ QLayoutParameter<qreal> q_defaultSpacings[NOrientations];
+ QGridLayoutRowInfo q_infos[NOrientations];
+ Qt::LayoutDirection m_visualDirection;
+
+ // Lazily computed from the above user input
+ mutable int q_cachedEffectiveFirstRows[NOrientations];
+ mutable int q_cachedEffectiveLastRows[NOrientations];
+ mutable quint8 q_cachedConstraintOrientation : 3;
+
+ // Layout item input
+ mutable QLayoutStyleInfo q_cachedDataForStyleInfo;
+ mutable QGridLayoutRowData q_columnData;
+ mutable QGridLayoutRowData q_rowData;
+ mutable QGridLayoutBox q_totalBoxes[NOrientations];
+
+ // Output
+ mutable QSizeF q_cachedSize;
+ mutable QVector<qreal> q_xx;
+ mutable QVector<qreal> q_yy;
+ mutable QVector<qreal> q_widths;
+ mutable QVector<qreal> q_heights;
+ mutable QVector<qreal> q_descents;
+
+ friend class QGridLayoutItem;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/layouts/qlayoutpolicy.cpp b/src/layouts/qlayoutpolicy.cpp
new file mode 100644
index 00000000..9a154768
--- /dev/null
+++ b/src/layouts/qlayoutpolicy.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlayoutpolicy_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qdatastream.h>
+
+QT_BEGIN_NAMESPACE
+
+void QLayoutPolicy::setControlType(ControlType type)
+{
+ /*
+ The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10,
+ etc. In memory, we pack it onto the available bits (CTSize) in
+ setControlType(), and unpack it here.
+
+ Example:
+
+ 0x00000001 maps to 0
+ 0x00000002 maps to 1
+ 0x00000004 maps to 2
+ 0x00000008 maps to 3
+ etc.
+ */
+
+ int i = 0;
+ while (true) {
+ if (type & (0x1 << i)) {
+ bits.ctype = i;
+ return;
+ }
+ ++i;
+ }
+}
+
+QLayoutPolicy::ControlType QLayoutPolicy::controlType() const
+{
+ return QLayoutPolicy::ControlType(1 << bits.ctype);
+}
+
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \relates QLayoutPolicy
+
+ Writes the size \a policy to the data stream \a stream.
+
+ \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
+*/
+QDataStream &operator<<(QDataStream &stream, const QLayoutPolicy &policy)
+{
+ // The order here is for historical reasons. (compatibility with Qt4)
+ quint32 data = (policy.bits.horPolicy | // [0, 3]
+ policy.bits.verPolicy << 4 | // [4, 7]
+ policy.bits.hfw << 8 | // [8]
+ policy.bits.ctype << 9 | // [9, 13]
+ policy.bits.wfh << 14 | // [14]
+ //policy.bits.padding << 15 | // [15]
+ policy.bits.verStretch << 16 | // [16, 23]
+ policy.bits.horStretch << 24); // [24, 31]
+ return stream << data;
+}
+
+#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1))
+
+/*!
+ \relates QLayoutPolicy
+
+ Reads the size \a policy from the data stream \a stream.
+
+ \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
+*/
+QDataStream &operator>>(QDataStream &stream, QLayoutPolicy &policy)
+{
+ quint32 data;
+ stream >> data;
+ policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4);
+ policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4);
+ policy.bits.hfw = VALUE_OF_BITS(data, 8, 1);
+ policy.bits.ctype = VALUE_OF_BITS(data, 9, 5);
+ policy.bits.wfh = VALUE_OF_BITS(data, 14, 1);
+ policy.bits.padding = 0;
+ policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8);
+ policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8);
+ return stream;
+}
+#endif // QT_NO_DATASTREAM
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QLayoutPolicy &p)
+{
+ dbg.nospace() << "QLayoutPolicy(horizontalPolicy = " << p.horizontalPolicy()
+ << ", verticalPolicy = " << p.verticalPolicy() << ')';
+ return dbg.space();
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/layouts/qlayoutpolicy_p.h b/src/layouts/qlayoutpolicy_p.h
new file mode 100644
index 00000000..0f3e6a08
--- /dev/null
+++ b/src/layouts/qlayoutpolicy_p.h
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLAYOUTPOLICY_H
+#define QLAYOUTPOLICY_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+
+class QVariant;
+
+class QLayoutPolicy
+{
+ Q_ENUMS(Policy)
+
+public:
+ enum PolicyFlag {
+ GrowFlag = 1,
+ ExpandFlag = 2,
+ ShrinkFlag = 4,
+ IgnoreFlag = 8
+ };
+
+ enum Policy {
+ Fixed = 0,
+ Minimum = GrowFlag,
+ Maximum = ShrinkFlag,
+ Preferred = GrowFlag | ShrinkFlag,
+ MinimumExpanding = GrowFlag | ExpandFlag,
+ Expanding = GrowFlag | ShrinkFlag | ExpandFlag,
+ Ignored = ShrinkFlag | GrowFlag | IgnoreFlag
+ };
+
+ enum ControlType {
+ DefaultType = 0x00000001,
+ ButtonBox = 0x00000002,
+ CheckBox = 0x00000004,
+ ComboBox = 0x00000008,
+ Frame = 0x00000010,
+ GroupBox = 0x00000020,
+ Label = 0x00000040,
+ Line = 0x00000080,
+ LineEdit = 0x00000100,
+ PushButton = 0x00000200,
+ RadioButton = 0x00000400,
+ Slider = 0x00000800,
+ SpinBox = 0x00001000,
+ TabWidget = 0x00002000,
+ ToolButton = 0x00004000
+ };
+ Q_DECLARE_FLAGS(ControlTypes, ControlType)
+
+ QLayoutPolicy() : data(0) { }
+
+ QLayoutPolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType)
+ : data(0) {
+ bits.horPolicy = horizontal;
+ bits.verPolicy = vertical;
+ setControlType(type);
+ }
+ Policy horizontalPolicy() const { return static_cast<Policy>(bits.horPolicy); }
+ Policy verticalPolicy() const { return static_cast<Policy>(bits.verPolicy); }
+ ControlType controlType() const;
+
+ void setHorizontalPolicy(Policy d) { bits.horPolicy = d; }
+ void setVerticalPolicy(Policy d) { bits.verPolicy = d; }
+ void setControlType(ControlType type);
+
+ Qt::Orientations expandingDirections() const {
+ Qt::Orientations result;
+ if (verticalPolicy() & ExpandFlag)
+ result |= Qt::Vertical;
+ if (horizontalPolicy() & ExpandFlag)
+ result |= Qt::Horizontal;
+ return result;
+ }
+
+ void setHeightForWidth(bool b) { bits.hfw = b; }
+ bool hasHeightForWidth() const { return bits.hfw; }
+ void setWidthForHeight(bool b) { bits.wfh = b; }
+ bool hasWidthForHeight() const { return bits.wfh; }
+
+ bool operator==(const QLayoutPolicy& s) const { return data == s.data; }
+ bool operator!=(const QLayoutPolicy& s) const { return data != s.data; }
+
+ int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
+ int verticalStretch() const { return static_cast<int>(bits.verStretch); }
+ void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
+ void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); }
+
+ void transpose();
+
+
+private:
+#ifndef QT_NO_DATASTREAM
+ friend QDataStream &operator<<(QDataStream &, const QLayoutPolicy &);
+ friend QDataStream &operator>>(QDataStream &, QLayoutPolicy &);
+#endif
+ QLayoutPolicy(int i) : data(i) { }
+
+ union {
+ struct {
+ quint32 horStretch : 8;
+ quint32 verStretch : 8;
+ quint32 horPolicy : 4;
+ quint32 verPolicy : 4;
+ quint32 ctype : 5;
+ quint32 hfw : 1;
+ quint32 wfh : 1;
+ quint32 padding : 1; // feel free to use
+ } bits;
+ quint32 data;
+ };
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QLayoutPolicy::ControlTypes)
+
+#ifndef QT_NO_DATASTREAM
+QDataStream &operator<<(QDataStream &, const QLayoutPolicy &);
+QDataStream &operator>>(QDataStream &, QLayoutPolicy &);
+#endif
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QLayoutPolicy &);
+#endif
+
+inline void QLayoutPolicy::transpose() {
+ Policy hData = horizontalPolicy();
+ Policy vData = verticalPolicy();
+ int hStretch = horizontalStretch();
+ int vStretch = verticalStretch();
+ setHorizontalPolicy(vData);
+ setVerticalPolicy(hData);
+ setHorizontalStretch(vStretch);
+ setVerticalStretch(hStretch);
+}
+
+QT_END_NAMESPACE
+
+#endif // QLAYOUTPOLICY_H
diff --git a/src/layouts/qmldir b/src/layouts/qmldir
new file mode 100644
index 00000000..ec1d66a2
--- /dev/null
+++ b/src/layouts/qmldir
@@ -0,0 +1,3 @@
+module QtQuick.Layouts
+plugin qquicklayoutsplugin
+typeinfo plugins.qmltypes
diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h
new file mode 100644
index 00000000..dd26b1d6
--- /dev/null
+++ b/src/layouts/qquickgridlayoutengine_p.h
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKGRIDLAYOUTENGINE_P_H
+#define QQUICKGRIDLAYOUTENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the graphics view layout classes. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgridlayoutengine_p.h"
+#include "qquickitem.h"
+#include "qquicklayout_p.h"
+#include <QtWidgets/qsizepolicy.h>
+#include "qdebug.h"
+QT_BEGIN_NAMESPACE
+
+
+/*
+ The layout engine assumes:
+ 1. minimum <= preferred <= maximum
+ 2. descent is within minimum and maximum bounds (### verify)
+
+ This function helps to ensure that by the following rules (in the following order):
+ 1. If minimum > maximum, set minimum = maximum
+ 2. Make sure preferred is not outside the [minimum,maximum] range.
+ 3. If descent > minimum, set descent = minimum (### verify if this is correct, it might
+ need some refinements to multiline texts)
+
+ If any values are "not set" (i.e. 0 or less), they will be left untouched, so that we
+ know which values needs to be fetched from the implicit hints (not user hints).
+ */
+static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qreal &descent)
+{
+ if (minimum > 0 && maximum > 0 && minimum > maximum)
+ minimum = maximum;
+
+ if (preferred > 0) {
+ if (minimum > 0 && preferred < minimum) {
+ preferred = minimum;
+ } else if (maximum > 0 && preferred > maximum) {
+ preferred = maximum;
+ }
+ }
+
+ if (minimum > 0 && descent > minimum)
+ descent = minimum;
+}
+
+static void boundSize(QSizeF &result, const QSizeF &size)
+{
+ if (size.width() > 0 && size.width() < result.width())
+ result.setWidth(size.width());
+ if (size.height() > 0 && size.height() < result.height())
+ result.setHeight(size.height());
+}
+
+static void expandSize(QSizeF &result, const QSizeF &size)
+{
+ if (size.width() > 0 && size.width() > result.width())
+ result.setWidth(size.width());
+ if (size.height() > 0 && size.height() > result.height())
+ result.setHeight(size.height());
+}
+
+static inline void combineHints(qreal &current, qreal fallbackHint)
+{
+ if (current <= 0)
+ current = fallbackHint;
+}
+
+class QQuickGridLayoutItem : public QGridLayoutItem {
+public:
+ QQuickGridLayoutItem(QQuickItem *item, int row, int column,
+ int rowSpan = 1, int columnSpan = 1, Qt::Alignment alignment = 0)
+ : QGridLayoutItem(row, column, rowSpan, columnSpan, alignment), m_item(item), sizeHintCacheDirty(true) {}
+
+
+ typedef qreal (QQuickLayoutAttached::*SizeGetter)() const;
+
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+ {
+ Q_UNUSED(constraint); // Quick Layouts does not support constraint atm
+ return effectiveSizeHints()[which];
+ }
+
+ QSizeF *effectiveSizeHints() const
+ {
+ if (!sizeHintCacheDirty)
+ return cachedSizeHints;
+
+ QQuickLayoutAttached *info = 0;
+ // First, retrieve the user-specified hints from the attached "Layout." properties
+ if (QObject *attached = qmlAttachedPropertiesObject<QQuickLayout>(m_item, false)) {
+ info = static_cast<QQuickLayoutAttached *>(attached);
+
+ struct Getters {
+ SizeGetter call[NSizes];
+ };
+
+ static Getters horGetters = {
+ {&QQuickLayoutAttached::minimumWidth, &QQuickLayoutAttached::preferredWidth, &QQuickLayoutAttached::maximumWidth},
+ };
+
+ static Getters verGetters = {
+ {&QQuickLayoutAttached::minimumHeight, &QQuickLayoutAttached::preferredHeight, &QQuickLayoutAttached::maximumHeight}
+ };
+ for (int i = 0; i < NSizes; ++i) {
+ SizeGetter getter = horGetters.call[i];
+ Q_ASSERT(getter);
+ cachedSizeHints[i].setWidth((info->*getter)());
+ getter = verGetters.call[i];
+ Q_ASSERT(getter);
+ cachedSizeHints[i].setHeight((info->*getter)());
+ }
+ } else {
+ for (int i = 0; i < NSizes; ++i)
+ cachedSizeHints[i] = QSize();
+ }
+ cachedSizeHints[Qt::MinimumDescent] = QSize(); //### FIXME when baseline support is added
+
+ QSizeF &minS = cachedSizeHints[Qt::MinimumSize];
+ QSizeF &prefS = cachedSizeHints[Qt::PreferredSize];
+ QSizeF &maxS = cachedSizeHints[Qt::MaximumSize];
+ QSizeF &descentS = cachedSizeHints[Qt::MinimumDescent];
+
+ // For instance, will normalize the following user-set hints
+ // from: [10, 5, 60]
+ // to: [10, 10, 60]
+ normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth());
+ normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight());
+/*
+ The following table illustrates the preference of the properties used for measuring layout
+ items. If present, the USER properties will be preferred. If USER properties are not present,
+ the HINT 1 properties will be preferred. Finally, the HINT 2 properties will be used as an
+ ultimate fallback.
+
+ | USER | HINT 1 | HINT 2
+ -----+--------------------------------+-------------------+-------
+ MIN | Layout.minimumWidth | | 0
+ PREF | Layout.preferredWidth | implicitWidth | width
+ MAX | Layout.maximumWidth | | 100000
+ -----+--------------------------------+-------------------+--------
+ Fixed | Layout.fillWidth | Expanding if layout, Fixed if item |
+
+*/
+ //--- GATHER MINIMUM SIZE HINTS ---
+ // They are always 0
+
+ //--- GATHER PREFERRED SIZE HINTS ---
+ // First, from implicitWidth/Height
+ qreal &prefWidth = prefS.rwidth();
+ qreal &prefHeight = prefS.rheight();
+ combineHints(prefWidth, m_item->implicitWidth());
+ combineHints(prefHeight, m_item->implicitHeight());
+
+ // If that fails, make an ultimate fallback to width/height
+
+ if (!info && (prefWidth <= 0 || prefHeight <= 0))
+ info = static_cast<QQuickLayoutAttached *>(qmlAttachedPropertiesObject<QQuickLayout>(m_item));
+
+ if (info) {
+ /* This block is a bit hacky, but if we want to support using width/height
+ as preferred size hints in layouts, (which we think most people expect),
+ we only want to use the initial width.
+ This is because the width will change due to layout rearrangement, and the preferred
+ width should return the same value, regardless of the current width.
+ We therefore store the width in the Layout.preferredWidth attached property.
+ Since the layout listens to changes of Layout.preferredWidth, (it will
+ basically cause an invalidation of the layout, we have to disable that
+ notification while we set the preferred width.
+ */
+ //### Breaks with items that has Layout.preferredWidth: 0
+ const bool was = info->setChangesNotificationEnabled(false);
+ if (prefWidth <= 0) {
+ prefWidth = m_item->width();
+ info->setPreferredWidth(prefWidth);
+ }
+ if (prefHeight <= 0) {
+ prefHeight = m_item->height();
+ info->setPreferredHeight(prefHeight);
+ }
+ info->setChangesNotificationEnabled(was);
+ }
+ //--- GATHER MAXIMUM SIZE HINTS ---
+ // They are always q_declarativeLayoutMaxSize
+ combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), q_declarativeLayoutMaxSize);
+ combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), q_declarativeLayoutMaxSize);
+
+ //--- GATHER DESCENT
+ // ### Not implemented
+
+
+ // Normalize again after the implicit hints have been gathered
+ // (using different rules than normalizeHints actually??))
+ // This is consistent with QGraphicsLayoutItemPrivate::effectiveSizeHints()
+/*
+The following shows how the different [min,pref,max] combinations are normalized after performing
+each normalization stage (maxS, minS and prefS):
+
+input [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 2, 1] [3, 1, 2]
+------------------------------------------------------------------
+maxS [1, 2, 3] [1, 3, 3] [2, 1, 3] [2, 3, 3] [3, 2, 3] [3, 1, 3]
+minS [1, 2, 3] [1, 3, 3] [1, 1, 3] [2, 3, 3] [2, 2, 3] [1, 1, 3]
+prefS [1, 2, 3] [1, 3, 3] [1, 1, 3] [2, 3, 3] [2, 2, 3] [1, 1, 3] ###No change here.
+*/
+ expandSize(minS, QSizeF(0,0));
+ boundSize(minS, maxS);
+ expandSize(prefS, minS);
+ boundSize(prefS, maxS);
+ //expandSize(maxS, prefS); // [3,2,1] > [3,2,2]
+ //expandSize(maxS, minS);
+ //boundSize(maxS, QSizeF(q_declarativeLayoutMaxSize, q_declarativeLayoutMaxSize));
+
+
+ //boundSize(minS, prefS); // [3,2,1] > [2,2,1]
+ //boundSize(minS, maxS);
+
+ // Both of these are invariants and inconsistent with the above combinations of the
+ // "symmetric" combination (i.e. boundSize(minS, prefS) and expandSize(maxS, prefS)
+ //expandSize(prefS, minS); //[3,2,1] > [3,3,1]
+ //boundSize(prefS, maxS); //[3,2,1] > [3,1,1]
+
+ sizeHintCacheDirty = false;
+ return cachedSizeHints;
+ }
+
+ void invalidate()
+ {
+ quickLayoutDebug() << "engine::invalidate()";
+ sizeHintCacheDirty = true;
+ }
+
+ QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const
+ {
+ bool fillExtent = false;
+ bool isSet = false;
+ if (QQuickLayoutAttached *info = attachedLayoutObject(m_item, false)) {
+ if (orientation == Qt::Horizontal) {
+ isSet = info->isFillWidthSet();
+ if (isSet) fillExtent = info->fillWidth();
+ } else {
+ isSet = info->isFillHeightSet();
+ if (isSet) fillExtent = info->fillHeight();
+ }
+ }
+ if (!isSet && qobject_cast<QQuickLayout*>(m_item))
+ fillExtent = true;
+ return fillExtent ? QLayoutPolicy::Preferred : QLayoutPolicy::Fixed;
+ }
+
+ void setGeometry(const QRectF &rect)
+ {
+ m_item->setPosition(rect.topLeft());
+ m_item->setSize(rect.size());
+ }
+
+ QQuickItem *layoutItem() const { return m_item; }
+
+ QQuickItem *m_item;
+private:
+ mutable QSizeF cachedSizeHints[Qt::NSizeHints];
+ mutable bool sizeHintCacheDirty;
+};
+
+class QQuickGridLayoutEngine : public QGridLayoutEngine {
+public:
+ QQuickGridLayoutEngine() : QGridLayoutEngine() {} //### not needed
+
+ int indexOf(QQuickItem *item) const {
+ for (int i = 0; i < q_items.size(); ++i) {
+ if (item == static_cast<QQuickGridLayoutItem*>(q_items.at(i))->layoutItem())
+ return i;
+ }
+ return -1;
+ }
+
+ QQuickGridLayoutItem *findLayoutItem(QQuickItem *layoutItem) const
+ {
+ for (int i = q_items.count() - 1; i >= 0; --i) {
+ QQuickGridLayoutItem *item = static_cast<QQuickGridLayoutItem*>(q_items.at(i));
+ if (item->layoutItem() == layoutItem)
+ return item;
+ }
+ return 0;
+ }
+};
+
+
+
+QT_END_NAMESPACE
+
+#endif // QQUICKGRIDLAYOUTENGINE_P_H
diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp
new file mode 100644
index 00000000..77c3d443
--- /dev/null
+++ b/src/layouts/qquicklayout.cpp
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklayout_p.h"
+#include <QEvent>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qnumeric.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
+ : QObject(parent),
+ m_minimumWidth(0),
+ m_minimumHeight(0),
+ m_preferredWidth(0),
+ m_preferredHeight(0),
+ m_maximumWidth(q_declarativeLayoutMaxSize),
+ m_maximumHeight(q_declarativeLayoutMaxSize),
+ m_row(0),
+ m_column(0),
+ m_rowSpan(1),
+ m_columnSpan(1),
+ m_fillWidth(false),
+ m_fillHeight(false),
+ m_isFillWidthSet(false),
+ m_isFillHeightSet(false),
+ m_changesNotificationEnabled(true)
+{
+
+}
+
+void QQuickLayoutAttached::setMinimumWidth(qreal width)
+{
+ if (qIsNaN(width) || m_minimumWidth == width)
+ return;
+
+ m_minimumWidth = width;
+ invalidateItem();
+ emit minimumWidthChanged();
+}
+
+void QQuickLayoutAttached::setMinimumHeight(qreal height)
+{
+ if (qIsNaN(height) || m_minimumHeight == height)
+ return;
+
+ m_minimumHeight = height;
+ invalidateItem();
+ emit minimumHeightChanged();
+}
+
+void QQuickLayoutAttached::setPreferredWidth(qreal width)
+{
+ if (qIsNaN(width) || m_preferredWidth == width)
+ return;
+
+ m_preferredWidth = width;
+ if (m_changesNotificationEnabled)
+ invalidateItem();
+ emit preferredWidthChanged();
+}
+
+void QQuickLayoutAttached::setPreferredHeight(qreal height)
+{
+ if (qIsNaN(height) || m_preferredHeight == height)
+ return;
+
+ m_preferredHeight = height;
+ if (m_changesNotificationEnabled)
+ invalidateItem();
+ emit preferredHeightChanged();
+}
+
+void QQuickLayoutAttached::setMaximumWidth(qreal width)
+{
+ if (qIsNaN(width) || m_maximumWidth == width)
+ return;
+
+ m_maximumWidth = width;
+ invalidateItem();
+ emit maximumWidthChanged();
+}
+
+void QQuickLayoutAttached::setMaximumHeight(qreal height)
+{
+ if (qIsNaN(height) || m_maximumHeight == height)
+ return;
+
+ m_maximumHeight = height;
+ invalidateItem();
+ emit maximumHeightChanged();
+}
+
+void QQuickLayoutAttached::setFillWidth(bool fill)
+{
+ m_isFillWidthSet = true;
+ if (m_fillWidth != fill) {
+ m_fillWidth = fill;
+ invalidateItem();
+ emit fillWidthChanged();
+ }
+}
+
+void QQuickLayoutAttached::setFillHeight(bool fill)
+{
+ m_isFillHeightSet = true;
+ if (m_fillHeight != fill) {
+ m_fillHeight = fill;
+ invalidateItem();
+ emit fillHeightChanged();
+ }
+}
+
+void QQuickLayoutAttached::invalidateItem()
+{
+ quickLayoutDebug() << "QQuickLayoutAttached::invalidateItem";
+ if (QQuickLayout *layout = parentLayout()) {
+ layout->invalidate(item());
+ }
+}
+
+QQuickLayout *QQuickLayoutAttached::parentLayout() const
+{
+ QQuickItem *parentItem = item()->parentItem();
+ if (qobject_cast<QQuickLayout *>(parentItem))
+ return static_cast<QQuickLayout *>(parentItem);
+ return 0;
+}
+
+QQuickItem *QQuickLayoutAttached::item() const
+{
+ Q_ASSERT(qobject_cast<QQuickItem*>(parent()));
+ return static_cast<QQuickItem*>(parent());
+}
+
+
+
+
+
+QQuickLayout::QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent)
+ : QQuickItem(dd, parent),
+ m_dirty(false)
+{
+}
+
+QQuickLayout::~QQuickLayout()
+{
+
+}
+
+void QQuickLayout::setupItemLayout(QQuickItem *item)
+{
+ //### not needed anymore, since these are deducted from hierarcy?
+ qmlAttachedPropertiesObject<QQuickLayout>(item);
+}
+
+QQuickLayoutAttached *QQuickLayout::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickLayoutAttached(object);
+}
+
+bool QQuickLayout::event(QEvent *e)
+{
+ if (e->type() == QEvent::LayoutRequest)
+ rearrange(QSizeF(width(), height()));
+
+ return QQuickItem::event(e);
+}
+
+void QQuickLayout::componentComplete()
+{
+ QQuickItem::componentComplete();
+}
+
+void QQuickLayout::invalidate(QQuickItem * /*childItem*/)
+{
+ if (m_dirty)
+ return;
+
+ m_dirty = true;
+
+ if (QQuickLayout *parentLayout = qobject_cast<QQuickLayout *>(parentItem())) {
+ parentLayout->invalidate(this);
+ } else {
+ quickLayoutDebug() << "QQuickLayout::invalidate(), postEvent";
+ QCoreApplication::postEvent(this, new QEvent(QEvent::LayoutRequest));
+ }
+}
+
+void QQuickLayout::rearrange(const QSizeF &/*size*/)
+{
+ m_dirty = false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h
new file mode 100644
index 00000000..ad1f2df5
--- /dev/null
+++ b/src/layouts/qquicklayout_p.h
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLAYOUT_P_H
+#define QQUICKLAYOUT_P_H
+
+#include <QPointer>
+#include <QQuickItem>
+#include <private/qquickitem_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickLayoutAttached;
+
+static const qreal q_declarativeLayoutMaxSize = 10e8;
+
+#if 0 && !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_OUTPUT)
+# define quickLayoutDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug
+#else
+# define quickLayoutDebug QT_NO_QWARNING_MACRO
+#endif
+
+class QQuickLayoutPrivate;
+class QQuickLayout : public QQuickItem
+{
+ Q_OBJECT
+public:
+ enum SizeHint {
+ MinimumSize = 0,
+ PreferredSize,
+ MaximumSize,
+ NSizes
+ };
+
+ explicit QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent = 0);
+ ~QQuickLayout();
+
+ static QQuickLayoutAttached *qmlAttachedProperties(QObject *object);
+
+
+ void componentComplete();
+ virtual void invalidate(QQuickItem * childItem = 0);
+protected:
+ bool event(QEvent *e);
+ virtual void rearrange(const QSizeF &);
+ void setupItemLayout(QQuickItem *item);
+
+
+ enum Orientation {
+ Vertical = 0,
+ Horizontal,
+ NOrientations
+ };
+
+private:
+ bool m_dirty;
+
+ Q_DECLARE_PRIVATE(QQuickLayout)
+
+ friend class QQuickLayoutAttached;
+};
+
+
+class QQuickLayoutPrivate : public QQuickItemPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickLayout)
+};
+
+
+class QQuickLayoutAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
+ Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
+ Q_PROPERTY(qreal preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
+ Q_PROPERTY(qreal preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
+ Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
+ Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
+ Q_PROPERTY(bool fillHeight READ fillHeight WRITE setFillHeight)
+ Q_PROPERTY(bool fillWidth READ fillWidth WRITE setFillWidth)
+ Q_PROPERTY(int row READ row WRITE setRow)
+ Q_PROPERTY(int column READ column WRITE setColumn)
+ Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan)
+ Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan)
+
+public:
+ QQuickLayoutAttached(QObject *object);
+
+ qreal minimumWidth() const { return m_minimumWidth; }
+ void setMinimumWidth(qreal width);
+
+ qreal minimumHeight() const { return m_minimumHeight; }
+ void setMinimumHeight(qreal height);
+
+ qreal preferredWidth() const { return m_preferredWidth; }
+ void setPreferredWidth(qreal width);
+
+ qreal preferredHeight() const { return m_preferredHeight; }
+ void setPreferredHeight(qreal width);
+
+ qreal maximumWidth() const { return m_maximumWidth; }
+ void setMaximumWidth(qreal width);
+
+ qreal maximumHeight() const { return m_maximumHeight; }
+ void setMaximumHeight(qreal height);
+
+ bool fillWidth() const { return m_fillWidth; }
+ void setFillWidth(bool fill);
+ bool isFillWidthSet() const { return m_isFillWidthSet; }
+
+ bool fillHeight() const { return m_fillHeight; }
+ void setFillHeight(bool fill);
+ bool isFillHeightSet() const { return m_isFillHeightSet; }
+
+ int row() const { return m_row; }
+ void setRow(int row) { m_row = row; }
+ int column() const { return m_column; }
+ void setColumn(int column) { m_column = column; }
+
+ int rowSpan() const { return m_rowSpan; }
+ void setRowSpan(int span) { m_rowSpan = span; }
+ int columnSpan() const { return m_columnSpan; }
+ void setColumnSpan(int span) { m_columnSpan = span; }
+
+ bool setChangesNotificationEnabled(bool enabled)
+ {
+ const bool old = m_changesNotificationEnabled;
+ m_changesNotificationEnabled = enabled;
+ return old;
+ }
+
+signals:
+ void minimumWidthChanged();
+ void minimumHeightChanged();
+ void preferredWidthChanged();
+ void preferredHeightChanged();
+ void maximumWidthChanged();
+ void maximumHeightChanged();
+ void fillWidthChanged();
+ void fillHeightChanged();
+
+private:
+ void invalidateItem();
+ QQuickLayout *parentLayout() const;
+ QQuickItem *item() const;
+private:
+ qreal m_minimumWidth;
+ qreal m_minimumHeight;
+ qreal m_preferredWidth;
+ qreal m_preferredHeight;
+ qreal m_maximumWidth;
+ qreal m_maximumHeight;
+
+ // GridLayout specific properties
+ int m_row;
+ int m_column;
+ int m_rowSpan;
+ int m_columnSpan;
+
+ unsigned m_fillWidth : 1;
+ unsigned m_fillHeight : 1;
+ unsigned m_isFillWidthSet : 1;
+ unsigned m_isFillHeightSet : 1;
+ unsigned m_changesNotificationEnabled : 1;
+ friend class QQuickLayout;
+};
+
+inline QQuickLayoutAttached *attachedLayoutObject(QQuickItem *item, bool create = true)
+{
+ return static_cast<QQuickLayoutAttached *>(qmlAttachedPropertiesObject<QQuickLayout>(item, create));
+}
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickLayout)
+QML_DECLARE_TYPEINFO(QQuickLayout, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QQUICKLAYOUT_P_H
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp
new file mode 100644
index 00000000..d098a6c4
--- /dev/null
+++ b/src/layouts/qquicklinearlayout.cpp
@@ -0,0 +1,433 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquicklinearlayout_p.h"
+#include <QtCore/qnumeric.h>
+#include "qdebug.h"
+/*!
+ \qmltype RowLayout
+ \instantiates QQuickRowLayout
+ \inqmlmodule QtDesktop 1.0
+ \brief RowLayout is doing bla...bla...
+*/
+
+/*!
+ \qmltype ColumnLayout
+ \instantiates QQuickColumnLayout
+ \inqmlmodule QtDesktop 1.0
+ \brief ColumnLayout is doing bla...bla...
+*/
+
+QT_BEGIN_NAMESPACE
+
+static const qreal q_declarativeLayoutDefaultSpacing = 4.0;
+
+
+QQuickGridLayoutBase::QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd,
+ Qt::Orientation orientation,
+ QQuickItem *parent /*= 0*/)
+ : QQuickLayout(dd, parent)
+{
+ Q_D(QQuickGridLayoutBase);
+ d->orientation = orientation;
+}
+
+Qt::Orientation QQuickGridLayoutBase::orientation() const
+{
+ Q_D(const QQuickGridLayoutBase);
+ return d->orientation;
+}
+
+void QQuickGridLayoutBase::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QQuickGridLayoutBase);
+ if (d->orientation == orientation)
+ return;
+
+ d->orientation = orientation;
+ invalidate();
+}
+
+void QQuickGridLayoutBase::componentComplete()
+{
+ Q_D(QQuickGridLayoutBase);
+ quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::componentComplete()" << parent();
+ d->m_disableRearrange = true;
+ QQuickLayout::componentComplete(); // will call our geometryChange(), (where isComponentComplete() == true)
+ d->m_disableRearrange = false;
+ updateLayoutItems();
+
+ QQuickItem *par = parentItem();
+ if (qobject_cast<QQuickLayout*>(par))
+ return;
+ rearrange(QSizeF(width(), height()));
+}
+
+/*
+ Invalidation happens like this as a reaction to that a size hint changes on an item "a":
+
+ Suppose we have the following Qml document:
+ RowLayout {
+ id: l1
+ RowLayout {
+ id: l2
+ Item {
+ id: a
+ }
+ Item {
+ id: b
+ }
+ }
+ }
+
+ 1. l2->invalidateChildItem(a) is called on l2, where item refers to "a".
+ (this will dirty the cached size hints of item "a")
+ 2. l2->invalidate() is called
+ this will :
+ i) invalidate the layout engine
+ ii) dirty the cached size hints of item "l2" (by calling parentLayout()->invalidateChildItem
+
+ */
+/*!
+ \internal
+
+ Invalidates \a childItem and this layout.
+ After a call to invalidate, the next call to retrieve e.g. sizeHint will be up-to date.
+ This function will also call QQuickLayout::invalidate(0), to ensure that the parent layout
+ is invalidated.
+ */
+void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
+{
+ Q_D(QQuickGridLayoutBase);
+ if (!isComponentComplete())
+ return;
+ quickLayoutDebug() << "QQuickGridLayoutBase::invalidate()";
+
+ if (childItem) {
+ if (QQuickGridLayoutItem *layoutItem = d->engine.findLayoutItem(childItem))
+ layoutItem->invalidate();
+ }
+ // invalidate engine
+ d->engine.invalidate();
+
+ QQuickLayout::invalidate(this);
+}
+
+void QQuickGridLayoutBase::updateLayoutItems()
+{
+ Q_D(QQuickGridLayoutBase);
+ if (!isComponentComplete())
+ return;
+ quickLayoutDebug() << "QQuickGridLayoutBase::updateLayoutItems";
+ d->engine.deleteItems();
+ foreach (QQuickItem *child, childItems()) {
+ if (child->isVisible())
+ insertLayoutItem(child);
+ }
+
+ invalidate();
+ quickLayoutDebug() << "QQuickGridLayoutBase::updateLayoutItems LEAVING";
+ propagateLayoutSizeHints();
+}
+
+void QQuickGridLayoutBase::propagateLayoutSizeHints()
+{
+ Q_D(QQuickGridLayoutBase);
+ quickLayoutDebug() << "propagateLayoutSizeHints()";
+ QObject *attached = qmlAttachedPropertiesObject<QQuickLayout>(this);
+ QQuickLayoutAttached *info = static_cast<QQuickLayoutAttached *>(attached);
+
+ const QSizeF min = d->engine.sizeHint(Qt::MinimumSize, QSizeF());
+ const QSizeF pref = d->engine.sizeHint(Qt::PreferredSize, QSizeF());
+ const QSizeF max = d->engine.sizeHint(Qt::MaximumSize, QSizeF());
+
+ info->setMinimumWidth(min.width());
+ info->setMinimumHeight(min.height());
+ setImplicitWidth(pref.width());
+ setImplicitHeight(pref.height());
+ info->setMaximumWidth(max.width());
+ info->setMaximumHeight(max.height());
+}
+
+void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &value)
+{
+ if (change == ItemChildAddedChange) {
+ quickLayoutDebug() << "ItemChildAddedChange";
+ QQuickItem *item = value.item;
+ QObject::connect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
+ QObject::connect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
+ QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
+
+ if (isComponentComplete() && isVisible())
+ updateLayoutItems();
+ } else if (change == ItemChildRemovedChange) {
+ quickLayoutDebug() << "ItemChildRemovedChange";
+ QQuickItem *item = value.item;
+ QObject::disconnect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
+ QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
+ QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged()));
+ if (isComponentComplete() && isVisible())
+ updateLayoutItems();
+ }
+
+ QQuickLayout::itemChange(change, value);
+}
+
+void QQuickGridLayoutBase::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickGridLayoutBase);
+ QQuickLayout::geometryChanged(newGeometry, oldGeometry);
+ if (d->m_disableRearrange || !isComponentComplete() || !newGeometry.isValid())
+ return;
+ quickLayoutDebug() << "QQuickGridLayoutBase::geometryChanged" << newGeometry << oldGeometry;
+ rearrange(newGeometry.size());
+}
+
+void QQuickGridLayoutBase::insertLayoutItem(QQuickItem *item)
+{
+ Q_D(QQuickGridLayoutBase);
+ if (!item) {
+ qWarning("QGraphicsGridLayout::addItem: cannot add null item");
+ return;
+ }
+ QQuickLayoutAttached *info = attachedLayoutObject(item, false);
+ int row = 0;
+ int column = 0;
+ int rowSpan = 1;
+ int columnSpan = 1;
+ Qt::Alignment alignment = 0;
+ if (info) {
+ row = info->row();
+ column = info->column();
+ rowSpan = info->rowSpan();
+ columnSpan = info->columnSpan();
+ }
+ if (row < 0 || column < 0) {
+ qWarning("QQuickGridLayoutBase::insertLayoutItemAt: invalid row/column: %d",
+ row < 0 ? row : column);
+ return;
+ }
+ if (columnSpan < 1 || rowSpan < 1) {
+ qWarning("QQuickGridLayoutBase::addItem: invalid row span/column span: %d",
+ rowSpan < 1 ? rowSpan : columnSpan);
+ return;
+ }
+ QQuickGridLayoutItem *layoutItem = new QQuickGridLayoutItem(item, row, column, rowSpan, columnSpan, alignment);
+ d->engine.insertItem(layoutItem, -1);
+
+ setupItemLayout(item);
+}
+
+void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem)
+{
+ Q_D(QQuickGridLayoutBase);
+ const int index = gridItem->firstRow(d->orientation);
+ d->engine.removeItem(gridItem);
+ d->engine.removeRows(index, 1, d->orientation);
+}
+
+void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item)
+{
+ Q_D(QQuickGridLayoutBase);
+ quickLayoutDebug() << "QQuickGridLayoutBase::removeLayoutItem";
+ if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(item)) {
+ removeGridItem(gridItem);
+ delete gridItem;
+ invalidate();
+ }
+}
+
+void QQuickGridLayoutBase::onItemVisibleChanged()
+{
+ if (!isComponentComplete())
+ return;
+ quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged";
+ updateLayoutItems();
+}
+
+void QQuickGridLayoutBase::onItemDestroyed()
+{
+ Q_D(QQuickGridLayoutBase);
+ quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed";
+ QQuickItem *inDestruction = static_cast<QQuickItem *>(sender());
+ if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(inDestruction)) {
+ removeGridItem(gridItem);
+ delete gridItem;
+ invalidate();
+ }
+}
+
+void QQuickGridLayoutBase::onItemImplicitSizeChanged()
+{
+ QQuickItem *item = static_cast<QQuickItem *>(sender());
+ Q_ASSERT(item);
+ invalidate(item);
+ propagateLayoutSizeHints();
+}
+
+void QQuickGridLayoutBase::rearrange(const QSizeF &size)
+{
+ Q_D(QQuickGridLayoutBase);
+ if (!isComponentComplete())
+ return;
+
+ quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::rearrange()" << size;
+ Qt::LayoutDirection visualDir = Qt::LeftToRight; // ### Fix if RTL support is needed
+ d->engine.setVisualDirection(visualDir);
+
+ /*
+ qreal left, top, right, bottom;
+ left = top = right = bottom = 0; // ### support for margins?
+ if (visualDir == Qt::RightToLeft)
+ qSwap(left, right);
+ */
+
+ d->engine.setGeometries(QRectF(QPointF(0,0), size));
+
+ QQuickLayout::rearrange(size);
+ // propagate hints to upper levels
+ propagateLayoutSizeHints();
+}
+
+
+/**********************************
+ **
+ ** QQuickGridLayout
+ **
+ **/
+QQuickGridLayout::QQuickGridLayout(QQuickItem *parent /* = 0*/)
+ : QQuickGridLayoutBase(*new QQuickGridLayoutPrivate, Qt::Horizontal, parent)
+{
+ Q_D(QQuickGridLayout);
+ d->columnSpacing = q_declarativeLayoutDefaultSpacing;
+ d->rowSpacing = q_declarativeLayoutDefaultSpacing;
+ d->engine.setSpacing(d->columnSpacing, Qt::Horizontal);
+ d->engine.setSpacing(d->rowSpacing, Qt::Vertical);
+}
+
+qreal QQuickGridLayout::columnSpacing() const
+{
+ Q_D(const QQuickGridLayout);
+ return d->columnSpacing;
+}
+
+void QQuickGridLayout::setHorizontalSpacing(qreal spacing)
+{
+ Q_D(QQuickGridLayout);
+ if (qIsNaN(spacing) || d->columnSpacing == spacing)
+ return;
+
+ d->columnSpacing = spacing;
+ d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical);
+ invalidate();
+}
+
+qreal QQuickGridLayout::rowSpacing() const
+{
+ Q_D(const QQuickGridLayout);
+ return d->rowSpacing;
+}
+
+void QQuickGridLayout::setVerticalSpacing(qreal spacing)
+{
+ Q_D(QQuickGridLayout);
+ if (qIsNaN(spacing) || d->rowSpacing == spacing)
+ return;
+
+ d->rowSpacing = spacing;
+ d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical);
+ invalidate();
+}
+
+
+/**********************************
+ **
+ ** QQuickLinearLayout
+ **
+ **/
+QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation,
+ QQuickItem *parent /*= 0*/)
+ : QQuickGridLayoutBase(*new QQuickLinearLayoutPrivate, orientation, parent)
+{
+ Q_D(QQuickLinearLayout);
+ d->spacing = q_declarativeLayoutDefaultSpacing;
+ d->engine.setSpacing(d->spacing, Qt::Horizontal | Qt::Vertical);
+}
+
+qreal QQuickLinearLayout::spacing() const
+{
+ Q_D(const QQuickLinearLayout);
+ return d->spacing;
+}
+
+void QQuickLinearLayout::setSpacing(qreal spacing)
+{
+ Q_D(QQuickLinearLayout);
+ if (qIsNaN(spacing) || d->spacing == spacing)
+ return;
+
+ d->spacing = spacing;
+ d->engine.setSpacing(spacing, Qt::Horizontal | Qt::Vertical);
+ invalidate();
+}
+
+
+void QQuickLinearLayout::insertLayoutItem(QQuickItem *item)
+{
+ Q_D(QQuickLinearLayout);
+ const int index = d->engine.rowCount(d->orientation);
+ d->engine.insertRow(index, d->orientation);
+
+ int gridRow = 0;
+ int gridColumn = index;
+ if (d->orientation == Qt::Vertical)
+ qSwap(gridRow, gridColumn);
+ QQuickGridLayoutItem *layoutItem = new QQuickGridLayoutItem(item, gridRow, gridColumn, 1, 1, 0);
+ d->engine.insertItem(layoutItem, index);
+
+ setupItemLayout(item);
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h
new file mode 100644
index 00000000..04b3b300
--- /dev/null
+++ b/src/layouts/qquicklinearlayout_p.h
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Layouts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKLINEARLAYOUT_P_H
+#define QQUICKLINEARLAYOUT_P_H
+
+#include "qquicklayout_p.h"
+#include "qquickgridlayoutengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/**********************************
+ **
+ ** QQuickGridLayoutBase
+ **
+ **/
+class QQuickGridLayoutBasePrivate;
+
+class QQuickGridLayoutBase : public QQuickLayout
+{
+ Q_OBJECT
+public:
+ explicit QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd,
+ Qt::Orientation orientation,
+ QQuickItem *parent = 0);
+ ~QQuickGridLayoutBase() {}
+
+ void componentComplete();
+ void invalidate(QQuickItem *childItem = 0);
+ Qt::Orientation orientation() const;
+ void setOrientation(Qt::Orientation orientation);
+
+protected:
+ void updateLayoutItems();
+ void rearrange(const QSizeF &size);
+ virtual void insertLayoutItem(QQuickItem *item);
+ void removeLayoutItem(QQuickItem *item);
+ void itemChange(ItemChange change, const ItemChangeData &data);
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+
+protected slots:
+ void onItemVisibleChanged();
+ void onItemDestroyed();
+ void onItemImplicitSizeChanged();
+
+private:
+ void removeGridItem(QGridLayoutItem *gridItem);
+ void propagateLayoutSizeHints();
+ Q_DECLARE_PRIVATE(QQuickGridLayoutBase)
+};
+
+
+class QQuickGridLayoutBasePrivate : public QQuickLayoutPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickGridLayoutBase)
+
+public:
+ QQuickGridLayoutBasePrivate() : m_disableRearrange(true) { }
+ QQuickGridLayoutEngine engine;
+ Qt::Orientation orientation;
+ bool m_disableRearrange;
+
+};
+
+/**********************************
+ **
+ ** QQuickGridLayout
+ **
+ **/
+class QQuickGridLayoutPrivate;
+class QQuickGridLayout : public QQuickGridLayoutBase
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setHorizontalSpacing NOTIFY columnSpacingChanged)
+ Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setVerticalSpacing NOTIFY rowSpacingChanged)
+public:
+ explicit QQuickGridLayout(QQuickItem *parent = 0);
+ qreal columnSpacing() const;
+ void setHorizontalSpacing(qreal spacing);
+ qreal rowSpacing() const;
+ void setVerticalSpacing(qreal spacing);
+signals:
+ void columnSpacingChanged();
+ void rowSpacingChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QQuickGridLayout)
+};
+
+class QQuickGridLayoutPrivate : public QQuickGridLayoutBasePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickGridLayout)
+public:
+ QQuickGridLayoutPrivate() {}
+ qreal columnSpacing;
+ qreal rowSpacing;
+};
+
+
+/**********************************
+ **
+ ** QQuickLinearLayout
+ **
+ **/
+class QQuickLinearLayoutPrivate;
+class QQuickLinearLayout : public QQuickGridLayoutBase
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
+public:
+ explicit QQuickLinearLayout(Qt::Orientation orientation,
+ QQuickItem *parent = 0);
+ void insertLayoutItem(QQuickItem *item);
+ qreal spacing() const;
+ void setSpacing(qreal spacing);
+
+signals:
+ void spacingChanged();
+private:
+ Q_DECLARE_PRIVATE(QQuickLinearLayout)
+};
+
+class QQuickLinearLayoutPrivate : public QQuickGridLayoutBasePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickLinearLayout)
+public:
+ QQuickLinearLayoutPrivate() {}
+ qreal spacing;
+};
+
+
+/**********************************
+ **
+ ** QQuickRowLayout
+ **
+ **/
+class QQuickRowLayout : public QQuickLinearLayout
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickRowLayout(QQuickItem *parent = 0)
+ : QQuickLinearLayout(Qt::Horizontal, parent) {}
+};
+
+
+/**********************************
+ **
+ ** QQuickColumnLayout
+ **
+ **/
+class QQuickColumnLayout : public QQuickLinearLayout
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickColumnLayout(QQuickItem *parent = 0)
+ : QQuickLinearLayout(Qt::Vertical, parent) {}
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKLINEARLAYOUT_P_H
diff --git a/src/private/AbstractCheckable.qml b/src/private/AbstractCheckable.qml
new file mode 100644
index 00000000..ba203e4d
--- /dev/null
+++ b/src/private/AbstractCheckable.qml
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+/*!
+ \qmltype AbstractCheckable
+ \inqmlmodule QtQuick.Controls 1.0
+ \ingroup controls
+ \brief An abstract representation of a checkable control with a label
+ \qmlabstract
+ \internal
+
+ A checkable control is one that has two states: checked (on) and
+ unchecked (off). AbstractCheckable encapsulates the basic behavior and
+ states that are required by checkable controls.
+
+ Examples of checkable controls are RadioButton and
+ CheckBox. CheckBox extends AbstractCheckable's behavior by adding a third
+ state: partially checked.
+*/
+
+Control {
+ id: abstractCheckable
+
+ /*!
+ Emitted whenever the control is clicked.
+ */
+ signal clicked
+
+ /*!
+ \qmlproperty bool AbstractCheckable::pressed
+
+ This property is \c true if the control is pressed.
+ Set this property to manually invoke a mouse click.
+ */
+ readonly property alias pressed: mouseArea.effectivePressed
+
+ /*!
+ This property is \c true if the control is checked.
+ */
+ property bool checked: false
+
+ /*!
+ This property is \c true if the control takes the focus when it is
+ pressed; \l{QQuickItem::forceActiveFocus()}{forceActiveFocus()} will be
+ called on the control.
+ */
+ property bool activeFocusOnPress: false
+
+ /*!
+ This property stores the ExclusiveGroup that the control belongs to.
+ */
+ property ExclusiveGroup exclusiveGroup: null
+
+ /*!
+ This property holds the text that the label should display.
+ */
+ property string text
+
+ /*! \internal */
+ property var __cycleStatesHandler: cycleRadioButtonStates
+
+ /*! \internal
+
+ This property is \c true if the control currently contains the
+ mouse cursor.
+ */
+ readonly property alias __containsMouse: mouseArea.containsMouse
+
+ activeFocusOnTab: true
+
+ MouseArea {
+ id: mouseArea
+ focus: true
+ anchors.fill: parent
+ hoverEnabled: true
+ enabled: !keyPressed
+
+ property bool keyPressed: false
+ property bool effectivePressed: pressed && containsMouse || keyPressed
+
+ onClicked: abstractCheckable.clicked();
+
+ onPressed: if (activeFocusOnPress) forceActiveFocus();
+
+ onReleased: {
+ if (containsMouse && (!exclusiveGroup || !checked))
+ __cycleStatesHandler();
+ }
+ }
+
+ /*! \internal */
+ onExclusiveGroupChanged: {
+ if (exclusiveGroup)
+ exclusiveGroup.bindCheckable(abstractCheckable)
+ }
+
+ Keys.onPressed: {
+ if (event.key === Qt.Key_Space && !event.isAutoRepeat && !mouseArea.pressed)
+ mouseArea.keyPressed = true;
+ }
+
+ Keys.onReleased: {
+ if (event.key === Qt.Key_Space && !event.isAutoRepeat && mouseArea.keyPressed) {
+ mouseArea.keyPressed = false;
+ if (!exclusiveGroup || !checked)
+ __cycleStatesHandler();
+ clicked();
+ }
+ }
+}
diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml
new file mode 100644
index 00000000..f0d2a9ec
--- /dev/null
+++ b/src/private/BasicButton.qml
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import QtQuick.Controls.Styles 1.0
+
+/*!
+ \qmltype BasicButton
+ \internal
+ \qmlabstract
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
+
+Control {
+ id: button
+
+ /*! This signal is emitted when the button is clicked. */
+ signal clicked
+
+ /*! \qmlproperty bool BasicButton::pressed
+
+ This property holds whether the button is pressed. */
+ property alias pressed: behavior.effectivePressed
+
+ /*! This property holds whether the button is checkable.
+
+ The default value is \c false. */
+ property bool checkable: false
+
+ /*! This property holds whether the button is checked.
+
+ Only checkable buttons can be checked.
+
+ The default value is \c false. */
+ property bool checked: false
+
+ /*! This property holds the ExclusiveGroup that the button belongs to.
+
+ The default value is \c null. */
+ property ExclusiveGroup exclusiveGroup: null
+
+ /*! This property holds the associated button action.
+
+ If a button has an action associated, the action defines the
+ button's properties like checked, text, tooltip etc.
+
+ The default value is \c null. */
+ property Action action: null
+
+ /*! This property specifies whether the button should gain active focus when pressed.
+
+ The default value is \c false. */
+ property bool activeFocusOnPress: false
+
+ /*! This property holds the button text color.
+
+ The default value is SystemPalette::text. */
+ property color textColor: syspal.text
+
+ /*! This property holds the button tooltip. */
+ property string tooltip
+
+ /*! \internal */
+ property string __position: "only"
+ /*! \internal */
+ property alias __containsMouse: behavior.containsMouse
+ /*! \internal */
+ property Action __action: action || ownAction
+
+ /*! \internal */
+ onExclusiveGroupChanged: {
+ if (exclusiveGroup)
+ exclusiveGroup.bindCheckable(button)
+ }
+
+ Accessible.role: Accessible.Button
+ Accessible.description: tooltip
+
+ Action { id: ownAction }
+
+ Connections {
+ target: __action
+ onTriggered: button.clicked()
+ }
+
+ activeFocusOnTab: true
+
+ Keys.onPressed: {
+ if (event.key === Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed)
+ behavior.keyPressed = true;
+ }
+
+ Keys.onReleased: {
+ if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
+ behavior.keyPressed = false;
+ __action.trigger()
+ }
+ }
+
+ MouseArea {
+ id: behavior
+ property bool checkable: __action.checkable
+ property bool checked: __action.checked
+ property bool keyPressed: false
+ property bool effectivePressed: pressed && containsMouse || keyPressed
+
+ anchors.fill: parent
+ hoverEnabled: true
+ enabled: !keyPressed
+
+ onReleased: if (containsMouse) __action.trigger()
+ onExited: PrivateHelper.hideTooltip()
+ onCanceled: PrivateHelper.hideTooltip()
+ onPressed: if (activeFocusOnPress) button.forceActiveFocus()
+
+ Timer {
+ interval: 1000
+ running: behavior.containsMouse && !pressed && tooltip.length
+ onTriggered: PrivateHelper.showTooltip(behavior, Qt.point(behavior.mouseX, behavior.mouseY), tooltip)
+ }
+ }
+
+ SystemPalette { id: syspal }
+
+ states: [
+ State {
+ name: "ownAction"
+ when: action === null
+ PropertyChanges {
+ target: ownAction
+ enabled: button.enabled
+ checkable: button.checkable
+ checked: button.checked
+ exclusiveGroup: button.exclusiveGroup
+ text: button.text
+ iconSource: button.iconSource
+ tooltip: button.tooltip
+ }
+ },
+
+ State {
+ name: "boundAction"
+ when: action !== null
+ PropertyChanges {
+ target: button
+ enabled: action.enabled
+ checkable: action.checkable
+ checked: action.checked
+ exclusiveGroup: action.exclusiveGroup
+ text: action.text
+ iconSource: action.iconSource
+ tooltip: action.tooltip
+ }
+ }
+ ]
+}
diff --git a/src/qtdesktop/Frame.qml b/src/private/Control.qml
index 93aefdd9..06bcdce6 100644
--- a/src/qtdesktop/Frame.qml
+++ b/src/private/Control.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,41 +37,49 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-import QtQuick 2.0
-import QtDesktop 1.0
-import "Styles/Settings.js" as Settings
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
/*!
- \qmltype Frame
- \inqmlmodule QtDesktop 1.0
- \brief Frame is doing bla...bla...
+ \qmltype Control
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
*/
+FocusScope {
+ id: root
+
+ property Component style
+
+ /* \internal */
+ property Style __style: styleLoader.item
+
+ /* \internal */
+ property Item __panel: panelLoader.item
-Item {
- id: frame
- default property alias data: content.data
- implicitWidth: adjustToContentSize ? content.childrenRect.width + 2 * content.frameWidth : 30
- implicitHeight: adjustToContentSize ? content.childrenRect.height + 2 * content.frameWidth : 30
+ /* \internal */
+ property var styleHints: []
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/FrameStyle.qml", frame)
+ /* \internal */
+ implicitWidth: __panel ? __panel.implicitWidth: 0
- property bool raised
- property bool sunken
- property bool adjustToContentSize: false
+ /* \internal */
+ implicitHeight: __panel ? __panel.implicitHeight: 0
+
+ activeFocusOnTab: false
Loader {
- id: loader
+ id: panelLoader
anchors.fill: parent
- sourceComponent: style
- Item {
- id: content
- anchors.fill: parent
- anchors.margins: frameWidth
- property int frameWidth
+ sourceComponent: __style ? __style.panel : null
+ property alias control: root
+ onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
+ Loader {
+ id: styleLoader
+ sourceComponent: style
+ onStatusChanged: {
+ if (status === Loader.Error)
+ console.error("Failed to load Style for", root)
+ }
}
- onLoaded: item.z = -1
}
-
-
}
diff --git a/src/private/FocusFrame.qml b/src/private/FocusFrame.qml
new file mode 100644
index 00000000..08f4b04a
--- /dev/null
+++ b/src/private/FocusFrame.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype FocusFrame
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
+StyleItem {
+ z: 2
+ anchors.fill: parent
+ property int focusMargin: -3
+ anchors.topMargin: focusMargin
+ anchors.leftMargin: focusMargin
+ anchors.rightMargin: focusMargin
+ anchors.bottomMargin: focusMargin
+ elementType: "focusframe"
+}
diff --git a/src/qtdesktop/private/ModalPopupBehavior.qml b/src/private/ModalPopupBehavior.qml
index 1e95f6f1..1c6db2ff 100644
--- a/src/qtdesktop/private/ModalPopupBehavior.qml
+++ b/src/private/ModalPopupBehavior.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,11 +38,16 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
// KNOWN ISSUES
// none
+/*!
+ \qmltype ModalPopupBehavior
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
Item {
id: popupBehavior
diff --git a/src/qtdesktop/private/PageSlideTransition.qml b/src/private/PageSlideTransition.qml
index aed74d68..d77e1eaf 100644
--- a/src/qtdesktop/private/PageSlideTransition.qml
+++ b/src/private/PageSlideTransition.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,9 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+/*!
+ \qmltype PageSlideTransition
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
PageTransition {
id: root
diff --git a/src/private/PageStack.js b/src/private/PageStack.js
new file mode 100644
index 00000000..7256e89e
--- /dev/null
+++ b/src/private/PageStack.js
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+var pageStack = [];
+
+function push(p)
+{
+ if (!p)
+ return
+ pageStack.push(p)
+ __depth++
+ return p
+}
+
+function pop()
+{
+ if (pageStack.length === 0)
+ return null
+ var p = pageStack.pop()
+ __depth--
+ return p
+}
+
+function current()
+{
+ if (pageStack.length === 0)
+ return null
+ return pageStack[pageStack.length-1]
+}
+
diff --git a/src/qtdesktop/private/ScrollBar.qml b/src/private/ScrollBar.qml
index 9271b52d..d11fcef6 100644
--- a/src/qtdesktop/private/ScrollBar.qml
+++ b/src/private/ScrollBar.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,61 +38,66 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
import "../Styles/Settings.js" as Settings
/*!
- \qmltype ScrollBar
- \inqmlmodule QtDesktop 1.0
- \brief ScrollBar is doing bla...bla...
+ \qmltype ScrollBar
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
*/
-
Item {
id: scrollbar
property int orientation: Qt.Horizontal
property alias minimumValue: slider.minimumValue
property alias maximumValue: slider.maximumValue
- property int pageStep: internal.horizontal ? width : height
- property int singleStep: 20
property alias value: slider.value
- property bool scrollToClickposition: internal.scrollToClickPosition
-
- implicitWidth: loader.implicitWidth
- implicitHeight: loader.implicitHeight
-
- onValueChanged: internal.updateHandle()
property Component style: Qt.createComponent("../" + Settings.THEME_PATH + "/ScrollBarStyle.qml", scrollbar)
+ property alias styleItem: loader.item
- property bool upPressed
- property bool downPressed
+ activeFocusOnTab: false
- property bool pageUpPressed
- property bool pageDownPressed
+ Accessible.role: Accessible.ScrollBar
+ implicitWidth: loader.implicitWidth
+ implicitHeight: loader.implicitHeight
+
+ readonly property alias upPressed: internal.upPressed
+ readonly property alias downPressed: internal.downPressed
+ readonly property alias pageUpPressed: internal.pageUpPressed
+ readonly property alias pageDownPressed: internal.pageDownPressed
+ readonly property alias handlePressed: internal.handlePressed
MouseArea {
id: internal
+ property bool upPressed
+ property bool downPressed
+ property bool pageUpPressed
+ property bool pageDownPressed
+ property bool handlePressed
+
property bool horizontal: orientation === Qt.Horizontal
- property alias styleItem: loader.item
+ property int pageStep: internal.horizontal ? width : height
+ property int singleStep: 20
+ property bool scrollToClickposition: internal.scrollToClickPosition
anchors.fill: parent
property bool autoincrement: false
property bool scrollToClickPosition: styleItem ? styleItem.scrollToClickPosition : 0
- property bool handlePressed
// Update hover item
- onEntered: styleItem.activeControl = styleItem.hitTest(mouseX, mouseY)
- onExited: styleItem.activeControl = "none"
- onMouseXChanged: styleItem.activeControl = styleItem.hitTest(mouseX, mouseY)
+ onEntered: if (!pressed) styleItem.activeControl = styleItem.hitTest(mouseX, mouseY)
+ onExited: if (!pressed) styleItem.activeControl = "none"
+ onMouseXChanged: if (!pressed) styleItem.activeControl = styleItem.hitTest(mouseX, mouseY)
hoverEnabled: true
- property variant control
- property variant pressedX
- property variant pressedY
+ property var pressedX
+ property var pressedY
property int oldPosition
property int grooveSize
@@ -106,14 +111,20 @@ Item {
running: internal.autoincrement
interval: 60
repeat: true
- onTriggered: upPressed ? internal.decrement() : downPressed ? internal.increment() :
- pageUpPressed ? internal.decrementPage() :
- internal.incrementPage()
+ onTriggered: {
+ if (upPressed && internal.containsMouse)
+ internal.decrement();
+ else if (downPressed && internal.containsMouse)
+ internal.increment();
+ else if (pageUpPressed)
+ internal.decrementPage();
+ else if (pageDownPressed)
+ internal.incrementPage();
+ }
}
onPositionChanged: {
- if (pressed && control === "handle") {
- //slider.positionAtMaximum = grooveSize
+ if (pressed && styleItem.activeControl === "handle") {
if (!horizontal)
slider.position = oldPosition + (mouseY - pressedY)
else
@@ -122,43 +133,46 @@ Item {
}
onPressed: {
- control = styleItem.hitTest(mouseX, mouseY)
+ styleItem.activeControl = styleItem.hitTest(mouseX, mouseY)
scrollToClickposition = scrollToClickPosition
+ var handleRect = styleItem.subControlRect("handle")
grooveSize = horizontal ? styleItem.subControlRect("groove").width -
- styleItem.subControlRect("handle").width:
+ handleRect.width:
styleItem.subControlRect("groove").height -
- styleItem.subControlRect("handle").height;
- if (control == "handle") {
- pressedX = mouseX
- pressedY = mouseY
- oldPosition = slider.position
- } else if (control == "up") {
+ handleRect.height;
+ if (styleItem.activeControl === "handle") {
+ pressedX = mouseX;
+ pressedY = mouseY;
+ internal.handlePressed = true;
+ oldPosition = slider.position;
+ } else if (styleItem.activeControl === "up") {
decrement();
- upPressed = true
- } else if (control == "down") {
+ internal.upPressed = Qt.binding(function() {return containsMouse});
+ } else if (styleItem.activeControl === "down") {
increment();
- downPressed = true
+ internal.downPressed = Qt.binding(function() {return containsMouse});
} else if (!scrollToClickposition){
- if (control == "upPage") {
+ if (styleItem.activeControl === "upPage") {
decrementPage();
- pageUpPressed = true
- } else if (control == "downPage") {
+ internal.pageUpPressed = true;
+ } else if (styleItem.activeControl === "downPage") {
incrementPage();
- pageDownPressed = true
+ internal.pageDownPressed = true;
}
} else {
- slider.position = horizontal ? mouseX - handleRect.width/2
+ slider.position = horizontal ? mouseX - handleRect.width/2
: mouseY - handleRect.height/2
}
}
onReleased: {
+ styleItem.activeControl = styleItem.hitTest(mouseX, mouseY);
autoincrement = false;
- upPressed = false;
- downPressed = false;
- pageUpPressed = false
- pageDownPressed = false
- control = ""
+ internal.upPressed = false;
+ internal.downPressed = false;
+ internal.handlePressed = false;
+ internal.pageUpPressed = false;
+ internal.pageDownPressed = false;
}
function incrementPage() {
@@ -192,12 +206,6 @@ Item {
anchors.fill: parent
}
- property rect handleRect: Qt.rect(0,0,0,0)
- property rect grooveRect: Qt.rect(0,0,0,0)
- function updateHandle() {
- internal.handleRect = styleItem.subControlRect("handle")
- grooveRect = styleItem.subControlRect("groove");
- }
RangeModel {
id: slider
diff --git a/src/private/ScrollViewHelper.qml b/src/private/ScrollViewHelper.qml
new file mode 100644
index 00000000..ec0194c2
--- /dev/null
+++ b/src/private/ScrollViewHelper.qml
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+
+/*!
+ \qmltype ScrollViewHeader
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
+Item {
+ id: wheelarea
+
+ property alias horizontalScrollBar: hscrollbar
+ property alias verticalScrollBar: vscrollbar
+ property bool blockUpdates: false
+ property int availableHeight
+ property int availableWidth
+ property int contentHeight
+ property int contentWidth
+
+ anchors.fill: parent
+
+ property int frameMargin: outerFrame ? frameWidth : 0
+
+ property bool recursionGuard: false
+
+ function doLayout() {
+ if (!recursionGuard) {
+ recursionGuard = true
+ wheelarea.availableWidth = viewport.width
+ wheelarea.availableHeight = viewport.height
+ wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
+ wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
+ recursionGuard = false
+ }
+ }
+
+ Connections {
+ target: viewport
+ onWidthChanged: doLayout()
+ onHeightChanged: doLayout()
+ }
+
+ Connections {
+ target: flickableItem
+ onContentWidthChanged: doLayout()
+ onContentHeightChanged: doLayout()
+ }
+
+ Connections {
+ target: flickableItem
+ onContentXChanged: {
+ hscrollbar.flash()
+ vscrollbar.flash()
+ }
+ onContentYChanged: {
+ hscrollbar.flash()
+ vscrollbar.flash()
+ }
+ }
+
+ StyleItem {
+ // This is the filled corner between scrollbars
+ id: cornerFill
+ elementType: "scrollareacorner"
+ width: visible ? vscrollbar.width : 0
+ anchors.right: parent.right
+ height: visible ? hscrollbar.height : 0
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: frameMargin
+ anchors.rightMargin: frameMargin
+ visible: hscrollbar.visible && !hscrollbar.isTransient && vscrollbar.visible && !vscrollbar.isTransient
+ }
+
+ ScrollBar {
+ id: hscrollbar
+ property bool isTransient: !!styleItem && styleItem.styleHint("transientScrollBars")
+ property bool active: !!styleItem && (styleItem.sunken || styleItem.activeControl != "none")
+ orientation: Qt.Horizontal
+ visible: contentWidth > availableWidth
+ height: visible ? implicitHeight : 0
+ z: 1
+ maximumValue: contentWidth > availableWidth ? contentWidth - availableWidth : 0
+ minimumValue: 0
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: cornerFill.left
+ anchors.leftMargin: frameMargin
+ anchors.bottomMargin: frameMargin
+ onValueChanged: {
+ if (!blockUpdates) {
+ flickableItem.contentX = value
+ }
+ }
+ Binding {
+ target: hscrollbar.styleItem
+ property: "raised"
+ value: vscrollbar.active
+ when: hscrollbar.isTransient
+ }
+ function flash() {
+ if (hscrollbar.isTransient) {
+ hscrollbar.styleItem.on = true
+ hscrollbar.styleItem.visible = true
+ }
+ }
+ }
+
+ ScrollBar {
+ id: vscrollbar
+ property bool isTransient: !!styleItem && styleItem.styleHint("transientScrollBars")
+ property bool active: !!styleItem && (styleItem.sunken || styleItem.activeControl != "none")
+ orientation: Qt.Vertical
+ visible: contentHeight > availableHeight
+ width: visible ? implicitWidth : 0
+ z: 1
+ anchors.bottom: cornerFill.top
+ anchors.bottomMargin: hscrollbar.visible ? 0 : frameMargin
+ maximumValue: contentHeight > availableHeight ? contentHeight - availableHeight : 0
+ minimumValue: 0
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.topMargin: __scrollBarTopMargin + frameMargin
+ anchors.rightMargin: frameMargin
+ onValueChanged: {
+ if (flickableItem && !blockUpdates && enabled) {
+ flickableItem.contentY = value
+ }
+ }
+ Binding {
+ target: vscrollbar.styleItem
+ property: "raised"
+ value: hscrollbar.active
+ when: vscrollbar.isTransient
+ }
+ function flash() {
+ if (vscrollbar.isTransient) {
+ vscrollbar.styleItem.on = true
+ vscrollbar.styleItem.visible = true
+ }
+ }
+ }
+}
diff --git a/src/qtdesktop/private/TabBar.qml b/src/private/TabBar.qml
index 68233ff6..25914f1c 100644
--- a/src/qtdesktop/private/TabBar.qml
+++ b/src/private/TabBar.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,38 +38,45 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
-Item {
+/*!
+ \qmltype TabBar
+ \internal
+ \inqmlmodule QtQuick.Controls.Private 1.0
+*/
+FocusScope {
id: tabbar
height: tabrow.height
width: tabrow.width
+ activeFocusOnTab: true
Keys.onRightPressed: {
- if (tabFrame && tabFrame.current < tabFrame.count - 1)
- tabFrame.current = tabFrame.current + 1
+ if (tabView && tabView.currentIndex < tabView.count - 1)
+ tabView.currentIndex = tabView.currentIndex + 1
}
Keys.onLeftPressed: {
- if (tabFrame && tabFrame.current > 0)
- tabFrame.current = tabFrame.current - 1
+ if (tabView && tabView.currentIndex > 0)
+ tabView.currentIndex = tabView.currentIndex - 1
}
- onTabFrameChanged: parent = tabFrame
- visible: tabFrame ? tabFrame.tabsVisible : true
+ onTabViewChanged: parent = tabView
+ visible: tabView ? tabView.tabsVisible : true
-
- property Item tabFrame
+ property var tabView
property var style
- property var styleItem: tabFrame.__styleItem ? tabFrame.__styleItem : null
+ property var styleItem: tabView.__styleItem ? tabView.__styleItem : null
property string tabBarAlignment: styleItem ? styleItem.tabBarAlignment : "left"
- property string position: tabFrame ? tabFrame.position : "North"
+ property string position: tabView ? tabView.tabPosition : "Top"
property int tabOverlap: styleItem ? styleItem.tabOverlap : 0
property int tabBaseOverlap: styleItem ? styleItem.tabBaseOverlap : 0
+ property int elide: Text.ElideRight
+
function tab(index) {
for (var i = 0; i < tabrow.children.length; ++i) {
if (tabrow.children[i].tabindex == index) {
@@ -87,6 +94,7 @@ Item {
states: [
State {
name: "left"
+ when: tabBarAlignment == "left"
AnchorChanges { target:tabrow ; anchors.left: parent.left }
PropertyChanges { target:tabrow ; anchors.leftMargin: styleItem ? styleItem.leftMargin : 0 }
},
@@ -107,20 +115,21 @@ Item {
Repeater {
id: repeater
focus: true
- model: tabFrame ? tabFrame.tabs.length : null
+ model: tabView.count
+
delegate: Item {
id: tabitem
focus: true
property int tabindex: index
property bool selectedHelper: selected
- property bool selected : tabFrame.current == index
+ property bool selected : tabView.currentIndex == index
property bool hover: mousearea.containsMouse
property bool first: index === 0
- property string title: tabFrame.tabs[index].title
+ property string title: tabView.__tabs[index].title
z: selected ? 1 : -index
- implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/tabs.length) + 1
+ implicitWidth: Math.min(tabloader.implicitWidth, tabbar.width/repeater.count) + 1
implicitHeight: tabloader.implicitHeight
Loader {
@@ -129,11 +138,11 @@ Item {
sourceComponent: loader.item ? loader.item.tab : null
anchors.fill: parent
- property Item control: tabFrame
+ property Item control: tabView
property Item tab: tabitem
property int index: tabindex
- property bool nextSelected: tabFrame.current === index + 1
- property bool previousSelected: tabFrame.current === index - 1
+ property bool nextSelected: tabView.currentIndex === index + 1
+ property bool previousSelected: tabView.currentIndex === index - 1
property string title: tab.title
}
@@ -141,11 +150,11 @@ Item {
id: mousearea
anchors.fill: parent
hoverEnabled: true
- onPressed: tabFrame.current = index
+ onPressed: tabView.currentIndex = index
onPressAndHold: tabitem.parent = null
}
Accessible.role: Accessible.PageTab
- Accessible.name: tabFrame.tabs[index].title
+ Accessible.name: tabView.__tabs[index].title
}
}
}
diff --git a/src/private/private.pro b/src/private/private.pro
new file mode 100644
index 00000000..29707586
--- /dev/null
+++ b/src/private/private.pro
@@ -0,0 +1,42 @@
+TARGET = privateplugin
+TARGETPATH = QtQuick/Controls/Private
+
+QT += qml quick widgets gui-private core-private
+
+HEADERS += \
+ $$PWD/qquickcomponentsprivate_p.h \
+ $$PWD/qprivateplugin_p.h\
+ $$PWD/qrangemodel_p.h \
+ $$PWD/qrangemodel_p_p.h \
+ $$PWD/qwheelarea_p.h \
+ $$PWD/qstyleitem_p.h
+
+SOURCES += \
+ $$PWD/qquickcomponentsprivate.cpp \
+ $$PWD/qprivateplugin.cpp\
+ $$PWD/qstyleitem.cpp \
+ $$PWD/qrangemodel.cpp\
+ $$PWD/qwheelarea.cpp
+
+OTHER_FILES += \
+ $$PWD/privateplugin.json
+
+# private qml files
+QML_FILES += \
+ AbstractCheckable.qml \
+ TabBar.qml \
+ BasicButton.qml \
+ Control.qml \
+ ModalPopupBehavior.qml \
+ PageSlideTransition.qml \
+ PageStack.js \
+ ScrollViewHelper.qml \
+ ScrollBar.qml \
+ FocusFrame.qml
+
+mac {
+ LIBS += -framework Carbon
+}
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/private/privateplugin.json b/src/private/privateplugin.json
new file mode 100644
index 00000000..0967ef42
--- /dev/null
+++ b/src/private/privateplugin.json
@@ -0,0 +1 @@
+{}
diff --git a/src/private/qmldir b/src/private/qmldir
new file mode 100644
index 00000000..19886b2d
--- /dev/null
+++ b/src/private/qmldir
@@ -0,0 +1,10 @@
+module QtQuick.Controls.Private
+plugin privateplugin
+AbstractCheckable 1.0 AbstractCheckable.qml
+Control 1.0 Control.qml
+FocusFrame 1.0 FocusFrame.qml
+BasicButton 1.0 BasicButton.qml
+ScrollBar 1.0 ScrollBar.qml
+ScrollViewHelper 1.0 ScrollViewHelper.qml
+TabBar 1.0 TabBar.qml
+PageSlideTransition 1.0 PageSlideTransition.qml
diff --git a/src/private/qprivateplugin.cpp b/src/private/qprivateplugin.cpp
new file mode 100644
index 00000000..1ad7ba09
--- /dev/null
+++ b/src/private/qprivateplugin.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprivateplugin_p.h"
+#include "qrangemodel_p.h"
+#include "qwheelarea_p.h"
+#include "qstyleitem_p.h"
+#include "qquickcomponentsprivate_p.h"
+
+#include <qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+QObject *registerPrivateModule(QQmlEngine *engine, QJSEngine *jsEngine)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(jsEngine);
+ return new QQuickComponentsPrivate();
+}
+
+
+void StylePlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<QRangeModel>(uri, 1, 0, "RangeModel");
+ qmlRegisterType<QWheelArea>(uri, 1, 0, "WheelArea");
+ qmlRegisterType<QStyleItem>(uri, 1, 0, "StyleItem");
+ qmlRegisterSingletonType<QQuickComponentsPrivate>(uri, 1, 0, "PrivateHelper", registerPrivateModule);
+}
+
+QT_END_NAMESPACE
diff --git a/src/private/qprivateplugin_p.h b/src/private/qprivateplugin_p.h
new file mode 100644
index 00000000..3d27aa0a
--- /dev/null
+++ b/src/private/qprivateplugin_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLEPLUGIN_P_H
+#define QSTYLEPLUGIN_P_H
+
+#include <QtQml/qqmlextensionplugin.h>
+
+QT_BEGIN_NAMESPACE
+
+class StylePlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtquickcontrols.QQmlExtensionInterface" FILE "privateplugin.json")
+public:
+ void registerTypes(const char *uri);
+};
+
+QT_END_NAMESPACE
+
+#endif // QSTYLEPLUGIN_P_H
diff --git a/src/private/qquickcomponentsprivate.cpp b/src/private/qquickcomponentsprivate.cpp
new file mode 100644
index 00000000..1fdebfad
--- /dev/null
+++ b/src/private/qquickcomponentsprivate.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickcomponentsprivate_p.h"
+
+#include <qtooltip.h>
+#include <qquickwindow.h>
+#include <qquickitem.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickComponentsPrivate::QQuickComponentsPrivate(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+void QQuickComponentsPrivate::showTooltip(QQuickItem *item, const QPointF &pos, const QString &str)
+{
+ if (!item || !item->window())
+ return;
+
+ QToolTip::showText(item->window()->mapToGlobal(item->mapToScene(pos).toPoint()), str);
+}
+
+void QQuickComponentsPrivate::hideTooltip()
+{
+ QToolTip::hideText();
+}
+
+QT_END_NAMESPACE
diff --git a/src/private/qquickcomponentsprivate_p.h b/src/private/qquickcomponentsprivate_p.h
new file mode 100644
index 00000000..a08dafb9
--- /dev/null
+++ b/src/private/qquickcomponentsprivate_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKCOMPONENTSPRIVATE_P_H
+#define QQUICKCOMPONENTSPRIVATE_P_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPointF;
+class QQuickItem;
+
+class QQuickComponentsPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ QQuickComponentsPrivate(QObject *parent = 0);
+
+ Q_INVOKABLE void showTooltip(QQuickItem *item, const QPointF &pos, const QString &text);
+ Q_INVOKABLE void hideTooltip();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKCOMPONENTSPRIVATE_P_H
diff --git a/src/qtdesktop/qrangemodel.cpp b/src/private/qrangemodel.cpp
index 1f454ddd..987026f5 100644
--- a/src/qtdesktop/qrangemodel.cpp
+++ b/src/private/qrangemodel.cpp
@@ -1,50 +1,45 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
****************************************************************************/
/*!
- \qmltype RangeModel
- \instantiates QRangeModel
- \inqmlmodule QtDesktop 1.0
- \brief RangeModel helps users to build components that depend
- on some value and/or position to be in a certain range previously defined
-
With this class, the user sets a value range and a position range, which
represent the valid values/positions the model can assume. It is worth telling
that the value property always has priority over the position property. A nice use
@@ -55,15 +50,6 @@
be updated due to the new position range.
*/
-#include <QEvent>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QGraphicsSceneEvent>
-#include <QDebug>
-
-#ifndef QT_NO_ACCESSIBILITY
-#include <QAccessible>
-#endif
-
#include "qrangemodel_p.h"
#include "qrangemodel_p_p.h"
diff --git a/src/qtdesktop/qrangemodel_p.h b/src/private/qrangemodel_p.h
index 7e14d622..7a2ac606 100644
--- a/src/qtdesktop/qrangemodel_p.h
+++ b/src/private/qrangemodel_p.h
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -42,12 +43,8 @@
#define QRANGEMODEL_P_H
#include <QtCore/qobject.h>
-//#include <QtGui/qgraphicsitem.h>
-#include <QtWidgets/qabstractslider.h>
#include <QtQml/qqml.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QRangeModelPrivate;
@@ -128,6 +125,4 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QRangeModel)
-QT_END_HEADER
-
#endif // QRANGEMODEL_P_H
diff --git a/src/qtdesktop/qrangemodel_p_p.h b/src/private/qrangemodel_p_p.h
index b7f78568..d0a35b4e 100644
--- a/src/qtdesktop/qrangemodel_p_p.h
+++ b/src/private/qrangemodel_p_p.h
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -52,12 +53,10 @@
// We mean it.
//
-QT_BEGIN_HEADER
+#include "qrangemodel_p.h"
QT_BEGIN_NAMESPACE
-#include "qrangemodel_p.h"
-
class QRangeModelPrivate
{
Q_DECLARE_PUBLIC(QRangeModel)
@@ -109,6 +108,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QRANGEMODEL_P_P_H
diff --git a/src/qtdesktop/qstyleitem.cpp b/src/private/qstyleitem.cpp
index c892efb6..1288b376 100644
--- a/src/qtdesktop/qstyleitem.cpp
+++ b/src/private/qstyleitem.cpp
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -40,18 +41,16 @@
#include "qstyleitem_p.h"
-#include <QtGui/QPainter>
-#include <QtWidgets/QStyle>
-#include <QtWidgets/QStyleOption>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QMainWindow>
-#include <QtWidgets/QGroupBox>
-#include <QtWidgets/QToolBar>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QtWidgets>
-#include <QtCore/QStringBuilder>
-#include <QtQuick/QSGSimpleTextureNode>
-#include <QtQuick/QQuickWindow>
+#include <qstringbuilder.h>
+#include <qpainter.h>
+#include <qpixmapcache.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qapplication.h>
+#include <qsgsimpletexturenode.h>
+#include <qquickwindow.h>
+#include "private/qguiapplication_p.h"
+#include <QtGui/qpa/qplatformtheme.h>
QT_BEGIN_NAMESPACE
@@ -133,8 +132,13 @@ QStyleItem::QStyleItem(QQuickItem *parent)
m_contentHeight(0)
{
- if (!qApp->style()) {
- qWarning("\nError: No widget style available. \n\nQt Desktop Components "
+ // Check on QApplication, allowing for "qmlplugindump" to query our interfaces.
+ QCoreApplication *coreApp = QCoreApplication::instance();
+ Q_ASSERT(coreApp);
+ if (!qobject_cast<QApplication *>(coreApp)) {
+ if (QCoreApplication::applicationFilePath().contains(QLatin1String("qmlplugindump"), Qt::CaseInsensitive))
+ return;
+ qWarning("\nError: No widget style available. \n\nQt Quick Controls"
"currently depend on the widget module to function. \n"
"Use QApplication when creating standalone executables.\n\n");
exit(-1);
@@ -150,6 +154,7 @@ QStyleItem::QStyleItem(QQuickItem *parent)
connect(this, SIGNAL(onChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(selectedChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
+ connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint()));
connect(this, SIGNAL(textChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(activeChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(raisedChanged()), this, SLOT(updateItem()));
@@ -163,10 +168,12 @@ QStyleItem::QStyleItem(QQuickItem *parent)
connect(this, SIGNAL(hasFocusChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(activeControlChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(hintChanged()), this, SLOT(updateItem()));
+ connect(this, SIGNAL(propertiesChanged()), this, SLOT(updateSizeHint()));
+ connect(this, SIGNAL(propertiesChanged()), this, SLOT(updateItem()));
connect(this, SIGNAL(elementTypeChanged()), this, SLOT(updateItem()));
- connect(this, SIGNAL(textChanged()), this, SLOT(updateSizeHint()));
connect(this, SIGNAL(contentWidthChanged(int)), this, SLOT(updateSizeHint()));
connect(this, SIGNAL(contentHeightChanged(int)), this, SLOT(updateSizeHint()));
+ connect(this, SIGNAL(widthChanged()), this, SLOT(updateRect()));
}
QStyleItem::~QStyleItem()
@@ -234,11 +241,11 @@ void QStyleItem::initStyleOption()
QStyleOptionHeader::SortDown
: activeControl() == "up" ?
QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
- if (info() == QLatin1String("beginning"))
+ if (hints().contains("beginning"))
opt->position = QStyleOptionHeader::Beginning;
- else if (info() == QLatin1String("end"))
+ else if (hints().contains("end"))
opt->position = QStyleOptionHeader::End;
- else if (info() == QLatin1String("only"))
+ else if (hints().contains("only"))
opt->position = QStyleOptionHeader::OnlyOneSection;
else
opt->position = QStyleOptionHeader::Middle;
@@ -253,6 +260,16 @@ void QStyleItem::initStyleOption()
opt->subControls = QStyle::SC_ToolButton;
opt->state |= QStyle::State_AutoRaise;
opt->activeSubControls = QStyle::SC_ToolButton;
+ opt->text = text();
+ opt->icon = m_properties["icon"].value<QIcon>();
+
+ // For now icon only is displayed by default.
+ opt->toolButtonStyle = Qt::ToolButtonIconOnly;
+ if (opt->icon.isNull() && !opt->text.isEmpty())
+ opt->toolButtonStyle = Qt::ToolButtonTextOnly;
+
+ int e = qApp->style()->pixelMetric(QStyle::PM_ToolBarIconSize, m_styleoption, 0);
+ opt->iconSize = QSize(e, e);
}
break;
case ToolBar: {
@@ -264,15 +281,19 @@ void QStyleItem::initStyleOption()
if (!m_styleoption)
m_styleoption = new QStyleOptionTab();
+
QStyleOptionTab *opt = qstyleoption_cast<QStyleOptionTab*>(m_styleoption);
opt->text = text();
- if (hint().length() > 2) {
- QString shape = hint()[0];
- QString position = hint()[1];
- QString selectedPosition = hint()[2];
+ if (m_properties["hasFrame"].toBool())
+ opt->features |= QStyleOptionTab::HasFrame;
- opt->shape = (shape == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ if (hints().length() > 2) {
+ QString shape = hints()[0];
+ QString position = hints()[1];
+ QString selectedPosition = hints()[2];
+
+ opt->shape = (shape == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
if (position == QLatin1String("beginning"))
opt->position = QStyleOptionTab::Beginning;
@@ -287,17 +308,12 @@ void QStyleItem::initStyleOption()
opt->selectedPosition = QStyleOptionTab::NextIsSelected;
else if (selectedPosition == QLatin1String("previous"))
opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
- else
+ else
opt->selectedPosition = QStyleOptionTab::NotAdjacent;
}
} break;
- case Menu: {
- if (!m_styleoption)
- m_styleoption = new QStyleOptionMenuItem();
- }
- break;
case Frame: {
if (!m_styleoption)
m_styleoption = new QStyleOptionFrame();
@@ -312,7 +328,7 @@ void QStyleItem::initStyleOption()
if (!m_styleoption)
m_styleoption = new QStyleOptionTabWidgetFrame();
QStyleOptionTabWidgetFrame *opt = qstyleoption_cast<QStyleOptionTabWidgetFrame*>(m_styleoption);
- opt->shape = (info() == "South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
+ opt->shape = hints().contains("South") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
if (minimum())
opt->selectedTabRect = QRect(value(), 0, minimum(), height());
opt->tabBarSize = QSize(minimum() , height());
@@ -320,6 +336,35 @@ void QStyleItem::initStyleOption()
opt->leftCornerWidgetSize = QSize(value(), 0);
}
break;
+ case MenuBar:
+ if (!m_styleoption) {
+ QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem();
+ menuOpt->menuItemType = QStyleOptionMenuItem::EmptyArea;
+ m_styleoption = menuOpt;
+ }
+
+ break;
+ case MenuBarItem:
+ {
+ if (!m_styleoption)
+ m_styleoption = new QStyleOptionMenuItem();
+
+ QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption);
+ opt->text = text();
+ opt->menuItemType = QStyleOptionMenuItem::Normal;
+
+ if (const QFont *font = QGuiApplicationPrivate::platformTheme()->font(QPlatformTheme::MenuBarFont)) {
+ opt->font = *font;
+ opt->fontMetrics = QFontMetrics(opt->font);
+ m_font = opt->font;
+ }
+ }
+ break;
+ case Menu: {
+ if (!m_styleoption)
+ m_styleoption = new QStyleOptionMenuItem();
+ }
+ break;
case MenuItem:
case ComboBoxItem:
{
@@ -327,8 +372,40 @@ void QStyleItem::initStyleOption()
m_styleoption = new QStyleOptionMenuItem();
QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption);
- opt->checked = false;
- opt->text = text();
+ // For GTK style. See below, in setElementType()
+ setProperty("_q_isComboBoxPopupItem", m_itemType == ComboBoxItem);
+ if (text().isEmpty()) {
+ opt->menuItemType = QStyleOptionMenuItem::Separator;
+ } else {
+ opt->text = text();
+
+ if (m_properties["isSubmenu"].toBool()) {
+ opt->menuItemType = QStyleOptionMenuItem::SubMenu;
+ } else {
+ QString shortcut = m_properties["shortcut"].toString();
+ if (!shortcut.isEmpty()) {
+ opt->text += QLatin1Char('\t') + shortcut;
+ opt->tabWidth = qMax(opt->tabWidth, textWidth(shortcut));
+ }
+
+ if (m_properties["checkable"].toBool()) {
+ opt->checked = on();
+ QVariant exclusive = m_properties["exclusive"];
+ opt->checkType = exclusive.toBool() ? QStyleOptionMenuItem::Exclusive :
+ QStyleOptionMenuItem::NonExclusive;
+ } else {
+ opt->menuItemType = QStyleOptionMenuItem::Normal;
+ }
+ }
+ if (m_properties["icon"].canConvert<QIcon>())
+ opt->icon = m_properties["icon"].value<QIcon>();
+
+ if (const QFont *font = QGuiApplicationPrivate::platformTheme()->font(QPlatformTheme::MenuFont)) {
+ opt->font = *font;
+ opt->fontMetrics = QFontMetrics(opt->font);
+ m_font = opt->font;
+ }
+ }
}
break;
case CheckBox:
@@ -340,6 +417,8 @@ void QStyleItem::initStyleOption()
QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
if (!on())
opt->state |= QStyle::State_Off;
+ if (m_hints.contains("partiallyChecked"))
+ opt->state |= QStyle::State_NoChange;
opt->text = text();
}
break;
@@ -356,6 +435,7 @@ void QStyleItem::initStyleOption()
m_styleoption = new QStyleOptionComboBox();
QStyleOptionComboBox *opt = qstyleoption_cast<QStyleOptionComboBox*>(m_styleoption);
opt->currentText = text();
+ opt->editable = false;
}
break;
case SpinBox: {
@@ -383,6 +463,8 @@ void QStyleItem::initStyleOption()
m_styleoption = new QStyleOptionSlider();
QStyleOptionSlider *opt = qstyleoption_cast<QStyleOptionSlider*>(m_styleoption);
+ opt->orientation = horizontal() ? Qt::Horizontal : Qt::Vertical;
+ opt->upsideDown = !horizontal();
opt->minimum = minimum();
opt->maximum = maximum();
opt->sliderPosition = value();
@@ -392,15 +474,16 @@ void QStyleItem::initStyleOption()
qreal numOfSteps = (opt->maximum - opt->minimum) / opt->singleStep;
// at least 5 pixels between tick marks
if (numOfSteps && (width() / numOfSteps < 5))
- opt->tickInterval = qRound((5*numOfSteps / width()) + 0.5)*step();
+ opt->tickInterval = qRound((5 * numOfSteps / width()) + 0.5) * step();
else
opt->tickInterval = opt->singleStep;
+
} else // default Qt-components implementation
opt->tickInterval = opt->maximum != opt->minimum ? 1200 / (opt->maximum - opt->minimum) : 0;
opt->sliderValue = value();
opt->subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
- opt->tickPosition = (activeControl() == "tick" ?
+ opt->tickPosition = (activeControl() == "ticks" ?
QSlider::TicksBelow : QSlider::NoTicks);
if (opt->tickPosition != QSlider::NoTicks)
opt->subControls |= QStyle::SC_SliderTickmarks;
@@ -428,12 +511,12 @@ void QStyleItem::initStyleOption()
opt->lineWidth = 1;
opt->subControls = QStyle::SC_GroupBoxLabel;
opt->features = 0;
- if (sunken()) { // Qt draws an ugly line here so I ignore it
+ if (m_properties["sunken"].toBool()) { // Qt draws an ugly line here so I ignore it
opt->subControls |= QStyle::SC_GroupBoxFrame;
} else {
opt->features |= QStyleOptionFrame::Flat;
}
- if (activeControl() == "checkbox")
+ if (m_properties["checkable"].toBool())
opt->subControls |= QStyle::SC_GroupBoxCheckBox;
}
@@ -450,31 +533,17 @@ void QStyleItem::initStyleOption()
opt->sliderPosition = value();
opt->sliderValue = value();
opt->activeSubControls = (activeControl() == QLatin1String("up"))
- ? QStyle::SC_ScrollBarSubLine :
- (activeControl() == QLatin1String("down")) ?
- QStyle::SC_ScrollBarAddLine:
- QStyle::SC_ScrollBarSlider;
+ ? QStyle::SC_ScrollBarSubLine : (activeControl() == QLatin1String("down")) ?
+ QStyle::SC_ScrollBarAddLine :
+ (activeControl() == QLatin1String("handle")) ?
+ QStyle::SC_ScrollBarSlider : hover() ? QStyle::SC_ScrollBarGroove : QStyle::SC_None;
+ if (raised())
+ opt->state |= QStyle::State_On;
opt->sliderValue = value();
opt->subControls = QStyle::SC_All;
-
- }
- case MenuBar:
- if (!m_styleoption) {
- QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem();
- menuOpt->menuItemType = QStyleOptionMenuItem::EmptyArea;
- m_styleoption = menuOpt;
- }
-
- break;
- case MenuBarItem:
- if (!m_styleoption) {
- QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem();
- menuOpt->text = text();
- menuOpt->menuItemType = QStyleOptionMenuItem::Normal;
- m_styleoption = menuOpt;
- }
break;
+ }
default:
break;
}
@@ -483,12 +552,18 @@ void QStyleItem::initStyleOption()
m_styleoption = new QStyleOption();
m_styleoption->styleObject = this;
- m_styleoption->rect = QRect(m_paintMargins, m_paintMargins, width() - 2* m_paintMargins, height() - 2 * m_paintMargins);
+ m_styleoption->rect = QRect(m_paintMargins, 0, width() - 2* m_paintMargins, height());
- if (isEnabled())
+ if (isEnabled()) {
m_styleoption->state |= QStyle::State_Enabled;
+ m_styleoption->palette.setCurrentColorGroup(QPalette::Active);
+ } else {
+ m_styleoption->palette.setCurrentColorGroup(QPalette::Disabled);
+ }
if (m_active)
m_styleoption->state |= QStyle::State_Active;
+ else
+ m_styleoption->palette.setCurrentColorGroup(QPalette::Inactive);
if (m_sunken)
m_styleoption->state |= QStyle::State_Sunken;
if (m_raised)
@@ -504,9 +579,9 @@ void QStyleItem::initStyleOption()
if (m_horizontal)
m_styleoption->state |= QStyle::State_Horizontal;
- if (m_hint.indexOf("mini") != -1) {
+ if (m_hints.indexOf("mini") != -1) {
m_styleoption->state |= QStyle::State_Mini;
- } else if (m_hint.indexOf("small") != -1) {
+ } else if (m_hints.indexOf("small") != -1) {
m_styleoption->state |= QStyle::State_Small;
}
@@ -599,9 +674,31 @@ QSize QStyleItem::sizeFromContents(int width, int height)
break;
case ToolButton: {
QStyleOptionToolButton *btn = qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
- int newWidth = qMax(width, btn->fontMetrics.width(btn->text));
- int newHeight = qMax(height, btn->fontMetrics.height());
- size = qApp->style()->sizeFromContents(QStyle::CT_ToolButton, m_styleoption, QSize(newWidth, newHeight)); }
+ int w = 0;
+ int h = 0;
+ if (btn->toolButtonStyle != Qt::ToolButtonTextOnly) {
+ QSize icon = btn->iconSize;
+ w = icon.width();
+ h = icon.height();
+ }
+ if (btn->toolButtonStyle != Qt::ToolButtonIconOnly) {
+ QSize textSize = btn->fontMetrics.size(Qt::TextShowMnemonic, btn->text);
+ textSize.setWidth(textSize.width() + btn->fontMetrics.width(QLatin1Char(' '))*2);
+ if (btn->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
+ h += 4 + textSize.height();
+ if (textSize.width() > w)
+ w = textSize.width();
+ } else if (btn->toolButtonStyle == Qt::ToolButtonTextBesideIcon) {
+ w += 4 + textSize.width();
+ if (textSize.height() > h)
+ h = textSize.height();
+ } else { // TextOnly
+ w = textSize.width();
+ h = textSize.height();
+ }
+ }
+ btn->rect.setSize(QSize(w, h));
+ size = qApp->style()->sizeFromContents(QStyle::CT_ToolButton, m_styleoption, QSize(w, h)); }
break;
case Button: {
QStyleOptionButton *btn = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
@@ -632,11 +729,21 @@ QSize QStyleItem::sizeFromContents(int width, int height)
break;
case Edit:
size = qApp->style()->sizeFromContents(QStyle::CT_LineEdit, m_styleoption, QSize(width,height));
- if (hint().indexOf("rounded") != -1)
+ if (hints().indexOf("rounded") != -1)
size += QSize(0, 3);
break;
- case GroupBox:
- size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(width,height));
+ case GroupBox: {
+ QStyleOptionGroupBox *box = qstyleoption_cast<QStyleOptionGroupBox*>(m_styleoption);
+ QFontMetrics metrics(box->fontMetrics);
+ int baseWidth = metrics.width(box->text) + metrics.width(QLatin1Char(' '));
+ int baseHeight = metrics.height() + m_contentHeight;
+ if (box->subControls & QStyle::SC_GroupBoxCheckBox) {
+ baseWidth += qApp->style()->pixelMetric(QStyle::PM_IndicatorWidth);
+ baseWidth += qApp->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing);
+ baseHeight = qMax(baseHeight, qApp->style()->pixelMetric(QStyle::PM_IndicatorHeight));
+ }
+ size = qApp->style()->sizeFromContents(QStyle::CT_GroupBox, m_styleoption, QSize(qMax(baseWidth, m_contentWidth), baseHeight));
+ }
break;
case Header:
size = qApp->style()->sizeFromContents(QStyle::CT_HeaderSection, m_styleoption, QSize(width,height));
@@ -649,16 +756,38 @@ QSize QStyleItem::sizeFromContents(int width, int height)
case Item: //fall through
size = qApp->style()->sizeFromContents(QStyle::CT_ItemViewItem, m_styleoption, QSize(width,height));
break;
- case MenuBarItem: //fall through
+ case MenuBarItem:
size = qApp->style()->sizeFromContents(QStyle::CT_MenuBarItem, m_styleoption, QSize(width,height));
break;
- case MenuBar: //fall through
+ case MenuBar:
size = qApp->style()->sizeFromContents(QStyle::CT_MenuBar, m_styleoption, QSize(width,height));
break;
+ case Menu:
+ size = qApp->style()->sizeFromContents(QStyle::CT_Menu, m_styleoption, QSize(width,height));
+ break;
+ case MenuItem:
+ case ComboBoxItem:
+ size = qApp->style()->sizeFromContents(QStyle::CT_MenuItem, m_styleoption, QSize(width,height));
+ break;
default:
break;
+ } return size;
+}
+
+void QStyleItem::setContentWidth(int arg)
+{
+ if (m_contentWidth != arg) {
+ m_contentWidth = arg;
+ emit contentWidthChanged(arg);
+ }
+}
+
+void QStyleItem::setContentHeight(int arg)
+{
+ if (m_contentHeight != arg) {
+ m_contentHeight = arg;
+ emit contentHeightChanged(arg);
}
- return size;
}
void QStyleItem::updateSizeHint()
@@ -667,11 +796,17 @@ void QStyleItem::updateSizeHint()
setImplicitSize(implicitSize.width(), implicitSize.height());
}
+void QStyleItem::updateRect()
+{
+ initStyleOption();
+ m_styleoption->rect.setWidth(width());
+}
+
int QStyleItem::pixelMetric(const QString &metric)
{
if (metric == "scrollbarExtent")
- return qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0) + 1;
+ return qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0 );
else if (metric == "defaultframewidth")
return qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0);
else if (metric == "taboverlap")
@@ -688,12 +823,24 @@ int QStyleItem::pixelMetric(const QString &metric)
return qApp->style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0 );
else if (metric == "tabvshift")
return qApp->style()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, 0 );
+ else if (metric == "menubarhmargin")
+ return qApp->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0 );
+ else if (metric == "menubarvmargin")
+ return qApp->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0 );
+ else if (metric == "menubarpanelwidth")
+ return qApp->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0 );
+ else if (metric == "menubaritemspacing")
+ return qApp->style()->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0 );
+ else if (metric == "spacebelowmenubar")
+ return qApp->style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, m_styleoption);
else if (metric == "menuhmargin")
return qApp->style()->pixelMetric(QStyle::PM_MenuHMargin, 0 );
else if (metric == "menuvmargin")
return qApp->style()->pixelMetric(QStyle::PM_MenuVMargin, 0 );
else if (metric == "menupanelwidth")
return qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0 );
+ else if (metric == "submenuoverlap")
+ return qApp->style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0 );
else if (metric == "splitterwidth")
return qApp->style()->pixelMetric(QStyle::PM_SplitterWidth, 0 );
else if (metric == "scrollbarspacing")
@@ -717,17 +864,21 @@ QVariant QStyleItem::styleHint(const QString &metric)
if (result == Qt::AlignCenter)
return "center";
return "left";
- } else if (metric == "framearoundcontents") {
+ } else if (metric == "frameOnlyAroundContents") {
return qApp->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents);
} else if (metric == "scrollToClickPosition")
return qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition);
+ else if (metric == "transientScrollBars")
+ return qApp->style()->styleHint(QStyle::SH_ScrollBar_Transient, m_styleoption);
return 0;
+
+ // Add SH_Menu_SpaceActivatesItem, SH_Menu_SubMenuPopupDelay
}
-void QStyleItem::setHint(const QStringList &str)
+void QStyleItem::setHints(const QStringList &str)
{
- if (m_hint != str) {
- m_hint = str;
+ if (m_hints != str) {
+ m_hints = str;
initStyleOption();
updateSizeHint();
if (m_styleoption->state & QStyle::State_Mini) {
@@ -757,8 +908,10 @@ void QStyleItem::setElementType(const QString &str)
}
// Only enable visible if the widget can animate
- if (str == "menu" || str == "menuitem") {
- m_itemType = (str == "menu") ? Menu : MenuItem;
+ if (str == "menu") {
+ m_itemType = Menu;
+ } else if (str == "menuitem") {
+ m_itemType = MenuItem;
} else if (str == "item" || str == "itemrow" || str == "header") {
#ifdef Q_OS_MAC
m_font.setPointSize(11.0);
@@ -889,6 +1042,8 @@ QRectF QStyleItem::subControlRect(const QString &subcontrolString)
void QStyleItem::paint(QPainter *painter)
{
initStyleOption();
+ if (QStyleOptionMenuItem *opt = qstyleoption_cast<QStyleOptionMenuItem*>(m_styleoption))
+ painter->setFont(opt->font);
switch (m_itemType) {
case Button:
@@ -920,7 +1075,7 @@ void QStyleItem::paint(QPainter *painter)
case ToolButton:
#ifdef Q_OS_MAC
- if (style() == "mac" && hint().indexOf("segmented") != -1) {
+ if (style() == "mac" && hints().indexOf("segmented") != -1) {
const QPaintDevice *target = painter->device();
HIThemeSegmentDrawInfo sgi;
sgi.version = 0;
@@ -936,10 +1091,10 @@ void QStyleItem::paint(QPainter *painter)
}
SInt32 button_height;
GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height);
- sgi.position = info() == "leftmost" ? kHIThemeSegmentPositionFirst:
- info() == "rightmost" ? kHIThemeSegmentPositionLast :
- info() == "h_middle" ? kHIThemeSegmentPositionMiddle :
- kHIThemeSegmentPositionOnly;
+ sgi.position = hints().contains("leftmost") ? kHIThemeSegmentPositionFirst:
+ hints().contains("rightmost") ? kHIThemeSegmentPositionLast :
+ hints().contains("h_middle") ? kHIThemeSegmentPositionMiddle :
+ kHIThemeSegmentPositionOnly;
QRect centered = m_styleoption->rect;
centered.setHeight(button_height);
centered.moveCenter(m_styleoption->rect.center());
@@ -950,13 +1105,20 @@ void QStyleItem::paint(QPainter *painter)
qApp->style()->drawComplexControl(QStyle::CC_ToolButton, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter);
break;
case Tab:
- qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter);
+ if (style() == "mac") {
+ m_styleoption->rect.translate(0, 1); // Unhack QMacStyle's hack
+ qApp->style()->drawControl(QStyle::CE_TabBarTabShape, m_styleoption, painter);
+ m_styleoption->rect.translate(0, -1);
+ qApp->style()->drawControl(QStyle::CE_TabBarTabLabel, m_styleoption, painter);
+ } else {
+ qApp->style()->drawControl(QStyle::CE_TabBarTab, m_styleoption, painter);
+ }
break;
case Frame:
qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter);
break;
case FocusFrame:
- if (style() == "mac" && hint().indexOf("rounded") != -1)
+ if (style() == "mac" && hints().indexOf("rounded") != -1)
break; // embedded in the line itself
else
qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter);
@@ -982,7 +1144,7 @@ void QStyleItem::paint(QPainter *painter)
break;
case Edit: {
#ifdef Q_OS_MAC
- if (style() == "mac" && hint().indexOf("rounded") != -1) {
+ if (style() == "mac" && hints().indexOf("rounded") != -1) {
const QPaintDevice *target = painter->device();
HIThemeFrameDrawInfo fdi;
fdi.version = 0;
@@ -1058,17 +1220,21 @@ void QStyleItem::paint(QPainter *painter)
qApp->style()->drawControl(QStyle::CE_ProgressBar, m_styleoption, painter);
break;
case ToolBar:
+ painter->fillRect(m_styleoption->rect, m_styleoption->palette.window().color());
qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter);
+ painter->setPen(m_styleoption->palette.dark().color().darker(120));
+ painter->drawLine(m_styleoption->rect.bottomLeft(), m_styleoption->rect.bottomRight());
break;
case StatusBar:
if (style() == "mac") {
- m_styleoption->rect.adjust(0, 1, 0, 0);
qApp->style()->drawControl(QStyle::CE_ToolBar, m_styleoption, painter);
- m_styleoption->rect.adjust(0, -1, 0, 0);
painter->setPen(m_styleoption->palette.dark().color().darker(120));
painter->drawLine(m_styleoption->rect.topLeft(), m_styleoption->rect.topRight());
} else {
- qApp->style()->drawPrimitive(QStyle::PE_PanelToolBar, m_styleoption, painter);
+ painter->fillRect(m_styleoption->rect, m_styleoption->palette.window().color());
+ painter->setPen(m_styleoption->palette.dark().color().darker(120));
+ painter->drawLine(m_styleoption->rect.topLeft(), m_styleoption->rect.topRight());
+ qApp->style()->drawPrimitive(QStyle::PE_PanelStatusBar, m_styleoption, painter);
}
break;
case GroupBox:
@@ -1076,6 +1242,7 @@ void QStyleItem::paint(QPainter *painter)
break;
case ScrollBar:
qApp->style()->drawComplexControl(QStyle::CC_ScrollBar, qstyleoption_cast<QStyleOptionComplex*>(m_styleoption), painter);
+ setOn(false);
break;
case Menu: {
QStyleHintReturnMask val;
@@ -1086,11 +1253,14 @@ void QStyleItem::paint(QPainter *painter)
painter->restore();
qApp->style()->drawPrimitive(QStyle::PE_PanelMenu, m_styleoption, painter);
- QStyleOptionFrame frame;
- frame.lineWidth = qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth);
- frame.midLineWidth = 0;
- frame.rect = m_styleoption->rect;
- qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter);
+ if (int fw = qApp->style()->pixelMetric(QStyle::PM_MenuPanelWidth)) {
+ QStyleOptionFrame frame;
+ frame.state = QStyle::State_None;
+ frame.lineWidth = fw;
+ frame.midLineWidth = 0;
+ frame.rect = m_styleoption->rect;
+ qApp->style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, painter);
+ }
}
break;
default:
@@ -1103,6 +1273,11 @@ int QStyleItem::textWidth(const QString &text)
return QFontMetrics(m_font).boundingRect(text).width();
}
+int QStyleItem::textHeight(const QString &text)
+{
+ return QFontMetrics(m_font).boundingRect(text).height();
+}
+
QString QStyleItem::elidedText(const QString &text, int elideMode, int width)
{
return qApp->fontMetrics().elidedText(text, Qt::TextElideMode(elideMode), width);
@@ -1140,8 +1315,10 @@ QSGNode *QStyleItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
void QStyleItem::updatePolish()
{
- if (width() > 0 && height() > 0) {
- m_image = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
+ if (width() >= 1 && height() >= 1) { // Note these are reals so 1 pixel is minimum
+ float devicePixelRatio = window() ? window()->devicePixelRatio() : qApp->devicePixelRatio();
+ m_image = QImage(width() * devicePixelRatio, height() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
+ m_image.setDevicePixelRatio(devicePixelRatio);
m_image.fill(Qt::transparent);
QPainter painter(&m_image);
paint(&painter);
diff --git a/src/qtdesktop/qstyleitem_p.h b/src/private/qstyleitem_p.h
index 3a9e60b3..28111588 100644
--- a/src/qtdesktop/qstyleitem_p.h
+++ b/src/private/qstyleitem_p.h
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -41,15 +42,14 @@
#ifndef QSTYLEITEM_P_H
#define QSTYLEITEM_P_H
+#include <QtGui/qimage.h>
#include <QtQuick/qquickitem.h>
-#include <QtWidgets/QStyle>
-#include <QtGui/QImage>
-#include <QEvent>
-
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QWidget;
+class QStyleOption;
+
class QStyleItem: public QQuickItem
{
Q_OBJECT
@@ -66,9 +66,9 @@ class QStyleItem: public QQuickItem
Q_PROPERTY( QString elementType READ elementType WRITE setElementType NOTIFY elementTypeChanged)
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged)
- Q_PROPERTY( QString info READ info WRITE setInfo NOTIFY infoChanged)
Q_PROPERTY( QString style READ style NOTIFY styleChanged)
- Q_PROPERTY( QStringList hint READ hint WRITE setHint NOTIFY hintChanged)
+ Q_PROPERTY( QStringList hints READ hints WRITE setHints NOTIFY hintChanged)
+ Q_PROPERTY( QVariantMap properties READ properties WRITE setProperties NOTIFY propertiesChanged)
Q_PROPERTY( QFont font READ font NOTIFY fontChanged)
// For range controls
@@ -139,8 +139,8 @@ public:
QString elementType() const { return m_type; }
QString text() const { return m_text; }
QString activeControl() const { return m_activeControl; }
- QString info() const { return m_info; }
- QStringList hint() const { return m_hint; }
+ QStringList hints() const { return m_hints; }
+ QVariantMap properties() const { return m_properties; }
QFont font() const { return m_font;}
QString style() const;
@@ -160,41 +160,31 @@ public:
void setElementType(const QString &str);
void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}}
void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}}
- void setInfo(const QString &str) { if (m_info != str) {m_info = str; emit infoChanged();}}
- void setHint(const QStringList &str);
+ void setHints(const QStringList &str);
+ void setProperties(const QVariantMap &props) { if (m_properties != props) { m_properties = props; emit propertiesChanged(); } }
int contentWidth() const { return m_contentWidth; }
+ void setContentWidth(int arg);
+
int contentHeight() const { return m_contentHeight; }
+ void setContentHeight(int arg);
virtual void initStyleOption ();
+ Q_INVOKABLE int textWidth(const QString &);
+ Q_INVOKABLE int textHeight(const QString &);
+
public Q_SLOTS:
int pixelMetric(const QString&);
QVariant styleHint(const QString&);
void updateSizeHint();
+ void updateRect();
void updateItem(){polish();}
QString hitTest(int x, int y);
QRectF subControlRect(const QString &subcontrolString);
QString elidedText(const QString &text, int elideMode, int width);
- int textWidth(const QString &);
bool hasThemeIcon(const QString &) const;
- void setContentWidth(int arg)
- {
- if (m_contentWidth != arg) {
- m_contentWidth = arg;
- emit contentWidthChanged(arg);
- }
- }
-
- void setContentHeight(int arg)
- {
- if (m_contentHeight != arg) {
- m_contentHeight = arg;
- emit contentHeightChanged(arg);
- }
- }
-
Q_SIGNALS:
void elementTypeChanged();
void textChanged();
@@ -215,6 +205,7 @@ Q_SIGNALS:
void styleChanged();
void paintMarginsChanged();
void hintChanged();
+ void propertiesChanged();
void fontChanged();
void contentWidthChanged(int arg);
@@ -236,8 +227,8 @@ protected:
QString m_type;
QString m_text;
QString m_activeControl;
- QString m_info;
- QStringList m_hint;
+ QStringList m_hints;
+ QVariantMap m_properties;
QFont m_font;
bool m_sunken;
@@ -264,6 +255,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSTYLEITEM_P_H
diff --git a/src/private/qwheelarea.cpp b/src/private/qwheelarea.cpp
new file mode 100644
index 00000000..db3b5171
--- /dev/null
+++ b/src/private/qwheelarea.cpp
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwheelarea_p.h"
+
+QT_BEGIN_NAMESPACE
+
+// On Mac OS X, the scrolling speed in Safari is roughly 2.5 times faster
+// than in TextEdit (the native app). The former is using high-resolution
+// pixel-based delta values as they are, which is fine for a typical web
+// content, whereas the latter evidently makes scrolling slower to make it
+// feel natural and more precise for typical document type of content.
+// => we'll compromise between the two for now, and pick an arbitrary value
+// to make the pixel-based scrolling speed something between the two
+static const qreal pixelDeltaAdjustment = 0.5;
+
+// The default scroll speed for typical angle-based mouse wheels. The value
+// comes originally from QTextEdit, which sets 20px steps by default.
+static const qreal defaultScrollSpeed = 20.0;
+
+QWheelArea::QWheelArea(QQuickItem *parent)
+ : QQuickItem(parent),
+ m_horizontalMinimumValue(0),
+ m_horizontalMaximumValue(0),
+ m_verticalMinimumValue(0),
+ m_verticalMaximumValue(0),
+ m_horizontalValue(0),
+ m_verticalValue(0),
+ m_verticalDelta(0),
+ m_horizontalDelta(0),
+ m_scrollSpeed(defaultScrollSpeed)
+{
+
+}
+
+QWheelArea::~QWheelArea()
+{
+
+}
+
+void QWheelArea::wheelEvent(QWheelEvent *we)
+{
+ QPoint numPixels = we->pixelDelta();
+ QPoint numDegrees = we->angleDelta() / 8;
+
+ if (!numPixels.isNull()) {
+ setHorizontalDelta(numPixels.x() * pixelDeltaAdjustment);
+ setVerticalDelta(numPixels.y() * pixelDeltaAdjustment);
+ } else if (!numDegrees.isNull()) {
+ setHorizontalDelta(numDegrees.x() / 15.0 * m_scrollSpeed);
+ setVerticalDelta(numDegrees.y() / 15.0 * m_scrollSpeed);
+ }
+
+ we->accept();
+}
+
+void QWheelArea::setHorizontalMinimumValue(qreal value)
+{
+ m_horizontalMinimumValue = value;
+}
+
+qreal QWheelArea::horizontalMinimumValue() const
+{
+ return m_horizontalMinimumValue;
+}
+
+void QWheelArea::setHorizontalMaximumValue(qreal value)
+{
+ m_horizontalMaximumValue = value;
+}
+
+qreal QWheelArea::horizontalMaximumValue() const
+{
+ return m_horizontalMaximumValue;
+}
+
+void QWheelArea::setVerticalMinimumValue(qreal value)
+{
+ m_verticalMinimumValue = value;
+}
+
+qreal QWheelArea::verticalMinimumValue() const
+{
+ return m_verticalMinimumValue;
+}
+
+void QWheelArea::setVerticalMaximumValue(qreal value)
+{
+ m_verticalMaximumValue = value;
+}
+
+qreal QWheelArea::verticalMaximumValue() const
+{
+ return m_verticalMaximumValue;
+}
+
+void QWheelArea::setHorizontalValue(qreal value)
+{
+ value = qBound<qreal>(m_horizontalMinimumValue, value, m_horizontalMaximumValue);
+
+ if (value != m_horizontalValue) {
+ m_horizontalValue = value;
+ emit horizontalValueChanged();
+ }
+}
+
+qreal QWheelArea::horizontalValue() const
+{
+ return m_horizontalValue;
+}
+
+void QWheelArea::setVerticalValue(qreal value)
+{
+ value = qBound<qreal>(m_verticalMinimumValue, value, m_verticalMaximumValue);
+
+ if (value != m_verticalValue) {
+ m_verticalValue = value;
+ emit verticalValueChanged();
+ }
+}
+
+qreal QWheelArea::verticalValue() const
+{
+ return m_verticalValue;
+}
+
+void QWheelArea::setVerticalDelta(qreal value)
+{
+ m_verticalDelta = value;
+ setVerticalValue(m_verticalValue - m_verticalDelta);
+
+ emit verticalWheelMoved();
+}
+
+qreal QWheelArea::verticalDelta() const
+{
+ return m_verticalDelta;
+}
+
+void QWheelArea::setHorizontalDelta(qreal value)
+{
+ m_horizontalDelta = value;
+ setHorizontalValue(m_horizontalValue - m_horizontalDelta);
+
+ emit horizontalWheelMoved();
+}
+
+qreal QWheelArea::horizontalDelta() const
+{
+ return m_horizontalDelta;
+}
+
+void QWheelArea::setScrollSpeed(qreal value)
+{
+ if (value != m_scrollSpeed) {
+ m_scrollSpeed = value;
+ emit scrollSpeedChanged();
+ }
+}
+
+qreal QWheelArea::scrollSpeed() const
+{
+ return m_scrollSpeed;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qtdesktop/qwheelarea_p.h b/src/private/qwheelarea_p.h
index 6c0209df..ac556816 100644
--- a/src/qtdesktop/qwheelarea_p.h
+++ b/src/private/qwheelarea_p.h
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -42,11 +43,8 @@
#define QWHEELAREA_P_H
#include <QtGui/qevent.h>
-#include <QtWidgets/qgraphicssceneevent.h>
#include <QtQuick/qquickitem.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
class QWheelArea : public QQuickItem
@@ -120,6 +118,4 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QWheelArea)
-QT_END_HEADER
-
#endif // QWHEELAREA_P_H
diff --git a/src/qtdesktop/ApplicationWindow.qml b/src/qtdesktop/ApplicationWindow.qml
deleted file mode 100644
index 453edfa9..00000000
--- a/src/qtdesktop/ApplicationWindow.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-/*!
- \qmltype ApplicationWindow
- \inqmlmodule QtDesktop 1.0
- \brief ApplicationWindow is doing bla...bla...
-*/
-
-Window {
- id: root
- width: 320
- height: 240
-
- property MenuBar menuBar
- property alias toolBar: toolBarArea.data
- property alias statusBar: statusBarArea.data
- default property alias data: contentArea.data
- property alias backgroundColor: syspal.window
- property bool showMenuBar: menuBar ? menuBar.showMenuBar : false
-
- SystemPalette {id: syspal}
-
- Rectangle {
- anchors.fill: parent
- color: backgroundColor
- }
-
- StyleItem {
- id: menuBarArea
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- elementType: "menubar"
- visible: showMenuBar
- contentHeight: showMenuBar ? 20 : 0
- Row {
- id: row
- anchors.fill: parent
- Repeater {
- model: showMenuBar ? menuBar.menuList.length : 0
- StyleItem {
- id: menuItem
- elementType: "menubaritem"
- contentWidth: 100
- contentHeight: 20
- width: text.paintedWidth + 12
- height :text.paintedHeight + 4
- sunken: true
- selected: mouse.pressed
- property var menu: menuBar.menuList[index]
- Text {
- id: text
- text: menu.text
- anchors.centerIn: parent
- renderType: Text.NativeRendering
- color: menuItem.selected ? syspal.highlightedText : syspal.windowText
- }
- MouseArea {
- id: mouse
- anchors.fill:parent
- onPressed: menu.showPopup(menuItem.x, menuBarArea.height, 0, root)
- }
- }
- }
- }
- }
-
- Item {
- id: contentArea
- anchors.top: toolBarArea.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: statusBarArea.top
- }
-
- Row {
- id: toolBarArea
- anchors.top: menuBarArea.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- }
-
- Row {
- id: statusBarArea
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- }
-}
diff --git a/src/qtdesktop/ButtonColumn.qml b/src/qtdesktop/ButtonColumn.qml
deleted file mode 100644
index a1662992..00000000
--- a/src/qtdesktop/ButtonColumn.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import "private/ButtonGroup.js" as Behavior
-
-/*!
- \qmltype ButtonColumn
- \inqmlmodule QtDesktop 1.0
- \brief ButtonColumn allows you to group Buttons in a column. It provides a selection-behavior as well.
-
- Note: This component don't support the enabled property.
- If you need to disable it you should disable all the buttons inside it.
-
- \qml
- ButtonColumn {
- Button { text: "Top" }
- Button { text: "Bottom" }
- }
- \endqml
-*/
-Column {
- id: root
-
- /*
- * Property: exclusive
- * [bool=true] Specifies the grouping behavior. If enabled, the checked property on buttons contained
- * in the group will be exclusive.
- *
- * Note that a button in an exclusive group will allways be checkable
- */
- property bool exclusive: true
-
- /*
- * Property: styleHints
- * [string] Used to indicate special OS specific button types
- */
- property var styleHints:[]
-
- /*
- * Property: checkedButton
- * [string] Contains the last checked Button.
- */
- property Item checkedButton;
-
- Component.onCompleted: {
- Behavior.create(root, {direction: Qt.Vertical});
- }
-
- Component.onDestruction: {
- Behavior.destroy();
- }
-
-}
diff --git a/src/qtdesktop/ButtonRow.qml b/src/qtdesktop/ButtonRow.qml
deleted file mode 100644
index 6a019af6..00000000
--- a/src/qtdesktop/ButtonRow.qml
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import "private/ButtonGroup.js" as Behavior
-
-/*!
- \qmltype ButtonRow
- \inqmlmodule QtDesktop 1.0
- \brief ButtonRow allows you to group Buttons in a row. It provides a selection-behavior as well.
-
- Note: This component don't support the enabled property.
- If you need to disable it you should disable all the buttons inside it.
-
- \qml
- ButtonRow {
- Button { text: "Left" }
- Button { text: "Right" }
- }
- \endqml
-*/
-Row {
- id: root
-
- /*
- * Property: exclusive
- * [bool=false] Specifies the grouping behavior. If enabled, the checked property on buttons contained
- * in the group will be exclusive.
- *
- * Note that a button in an exclusive group will allways be checkable
- */
- property bool exclusive: false
-
- /*
- * Property: styleHints
- * [string] Used to indicate special OS specific button types
- */
- property var styleHints
- /*
- * Property: checkedButton
- * [string] Contains the last checked Button.
- */
- property Item checkedButton;
-
- Component.onCompleted: {
- Behavior.create(root, {direction: Qt.Horizontal});
- }
-
- Component.onDestruction: {
- Behavior.destroy();
- }
-}
diff --git a/src/qtdesktop/CheckBox.qml b/src/qtdesktop/CheckBox.qml
deleted file mode 100644
index 5c84400f..00000000
--- a/src/qtdesktop/CheckBox.qml
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "Styles/Settings.js" as Settings
-import "private"
-
-/*!
- \qmltype CheckBox
- \inqmlmodule QtDesktop 1.0
- \brief A checkbox with a text label
-
- A CheckBox is an option button that can be toggled on (checked) or off
- (unchecked). Checkboxes are typically used to represent features in an
- application that can be enabled or disabled without affecting others.
-
- The state of the checkbox can be set with the \l checked property.
-
- The text of the label shown next to the checkbox can be set with the \l text
- property.
-
- Whenever a CheckBox is clicked, it emits the clicked() signal.
-*/
-
-FocusScope {
- id: checkBox
-
- /*!
- Emitted whenever the checkbox is clicked.
- */
- signal clicked
-
- /*!
- \qmlproperty bool pressed
-
- This property is \c true if the checkbox is pressed.
- Set this property to manually invoke a mouse click.
- */
- property alias pressed: behavior.effectivePressed
-
- /*!
- \qmlproperty bool checked
-
- This property is \c true if the checkbox is checked.
- */
- property alias checked: behavior.checked
-
- /*!
- \qmlproperty bool containsMouse
-
- This property is \c true if the checkbox currently contains the mouse
- cursor.
- */
- property alias containsMouse: behavior.containsMouse
-
- /*!
- This property is \c true if the checkbox takes the focus when it is
- pressed; \l{QQuickItem::forceActiveFocus()}{forceActiveFocus()} will be
- called on the checkbox.
- */
- property bool activeFocusOnPress: false
-
- /*!
- This property holds the text that the label should display.
- */
- property string text
-
- /*!
- \internal
- */
- property var styleHints:[]
-
- // implementation
- Accessible.role: Accessible.CheckBox
- Accessible.name: text
-
- implicitWidth: Math.max(120, loader.item ? loader.item.implicitWidth : 0)
- implicitHeight: loader.item ? loader.item.implicitHeight : 0
-
- /*!
- The style that should be applied to the checkbox. Custom style
- components can be created with:
-
- \codeline Qt.createComponent("path/to/style.qml", checkBoxId);
- */
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/CheckBoxStyle.qml", checkBox)
-
- Loader {
- id: loader
- anchors.fill: parent
- property alias control: checkBox
- sourceComponent: style
- }
-
- ButtonBehavior {
- id: behavior
- focus: true
- anchors.fill: parent
- checkable: true
- onClicked: checkBox.clicked();
- onPressed: if (checkBox.activeFocusOnPress) checkBox.forceActiveFocus();
- }
-
- Keys.onPressed: {
- if (event.key == Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed)
- behavior.keyPressed = true;
- }
-
- Keys.onReleased: {
- if (event.key == Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
- behavior.keyPressed = false;
- checked = !checked;
- checkBox.clicked();
- }
- }
-}
diff --git a/src/qtdesktop/ComboBox.qml b/src/qtdesktop/ComboBox.qml
deleted file mode 100644
index e08c2822..00000000
--- a/src/qtdesktop/ComboBox.qml
+++ /dev/null
@@ -1,136 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "private" as Private
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype ComboBox
- \inqmlmodule QtDesktop 1.0
- \brief ComboBox is a combined button and popup list. The popup menu itself is platform
- native, and cannot by styled from QML code.
-
- Add menu items to the comboBox by either adding MenuItem children inside the popup, or
- assign it a ListModel (or both).
-
- The ComboBox contains the following API (in addition to the BasicButton API):
-
- ListModel model - this model will be used, in addition to MenuItem children, to
- create items inside the popup menu
- bool popupOpen - setting this property to 'true' will open the popup.
- int selectedIndex - the index of the selected item in the popup menu.
- int hoveredIndex - the index of the highlighted item in the popup menu.
- string selectedText - the text of the selected menu item.
- string hoveredText - the text of the highlighted menu item.
-
- Example 1:
-
- \qml
- ListModel {
- id: menuItems
- ListElement { text: "Banana"; color: "Yellow" }
- ListElement { text: "Apple"; color: "Green" }
- ListElement { text: "Coconut"; color: "Brown" }
- }
- ComboBox {
- model: menuItems
- width: 200
- onSelectedIndexChanged: console.debug(selectedText + ", " + menuItems.get(selectedIndex).color)
- }
- \endqml
-
- Example 2:
-
- \qml
- ComboBox {
- width: 200
- MenuItem {
- text: "Pineapple"
- onSelected: console.debug(text)
-
- }
- MenuItem {
- text: "Grape"
- onSelected: console.debug(text)
- }
- }
- \endqml
-*/
-
-Private.BasicButton {
- id: comboBox
-
- default property alias menuItems: popup.menuItems
- property alias model: popup.model
- property alias popupOpen: popup.visible
-
- property alias selectedIndex: popup.selectedIndex
- property alias hoveredIndex: popup.hoveredIndex
- property alias selectedText: popup.selectedText
- property alias hoveredText: popup.hoveredText
- property var styleHints:[]
-
- style: Qt.createComponent(Settings.THEME_PATH + "/ComboBoxStyle.qml", comboBox)
-
-// ToDo: adjust margins so that selected popup label
-// centers directly above button label when
-// popup.centerOnSelectedText === true
-
- width: implicitWidth
- height: implicitHeight
- onWidthChanged: popup.setMinimumWidth(width)
- checkable: false
- onPressedChanged: if (pressed) popup.visible = true
-
- ContextMenu {
- id: popup
- property bool center: false
- centerSelectedText: center
- y: center ? 0 : comboBox.height
- }
-
- // The key bindings below will only be in use when popup is
- // not visible. Otherwise, native popup key handling will take place:
- Keys.onSpacePressed: { comboBox.popupOpen = !comboBox.popupOpen }
- Keys.onUpPressed: { if (selectedIndex < model.count - 1) selectedIndex++ }
- Keys.onDownPressed: { if (selectedIndex > 0) selectedIndex-- }
-}
diff --git a/src/qtdesktop/ContextMenu.qml b/src/qtdesktop/ContextMenu.qml
deleted file mode 100644
index a97867e3..00000000
--- a/src/qtdesktop/ContextMenu.qml
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-/*!
- \qmltype ContextMenu
- \inqmlmodule QtDesktop 1.0
- \brief ContextMenu is doing bla...bla...
-*/
-
-Menu {
- id: root
- property string selectedText: itemTextAt(selectedIndex)
- property string hoveredText: itemTextAt(hoveredIndex)
- property string textRole
-
- // 'centerSelectedText' means that the menu will be positioned
- // so that the selected text' top left corner will be at x, y.
- property bool centerSelectedText: true
-
- visible: false
- onMenuClosed: visible = false
- onModelChanged: if (Component.status === Component.Ready && model !== undefined) rebuildMenu()
-
- Component.onCompleted: if (model !== undefined) rebuildMenu()
-
- onHoveredIndexChanged: {
- if (hoveredIndex < menuItems.length)
- menuItems[hoveredIndex].hovered()
- }
-
- onSelectedIndexChanged: {
- if (hoveredIndex < menuItems.length)
- menuItems[hoveredIndex].selected()
- }
-
- onVisibleChanged: {
- if (visible) {
- var globalPos = mapToItem(null, x, y)
- showPopup(globalPos.x, globalPos.y, centerSelectedText ? selectedIndex : 0)
- } else {
- hidePopup()
- }
- }
-
- function rebuildMenu()
- {
- clearMenuItems();
-
- for (var i=0; i<menuItems.length; ++i)
- addMenuItem(menuItems[i].text)
-
- var nativeModel = root.hasNativeModel()
-
- if (model !== undefined) {
- var modelCount = nativeModel ? root.modelCount() : model.count;
- for (var j = 0 ; j < modelCount; ++j) {
- var textValue
- if (nativeModel) {
- textValue = root.modelTextAt(j);
- } else {
- if (textRole !== "")
- textValue = model.get(j)[textRole]
- else if (model.count > 0 && root.model.get && root.model.get(0)) {
- // ListModel with one role
- var listElement = root.model.get(0)
- var oneRole = true
- var roleName = ""
- var roleCount = 0
- for (var role in listElement) {
- if (!roleName || role === "text")
- roleName = role
- ++roleCount
- }
- if (roleCount > 1 && roleName !== "text") {
- oneRole = false
- console.log("Warning: No textRole set for ComboBox.")
- break
- }
-
- if (oneRole) {
- root.textRole = roleName
- textValue = root.model.get(j)[textRole]
- }
- }
- }
- addMenuItem(textValue)
- }
- }
- }
-}
diff --git a/src/qtdesktop/GroupBox.qml b/src/qtdesktop/GroupBox.qml
deleted file mode 100644
index 80f8ef9f..00000000
--- a/src/qtdesktop/GroupBox.qml
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype GroupBox
- \inqmlmodule QtDesktop 1.0
- \brief GroupBox is doing bla...bla...
-*/
-
-Item {
- id: groupbox
- implicitWidth: Math.max(200, contentWidth + (loader.item ? loader.item.implicitWidth: 0) )
- implicitHeight: contentHeight + (loader.item ? loader.item.implicitHeight : 0) + 4
-
- default property alias data: content.data
-
- property string title
- property bool flat: false
- property bool checkable: false
- property int contentWidth: content.childrenRect.width
- property int contentHeight: content.childrenRect.height
-
- property Item checkbox: check
- property alias checked: check.checked
- property bool adjustToContentSize: false // Resizes groupbox to fit contents.
- // Note when using this, you cannot anchor children
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/GroupBoxStyle.qml", groupbox)
-
- Accessible.role: Accessible.Grouping
- Accessible.name: title
-
- Loader {
- id: loader
- property alias control: groupbox
- anchors.fill: parent
- property int topMargin: title.length > 0 || checkable ? 22 : 4
- property int bottomMargin: 4
- property int leftMargin: 4
- property int rightMargin: 4
- sourceComponent: style
- onLoaded: item.z = -1
- }
-
- CheckBox {
- id: check
- checked: true
- visible: checkable
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- height: loader.topMargin
- }
-
- Item {
- id:content
- z: 1
- focus: true
- anchors.topMargin: loader.topMargin
- anchors.leftMargin: 8
- anchors.rightMargin: 8
- anchors.bottomMargin: 8
- anchors.fill: parent
- enabled: (!checkable || checkbox.checked)
- }
-}
diff --git a/src/qtdesktop/Page.qml b/src/qtdesktop/Page.qml
deleted file mode 100644
index c4edb857..00000000
--- a/src/qtdesktop/Page.qml
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-/*!
- \qmltype Page
- \inqmlmodule QtDesktop 1.0
- \brief A Page is an Item you can push on a PageStack
-
- A \a Page is the main Item pushed onto a \l PageStack. It normally contains a discrete
- set of information and interaction elements meant for the user to solve a specific task, and
- contains properties to use when working with a PageStack.
- See \l PageStack for more information.
-
- \qml
- \endqml
-*/
-
-Item {
- id: root
-
- /*! \readonly
- The status of the page. It can have one of the following values:
- \list
- \li \c PageStatus.Inactive: the page is not visible
- \li \c PageStatus.Activating: the page is transitioning into becoming an active page on the stack
- \li \c PageStatus.Active: the page is on top of the stack
- \li \c PageStatus.Deactivating: the page is transitioning into becoming inactive
- \endlist */
- readonly property alias status: root.__status
- /*! \readonly
- This property contains the PageStack the page is in. If the page is not inside
- a PageStack, \a pageStack will be \c null. */
- readonly property alias pageStack: root.__pageStack
- /*! \readonly
- This property contains the index of the page inside \l{pageStack}{PageStack}, so
- that \l{PageStack::get()}{pageStack.get(index)} will
- return the page itself. If \l{Page::pageStack}{pageStack} is \c null, \a index
- will be \c -1. */
- readonly property alias index: root.__index
- /*! This property can be set to override the default animations used
- during a page transition. To better understand how to use this
- property, refer to the \l{PageStack#Transitions}{transition documentation} in PageStack.
- \sa {PageStack::animations}{PageStack.animations} */
- property PageTransition pageTransition
-
- visible: false // PageStack will show/hide the page as needed
- width: parent.width
- height: parent.height
-
- // ********** PRIVATE API **********
-
- /*! \internal */
- property int __status: PageStatus.Inactive
- /*! \internal */
- property PageStack __pageStack: null
- /*! \internal */
- property int __index: -1
-}
diff --git a/src/qtdesktop/ProgressBar.qml b/src/qtdesktop/ProgressBar.qml
deleted file mode 100644
index 4ad9134a..00000000
--- a/src/qtdesktop/ProgressBar.qml
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype ProgressBar
- \inqmlmodule QtDesktop 1.0
- \brief ProgressBar is doing bla...bla...
-*/
-
-Item {
- id: progressbar
-
- property real value: 0
- property real minimumValue: 0
- property real maximumValue: 1
- property bool indeterminate: false
- property bool containsMouse: mouseArea.containsMouse
-
- property int minimumWidth: 0
- property int minimumHeight: 0
-
- property int orientation: Qt.Horizontal
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/ProgressBarStyle.qml", progressbar)
- property var styleHints:[]
-
- Accessible.role: Accessible.ProgressBar
- Accessible.name: value
-
- implicitWidth: orientation === Qt.Horizontal ? 200 : (loader.item ? loader.item.implicitHeight : 0)
- implicitHeight: orientation === Qt.Horizontal ? (loader.item ? loader.item.implicitHeight : 0) : 200
-
- Loader {
- id: loader
- property alias indeterminate: progressbar.indeterminate
- property alias value: progressbar.value
- property alias maximumValue: progressbar.maximumValue
- property alias minimumValue: progressbar.minimumValue
-
- property alias control: progressbar
- sourceComponent: style
- anchors.fill: parent
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- hoverEnabled: true
- }
-}
-
diff --git a/src/qtdesktop/ScrollArea.qml b/src/qtdesktop/ScrollArea.qml
deleted file mode 100644
index d52cf68c..00000000
--- a/src/qtdesktop/ScrollArea.qml
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "private" as Private
-
-/*!
- \qmltype ScrollArea
- \inqmlmodule QtDesktop 1.0
- \brief ScrollArea is doing bla...bla...
-*/
-
-FocusScope {
- id: root
- width: 100
- height: 100
-
- // Cosmetic propeties
- property bool frame: true
- property bool frameAroundContents: true
- property bool highlightOnFocus: false
- property alias color: colorRect.color // background color
- property int frameWidth: frame ? styleitem.frameWidth : 0
-
- // Viewport properties
- property int contentX
- property int contentY
- property int contentHeight : content.childrenRect.height
- property int contentWidth: content.childrenRect.width
- property int viewportHeight: height - (scroller.horizontalScrollBar.visible ?
- scroller.verticalScrollBar.height : 0) - 2 * frameWidth
- property int viewportWidth: width - (scroller.verticalScrollBar.visible ?
- scroller.verticalScrollBar.width : 0) - 2 * frameWidth
- default property alias data: content.data
-
- Rectangle {
- id: colorRect
- color: "transparent"
- anchors.fill:styleitem
- anchors.margins: frameWidth
- }
-
- StyleItem {
- id: styleitem
- elementType: "frame"
- sunken: true
- visible: frame
- anchors.fill: parent
- anchors.rightMargin: frame ? (frameAroundContents ?
- (scroller.verticalScrollBar.visible ?
- scroller.verticalScrollBar.width + 2 * frameMargins : 0) : 0) : 0
- anchors.bottomMargin: frame ? (frameAroundContents ?
- (scroller.horizontalScrollBar.visible ?
- scroller.horizontalScrollBar.height + 2 * frameMargins : 0) : 0) : 0
- anchors.topMargin: frame ? (frameAroundContents ? 0 : 0) : 0
- property int frameWidth
- property int scrollbarspacing: styleitem.pixelMetric("scrollbarspacing");
- property int frameMargins : frame ? scrollbarspacing : 0
- Component.onCompleted: {
- frameWidth = styleitem.pixelMetric("defaultframewidth");
- frameAroundContents = styleitem.styleHint("framearoundcontents")
- }
- }
-
- onContentYChanged: {
- scroller.blockUpdates = true
- scroller.verticalScrollBar.value = contentY
- scroller.verticalValue = contentY
- scroller.blockUpdates = false
- }
-
- onContentXChanged: {
- scroller.blockUpdates = true
- scroller.horizontalScrollBar.value = contentX
- scroller.horizontalValue = contentX
- scroller.blockUpdates = false
- }
-
- Item {
- id: clipper
- anchors.fill: styleitem
- anchors.margins: frameWidth
- clip: true
- Item {
- id: content
- x: -root.contentX
- y: -root.contentY
- }
- }
-
-
- Private.ScrollAreaHelper {
- id: scroller
- anchors.fill: parent
- }
-
- StyleItem {
- z: 2
- anchors.fill: parent
-
- anchors.topMargin: -3
- anchors.leftMargin: -3
- anchors.rightMargin: -5
- anchors.bottomMargin: -5
-
- visible: highlightOnFocus && parent.activeFocus && styleitem.styleHint("focuswidget")
- elementType: "focusframe"
- }
-}
diff --git a/src/qtdesktop/SpinBox.qml b/src/qtdesktop/SpinBox.qml
deleted file mode 100644
index 1656e53e..00000000
--- a/src/qtdesktop/SpinBox.qml
+++ /dev/null
@@ -1,249 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype SpinBox
- \inqmlmodule QtDesktop 1.0
- \brief SpinBox is doing bla...bla...
-*/
-
-FocusScope {
- id: spinbox
-
- property int minimumWidth: 0
- property int minimumHeight: 0
-
- /*!
- The value of this SpinBox, clamped to \l minimumValue and \l maximumValue.
- */
- property real value: 0
- /*!
- The minimum value of the SpinBox range.
- The \l value is clamped to this value.
- */
- property real minimumValue: 0
- /*!
- The maximum value of the SpinBox range.
- The \l value is clamped to this value.
- */
- property real maximumValue: 99
- /*!
- The amount by which the \l value is incremented/decremented.
- */
- property real singleStep: 1
- /*
- \qmlproperty string inputMask
- The inputMask for the text input.
- */
- property alias inputMask: input.inputMask
- property string postfix
- property var styleHints:[]
-
- property bool upEnabled: value != maximumValue;
- property bool downEnabled: value != minimumValue;
- property alias upPressed: mouseUp.pressed
- property alias downPressed: mouseDown.pressed
- property alias upHovered: mouseUp.containsMouse
- property alias downHovered: mouseDown.containsMouse
- property alias containsMouse: mouseArea.containsMouse
- property alias font: input.font
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/SpinBoxStyle.qml", spinbox)
-
- Accessible.name: input.text
- Accessible.role: Accessible.SpinBox
-
- width: implicitWidth
- height: implicitHeight
-
- implicitWidth: loader.item ? loader.item.implicitWidth : 0
- implicitHeight: loader.item ? loader.item.implicitHeight : 0
-
- /*!
- Increments \l value by \l singleStep, clamping to \l maximumValue
- if the new value is too large.
- */
- function increment() {
- setValue(input.text)
- value += singleStep
- if (value > maximumValue)
- value = maximumValue
- input.text = value
- }
-
- /*!
- Increments \l value by \l singleStep, clamping to \l minimumValue
- if the new value is too small.
- */
- function decrement() {
- setValue(input.text)
- value -= singleStep
- if (value < minimumValue)
- value = minimumValue
- input.text = value
- }
-
- /*!
- Sets \l value to \a v, clamping to \l minimumValue and \l maximumValue
- if \a v is not within this range.
- */
- function setValue(v) {
- var newval = parseFloat(v)
- if (newval > maximumValue)
- newval = maximumValue
- else if (v < minimumValue)
- newval = minimumValue
- value = newval
- input.text = value
- }
-
- Component.onCompleted: setValue(value)
-
- onValueChanged: {
- input.valueUpdate = true
- input.text = value
- input.valueUpdate = false
- }
-
- Loader {
- id: loader
- property alias control: spinbox
- sourceComponent: style
- anchors.fill: parent
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- hoverEnabled: true
- }
-
- // Spinbox input field
-
- TextInput {
- id: input
-
- property bool valueUpdate: false
- property Item styleItem: loader.item
-
- clip: true
-
- horizontalAlignment: styleItem ? styleItem.horizontalTextAlignment : Qt.AlignLeft
- verticalAlignment: styleItem ? styleItem.verticalTextAlignment : Qt.AlignVCenter
- anchors.fill: parent
- anchors.leftMargin: styleItem ? styleItem.leftMargin : 0
- anchors.topMargin: styleItem ? styleItem.topMargin : 0
- anchors.rightMargin: styleItem ? styleItem.rightMargin: 0
- anchors.bottomMargin: styleItem ? styleItem.bottomMargin: 0
- selectByMouse: true
-
- // validator: DoubleValidator { bottom: minimumValue; top: maximumValue; }
- onAccepted: {setValue(input.text)}
- onActiveFocusChanged: setValue(input.text)
- color: loader.item ? loader.item.foregroundColor : "black"
- selectionColor: loader.item ? loader.item.selectionColor : "black"
- selectedTextColor: loader.item ? loader.item.selectedTextColor : "black"
-
- opacity: parent.enabled ? 1 : 0.5
- renderType: Text.NativeRendering
- Text {
- text: postfix
- color: loader.item ? loader.item.foregroundColor : "black"
- anchors.rightMargin: 4
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- }
- }
-
- // Spinbox increment button
-
- MouseArea {
- id: mouseUp
- hoverEnabled: true
-
- property var upRect: loader.item ? loader.item.upRect : null
-
- anchors.left: parent.left
- anchors.top: parent.top
-
- anchors.leftMargin: upRect ? upRect.x : 0
- anchors.topMargin: upRect ? upRect.y : 0
-
- width: upRect ? upRect.width : 0
- height: upRect ? upRect.height : 0
-
- onClicked: increment()
-
- property bool autoincrement: false;
- onReleased: autoincrement = false
- Timer { running: mouseUp.pressed; interval: 350 ; onTriggered: mouseUp.autoincrement = true }
- Timer { running: mouseUp.autoincrement; interval: 60 ; repeat: true ; onTriggered: increment() }
- }
-
- // Spinbox decrement button
-
- MouseArea {
- id: mouseDown
- hoverEnabled: true
-
- onClicked: decrement()
- property var downRect: loader.item ? loader.item.downRect : null
-
- anchors.left: parent.left
- anchors.top: parent.top
-
- anchors.leftMargin: downRect ? downRect.x : 0
- anchors.topMargin: downRect ? downRect.y : 0
-
- width: downRect ? downRect.width : 0
- height: downRect ? downRect.height : 0
-
- property bool autoincrement: false;
- onReleased: autoincrement = false
- Timer { running: mouseDown.pressed; interval: 350 ; onTriggered: mouseDown.autoincrement = true }
- Timer { running: mouseDown.autoincrement; interval: 60 ; repeat: true ; onTriggered: decrement() }
- }
-
- Keys.onUpPressed: increment()
- Keys.onDownPressed: decrement()
-}
diff --git a/src/qtdesktop/SplitterColumn.qml b/src/qtdesktop/SplitterColumn.qml
deleted file mode 100644
index 3de5f9c4..00000000
--- a/src/qtdesktop/SplitterColumn.qml
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import "private" as Private
-import QtDesktop 1.0
-
-/*!
- \qmltype SplitterColumn
- \inqmlmodule QtDesktop 1.0
- \brief SplitterColumn is doing bla...bla...
-*/
-
-/*
-*
-* SplitterColumn
-*
-* SplitterColumn is a component that provides a way to layout items horisontally with
-* a draggable splitter added in-between each item.
-*
-* Add items to the SplitterColumn by inserting them as child items. The splitter handle
-* is outsourced as a delegate (handleDelegate). To enable the user to drag the handle,
-* it will need to contain a mouse area that communicates with the SplitterColumn by binding
-* 'drag.target: handle'. The 'handle' property points to the handle item that embeds
-* the delegate. To change handle positions, either change 'y; (or 'height') of 'handle', or
-* change the height of the child items inside the SplitterColumn. If you set the visibility
-* of a child item to false, the corresponding handle will also be hidden, and the
-* SplitterColumn will perform a layout update to fill up available space.
-*
-* There will always be one (and only one) item in the SplitterColumn that is 'expanding'.
-* The expanding item is the child that will get all the remaining space in the SplitterColumn
-* (down to its own mimimumHeight/Height) when all other items have been layed out.
-* This means that that 'height', 'percentageHeight' and 'maximumHeight' will be ignored for this item.
-* By default, the last visible child item of the SplitterColumn will be 'expanding'.
-*
-* A handle can belong to the item on the left side, or the right side, of the handle. Which one depends
-* on the expaning item. If the expanding item is to the right of the handle, the
-* handle will belong to the item on the left. If it is to the left, it will belong to the item on the
-* right. This will again control which item that gets resized when the user drags a handle, and which
-* handle that gets hidden when an item is told to hide.
-*
-* NB: Since SplitterColumn might modify geometry properties like 'height' and 'y; of child items
-* to e.g. ensure they stay within minimumHeight/maximumHeight, explicit expression bindings
-* to such properties can easily be broken up by the SplitterColumn, and is not recommended.
-*
-* The SplitterColumn contains the following API:
-*
-* Component handleDelegate - delegate that will be instanciated between each
-* child item. Inside the delegate, the following properties are available:
-* int handleIndex - specifies the index of the splitter handle. The handle
-* between the first and the second item will get index 0, the next handle index 1 etc.
-* Item handle - convenience property that points to the item where the handle background is
-* instanciated as a child. Identical to splitterColumn.handles[handleIndex]. The handle
-* background iteself can be accessed through handle.item.
-* Modify 'handle[d.offset]' to move the handle (or change 'height' of SplitterColumn child items).
-* Item splitterItem - convenience property that points to the child item that the handle controls.
-* Also refer to information about the expanding item above.
-* Item splitterColumn - points to the SplitterColumn that the handle is in.
-* List<Item> items - contains the list of child items in the SplitterColumn. Currently read-only.
-* List<Item> handles - contains the list of splitter handles in the SplitterColumn. Note that this list will
-* be populated after all child items has completed, so accessing it from Component.onCompleted
-* inside a SplitterColumn child item will not work. To get to the handle background, access the
-* 'background' property of the handle, e.g. handles[0].background. Read-only.
-* real preferredHeight/Height - contains the accumulated with of all child items and handles, except
-* the expanding item. If the expanding item has a minimum height, the minimum height will
-* be included.
-*
-* The following attached properties can be used for each child item of SplitterColumn:
-*
-* real Splitter.minimumSize - ensures that the item cannot be resized below the
-* given pixelvalue. A value of -1 will disable it.
-* real Splitter.maximumSize - ensures that the item cannot be resized above the
-* given pixelvalue. A value of -1 will disable it.
-* real percentageHeight - This value specifies a percentage (0 - 100) of the height of the
-* SplitterColumn height. If the height of the SplitterColumn change, the height of the item will
-* change as well. 'percentageHeight' have precedence over 'height', which means that
-* SplitterColumn will ignore any assignments to 'height'. A value of -1 disables it.
-* bool Splitter.expanding - See explanation of 'expanding' above. If set to true, the current item
-* will be the expanding item in the SplitterColumn. If set to false, the SplitterColumn will
-* autmatically choose the last visible child of the SplitterColumn as expanding instead.
-* int Splitter.itemIndex - will be assigned a read-only value with the item index. Can be used to e.g. look-up
-* the handles sourrounding the item (parent.handles[itemIndex])
-*
-* Example:
-*
-* To create a SplitterColumn with three items, and let
-* the center item be the one that should be expanding, one
-* could do the following:
-*
-* SplitterColumn {
-* anchors.fill: parent
-*
-* Rectangle {
-* Splitter.maximumSize: 400
-* color: "gray"
-* height: 200
-* }
-* Rectangle {
-* Splitter.minimumSize: 50
-* Splitter.expanding: true
-* color: "darkgray"
-* }
-* Rectangle {
-* color: "gray"
-* height: 200
-* }
-* }
-*/
-
-Private.Splitter {
- orientation: Qt.Vertical
- handleDelegate: StyleItem {
- id: styleitem
- elementType: "splitter"
- height: handleWidth != -1 ? handleWidth : pixelMetric("splitterwidth")
- horizontal: false
- property alias pressed: mouseArea.pressed
- property bool dragged: mouseArea.drag.active
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- anchors.topMargin: (parent.height <= 1) ? -2 : 0
- anchors.bottomMargin: (parent.height <= 1) ? -2 : 0
- drag.axis: Drag.XandYAxis // Why doesn't X-axis work?
- drag.target: handle
- cursorShape: Qt.SplitVCursor
- }
- }
-}
diff --git a/src/qtdesktop/SplitterRow.qml b/src/qtdesktop/SplitterRow.qml
deleted file mode 100644
index 6f970723..00000000
--- a/src/qtdesktop/SplitterRow.qml
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import "private" as Private
-import QtDesktop 1.0
-
-/*!
- \qmltype SplitterRow
- \inqmlmodule QtDesktop 1.0
- \brief SplitterRow is doing bla...bla...
-*/
-
-/*
-*
-* SplitterRow
-*
-* SplitterRow is a component that provides a way to layout items horisontally with
-* a draggable splitter added in-between each item.
-*
-* Add items to the SplitterRow by inserting them as child items. The splitter handle
-* is outsourced as a delegate (handleDelegate). To enable the user to drag the handle,
-* it will need to contain a mouse area that communicates with the SplitterRow by binding
-* 'drag.target: handle'. The 'handle' property points to the handle item that embeds
-* the delegate. To change handle positions, either change 'x' (or 'width') of 'handle', or
-* change the width of the child items inside the SplitterRow. If you set the visibility
-* of a child item to false, the corresponding handle will also be hidden, and the
-* SplitterRow will perform a layout update to fill up available space.
-*
-* There will always be one (and only one) item in the SplitterRow that is 'expanding'.
-* The expanding item is the child that will get all the remaining space in the SplitterRow
-* (down to its own mimimumWidth/Height) when all other items have been layed out.
-* This means that that 'width', 'percentageWidth' and 'maximumWidth' will be ignored for this item.
-* By default, the last visible child item of the SplitterRow will be 'expanding'.
-*
-* A handle can belong to the item on the left side, or the right side, of the handle. Which one depends
-* on the expaning item. If the expanding item is to the right of the handle, the
-* handle will belong to the item on the left. If it is to the left, it will belong to the item on the
-* right. This will again control which item that gets resized when the user drags a handle, and which
-* handle that gets hidden when an item is told to hide.
-*
-* NB: Since SplitterRow might modify geometry properties like 'width' and 'x' of child items
-* to e.g. ensure they stay within minimumWidth/maximumWidth, explicit expression bindings
-* to such properties can easily be broken up by the SplitterRow, and is not recommended.
-*
-* The SplitterRow contains the following API:
-*
-* Component handleDelegate - delegate that will be instanciated between each
-* child item. Inside the delegate, the following properties are available:
-* int handleIndex - specifies the index of the splitter handle. The handle
-* between the first and the second item will get index 0, the next handle index 1 etc.
-* Item handle - convenience property that points to the item where the handle background is
-* instanciated as a child. Identical to splitterRow.handles[handleIndex]. The handle
-* background iteself can be accessed through handle.item.
-* Modify 'handle[d.offset]' to move the handle (or change 'width' of SplitterRow child items).
-* Item splitterItem - convenience property that points to the child item that the handle controls.
-* Also refer to information about the expanding item above.
-* Item splitterRow - points to the SplitterRow that the handle is in.
-* List<Item> items - contains the list of child items in the SplitterRow. Currently read-only.
-* List<Item> handles - contains the list of splitter handles in the SplitterRow. Note that this list will
-* be populated after all child items has completed, so accessing it from Component.onCompleted
-* inside a SplitterRow child item will not work. To get to the handle background, access the
-* 'background' property of the handle, e.g. handles[0].background. Read-only.
-* real preferredWidth/Height - contains the accumulated with of all child items and handles, except
-* the expanding item. If the expanding item has a minimum width, the minimum width will
-* be included.
-*
-* The following attached properties can optionally be used for each child item of SplitterRow:
-*
-* real Splitter.minimumSize - ensures that the item cannot be resized below the
-* given pixelvalue. A value of -1 will disable it.
-* real Splitter.maximumSixe - ensures that the item cannot be resized above the
-* given value. A value of -1 will disable it.
-* real Splitter.percentageSize - This value specifies a percentage (0 - 100) of the width of the
-* SplitterRow width. If the width of the SplitterRow change, the width of the item will
-* change as well. 'percentageWidth' have precedence over 'width', which means that
-* SplitterRow will ignore any assignments to 'width'. A value of -1 disables it.
-* bool Splitter.expanding - See explanation of 'expanding' above. If set to true, the current item
-* will be the expanding item in the SplitterRow. If set to false, the SplitterRow will
-* autmatically choose the last visible child of the SplitterRow as expanding instead.
-* int Splitter.itemIndex - will be assigned a read-only value with the item index. Can be used to e.g. look-up
-* the handles sourrounding the item (parent.handles[itemIndex])
-*
-* Example:
-*
-* To create a SplitterRow with three items, and let
-* the center item be the one that should be expanding, one
-* could do the following:
-*
-* SplitterRow {
-* anchors.fill: parent
-*
-* Rectangle {
-* Splitter.maximumWidth: 400
-* color: "gray"
-* width: 200
-* }
-* Rectangle {
-* Splitter.minimumWidth: 50
-* Splitter.expanding: true
-* color: "darkgray"
-* }
-* Rectangle {
-* color: "gray"
-* width: 200
-* }
-* }
-*/
-
-
-Private.Splitter {
- orientation: Qt.Horizontal
- handleDelegate: StyleItem {
- id: styleitem
- elementType: "splitter"
- width: handleWidth != -1 ? handleWidth : pixelMetric("splitterwidth")
- property alias pressed: mouseArea.pressed
- property bool dragged: mouseArea.drag.active
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- anchors.leftMargin: (parent.width <= 1) ? -2 : 0
- anchors.rightMargin: (parent.width <= 1) ? -2 : 0
- drag.axis: Qt.YAxis
- drag.target: handle
- cursorShape: Qt.SplitHCursor
- }
- }
-}
diff --git a/src/qtdesktop/TabFrame.qml b/src/qtdesktop/TabFrame.qml
deleted file mode 100644
index f64f89dc..00000000
--- a/src/qtdesktop/TabFrame.qml
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "private"
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype TabFrame
- \inqmlmodule QtDesktop 1.0
- \brief Represents a control that contains multiple items that share the same space on the screen.
-
-*/
-
-Item {
- id: tabWidget
- width: 100
- height: 100
-
- property int current: 0
- property int count: stack.children.length
- property bool frame: true
- property bool tabsVisible: true
- property string position: "North"
- default property alias tabs : stack.children
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/TabFrameStyle.qml", tabWidget)
- property var __styleItem: loader.item
-
- onCurrentChanged: __setOpacities()
- Component.onCompleted: __setOpacities()
-
- function __setOpacities() {
- for (var i = 0; i < stack.children.length; ++i) {
- stack.children[i].visible = (i == current ? true : false)
- }
- }
-
- Component {
- id: tabcomp
- Tab {}
- }
-
- function addTab(component, title) {
- var tab = tabcomp.createObject(this);
- component.createObject(tab)
- tab.parent = stack
- tab.title = title
- __setOpacities()
- return tab
- }
-
- function removeTab(id) {
- var tab = tabs[id]
- tab.destroy()
- if (current > 0)
- current-=1
- }
-
- Loader {
- id: loader
- sourceComponent: style
- property var control: tabWidget
- }
-
- Loader {
- id: frameLoader
-
- anchors.fill: parent
- anchors.topMargin: tabbarItem && tabsVisible && position == "North" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0
- anchors.bottomMargin: tabbarItem && tabsVisible && position == "South" ? Math.max(0, tabbarItem.height - stack.baseOverlap) : 0
- sourceComponent: frame && loader.item ? loader.item.frame : null
- property var control: tabWidget
-
- Item {
- id: stack
- anchors.fill: parent
- anchors.margins: (frame ? frameWidth : 0)
- anchors.topMargin: anchors.margins + (style =="mac" ? 6 : 0)
- anchors.bottomMargin: anchors.margins + (style =="mac" ? 6 : 0)
- property int frameWidth
- property string style
- property int baseOverlap
- }
- onLoaded: { item.z = -1 }
- }
-
- TabBar {
- id: tabbarItem
- tabFrame: tabWidget
- style: loader.item
- anchors.top: parent.top
- anchors.left: tabWidget.left
- anchors.right: tabWidget.right
- }
-
- states: [
- State {
- name: "South"
- when: position == "South" && tabbarItem != undefined
- PropertyChanges {
- target: tabbarItem
- anchors.topMargin: tabbarItem.height
- }
- AnchorChanges {
- target: tabbarItem
- anchors.top: undefined
- anchors.bottom: tabWidget.bottom
- }
- }
- ]
-}
diff --git a/src/qtdesktop/TableView.qml b/src/qtdesktop/TableView.qml
deleted file mode 100644
index ff4e3ec6..00000000
--- a/src/qtdesktop/TableView.qml
+++ /dev/null
@@ -1,663 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "private" as Private
-
-/*!
- \qmltype TableView
- \inqmlmodule QtDesktop 1.0
- \brief TableView is doing bla...bla...
-*/
-
-/*
-*
-* TableView
-*
-* This component provides an item-view with resizable
-* header sections.
-*
-* You can style the drawn delegate by overriding the itemDelegate
-* property. The following properties are supported for custom
-* delegates:
-*
-* Note: Currently only row selection is available for this component
-*
-* itemheight - default platform size of item
-* itemwidth - default platform width of item
-* itemselected - if the row is currently selected
-* itemvalue - The text for this item
-* itemforeground - The default text color for an item
-*
-* For example:
-* itemDelegate: Item {
-* Text {
-* anchors.verticalCenter: parent.verticalCenter
-* color: itemForeground
-* elide: Text.ElideRight
-* text: itemValue
-* }
-* }
-*
-* Data for each row is provided through a model:
-*
-* ListModel {
-* ListElement{ column1: "value 1"; column2: "value 2"}
-* ListElement{ column1: "value 3"; column2: "value 4"}
-* }
-*
-* You provide title and size properties on TableColumns
-* by setting the default header property :
-*
-* TableView {
-* TableColumn{ role: "column1" ; title: "Column 1" ; width:100}
-* TableColumn{ role: "column2" ; title: "Column 2" ; width:200}
-* model: datamodel
-* }
-*
-* The header sections are attached to values in the datamodel by defining
-* the listmodel property they attach to. Each property in the model, will
-* then be shown in each column section.
-*
-* The view itself does not provide sorting. This has to
-* be done on the model itself. However you can provide sorting
-* on the model and enable sort indicators on headers.
-*
-* sortColumn - The index of the currently selected sort header
-* sortIndicatorVisible - If sort indicators should be enabled
-* sortIndicatorDirection - "up" or "down" depending on state
-*
-*/
-
-FocusScope{
- id: root
-
- property variant model
-
- // Framewidth seems to be 1 regardless of style
- property int frameWidth: frame ? frameitem.frameWidth : 0;
- width: 200
- height: 200
-
- // Cosmetic properties
- property bool frame: true
- property bool frameAroundContents: styleitem.styleHint("framearoundcontents")
- property bool highlightOnFocus: false
- property bool alternateRowColor: true
- property bool headerVisible: true
-
- // Styling properties
- property Component itemDelegate: standardDelegate
- property Component rowDelegate: rowDelegate
- property Component headerDelegate: headerDelegate
- property color backgroundColor: "white"
-
- // Sort properties
- property int sortColumn // Index of currently selected sort column
- property bool sortIndicatorVisible: false // enables or disables sort indicator
- property string sortIndicatorDirection: "down" // "up" or "down" depending on current state
-
- // Item properties
- default property alias header: tree.columnheader
- property alias contentHeader: tree.header
- property alias contentFooter: tree.footer
- property alias currentItem: tree.currentItem
-
- property alias horizontalScrollBar: scroller.horizontalScrollBar
- property alias verticalScrollBar: scroller.verticalScrollBar
-
- // Viewport properties
- property alias contentX: tree.contentX
- property alias contentY: tree.contentY
- property alias contentHeight : tree.contentHeight
- property alias contentWidth: tree.contentWidth
- property alias viewportWidth: scroller.availableWidth
- property alias viewportHeight: scroller.availableHeight
- property alias count: tree.count
- property alias section: tree.section
-
- property alias cacheBuffer: tree.cacheBuffer
- property alias currentIndex: tree.currentIndex // Should this be currentRowIndex?
-
- Accessible.role: Accessible.Table
-
- // Signals
- signal activated
-
- Component {
- id: standardDelegate
- Item {
- height: Math.max(16, styleitem.implicitHeight)
- property int implicitWidth: sizehint.paintedWidth + 4
- Text {
- id: label
- objectName: "label"
- width: parent.width
- anchors.margins: 6
- font: itemstyle.font
- anchors.left: parent.left
- anchors.right: parent.right
- horizontalAlignment: itemTextAlignment
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue != undefined ? itemValue : ""
- color: itemForeground
- renderType: Text.NativeRendering
- }
- Text {
- id: sizehint
- font: label.font
- text: itemValue ? itemValue : ""
- visible: false
- }
- }
- }
-
- StyleItem {
- id: itemstyle
- elementType: "item"
- visible:false
- }
-
- Component {
- id: nativeDelegate
- // This gives more native styling, but might be less performant
- StyleItem {
- elementType: "item"
- text: itemValue
- selected: itemSelected
- }
- }
-
- Component {
- id: headerDelegate
- StyleItem {
- elementType: "header"
- activeControl: itemSort
- raised: true
- sunken: itemPressed
- text: itemValue
- hover: itemContainsMouse
- info: itemPosition
- }
- }
-
- Component {
- id: rowDelegate
- StyleItem {
- id: rowstyle
- elementType: "itemrow"
- activeControl: itemAlternateBackground ? "alternate" : ""
- selected: itemSelected ? true : false
- height: Math.max(16, styleitem.implicitHeight)
- }
- }
-
- Rectangle {
- id: colorRect
- color: backgroundColor
- anchors.fill: frameitem
- anchors.margins: frameWidth
- anchors.rightMargin: (!frameAroundContents && verticalScrollBar.visible ? verticalScrollBar.width : 0) + frameWidth
- anchors.bottomMargin: (!frameAroundContents && horizontalScrollBar.visible ? horizontalScrollBar.height : 0) +frameWidth
- }
-
- StyleItem {
- id: frameitem
- elementType: "frame"
- Component.onCompleted: frameWidth = styleitem.pixelMetric("defaultframewidth");
- sunken: true
- visible: frame
- anchors.fill: parent
- anchors.rightMargin: frame ? (frameAroundContents ? (verticalScrollBar.visible ? verticalScrollBar.width + 2 * frameMargins : 0) : 0) : 0
- anchors.bottomMargin: frame ? (frameAroundContents ? (horizontalScrollBar.visible ? horizontalScrollBar.height + 2 * frameMargins : 0) : 0) : 0
- anchors.topMargin: frame ? frameAroundContents : 0
- anchors.leftMargin: frame ? frameAroundContents : 0
- property int frameWidth
- property int scrollbarspacing: styleitem.pixelMetric("scrollbarspacing");
- property int frameMargins : frame ? scrollbarspacing : 0
- }
- MouseArea {
- id: mousearea
-
- anchors.fill: tree
-
- property bool autoincrement: false
- property bool autodecrement: false
-
- onReleased: {
- autoincrement = false
- autodecrement = false
- }
-
- // Handle vertical scrolling whem dragging mouse outside boundraries
- Timer { running: mousearea.autoincrement && verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: incrementCurrentIndex()}
- Timer { running: mousearea.autodecrement && verticalScrollBar.visible; repeat: true; interval: 20 ; onTriggered: decrementCurrentIndex()}
-
- onPositionChanged: {
- if (mouseY > tree.height && pressed) {
- if (autoincrement) return;
- autodecrement = false;
- autoincrement = true;
- } else if (mouseY < 0 && pressed) {
- if (autodecrement) return;
- autoincrement = false;
- autodecrement = true;
- } else {
- autoincrement = false;
- autodecrement = false;
- }
- var y = Math.min(contentY + tree.height - 5, Math.max(mouseY + contentY, contentY));
- var newIndex = tree.indexAt(0, y);
- if (newIndex >= 0)
- tree.currentIndex = tree.indexAt(0, y);
- }
-
- onPressed: {
- tree.forceActiveFocus()
- var x = Math.min(contentWidth - 5, Math.max(mouseX + contentX, 0))
- var y = Math.min(contentHeight - 5, Math.max(mouseY + contentY, 0))
- tree.currentIndex = tree.indexAt(x, y)
- }
-
- onDoubleClicked: {
- parent.activated()
- }
- }
-
- function decrementCurrentIndex() {
- scroller.blockUpdates = true;
- tree.decrementCurrentIndex();
- scroller.verticalValue = contentY;
- scroller.blockUpdates = false;
- }
-
- function incrementCurrentIndex() {
- scroller.blockUpdates = true;
- tree.incrementCurrentIndex();
- scroller.verticalValue = contentY;
- scroller.blockUpdates = false;
- }
-
- ListView {
- id: tree
-
- property list<TableColumn> columnheader
- highlightFollowsCurrentItem: true
- model: root.model
- interactive: false
-
- anchors.top: tableColumn.bottom
- anchors.left: frameitem.left
- anchors.right: frameitem.right
- anchors.bottom: frameitem.bottom
- anchors.margins: frameWidth
- anchors.topMargin: -frameWidth
- anchors.rightMargin: (!frameAroundContents && verticalScrollBar.visible ? verticalScrollBar.width: 0) + frameWidth
- anchors.bottomMargin: (!frameAroundContents && horizontalScrollBar.visible ? horizontalScrollBar.height : 0) + frameWidth
-
- focus: true
- clip: true
-
- // Fills extra rows with alternate color
- Column {
- id: rowfiller
- property variant rowHeight: Math.max(1, contentHeight / count)
- property int rowCount: height/rowHeight
- y: contentHeight
- width: parent.width
- visible: contentHeight > 0 && alternateRowColor && !verticalScrollBar.visible
- height: parent.height - contentHeight
- Repeater {
- model: visible ? rowfiller.rowCount : 0
- Loader {
- width: rowfiller.width
- height: rowfiller.rowHeight
- sourceComponent: root.rowDelegate
- property bool itemAlternateBackground: (index + count) % 2 === 1
- property bool itemSelected: false
- property variant model: tree.model
- property variant modelData: null
- }
- }
- }
-
- Keys.onUpPressed: root.decrementCurrentIndex()
- Keys.onDownPressed: root.incrementCurrentIndex()
-
- Keys.onPressed: {
- if (event.key == Qt.Key_PageUp) {
- verticalScrollBar.value = verticalScrollBar.value - tree.height
- } else if (event.key == Qt.Key_PageDown)
- verticalScrollBar.value = verticalScrollBar.value + tree.height
- }
-
- Keys.onReturnPressed: root.activated();
-
- onContentYChanged: {
- scroller.blockUpdates = true
- scroller.verticalValue = tree.contentY
- verticalScrollBar.value = tree.contentY
- scroller.blockUpdates = false
- }
-
- onContentXChanged: {
- scroller.blockUpdates = true
- scroller.horizontalValue = tree.contentX
- horizontalScrollBar.value = tree.contentX
- scroller.blockUpdates = false
- }
-
- delegate: Item {
- id: rowitem
- width: row.width
- height: rowstyle.height
-
- anchors.margins: frameWidth
- property int rowIndex: model.index
- property bool itemAlternateBackground: alternateRowColor && rowIndex % 2 == 1
- property variant itemModelData: typeof modelData == "undefined" ? null : modelData
- property variant itemModel: model
-
- Loader {
- id: rowstyle
- // row delegate
- sourceComponent: root.rowDelegate
- // Row fills the tree width regardless of item size
- // But scrollbar should not adjust to it
- width: frameitem.width
- x: contentX
-
- property bool itemAlternateBackground: rowitem.itemAlternateBackground
- property bool itemSelected: rowitem.ListView.isCurrentItem
- property int index: rowitem.rowIndex
- property variant model: tree.model
- property variant modelData: rowitem.itemModelData
- property variant itemModel: rowitem.itemModel
- }
- Row {
- id: row
- anchors.left: parent.left
- height: parent.height
- Repeater {
- id: repeater
- model: root.header.length
- Loader {
- id: itemDelegateLoader
- height: parent.height
- visible: header[index].visible
- sourceComponent: header[index].delegate ? header[index].delegate : itemDelegate
- property variant model: tree.model
- property variant role: header[index].role
- property variant modelData: itemModelData
-
- width: header[index].width
-
- function getValue() {
- if (header[index].role.length && itemModel.hasOwnProperty(header[index].role))
- return itemModel[header[index].role] // Qml ListModel and QAbstractItemModel
- else if (modelData != undefined && modelData.hasOwnProperty(header[index].role))
- return modelData[header[index].role] // QObjectList / QObject
- else if (modelData != undefined)
- return modelData // Models without role
- else
- return ""
- }
- property variant itemValue: getValue()
- property bool itemSelected: rowitem.ListView.isCurrentItem
- property color itemForeground: itemSelected ? rowstyleitem.highlightedTextColor : rowstyleitem.textColor
- property int rowIndex: rowitem.rowIndex
- property int columnIndex: index
- property int itemElideMode: header[index].elideMode
- property int itemTextAlignment: header[index].textAlignment
- }
- }
- onWidthChanged: tree.contentWidth = width
- }
- }
- }
-
-
- Text{ id:text }
-
- Item {
- id: tableColumn
-
- anchors.top: frameitem.top
- anchors.left: frameitem.left
- anchors.right: frameitem.right
- anchors.margins: frameWidth
-
- clip: true
- visible: headerVisible
- height: headerVisible ? headerrow.height : frameWidth
-
- Behavior on height { NumberAnimation{ duration: 80 } }
-
- Row {
- id: headerrow
- anchors.top: parent.top
- x: -tree.contentX
-
- Repeater {
- id: repeater
-
- property int targetIndex: -1
- property int dragIndex: -1
-
- model: header.length
-
- delegate: Item {
- z:-index
- width: header[index].width
- visible: header[index].visible
- height: headerStyle.height
-
- Loader {
- id: headerStyle
- sourceComponent: root.headerDelegate
- anchors.left: parent.left
- anchors.right: parent.right
- property string itemValue: header[index].title
- property string itemSort: (sortIndicatorVisible && index == sortColumn) ? (sortIndicatorDirection == "up" ? "up" : "down") : "";
- property bool itemPressed: headerClickArea.pressed
- property bool itemContainsMouse: headerClickArea.containsMouse
- property string itemPosition: header.length === 1 ? "only" :
- index===header.length-1 ? "end" :
- index===0 ? "beginning" : ""
- }
- Rectangle{
- id: targetmark
- width: parent.width
- height:parent.height
- opacity: (index == repeater.targetIndex && repeater.targetIndex != repeater.dragIndex) ? 0.5 : 0
- Behavior on opacity { NumberAnimation{duration:160}}
- color: palette.highlight
- SystemPalette{id:palette}
- }
-
- MouseArea{
- id: headerClickArea
- drag.axis: Qt.YAxis
- hoverEnabled: true
- anchors.fill: parent
- onClicked: {
- if (sortColumn == index)
- sortIndicatorDirection = sortIndicatorDirection === "up" ? "down" : "up"
- sortColumn = index
- }
- // Here we handle moving header sections
- // NOTE: the direction is different from the master branch
- // so this indicates that Im using an invalid assumption on item ordering
- onPositionChanged: {
- if (pressed) { // only do this while dragging
- for (var h = header.length-1 ; h >= 0 ; --h) {
- if (drag.target.x > headerrow.children[h].x) {
- repeater.targetIndex = h
- break
- }
- }
- }
- }
-
- onPressed: {
- repeater.dragIndex = index
- draghandle.x = parent.x
- }
-
- onReleased: {
- if (repeater.targetIndex >= 0 && repeater.targetIndex != index ) {
- // Rearrange the header sections
- var items = new Array
- for (var i = 0 ; i< header.length ; ++i)
- items.push(header[i])
- items.splice(index, 1);
- items.splice(repeater.targetIndex, 0, header[index]);
- header = items
- if (sortColumn == index)
- sortColumn = repeater.targetIndex
- }
- repeater.targetIndex = -1
- }
- drag.maximumX: 1000
- drag.minimumX: -1000
- drag.target: draghandle
- }
-
- Loader {
- id: draghandle
- property string itemValue: header[index].title
- property string itemSort: (sortIndicatorVisible && index == sortColumn) ? (sortIndicatorDirection == "up" ? "up" : "down") : "";
- property bool itemPressed: headerClickArea.pressed
- property bool itemContainsMouse: headerClickArea.containsMouse
- property string itemPosition
-
- parent: tableColumn
- width: header[index].width
- height: parent.height
- sourceComponent: root.headerDelegate
- visible: headerClickArea.pressed
- opacity: 0.5
- }
-
-
- MouseArea {
- id: headerResizeHandle
- property int offset: 0
- property int minimumSize: 20
- anchors.rightMargin: -width/2
- width: 16 ; height: parent.height
- anchors.right: parent.right
- onPositionChanged: {
- var newHeaderWidth = header[index].width + (mouseX - offset)
- header[index].width = Math.max(minimumSize, newHeaderWidth)
- }
- property bool found:false
-
- onDoubleClicked: {
- var row
- var minWidth = 0
- var listdata = tree.children[0]
- for (row = 0 ; row < listdata.children.length ; ++row){
- var item = listdata.children[row+1]
- if (item && item.children[1] && item.children[1].children[index] &&
- item.children[1].children[index].children[0].hasOwnProperty("implicitWidth"))
- minWidth = Math.max(minWidth, item.children[1].children[index].children[0].implicitWidth)
- }
- if (minWidth)
- header[index].width = minWidth
- }
- onPressedChanged: if(pressed)offset=mouseX
- cursorShape: Qt.SplitHCursor
- }
- }
- }
- }
- Loader {
- id: loader
- property string itemValue
- property string itemSort
- property bool itemPressed
- property bool itemContainsMouse
- property string itemPosition
-
- anchors.top: parent.top
- anchors.right: parent.right
- anchors.bottom: headerrow.bottom
- anchors.rightMargin: -2
- sourceComponent: root.headerDelegate
- width: root.width - headerrow.width + 2
- visible: root.header.length
- z:-1
- }
- }
-
- Private.ScrollAreaHelper {
- id: scroller
- anchors.fill: parent
- anchors.topMargin: styleitem.style == "mac" ? tableColumn.height + frameWidth: 0
- scrollSpeed: 2
- }
-
- StyleItem {
- z: 2
- anchors.fill: parent
- anchors.margins: -4
- visible: highlightOnFocus && parent.activeFocus && styleitem.styleHint("focuswidget")
- elementType: "focusframe"
- }
-
- StyleItem {
- id: styleitem
- elementType: "header"
- visible:false
- contentWidth: 16
- contentHeight: font.pixelSize
- }
-
- StyleItem {
- id: rowstyleitem
- property color textColor: styleHint("textColor")
- property color highlightedTextColor: styleHint("highlightedTextColor")
- elementType: "item"
- visible: false
- }
-}
diff --git a/src/qtdesktop/TextField.qml b/src/qtdesktop/TextField.qml
deleted file mode 100644
index 3d5a3be4..00000000
--- a/src/qtdesktop/TextField.qml
+++ /dev/null
@@ -1,781 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-import "Styles"
-import "Styles/Settings.js" as Settings
-
-/*!
- \qmltype TextField
- \inqmlmodule QtDesktop 1.0
- \brief TextField displays a single line of editable plain text
-
- TextField is used to accept a line of text input. Input constraints
- can be placed on a TextField item (for example, through a \l validator or \l inputMask),
- and setting \l echoMode to an appropriate value enables TextField to be used for
- a password input field.
-
- \sa TextArea, TextInput
-*/
-
-FocusScope {
- id: textfield
-
- /*!
- \qmlproperty bool TextField::acceptableInput
-
- This property is always true unless a validator or input mask has been set.
- If a validator or input mask has been set, this property will only be true
- if the current text is acceptable to the validator or input mask as a final
- string (not as an intermediate string).
- */
- property alias acceptableInput: textInput.acceptableInput // read only
-
- /*!
- \qmlproperty bool TextField::activeFocusOnPress
-
- Whether the TextField should gain active focus on a mouse press. By default this is
- set to true.
- */
- property alias activeFocusOnPress: textInput.activeFocusOnPress
-
- /*!
- \qmlproperty bool TextField::autoScroll
-
- Whether the TextField should scroll when the text is longer than the width. By default this is
- set to true.
- */
- property alias autoScroll: textInput.autoScroll
-
- /*!
- \qmlproperty bool TextField::canPaste
-
- Returns true if the TextField is writable and the content of the clipboard is
- suitable for pasting into the TextField.
- */
- property alias canPaste: textInput.canPaste
-
- /*!
- \qmlproperty bool TextField::canRedo
-
- Returns true if the TextField is writable and there are \l {undo}{undone}
- operations that can be redone.
- */
- property alias canRedo: textInput.canRedo
-
- /*!
- \qmlproperty bool TextField::canUndo
-
- Returns true if the TextField is writable and there are previous operations
- that can be undone.
- */
- property alias canUndo: textInput.canUndo
-
- /*!
- \qmlproperty color TextField::color
-
- The text color.
- */
- property alias color: textInput.color
-
- /*!
- \qmlproperty bool TextField::containsMouse
- This property holds whether the mouse is currently inside the TextField.
- */
- property alias containsMouse: mouseArea.containsMouse
-
- /*!
- \qmlproperty real TextField::contentHeight
-
- Returns the height of the text, including the height past the height
- that is covered if the text does not fit within the set height.
- */
- property alias contentHeight: textInput.contentHeight
-
- /*!
- \qmlproperty real TextField::contentWidth
-
- Returns the width of the text, including the width past the width
- which is covered due to insufficient wrapping if \l wrapMode is set.
- */
- property alias contentWidth: textInput.contentWidth
-
- /*!
- \qmlproperty Component TextField::cursorDelegate
- The delegate for the cursor in the TextField.
-
- If you set a cursorDelegate for a TextField, this delegate will be used for
- drawing the cursor instead of the standard cursor. An instance of the
- delegate will be created and managed by the TextField when a cursor is
- needed, and the x property of delegate instance will be set so as
- to be one pixel before the top left of the current character.
-
- Note that the root item of the delegate component must be a QQuickItem or
- QQuickItem derived item.
- */
- property alias cursorDelegate: textInput.cursorDelegate
-
- /*!
- \qmlproperty int TextField::cursorPosition
- The position of the cursor in the TextField.
- */
- property alias cursorPosition: textInput.cursorPosition
-
- /*!
- \qmlproperty rectangle TextField::cursorRectangle
-
- The rectangle where the standard text cursor is rendered within the text input. Read only.
-
- The position and height of a custom cursorDelegate are updated to follow the cursorRectangle
- automatically when it changes. The width of the delegate is unaffected by changes in the
- cursor rectangle.
- */
- property alias cursorRectangle: textInput.cursorRectangle
-
- /*!
- \qmlproperty bool TextField::cursorVisible
- Set to true when the TextField shows a cursor.
-
- This property is set and unset when the TextField gets active focus, so that other
- properties can be bound to whether the cursor is currently showing. As it
- gets set and unset automatically, when you set the value yourself you must
- keep in mind that your value may be overwritten.
-
- It can be set directly in script, for example if a KeyProxy might
- forward keys to it and you desire it to look active when this happens
- (but without actually giving it active focus).
-
- It should not be set directly on the item, like in the below QML,
- as the specified value will be overridden an lost on focus changes.
-
- \code
- TextField {
- text: "Text"
- cursorVisible: false
- }
- \endcode
-
- In the above snippet the cursor will still become visible when the
- TextField gains active focus.
- */
- property alias cursorVisible: textInput.cursorVisible
-
- /*!
- \qmlproperty string TextField::displayText
-
- This is the text displayed in the TextField.
-
- If \l echoMode is set to TextInput::Normal, this holds the
- same value as the TextField::text property. Otherwise,
- this property holds the text visible to the user, while
- the \l text property holds the actual entered text.
- */
- property alias displayText: textInput.displayText
-
- /*!
- \qmlproperty enumeration TextField::echoMode
-
- Specifies how the text should be displayed in the TextField.
- \list
- \li TextInput.Normal - Displays the text as it is. (Default)
- \li TextInput.Password - Displays asterisks instead of characters.
- \li TextInput.NoEcho - Displays nothing.
- \li TextInput.PasswordEchoOnEdit - Displays characters as they are entered
- while editing, otherwise displays asterisks.
- \endlist
- */
- property alias echoMode: textInput.echoMode
-
- /*!
- \qmlproperty font TextField::font
-
- The font of the TextField.
- */
- property alias font: textInput.font
-
- /*!
- \qmlproperty enumeration TextField::horizontalAlignment
- \qmlproperty enumeration TextField::effectiveHorizontalAlignment
- \qmlproperty enumeration TextField::verticalAlignment
-
- Sets the alignment of the text within the TextField item's width and height.
- By default, the horizontal text alignment follows the natural alignment of the text,
- for example text that is read from left to right will be aligned to the left.
-
- The valid values for \c horizontalAlignment are \c TextInput.AlignLeft, \c TextInput.AlignRight and
- \c TextInput.AlignHCenter.
-
- Valid values for \c verticalAlignment are \c TextInput.AlignTop,
- \c TextInput.AlignBottom \c TextInput.AlignVCenter (default).
-
- When using the attached property LayoutMirroring::enabled to mirror application
- layouts, the horizontal alignment of text will also be mirrored. However, the property
- \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment
- of TextField, use the read-only property \c effectiveHorizontalAlignment.
- */
- property alias horizontalAlignment: textInput.horizontalAlignment
- property alias effectiveHorizontalAlignment: textInput.effectiveHorizontalAlignment
- property alias verticalAlignment: textInput.verticalAlignment
-
- /*!
- \qmlproperty string TextField::inputMask
-
- Allows you to set an input mask on the TextField, restricting the allowable
- text inputs. See QLineEdit::inputMask for further details, as the exact
- same mask strings are used by TextField.
-
- \sa acceptableInput, validator
- */
- property alias inputMask: textInput.inputMask
-
- /*!
- \qmlproperty bool TextField::inputMethodComposing
-
- This property holds whether the TextField has partial text input from an
- input method.
-
- While it is composing an input method may rely on mouse or key events from
- the TextField to edit or commit the partial text. This property can be
- used to determine when to disable event handlers that may interfere with
- the correct operation of an input method.
- */
- property alias inputMethodComposing: textInput.inputMethodComposing
-
- /*!
- \qmlproperty enumeration TextField::inputMethodHints
-
- Provides hints to the input method about the expected content of the text field and how it
- should operate.
-
- The value is a bit-wise combination of flags, or Qt.ImhNone if no hints are set.
-
- Flags that alter behavior are:
-
- \list
- \li Qt.ImhHiddenText - Characters should be hidden, as is typically used when entering passwords.
- This is automatically set when setting echoMode to \c TextInput.Password.
- \li Qt.ImhSensitiveData - Typed text should not be stored by the active input method
- in any persistent storage like predictive user dictionary.
- \li Qt.ImhNoAutoUppercase - The input method should not try to automatically switch to upper case
- when a sentence ends.
- \li Qt.ImhPreferNumbers - Numbers are preferred (but not required).
- \li Qt.ImhPreferUppercase - Upper case letters are preferred (but not required).
- \li Qt.ImhPreferLowercase - Lower case letters are preferred (but not required).
- \li Qt.ImhNoPredictiveText - Do not use predictive text (i.e. dictionary lookup) while typing.
-
- \li Qt.ImhDate - The text editor functions as a date field.
- \li Qt.ImhTime - The text editor functions as a time field.
- \endlist
-
- Flags that restrict input (exclusive flags) are:
-
- \list
- \li Qt.ImhDigitsOnly - Only digits are allowed.
- \li Qt.ImhFormattedNumbersOnly - Only number input is allowed. This includes decimal point and minus sign.
- \li Qt.ImhUppercaseOnly - Only upper case letter input is allowed.
- \li Qt.ImhLowercaseOnly - Only lower case letter input is allowed.
- \li Qt.ImhDialableCharactersOnly - Only characters suitable for phone dialing are allowed.
- \li Qt.ImhEmailCharactersOnly - Only characters suitable for email addresses are allowed.
- \li Qt.ImhUrlCharactersOnly - Only characters suitable for URLs are allowed.
- \endlist
-
- Masks:
-
- \list
- \li Qt.ImhExclusiveInputMask - This mask yields nonzero if any of the exclusive flags are used.
- \endlist
- */
- property alias inputMethodHints: textInput.inputMethodHints
-
- /*!
- \qmlproperty int TextField::length
-
- Returns the total number of characters in the TextField item.
-
- If the TextField has an inputMask the length will include mask characters and may differ
- from the length of the string returned by the \l text property.
-
- This property can be faster than querying the length the \l text property as it doesn't
- require any copying or conversion of the TextField's internal string data.
- */
- property alias length: textInput.length
-
- /*!
- \qmlproperty int TextField::maximumLength
- The maximum permitted length of the text in the TextField.
-
- If the text is too long, it is truncated at the limit.
-
- By default, this property contains a value of 32767.
- */
- property alias maximumLength: textInput.maximumLength
-
- /*!
- \qmlproperty enumeration TextField::mouseSelectionMode
-
- Specifies how text should be selected using a mouse.
-
- \list
- \li TextInput.SelectCharacters - The selection is updated with individual characters. (Default)
- \li TextInput.SelectWords - The selection is updated with whole words.
- \endlist
-
- This property only applies when \l selectByMouse is true.
- */
- property alias mouseSelectionMode: textInput.mouseSelectionMode
-
- /*!
- \qmlproperty string TextField::passwordCharacter
-
- This is the character displayed when echoMode is set to Password or
- PasswordEchoOnEdit. By default it is an asterisk.
-
- If this property is set to a string with more than one character,
- the first character is used. If the string is empty, the value
- is ignored and the property is not set.
- */
- property alias passwordCharacter: textInput.passwordCharacter
-
- /*!
- \qmlproperty bool TextField::persistentSelection
-
- Whether the TextField should keep its selection when it loses active focus to another
- item in the scene. By default this is set to false;
- */
- property alias persistentSelection: textInput.persistentSelection
-
- /*!
- \qmlproperty string TextField::placeholderText
-
- The text that is shown in the text field when the text field is empty
- and has no focus.
- */
- property alias placeholderText: placeholderTextComponent.text
-
- /*!
- \qmlproperty bool TextField::readOnly
-
- Sets whether user input can modify the contents of the TextField.
-
- If readOnly is set to true, then user input will not affect the text
- property. Any bindings or attempts to set the text property will still
- work.
- */
- property alias readOnly: textInput.readOnly
-
- /*!
- \qmlproperty enumeration TextField::renderType
-
- Override the default rendering type for this component.
-
- Supported render types are:
- \list
- \li Text.QtRendering - the default
- \li Text.NativeRendering
- \endlist
-
- Select Text.NativeRendering if you prefer text to look native on the target platform and do
- not require advanced features such as transformation of the text. Using such features in
- combination with the NativeRendering render type will lend poor and sometimes pixelated
- results.
- */
- property alias renderType: textInput.renderType
-
- /*!
- \qmlproperty bool TextField::selectByMouse
-
- Defaults to true.
-
- If true, the user can use the mouse to select text in some
- platform-specific way. Note that for some platforms this may
- not be an appropriate interaction (eg. may conflict with how
- the text needs to behave inside a Flickable.
- */
- property alias selectByMouse: textInput.selectByMouse
-
- /*!
- \qmlproperty string TextField::selectedText
-
- This read-only property provides the text currently selected in the
- text input.
-
- It is equivalent to the following snippet, but is faster and easier
- to use.
-
- \js
- myTextField.text.toString().substring(myTextField.selectionStart, myTextField.selectionEnd);
- \endjs
- */
- property alias selectedText: textInput.selectedText
-
- /*!
- \qmlproperty color TextField::selectedTextColor
-
- The highlighted text color, used in selections.
- */
- property alias selectedTextColor: textInput.selectedTextColor
-
- /*!
- \qmlproperty color TextField::selectionColor
-
- The text highlight color, used behind selections.
- */
- property alias selectionColor: textInput.selectionColor
-
- /*!
- \qmlproperty int TextField::selectionEnd
-
- The cursor position after the last character in the current selection.
-
- This property is read-only. To change the selection, use select(start,end),
- selectAll(), or selectWord().
-
- \sa selectionStart, cursorPosition, selectedText
- */
- property alias selectionEnd: textInput.selectionEnd
-
- /*!
- \qmlproperty int TextField::selectionStart
-
- The cursor position before the first character in the current selection.
-
- This property is read-only. To change the selection, use select(start,end),
- selectAll(), or selectWord().
-
- \sa selectionEnd, cursorPosition, selectedText
- */
- property alias selectionStart: textInput.selectionStart
-
- /*!
- \qmlproperty string TextField::text
-
- The text in the TextField.
- */
- property alias text: textInput.text
-
- /*!
- \qmlproperty Validator TextField::validator
-
- Allows you to set a validator on the TextField. When a validator is set
- the TextField will only accept input which leaves the text property in
- an acceptable or intermediate state. The accepted signal will only be sent
- if the text is in an acceptable state when enter is pressed.
-
- Currently supported validators are IntValidator, DoubleValidator and
- RegExpValidator. An example of using validators is shown below, which allows
- input of integers between 11 and 31 into the text input:
-
- \code
- import QtQuick 2.0
- import QtDesktop 1.0
-
- TextField {
- validator: IntValidator {bottom: 11; top: 31;}
- focus: true
- }
- \endcode
-
- \sa acceptableInput, inputMask
- */
- property alias validator: textInput.validator
-
- /*!
- \qmlproperty enumeration TextField::wrapMode
-
- Set this property to wrap the text to the TextField item's width.
- The text will only wrap if an explicit width has been set.
-
- \list
- \li TextInput.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width.
- \li TextInput.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width.
- \li TextInput.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word.
- \li TextInput.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.
- \endlist
-
- The default is TextInput.NoWrap. If you set a width, consider using TextInput.Wrap.
- */
- property alias wrapMode: textInput.wrapMode
-
- /*! \internal */
- property Component style: Qt.createComponent(Settings.THEME_PATH + "/TextFieldStyle.qml", textInput)
-
- /*! \internal */
- property var styleHints:[]
-
- /*!
- \qmlsignal TextField::accepted()
-
- This signal is emitted when the Return or Enter key is pressed.
- Note that if there is a \l validator or \l inputMask set on the text
- field, the signal will only be emitted if the input is in an acceptable
- state.
- */
- signal accepted()
-
- /*!
- \qmlmethod TextField::copy()
-
- Copies the currently selected text to the system clipboard.
- */
- function copy() {
- textInput.copy()
- }
-
- /*!
- \qmlmethod TextField::cut()
-
- Moves the currently selected text to the system clipboard.
- */
- function cut() {
- textInput.cut()
- }
-
- /*!
- \qmlmethod TextField::deselect()
-
- Removes active text selection.
- */
- function deselect() {
- textInput.deselect();
- }
-
- /*!
- \qmlmethod string TextField::getText(int start, int end)
-
- Removes the section of text that is between the \a start and \a end positions from the TextField.
- */
- function getText(start, end) {
- return textInput.getText(start, end);
- }
-
- /*!
- \qmlmethod TextField::insert(int position, string text)
-
- Inserts \a text into the TextField at position.
- */
- function insert(position, text) {
- textInput.insert(position, text);
- }
-
- /*!
- \qmlmethod bool TextField::isRightToLeft(int start, int end)
-
- Returns true if the natural reading direction of the editor text
- found between positions \a start and \a end is right to left.
- */
- function isRightToLeft(start, end) {
- return textInput.isRightToLeft(start, end);
- }
-
- /*!
- \qmlmethod TextField::paste()
-
- Replaces the currently selected text by the contents of the system clipboard.
- */
- function paste() {
- textInput.paste()
- }
-
- /*!
- \qmlmethod int TextField::positionAt(real x, real y, CursorPosition position = CursorBetweenCharacters)
-
- This function returns the character position at
- x and y pixels from the top left of the TextField. Position 0 is before the
- first character, position 1 is after the first character but before the second,
- and so on until position text.length, which is after all characters.
-
- This means that for all x values before the first character this function returns 0,
- and for all x values after the last character this function returns text.length. If
- the y value is above the text the position will be that of the nearest character on
- the first line line and if it is below the text the position of the nearest character
- on the last line will be returned.
-
- The cursor position type specifies how the cursor position should be resolved.
-
- \list
- \li TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x.
- \li TextInput.CursorOnCharacter - Returns the position before the character that is nearest x.
- \endlist
- */
- function positionAt(x, y, cursor) {
- var p = mapToItem(textInput, x, y);
- return textInput.positionAt(p.x, p.y, cursor);
- }
-
- /*!
- \qmlmethod rect TextField::positionToRectangle(int pos)
-
- This function takes a character position and returns the rectangle that the
- cursor would occupy, if it was placed at that character position.
-
- This is similar to setting the cursorPosition, and then querying the cursor
- rectangle, but the cursorPosition is not changed.
- */
- function positionToRectangle(pos) {
- var p = mapToItem(textInput, pos.x, pos.y);
- return textInput.positionToRectangle(p);
- }
-
- /*!
- \qmlmethod TextField::redo()
-
- Redoes the last operation if redo is \l {canRedo}{available}.
- */
- function redo() {
- textInput.redo();
- }
-
- /*!
- \qmlmethod TextField::select(int start, int end)
-
- Causes the text from \a start to \a end to be selected.
-
- If either start or end is out of range, the selection is not changed.
-
- After calling this, selectionStart will become the lesser
- and selectionEnd will become the greater (regardless of the order passed
- to this method).
-
- \sa selectionStart, selectionEnd
- */
- function select(start, end) {
- textInput.select(start, end)
- }
-
- /*!
- \qmlmethod TextField::selectAll()
-
- Causes all text to be selected.
- */
- function selectAll() {
- textInput.selectAll()
- }
-
- /*!
- \qmlmethod TextField::selectWord()
-
- Causes the word closest to the current cursor position to be selected.
- */
- function selectWord() {
- textInput.selectWord()
- }
-
- /*!
- \qmlmethod TextField::undo()
-
- Undoes the last operation if undo is \l {canUndo}{available}. Deselects any
- current selection, and updates the selection start to the current cursor
- position.
- */
- function undo() {
- textInput.undo();
- }
-
- // Implementation
- implicitWidth: loader.implicitWidth
- implicitHeight: loader.implicitHeight
-
- Accessible.name: text
- Accessible.role: Accessible.EditableText
- Accessible.description: placeholderText
-
- Loader {
- id: loader
- sourceComponent: style
- anchors.fill: parent
- property Item control: textfield
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: textfield.forceActiveFocus()
- }
-
- /*! \internal */
- onFocusChanged: {
- if (textfield.activeFocus)
- textInput.forceActiveFocus();
- }
-
- TextInput { // see QTBUG-14936
- id: textInput
- selectByMouse: true
- selectionColor: loader.item ? loader.item.selectionColor : "black"
- selectedTextColor: loader.item ? loader.item.selectedTextColor : "black"
-
- property Item styleItem: loader.item
- font: styleItem ? styleItem.font : font
- anchors.leftMargin: styleItem ? styleItem.leftMargin : 0
- anchors.topMargin: styleItem ? styleItem.topMargin : 0
- anchors.rightMargin: styleItem ? styleItem.rightMargin : 0
- anchors.bottomMargin: styleItem ? styleItem.bottomMargin : 0
-
- anchors.fill: parent
- verticalAlignment: Text.AlignVCenter
-
- color: loader.item ? loader.item.foregroundColor : "darkgray"
- clip: true
- renderType: Text.NativeRendering
-
- onAccepted: textfield.accepted()
- }
-
- Text {
- id: placeholderTextComponent
- anchors.fill: textInput
- font: textInput.font
- horizontalAlignment: textInput.horizontalAlignment
- verticalAlignment: textInput.verticalAlignment
- opacity: !textInput.text.length && !textInput.activeFocus ? 1 : 0
- color: loader.item ? loader.item.placeholderTextColor : "darkgray"
- clip: true
- elide: Text.ElideRight
-// renderType: Text.NativeRendering
- Behavior on opacity { NumberAnimation { duration: 90 } }
- }
- MouseArea {
- anchors.fill: parent
- cursorShape: Qt.IBeamCursor
- acceptedButtons: Qt.NoButton
- }
-}
diff --git a/src/qtdesktop/doc/qtdesktopcomponents.qdocconf b/src/qtdesktop/doc/qtdesktopcomponents.qdocconf
deleted file mode 100644
index 4b1e70bb..00000000
--- a/src/qtdesktop/doc/qtdesktopcomponents.qdocconf
+++ /dev/null
@@ -1,59 +0,0 @@
-include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
-
-# Name of the project.
-project = QtDesktopComponents
-description = Qt Desktop Components Documentation
-
-depends = qtqml qtquick qtwidgets qtdoc
-
-# Directories in which to search for files to document and images.
-# By default set to the root directory of the project for sources
-# and headers and qdoc will therefore generate output for each file.
-# Images should be placed in <rootdir>/dic/images and examples in
-# <rootdir>/examples.
-# Paths are relative to the location of this file.
-
-exampledirs += ../../../examples/
-
-headerdirs += ../ ../../styles
-
-sourcedirs += ../ ../../styles
-
-excludedirs += ../private ../../styles/Desktop
-
-# The following parameters are for creating a qhp file, the qhelpgenerator
-# program can convert the qhp file into a qch file which can be opened in
-# Qt Assistant and/or Qt Creator.
-
-# Defines the name of the project. You cannot use operators (+, =, -) in
-# the name. Properties for this project are set using a qhp.<projectname>.property
-# format.
-qhp.projects = qtdesktopcomponents
-
-# Sets the name of the output qhp file.
-qhp.qtdesktopcomponents.file = qtdesktopcomponents.qhp
-
-# Namespace for the output file. This namespace is used to distinguish between
-# different documentation files in Creator/Assistant.
-qhp.qtdesktopcomponents.namespace = qtdesktopcomponents.100
-
-# Title for the package, will be the main title for the package in
-# Assistant/Creator.
-qhp.qtdesktopcomponents.indexTitle = Qt Desktop Components
-
-# Extra files to add to the output which are not linked to from anywhere
-# using a qdoc \l command.
-#qhp.qtdesktopcomponents.extraFiles = style/qtdesktopcomponents.css
-
-# Only update the name of the project for the next variables.
-qhp.qtdesktopcomponents.virtualFolder = qtdesktopcomponents
-
-qhp.qtdesktopcomponents.subprojects = desktopqmltypes styleqmltypes
-qhp.qtdesktopcomponents.subprojects.desktopqmltypes.title = Desktop QML Types
-qhp.qtdesktopcomponents.subprojects.desktopqmltypes.indexTitle = Qt Desktop QML Types
-qhp.qtdesktopcomponents.subprojects.desktopqmltypes.selectors = fake:qmlclass
-qhp.qtdesktopcomponents.subprojects.desktopqmltypes.sortPages = true
-qhp.qtdesktopcomponents.subprojects.styleqmltypes.title = Desktop Styles QML Types
-qhp.qtdesktopcomponents.subprojects.styleqmltypes.indexTitle = Qt Desktop Styles QML Types
-qhp.qtdesktopcomponents.subprojects.styleqmltypes.selectors = fake:qmlclass
-qhp.qtdesktopcomponents.subprojects.styleqmltypes.sortPages = true
diff --git a/src/qtdesktop/plugins.qmltypes b/src/qtdesktop/plugins.qmltypes
deleted file mode 100644
index 79e15ef6..00000000
--- a/src/qtdesktop/plugins.qmltypes
+++ /dev/null
@@ -1,451 +0,0 @@
-import QtQuick.tooling 1.1
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-//
-// This file was auto-generated with the command 'qmlplugindump QtDesktop 1.0 imports/'.
-
-Module {
- Component {
- name: "QDesktopItem"
- prototype: "QObject"
- exports: ["Desktop 1.0"]
- Property { name: "screenWidth"; type: "int"; isReadonly: true }
- Property { name: "screenHeight"; type: "int"; isReadonly: true }
- Property { name: "availableWidth"; type: "int"; isReadonly: true }
- Property { name: "availableHeight"; type: "int"; isReadonly: true }
- Property { name: "screenCount"; type: "int"; isReadonly: true }
- Signal { name: "screenGeometryChanged" }
- Signal { name: "availableGeometryChanged" }
- Method {
- name: "screenGeometry"
- type: "QRect"
- Parameter { name: "screen"; type: "int" }
- }
- Method {
- name: "availableGeometry"
- type: "QRect"
- Parameter { name: "screen"; type: "int" }
- }
- }
- Component {
- name: "QFileDialogItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["FileDialog 1.0"]
- Property { name: "visible"; type: "bool" }
- Property { name: "modal"; type: "bool" }
- Property { name: "title"; type: "string" }
- Property { name: "selectExisting"; type: "bool" }
- Property { name: "selectMultiple"; type: "bool" }
- Property { name: "selectFolder"; type: "bool" }
- Property { name: "folder"; type: "string" }
- Property { name: "nameFilters"; type: "QStringList" }
- Property { name: "filePath"; type: "string"; isReadonly: true }
- Property { name: "filePaths"; type: "QStringList"; isReadonly: true }
- Signal { name: "modalityChanged" }
- Signal { name: "accepted" }
- Signal { name: "rejected" }
- Method { name: "open" }
- Method { name: "close" }
- }
- Component {
- name: "QFileSystemModel"
- prototype: "QAbstractItemModel"
- exports: ["FileSystemModel 1.0"]
- Property { name: "resolveSymlinks"; type: "bool" }
- Property { name: "readOnly"; type: "bool" }
- Property { name: "nameFilterDisables"; type: "bool" }
- Signal {
- name: "rootPathChanged"
- Parameter { name: "newPath"; type: "string" }
- }
- Signal {
- name: "fileRenamed"
- Parameter { name: "path"; type: "string" }
- Parameter { name: "oldName"; type: "string" }
- Parameter { name: "newName"; type: "string" }
- }
- Signal {
- name: "directoryLoaded"
- Parameter { name: "path"; type: "string" }
- }
- }
- Component {
- name: "QQuickComponentsColumnLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLinearLayout"
- exports: ["ColumnLayout 1.0"]
- }
- Component {
- name: "QQuickComponentsLayout"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["Layout 1.0"]
- attachedType: "QQuickComponentsLayoutAttached"
- Enum {
- name: "SizePolicy"
- values: {
- "Fixed": 0,
- "Expanding": 1
- }
- }
- }
- Component {
- name: "QQuickComponentsLayoutAttached"
- prototype: "QObject"
- Property { name: "minimumWidth"; type: "double" }
- Property { name: "minimumHeight"; type: "double" }
- Property { name: "maximumWidth"; type: "double" }
- Property { name: "maximumHeight"; type: "double" }
- Property { name: "verticalSizePolicy"; type: "QQuickComponentsLayout::SizePolicy" }
- Property { name: "horizontalSizePolicy"; type: "QQuickComponentsLayout::SizePolicy" }
- }
- Component {
- name: "QQuickComponentsLinearLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLayout"
- Property { name: "spacing"; type: "double" }
- Signal { name: "orientationChanged" }
- }
- Component {
- name: "QQuickComponentsPrivate"
- prototype: "QObject"
- exports: ["PrivateHelper 1.0"]
- Method {
- name: "showToolTip"
- Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
- Parameter { name: "pos"; type: "QPointF" }
- Parameter { name: "text"; type: "string" }
- }
- Method { name: "hideToolTip" }
- }
- Component {
- name: "QQuickComponentsRowLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLinearLayout"
- exports: ["RowLayout 1.0"]
- }
- Component {
- name: "QRangeModel"
- prototype: "QObject"
- exports: ["RangeModel 1.0"]
- Property { name: "value"; type: "double" }
- Property { name: "minimumValue"; type: "double" }
- Property { name: "maximumValue"; type: "double" }
- Property { name: "stepSize"; type: "double" }
- Property { name: "position"; type: "double" }
- Property { name: "positionAtMinimum"; type: "double" }
- Property { name: "positionAtMaximum"; type: "double" }
- Property { name: "inverted"; type: "bool" }
- Signal {
- name: "valueChanged"
- Parameter { name: "value"; type: "double" }
- }
- Signal {
- name: "positionChanged"
- Parameter { name: "position"; type: "double" }
- }
- Signal {
- name: "stepSizeChanged"
- Parameter { name: "stepSize"; type: "double" }
- }
- Signal {
- name: "invertedChanged"
- Parameter { name: "inverted"; type: "bool" }
- }
- Signal {
- name: "minimumChanged"
- Parameter { name: "min"; type: "double" }
- }
- Signal {
- name: "maximumChanged"
- Parameter { name: "max"; type: "double" }
- }
- Signal {
- name: "positionAtMinimumChanged"
- Parameter { name: "min"; type: "double" }
- }
- Signal {
- name: "positionAtMaximumChanged"
- Parameter { name: "max"; type: "double" }
- }
- Method { name: "toMinimum" }
- Method { name: "toMaximum" }
- Method {
- name: "setValue"
- Parameter { name: "value"; type: "double" }
- }
- Method {
- name: "setPosition"
- Parameter { name: "position"; type: "double" }
- }
- Method {
- name: "valueForPosition"
- type: "double"
- Parameter { name: "position"; type: "double" }
- }
- Method {
- name: "positionForValue"
- type: "double"
- Parameter { name: "value"; type: "double" }
- }
- }
- Component {
- name: "QStyleItem"
- defaultProperty: "data"
- prototype: "QQuickPaintedItem"
- exports: ["StyleItem 1.0"]
- Property { name: "sunken"; type: "bool" }
- Property { name: "raised"; type: "bool" }
- Property { name: "active"; type: "bool" }
- Property { name: "selected"; type: "bool" }
- Property { name: "hasFocus"; type: "bool" }
- Property { name: "on"; type: "bool" }
- Property { name: "hover"; type: "bool" }
- Property { name: "horizontal"; type: "bool" }
- Property { name: "elementType"; type: "string" }
- Property { name: "text"; type: "string" }
- Property { name: "activeControl"; type: "string" }
- Property { name: "info"; type: "string" }
- Property { name: "style"; type: "string"; isReadonly: true }
- Property { name: "hint"; type: "string" }
- Property { name: "font"; type: "QFont"; isReadonly: true }
- Property { name: "minimum"; type: "int" }
- Property { name: "maximum"; type: "int" }
- Property { name: "value"; type: "int" }
- Property { name: "step"; type: "int" }
- Property { name: "paintMargins"; type: "int" }
- Property { name: "contentWidth"; type: "int" }
- Property { name: "contentHeight"; type: "int" }
- Signal {
- name: "contentWidthChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Signal {
- name: "contentHeightChanged"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "pixelMetric"
- type: "int"
- Parameter { type: "string" }
- }
- Method {
- name: "styleHint"
- type: "QVariant"
- Parameter { type: "string" }
- }
- Method { name: "updateSizeHint" }
- Method { name: "updateItem" }
- Method {
- name: "hitTest"
- type: "string"
- Parameter { name: "x"; type: "int" }
- Parameter { name: "y"; type: "int" }
- }
- Method {
- name: "subControlRect"
- type: "QRectF"
- Parameter { name: "subcontrolString"; type: "string" }
- }
- Method {
- name: "elidedText"
- type: "string"
- Parameter { name: "text"; type: "string" }
- Parameter { name: "elideMode"; type: "int" }
- Parameter { name: "width"; type: "int" }
- }
- Method {
- name: "textWidth"
- type: "int"
- Parameter { type: "string" }
- }
- Method {
- name: "hasThemeIcon"
- type: "bool"
- Parameter { type: "string" }
- }
- Method {
- name: "setContentWidth"
- Parameter { name: "arg"; type: "int" }
- }
- Method {
- name: "setContentHeight"
- Parameter { name: "arg"; type: "int" }
- }
- }
- Component {
- name: "QWheelArea"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["WheelArea 1.0"]
- Property { name: "verticalDelta"; type: "double" }
- Property { name: "horizontalDelta"; type: "double" }
- Property { name: "horizontalMinimumValue"; type: "double" }
- Property { name: "horizontalMaximumValue"; type: "double" }
- Property { name: "verticalMinimumValue"; type: "double" }
- Property { name: "verticalMaximumValue"; type: "double" }
- Property { name: "horizontalValue"; type: "double" }
- Property { name: "verticalValue"; type: "double" }
- Property { name: "scrollSpeed"; type: "double" }
- Signal { name: "verticalWheelMoved" }
- Signal { name: "horizontalWheelMoved" }
- }
- Component {
- name: "QWindowItem"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["Window 0.1", "Window 1.0"]
- Property { name: "minimumHeight"; type: "int" }
- Property { name: "maximumHeight"; type: "int" }
- Property { name: "minimumWidth"; type: "int" }
- Property { name: "maximumWidth"; type: "int" }
- Property { name: "visible"; type: "bool" }
- Property { name: "windowDecoration"; type: "bool" }
- Property { name: "modal"; type: "bool" }
- Property { name: "deleteOnClose"; type: "bool" }
- Property { name: "windowState"; type: "Qt::WindowState" }
- Property { name: "title"; type: "string" }
- Signal { name: "modalityChanged" }
- Method { name: "close" }
- }
- Component {
- name: "QtMenu"
- defaultProperty: "menuItems"
- prototype: "QtMenuBase"
- exports: ["Menu 1.0"]
- Property { name: "text"; type: "string" }
- Property { name: "model"; type: "QVariant" }
- Property { name: "selectedIndex"; type: "int" }
- Property { name: "hoveredIndex"; type: "int" }
- Property { name: "menuItems"; type: "QtMenuBase"; isList: true; isReadonly: true }
- Signal { name: "menuClosed" }
- Signal {
- name: "modelChanged"
- Parameter { name: "newModel"; type: "QVariant" }
- }
- Signal { name: "rebuldMenu" }
- Method {
- name: "setModel"
- Parameter { name: "newModel"; type: "QVariant" }
- }
- Method { name: "minimumWidth"; type: "int" }
- Method {
- name: "setMinimumWidth"
- Parameter { name: "w"; type: "int" }
- }
- Method {
- name: "showPopup"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- Parameter { name: "atActionIndex"; type: "int" }
- }
- Method {
- name: "showPopup"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- Method { name: "hidePopup" }
- Method { name: "clearMenuItems" }
- Method {
- name: "addMenuItem"
- Parameter { name: "text"; type: "string" }
- }
- Method {
- name: "itemTextAt"
- type: "string"
- Parameter { name: "index"; type: "int" }
- }
- Method {
- name: "modelTextAt"
- type: "string"
- Parameter { name: "index"; type: "int" }
- }
- Method { name: "modelCount"; type: "int" }
- Method { name: "hasNativeModel"; type: "bool" }
- }
- Component {
- name: "QtMenuBar"
- defaultProperty: "menus"
- prototype: "QQuickItem"
- exports: ["MenuBar 1.0"]
- Property { name: "menus"; type: "QtMenu"; isList: true; isReadonly: true }
- }
- Component {
- name: "QtMenuBase"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["NativeMenuBase 0.1"]
- Property { name: "iconSource"; type: "QUrl" }
- Property { name: "iconName"; type: "string" }
- }
- Component {
- name: "QtMenuItem"
- defaultProperty: "data"
- prototype: "QtMenuBase"
- exports: ["MenuItem 1.0"]
- Property { name: "text"; type: "string" }
- Property { name: "shortcut"; type: "string" }
- Property { name: "checkable"; type: "bool" }
- Property { name: "checked"; type: "bool" }
- Property { name: "enabled"; type: "bool" }
- Signal { name: "triggered" }
- Signal {
- name: "toggled"
- Parameter { type: "bool" }
- }
- }
- Component {
- name: "QtMenuSeparator"
- defaultProperty: "data"
- prototype: "QtMenuBase"
- exports: ["Separator 1.0"]
- }
- Component {
- name: "QtSplitterAttached"
- prototype: "QObject"
- Property { name: "minimumWidth"; type: "double" }
- Property { name: "maximumWidth"; type: "double" }
- Property { name: "minimumHeight"; type: "double" }
- Property { name: "maximumHeight"; type: "double" }
- Property { name: "percentageSize"; type: "double" }
- Property { name: "expanding"; type: "bool" }
- Property { name: "itemIndex"; type: "int" }
- Signal {
- name: "minimumWidthChanged"
- Parameter { name: "arg"; type: "double" }
- }
- Signal {
- name: "maximumWidthChanged"
- Parameter { name: "arg"; type: "double" }
- }
- Signal {
- name: "minimumHeightChanged"
- Parameter { name: "arg"; type: "double" }
- }
- Signal {
- name: "maximumHeightChanged"
- Parameter { name: "arg"; type: "double" }
- }
- Signal {
- name: "expandingChanged"
- Parameter { name: "arg"; type: "bool" }
- }
- Signal {
- name: "percentageWidthSize"
- Parameter { name: "arg"; type: "double" }
- }
- Signal {
- name: "itemIndexChanged"
- Parameter { name: "arg"; type: "int" }
- }
- }
- Component {
- name: "QtSplitterBase"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["Splitter 1.0"]
- attachedType: "QtSplitterAttached"
- }
-}
diff --git a/src/qtdesktop/private/BasicButton.qml b/src/qtdesktop/private/BasicButton.qml
deleted file mode 100644
index 1e583831..00000000
--- a/src/qtdesktop/private/BasicButton.qml
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0 as Internal
-
-Item {
- id: button
-
- signal clicked
- property alias pressed: behavior.effectivePressed
- property alias containsMouse: behavior.containsMouse
- property alias checkable: behavior.checkable // button toggles between checked and !checked
- property alias checked: behavior.checked
- property bool activeFocusOnPress: false
- property alias style: loader.sourceComponent
- property var styleHints: []
-
- property color textColor: syspal.text
- property string tooltip
-
- Accessible.role: Accessible.Button
- Accessible.description: tooltip
-
- signal toolTipTriggered
-
- // implementation
-
- property string __position: "only"
- implicitWidth: loader.implicitWidth
- implicitHeight: loader.implicitHeight
-
- Keys.onPressed: {
- if (event.key === Qt.Key_Space && !event.isAutoRepeat && !behavior.pressed)
- behavior.keyPressed = true;
- }
-
- Keys.onReleased: {
- if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) {
- behavior.keyPressed = false;
- if (checkable)
- checked = !checked;
- button.clicked();
- }
- }
-
- Loader {
- id: loader
- anchors.fill: parent
- sourceComponent: style
- property alias control: button
- property alias position: button.__position
- height: item ? item.implicitHeight : 0
- width: item ? item.implicitWidth : 0
- }
-
- ButtonBehavior {
- id: behavior
- anchors.fill: parent
- onClicked: button.clicked()
- onExited: Internal.PrivateHelper.hideToolTip()
- onCanceled: Internal.PrivateHelper.hideToolTip()
- onPressed: if (activeFocusOnPress) button.forceActiveFocus()
-
- Timer {
- interval: 1000
- running: containsMouse && !pressed && tooltip.length
- onTriggered: Internal.PrivateHelper.showToolTip(behavior, Qt.point(behavior.mouseX, behavior.mouseY), tooltip)
- }
- }
-
- SystemPalette { id: syspal }
-}
diff --git a/src/qtdesktop/private/ButtonBehavior.qml b/src/qtdesktop/private/ButtonBehavior.qml
deleted file mode 100644
index 1119811c..00000000
--- a/src/qtdesktop/private/ButtonBehavior.qml
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-
-MouseArea {
- property bool checkable: false
- property bool checked: false
- property bool keyPressed: false
- property bool effectivePressed: pressed && containsMouse || keyPressed
-
- hoverEnabled: true
- enabled: !keyPressed
-
- onCheckableChanged: {
- if (!checkable)
- checked = false;
- }
-
- onReleased: {
- if (checkable && containsMouse)
- checked = !checked;
- }
-}
diff --git a/src/qtdesktop/private/ButtonGroup.js b/src/qtdesktop/private/ButtonGroup.js
deleted file mode 100644
index 5b0d9adb..00000000
--- a/src/qtdesktop/private/ButtonGroup.js
+++ /dev/null
@@ -1,141 +0,0 @@
-var self;
-var checkHandlers = [];
-var visibleButtons = [];
-var nonVisibleButtons = [];
-var direction;
-
-function create(that, options) {
- self = that;
- direction = options.direction || Qt.Horizontal;
- self.childrenChanged.connect(rebuild);
-// self.widthChanged.connect(resizeChildren);
- build();
-}
-
-function isButton(item) {
- if (item && item.hasOwnProperty("__position"))
- return true;
- return false;
-}
-
-function hasChecked(item) {
- return (item && item.hasOwnProperty("checked"));
-}
-
-function destroy() {
- self.childrenChanged.disconnect(rebuild);
-// self.widthChanged.disconnect(resizeChildren);
- cleanup();
-}
-
-function build() {
- visibleButtons = [];
- nonVisibleButtons = [];
-
- for (var i = 0, item; (item = self.children[i]); i++) {
-
- if (item.hasOwnProperty("styleHint"))
- item.styleHint = styleHint;
-
- if (!hasChecked(item))
- continue;
-
- item.visibleChanged.connect(rebuild); // Not optimal, but hardly a bottleneck in your app
- if (!item.visible) {
- nonVisibleButtons.push(item);
- continue;
- }
- visibleButtons.push(item);
-
- if (self.exclusive && item.hasOwnProperty("checkable"))
- item.checkable = true;
-
- if (self.exclusive) {
- item.checked = false;
- checkHandlers.push(checkExclusive(item));
- item.checkedChanged.connect(checkHandlers[checkHandlers.length - 1]);
- }
- }
-
- var nrButtons = visibleButtons.length;
- if (nrButtons == 0)
- return;
-
- if (self.checkedButton)
- self.checkedButton.checked = true;
- else if (self.exclusive) {
- self.checkedButton = visibleButtons[0];
- self.checkedButton.checked = true;
- }
-
- if (nrButtons == 1) {
- finishButton(visibleButtons[0], "only");
- } else {
- finishButton(visibleButtons[0], direction == Qt.Horizontal ? "leftmost" : "top");
- for (var i = 1; i < nrButtons - 1; i++)
- finishButton(visibleButtons[i], direction == Qt.Horizontal ? "h_middle": "v_middle");
- finishButton(visibleButtons[nrButtons - 1], direction == Qt.Horizontal ? "rightmost" : "bottom");
- }
-}
-
-function finishButton(button, position) {
- if (isButton(button)) {
- button.__position = position;
- if (direction == Qt.Vertical) {
- button.anchors.left = self.left //mm How to make this not cause binding loops? see QTBUG-17162
- button.anchors.right = self.right
- }
- }
-}
-
-function cleanup() {
- visibleButtons.forEach(function(item, i) {
- if (checkHandlers[i])
- item.checkedChanged.disconnect(checkHandlers[i]);
- item.visibleChanged.disconnect(rebuild);
- });
- checkHandlers = [];
-
- nonVisibleButtons.forEach(function(item, i) {
- item.visibleChanged.disconnect(rebuild);
- });
-}
-
-function rebuild() {
- if (self == undefined)
- return;
-
- cleanup();
- build();
-}
-
-function resizeChildren() {
- if (direction != Qt.Horizontal)
- return;
-
- var extraPixels = self.width % visibleButtons;
- var buttonSize = (self.width - extraPixels) / visibleButtons;
- visibleButtons.forEach(function(item, i) {
- if (!item || !item.visible)
- return;
- item.width = buttonSize + (extraPixels > 0 ? 1 : 0);
- if (extraPixels > 0)
- extraPixels--;
- });
-}
-
-function checkExclusive(item) {
- var button = item;
- return function() {
- for (var i = 0, ref; (ref = visibleButtons[i]); i++) {
- if (ref.checked == (button === ref))
- continue;
-
- // Disconnect the signal to avoid recursive calls
- ref.checkedChanged.disconnect(checkHandlers[i]);
- ref.checked = !ref.checked;
- ref.checkedChanged.connect(checkHandlers[i]);
- }
- self.checkedButton = button;
- }
-}
diff --git a/src/qtdesktop/private/PageStack.js b/src/qtdesktop/private/PageStack.js
deleted file mode 100644
index 97f292d5..00000000
--- a/src/qtdesktop/private/PageStack.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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$
-**
-****************************************************************************/
-
-var pageStack = [];
-
-function push(p)
-{
- if (!p)
- return
- pageStack.push(p)
- __depth++
- return p
-}
-
-function pop()
-{
- if (pageStack.length === 0)
- return null
- var p = pageStack.pop()
- __depth--
- return p
-}
-
-function current()
-{
- if (pageStack.length === 0)
- return null
- return pageStack[pageStack.length-1]
-}
-
diff --git a/src/qtdesktop/private/ScrollAreaHelper.qml b/src/qtdesktop/private/ScrollAreaHelper.qml
deleted file mode 100644
index e99b3276..00000000
--- a/src/qtdesktop/private/ScrollAreaHelper.qml
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-WheelArea {
- id: wheelarea
-
- property alias horizontalScrollBar: hscrollbar
- property alias verticalScrollBar: vscrollbar
- property int macOffset: styleitem.style == "mac" ? 1 : 0
- property bool blockUpdates: false
- property int availableHeight : height - (hscrollbar.visible ? hscrollbar.height : 0)
- property int availableWidth: width - vscrollbar.width
-
- anchors.fill: parent
- anchors.margins: frameWidth
- horizontalMinimumValue: hscrollbar.minimumValue
- horizontalMaximumValue: hscrollbar.maximumValue
- verticalMinimumValue: vscrollbar.minimumValue
- verticalMaximumValue: vscrollbar.maximumValue
-
- onVerticalValueChanged: {
- if (!blockUpdates)
- verticalScrollBar.value = verticalValue
- }
-
- onHorizontalValueChanged: {
- if (!blockUpdates)
- horizontalScrollBar.value = horizontalValue
- }
-
- StyleItem {
- // This is the filled corner between scrollbars
- id: cornerFill
- elementType: "scrollareacorner"
- width: vscrollbar.width
- anchors.right: parent.right
- height: hscrollbar.height
- anchors.bottom: parent.bottom
- visible: hscrollbar.visible && vscrollbar.visible
- }
-
- ScrollBar {
- id: hscrollbar
- orientation: Qt.Horizontal
- visible: contentWidth > availableWidth
- maximumValue: contentWidth > availableWidth ? root.contentWidth - availableWidth : 0
- minimumValue: 0
- anchors.bottom: parent.bottom
- anchors.leftMargin: parent.macOffset
- anchors.bottomMargin: -parent.macOffset
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.rightMargin: vscrollbar.visible ? vscrollbar.width -parent.macOffset: 0
- onValueChanged: {
- if (!blockUpdates) {
- contentX = value
- horizontalValue = value
- }
- }
- }
-
- ScrollBar {
- id: vscrollbar
- orientation: Qt.Vertical
- // We cannot bind directly to tree.height due to binding loops so we have to redo the calculation here
- // visible: contentHeight > availableHeight
- maximumValue: contentHeight > availableHeight ? root.contentHeight - availableHeight : 0
- minimumValue: 0
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.topMargin: 1//parent.macOffset
- anchors.rightMargin: -parent.macOffset
- anchors.bottomMargin: hscrollbar.visible ? hscrollbar.height - parent.macOffset : 0
-
- onValueChanged: {
- if (!blockUpdates) {
- contentY = value
- verticalValue = value
- }
- }
- }
-}
diff --git a/src/qtdesktop/private/Splitter.qml b/src/qtdesktop/private/Splitter.qml
deleted file mode 100644
index b24840b6..00000000
--- a/src/qtdesktop/private/Splitter.qml
+++ /dev/null
@@ -1,471 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-Splitter {
- id: root
- default property alias items: splitterItems.children
- property alias handles: splitterHandles.children
- property Component handleDelegate: Rectangle { width:3; color: "black" }
- property int handleWidth: -1
- property real preferredSize: 0
- property int orientation: Qt.Horizontal
-
- clip: true
- Component.onCompleted: d.init();
- onWidthChanged: d.updateLayout();
- onHeightChanged: d.updateLayout();
-
- QtObject {
- id: d
-
- property bool horizontal: orientation == Qt.Horizontal
- property string size: horizontal ? "width" : "height"
- property string minimum: horizontal ? "minimumWidth" : "minimumHeight"
- property string maximum: horizontal ? "maximumWidth" : "maximumHeight"
-
- property string offset: horizontal ? "x" : "y"
- property int expandingIndex: -1
- property bool updateLayoutGuard: true
- property bool itemWidthGuard: false
- property bool itemExpandingGuard: true
-
- function init()
- {
- for (var i=0; i<items.length; ++i) {
- var item = items[i];
-
- item.Splitter.itemIndex = i
- // Assign one, and only one, item to be expanding:
- if (item.Splitter.expanding === true) {
- if (d.expandingIndex === -1 && item.visible === true)
- d.expandingIndex = i
- else
- item.Splitter.expanding = false
- }
-
- // Anchor each item to fill out all space vertically:
- if (d.horizontal) {
- item.anchors.top = splitterItems.top
- item.anchors.bottom = splitterItems.bottom
- } else {
- item.anchors.left = splitterItems.left
- item.anchors.right = splitterItems.right
-
- }
-
- // Listen for changes to width and expanding:
- propertyChangeListener.createObject(item, {"itemIndex":i});
- if (i < items.length-1) {
- // Create a handle for the item, unless its the last:
- var handle = handleloader.createObject(splitterHandles, {"handleIndex":i});
-
- if (d.horizontal) {
- handle.anchors.top = splitterHandles.top
- handle.anchors.bottom = splitterHandles.bottom
- } else {
- handle.anchors.left = splitterHandles.left
- handle.anchors.right = splitterHandles.right
- }
- }
- }
-
- if (d.expandingIndex === -1) {
- // INVARIANT: No item was set as expanding.
- // We then choose the last visible item instead:
- d.expandingIndex = items.length - 1
- for (i=items.length-1; i>=0; --i) {
- var item = items[i]
- if (item.visible === true) {
- d.expandingIndex = i
- item = items[i]
- break
- }
- }
- if (items.length && item.visible) {
- item.Splitter.expanding = true
- }
- }
-
- d.itemExpandingGuard = false
- d.updateLayoutGuard = false
- d.updateLayout()
- }
-
- function accumulatedSize(firstIndex, lastIndex, includeExpandingMinimum)
- {
- // Go through items and handles, and
- // calculate their acummulated width.
- var w = 0
- for (var i=firstIndex; i<lastIndex; ++i) {
- var item = items[i]
- if (item.visible) {
- if (i !== d.expandingIndex)
- w += item[d.size];
- else if (includeExpandingMinimum && item.Splitter[minimum] != -1)
- w += item.Splitter[minimum]
- }
-
- var handle = handles[i]
- if (handle && items[i + ((d.expandingIndex > i) ? 0 : 1)].visible)
- w += handle[d.size]
- }
- return w
- }
-
- function updateLayout()
- {
- // This function will reposition both handles and
- // items according to the _width of the each item_
- if (items.length === 0)
- return;
- if (d.updateLayoutGuard === true)
- return
- d.updateLayoutGuard = true
-
- // Use a temporary variable to store values to avoid breaking
- // property bindings when the value does not actually change:
- var newValue
-
- // Ensure all items within min/max:
- for (var i=0; i<items.length; ++i) {
- if (i !== d.expandingIndex) {
- item = items[i];
- // If the item is using percentage width, convert
- // that number to real width now:
- if (item.Splitter.percentageSize !== -1) {
- newValue = item.Splitter.percentageSize * (root[d.size] / 100)
- if (newValue !== item[d.size])
- item[d.size] = newValue
- }
- // Ensure item width is not more than maximumSize:
- if (item.Splitter[maximum] !== -1) {
- newValue = Math.min(item[d.size], item.Splitter[maximum])
- if (newValue !== item[d.size])
- item[d.size] = newValue
- }
- // Ensure item width is not more less minimumWidth:
- if (item.Splitter[minimum] !== -1) {
- newValue = Math.max(item[d.size], item.Splitter[minimum])
- if (newValue !== item[d.size])
- item[d.size] = newValue
- }
- }
- }
-
- // Special case: set width of expanding item to available space:
- newValue = root[d.size] - d.accumulatedSize(0, items.length, false);
- var expandingItem = items[d.expandingIndex]
- var expandingMinimum = 0
- if (expandingItem.Splitter[minimum] !== -1)
- expandingMinimum = expandingItem.Splitter[minimum]
- newValue = Math.max(newValue, expandingMinimum)
- if (expandingItem[d.size] !== 0 && expandingItem.Splitter.percentageSize !== -1)
- expandingItem.Splitter.percentageSize = newValue * (100 / root[d.size])
- if (expandingItem[d.size] !== newValue)
- expandingItem[d.size] = newValue
-
- // Then, position items and handles according to their width:
- var item, lastVisibleItem
- var handle, lastVisibleHandle
- var newpreferredSize = expandingMinimum - expandingItem[d.size]
-
- for (i=0; i<items.length; ++i) {
- // Position item to the right of the previous visible handle:
- item = items[i];
- if (item.visible) {
- if (lastVisibleHandle) {
- newValue = lastVisibleHandle[d.offset] + lastVisibleHandle[d.size]
- if (newValue !== item[d.offset])
- item[d.offset] = newValue
- } else {
- newValue = 0
- if (newValue !== item[d.offset])
- item[d.offset] = newValue
- }
- newpreferredSize += item[d.size]
- lastVisibleItem = item
- }
-
- // Position handle to the right of the previous visible item. We use an alterative way of
- // checking handle visibility because that property might not have updated correctly yet:
- handle = handles[i]
- if (handle && items[i + ((d.expandingIndex > i) ? 0 : 1)].visible) {
- newValue = lastVisibleItem[d.offset] + Math.max(0, lastVisibleItem[d.size])
- if (newValue !== handle[d.offset])
- handle[d.offset] = newValue
- newpreferredSize += handle[d.size]
- lastVisibleHandle = handle
- }
- }
-
- root.preferredSize = newpreferredSize
- d.updateLayoutGuard = false
- }
- }
-
- Component {
- id: handleloader
- Loader {
- id: myHandle
- property int handleIndex: 0
- property Item handle: myHandle
- property Item splitterItem: items[handleIndex + ((d.expandingIndex > handleIndex) ? 0 : 1)]
-
- // 'splitterRow' should be an alias, but that fails to resolve runtime:
- property Item splitterRow: root
- property Item background: item
-
- visible: splitterItem.visible
- sourceComponent: handleDelegate
- onWidthChanged: d.updateLayout()
- onHeightChanged: d.updateLayout()
-
- onXChanged: {
- // For some unknown reason, dragging by X axis only not working in MouseArea, so
- // to enable it Drag.XandYAxis should be used, therefore not only Y coordinate
- // changes, but also X and we need to filter out this events, if we have splitter,
- // that should move vertically
- if (d.horizontal) {
- moveHandle()
- }
- }
-
- onYChanged: {
- moveHandle()
- }
-
- function moveHandle() {
- // Moving the handle means resizing an item. Which one,
- // left or right, depends on where the expanding item is.
- // 'updateLayout' will override in case new width violates max/min.
- // And 'updateLayout will be triggered when an item changes width.
- if (d.updateLayoutGuard)
- return
-
- var leftHandle, leftItem, rightItem, rightHandle
- var leftEdge, rightEdge, newWidth, leftStopX, rightStopX
- var i
-
- if (d.expandingIndex > handleIndex) {
- // Resize item to the left.
- // Ensure that the handle is not crossing other handles. So
- // find the first visible handle to the left to determine the left edge:
- leftEdge = 0
- for (i=handleIndex-1; i>=0; --i) {
- leftHandle = handles[i]
- if (leftHandle.visible) {
- leftEdge = leftHandle[d.offset] + leftHandle[d.size]
- break;
- }
- }
-
- // Ensure: leftStopX >= myHandle[d.offset] >= rightStopX
- var min = d.accumulatedSize(handleIndex+1, items.length, true)
- rightStopX = root[d.size] - min - myHandle[d.size]
- leftStopX = Math.max(leftEdge, myHandle[d.offset])
- myHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, myHandle[d.offset]))
-
- newWidth = myHandle[d.offset] - leftEdge
- leftItem = items[handleIndex]
- if (root[d.size] != 0 && leftItem.Splitter.percentageSize !== -1)
- leftItem.Splitter.percentageSize = newWidth * (100 / root[d.size])
- // The next line will trigger 'updateLayout' inside 'propertyChangeListener':
- leftItem[d.size] = newWidth
- } else {
- // Resize item to the right.
- // Ensure that the handle is not crossing other handles. So
- // find the first visible handle to the right to determine the right edge:
- rightEdge = root[d.size]
- for (i=handleIndex+1; i<handles.length; ++i) {
- rightHandle = handles[i]
- if (rightHandle.visible) {
- rightEdge = rightHandle[d.offset]
- break;
- }
- }
-
- // Ensure: leftStopX <= myHandle[d.offset] <= rightStopX
- var min = d.accumulatedSize(0, handleIndex+1, true)
- leftStopX = min - myHandle[d.size]
- rightStopX = Math.min((rightEdge - myHandle[d.size]), myHandle[d.offset])
- myHandle[d.offset] = Math.max(leftStopX, Math.min(myHandle[d.offset], rightStopX))
-
- newWidth = rightEdge - (myHandle[d.offset] + myHandle[d.size])
- rightItem = items[handleIndex+1]
- if (root[d.size] !== 0 && rightItem[d.percentageSize] !== -1)
- rightItem.Splitter.percentageSize = newWidth * (100 / root[d.size])
- // The next line will trigger 'updateLayout' inside 'propertyChangeListener':
- rightItem[d.size] = newWidth
- }
- }
- }
- }
-
- Item {
- id: splitterItems
- anchors.fill: parent
- }
- Item {
- id: splitterHandles
- anchors.fill: parent
- }
-
- Component {
- // This dummy item becomes a child of all
- // items it the splitter, just to provide a way
- // to listen for changes to their width, expanding etc.
- id: propertyChangeListener
- Item {
- id: target
- width: (d.horizontal ? parent[d.size] : 0)
- height: (!d.horizontal ? parent[d.size] : 0)
- property bool expanding: parent.Splitter.expanding
- property real percentageSize: parent.Splitter.percentageSize
- property real minimumWidth: parent.Splitter[d.minimum]
- property real maximumSize: parent.Splitter[d.maximum]
- property int itemIndex: parent.Splitter.itemIndex
-
- onPercentageSizeChanged: d.updateLayout();
- onMinimumWidthChanged: d.updateLayout();
- onMaximumSizeChanged: d.updateLayout();
- onExpandingChanged: updateExpandingIndex()
-
- function updateExpandingIndex()
- {
- // The following code is needed to avoid a binding
- // loop, since we might change 'expanding' again to a different item:
- if (d.itemExpandingGuard === true)
- return
- d.itemExpandingGuard = true
- // break binding:
- expanding = false
-
- // 'expanding' follows radio button behavior:
- // First, find the new expanding item:
- var newIndex = items.length-1
- for (var i=0; i<items.length; ++i) {
- var item = items[i]
- if (i !== d.expandingIndex && item.Splitter.expanding === true && item.visible === true) {
- newIndex = i
- break
- }
- }
- item = items[newIndex]
- if (item.visible === false) {
- // So now we ended up with the last item in the splitter to be
- // expanding, but it turns out to not be visible. So we need to
- // traverse backwards again to find one that is visible...
- for (i=items.length-2; i>=0; --i) {
- var item = items[i]
- if (item.visible === true) {
- newIndex = i
- item = items[newIndex]
- break
- }
- }
- }
-
- // Tell the found item that it is expanding:
- if (item.Splitter.expanding !== true)
- item.Splitter.expanding = true
- // ...and the old one that it is not:
- if (newIndex !== d.expandingIndex) {
- item = items[d.expandingIndex]
- if (item.Splitter.expanding !== false)
- item.Splitter.expanding = false
- }
- // update index:
- d.expandingIndex = newIndex
- d.updateLayout();
- // recreate binding:
- expanding = Qt.binding(function() { return parent.Splitter.expanding })
- d.itemExpandingGuard = false
- }
-
- function handleSizeChanged() {
- // We need to update the layout.
- // The following code is needed to avoid a binding
- // loop, since we might change 'width' again to a different value:
- if (d.itemWidthGuard === true)
- return
- d.itemWidthGuard = true
- // Break binding:
- if (d.horizontal) {
- width = 0
- } else {
- height = 0
- }
-
- d.updateLayout()
-
- // Restablish binding:
- if (d.horizontal) {
- width = Qt.binding(function() { return parent[d.size]; })
- } else {
- height = Qt.binding(function() { return parent[d.size]; })
- }
- d.itemWidthGuard = false
- }
-
- onWidthChanged: handleSizeChanged()
- onHeightChanged: handleSizeChanged()
- onVisibleChanged: {
- // Hiding the expanding item forces us to
- // select a new one (and therefore not recommended):
- if (d.expandingIndex === itemIndex) {
- updateExpandingIndex()
- } else {
- if (visible) {
- // Try to keep all items within the SplitterRow. When an item
- // has been hidden, the expanding item might no longer be large enough
- // to give away space to the new items width. So we need to resize:
- var overflow = d.accumulatedSize(0, items.length, true) - root[d.size];
- if (overflow > 0)
- parent[d.size] -= overflow
- }
- d.updateLayout()
- }
- }
- }
- }
-}
diff --git a/src/qtdesktop/qdesktopitem.cpp b/src/qtdesktop/qdesktopitem.cpp
deleted file mode 100644
index 65433455..00000000
--- a/src/qtdesktop/qdesktopitem.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qdesktopitem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QDesktopItem::QDesktopItem(QObject* obj) : QObject(obj) {
- connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(screenGeometryChanged()));
- connect(&desktopWidget, SIGNAL(resized(int)), this, SIGNAL(availableGeometryChanged()));
- connect(&desktopWidget, SIGNAL(workAreaResized(int)), this, SIGNAL(availableGeometryChanged()));
- connect(&desktopWidget, SIGNAL(screenCountChanged(int)), this, SIGNAL(screenCountChanged()));
-}
-
-int QDesktopItem::screenCount() const
-{
- return desktopWidget.screenCount();
-}
-
-QRect QDesktopItem::screenGeometry(int screen) const {
- return desktopWidget.screenGeometry(screen);
-}
-
-QRect QDesktopItem::availableGeometry(int screen) const {
- return desktopWidget.availableGeometry(screen);
-}
-
-int QDesktopItem::screenWidth() const
-{
- return desktopWidget.screenGeometry().width();
-}
-
-int QDesktopItem::screenHeight() const
-{
- return desktopWidget.screenGeometry().height();
-}
-
-int QDesktopItem::availableWidth() const
-{
- return desktopWidget.availableGeometry().width();
-}
-
-int QDesktopItem::availableHeight() const
-{
- return desktopWidget.availableGeometry().height();
-}
-
-QDesktopItem *QDesktopItem::qmlAttachedProperties(QObject *obj) {
- return new QDesktopItem(obj);
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qdesktopitem_p.h b/src/qtdesktop/qdesktopitem_p.h
deleted file mode 100644
index 1db2a890..00000000
--- a/src/qtdesktop/qdesktopitem_p.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QDESKTOPITEM_P_H
-#define QDESKTOPITEM_P_H
-
-#include <QtWidgets/QDesktopWidget>
-#include <QtQml>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QDesktopItem : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int screenWidth READ screenWidth NOTIFY screenGeometryChanged)
- Q_PROPERTY(int screenHeight READ screenHeight NOTIFY screenGeometryChanged)
- Q_PROPERTY(int availableWidth READ availableWidth NOTIFY availableGeometryChanged)
- Q_PROPERTY(int availableHeight READ availableHeight NOTIFY availableGeometryChanged)
- Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged)
-
-public:
- QDesktopItem(QObject* obj);
-
- int screenCount() const;
- Q_INVOKABLE QRect screenGeometry(int screen) const;
- Q_INVOKABLE QRect availableGeometry(int screen) const;
- int screenWidth() const;
- int screenHeight() const;
- int availableWidth() const;
- int availableHeight() const;
- static QDesktopItem *qmlAttachedProperties(QObject *obj);
-
-private:
- QDesktopWidget desktopWidget;
-
-Q_SIGNALS:
- void screenGeometryChanged();
- void availableGeometryChanged();
- void screenCountChanged();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QDesktopItem, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QDESKTOPITEM_P_H
diff --git a/src/qtdesktop/qfiledialogitem.cpp b/src/qtdesktop/qfiledialogitem.cpp
deleted file mode 100644
index 67c7cb4b..00000000
--- a/src/qtdesktop/qfiledialogitem.cpp
+++ /dev/null
@@ -1,328 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Alberto Mardegan <info@mardy.it>
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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$
-**
-****************************************************************************/
-
-/*!
- \qmltype FileDialog
- \instantiates QFileDialogItem
- \inqmlmodule QtDesktop 1.0
- \brief Dialog component for choosing files from a local filesystem.
-
- FileDialog implements a basic file chooser: it allows the user to select
- existing files and/or directories, or create new filenames.
-*/
-
-/*!
- \qmlsignal FileDialog::accepted
-
- The \a accepted signal is emitted when the user has finished using the
- dialog. You can then inspect the \a filePath or \a filePaths properties to
- get the selection.
-
- Example:
-
- \qml
- FileDialog {
- onAccepted: { console.log("Selected file: " + filePath) }
- }
- \endqml
-*/
-
-/*!
- \qmlsignal FileDialog::rejected
-
- The \a rejected signal is emitted when the user has dismissed the dialog,
- either by closing the dialog window or by pressing the Cancel button.
-*/
-
-#include "qfiledialogitem_p.h"
-
-#if QT_VERSION < 0x050000
-#include <QGraphicsScene>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QFileDialogItem::QFileDialogItem():
- _dialog(new QFileDialog),
- _isOpen(false),
- _selectExisting(true),
- _selectMultiple(false),
- _selectFolder(false)
-{
- QObject::connect(_dialog, SIGNAL(accepted()), this, SIGNAL(accepted()));
- QObject::connect(_dialog, SIGNAL(rejected()), this, SIGNAL(rejected()));
-}
-
-QFileDialogItem::~QFileDialogItem()
-{
- delete _dialog;
-}
-
-/*!
- \qmlproperty string FileDialog::title
-
- The title of the dialog window.
-*/
-void QFileDialogItem::setTitle(QString title)
-{
- _dialog->setWindowTitle(title);
- emit titleChanged();
-}
-
-/* Intentionally left undocumented, as we might decide to remove it later */
-void QFileDialogItem::setModal(bool modal)
-{
- bool visible = _dialog->isVisible();
- _dialog->hide();
- _dialog->setWindowModality(modal ? Qt::WindowModal : Qt::NonModal);
-
- if (visible)
- _dialog->show();
- emit modalityChanged();
-}
-
-/*!
- \qmlproperty bool FileDialog::selectExisting
-
- Whether only existing files or directories can be selected.
-
- By default, this property is true.
-*/
-void QFileDialogItem::setSelectExisting(bool selectExisting)
-{
- if (selectExisting == _selectExisting) return;
- _selectExisting = selectExisting;
-
- updateFileMode();
-
- _dialog->setAcceptMode(selectExisting ?
- QFileDialog::AcceptOpen : QFileDialog::AcceptSave);
-
- Q_EMIT selectExistingChanged();
-}
-
-/*!
- \qmlproperty bool FileDialog::selectMultiple
-
- Whether more than one filename can be selected.
-
- By default, this property is false.
-*/
-void QFileDialogItem::setSelectMultiple(bool selectMultiple)
-{
- if (selectMultiple == _selectMultiple) return;
- _selectMultiple = selectMultiple;
-
- updateFileMode();
-
- Q_EMIT selectMultipleChanged();
-}
-
-/*!
- \qmlproperty bool FileDialog::selectFolder
-
- Whether the selected item should be a folder.
-
- By default, this property is false.
-*/
-void QFileDialogItem::setSelectFolder(bool selectFolder)
-{
- if (selectFolder == _selectFolder) return;
- _selectFolder = selectFolder;
-
- updateFileMode();
-
- Q_EMIT selectFolderChanged();
-}
-
-void QFileDialogItem::updateFileMode()
-{
- QFileDialog::FileMode mode = QFileDialog::AnyFile;
-
- if (_selectFolder) {
- mode = QFileDialog::Directory;
- _dialog->setOption(QFileDialog::ShowDirsOnly, true);
- } else if (_selectExisting) {
- mode = _selectMultiple ?
- QFileDialog::ExistingFiles : QFileDialog::ExistingFile;
- _dialog->setOption(QFileDialog::ShowDirsOnly, false);
- }
- _dialog->setFileMode(mode);
-}
-
-/*!
- \qmlproperty string FileDialog::folder
-
- The path to the currently selected folder. Setting this property before
- invoking open() will cause the file browser to be initially positioned on
- the specified folder.
-
- The value of this property is also updated after the dialog is closed.
-
- By default, this property is false.
-*/
-void QFileDialogItem::setFolder(const QString &folder)
-{
- _dialog->setDirectory(folder);
- Q_EMIT folderChanged();
-}
-
-QString QFileDialogItem::folder() const
-{
- return _dialog->directory().absolutePath();
-}
-
-/*!
- \qmlproperty list<string> FileDialog::nameFilters
-
- A list of strings to be used as file name filters. Each string can be a
- space-separated list of filters; filters may include the ? and * wildcards.
- The list of filters can also be enclosed in parentheses and a textual
- description of the filter can be provided.
-
- For example:
-
- \qml
- FileDialog {
- nameFilters: [ "Image files (*.jpg *.png)", "All files (*)" ]
- }
- \endqml
-
- \note Directories are not excluded by filters.
-*/
-void QFileDialogItem::setNameFilters(const QStringList &nameFilters)
-{
- _dialog->setNameFilters(nameFilters);
- Q_EMIT nameFiltersChanged();
-}
-
-/*!
- \qmlproperty string FileDialog::filePath
-
- The path of the file which was selected by the user.
-
- \note This property is set only if exactly one file was selected. In all
- other cases, it will return an empty string.
-
- \sa filePaths
-*/
-QString QFileDialogItem::filePath() const
-{
- QStringList files = filePaths();
- return (files.count() == 1) ? files[0] : QString();
-}
-
-/*!
- \qmlproperty list<string> FileDialog::filePaths
-
- The list of file paths which were selected by the user.
-*/
-QStringList QFileDialogItem::filePaths() const
-{
- return _dialog->selectedFiles();
-}
-
-void QFileDialogItem::setVisible(bool visible)
-{
- if (visible)
- open();
- else
- close();
-}
-
-/*!
- \qmlmethod void FileDialog::open()
-
- Shows the dialog to the user.
-*/
-void QFileDialogItem::open()
-{
-#if QT_VERSION < 0x050000
- /* We must set the QtDeclarative scene as parent widget for the
- * QDialog, so that it will be positioned on top of it.
- * This is also necessary for the modality to work.
- */
- if (_dialog->parentWidget() == 0) {
- QList<QGraphicsView *> views = scene()->views();
- if (!views.isEmpty()) {
- _dialog->setParent(views[0], Qt::Dialog);
- }
- }
-#endif
-
- if (!isVisible()) {
- _dialog->show();
- emit visibleChanged();
- }
- _isOpen = true;
-}
-
-/*!
- \qmlmethod void FileDialog::close()
-
- Closes the dialog.
-*/
-void QFileDialogItem::close()
-{
- _isOpen = false;
- _dialog->hide();
- emit visibleChanged();
-}
-
-#if QT_VERSION < 0x050000
-QVariant QFileDialogItem::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- if (change == QGraphicsItem::QGraphicsItem::ItemVisibleHasChanged) {
- bool visible = value.toBool();
-
- if (visible && _isOpen) {
- _dialog->show();
- } else {
- _dialog->hide();
- }
- emit visibleChanged();
- }
-
- return QDeclarativeItem::itemChange(change, value);
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qfiledialogitem_p.h b/src/qtdesktop/qfiledialogitem_p.h
deleted file mode 100644
index d7a910b3..00000000
--- a/src/qtdesktop/qfiledialogitem_p.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Alberto Mardegan <info@mardy.it>
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QFILEDIALOGITEM_P_H
-#define QFILEDIALOGITEM_P_H
-
-#include <QApplication>
-#if QT_VERSION < 0x050000
-#include <QDeclarativeItem>
-#include <QDeclarativeView>
-#else
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#endif
-#include <QFileDialog>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-#if QT_VERSION < 0x050000
-class QFileDialogItem : public QDeclarativeItem
-#else
-class QFileDialogItem : public QQuickItem
-#endif
-{
- Q_OBJECT
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
- Q_PROPERTY(bool modal READ modal WRITE setModal NOTIFY modalityChanged)
- Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
- Q_PROPERTY(bool selectExisting READ selectExisting \
- WRITE setSelectExisting NOTIFY selectExistingChanged)
- Q_PROPERTY(bool selectMultiple READ selectMultiple \
- WRITE setSelectMultiple NOTIFY selectMultipleChanged)
- Q_PROPERTY(bool selectFolder READ selectFolder \
- WRITE setSelectFolder NOTIFY selectFolderChanged)
- Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
- Q_PROPERTY(QStringList nameFilters READ nameFilters \
- WRITE setNameFilters NOTIFY nameFiltersChanged)
- Q_PROPERTY(QString filePath READ filePath NOTIFY accepted)
- Q_PROPERTY(QStringList filePaths READ filePaths NOTIFY accepted)
-
-public:
- QFileDialogItem();
- ~QFileDialogItem();
-
- bool isVisible() const { return _dialog->isVisible(); }
- QString title() const { return _dialog->windowTitle(); }
- bool modal() const { return _dialog->isModal(); }
- bool selectExisting() const { return _selectExisting; }
- bool selectMultiple() const { return _selectMultiple; }
- bool selectFolder() const { return _selectFolder; }
- QString folder() const;
- QStringList nameFilters() const { return _dialog->nameFilters(); }
- QString filePath() const;
- QStringList filePaths() const;
-
- void setVisible(bool visible);
- void setTitle(QString title);
- void setModal(bool modal);
- void setSelectExisting(bool selectExisting);
- void setSelectMultiple(bool selectMultiple);
- void setSelectFolder(bool selectFolder);
- void setFolder(const QString &folder);
- void setNameFilters(const QStringList &nameFilters);
-
-public Q_SLOTS:
- void open();
- void close();
-
-Q_SIGNALS:
- void titleChanged();
- void modalityChanged();
- void accepted();
- void rejected();
- void selectExistingChanged();
- void selectMultipleChanged();
- void selectFolderChanged();
- void folderChanged();
- void nameFiltersChanged();
- void visibleChanged();
-
-protected:
-#if QT_VERSION < 0x050000
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-#endif
-
-private:
- void updateFileMode();
-
-private:
- QFileDialog *_dialog;
- bool _isOpen;
- bool _selectExisting;
- bool _selectMultiple;
- bool _selectFolder;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFILEDIALOGITEM_P_H
diff --git a/src/qtdesktop/qpagestatus.h b/src/qtdesktop/qpagestatus.h
deleted file mode 100644
index c3cb9c47..00000000
--- a/src/qtdesktop/qpagestatus.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QPAGESTATUS_H
-#define QPAGESTATUS_H
-
-#include <QtQml>
-#include <QtQuick>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QPageStatus : public QObject
-{
- Q_OBJECT
- Q_ENUMS(PageStatus)
-
-public:
- enum PageStatus {
- Inactive = 0,
- Deactivating = 1,
- Activating = 2,
- Active = 3
- };
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPAGESTATUS_H
diff --git a/src/qtdesktop/qquickcomponentsprivate.cpp b/src/qtdesktop/qquickcomponentsprivate.cpp
deleted file mode 100644
index d53b29d8..00000000
--- a/src/qtdesktop/qquickcomponentsprivate.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qquickcomponentsprivate_p.h"
-#include <QToolTip>
-#include <QQuickWindow>
-
-QT_BEGIN_NAMESPACE
-
-QQuickComponentsPrivate::QQuickComponentsPrivate(QObject *parent)
- : QObject(parent)
-{
-
-}
-
-void QQuickComponentsPrivate::showToolTip(QQuickItem *item, const QPointF &pos, const QString &str)
-{
- if (!item || !item->window())
- return;
-
- QToolTip::showText(item->window()->mapToGlobal(item->mapToScene(pos).toPoint()), str);
-}
-
-void QQuickComponentsPrivate::hideToolTip()
-{
- QToolTip::hideText();
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qquickcomponentsprivate_p.h b/src/qtdesktop/qquickcomponentsprivate_p.h
deleted file mode 100644
index 716e6e11..00000000
--- a/src/qtdesktop/qquickcomponentsprivate_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QQUICKCOMPONENTSPRIVATE_P_H
-#define QQUICKCOMPONENTSPRIVATE_P_H
-
-#include <QObject>
-#include <QQuickItem>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QQuickComponentsPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QQuickComponentsPrivate(QObject *parent = 0);
-
- Q_INVOKABLE void showToolTip(QQuickItem *item, const QPointF &pos, const QString &text);
- Q_INVOKABLE void hideToolTip();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QQUICKCOMPONENTSPRIVATE_P_H
diff --git a/src/qtdesktop/qquicklayout.cpp b/src/qtdesktop/qquicklayout.cpp
deleted file mode 100644
index 1872fc76..00000000
--- a/src/qtdesktop/qquicklayout.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 "qquicklayout_p.h"
-#include <QEvent>
-#include <QApplication>
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-static const qreal q_declarativeLayoutMaxSize = 10e8;
-
-
-QQuickComponentsLayoutAttached::QQuickComponentsLayoutAttached(QObject *parent)
- : QObject(parent),
- m_minimumWidth(0),
- m_minimumHeight(0),
- m_maximumWidth(q_declarativeLayoutMaxSize),
- m_maximumHeight(q_declarativeLayoutMaxSize),
- m_verticalSizePolicy(QQuickComponentsLayout::Fixed),
- m_horizontalSizePolicy(QQuickComponentsLayout::Fixed)
-{
-
-}
-
-void QQuickComponentsLayoutAttached::setMinimumWidth(qreal width)
-{
- if (qIsNaN(width) || m_minimumWidth == width)
- return;
-
- m_minimumWidth = width;
- updateLayout();
-}
-
-void QQuickComponentsLayoutAttached::setMinimumHeight(qreal height)
-{
- if (qIsNaN(height) || m_minimumHeight == height)
- return;
-
- m_minimumHeight = height;
- updateLayout();
-}
-
-void QQuickComponentsLayoutAttached::setMaximumWidth(qreal width)
-{
- if (qIsNaN(width) || m_maximumWidth == width)
- return;
-
- m_maximumWidth = width;
- updateLayout();
-}
-
-void QQuickComponentsLayoutAttached::setMaximumHeight(qreal height)
-{
- if (qIsNaN(height) || m_maximumHeight == height)
- return;
-
- m_maximumHeight = height;
- updateLayout();
-}
-
-void QQuickComponentsLayoutAttached::setVerticalSizePolicy(QQuickComponentsLayout::SizePolicy policy)
-{
- if (m_verticalSizePolicy != policy) {
- m_verticalSizePolicy = policy;
- updateLayout();
- }
-}
-
-void QQuickComponentsLayoutAttached::setHorizontalSizePolicy(QQuickComponentsLayout::SizePolicy policy)
-{
- if (m_horizontalSizePolicy != policy) {
- m_horizontalSizePolicy = policy;
- updateLayout();
- }
-}
-
-void QQuickComponentsLayoutAttached::updateLayout()
-{
- if (m_layout)
- m_layout->invalidate();
-}
-
-
-
-QQuickComponentsLayout::QQuickComponentsLayout(QQuickItem *parent)
- : QQuickItem(parent),
- m_dirty(false)
-{
-
-}
-
-QQuickComponentsLayout::~QQuickComponentsLayout()
-{
-
-}
-
-void QQuickComponentsLayout::setupItemLayout(QQuickItem *item)
-{
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(item);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
- info->m_layout = this;
-}
-
-QQuickComponentsLayoutAttached *QQuickComponentsLayout::qmlAttachedProperties(QObject *object)
-{
- return new QQuickComponentsLayoutAttached(object);
-}
-
-bool QQuickComponentsLayout::event(QEvent *e)
-{
- if (e->type() == QEvent::LayoutRequest)
- reconfigureTopDown();
-
- return QQuickItem::event(e);
-}
-
-void QQuickComponentsLayout::invalidate()
-{
- if (m_dirty)
- return;
-
- QQuickComponentsLayout *layout = this;
- QQuickComponentsLayout *parentLayout = 0;
-
- while (!layout->m_dirty) {
- layout->m_dirty = true;
- parentLayout = qobject_cast<QQuickComponentsLayout *>(layout->parentItem());
-
- if (!parentLayout)
- break;
- else
- layout = parentLayout;
- }
-
- // just post events for top level layouts
- if (!parentLayout)
- QApplication::postEvent(layout, new QEvent(QEvent::LayoutRequest));
-}
-
-void QQuickComponentsLayout::reconfigureTopDown()
-{
- const QList<QQuickItem *> &children = childItems();
-
- reconfigureLayout();
-
- foreach (QQuickItem *child, children) {
- QQuickComponentsLayout *layout = qobject_cast<QQuickComponentsLayout *>(child);
-
- if (layout && layout->m_dirty)
- layout->reconfigureTopDown();
- }
-
- m_dirty = false;
-}
-
-void QQuickComponentsLayout::reconfigureLayout()
-{
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qquicklayout_p.h b/src/qtdesktop/qquicklayout_p.h
deleted file mode 100644
index 3f2f9f6c..00000000
--- a/src/qtdesktop/qquicklayout_p.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 QQUICKLAYOUT_P_H
-#define QQUICKLAYOUT_P_H
-
-#include <QPointer>
-#include <QQuickItem>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QQuickComponentsLayoutAttached;
-
-
-class QQuickComponentsLayout : public QQuickItem
-{
- Q_OBJECT
- Q_ENUMS(SizePolicy)
-
-public:
- enum SizePolicy {
- Fixed,
- Expanding
- };
-
- explicit QQuickComponentsLayout(QQuickItem *parent = 0);
- ~QQuickComponentsLayout();
-
- static QQuickComponentsLayoutAttached *qmlAttachedProperties(QObject *object);
-
-protected:
- void invalidate();
- bool event(QEvent *e);
- void reconfigureTopDown();
- virtual void reconfigureLayout();
- void setupItemLayout(QQuickItem *item);
-
-private:
- bool m_dirty;
-
- friend class QQuickComponentsLayoutAttached;
-};
-
-
-class QQuickComponentsLayoutAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth)
- Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight)
- Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth)
- Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight)
- Q_PROPERTY(QQuickComponentsLayout::SizePolicy verticalSizePolicy READ verticalSizePolicy WRITE setVerticalSizePolicy)
- Q_PROPERTY(QQuickComponentsLayout::SizePolicy horizontalSizePolicy READ horizontalSizePolicy WRITE setHorizontalSizePolicy)
-
-public:
- QQuickComponentsLayoutAttached(QObject *object);
-
- qreal minimumWidth() const { return m_minimumWidth; }
- void setMinimumWidth(qreal width);
-
- qreal minimumHeight() const { return m_minimumHeight; }
- void setMinimumHeight(qreal height);
-
- qreal maximumWidth() const { return m_maximumWidth; }
- void setMaximumWidth(qreal width);
-
- qreal maximumHeight() const { return m_maximumHeight; }
- void setMaximumHeight(qreal height);
-
- QQuickComponentsLayout::SizePolicy verticalSizePolicy() const { return m_verticalSizePolicy; }
- void setVerticalSizePolicy(QQuickComponentsLayout::SizePolicy policy);
-
- QQuickComponentsLayout::SizePolicy horizontalSizePolicy() const { return m_horizontalSizePolicy; }
- void setHorizontalSizePolicy(QQuickComponentsLayout::SizePolicy policy);
-
-protected:
- void updateLayout();
-
-private:
- qreal m_minimumWidth;
- qreal m_minimumHeight;
- qreal m_maximumWidth;
- qreal m_maximumHeight;
- QQuickComponentsLayout::SizePolicy m_verticalSizePolicy;
- QQuickComponentsLayout::SizePolicy m_horizontalSizePolicy;
- QPointer<QQuickComponentsLayout> m_layout;
-
- friend class QQuickComponentsLayout;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QQuickComponentsLayout)
-QML_DECLARE_TYPEINFO(QQuickComponentsLayout, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QQUICKLAYOUT_P_H
diff --git a/src/qtdesktop/qquicklayoutengine.cpp b/src/qtdesktop/qquicklayoutengine.cpp
deleted file mode 100644
index 2ede7af9..00000000
--- a/src/qtdesktop/qquicklayoutengine.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 "qquicklayoutengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*
- This function is a modification of qGeomCalc() included in "QtCore/kernel/qlayoutengine_p.h".
- It is used as a helper function to handle linear layout recalculations for QQuickItems.
-
- chain contains input and output parameters describing the geometry.
- count is the count of items in the chain; pos and space give the
- interval (relative to parentWidget topLeft).
-*/
-void qDeclarativeLayoutCalculate(QVector<QQuickComponentsLayoutInfo> &chain, int start,
- int count, qreal pos, qreal space, qreal spacer)
-{
- if (chain.count() == 0)
- return;
-
- bool wannaGrow = false;
- qreal totalStretch = 0;
- qreal totalSpacing = 0;
- qreal totalSizeHint = 0;
- qreal totalMinimumSize = 0;
-
- const int end = start + count;
- const int spacerCount = chain.count() - 1;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- data->done = false;
-
- totalStretch += data->stretch;
- totalSizeHint += data->smartSizeHint();
- totalMinimumSize += data->minimumSize;
-
- // don't count last spacing
- if (i < end - 1)
- totalSpacing += data->effectiveSpacer(spacer);
-
- wannaGrow = (wannaGrow || data->expansive || data->stretch > 0);
- }
-
- qreal extraSpace = 0;
-
- if (space < totalMinimumSize + totalSpacing) {
- // Less space than minimumSize; take from the biggest first
- qreal minSize = totalMinimumSize + totalSpacing;
-
- // shrink the spacers proportionally
- if (spacer >= 0) {
- spacer = minSize > 0 ? spacer * space / minSize : 0;
- totalSpacing = spacer * spacerCount;
- }
-
- QList<qreal> list;
-
- for (int i = start; i < end; i++)
- list << chain.at(i).minimumSize;
-
- qSort(list);
-
- qreal spaceLeft = space - totalSpacing;
-
- qreal sum = 0;
- int idx = 0;
- qreal spaceUsed = 0;
- qreal current = 0;
-
- while (idx < count && spaceUsed < spaceLeft) {
- current = list.at(idx);
- spaceUsed = sum + current * (count - idx);
- sum += current;
- ++idx;
- }
-
- --idx;
-
- int items = count - idx;
- qreal deficit = spaceUsed - spaceLeft;
- qreal deficitPerItem = deficit / items;
- qreal maxval = current - deficitPerItem;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
- data->done = true;
-
- if (data->minimumSize > 0)
- data->size = data->minimumSize;
- else
- data->size = qMin<qreal>(data->minimumSize, maxval);
- }
- } else if (space < totalSizeHint + totalSpacing) {
- /*
- Less space than smartSizeHint(), but more than minimumSize.
- Currently take space equally from each, as in Qt 2.x.
- Commented-out lines will give more space to stretchier
- items.
- */
- int n = count;
- qreal spaceLeft = space - totalSpacing;
- qreal overdraft = totalSizeHint - spaceLeft;
-
- // first give to the fixed ones
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->minimumSize >= data->smartSizeHint()) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->smartSizeHint();
- n--;
- }
- }
-
- bool finished = (n == 0);
-
- while (!finished) {
- finished = true;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- qreal w = overdraft / n;
- data->size = data->smartSizeHint() - w;
-
- if (data->size < data->minimumSize) {
- data->done = true;
- data->size = data->minimumSize;
- finished = false;
- overdraft -= data->smartSizeHint() - data->minimumSize;
- n--;
- break;
- }
- }
- }
- } else { // extra space
- int n = count;
- qreal spaceLeft = space - totalSpacing;
-
- // first give to the fixed ones, and handle non-expansiveness
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- if (data->maximumSize <= data->smartSizeHint()
- || (wannaGrow && !data->expansive && data->stretch == 0)
- || (!data->expansive && data->stretch == 0)) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->size;
- totalStretch -= data->stretch;
- n--;
- }
- }
-
- extraSpace = spaceLeft;
-
- /*
- Do a trial distribution and calculate how much it is off.
- If there are more deficit pixels than surplus pixels, give
- the minimum size items what they need, and repeat.
- Otherwise give to the maximum size items, and repeat.
-
- Paul Olav Tvete has a wonderful mathematical proof of the
- correctness of this principle, but unfortunately this
- comment is too small to contain it.
- */
- qreal surplus, deficit;
-
- do {
- surplus = deficit = 0;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- extraSpace = 0;
-
- qreal w;
-
- if (totalStretch <= 0)
- w = (spaceLeft / n);
- else
- w = (spaceLeft * data->stretch) / totalStretch;
-
- data->size = w;
-
- if (w < data->smartSizeHint())
- deficit += data->smartSizeHint() - w;
- else if (w > data->maximumSize)
- surplus += w - data->maximumSize;
- }
-
- if (deficit > 0 && surplus <= deficit) {
- // give to the ones that have too little
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->size < data->smartSizeHint()) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->smartSizeHint();
- totalStretch -= data->stretch;
- n--;
- }
- }
- }
-
- if (surplus > 0 && surplus >= deficit) {
- // take from the ones that have too much
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->size > data->maximumSize) {
- data->done = true;
- data->size = data->maximumSize;
- spaceLeft -= data->maximumSize;
- totalStretch -= data->stretch;
- n--;
- }
- }
- }
- } while (n > 0 && surplus != deficit);
-
- if (n == 0)
- extraSpace = spaceLeft;
- }
-
- /*
- As a last resort, we distribute the unwanted space equally
- among the spacers (counting the start and end of the chain). We
- could, but don't, attempt a sub-pixel allocation of the extra
- space.
- */
- qreal extra = extraSpace / (spacerCount + 2);
- qreal p = pos + extra;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
- data->pos = p;
- p += data->size;
- p += data->effectiveSpacer(spacer) + extra;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qquicklayoutengine_p.h b/src/qtdesktop/qquicklayoutengine_p.h
deleted file mode 100644
index 3bb656e5..00000000
--- a/src/qtdesktop/qquicklayoutengine_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 QQUICKLAYOUTENGINE_P_H
-#define QQUICKLAYOUTENGINE_P_H
-
-#include <QVector>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-struct QQuickComponentsLayoutInfo
-{
- QQuickComponentsLayoutInfo()
- : stretch(1),
- sizeHint(0),
- spacing(0),
- minimumSize(0),
- maximumSize(0),
- expansive(true),
- done(false),
- pos(0),
- size(0)
- { }
-
- inline qreal smartSizeHint() {
- return (stretch > 0) ? minimumSize : sizeHint;
- }
-
- inline qreal effectiveSpacer(qreal value) const {
- return value + spacing;
- }
-
- qreal stretch;
- qreal sizeHint;
- qreal spacing;
- qreal minimumSize;
- qreal maximumSize;
- bool expansive;
-
- // result
- bool done;
- qreal pos;
- qreal size;
-};
-
-void qDeclarativeLayoutCalculate(QVector<QQuickComponentsLayoutInfo> &chain, int start,
- int count, qreal pos, qreal space, qreal spacer);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QQUICKLAYOUTENGINE_P_H
diff --git a/src/qtdesktop/qquicklinearlayout.cpp b/src/qtdesktop/qquicklinearlayout.cpp
deleted file mode 100644
index da18ae0b..00000000
--- a/src/qtdesktop/qquicklinearlayout.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 "qquicklinearlayout_p.h"
-#include "qquicklayoutengine_p.h"
-#include <QtCore/qnumeric.h>
-
-/*!
- \qmltype RowLayout
- \instantiates QQuickComponentsRowLayout
- \inqmlmodule QtDesktop 1.0
- \brief RowLayout is doing bla...bla...
-*/
-
-/*!
- \qmltype ColumnLayout
- \instantiates QQuickComponentsColumnLayout
- \inqmlmodule QtDesktop 1.0
- \brief ColumnLayout is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-static const qreal q_declarativeLayoutDefaultSpacing = 4.0;
-
-
-QQuickComponentsLinearLayout::QQuickComponentsLinearLayout(Orientation orientation,
- QQuickItem *parent)
- : QQuickComponentsLayout(parent),
- m_spacing(q_declarativeLayoutDefaultSpacing),
- m_orientation(orientation)
-{
-
-}
-
-qreal QQuickComponentsLinearLayout::spacing() const
-{
- return m_spacing;
-}
-
-void QQuickComponentsLinearLayout::setSpacing(qreal spacing)
-{
- if (qIsNaN(spacing) || m_spacing == spacing)
- return;
-
- m_spacing = spacing;
- invalidate();
-}
-
-QQuickComponentsLinearLayout::Orientation QQuickComponentsLinearLayout::orientation() const
-{
- return m_orientation;
-}
-
-void QQuickComponentsLinearLayout::setOrientation(Orientation orientation)
-{
- if (m_orientation == orientation)
- return;
-
- m_orientation = orientation;
- invalidate();
-
- emit orientationChanged();
-}
-
-void QQuickComponentsLinearLayout::componentComplete()
-{
- QQuickComponentsLayout::componentComplete();
- updateLayoutItems();
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::updateLayoutItems()
-{
- const QList<QQuickItem *> &children = childItems();
- qreal implicitWidth = 0;
- qreal implicitHeight = 0;
- foreach (QQuickItem *child, children) {
- if (m_orientation == Horizontal) {
- implicitWidth += child->implicitWidth();
- implicitHeight = qMax(implicitHeight, child->implicitHeight());
- } else {
- implicitHeight += child->implicitHeight();
- implicitWidth = qMax(implicitWidth, child->implicitWidth());
- }
- insertLayoutItem(child);
- }
- setImplicitWidth(implicitWidth);
- setImplicitHeight(implicitHeight);
-}
-
-void QQuickComponentsLinearLayout::itemChange(ItemChange change, const ItemChangeData &value)
-{
- if (isComponentComplete()) {
- if (change == ItemChildAddedChange)
- insertLayoutItem(value.item);
- else if (change == ItemChildRemovedChange)
- removeLayoutItem(value.item);
- }
-
- QQuickComponentsLayout::itemChange(change, value);
-}
-
-void QQuickComponentsLinearLayout::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- QQuickComponentsLayout::geometryChanged(newGeometry, oldGeometry);
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::insertLayoutItem(QQuickItem *item)
-{
- m_items.append(item);
- setupItemLayout(item);
-
- invalidate();
- QObject::connect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
-}
-
-void QQuickComponentsLinearLayout::removeLayoutItem(QQuickItem *item)
-{
- if (!m_items.removeOne(item))
- return;
-
- invalidate();
- QObject::disconnect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
-}
-
-void QQuickComponentsLinearLayout::onItemDestroyed()
-{
- if (!m_items.removeOne(static_cast<QQuickItem *>(sender())))
- return;
-
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::reconfigureLayout()
-{
- if (!isComponentComplete())
- return;
-
- const int count = m_items.count();
-
- if (count == 0)
- return;
-
- qreal totalSpacing = 0;
- qreal totalSizeHint = 0;
- qreal totalMinimumSize = 0;
- qreal totalMaximumSize = 0;
-
- QVector<QQuickComponentsLayoutInfo> itemData;
-
- for (int i = 0; i < count; i++) {
- QQuickItem *item = m_items.at(i);
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(item);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
-
- QQuickComponentsLayoutInfo data;
-
- if (m_orientation == Horizontal) {
- data.sizeHint = item->implicitWidth();
- data.minimumSize = info->minimumWidth();
- data.maximumSize = info->maximumWidth();
- data.expansive = (info->horizontalSizePolicy() == QQuickComponentsLayout::Expanding);
- data.stretch = info->horizontalSizePolicy() == Expanding ? 1.0 : 0;
- } else {
- data.sizeHint = item->implicitHeight();
- data.minimumSize = info->minimumHeight();
- data.maximumSize = info->maximumHeight();
- data.expansive = (info->verticalSizePolicy() == QQuickComponentsLayout::Expanding);
- data.stretch = info->verticalSizePolicy() == Expanding ? 1.0 : 0;
- }
-
- itemData.append(data);
-
- // sum
- totalSizeHint += data.sizeHint;
- totalMinimumSize += data.minimumSize;
- totalMaximumSize += data.maximumSize;
-
- // don't count last spacing
- if (i < count - 1)
- totalSpacing += data.spacing + m_spacing;
- }
-
- if (m_orientation == Horizontal) {
- qDeclarativeLayoutCalculate(itemData, 0, count, 0, width(), m_spacing);
-
- for (int i = 0; i < count; i++) {
- QQuickItem *item = m_items.at(i);
- const QQuickComponentsLayoutInfo &data = itemData.at(i);
-
- item->setX(data.pos);
- item->setY(height()/2 - item->height()/2);
- item->setWidth(data.size);
- }
- } else {
- qDeclarativeLayoutCalculate(itemData, 0, count, 0, height(), m_spacing);
-
- for (int i = 0; i < count; i++) {
- QQuickItem *item = m_items.at(i);
- const QQuickComponentsLayoutInfo &data = itemData.at(i);
-
- item->setY(data.pos);
- item->setX(width()/2 - item->width()/2);
- item->setHeight(data.size);
- }
- }
-
- // propagate hints to upper levels
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(this);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
-
- if (m_orientation == Horizontal) {
- setImplicitWidth(totalSizeHint);
- info->setMinimumWidth(totalMinimumSize + totalSpacing);
- info->setMaximumWidth(totalMaximumSize + totalSpacing);
- } else {
- setImplicitHeight(totalSizeHint);
- info->setMinimumHeight(totalMinimumSize + totalSpacing);
- info->setMaximumHeight(totalMaximumSize + totalSpacing);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qquicklinearlayout_p.h b/src/qtdesktop/qquicklinearlayout_p.h
deleted file mode 100644
index 74dc7bcd..00000000
--- a/src/qtdesktop/qquicklinearlayout_p.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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 QQUICKLINEARLAYOUT_P_H
-#define QQUICKLINEARLAYOUT_P_H
-
-#include "qquicklayout_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QQuickComponentsLinearLayout : public QQuickComponentsLayout
-{
- Q_OBJECT
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
-
-public:
- enum Orientation {
- Vertical,
- Horizontal
- };
-
- explicit QQuickComponentsLinearLayout(Orientation orientation,
- QQuickItem *parent = 0);
- ~QQuickComponentsLinearLayout() {}
-
- qreal spacing() const;
- void setSpacing(qreal spacing);
-
- Orientation orientation() const;
- void setOrientation(Orientation orientation);
-
- void componentComplete();
-
-signals:
- void spacingChanged();
- void orientationChanged();
-
-protected:
- void updateLayoutItems();
- void reconfigureLayout();
- void insertLayoutItem(QQuickItem *item);
- void removeLayoutItem(QQuickItem *item);
- void itemChange(ItemChange change, const ItemChangeData &data);
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-
-protected slots:
- void onItemDestroyed();
-
-private:
- qreal m_spacing;
- Orientation m_orientation;
- QList<QQuickItem *> m_items;
-};
-
-
-class QQuickComponentsRowLayout : public QQuickComponentsLinearLayout
-{
- Q_OBJECT
-
-public:
- explicit QQuickComponentsRowLayout(QQuickItem *parent = 0)
- : QQuickComponentsLinearLayout(Horizontal, parent) {}
-};
-
-
-class QQuickComponentsColumnLayout : public QQuickComponentsLinearLayout
-{
- Q_OBJECT
-
-public:
- explicit QQuickComponentsColumnLayout(QQuickItem *parent = 0)
- : QQuickComponentsLinearLayout(Vertical, parent) {}
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QQUICKLINEARLAYOUT_P_H
diff --git a/src/qtdesktop/qstyleplugin.cpp b/src/qtdesktop/qstyleplugin.cpp
deleted file mode 100644
index cc80095a..00000000
--- a/src/qtdesktop/qstyleplugin.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 <qqml.h>
-#include "qstyleplugin_p.h"
-#include "qstyleitem_p.h"
-#include "qrangemodel_p.h"
-#include "qtaction_p.h"
-#include "qtexclusivegroup_p.h"
-#include "qtmenu_p.h"
-#include "qtmenubar_p.h"
-#include "qdesktopitem_p.h"
-#include "qwheelarea_p.h"
-#include "qtsplitterbase_p.h"
-#include "qquicklinearlayout_p.h"
-#include "qquickcomponentsprivate_p.h"
-#include "qfiledialogitem_p.h"
-#include "qpagestatus.h"
-#include <qqmlextensionplugin.h>
-
-#include <qqmlengine.h>
-#include <qquickimageprovider.h>
-#include <QtWidgets/QApplication>
-#include <QtQuick/QQuickWindow>
-#include <QImage>
-
-QT_BEGIN_NAMESPACE
-
-// Load icons from desktop theme
-class DesktopIconProvider : public QQuickImageProvider
-{
-public:
- DesktopIconProvider()
- : QQuickImageProvider(QQuickImageProvider::Pixmap)
- {
- }
-
- QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
- {
- Q_UNUSED(requestedSize);
- Q_UNUSED(size);
- int pos = id.lastIndexOf('/');
- QString iconName = id.right(id.length() - pos);
- int width = requestedSize.width();
- return QIcon::fromTheme(iconName).pixmap(width);
- }
-};
-
-QObject *registerPrivateModule(QQmlEngine *engine, QJSEngine *jsEngine)
-{
- Q_UNUSED(engine);
- Q_UNUSED(jsEngine);
- return new QQuickComponentsPrivate();
-}
-
-void StylePlugin::registerTypes(const char *uri)
-{
- qmlRegisterSingletonType<QQuickComponentsPrivate>(uri, 1, 0, "PrivateHelper", registerPrivateModule);
-
- qmlRegisterType<QStyleItem>(uri, 1, 0, "StyleItem");
- qmlRegisterType<QRangeModel>(uri, 1, 0, "RangeModel");
- qmlRegisterType<QWheelArea>(uri, 1, 0, "WheelArea");
-
- qmlRegisterType<QtAction>(uri, 1, 0, "Action");
- qmlRegisterType<QtExclusiveGroup>(uri, 1, 0, "ExclusiveGroup");
- qmlRegisterType<QtMenu>(uri, 1, 0, "Menu");
- qmlRegisterType<QtMenuBar>(uri, 1, 0, "MenuBar");
- qmlRegisterType<QtMenuItem>(uri, 1, 0, "MenuItem");
- qmlRegisterType<QtMenuSeparator>(uri, 1, 0, "Separator");
-
- qmlRegisterType<QQuickComponentsRowLayout>(uri, 1, 0, "RowLayout");
- qmlRegisterType<QQuickComponentsColumnLayout>(uri, 1, 0, "ColumnLayout");
- qmlRegisterUncreatableType<QQuickComponentsLayout>(uri, 1, 0, "Layout",
- QLatin1String("Do not create objects of type Layout"));
-
- qmlRegisterType<QFileDialogItem>(uri, 1, 0, "FileDialog");
-
- qmlRegisterType<QFileSystemModel>(uri, 1, 0, "FileSystemModel");
- qmlRegisterType<QtSplitterBase>(uri, 1, 0, "Splitter");
- qmlRegisterType<QQuickWindow>(uri, 1, 0, "Window");
-
- qmlRegisterUncreatableType<QtMenuBase>(uri, 1, 0, "NativeMenuBase", QLatin1String("Do not create objects of type NativeMenuBase"));
- qmlRegisterUncreatableType<QDesktopItem>(uri, 1, 0,"Desktop", QLatin1String("Do not create objects of type Desktop"));
- qmlRegisterUncreatableType<QPageStatus>(uri, 1, 0, "PageStatus", QLatin1String("Do not create objects of type PageStatus"));
-}
-
-void StylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
-{
- Q_UNUSED(uri);
- engine->addImageProvider("desktoptheme", new DesktopIconProvider);
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qstyleplugin_p.h b/src/qtdesktop/qstyleplugin_p.h
deleted file mode 100644
index e6af9952..00000000
--- a/src/qtdesktop/qstyleplugin_p.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QSTYLEPLUGIN_P_H
-#define QSTYLEPLUGIN_P_H
-
-#include <QQmlExtensionPlugin>
-#include <QtCore/QTimer>
-#include <QtWidgets/QFileSystemModel>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class StylePlugin : public QQmlExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtdesktopcomponents.QQmlExtensionInterface" FILE "styleplugin.json")
-public:
- void registerTypes(const char *uri);
- void initializeEngine(QQmlEngine *engine, const char *uri);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTYLEPLUGIN_P_H
diff --git a/src/qtdesktop/qtaction.cpp b/src/qtdesktop/qtaction.cpp
deleted file mode 100644
index 158575eb..00000000
--- a/src/qtdesktop/qtaction.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtaction_p.h"
-#include "qtexclusivegroup_p.h"
-
-#include <QtGui/private/qguiapplication_p.h>
-
-
-QtAction::QtAction(QObject *parent)
- : QObject(parent)
- , m_enabled(true)
- , m_checkable(false)
- , m_checked(false)
- , m_exclusiveGroup(0)
-{
-}
-
-QtAction::~QtAction()
-{
- setShortcut(QString());
- setMnemonic(QString());
-}
-
-void QtAction::setText(const QString &text)
-{
- if (text == m_text)
- return;
- m_text = text;
- emit textChanged();
-}
-
-bool qShortcutContextMatcher(QObject *, Qt::ShortcutContext)
-{
- // the context matching is only interesting for non window-wide shortcuts
- // it might be interesting to check for the action's window being active
- // we currently only support the window wide focus so we can safely ignore this
- return true;
-}
-
-QString QtAction::shortcut() const
-{
- return m_shortcut.toString(QKeySequence::NativeText);
-}
-
-void QtAction::setShortcut(const QString &arg)
-{
- QKeySequence sequence = QKeySequence::fromString(arg);
- if (sequence == m_shortcut)
- return;
-
- if (!m_shortcut.isEmpty())
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, m_shortcut);
-
- m_shortcut = sequence;
-
- if (!m_shortcut.isEmpty()) {
- Qt::ShortcutContext context = Qt::WindowShortcut;
- QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, m_shortcut, context, qShortcutContextMatcher);
- }
- emit shortcutChanged(shortcut());
-}
-
-QString QtAction::mnemonic() const
-{
- return m_mnemonic.toString(QKeySequence::NativeText);
-}
-
-void QtAction::setMnemonic(const QString &mnem)
-{
- QKeySequence sequence = QKeySequence::mnemonic(mnem);
- if (m_mnemonic == sequence)
- return;
-
- if (!m_mnemonic.isEmpty())
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(0, this, m_mnemonic);
-
- m_mnemonic = sequence;
-
- if (!m_mnemonic.isEmpty()) {
- Qt::ShortcutContext context = Qt::WindowShortcut;
- QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, m_mnemonic, context, qShortcutContextMatcher);
- }
- emit mnemonicChanged(mnemonic());
-}
-
-void QtAction::setIconSource(const QUrl &iconSource)
-{
- if (iconSource == m_iconSource)
- return;
-
- m_iconSource = iconSource;
- emit iconSourceChanged();
-}
-
-void QtAction::setIconName(const QString &iconName)
-{
- if (iconName == m_iconName)
- return;
-
- m_iconName = iconName;
- emit iconNameChanged();
-}
-
-void QtAction::setToolTip(const QString &arg)
-{
- if (m_toolTip != arg) {
- m_toolTip = arg;
- emit toolTipChanged(arg);
- }
-}
-
-void QtAction::setEnabled(bool e)
-{
- if (e == m_enabled)
- return;
- m_enabled = e;
- emit enabledChanged();
-}
-
-void QtAction::setCheckable(bool c)
-{
- if (c == m_checkable)
- return;
- m_checkable = c;
- emit checkableChanged();
-}
-
-void QtAction::setChecked(bool c)
-{
- if (c == m_checked)
- return;
- m_checked = c;
- emit toggled(m_checked);
-}
-
-void QtAction::setExclusiveGroup(QtExclusiveGroup *eg)
-{
- if (m_exclusiveGroup == eg)
- return;
-
- if (m_exclusiveGroup)
- m_exclusiveGroup->unregisterCheckable(this);
- m_exclusiveGroup = eg;
- if (m_exclusiveGroup)
- m_exclusiveGroup->registerCheckable(this);
-
- emit exclusiveGroupChanged();
-}
-
-bool QtAction::event(QEvent *e)
-{
- if (!m_enabled)
- return false;
-
- if (e->type() != QEvent::Shortcut)
- return false;
-
- QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
-
- Q_ASSERT_X(se->key() == m_shortcut || se->key() == m_mnemonic,
- "QtAction::event",
- "Received shortcut event from incorrect shortcut");
- if (se->isAmbiguous()) {
- qWarning("QtAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
- return false;
- }
-
- if (m_checkable)
- setChecked(!m_checked);
- emit triggered();
-
- return true;
-}
diff --git a/src/qtdesktop/qtaction_p.h b/src/qtdesktop/qtaction_p.h
deleted file mode 100644
index 3c12229a..00000000
--- a/src/qtdesktop/qtaction_p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTACTION_H
-#define QTACTION_H
-
-#include <QtCore/QObject>
-#include <QtCore/QUrl>
-#include <QtGui/QIcon>
-#include <QtGui/qkeysequence.h>
-
-class QtExclusiveGroup;
-
-class QtAction : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
- Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
- Q_PROPERTY(QString toolTip READ tooltip WRITE setToolTip NOTIFY toolTipChanged)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
-
- Q_PROPERTY(QtExclusiveGroup *exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup NOTIFY exclusiveGroupChanged)
-#ifndef QT_NO_SHORTCUT
- Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged)
- Q_PROPERTY(QString mnemonic READ mnemonic WRITE setMnemonic NOTIFY mnemonicChanged)
-#endif
-
-public:
- explicit QtAction(QObject *parent = 0);
- ~QtAction();
-
- QString text() const { return m_text; }
- void setText(const QString &text);
-
- QString shortcut() const;
- void setShortcut(const QString &shortcut);
-
- QString mnemonic() const;
- void setMnemonic(const QString &mnemonic);
-
- QString iconName() const { return m_iconName; }
- void setIconName(const QString &iconName);
-
- QUrl iconSource() const { return m_iconSource; }
- void setIconSource(const QUrl &iconSource);
-
- QString tooltip() const { return m_toolTip; }
- void setToolTip(const QString &toolTip);
-
- bool isEnabled() const { return m_enabled; }
- void setEnabled(bool e);
-
- bool isCheckable() const { return m_checkable; }
- void setCheckable(bool c);
-
- bool isChecked() const { return m_checked; }
- void setChecked(bool c);
-
- QtExclusiveGroup *exclusiveGroup() const { return m_exclusiveGroup; }
- void setExclusiveGroup(QtExclusiveGroup * arg);
-
- bool event(QEvent *e);
-
-public Q_SLOTS:
- void trigger() { emit triggered(); }
- void hover() { emit hovered(); }
-
-Q_SIGNALS:
- void triggered();
- void hovered();
- void toggled(bool);
-
- void textChanged();
- void shortcutChanged(QString shortcut);
- void mnemonicChanged(QString mnemonic);
-
- void iconNameChanged();
- void iconSourceChanged();
- void toolTipChanged(QString arg);
- void enabledChanged();
- void checkableChanged();
-
- void exclusiveGroupChanged();
-
-private:
- QString m_text;
- QUrl m_iconSource;
- QString m_iconName;
- bool m_enabled;
- bool m_checkable;
- bool m_checked;
- QtExclusiveGroup *m_exclusiveGroup;
- QKeySequence m_shortcut;
- QKeySequence m_mnemonic;
- QString m_toolTip;
-};
-
-#endif // QTACTION_H
diff --git a/src/qtdesktop/qtdesktop.pro b/src/qtdesktop/qtdesktop.pro
deleted file mode 100644
index c4e01387..00000000
--- a/src/qtdesktop/qtdesktop.pro
+++ /dev/null
@@ -1,64 +0,0 @@
-CXX_MODULE = qml
-TARGET = styleplugin
-TARGETPATH = QtDesktop
-
-QT += qml quick widgets gui-private core-private
-
-QMAKE_DOCS = $$PWD/doc/qtdesktopcomponents.qdocconf
-
-QML_FILES = \
- ApplicationWindow.qml \
- Button.qml \
- ButtonColumn.qml \
- ButtonRow.qml \
- CheckBox.qml \
- ComboBox.qml \
- ContextMenu.qml \
- Dial.qml \
- Dialog.qml \
- Frame.qml \
- GroupBox.qml \
- Label.qml \
- Page.qml \
- PageAnimation.qml \
- PageStack.qml \
- PageTransition.qml \
- ProgressBar.qml \
- RadioButton.qml \
- ScrollArea.qml \
- Slider.qml \
- SpinBox.qml \
- SplitterColumn.qml \
- SplitterRow.qml \
- StatusBar.qml \
- Tab.qml \
- TabFrame.qml \
- TableColumn.qml \
- TableView.qml \
- TextArea.qml \
- TextField.qml \
- ToolBar.qml \
- ToolButton.qml
-
-# private qml files
-QML_FILES += \
- private/TabBar.qml \
- private/BasicButton.qml \
- private/ButtonBehavior.qml \
- private/ButtonGroup.js \
- private/ModalPopupBehavior.qml \
- private/PageSlideTransition.qml \
- private/PageStack.js \
- private/ScrollAreaHelper.qml \
- private/Splitter.qml \
- private/ScrollBar.qml
-
-include(styleplugin.pri)
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
-mac {
- LIBS += -framework Carbon
-}
-
-load(qml_plugin)
diff --git a/src/qtdesktop/qtexclusivegroup.cpp b/src/qtdesktop/qtexclusivegroup.cpp
deleted file mode 100644
index 14622834..00000000
--- a/src/qtdesktop/qtexclusivegroup.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtexclusivegroup_p.h"
-
-#include <QtCore/QVariant>
-#include "qdebug.h"
-
-#define CHECKED_PROPERTY "checked"
-
-static const char *checkableSignals[] = {
- CHECKED_PROPERTY"Changed()",
- "toggled(bool)",
- "toggled()",
- 0
-};
-
-QtExclusiveGroup::QtExclusiveGroup(QObject *parent)
- : QObject(parent)
-{
- int index = metaObject()->indexOfMethod("updateCurrent()");
- m_updateCurrentMethod = metaObject()->method(index);
-}
-
-void QtExclusiveGroup::setCurrent(QObject * o)
-{
- if (m_current == o)
- return;
-
- if (m_current)
- m_current->setProperty(CHECKED_PROPERTY, QVariant(false));
- m_current = o;
- if (m_current)
- m_current->setProperty(CHECKED_PROPERTY, QVariant(true));
- emit currentChanged();
-}
-
-void QtExclusiveGroup::updateCurrent()
-{
- QObject *checkable = sender();
- QVariant checkedVariant = checkable->property(CHECKED_PROPERTY);
- if (checkedVariant.isValid() && checkedVariant.toBool())
- setCurrent(checkable);
-}
-
-void QtExclusiveGroup::registerCheckable(QObject *o)
-{
- for (const char **signalName = checkableSignals; *signalName; signalName++) {
- int signalIndex = o->metaObject()->indexOfSignal(*signalName);
- if (signalIndex != -1) {
- QMetaMethod signalMethod = o->metaObject()->method(signalIndex);
- connect(o, signalMethod, this, m_updateCurrentMethod, Qt::UniqueConnection);
- connect(o, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterCheckable(QObject*)), Qt::UniqueConnection);
- return;
- }
- }
-
- qWarning() << "QtExclusiveGroup::registerCheckable(): Cannot register" << o;
-}
-
-void QtExclusiveGroup::unregisterCheckable(QObject *o)
-{
- for (const char **signalName = checkableSignals; *signalName; signalName++) {
- int signalIndex = o->metaObject()->indexOfSignal(*signalName);
- if (signalIndex != -1) {
- QMetaMethod signalMethod = o->metaObject()->method(signalIndex);
- if (disconnect(o, signalMethod, this, m_updateCurrentMethod)) {
- disconnect(o, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterCheckable(QObject*)));
- break;
- }
- }
- }
-}
diff --git a/src/qtdesktop/qtexclusivegroup_p.h b/src/qtdesktop/qtexclusivegroup_p.h
deleted file mode 100644
index 28ae93dc..00000000
--- a/src/qtdesktop/qtexclusivegroup_p.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTEXCLUSIVEGROUP_H
-#define QTEXCLUSIVEGROUP_H
-
-#include <QObject>
-#include <QtQml/QtQml>
-
-class QtExclusiveGroup : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QObject *current READ current WRITE setCurrent NOTIFY currentChanged)
-
-public:
- explicit QtExclusiveGroup(QObject *parent = 0);
-
-public Q_SLOTS:
- void registerCheckable(QObject *o);
- void unregisterCheckable(QObject *o);
-
- QObject *current() const { return m_current; }
- void setCurrent(QObject * o);
-
-Q_SIGNALS:
- void currentChanged();
-
-private Q_SLOTS:
- void updateCurrent();
-
-private:
- QObject * m_current;
- QMetaMethod m_updateCurrentMethod;
-};
-
-#endif // QTEXCLUSIVEGROUP_H
diff --git a/src/qtdesktop/qtmenu.cpp b/src/qtdesktop/qtmenu.cpp
deleted file mode 100644
index e02d28a9..00000000
--- a/src/qtdesktop/qtmenu.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtmenu_p.h"
-#include "qdebug.h"
-#include <qapplication.h>
-#include <qmenubar.h>
-#include <qabstractitemmodel.h>
-
-/*!
- \qmltype Menu
- \instantiates QtMenu
- \inqmlmodule QtDesktop 1.0
- \brief Menu is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-QtMenu::QtMenu(QQuickItem *parent)
- : QtMenuBase(parent),
- dummy(0),
- m_selectedIndex(0),
- m_highlightedIndex(0),
- m_hasNativeModel(false)
-{
- m_qmenu = new QMenu(0);
- connect(m_qmenu, SIGNAL(aboutToHide()), this, SIGNAL(menuClosed()));
-}
-
-QtMenu::~QtMenu()
-{
- delete m_qmenu;
-}
-
-void QtMenu::setText(const QString &text)
-{
- m_qmenu->setTitle(text);
- emit textChanged();
-}
-
-QString QtMenu::text() const
-{
- return m_qmenu->title();
-}
-
-void QtMenu::setSelectedIndex(int index)
-{
- m_selectedIndex = index;
- QList<QAction *> actionList = m_qmenu->actions();
- if (m_selectedIndex >= 0 && m_selectedIndex < actionList.size())
- m_qmenu->setActiveAction(actionList[m_selectedIndex]);
- emit selectedIndexChanged();
-}
-
-void QtMenu::setHoveredIndex(int index)
-{
- m_highlightedIndex = index;
- QList<QAction *> actionList = m_qmenu->actions();
- if (m_highlightedIndex >= 0 && m_highlightedIndex < actionList.size())
- m_qmenu->setActiveAction(actionList[m_highlightedIndex]);
- emit hoveredIndexChanged();
-}
-
-QQmlListProperty<QtMenuBase> QtMenu::menuItems()
-{
- return QQmlListProperty<QtMenuBase>(this, 0, &QtMenu::append_qmenuItem, 0, 0, 0);
-}
-
-void QtMenu::showPopup(qreal x, qreal y, int atActionIndex, QQuickWindow * parentWindow)
-{
-
- if (m_qmenu->isVisible())
- return;
-
- // If atActionIndex is valid, x and y is specified from the
- // the position of the corresponding QAction:
- QAction *atAction = 0;
- if (atActionIndex >= 0 && atActionIndex < m_qmenu->actions().size())
- atAction = m_qmenu->actions()[atActionIndex];
-
- QPointF screenPosition(mapToScene(QPoint(x, y)));
- QWindow *tw = parentWindow ? parentWindow : window();
- if (tw) {
- screenPosition = tw->mapToGlobal(QPoint(x, y));
- // calling winId forces a QWindow to be created
- // since this needs to be a top-level
- // otherwise windowHandle might return 0
- m_qmenu->winId();
- m_qmenu->windowHandle()->setTransientParent(tw);
- }
-
- setHoveredIndex(m_selectedIndex);
- m_qmenu->popup(screenPosition.toPoint(), atAction);
-}
-
-void QtMenu::hidePopup()
-{
- m_qmenu->close();
-}
-
-QAction* QtMenu::action()
-{
- return m_qmenu->menuAction();
-}
-
-Q_INVOKABLE void QtMenu::clearMenuItems()
-{
- m_qmenu->clear();
- foreach (QtMenuBase *item, m_qmenuItems) {
- delete item;
- }
- m_qmenuItems.clear();
-}
-
-void QtMenu::addMenuItem(const QString &text)
-{
- QtMenuItem *menuItem = new QtMenuItem(this);
- menuItem->setText(text);
- m_qmenuItems.append(menuItem);
- m_qmenu->addAction(menuItem->action());
-
- connect(menuItem->action(), SIGNAL(triggered()), this, SLOT(emitSelected()));
- connect(menuItem->action(), SIGNAL(hovered()), this, SLOT(emitHovered()));
-
- if (m_qmenu->actions().size() == 1)
- // Inform QML that the selected action (0) now has changed contents:
- emit selectedIndexChanged();
-}
-
-void QtMenu::emitSelected()
-{
- QAction *act = qobject_cast<QAction *>(sender());
- if (!act)
- return;
- m_selectedIndex = m_qmenu->actions().indexOf(act);
- emit selectedIndexChanged();
-}
-
-void QtMenu::emitHovered()
-{
- QAction *act = qobject_cast<QAction *>(sender());
- if (!act)
- return;
- m_highlightedIndex = m_qmenu->actions().indexOf(act);
- emit hoveredIndexChanged();
-}
-
-QString QtMenu::itemTextAt(int index) const
-{
- QList<QAction *> actionList = m_qmenu->actions();
- if (index >= 0 && index < actionList.size())
- return actionList[index]->text();
- else
- return "";
-}
-
-QString QtMenu::modelTextAt(int index) const
-{
- if (QAbstractItemModel *model = qobject_cast<QAbstractItemModel*>(m_model.value<QObject*>())) {
- return model->data(model->index(index, 0)).toString();
- } else if (m_model.canConvert(QVariant::StringList)) {
- return m_model.toStringList().at(index);
- }
- return "";
-}
-
-int QtMenu::modelCount() const
-{
- if (QAbstractItemModel *model = qobject_cast<QAbstractItemModel*>(m_model.value<QObject*>())) {
- return model->rowCount();
- } else if (m_model.canConvert(QVariant::StringList)) {
- return m_model.toStringList().count();
- }
- return -1;
-}
-
-void QtMenu::append_qmenuItem(QQmlListProperty<QtMenuBase> *list, QtMenuBase *menuItem)
-{
- QtMenu *menu = qobject_cast<QtMenu *>(list->object);
- if (menu) {
- menuItem->setParent(menu);
- menu->m_qmenuItems.append(menuItem);
- menu->qmenu()->addAction(menuItem->action());
- }
-}
-
-void QtMenu::setModel(const QVariant &newModel) {
- if (m_model != newModel) {
-
- // Clean up any existing connections
- if (QAbstractItemModel *oldModel = qobject_cast<QAbstractItemModel*>(m_model.value<QObject*>())) {
- disconnect(oldModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SIGNAL(rebuildMenu()));
- }
-
- m_hasNativeModel = false;
- m_model = newModel;
-
- if (QAbstractItemModel *model = qobject_cast<QAbstractItemModel*>(newModel.value<QObject*>())) {
- m_hasNativeModel = true;
- connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SIGNAL(rebuildMenu()));
- } else if (newModel.canConvert(QVariant::StringList)) {
- m_hasNativeModel = true;
- }
- emit modelChanged(m_model);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qtmenu_p.h b/src/qtdesktop/qtmenu_p.h
deleted file mode 100644
index a1ce4c6e..00000000
--- a/src/qtdesktop/qtmenu_p.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTMENU_P_H
-#define QTMENU_P_H
-#include <QtCore/qglobal.h>
-#include <QtWidgets/qmenu.h>
-#include <QtQuick/QtQuick>
-#include <QtQml/QtQml>
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/QVariant>
-#include "qtmenuitem_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QtMenu : public QtMenuBase
-{
- Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged)
- Q_PROPERTY(int hoveredIndex READ hoveredIndex WRITE setHoveredIndex NOTIFY hoveredIndexChanged)
- Q_PROPERTY(QQmlListProperty<QtMenuBase> menuItems READ menuItems)
- Q_CLASSINFO("DefaultProperty", "menuItems")
-public:
- QtMenu(QQuickItem *parent = 0);
- virtual ~QtMenu();
-
- void setText(const QString &text);
- QString text() const;
-
- int selectedIndex() const { return m_selectedIndex; }
- void setSelectedIndex(int index);
- int hoveredIndex() const { return m_highlightedIndex; }
- void setHoveredIndex(int index);
-
- QQmlListProperty<QtMenuBase> menuItems();
-
- QMenu* qmenu() { return m_qmenu; }
-
- QAction* action();
-
- Q_INVOKABLE int minimumWidth() const { return m_qmenu->minimumWidth(); }
- Q_INVOKABLE void setMinimumWidth(int w) { m_qmenu->setMinimumWidth(w); }
- Q_INVOKABLE void showPopup(qreal x, qreal y, int atActionIndex = -1, QQuickWindow *window = 0);
- Q_INVOKABLE void hidePopup();
- Q_INVOKABLE void clearMenuItems();
- Q_INVOKABLE void addMenuItem(const QString &text);
- Q_INVOKABLE QString itemTextAt(int index) const;
- Q_INVOKABLE QString modelTextAt(int index) const;
- Q_INVOKABLE int modelCount() const;
-
- QVariant model() const { return m_model; }
- Q_INVOKABLE bool hasNativeModel() const { return m_hasNativeModel; }
-
-public slots:
- void setModel(const QVariant &newModel);
-
-public:
-Q_SIGNALS:
- void menuClosed();
- void selectedIndexChanged();
- void hoveredIndexChanged();
- void modelChanged(const QVariant &newModel);
- void rebuildMenu();
- void textChanged();
-
-private Q_SLOTS:
- void emitSelected();
- void emitHovered();
-
-private:
- static void append_qmenuItem(QQmlListProperty<QtMenuBase> *list, QtMenuBase *menuItem);
-
- QWidget *dummy;
- QMenu *m_qmenu;
- QList<QtMenuBase *> m_qmenuItems;
- int m_selectedIndex;
- int m_highlightedIndex;
- bool m_hasNativeModel;
- QVariant m_model;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QtMenu)
-
-QT_END_HEADER
-
-#endif // QTMENU_P_H
diff --git a/src/qtdesktop/qtmenubar.cpp b/src/qtdesktop/qtmenubar.cpp
deleted file mode 100644
index a48b6e3a..00000000
--- a/src/qtdesktop/qtmenubar.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtmenubar_p.h"
-
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-
-/*!
- \qmltype MenuBar
- \instantiates QtMenuBar
- \inqmlmodule QtDesktop 1.0
- \brief MenuBar is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-QtMenuBar::QtMenuBar(QQuickItem *parent)
- : QQuickItem(parent)
-{
- connect(this, SIGNAL(parentChanged(QQuickItem *)), this, SLOT(updateParent(QQuickItem *)));
- setFlag(QQuickItem::ItemHasContents, false);
-#ifdef Q_OS_MAC
- _menuBar = new QMenuBar(0);
-#endif
-}
-
-QtMenuBar::~QtMenuBar()
-{
-}
-
-QQmlListProperty<QtMenu> QtMenuBar::menus()
-{
- return QQmlListProperty<QtMenu>(this, 0, &QtMenuBar::append_menu, 0, 0, 0);
-}
-
-QList<QObject*> QtMenuBar::menuList()
-{
- return m_menus;
-}
-
-void QtMenuBar::updateParent(QQuickItem *newParent)
-{
-#ifdef Q_OS_MAC
- _menuBar->clear();
- foreach (QObject *obj, m_menus) {
- QtMenu *menu = qobject_cast<QtMenu*>(obj);
- _menuBar->addMenu(menu->qmenu());
- }
-#endif
-}
-
-void QtMenuBar::append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu)
-{
- QtMenuBar *menuBar = qobject_cast<QtMenuBar *>(list->object);
- if (menuBar) {
- menu->setParent(menuBar);
- menuBar->m_menus.append(menu);
-#ifdef Q_OS_MAC
- if (menuBar->_menuBar)
- menuBar->_menuBar->addMenu(menu->qmenu());
-#endif
- menuBar->menuChanged();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qtmenubar_p.h b/src/qtdesktop/qtmenubar_p.h
deleted file mode 100644
index a49af73d..00000000
--- a/src/qtdesktop/qtmenubar_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTMENUBAR_P_H
-#define QTMENUBAR_P_H
-
-#include <QtCore/qglobal.h>
-
-#include <QtQuick/QQuickItem>
-#include <QtWidgets>
-
-#include "qtmenu_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QtMenuBar: public QQuickItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QQmlListProperty<QtMenu> menus READ menus NOTIFY menuChanged)
- Q_PROPERTY(QList<QObject*> menuList READ menuList NOTIFY menuChanged)
- Q_PROPERTY(bool showMenuBar READ showMenuBar NOTIFY showMenuBarChanged)
- Q_CLASSINFO("DefaultProperty", "menus")
-public:
- QtMenuBar(QQuickItem *parent = 0);
- ~QtMenuBar();
-
- QQmlListProperty<QtMenu> menus();
- QList<QObject*> menuList();
-
- bool showMenuBar() {
-#ifdef Q_OS_MAC
- return false;
-#endif
- return true;
-}
-
-signals:
- void menuChanged();
- void showMenuBarChanged();
-
-protected Q_SLOTS:
- void updateParent(QQuickItem *newParent);
-
-private:
- static void append_menu(QQmlListProperty<QtMenu> *list, QtMenu *menu);
-
-private:
- QList<QObject *> m_menus;
- QMenuBar *_menuBar;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QTMENUBAR_P_H
diff --git a/src/qtdesktop/qtmenuitem.cpp b/src/qtdesktop/qtmenuitem.cpp
deleted file mode 100644
index ec1826b0..00000000
--- a/src/qtdesktop/qtmenuitem.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtmenuitem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-void QtMenuBase::setIconSource(const QUrl &icon)
-{
- _iconSource = icon;
- if (_iconName.isEmpty())
- action()->setIcon(QIcon(icon.toLocalFile()));
- else
- action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile())));
-
- emit iconSourceChanged();
-}
-
-QUrl QtMenuBase::iconSource() const
-{
- return _iconSource;
-}
-
-void QtMenuBase::setIconName(const QString &icon)
-{
- _iconName = icon;
- action()->setIcon(QIcon::fromTheme(_iconName, QIcon(_iconSource.toLocalFile())));
-
- emit iconNameChanged();
-}
-
-QString QtMenuBase::iconName() const
-{
- return _iconName;
-}
-
-/*!
- \qmltype MenuItem
- \instantiates QtMenuSeparator
- \inqmlmodule QtDesktop 1.0
- \brief MenuItem is doing bla...bla...
-*/
-
-QtMenuSeparator::QtMenuSeparator(QQuickItem *parent)
- : QtMenuBase(parent), _action(new QAction(this))
-{
- _action->setSeparator(true);
-}
-
-QtMenuSeparator::~QtMenuSeparator()
-{
-}
-
-QAction * QtMenuSeparator::action()
-{
- return _action;
-}
-
-/*!
- \qmltype MenuItem
- \instantiates QtMenuItem
- \inqmlmodule QtDesktop 1.0
- \brief MenuItem is doing bla...bla...
-*/
-
-QtMenuItem::QtMenuItem(QQuickItem *parent)
- : QtMenuBase(parent), _action(new QAction(this))
-{
- connect(_action, SIGNAL(triggered()), this, SIGNAL(triggered()));
- connect(_action, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
- connect(_action, SIGNAL(changed()), this, SIGNAL(enabledChanged()));
-}
-
-QtMenuItem::~QtMenuItem()
-{
-}
-
-void QtMenuItem::setText(const QString &text)
-{
- _action->setText(text);
- emit textChanged();
-}
-
-void QtMenuItem::setShortcut(const QString &shortcut)
-{
- _action->setShortcut(QKeySequence(shortcut));
- emit shortcutChanged();
-}
-
-void QtMenuItem::setCheckable(bool checkable)
-{
- _action->setCheckable(checkable);
-}
-
-void QtMenuItem::setChecked(bool checked)
-{
- _action->setChecked(checked);
-}
-
-void QtMenuItem::setEnabled(bool enabled)
-{
- _action->setEnabled(enabled);
-}
-
-QString QtMenuItem::text() const
-{
- return _action->text();
-}
-
-QString QtMenuItem::shortcut() const
-{
- return _action->shortcut().toString();
-}
-
-bool QtMenuItem::checkable() const
-{
- return _action->isCheckable();
-}
-
-bool QtMenuItem::checked() const
-{
- return _action->isChecked();
-}
-
-bool QtMenuItem::enabled() const
-{
- return _action->isEnabled();
-}
-
-QAction * QtMenuItem::action()
-{
- return _action;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qtmenuitem_p.h b/src/qtdesktop/qtmenuitem_p.h
deleted file mode 100644
index 79654832..00000000
--- a/src/qtdesktop/qtmenuitem_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTMENUITEM_P_H
-#define QTMENUITEM_P_H
-
-#include <QtCore/QObject>
-#include <QtWidgets/QAction>
-#include <QtCore/QUrl>
-
-#include <QtQuick/QQuickItem>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QtMenuBase: public QQuickItem
-{
-Q_OBJECT
- Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged)
- Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
-
-public:
- QtMenuBase(QQuickItem *parent = 0) : QQuickItem(parent) {}
-
- virtual QAction* action() = 0;
-
- void setIconSource(const QUrl &icon);
- QUrl iconSource() const;
-
- void setIconName(const QString &icon);
- QString iconName() const;
-
-Q_SIGNALS:
- void iconSourceChanged();
- void iconNameChanged();
-
-private:
- QUrl _iconSource;
- QString _iconName;
-};
-
-class QtMenuSeparator : public QtMenuBase
-{
- Q_OBJECT
-public:
- QtMenuSeparator(QQuickItem *parent = 0);
- ~QtMenuSeparator();
- QAction* action();
-
-private:
- QAction *_action;
-};
-
-class QtMenuItem: public QtMenuBase
-{
- Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged);
- Q_PROPERTY(QString shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged)
- Q_PROPERTY(bool checkable READ checkable WRITE setCheckable)
- Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
-
-public:
- QtMenuItem(QQuickItem *parent = 0);
- ~QtMenuItem();
-
- void setText(const QString &text);
- void setShortcut(const QString &shortcut);
- void setCheckable(bool checkable);
- void setChecked(bool checked);
- void setEnabled(bool enabled);
-
- QString text() const;
- QString shortcut() const;
- bool checkable() const;
- bool checked() const;
- bool enabled() const;
-
- QAction* action();
-
-Q_SIGNALS:
- void triggered();
- void textChanged();
- void shortcutChanged();
- void toggled(bool);
- void enabledChanged();
-
-private:
- QAction *_action;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QTMENUITEM_P_H
diff --git a/src/qtdesktop/qtsplitterbase.cpp b/src/qtdesktop/qtsplitterbase.cpp
deleted file mode 100644
index 1ba2a58a..00000000
--- a/src/qtdesktop/qtsplitterbase.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qtsplitterbase_p.h"
-
-/*!
- \qmltype Splitter
- \instantiates QtSplitterBase
- \inqmlmodule QtDesktop 1.0
- \brief Splitter is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-QtSplitterBase::QtSplitterBase(QQuickItem *parent)
- : QQuickItem(parent)
-{
-}
-
-QtSplitterAttached *QtSplitterBase::qmlAttachedProperties(QObject *object)
-{
- return new QtSplitterAttached(object);
-}
-
-void QtSplitterAttached::setExpanding(bool expanding)
-{
- m_expanding = expanding;
- emit expandingChanged(expanding);
-}
-
-void QtSplitterAttached::setMaximumWidth(qreal width)
-{
- m_maximumWidth = width;
- emit maximumWidthChanged(width);
-}
-
-void QtSplitterAttached::setMinimumWidth(qreal width)
-{
- m_minimumWidth = width;
- emit minimumWidthChanged(width);
-}
-
-void QtSplitterAttached::setMaximumHeight(qreal height)
-{
- m_maximumHeight = height;
- emit maximumHeightChanged(height);
-}
-
-void QtSplitterAttached::setMinimumHeight(qreal height)
-{
- m_minimumHeight = height;
- emit minimumHeightChanged(height);
-}
-
-QtSplitterAttached::QtSplitterAttached(QObject *object)
- : QObject(object),
- m_minimumWidth(-1),
- m_maximumWidth(-1),
- m_minimumHeight(-1),
- m_maximumHeight(-1),
- m_percentageSize(-1),
- m_itemIndex(-1),
- m_expanding(false)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/qtsplitterbase_p.h b/src/qtdesktop/qtsplitterbase_p.h
deleted file mode 100644
index 9b7b226f..00000000
--- a/src/qtdesktop/qtsplitterbase_p.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 QTSPLITTERBASE_P_H
-#define QTSPLITTERBASE_P_H
-
-#include <QtQml>
-#include <QtQuick>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QtSplitterAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
- Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
- Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
- Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
- Q_PROPERTY(qreal percentageSize READ percentageSize WRITE setPercentageSize NOTIFY percentageWidthSize)
- Q_PROPERTY(bool expanding READ expanding WRITE setExpanding NOTIFY expandingChanged)
- Q_PROPERTY(int itemIndex READ itemIndex WRITE setItemIndex NOTIFY itemIndexChanged)
-
-public:
- explicit QtSplitterAttached(QObject *object);
-
- qreal minimumWidth() const { return m_minimumWidth; }
- void setMinimumWidth(qreal width);
-
- qreal maximumWidth() const { return m_maximumWidth; }
- void setMaximumWidth(qreal width);
-
- qreal minimumHeight() const { return m_minimumHeight; }
- void setMinimumHeight(qreal width);
-
- qreal maximumHeight() const { return m_maximumHeight; }
- void setMaximumHeight(qreal width);
-
- bool expanding() const { return m_expanding; }
- void setExpanding(bool expanding);
-
- qreal percentageSize() const { return m_percentageSize; }
-
- int itemIndex() const { return m_itemIndex; }
-
- void setPercentageSize(qreal arg) { m_percentageSize = arg; }
- void setItemIndex(int arg) {
- if (m_itemIndex != arg) {
- m_itemIndex = arg;
- emit itemIndexChanged(arg);
- }
- }
-
-signals:
- void minimumWidthChanged(qreal arg);
- void maximumWidthChanged(qreal arg);
- void minimumHeightChanged(qreal arg);
- void maximumHeightChanged(qreal arg);
- void expandingChanged(bool arg);
- void percentageWidthSize(qreal arg);
- void itemIndexChanged(int arg);
-
-private:
- qreal m_minimumWidth;
- qreal m_maximumWidth;
- qreal m_minimumHeight;
- qreal m_maximumHeight;
- qreal m_percentageSize;
- int m_itemIndex;
- bool m_expanding;
-
- friend class QtSplitterBase;
-};
-
-
-class QtSplitterBase : public QQuickItem
-{
- Q_OBJECT
-public:
- explicit QtSplitterBase(QQuickItem *parent = 0);
- ~QtSplitterBase() {}
-
- static QtSplitterAttached *qmlAttachedProperties(QObject *object);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QtSplitterBase, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif // QTSPLITTERBASE_P_H
diff --git a/src/qtdesktop/qwheelarea.cpp b/src/qtdesktop/qwheelarea.cpp
deleted file mode 100644
index 251353cb..00000000
--- a/src/qtdesktop/qwheelarea.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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 "qwheelarea_p.h"
-
-/*!
- \qmltype WheelArea
- \instantiates QWheelArea
- \inqmlmodule QtDesktop 1.0
- \brief WheelArea is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-QWheelArea::QWheelArea(QQuickItem *parent)
- : QQuickItem(parent),
- m_horizontalMinimumValue(0),
- m_horizontalMaximumValue(0),
- m_verticalMinimumValue(0),
- m_verticalMaximumValue(0),
- m_horizontalValue(0),
- m_verticalValue(0),
- m_verticalDelta(0),
- m_horizontalDelta(0),
- m_scrollSpeed(1.0)
-{
-
-}
-
-QWheelArea::~QWheelArea()
-{
-
-}
-
-void QWheelArea::wheelEvent(QWheelEvent *we)
-{
- if (we->orientation() == Qt::Vertical) {
- setVerticalDelta(we->delta());
- } else {
- setHorizontalDelta(we->delta());
- }
- we->accept();
-}
-
-void QWheelArea::setHorizontalMinimumValue(qreal value)
-{
- m_horizontalMinimumValue = value;
-}
-
-qreal QWheelArea::horizontalMinimumValue() const
-{
- return m_horizontalMinimumValue;
-}
-
-void QWheelArea::setHorizontalMaximumValue(qreal value)
-{
- m_horizontalMaximumValue = value;
-}
-
-qreal QWheelArea::horizontalMaximumValue() const
-{
- return m_horizontalMaximumValue;
-}
-
-void QWheelArea::setVerticalMinimumValue(qreal value)
-{
- m_verticalMinimumValue = value;
-}
-
-qreal QWheelArea::verticalMinimumValue() const
-{
- return m_verticalMinimumValue;
-}
-
-void QWheelArea::setVerticalMaximumValue(qreal value)
-{
- m_verticalMaximumValue = value;
-}
-
-qreal QWheelArea::verticalMaximumValue() const
-{
- return m_verticalMaximumValue;
-}
-
-void QWheelArea::setHorizontalValue(qreal value)
-{
- value = qBound<qreal>(m_horizontalMinimumValue, value, m_horizontalMaximumValue);
-
- if (value != m_horizontalValue) {
- m_horizontalValue = value;
- emit horizontalValueChanged();
- }
-}
-
-qreal QWheelArea::horizontalValue() const
-{
- return m_horizontalValue;
-}
-
-void QWheelArea::setVerticalValue(qreal value)
-{
- value = qBound<qreal>(m_verticalMinimumValue, value, m_verticalMaximumValue);
-
- if (value != m_verticalValue) {
- m_verticalValue = value;
- emit verticalValueChanged();
- }
-}
-
-qreal QWheelArea::verticalValue() const
-{
- return m_verticalValue;
-}
-
-void QWheelArea::setVerticalDelta(qreal value)
-{
- m_verticalDelta = m_scrollSpeed * value / 15;
- setVerticalValue(m_verticalValue - m_verticalDelta);
-
- emit verticalWheelMoved();
-}
-
-qreal QWheelArea::verticalDelta() const
-{
- return m_verticalDelta;
-}
-
-void QWheelArea::setHorizontalDelta(qreal value)
-{
- m_horizontalDelta = value / 15;
- setHorizontalValue(m_horizontalValue - m_horizontalDelta);
-
- emit horizontalWheelMoved();
-}
-
-qreal QWheelArea::horizontalDelta() const
-{
- return m_horizontalDelta;
-}
-
-void QWheelArea::setScrollSpeed(qreal value)
-{
- if (value != m_scrollSpeed) {
- m_scrollSpeed = value;
- emit scrollSpeedChanged();
- }
-}
-
-qreal QWheelArea::scrollSpeed() const
-{
- return m_scrollSpeed;
-}
-
-QT_END_NAMESPACE
diff --git a/src/qtdesktop/styleplugin.pri b/src/qtdesktop/styleplugin.pri
deleted file mode 100644
index 5493d66a..00000000
--- a/src/qtdesktop/styleplugin.pri
+++ /dev/null
@@ -1,40 +0,0 @@
-HEADERS += \
- $$PWD/qdesktopitem_p.h \
- $$PWD/qfiledialogitem_p.h \
- $$PWD/qquickcomponentsprivate_p.h \
- $$PWD/qquicklayout_p.h \
- $$PWD/qquicklayoutengine_p.h \
- $$PWD/qquicklinearlayout_p.h \
- $$PWD/qrangemodel_p.h \
- $$PWD/qrangemodel_p_p.h \
- $$PWD/qstyleitem_p.h \
- $$PWD/qstyleplugin_p.h \
- $$PWD/qtaction_p.h \
- $$PWD/qtexclusivegroup_p.h \
- $$PWD/qtmenu_p.h \
- $$PWD/qtmenubar_p.h \
- $$PWD/qtmenuitem_p.h \
- $$PWD/qtsplitterbase_p.h \
- $$PWD/qwheelarea_p.h \
- $$PWD/qpagestatus.h
-
-SOURCES += \
- $$PWD/qdesktopitem.cpp \
- $$PWD/qfiledialogitem.cpp \
- $$PWD/qquickcomponentsprivate.cpp \
- $$PWD/qquicklayout.cpp \
- $$PWD/qquicklayoutengine.cpp \
- $$PWD/qquicklinearlayout.cpp \
- $$PWD/qrangemodel.cpp \
- $$PWD/qstyleitem.cpp \
- $$PWD/qstyleplugin.cpp \
- $$PWD/qtaction.cpp \
- $$PWD/qtexclusivegroup.cpp \
- $$PWD/qtmenu.cpp \
- $$PWD/qtmenubar.cpp \
- $$PWD/qtmenuitem.cpp \
- $$PWD/qtsplitterbase.cpp \
- $$PWD/qwheelarea.cpp
-
-OTHER_FILES += \
- $$PWD/styleplugin.json
diff --git a/src/src.pro b/src/src.pro
index 3b0d512e..7bd5b33e 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += qtdesktop styles
+SUBDIRS += controls styles experimental private
+
+SUBDIRS += layouts
diff --git a/src/styles/ButtonStyle.qml b/src/styles/ButtonStyle.qml
index a51e9f66..6cd165e6 100644
--- a/src/styles/ButtonStyle.qml
+++ b/src/styles/ButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,46 +37,68 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype ButtonStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ButtonStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for Button
*/
-Item {
- implicitWidth: backgroundLoader.implicitWidth
- implicitHeight: backgroundLoader.implicitHeight
-
+Style {
+ id: buttonstyle
+ property font font
property color backgroundColor: "lightGray"
property color foregroundColor: "black"
- property alias font: textitem.font
+
+ property Component label: Item {
+ Text {
+ id: textitem
+ anchors.centerIn: parent
+ renderType: Text.NativeRendering
+ text: control.text
+ color: buttonstyle.foregroundColor
+ font: buttonstyle.font
+ }
+ }
property Component background: Rectangle {
- implicitWidth: 100
+ implicitWidth: 80
implicitHeight: 21
gradient: Gradient {
- GradientStop {color: control.pressed ? Qt.lighter(backgroundColor, 1.1) : Qt.lighter(backgroundColor, 1.8) ; position: 0}
- GradientStop {color: control.pressed ? Qt.lighter(backgroundColor, 1.1) : backgroundColor ; position: 1.4}
+ GradientStop {color: control.pressed ? Qt.lighter(buttonstyle.backgroundColor, 1.1) :
+ Qt.lighter(buttonstyle.backgroundColor, 1.8) ; position: 0}
+ GradientStop {color: control.pressed ? Qt.lighter(buttonstyle.backgroundColor, 1.1) :
+ buttonstyle.backgroundColor ; position: 1.4}
}
- border.color: Qt.darker(backgroundColor, 1.4)
+ border.color: Qt.darker(buttonstyle.backgroundColor, 1.4)
radius: 3
antialiasing: true
}
- Loader {
- id: backgroundLoader
- sourceComponent: background
+ property Component panel: Item {
+ property Item controlref: control
anchors.fill: parent
- }
- Text {
- id: textitem
- anchors.centerIn: backgroundLoader
- renderType: Text.NativeRendering
- text: control.text
- color: foregroundColor
+ implicitWidth: backgroundLoader.implicitWidth
+ implicitHeight: backgroundLoader.implicitHeight
+
+ Loader {
+ id: backgroundLoader
+ anchors.fill: parent
+ sourceComponent: background
+ property Item control: controlref
+ property Item label: labelLoader.item
+ }
+
+ Loader {
+ id: labelLoader
+ sourceComponent: label
+ anchors.fill: parent
+ property Item control: controlref
+ }
}
}
+
diff --git a/src/styles/CheckBoxStyle.qml b/src/styles/CheckBoxStyle.qml
index 17966c8f..77b6c60d 100644
--- a/src/styles/CheckBoxStyle.qml
+++ b/src/styles/CheckBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,55 +37,67 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype CheckBoxStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief CheckBoxStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for CheckBox
*/
+Style {
-Item {
- implicitWidth: 100
- implicitHeight: 20
+ property int labelSpacing: 6
property Component indicator: Rectangle {
- height:20
+ height: 20
width: 20
antialiasing: true
- gradient: Gradient{
+ gradient: Gradient {
GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0}
GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1}
}
- radius:4
+ radius: 2
border.color: "#aaa"
Rectangle {
- height:20
+ height: 20
width: 20
antialiasing: true
visible: control.checked
- gradient: Gradient{
- GradientStop{color: "darkgray" ; position: 1}
- GradientStop{color: "lightgray" ; position: 0}
- }
- radius:2
+ color: "#444"
+ radius: 1
anchors.margins: 5
anchors.fill: parent
- border.color: "gray"
+ border.color: "black"
}
}
- Loader {
- id: indicatorLoader
- sourceComponent: indicator
- }
-
- Text {
- anchors.left: parent.left
- anchors.leftMargin: 24
- anchors.verticalCenter: parent.verticalCenter
+ property Component label: Text {
text: control.text
renderType: Text.NativeRendering
}
+
+ property Component panel: Item {
+ implicitWidth: row.width
+ implicitHeight: row.height
+ property var _cref: control
+
+ Row {
+ id: row
+ spacing: labelSpacing
+ Loader {
+ id: indicatorLoader
+ sourceComponent: indicator
+ anchors.verticalCenter: parent.verticalCenter
+ property CheckBox control: _cref
+ }
+ Loader {
+ id: labelLoader
+ sourceComponent: label
+ anchors.verticalCenter: parent.verticalCenter
+ property CheckBox control: _cref
+ }
+ }
+ }
}
diff --git a/src/styles/ComboBoxStyle.qml b/src/styles/ComboBoxStyle.qml
index 2c4239a6..7a2da960 100644
--- a/src/styles/ComboBoxStyle.qml
+++ b/src/styles/ComboBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,30 +37,34 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
/*!
\qmltype ComboBoxStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ComboBoxStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-Rectangle {
- id: styleitem
- implicitWidth: 200
- implicitHeight: 20
+Style {
+ property Component panel: Rectangle {
+ id: styleitem
+ implicitWidth: 200
+ implicitHeight: 20
- gradient: Gradient{
- GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0}
- GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1}
- }
+ gradient: Gradient{
+ GradientStop{color: control.__pressed ? "lightgray" : "white" ; position: 0}
+ GradientStop{color: control.__pressed ? "lightgray" : "lightgray" ; position: 1}
+ }
- radius:4
- border.color: "#aaa"
+ radius:4
+ border.color: "#aaa"
- Text {
- anchors.centerIn: parent
- text: control.selectedText
+ Text {
+ anchors.centerIn: parent
+ text: control.currentText
+ }
}
+
+ property Component popupStyle: MenuStyle { }
}
diff --git a/src/styles/Desktop/ButtonStyle.qml b/src/styles/Desktop/ButtonStyle.qml
index cc57c447..fb1e5204 100644
--- a/src/styles/Desktop/ButtonStyle.qml
+++ b/src/styles/Desktop/ButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,26 +37,21 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-Item {
- width: implicitWidth
- height: implicitHeight
- implicitWidth: styleitem.implicitWidth
- implicitHeight: styleitem.implicitHeight
- StyleItem {
+Style {
+ property Component panel: StyleItem {
id: styleitem
- width: parent.width
- anchors.verticalCenter: parent.verticalCenter
elementType: "button"
sunken: control.pressed || control.checked
raised: !(control.pressed || control.checked)
- hover: control.containsMouse
+ hover: control.__containsMouse
text: control.iconSource === "" ? "" : control.text
- hasFocus: control.focus
- hint: control.styleHints
+ hasFocus: control.activeFocus
+ hints: control.styleHints
// If no icon, let the style do the drawing
- activeControl: defaultbutton ? "default" : "f"
+ activeControl: control.isDefault ? "default" : "f"
}
}
diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml
index 93c44a55..dcffb9c1 100644
--- a/src/styles/Desktop/CheckBoxStyle.qml
+++ b/src/styles/Desktop/CheckBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,29 +37,57 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- elementType: "checkbox"
- sunken: pressed
- on: checked || pressed
- hover: containsMouse
- enabled: control.enabled
- hasFocus: control.activeFocus
- hint: control.styleHints
- contentHeight: textitem.implicitHeight
- contentWidth: textitem.implicitWidth + indicatorWidth
- Text {
- id: textitem
- text: control.text
- anchors.left: parent.left
- anchors.leftMargin: parent.indicatorWidth
- anchors.verticalCenter: parent.verticalCenter
- anchors.right: parent.right
- elide: Text.ElideRight
- color: syspal.windowText
- SystemPalette { id: syspal }
+Style {
+ property Component panel: Item {
+ anchors.fill: parent
+
+ implicitWidth: styleitem.implicitWidth
+ implicitHeight: styleitem.implicitHeight
+
+ StyleItem {
+ id: styleitem
+ elementType: "checkbox"
+ sunken: control.pressed
+ on: control.checked || control.pressed
+ hover: control.__containsMouse
+ enabled: control.enabled
+ hasFocus: control.activeFocus
+ hints: {
+ if (control.checkedState === Qt.PartiallyChecked)
+ control.styleHints.push("partiallyChecked");
+ else {
+ var index = control.styleHints.indexOf("partiallyChecked");
+ if (index !== -1)
+ control.styleHints.splice(index, 1);
+ }
+ control.styleHints;
+ }
+ contentHeight: textitem.implicitHeight
+ contentWidth: textitem.implicitWidth + indicatorWidth
+ property int indicatorWidth: pixelMetric("indicatorwidth") + (macStyle ? 2 : 4)
+ property bool macStyle: (style === "mac")
+
+ Text {
+ id: textitem
+ text: control.text
+ anchors.left: parent.left
+ anchors.leftMargin: parent.indicatorWidth
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: parent.macStyle ? 1 : 0
+ anchors.right: parent.right
+ renderType: Text.NativeRendering
+ elide: Text.ElideRight
+ enabled: control.enabled
+ color: syspal.windowText
+ SystemPalette {
+ id: syspal
+ colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
+ }
+ }
}
- property int indicatorWidth: pixelMetric("indicatorwidth") + 2
}
diff --git a/src/styles/Desktop/ComboBoxStyle.qml b/src/styles/Desktop/ComboBoxStyle.qml
index b719fa1b..169ca795 100644
--- a/src/styles/Desktop/ComboBoxStyle.qml
+++ b/src/styles/Desktop/ComboBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,27 +37,65 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-
-Item {
- width: implicitWidth
- height: implicitHeight
- implicitWidth: styleitem.implicitWidth
- implicitHeight: styleitem.implicitHeight
- StyleItem {
- id: styleitem
- width: parent.width
- anchors.verticalCenter: parent.verticalCenter
- elementType: "combobox"
- sunken: comboBox.pressed
- raised: !sunken
- hover: comboBox.containsMouse
- enabled: comboBox.enabled
- text: comboBox.selectedText
- hasFocus: comboBox.focus
- contentHeight: 18
- contentWidth: 80
- Component.onCompleted: popup.center = styleHint("comboboxpopup");
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
+
+Style {
+ property Component panel: Item {
+ width: implicitWidth
+ height: implicitHeight
+ implicitWidth: styleitem.implicitWidth
+ implicitHeight: styleitem.implicitHeight
+
+ property int popup: styleitem.styleHint("comboboxpopup");
+
+ StyleItem {
+ id: styleitem
+ width: parent.width
+ anchors.verticalCenter: parent.verticalCenter
+ elementType: "combobox"
+ sunken: control.__pressed
+ raised: !sunken
+ hover: control.__containsMouse
+ enabled: control.enabled
+ text: control.currentText
+ hasFocus: control.activeFocus
+ contentHeight: 18
+ contentWidth: 80
+ }
+ }
+
+ property Component popupStyle: MenuStyle {
+ __menuItemType: "comboboxitem"
+ }
+
+ property Component dropDownStyle: Style {
+ property Component frame: StyleItem {
+ elementType: "frame"
+
+ width: (parent ? parent.contentWidth : 0)
+ height: (parent ? parent.contentHeight : 0) + 2 * pixelMetric("defaultframewidth")
+ }
+
+ property Component menuItem: StyleItem {
+ elementType: "itemrow"
+ selected: parent ? parent.selected : false
+
+ x: pixelMetric("defaultframewidth")
+ y: pixelMetric("defaultframewidth")
+
+ implicitWidth: textItem.contentWidth
+ implicitHeight: textItem.contentHeight
+
+ StyleItem {
+ id: textItem
+ elementType: "item"
+ contentWidth: textWidth(text)
+ contentHeight: textHeight(text)
+ text: parent && parent.parent ? parent.parent.text : ""
+ selected: parent ? parent.selected : false
+ }
+ }
}
}
diff --git a/src/styles/Desktop/FrameStyle.qml b/src/styles/Desktop/FrameStyle.qml
deleted file mode 100644
index 1d2e1543..00000000
--- a/src/styles/Desktop/FrameStyle.qml
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-StyleItem {
- id: style
- elementType: "frame"
- sunken: frame.sunken
- raised: frame.raised
- Component.onCompleted: content.frameWidth = pixelMetric("defaultframewidth");
-}
diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml
index c24d70a0..dc723f61 100644
--- a/src/styles/Desktop/GroupBoxStyle.qml
+++ b/src/styles/Desktop/GroupBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,16 +37,24 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import QtQuick.Controls.Styles 1.0
-StyleItem {
- id: styleitem
- elementType: "groupbox"
- text: control.title
- on: control.checked
- hasFocus: control.activeFocus
- activeControl: checkable ? "checkbox" : ""
- sunken: !flat
- contentHeight: (title.length > 0 || checkable) ? 24 : 4
+
+Style {
+ property int margin: 8
+
+ property Component panel: StyleItem {
+ id: styleitem
+ elementType: "groupbox"
+ text: control.title
+ on: control.checked
+ hasFocus: control.activeFocus
+ activeControl: checkable ? "checkbox" : ""
+ properties: { "checkable" : checkable , "sunken" : !flat}
+ contentWidth: control.contentWidth + 2 * margin
+ contentHeight: control.contentHeight + 2 * margin
+ }
}
diff --git a/src/styles/Desktop/MenuBarStyle.qml b/src/styles/Desktop/MenuBarStyle.qml
new file mode 100644
index 00000000..d0a6e16d
--- /dev/null
+++ b/src/styles/Desktop/MenuBarStyle.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
+
+
+Style {
+ property Component frame: StyleItem {
+ elementType: "menubar"
+ contentWidth: control.__contentItem.width
+ contentHeight: parent ? parent.contentHeight : 0
+ width: implicitWidth + 2 * (pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth"))
+ height: implicitHeight + 2 * (pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth"))
+ + pixelMetric("spacebelowmenubar")
+ }
+
+ property Component menuItem: StyleItem {
+ elementType: "menubaritem"
+ x: pixelMetric("menubarhmargin") + pixelMetric("menubarpanelwidth")
+ y: pixelMetric("menubarvmargin") + pixelMetric("menubarpanelwidth")
+
+ text: menuItem.title
+ contentWidth: textWidth(text)
+ contentHeight: textHeight(text)
+ width: implicitWidth + pixelMetric("menubaritemspacing")
+
+ enabled: menuItem.enabled
+ selected: parent.selected || sunken
+ sunken: parent.sunken
+ }
+}
diff --git a/src/styles/Desktop/MenuStyle.qml b/src/styles/Desktop/MenuStyle.qml
new file mode 100644
index 00000000..7bfee4e0
--- /dev/null
+++ b/src/styles/Desktop/MenuStyle.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
+
+Style {
+ id: styleRoot
+
+ property string __menuItemType: "menuitem"
+
+ property Component frame: StyleItem {
+ elementType: "menu"
+
+ contentWidth: parent ? parent.contentWidth : 0
+ contentHeight: parent ? parent.contentHeight : 0
+ width: implicitWidth + 2 * (pixelMetric("menuhmargin") + pixelMetric("menupanelwidth"))
+ height: implicitHeight + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth"))
+
+ property int subMenuOverlap: pixelMetric("submenuoverlap")
+
+ SystemPalette { id: syspal }
+
+ Rectangle {
+ visible: anchors.margins > 0
+ anchors {
+ fill: parent
+ margins: pixelMetric("menupanelwidth")
+ }
+ color: syspal.window
+ }
+ }
+
+ property Component menuItem: StyleItem {
+ elementType: __menuItemType
+ x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")
+ y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
+
+ text: !!parent && parent.text
+ property string textAndShorcut: text + (properties.shortcut ? "\t" + properties.shortcut : "")
+ contentWidth: textWidth(textAndShorcut)
+ contentHeight: textHeight(textAndShorcut)
+
+ enabled: !!parent && parent.enabled
+ selected: !!parent && parent.selected
+ on: !!menuItem && !!menuItem["checkable"] && menuItem.checked
+
+ properties: {
+ "checkable": !!menuItem && !!menuItem["checkable"],
+ "exclusive": !!menuItem && !!menuItem["exclusiveGroup"],
+ "shortcut": !!menuItem && menuItem["shortcut"] || "",
+ "isSubmenu": isSubmenu,
+ "icon": !!menuItem && menuItem.__icon
+ }
+ }
+}
diff --git a/src/styles/Desktop/ProgressBarStyle.qml b/src/styles/Desktop/ProgressBarStyle.qml
index 42d72dcc..7d7cbc54 100644
--- a/src/styles/Desktop/ProgressBarStyle.qml
+++ b/src/styles/Desktop/ProgressBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,21 +37,25 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- anchors.fill: parent
- elementType: "progressbar"
- // XXX: since desktop uses int instead of real, the progressbar
- // range [0..1] must be stretched to a good precision
- property int factor : 1000
- value: indeterminate ? 0 : progressbar.value * factor // does indeterminate value need to be 1 on windows?
- minimum: indeterminate ? 0 : progressbar.minimumValue * factor
- maximum: indeterminate ? 0 : progressbar.maximumValue * factor
- enabled: progressbar.enabled
- horizontal: progressbar.orientation == Qt.Horizontal
- hint: progressbar.styleHints
- contentWidth: 23
- contentHeight: 23
+Style {
+ property Component panel: StyleItem {
+ anchors.fill: parent
+ elementType: "progressbar"
+ // XXX: since desktop uses int instead of real, the progressbar
+ // range [0..1] must be stretched to a good precision
+ property int factor : 1000
+ property int decimals: 3
+ value: indeterminate ? 0 : control.value.toFixed(decimals) * factor // does indeterminate value need to be 1 on windows?
+ minimum: indeterminate ? 0 : control.minimumValue.toFixed(decimals) * factor
+ maximum: indeterminate ? 0 : control.maximumValue.toFixed(decimals) * factor
+ enabled: control.enabled
+ horizontal: control.orientation == Qt.Horizontal
+ hints: control.styleHints
+ contentWidth: 23
+ contentHeight: 23
+ }
}
diff --git a/src/styles/Desktop/RadioButtonStyle.qml b/src/styles/Desktop/RadioButtonStyle.qml
index 4be70853..9564b136 100644
--- a/src/styles/Desktop/RadioButtonStyle.qml
+++ b/src/styles/Desktop/RadioButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,30 +37,50 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- elementType: "radiobutton"
- sunken: pressed
- on: checked || pressed
- hover: containsMouse
- enabled: radiobutton.enabled
- hasFocus: radiobutton.activeFocus
- hint: radiobutton.styleHints
- contentHeight: textitem.implicitHeight
- contentWidth: textitem.implicitWidth + indicatorWidth
- property int indicatorWidth: pixelMetric("indicatorwidth") + 2
+Style {
+ property Component panel: Item {
+ anchors.fill: parent
- Text {
- id: textitem
- text: radiobutton.text
- anchors.left: parent.left
- anchors.leftMargin: parent.indicatorWidth
- anchors.verticalCenter: parent.verticalCenter
- anchors.right: parent.right
- elide: Text.ElideRight
- color: syspal.windowText
- SystemPalette { id: syspal }
+ implicitWidth: styleitem.implicitWidth
+ implicitHeight: styleitem.implicitHeight
+
+ StyleItem {
+ id: styleitem
+ elementType: "radiobutton"
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: macStyle ? -1 : 0
+ sunken: control.pressed
+ on: control.checked || control.pressed
+ hover: control.__containsMouse
+ enabled: control.enabled
+ hasFocus: control.activeFocus
+ hints: control.styleHints
+ contentHeight: textitem.implicitHeight
+ contentWidth: textitem.implicitWidth + indicatorWidth
+ property int indicatorWidth: pixelMetric("indicatorwidth") + (macStyle ? 2 : 4)
+ property bool macStyle: (style === "mac")
+
+ Text {
+ id: textitem
+ text: control.text
+ anchors.left: parent.left
+ anchors.leftMargin: parent.indicatorWidth
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.verticalCenterOffset: parent.macStyle ? 2 : 0
+ anchors.right: parent.right
+ renderType: Text.NativeRendering
+ elide: Text.ElideRight
+ enabled: control.enabled
+ color: syspal.windowText
+ SystemPalette {
+ id: syspal
+ colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
+ }
+ }
}
}
diff --git a/src/styles/Desktop/ScrollAreaStyle.qml b/src/styles/Desktop/ScrollAreaStyle.qml
deleted file mode 100644
index c1c1b8c5..00000000
--- a/src/styles/Desktop/ScrollAreaStyle.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-StyleItem {
- id: styleitem
- elementType: "frame"
- sunken: true
- visible: frame
- anchors.fill: parent
- anchors.rightMargin: frame ? (frameAroundContents ? (verticalScrollBar.visible ? verticalScrollBar.width + 2 * frameMargins : 0) : 0) : 0
- anchors.bottomMargin: frame ? (frameAroundContents ? (horizontalScrollBar.visible ? horizontalScrollBar.height + 2 * frameMargins : 0) : 0) : 0
- anchors.topMargin: frame ? (frameAroundContents ? 0 : 0) : 0
- property int frameWidth
- property int scrollbarspacing: pixelMetric("scrollbarspacing");
- property int frameMargins : frame ? scrollbarspacing : 0
- Component.onCompleted: frameWidth = pixelMetric("defaultframewidth");
-}
diff --git a/src/styles/Desktop/ScrollBarStyle.qml b/src/styles/Desktop/ScrollBarStyle.qml
index 491c3fe7..dc175f9a 100644
--- a/src/styles/Desktop/ScrollBarStyle.qml
+++ b/src/styles/Desktop/ScrollBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,9 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
StyleItem {
id: styleitem
@@ -47,7 +48,7 @@ StyleItem {
elementType: "scrollbar"
hover: activeControl != "none"
activeControl: "none"
- sunken: control.upPressed | control.downPressed
+ sunken: control.upPressed | control.downPressed | control.handlePressed
minimum: control.minimumValue
maximum: control.maximumValue
value: slider.value
diff --git a/src/styles/Desktop/SliderStyle.qml b/src/styles/Desktop/SliderStyle.qml
index da00df15..823e7746 100644
--- a/src/styles/Desktop/SliderStyle.qml
+++ b/src/styles/Desktop/SliderStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,23 +37,26 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- elementType: "slider"
- sunken: pressed
+Style {
+ property Component panel: StyleItem {
+ elementType: "slider"
+ sunken: control.pressed
+ implicitWidth: 200
+ contentHeight: horizontal ? 20 : 200
+ contentWidth: horizontal ? 200 : 20
- contentHeight: horizontal ? 20 : 200
- contentWidth: horizontal ? 200 : 20
-
- maximum: control.maximumValue*100
- minimum: control.minimumValue*100
- step: control.stepSize*100
- value: control.value*100
- horizontal: control.orientation === Qt.Horizontal
- enabled: control.enabled
- hasFocus: control.focus
- hint: control.styleHints
- activeControl: tickmarksEnabled ? tickPosition.toLowerCase() : ""
+ maximum: control.maximumValue*100
+ minimum: control.minimumValue*100
+ step: control.stepSize*100
+ value: control.value*100
+ horizontal: control.orientation === Qt.Horizontal
+ enabled: control.enabled
+ hasFocus: control.activeFocus
+ hints: control.styleHints
+ activeControl: control.tickmarksEnabled ? "ticks" : ""
+ }
}
diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml
index ea4cb6f3..3405213b 100644
--- a/src/styles/Desktop/SpinBoxStyle.qml
+++ b/src/styles/Desktop/SpinBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,89 +37,84 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-Item {
- id: style
+Style {
+ property Component panel: Item {
+ id: style
- property rect upRect
- property rect downRect
+ property rect upRect
+ property rect downRect
- property int topMargin: edit.anchors.topMargin
- property int leftMargin: 2 + edit.anchors.leftMargin
- property int rightMargin: 2 + edit.anchors.rightMargin
- property int bottomMargin: edit.anchors.bottomMargin
- property int horizontalTextAlignment: Qt.AlignLeft
- property int verticalTextAlignment: Qt.AlignVCenter
+ property int topMargin: edit.anchors.topMargin
+ property int leftMargin: 2 + edit.anchors.leftMargin
+ property int rightMargin: 2 + edit.anchors.rightMargin
+ property int bottomMargin: edit.anchors.bottomMargin
+ property int horizontalTextAlignment: Qt.AlignLeft
+ property int verticalTextAlignment: Qt.AlignVCenter
- property color foregroundColor: syspal.text
- property color backgroundColor: syspal.base
- property color selectionColor: syspal.highlight
- property color selectedTextColor: syspal.highlightedText
+ property color foregroundColor: syspal.text
+ property color backgroundColor: syspal.base
+ property color selectionColor: syspal.highlight
+ property color selectedTextColor: syspal.highlightedText
- SystemPalette {
- id: syspal
- colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled
- }
+ SystemPalette {
+ id: syspal
+ colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
- width: 100
- height: styleitem.implicitHeight
+ width: 100
+ height: styleitem.implicitHeight
- implicitWidth: styleitem.implicitWidth
- implicitHeight: styleitem.implicitHeight
+ implicitWidth: styleitem.implicitWidth
+ implicitHeight: styleitem.implicitHeight
- Item {
- id: edit
- anchors.fill: parent
- Rectangle {
- color: "white"
+ Item {
+ id: edit
anchors.fill: parent
- anchors.margins: -1
+ Rectangle {
+ color: "white"
+ anchors.fill: parent
+ anchors.margins: -1
+ }
+ FocusFrame {
+ focusMargin:-6
+ visible: spinbox.activeFocus && styleitem.styleHint("focuswidget")
+ }
}
- }
- Item {
- id: focusFrame
- anchors.fill: edit
- anchors.margins: -6
- visible: frameitem.styleHint("focuswidget")
- StyleItem {
- id: frameitem
- anchors.fill: parent
- visible: spinbox.activeFocus
- elementType: "focusframe"
+ function updateRect() {
+ style.upRect = styleitem.subControlRect("up");
+ style.downRect = styleitem.subControlRect("down");
+ var inputRect = styleitem.subControlRect("edit");
+ edit.anchors.topMargin = inputRect.y
+ edit.anchors.leftMargin = inputRect.x
+ edit.anchors.rightMargin = style.width - inputRect.width - edit.anchors.leftMargin
+ edit.anchors.bottomMargin = style.height - inputRect.height - edit.anchors.topMargin
}
- }
- function updateRect() {
- style.upRect = styleitem.subControlRect("up");
- style.downRect = styleitem.subControlRect("down");
- var inputRect = styleitem.subControlRect("edit");
- edit.anchors.topMargin = inputRect.y
- edit.anchors.leftMargin = inputRect.x
- edit.anchors.rightMargin = style.width - inputRect.width - edit.anchors.leftMargin
- edit.anchors.bottomMargin = style.height - inputRect.height - edit.anchors.topMargin
- }
-
- Component.onCompleted: updateRect()
- onWidthChanged: updateRect()
- onHeightChanged: updateRect()
+ Component.onCompleted: updateRect()
+ onWidthChanged: updateRect()
+ onHeightChanged: updateRect()
- StyleItem {
- id: styleitem
- elementType: "spinbox"
- anchors.fill: parent
- sunken: (downEnabled && downPressed) | (upEnabled && upPressed)
- hover: containsMouse
- hint: control.styleHints
- hasFocus: control.focus
- enabled: control.enabled
- value: (upPressed ? 1 : 0) |
- (downPressed == 1 ? 1<<1 : 0) |
- (upEnabled ? (1<<2) : 0) |
- (downEnabled == 1 ? (1<<3) : 0)
- contentWidth: 200
- contentHeight: 25
+ StyleItem {
+ id: styleitem
+ elementType: "spinbox"
+ anchors.fill: parent
+ sunken: (control.__downEnabled && control.__downPressed) || (control.__upEnabled && control.__upPressed)
+ hover: __containsMouse
+ hints: control.styleHints
+ hasFocus: control.activeFocus
+ enabled: control.enabled
+ value: (control.__upPressed ? 1 : 0) |
+ (control.__downPressed ? 1<<1 : 0) |
+ (control.__upEnabled ? (1<<2) : 0) |
+ (control.__downEnabled ? (1<<3) : 0)
+ contentWidth: control.__contentWidth
+ contentHeight: control.__contentHeight
+ }
}
}
diff --git a/src/styles/Desktop/TabFrameStyle.qml b/src/styles/Desktop/TabViewStyle.qml
index e681d0cb..e9249b02 100644
--- a/src/styles/Desktop/TabFrameStyle.qml
+++ b/src/styles/Desktop/TabViewStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,26 +37,21 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import QtQuick.Controls.Styles 1.0
-QtObject {
+Style {
id: root
property int leftMargin: 0
property int rightMargin: 0
-
+ property StyleItem __barstyle: StyleItem { elementType: "tabbar" ; visible: false }
property string tabBarAlignment: __barstyle.styleHint("tabbaralignment");
-
- property var __framestyle: StyleItem { elementType: "tabframe" ; visible: false }
- property var __barstyle: StyleItem { elementType: "tabbar" ; visible: false }
-
- property rect contentRect
- property int margins: control.frame ? stack.frameWidth : 0
property int tabOverlap: __barstyle.pixelMetric("taboverlap");
property int tabBaseOverlap: __barstyle.pixelMetric("tabbaseoverlap");
- property int tabHSpace: __barstyle.pixelMetric("tabhspace");
- property int tabVSpace: __barstyle.pixelMetric("tabvspace");
+ property string tabPosition: control.tabPosition == Qt.TopEdge ? "Top" : "Bottom"
property Component frame: StyleItem {
id: styleitem
@@ -64,9 +59,9 @@ QtObject {
anchors.topMargin: 1//stack.baseOverlap
z: style == "oxygen" ? 1 : 0
elementType: "tabframe"
- info: position
- value: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).x : 0
- minimum: tabbarItem && tabsVisible && tabbarItem.tab(current) ? tabbarItem.tab(current).width : 0
+ hints: tabPosition
+ value: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).x : 0
+ minimum: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).width : 0
maximum: tabbarItem && tabsVisible ? tabbarItem.width : width
Component.onCompleted: {
stack.frameWidth = styleitem.pixelMetric("defaultframewidth");
@@ -76,33 +71,32 @@ QtObject {
}
property Component tab: Item {
+ id: item
property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle"
property string selectedpos: nextSelected ? "next" : previousSelected ? "previous" : ""
- implicitWidth: Math.max(50, textitem.width) + tabHSpace + 2
+ property int tabHSpace: __barstyle.pixelMetric("tabhspace");
+ property int tabVSpace: __barstyle.pixelMetric("tabvspace");
+ implicitWidth: Math.max(50, styleitem.textWidth(title)) + tabHSpace + 2
implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0)
StyleItem {
id: styleitem
elementType: "tab"
+ paintMargins: style === "mac" ? 0 : 2
anchors.fill: parent
- anchors.leftMargin: (selected && style == "mac") ? -1 : 0
-
- hint: [control.position, tabpos, selectedpos]
+ anchors.topMargin: style === "mac" ? 2 : 0
+ anchors.rightMargin: -paintMargins
+ anchors.bottomMargin: -1
+ anchors.leftMargin: -paintMargins + (style === "mac" && selected ? -1 : 0)
+ properties: { "hasFrame" : true }
+ hints: [tabPosition, tabpos, selectedpos]
selected: tab.selected
- info: control.position
- text: title
+ text: elidedText(title, tabbarItem.elide, width - item.tabHSpace)
hover: tab.hover
- hasFocus: tab.focus && selected
- anchors.margins: paintMargins
-
- Text {
- id: textitem
- visible: false
- text: styleitem.text
- }
+ hasFocus: tabbarItem.activeFocus && selected
}
}
}
diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml
index 1db3e52c..5024ca86 100644
--- a/src/styles/Desktop/TextFieldStyle.qml
+++ b/src/styles/Desktop/TextFieldStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,55 +37,47 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- anchors.fill: parent
- elementType: "edit"
- sunken: true
- hasFocus: textfield.activeFocus
- hover: containsMouse
+Style {
+ property Component panel: StyleItem {
+ id: textfieldstyle
+ elementType: "edit"
+ anchors.fill: parent
- SystemPalette {
- id: syspal
- colorGroup: control.enabled ?
- SystemPalette.Active :
- SystemPalette.Disabled
- }
+ sunken: true
+ hasFocus: control.activeFocus
+ hover: __containsMouse
+ hints: control.styleHints
- contentWidth: 200
- contentHeight: 18
+ SystemPalette {
+ id: syspal
+ colorGroup: control.enabled ?
+ SystemPalette.Active :
+ SystemPalette.Disabled
+ }
- property bool rounded: hint.indexOf("rounded")
- property int topMargin: 4
- property int leftMargin: rounded > -1 ? 8 : 4
- property int rightMargin: 4
- property int bottomMargin: 4
+ property color foregroundColor: syspal.text
+ property color backgroundColor: syspal.base
+ property color placeholderTextColor: "darkGray"
+ property color selectionColor: syspal.highlight
+ property color selectedTextColor: syspal.highlightedText
- property color foregroundColor: syspal.text
- property color backgroundColor: syspal.base
- property color placeholderTextColor: "darkGray"
- property color selectionColor: syspal.highlight
- property color selectedTextColor: syspal.highlightedText
+ property bool rounded: hints.indexOf("rounded") > -1
+ property int topMargin: 1
+ property int leftMargin: rounded ? 8 : 4
+ property int rightMargin: 4
+ property int bottomMargin: 1
- hint: control.styleHints
+ contentWidth: 100
+ contentHeight: 18
- Item {
- id: focusFrame
- anchors.fill: parent
- parent: textfield
- visible: framestyle.styleHint("focuswidget")
- StyleItem {
- id: framestyle
- hint: control.styleHints
- anchors.margins: -2
- anchors.rightMargin:-4
- anchors.bottomMargin:-4
+ FocusFrame {
anchors.fill: parent
- visible: textfield.activeFocus
- elementType: "focusframe"
+ visible: textfield.activeFocus && textfieldstyle.styleHint("focuswidget")
}
}
}
diff --git a/src/styles/Desktop/ToolBarStyle.qml b/src/styles/Desktop/ToolBarStyle.qml
index 9e8de799..52a4d09e 100644
--- a/src/styles/Desktop/ToolBarStyle.qml
+++ b/src/styles/Desktop/ToolBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,8 +37,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
StyleItem {
id: toolbar
diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml
index 0fdce1a4..2fe5ea8d 100644
--- a/src/styles/Desktop/ToolButtonStyle.qml
+++ b/src/styles/Desktop/ToolButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,25 +37,26 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
+import QtQuick.Controls.Private 1.0
-StyleItem {
- id: styleitem
- anchors.fill: parent
- elementType: "toolbutton"
- on: pressed | checked
- sunken: pressed
- raised: containsMouse
- hover: containsMouse
- info: __position
- hint: control.styleHints
- contentWidth: Math.max(textitem.paintedWidth, 32)
- contentHeight: 30
- Text {
- id: textitem
+Style {
+ property Component panel: StyleItem {
+ id: styleitem
+
+ anchors.fill: parent
+ elementType: "toolbutton"
+ on: control.pressed | control.checked
+ sunken: control.pressed
+ raised: control.__containsMouse
+ hover: control.__containsMouse
+ hasFocus: control.activeFocus
+ hints: control.styleHints.concat([control.__position])
text: control.text
- anchors.centerIn: parent
- visible: control.iconSource == ""
+
+ properties: {
+ "icon": control.__action.__icon
+ }
}
}
diff --git a/src/styles/FrameStyle.qml b/src/styles/FrameStyle.qml
deleted file mode 100644
index 740ddbb2..00000000
--- a/src/styles/FrameStyle.qml
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-/*!
- \qmltype FrameStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief FrameStyle is doing bla...bla...
-*/
-
-Rectangle {
- height:20
- width: 20
- visible: control.checked
- gradient: Gradient{
- GradientStop{color: "darkgray" ; position: 1}
- GradientStop{color: "lightgray" ; position: 0}
- }
- radius:2
- anchors.margins: 5
- anchors.fill: parent
- border.color: "gray"
-}
diff --git a/src/styles/GroupBoxStyle.qml b/src/styles/GroupBoxStyle.qml
index 7be74b61..ba5010d4 100644
--- a/src/styles/GroupBoxStyle.qml
+++ b/src/styles/GroupBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,23 +37,25 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
/*!
\qmltype GroupBoxStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief GroupBoxStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-
-Item {
- implicitWidth: Math.max(200, contentWidth + 30)
- implicitHeight: contentHeight
-
- Text {
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.margins: 4
- text: control.title
+Style {
+ property int margin: 8
+ property Component panel: Item {
+ implicitWidth: Math.max(200, contentWidth + 30)
+ implicitHeight: contentHeight
+ Text {
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.margins: 4
+ text: control.title
+ }
}
}
diff --git a/src/styles/MenuBarStyle.qml b/src/styles/MenuBarStyle.qml
new file mode 100644
index 00000000..6b7950eb
--- /dev/null
+++ b/src/styles/MenuBarStyle.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls.Styles 1.0
+
+/*!
+ \qmltype MenuBarStyle
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+*/
+
+Style {
+ property var __syspal: SystemPalette { id: syspal }
+
+ property Component panel: Rectangle {
+ width: control.width
+ height: 20
+ color: __syspal.window
+ }
+
+ property Component menuItem: Rectangle {
+ width: text.width + 12
+ height: text.height + 4
+ color: selected ? __syspal.highlight : __syspal.window
+
+ Text {
+ id: text
+ text: menuItem.title
+ anchors.centerIn: parent
+ renderType: Text.NativeRendering
+ color: selected ? __syspal.highlightedText : __syspal.windowText
+ }
+ }
+}
diff --git a/tests/manual/FileDialogTest.qml b/src/styles/MenuStyle.qml
index 4a56f8ad..dfc25ac5 100644
--- a/tests/manual/FileDialogTest.qml
+++ b/src/styles/MenuStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,56 +38,54 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
-Rectangle {
+Style {
+ id: styleRoot
- width: 538
- height: 360
+ property Component frame: Rectangle {
+ width: (parent ? parent.contentWidth : 0) + 2
+ height: (parent ? parent.contentHeight : 0) + 2
- ToolBar {
- id: toolbar
- width: parent.width
- height: 40
- Row {
- spacing: 2
- anchors.verticalCenter: parent.verticalCenter
- ToolButton{
- text: "Toggle"
- tooltip: "Toggle file dialog visible"
- anchors.verticalCenter: parent.verticalCenter
- onClicked: fileDialogLoad.visible = !fileDialogLoad.visible
- }
- ToolButton{
- text: "Open"
- tooltip: "Open the file dialog"
- anchors.verticalCenter: parent.verticalCenter
- onClicked: fileDialogLoad.open()
- }
- ToolButton{
- text: "Close"
- tooltip: "Close the file dialog"
- anchors.verticalCenter: parent.verticalCenter
- onClicked: fileDialogLoad.close()
- }
- }
+ color: "lightgray"
+ border { width: 1; color: "darkgray" }
+
+ property int subMenuOverlap: -1
}
- FileDialog {
- id: fileDialogLoad
- folder: "/tmp"
- title: "Choose a file to open"
- selectMultiple: true
- nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ]
+ property Component menuItem: Rectangle {
+ width: Math.max((parent ? parent.contentWidth : 0), text.paintedWidth + 12)
+ height: isSeparator ? text.font.pixelSize / 2 : text.paintedHeight + 4
+ color: selected ? "" : backgroundColor
+ gradient: selected ? selectedGradient : undefined
- onAccepted: { console.log("Accepted: " + filePaths) }
- }
+ readonly property color backgroundColor: "lightgray"
+ Gradient {
+ id: selectedGradient
+ GradientStop {color: Qt.lighter(backgroundColor, 1.8) ; position: 0}
+ GradientStop {color: backgroundColor ; position: 1.4}
+ }
+ antialiasing: true
- Column {
- anchors.bottom: parent.bottom
- Text { text: "File dialog geometry " + fileDialogLoad.x + "," + fileDialogLoad.y + " " + fileDialogLoad.width + "x" + fileDialogLoad.height }
- Text { text: "File dialog visible? " + fileDialogLoad.visible }
+ Text {
+ id: text
+ visible: !isSeparator
+ text: menuItem.text + (isSubmenu ? " \u25b6" : "")
+ x: 6
+ anchors.verticalCenter: parent.verticalCenter
+ renderType: Text.NativeRendering
+ color: "black"
+ }
+
+ Rectangle {
+ visible: isSeparator
+ width: parent.width - 2
+ height: 1
+ x: 1
+ anchors.verticalCenter: parent.verticalCenter
+ color: "darkgray"
+ }
}
}
-
diff --git a/src/styles/ProgressBarStyle.qml b/src/styles/ProgressBarStyle.qml
index ecd70f54..799cb676 100644
--- a/src/styles/ProgressBarStyle.qml
+++ b/src/styles/ProgressBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,25 +38,25 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype ProgressBarStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ProgressBarStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for ProgressBar
*/
-Item {
- anchors.fill: parent
- implicitWidth: 200
- implicitHeight: 20
-
+Style {
property color backgroundColor: "darkgrey"
property color progressColor: "#47f"
property Component background: Rectangle {
id: styleitem
+ anchors.fill: parent
+ implicitWidth: 200
+ implicitHeight: 20
clip: true
radius: 2
antialiasing: true
@@ -90,9 +90,18 @@ Item {
}
}
- Loader {
- id: backgroundLoader
+ property Component panel: Item {
+ property Item controlref: control
anchors.fill: parent
- sourceComponent: background
+
+ implicitWidth: backgroundLoader.implicitWidth
+ implicitHeight: backgroundLoader.implicitHeight
+
+ Loader {
+ id: backgroundLoader
+ anchors.fill: parent
+ sourceComponent: background
+ property Item control: controlref
+ }
}
}
diff --git a/src/styles/RadioButtonStyle.qml b/src/styles/RadioButtonStyle.qml
index bdad3d1b..764e306f 100644
--- a/src/styles/RadioButtonStyle.qml
+++ b/src/styles/RadioButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,55 +37,63 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype RadioButtonStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief RadioButtonStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for RadioButton
*/
+Style {
-Item {
- implicitWidth: 100
- implicitHeight: 20
+ property int labelSpacing: 6
- property Component indicator: Rectangle {
- id: styleitem
- height:20
+ property Component indicator: Rectangle {
width: 20
- gradient: Gradient{
- GradientStop{color: control.pressed ? "lightgray" : "white" ; position: 0}
- GradientStop{color: control.pressed ? "lightgray" : "lightgray" ; position: 1}
- }
- radius: width/2
- border.color: "#aaa"
+ height: 20
+ color: "#f0f0f0"
+ border.color: "gray"
antialiasing: true
+ radius: height/2
+
Rectangle {
- height:20
- width: 20
- antialiasing: true
+ anchors.centerIn: parent
visible: control.checked
- gradient: Gradient{
- GradientStop{color: "darkgray" ; position: 1}
- GradientStop{color: "lightgray" ; position: 0}
- }
- radius: width/2
- anchors.margins: 5
- anchors.fill: parent
- border.color: "gray"
+ width: 10
+ height: 10
+ color: "#444"
+ border.color: "black"
+ antialiasing: true
+ radius: height/2
}
}
-
- Loader {
- id: indicatorLoader
- sourceComponent: indicator
+ property Component label: Text {
+ text: control.text
+ renderType: Text.NativeRendering
}
- Text {
- anchors.left: parent.left
- anchors.leftMargin: 24
- anchors.verticalCenter: parent.verticalCenter
- text: control.text
+ property Component panel: Item {
+ implicitWidth: row.width
+ implicitHeight: row.height
+ property var _cref: control
+
+ Row {
+ id: row
+ spacing: labelSpacing
+ Loader {
+ id: indicatorLoader
+ sourceComponent: indicator
+ anchors.verticalCenter: parent.verticalCenter
+ property Item control: _cref
+ }
+ Loader {
+ id: labelLoader
+ sourceComponent: label
+ anchors.verticalCenter: parent.verticalCenter
+ property Item control: _cref
+ }
+ }
}
}
diff --git a/src/styles/ScrollAreaStyle.qml b/src/styles/ScrollAreaStyle.qml
deleted file mode 100644
index 81da80a7..00000000
--- a/src/styles/ScrollAreaStyle.qml
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-/*!
- \qmltype ScrollAreaStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ScrollAreaStyle is doing bla...bla...
-*/
-
-Rectangle {
- height:20
- width: 20
- anchors.fill: parent
- color: "white"
- border.color: "gray"
-}
diff --git a/src/styles/ScrollBarStyle.qml b/src/styles/ScrollBarStyle.qml
index 0e8f23f6..4fed597d 100644
--- a/src/styles/ScrollBarStyle.qml
+++ b/src/styles/ScrollBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,15 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype ScrollBarStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ScrollBarStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-
Rectangle {
id: styleitem
@@ -176,7 +175,7 @@ Rectangle {
Loader{
id: handleControl
property int totalextent: horizontal ? bg.width : bg.height
- property int extent: Math.max(minimumHandleLength, totalextent - control.maximumValue + 2 * handleOverlap)
+ property int extent: Math.max(minimumHandleLength, 100 * totalextent / (control.maximumValue - control.minimumValue) + 2 * handleOverlap)
property bool mouseOver: activeControl === "handle"
height: horizontal ? implicitHeight : extent
diff --git a/src/styles/Settings.js b/src/styles/Settings.js
index 28ef8ee9..683e4363 100644
--- a/src/styles/Settings.js
+++ b/src/styles/Settings.js
@@ -1,2 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
.pragma library
var THEME_PATH = "Styles/Desktop"
diff --git a/src/styles/SliderStyle.qml b/src/styles/SliderStyle.qml
index a8ccef9c..2f618a17 100644
--- a/src/styles/SliderStyle.qml
+++ b/src/styles/SliderStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,21 +37,18 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype SliderStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief SliderStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-
-Item {
+Style {
id: styleitem
- implicitWidth: 200
- implicitHeight: 20
-
property int leftMargin
property int rightMargin
@@ -69,13 +66,11 @@ Item {
border.color: Qt.darker(backgroundColor, 1.8)
}
- property Component background: Item {
- Rectangle {
+ property Component background: Rectangle {
anchors.verticalCenter: parent.verticalCenter
- width: parent.width
-
- implicitWidth: 12
+ implicitWidth: 100
implicitHeight: 6
+
gradient: Gradient {
GradientStop {color: Qt.darker(backgroundColor, 1.2) ; position: 0}
GradientStop {color: Qt.darker(backgroundColor, 1.5) ; position: 1}
@@ -83,19 +78,29 @@ Item {
antialiasing: true
radius: height / 2.0
border.color: Qt.darker(backgroundColor, 1.8)
- }
}
- Loader {
- id: backgroundControl
- sourceComponent: background
- width: parent.width
- anchors.verticalCenter: parent.verticalCenter
- }
+ property Component panel: Item {
+ id: root
- Loader {
- sourceComponent: handle
- anchors.verticalCenter: backgroundControl.verticalCenter
- x: leftMargin + control.value / control.maximumValue * (parent.width - leftMargin - rightMargin - width)
+ implicitWidth: backgroundControl.implicitWidth
+ implicitHeight: backgroundControl.implicitHeight
+
+ property Control __cref: control
+
+ Loader {
+ id: backgroundControl
+ sourceComponent: background
+ property Control control: __cref
+ property Item handle: handleLoader.item
+ }
+
+ Loader {
+ id: handleLoader
+ sourceComponent: handle
+ anchors.verticalCenter: backgroundControl.verticalCenter
+ x: leftMargin + control.value / control.maximumValue * (root.width - leftMargin - rightMargin - width/2)
+ property Control control: __cref
+ }
}
}
diff --git a/src/styles/SpinBoxStyle.qml b/src/styles/SpinBoxStyle.qml
index 5b3c2f9b..890e7344 100644
--- a/src/styles/SpinBoxStyle.qml
+++ b/src/styles/SpinBoxStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,46 +37,35 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype SpinBoxStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief SpinBoxStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for SpinBox
*/
-Item {
- id: styleitem
- implicitWidth: 100
- implicitHeight: 21
-
- property rect upRect: Qt.rect(width - upControlLoader.implicitWidth, 0, upControlLoader.implicitWidth, height / 2 + 1)
- property rect downRect: Qt.rect(width - downControlLoader.implicitWidth, height / 2, downControlLoader.implicitWidth, height / 2)
+Style {
+ id: spinboxStyle
property int topMargin: 0
property int leftMargin: 4
property int rightMargin: 12
property int bottomMargin: 0
- property int horizontalTextAlignment: Qt.AlignLeft
- property int verticalTextAlignment: Qt.AlignVCenter
property color foregroundColor: syspal.text
property color backgroundColor: syspal.base
property color selectionColor: syspal.highlight
property color selectedTextColor: syspal.highlightedText
- SystemPalette {
- id: syspal
- colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled
- }
-
property Component upControl: Rectangle {
anchors.centerIn: parent
implicitWidth: 12
gradient: Gradient {
- GradientStop {color: control.upPressed ? "lightgray" : "white" ; position: 0}
- GradientStop {color: control.upPressed ? "lightgray" : "lightgray" ; position: 1}
+ GradientStop {color: control.__upPressed ? "lightgray" : "white" ; position: 0}
+ GradientStop {color: control.__upPressed ? "lightgray" : "lightgray" ; position: 1}
}
border.color: Qt.darker(backgroundColor, 2)
Image {
@@ -88,8 +77,8 @@ Item {
property Component downControl: Rectangle {
implicitWidth: 12
gradient: Gradient {
- GradientStop {color: control.downPressed ? "lightgray" : "white" ; position: 0}
- GradientStop {color: control.downPressed ? "lightgray" : "lightgray" ; position: 1}
+ GradientStop {color: control.__downPressed ? "lightgray" : "white" ; position: 0}
+ GradientStop {color: control.__downPressed ? "lightgray" : "lightgray" ; position: 1}
}
border.color: Qt.darker(backgroundColor, 2)
Image {
@@ -109,28 +98,60 @@ Item {
border.color: Qt.darker(backgroundColor, 2)
}
- Loader {
- id: backgroundLoader
- anchors.fill: parent
- sourceComponent: background
- }
- Loader {
- id: upControlLoader
- x: upRect.x
- y: upRect.y
- width: upRect.width
- height: upRect.height
- sourceComponent: upControl
- }
+ property Component panel: Item {
+ id: styleitem
+ implicitWidth: 100
+ implicitHeight: 21
- Loader {
- id: downControlLoader
- x: downRect.x
- y: downRect.y
- width: downRect.width
- height: downRect.height
- sourceComponent: downControl
- }
+ property color foregroundColor: spinboxStyle.foregroundColor
+ property color backgroundColor: spinboxStyle.backgroundColor
+ property color selectionColor: spinboxStyle.selectionColor
+ property color selectedTextColor: spinboxStyle.selectedTextColor
+
+ property int leftMargin: spinboxStyle.leftMargin
+ property int rightMargin: spinboxStyle.rightMargin
+ property int topMargin: spinboxStyle.topMargin
+ property int bottomMargin: spinboxStyle.bottomMargin
+
+ property rect upRect: Qt.rect(width - upControlLoader.implicitWidth, 0, upControlLoader.implicitWidth, height / 2 + 1)
+ property rect downRect: Qt.rect(width - downControlLoader.implicitWidth, height / 2, downControlLoader.implicitWidth, height / 2)
+
+ property int horizontalTextAlignment: Qt.AlignLeft
+ property int verticalTextAlignment: Qt.AlignVCenter
+ property SpinBox cref: control
+
+ SystemPalette {
+ id: syspal
+ colorGroup: control.enabled ? SystemPalette.Active : SystemPalette.Disabled
+ }
+
+ Loader {
+ id: backgroundLoader
+ anchors.fill: parent
+ sourceComponent: background
+ property SpinBox control: cref
+ }
+
+ Loader {
+ id: upControlLoader
+ x: upRect.x
+ y: upRect.y
+ width: upRect.width
+ height: upRect.height
+ sourceComponent: upControl
+ property SpinBox control: cref
+ }
+
+ Loader {
+ id: downControlLoader
+ x: downRect.x
+ y: downRect.y
+ width: downRect.width
+ height: downRect.height
+ sourceComponent: downControl
+ property SpinBox control: cref
+ }
+ }
}
diff --git a/src/styles/Style.qml b/src/styles/Style.qml
new file mode 100644
index 00000000..6cb65380
--- /dev/null
+++ b/src/styles/Style.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+
+
+/*!
+ \qmltype Style
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+*/
+
+QtObject { }
diff --git a/src/styles/TabFrameStyle.qml b/src/styles/TabViewStyle.qml
index d2057365..9f4c0bd9 100644
--- a/src/styles/TabFrameStyle.qml
+++ b/src/styles/TabViewStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,15 +37,17 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
+import QtQuick.Controls.Styles 1.0
/*!
- \qmltype TabFrameStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief TabFrameStyle is doing bla...bla...
+ \qmltype TabViewStyle
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for TabView
*/
-QtObject {
+Style {
/*! This property holds the base alignment of the tab bar.
The default value is "left". Supporeted alignments are
diff --git a/src/styles/TextFieldStyle.qml b/src/styles/TextFieldStyle.qml
index 086acc45..c2467ee8 100644
--- a/src/styles/TextFieldStyle.qml
+++ b/src/styles/TextFieldStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,40 +37,30 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype TextFieldStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief TextFieldStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
+ \brief provides custom styling for TextField.
*/
-Item {
+Style {
id: style
- anchors.fill: parent
-
- implicitWidth: backgroundLoader.implicitWidth ? backgroundLoader.implicitWidth : 100
- implicitHeight: backgroundLoader.implicitHeight ? backgroundLoader.implicitHeight : 20
property int topMargin: 4
property int leftMargin: 8
property int rightMargin: 8
property int bottomMargin: 4
- property color foregroundColor: syspal.text
- property color backgroundColor: syspal.base
- property color placeholderTextColor: Qt.rgba(0, 0, 0, 0.5)
- property color selectionColor: syspal.highlight
- property color selectedTextColor: syspal.highlightedText
- property font font
+ property color foregroundColor: "black"
+ property color backgroundColor: "white"
+ property color selectionColor: "blue"
+ property color selectedTextColor: "white"
- SystemPalette {
- id: syspal
- colorGroup: control.enabled ?
- SystemPalette.Active :
- SystemPalette.Disabled
- }
+ property font font
property Component background: Rectangle {
id: styleitem
@@ -83,9 +73,29 @@ Item {
antialiasing: true
}
- Loader {
- id: backgroundLoader
- sourceComponent: background
+ property Component panel: Item {
anchors.fill: parent
+
+ property int topMargin: style.topMargin
+ property int leftMargin: style.leftMargin
+ property int rightMargin: style.rightMargin
+ property int bottomMargin: style.bottomMargin
+
+ property color foregroundColor: style.foregroundColor
+ property color backgroundColor: style.backgroundColor
+ property color selectionColor: style.selectionColor
+ property color selectedTextColor: style.selectedTextColor
+
+ implicitWidth: backgroundLoader.implicitWidth ? backgroundLoader.implicitWidth : 100
+ implicitHeight: backgroundLoader.implicitHeight ? backgroundLoader.implicitHeight : 20
+
+ property color placeholderTextColor: Qt.rgba(0, 0, 0, 0.5)
+ property font font: style.font
+
+ Loader {
+ id: backgroundLoader
+ sourceComponent: background
+ anchors.fill: parent
+ }
}
}
diff --git a/src/styles/ToolBarStyle.qml b/src/styles/ToolBarStyle.qml
index b4928186..450304ed 100644
--- a/src/styles/ToolBarStyle.qml
+++ b/src/styles/ToolBarStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,19 +37,18 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype ToolBarStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ToolBarStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-
Item {
property int __overlap : 1
- property string position: "North"
+ property string position: "Top"
property string tabBarAlignment: "Center"
property int tabOverlap: 1
property int tabBaseOverlap: 1
diff --git a/src/styles/ToolButtonStyle.qml b/src/styles/ToolButtonStyle.qml
index 3e7dd589..13b9813c 100644
--- a/src/styles/ToolButtonStyle.qml
+++ b/src/styles/ToolButtonStyle.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -37,15 +37,14 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
/*!
\qmltype ToolButtonStyle
- \inqmlmodule QtDesktop.Styles 1.0
- \brief ToolButtonStyle is doing bla...bla...
+ \internal
+ \inqmlmodule QtQuick.Controls.Styles 1.0
*/
-
Rectangle {
id: styleitem
implicitWidth: 32
diff --git a/src/styles/qmldir b/src/styles/qmldir
index b279be3b..eee1abd1 100644
--- a/src/styles/qmldir
+++ b/src/styles/qmldir
@@ -1,8 +1,7 @@
-module QtDesktop.Styles
+module QtQuick.Controls.Styles
ButtonStyle 1.0 ButtonStyle.qml
CheckBoxStyle 1.0 CheckBoxStyle.qml
ComboBoxStyle 1.0 ComboBoxStyle.qml
-FrameStyle 1.0 FrameStyle.qml
GroupBoxStyle 1.0 GroupBoxStyle.qml
ProgressBarStyle 1.0 ProgressBarStyle.qml
RadioButtonStyle 1.0 RadioButtonStyle.qml
@@ -10,9 +9,9 @@ ScrollBarStyle 1.0 ScrollBarStyle.qml
SliderStyle 1.0 SliderStyle.qml
SpinBoxStyle 1.0 SpinBoxStyle.qml
TabStyle 1.0 TabStyle.qml
-TabFrameStyle 1.0 TabFrameStyle.qml
+TabViewStyle 1.0 TabViewStyle.qml
TextAreaStyle 1.0 TextAreaStyle.qml
TextFieldStyle 1.0 TextFieldStyle.qml
ToolBarStyle 1.0 ToolBarStyle.qml
ToolButtonStyle 1.0 ToolButtonStyle.qml
-
+Style 1.0 Style.qml
diff --git a/src/styles/styles.pro b/src/styles/styles.pro
index fa410557..f0d44f6a 100644
--- a/src/styles/styles.pro
+++ b/src/styles/styles.pro
@@ -1,19 +1,20 @@
-TARGETPATH = QtDesktop/Styles
+TARGETPATH = QtQuick/Controls/Styles
QML_FILES = \
ButtonStyle.qml \
CheckBoxStyle.qml \
ComboBoxStyle.qml \
- FrameStyle.qml \
GroupBoxStyle.qml \
+ MenuBarStyle.qml \
+ MenuStyle.qml \
ProgressBarStyle.qml \
RadioButtonStyle.qml \
- ScrollAreaStyle.qml \
ScrollBarStyle.qml \
Settings.js \
SliderStyle.qml \
SpinBoxStyle.qml \
- TabFrameStyle.qml \
+ Style.qml \
+ TabViewStyle.qml \
TextFieldStyle.qml \
ToolBarStyle.qml \
ToolButtonStyle.qml
@@ -23,15 +24,15 @@ QML_FILES += \
Desktop/ButtonStyle.qml \
Desktop/CheckBoxStyle.qml \
Desktop/ComboBoxStyle.qml \
- Desktop/FrameStyle.qml \
Desktop/GroupBoxStyle.qml \
+ Desktop/MenuBarStyle.qml \
+ Desktop/MenuStyle.qml \
Desktop/ProgressBarStyle.qml \
Desktop/RadioButtonStyle.qml \
- Desktop/ScrollAreaStyle.qml \
Desktop/ScrollBarStyle.qml \
Desktop/SliderStyle.qml \
Desktop/SpinBoxStyle.qml \
- Desktop/TabFrameStyle.qml \
+ Desktop/TabViewStyle.qml \
Desktop/TextFieldStyle.qml \
Desktop/ToolBarStyle.qml \
Desktop/ToolButtonStyle.qml
diff --git a/sync.profile b/sync.profile
index 9692e548..59c2fb57 100644
--- a/sync.profile
+++ b/sync.profile
@@ -9,8 +9,8 @@
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
- "qtbase" => "refs/heads/dev",
- "qtdeclarative" => "refs/heads/dev",
- "qtjsbackend" => "refs/heads/dev",
- "qtxmlpatterns" => "refs/heads/dev",
+ "qtbase" => "refs/heads/stable",
+ "qtdeclarative" => "refs/heads/stable",
+ "qtjsbackend" => "refs/heads/stable",
+ "qtxmlpatterns" => "refs/heads/stable",
);
diff --git a/tests/auto/activeFocusOnTab/activeFocusOnTab.pro b/tests/auto/activeFocusOnTab/activeFocusOnTab.pro
new file mode 100644
index 00000000..1a32e0e6
--- /dev/null
+++ b/tests/auto/activeFocusOnTab/activeFocusOnTab.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_activeFocusOnTab
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_activeFocusOnTab.cpp
+
+include (../shared/util.pri)
+
+TESTDATA = data/*
+
+QT += widgets core-private gui-private v8-private qml-private quick-private testlib
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
new file mode 100644
index 00000000..5955b61e
--- /dev/null
+++ b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+Item {
+ id: main
+ objectName: "main"
+ width: 800
+ height: 600
+ focus: true
+ Component.onCompleted: button1.focus = true
+ Column {
+ anchors.fill: parent
+ id: column
+ objectName: "column"
+ Button {
+ id: button1
+ objectName: "button1"
+ text: "button 1"
+ }
+ Button {
+ id: button2
+ objectName: "button2"
+ text: "button 2"
+ }
+ Label {
+ id: label
+ objectName: "label"
+ text: "label"
+ }
+ ToolButton {
+ id: toolbutton
+ objectName: "toolbutton"
+ iconSource: "images/testIcon.png"
+ tooltip: "Test Icon"
+ }
+ ListModel {
+ id: choices
+ ListElement { text: "Banana" }
+ ListElement { text: "Orange" }
+ ListElement { text: "Apple" }
+ ListElement { text: "Coconut" }
+ }
+ ComboBox {
+ id: combobox;
+ objectName: "combobox"
+ model: choices;
+ }
+ GroupBox {
+ id: group1
+ objectName: "group1"
+ title: "GroupBox 1"
+ checkable: true
+ __checkbox.objectName: "group1_checkbox"
+ Row {
+ CheckBox {
+ id: checkbox1
+ objectName: "checkbox1"
+ text: "Text frame"
+ checked: true
+ }
+ CheckBox {
+ id: checkbox2
+ objectName: "checkbox2"
+ text: "Tickmarks"
+ checked: false
+ }
+ }
+ }
+ GroupBox {
+ id: group2
+ objectName: "group2"
+ title: "GroupBox 2"
+ Row {
+ RadioButton {
+ id: radiobutton1
+ objectName: "radiobutton1"
+ text: "North"
+ checked: true
+ }
+ RadioButton {
+ id: radiobutton2
+ objectName: "radiobutton2"
+ text: "South"
+ }
+ }
+ }
+ //Page
+ //ProgressBar maybe not need
+ ProgressBar {
+ id: progressbar
+ objectName: "progressbar"
+ indeterminate: true
+ }
+ //ScrollArea
+ Slider {
+ id: slider
+ objectName: "slider"
+ value: 0.5
+ }
+ SpinBox {
+ id: spinbox
+ objectName: "spinbox"
+ width: 70
+ minimumValue: 0
+ maximumValue: 100
+ value: 50
+ }
+ //SplitterColumn and SplitterRow false
+ //StatusBar false
+ TabView {
+ id: tabview
+ objectName: "tabview"
+ width: 200
+ Tab {
+ id: tab1
+ objectName: "tab1"
+ title: "Tab1"
+ Column {
+ id: column_in_tab1
+ objectName: "column_in_tab1"
+ anchors.fill: parent
+ Button {
+ id: tab1_btn1
+ objectName: "tab1_btn1"
+ text: "button 1 in Tab1"
+ }
+ Button {
+ id: tab1_btn2
+ objectName: "tab1_btn2"
+ text: "button 2 in Tab1"
+ }
+ }
+ }
+ Tab {
+ id: tab2
+ objectName: "tab2"
+ title: "Tab2"
+ Column {
+ id: column_in_tab2
+ objectName: "column_in_tab2"
+ anchors.fill: parent
+ Button {
+ id: tab2_btn1
+ objectName: "tab2_btn1"
+ text: "button 1 in Tab2"
+ }
+ Button {
+ id: tab2_btn2
+ objectName: "tab2_btn2"
+ text: "button 2 in Tab2"
+ }
+ }
+ }
+ }
+ TextField {
+ id: textfield
+ objectName: "textfield"
+ text: "abc"
+ }
+ TextArea {
+ id: textarea
+ objectName: "textarea"
+ text: "abc"
+ }
+ }
+}
diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
new file mode 100644
index 00000000..19d0d194
--- /dev/null
+++ b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
@@ -0,0 +1,427 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include "../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_activeFocusOnTab : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_activeFocusOnTab();
+
+private slots:
+ void initTestCase();
+ void cleanup();
+
+ void activeFocusOnTab();
+private:
+ QQmlEngine engine;
+};
+
+tst_activeFocusOnTab::tst_activeFocusOnTab()
+{
+}
+
+void tst_activeFocusOnTab::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+}
+
+void tst_activeFocusOnTab::cleanup()
+{
+}
+
+void tst_activeFocusOnTab::activeFocusOnTab()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setBaseSize(QSize(800,600));
+
+ window->setSource(testFileUrl("activeFocusOnTab.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QGuiApplication::focusWindow() == window);
+
+ // original: button1
+ QQuickItem *item = findItem<QQuickItem>(window->rootObject(), "button1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: button1->button2
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "button2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: button2->toolbutton
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "toolbutton");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: toolbutton->combobox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "combobox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: combobox->group1_checkbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "group1");
+ QVERIFY(item);
+ QQuickItem *subitem = findItem<QQuickItem>(item, "group1_checkbox");
+ QVERIFY(subitem);
+ QVERIFY(subitem->hasActiveFocus());
+
+ // Tab: group1->checkbox1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "checkbox1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: checkbox1->checkbox2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "checkbox2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: checkbox2->radiobutton1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "radiobutton1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: radiobutton1->radiobutton2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "radiobutton2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: radiobutton2->slider
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "slider");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: slider->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: spinbox->tab1_btn1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ for (int i = 0; i < 2; ++i) {
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+ }
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab1_btn1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tab1_btn1->tab1_btn2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab1_btn2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tab1_btn2->textfield
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textfield");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: textfield->textarea
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textarea");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textarea->textfield
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textfield");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textfield->tab1_btn2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab1_btn2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tab1_btn2->tab1_btn1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab1_btn1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tab1_btn1->tab1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+/*
+ // Right: tab1->tab2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ // Tab: tab2->tab2_btn1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab2_btn1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tab2_btn1->tab2_btn2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab2_btn2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: tab2_btn2->textfield
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textfield");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: textfield->tab2_btn2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab2_btn2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tab2_btn2->tab2_btn1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "tab2_btn1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: tab2_btn1->tab2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+*/
+ // BackTab: tab2->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: spinbox->slider
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "slider");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: slider->radiobutton2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "radiobutton2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: radiobutton2->radiobutton1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "radiobutton1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: radiobutton1->checkbox2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "checkbox2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: checkbox2->checkbox1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "checkbox1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: checkbox1->group1_checkbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "group1_checkbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: group1_checkbox->combobox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "combobox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: combobox->toolbutton
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "toolbutton");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: toolbutton->button2
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "button2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: button2->button1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "button1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: button1->textarea
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "textarea");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete window;
+}
+
+QTEST_MAIN(tst_activeFocusOnTab)
+
+#include "tst_activeFocusOnTab.moc"
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 7f65bddf..927b7cca 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS += qtdesktop testplugin
+SUBDIRS += testplugin controls activeFocusOnTab
+CONFIG += ordered
diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro
new file mode 100644
index 00000000..8db8bf8f
--- /dev/null
+++ b/tests/auto/controls/controls.pro
@@ -0,0 +1,41 @@
+TEMPLATE = app
+TARGET = tst_controls
+
+IMPORTPATH = $$OUT_PWD/../testplugin
+
+QT += widgets
+
+CONFIG += qmltestcase console
+
+INCLUDEPATH += $$PWD/../../shared
+SOURCES += $$PWD/tst_controls.cpp
+
+TESTDATA = $$PWD/data/*
+
+OTHER_FILES += \
+ $$PWD/data/tst_button.qml \
+ $$PWD/data/tst_shortcuts.qml \
+ $$PWD/data/tst_spinbox.qml \
+ $$PWD/data/tst_tableview.qml \
+ $$PWD/data/tst_rangemodel.qml \
+ $$PWD/data/tst_scrollview.qml \
+ $$PWD/data/tst_menu.qml \
+ $$PWD/data/tst_textfield.qml \
+ $$PWD/data/tst_textarea.qml \
+ $$PWD/data/tst_applicationwindow.qml \
+ $$PWD/data/tst_combobox.qml \
+ $$PWD/data/tst_progressbar.qml \
+ $$PWD/data/tst_radiobutton.qml \
+ $$PWD/data/tst_label.qml \
+ $$PWD/data/tst_page.qml \
+ $$PWD/data/tst_menubar.qml \
+ $$PWD/data/tst_rowlayout.qml \
+ $$PWD/data/tst_slider.qml \
+ $$PWD/data/tst_statusbar.qml \
+ $$PWD/data/tst_tab.qml \
+ $$PWD/data/tst_tabview.qml \
+ $$PWD/data/tst_tableviewcolumn.qml \
+ $$PWD/data/tst_toolbar.qml \
+ $$PWD/data/tst_toolbutton.qml \
+ $$PWD/data/tst_checkbox.qml \
+ $$PWD/data/tst_groupbox.qml
diff --git a/tests/auto/qtdesktop/data/rangemodel/rangemodel.qml b/tests/auto/controls/data/rangemodel/rangemodel.qml
index 8644963c..bf03dd0c 100644
--- a/tests/auto/qtdesktop/data/rangemodel/rangemodel.qml
+++ b/tests/auto/controls/data/rangemodel/rangemodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Private 1.0
RangeModel {
minimumValue: 0
diff --git a/tests/auto/qtdesktop/data/shortcut/shortcuts.qml b/tests/auto/controls/data/shortcut/shortcuts.qml
index 3da19494..c9c6f5f5 100644
--- a/tests/auto/qtdesktop/data/shortcut/shortcuts.qml
+++ b/tests/auto/controls/data/shortcut/shortcuts.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
Rectangle {
width: 300
@@ -87,7 +87,7 @@ Rectangle {
}
Action {
- mnemonic: "&test"
+ text: "&test"
onTriggered: text.text = "alt t pressed"
}
}
diff --git a/tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml b/tests/auto/controls/data/tableview/table1_qobjectmodel.qml
index 60d95553..4b26f66d 100644
--- a/tests/auto/qtdesktop/data/tableview/table1_qobjectmodel.qml
+++ b/tests/auto/controls/data/tableview/table1_qobjectmodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,14 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktopTest 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuickControlsTests 1.0
TableView {
model: TestObject {}
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
diff --git a/tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml b/tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml
index 4e9efaf6..bc3da232 100644
--- a/tests/auto/qtdesktop/data/tableview/table2_qabstractitemmodel.qml
+++ b/tests/auto/controls/data/tableview/table2_qabstractitemmodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,14 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktopTest 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuickControlsTests 1.0
TableView {
model: TestItemModel {}
height: 70
- TableColumn {
+ TableViewColumn {
role: "test"
width: 100
}
diff --git a/tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml b/tests/auto/controls/data/tableview/table3_qobjectlist.qml
index 8ffb126f..f3f64327 100644
--- a/tests/auto/qtdesktop/data/tableview/table3_qobjectlist.qml
+++ b/tests/auto/controls/data/tableview/table3_qobjectlist.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,14 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktopTest 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuickControlsTests 1.0
TableView {
model: model_qobjectlist
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
diff --git a/tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml b/tests/auto/controls/data/tableview/table4_qstringlist.qml
index 6733165e..75840499 100644
--- a/tests/auto/qtdesktop/data/tableview/table4_qstringlist.qml
+++ b/tests/auto/controls/data/tableview/table4_qstringlist.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,14 +38,14 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktopTest 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuickControlsTests 1.0
TableView {
model: model_qstringlist
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
diff --git a/tests/auto/qtdesktop/data/tableview/table5_listmodel.qml b/tests/auto/controls/data/tableview/table5_listmodel.qml
index 151fff4f..c0e46abc 100644
--- a/tests/auto/qtdesktop/data/tableview/table5_listmodel.qml
+++ b/tests/auto/controls/data/tableview/table5_listmodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
TableView {
@@ -49,7 +49,7 @@ TableView {
ListElement { value: "C" }
} // qml
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
diff --git a/tests/auto/qtdesktop/data/tableview/table6_countmodel.qml b/tests/auto/controls/data/tableview/table6_countmodel.qml
index 3df45b47..995de485 100644
--- a/tests/auto/qtdesktop/data/tableview/table6_countmodel.qml
+++ b/tests/auto/controls/data/tableview/table6_countmodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,13 +38,13 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
TableView {
model: 3 // qml
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
diff --git a/tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml b/tests/auto/controls/data/tableview/table7_arraymodel.qml
index 1c91528e..d3483ddc 100644
--- a/tests/auto/qtdesktop/data/tableview/table7_arraymodel.qml
+++ b/tests/auto/controls/data/tableview/table7_arraymodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,13 +38,13 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
TableView {
model: ["A", "B", "C"] // qml
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
diff --git a/tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml b/tests/auto/controls/data/tableview/table8_itemmodel.qml
index 0d231668..081f1d61 100644
--- a/tests/auto/qtdesktop/data/tableview/table8_itemmodel.qml
+++ b/tests/auto/controls/data/tableview/table8_itemmodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,13 +38,13 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
TableView {
model: Item { x: 10 }// qml
height: 70
- TableColumn {
+ TableViewColumn {
role: "x"
width: 100
}
diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml
new file mode 100644
index 00000000..e465d47d
--- /dev/null
+++ b/tests/auto/controls/data/tst_applicationwindow.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ApplicationWindow"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_window() {
+ var tmp = Qt.createQmlObject('import QtQuick.Controls 1.0; ApplicationWindow {id: window}', testCase, '');
+ tmp.statusBar = Qt.createQmlObject('import QtQuick.Controls 1.0; StatusBar {}', testCase, '');
+ tmp.toolBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolBar {}', testCase, '');
+ verify(tmp.statusBar !== undefined)
+ verify(tmp.toolBar !== undefined)
+ }
+}
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
new file mode 100644
index 00000000..1efbd4e9
--- /dev/null
+++ b/tests/auto/controls/data/tst_button.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_Button"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_isDefault() {
+ var tmp = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button1}', testCase, '');
+ compare(tmp.isDefault, false);
+ }
+
+ function test_text() {
+ var tmp1 = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button2_1}', testCase, '');
+ compare(tmp1.text, "");
+ tmp1.text = "Hello";
+ compare(tmp1.text, "Hello");
+
+ var tmp2 = Qt.createQmlObject('import QtQuick.Controls 1.0; Button {id: button2_2; text: "Hello"}', testCase, '');
+ compare(tmp2.text, "Hello");
+ }
+
+ SignalSpy {
+ id: clickSpy
+ signalName: "clicked"
+ }
+
+ function test_action() {
+ var test_actionStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Controls 1.0; \
+ Item { \
+ property var testAction: Action { \
+ id: testAction; \
+ text: "Action text" \
+ } \
+ \
+ property var button: Button { \
+ id: button; \
+ action: testAction \
+ } \
+ } '
+
+ var tmp = Qt.createQmlObject(test_actionStr, testCase, '')
+ compare(tmp.button.text, "Action text")
+
+ tmp.testAction.text = "Action Joe"
+ compare(tmp.button.text, "Action Joe")
+
+ tmp.button.text = "G.I. Joe"
+ compare(tmp.button.text, "G.I. Joe")
+ compare(tmp.testAction.text, "Action Joe")
+
+ clickSpy.target = tmp.button
+ tmp.testAction.trigger()
+ compare(clickSpy.count, 1)
+ }
+}
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml
new file mode 100644
index 00000000..ae996d01
--- /dev/null
+++ b/tests/auto/controls/data/tst_checkbox.qml
@@ -0,0 +1,223 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+Item {
+ id: container
+ width: 200
+ height: 200
+
+ TestCase {
+ id: testCase
+ name: "Tests_CheckBox"
+ when: windowShown
+ width: 200
+ height: 200
+
+ property var checkBox
+
+ SignalSpy {
+ id: signalSpy
+ }
+
+ function init() {
+ checkBox = Qt.createQmlObject("import QtQuick.Controls 1.0; CheckBox { }", container, "");
+ }
+
+ function cleanup() {
+ signalSpy.clear();
+ }
+
+ function test_defaultConstructed() {
+ compare(checkBox.checked, false);
+ compare(checkBox.checkedState, Qt.Unchecked);
+ compare(checkBox.partiallyCheckedEnabled, false);
+ compare(checkBox.text, "");
+ }
+
+ function test_text() {
+ compare(checkBox.text, "");
+
+ checkBox.text = "Check me!";
+ compare(checkBox.text, "Check me!");
+ }
+
+ function test_checked() {
+ compare(checkBox.checked, false);
+ compare(checkBox.checkedState, Qt.Unchecked);
+ compare(checkBox.partiallyCheckedEnabled, false);
+
+ checkBox.checked = true;
+ compare(checkBox.checked, true);
+ compare(checkBox.checkedState, Qt.Checked);
+ compare(checkBox.partiallyCheckedEnabled, false);
+
+ checkBox.checkedState = Qt.Unchecked;
+ compare(checkBox.checked, false);
+ compare(checkBox.checkedState, Qt.Unchecked);
+ compare(checkBox.partiallyCheckedEnabled, false);
+
+ checkBox.checkedState = Qt.Checked;
+ compare(checkBox.checked, true);
+ compare(checkBox.checkedState, Qt.Checked);
+ compare(checkBox.partiallyCheckedEnabled, false);
+
+ checkBox.checkedState = Qt.PartiallyChecked;
+ compare(checkBox.checked, false);
+ compare(checkBox.checkedState, Qt.PartiallyChecked);
+ compare(checkBox.partiallyCheckedEnabled, true);
+ }
+
+ function test_clicked() {
+ signalSpy.signalName = "clicked"
+ signalSpy.target = checkBox;
+ compare(signalSpy.count, 0);
+ mouseClick(checkBox, checkBox.x + 1, checkBox.y + 1, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(checkBox.checked, true);
+ compare(checkBox.checkedState, Qt.Checked);
+
+ // Clicking outside should do nothing.
+ mouseClick(checkBox, checkBox.x - 1, checkBox.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(checkBox.checked, true);
+
+ mouseClick(checkBox, checkBox.x, checkBox.y - 1, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(checkBox.checked, true);
+
+ mouseClick(checkBox, checkBox.x - 1, checkBox.y - 1, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(checkBox.checked, true);
+ }
+
+ function test_keyPressed() {
+ checkBox.forceActiveFocus();
+
+ signalSpy.signalName = "clicked";
+ signalSpy.target = checkBox;
+ compare(signalSpy.count, 0);
+
+ // Try cycling through checked and unchecked.
+ var expectedStates = [Qt.Checked, Qt.Unchecked];
+ expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates);
+ for (var i = 0; i < expectedStates.length; ++i) {
+ keyPress(Qt.Key_Space);
+ keyRelease(Qt.Key_Space);
+ compare(signalSpy.count, i + 1);
+ compare(checkBox.checkedState, expectedStates[i]);
+ compare(checkBox.checked, checkBox.checkedState === Qt.Checked);
+ }
+
+ // Try cycling through all three states.
+ checkBox.partiallyCheckedEnabled = true;
+ compare(checkBox.checkedState, Qt.Unchecked);
+ compare(checkBox.checked, false);
+
+ signalSpy.clear();
+ expectedStates = [Qt.Checked, Qt.PartiallyChecked, Qt.Unchecked];
+ expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates);
+ for (i = 0; i < expectedStates.length; ++i) {
+ keyPress(Qt.Key_Space);
+ keyRelease(Qt.Key_Space);
+ compare(signalSpy.count, i + 1);
+ compare(checkBox.checkedState, expectedStates[i]);
+ }
+ }
+
+ function test_exclusiveGroup() {
+ var root = Qt.createQmlObject("import QtQuick 2.1; import QtQuick.Controls 1.0; \n"
+ + "Row { \n"
+ + " property alias checkBox1: checkBox1 \n"
+ + " property alias checkBox2: checkBox2 \n"
+ + " property alias group: group \n"
+ + " ExclusiveGroup { id: group } \n"
+ + " CheckBox { id: checkBox1; checked: true; exclusiveGroup: group } \n"
+ + " CheckBox { id: checkBox2; exclusiveGroup: group } \n"
+ + "}", container, "");
+
+ compare(root.checkBox1.exclusiveGroup, root.group);
+ compare(root.checkBox2.exclusiveGroup, root.group);
+ compare(root.checkBox1.checked, true);
+ compare(root.checkBox2.checked, false);
+
+ root.forceActiveFocus();
+
+ signalSpy.target = root.checkBox2;
+ signalSpy.signalName = "clicked";
+ compare(signalSpy.count, 0);
+
+ mouseClick(root.checkBox2, root.checkBox2.x, root.checkBox2.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(root.checkBox1.checked, false);
+ compare(root.checkBox2.checked, true);
+
+ signalSpy.clear();
+ signalSpy.target = root.checkBox1;
+ signalSpy.signalName = "clicked";
+ compare(signalSpy.count, 0);
+
+ mouseClick(root.checkBox1, root.checkBox1.x, root.checkBox1.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(root.checkBox1.checked, true);
+ compare(root.checkBox2.checked, false);
+
+ ignoreWarning("Cannot have partially checked boxes in an ExclusiveGroup.");
+ root.checkBox1.partiallyCheckedEnabled = true;
+ ignoreWarning("Cannot have partially checked boxes in an ExclusiveGroup.");
+ root.checkBox2.partiallyCheckedEnabled = true;
+
+ // Shouldn't be any warnings, since we're not setting a group.
+ root.checkBox1.exclusiveGroup = null;
+ root.checkBox2.exclusiveGroup = null;
+
+ ignoreWarning("Cannot have partially checked boxes in an ExclusiveGroup.");
+ root.checkBox1.exclusiveGroup = root.group;
+ ignoreWarning("Cannot have partially checked boxes in an ExclusiveGroup.");
+ root.checkBox2.exclusiveGroup = root.group;
+
+ // Shouldn't be any warnings, since we're not setting partiallyCheckedEnabled to true.
+ root.checkBox1.partiallyCheckedEnabled = false;
+ root.checkBox2.partiallyCheckedEnabled = false;
+ }
+ }
+}
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
new file mode 100644
index 00000000..3a0f0568
--- /dev/null
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ComboBox"
+ when:windowShown
+ width:400
+ height:400
+
+ property var model
+ function init() {
+ model = Qt.createQmlObject("import QtQuick 2.1; ListModel {}", testCase, '')
+ model.append({ text: "Banana", color: "Yellow" })
+ model.append({ text: "Apple", color: "Green" })
+ model.append({ text: "Coconut", color: "Brown" })
+ }
+
+ function test_keyupdown() {
+ var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', testCase, '');
+
+ compare(comboBox.currentIndex, 0)
+
+ comboBox.forceActiveFocus()
+
+ keyPress(Qt.Key_Down)
+ compare(comboBox.currentIndex, 1)
+ keyPress(Qt.Key_Down)
+ compare(comboBox.currentIndex, 2)
+ keyPress(Qt.Key_Up)
+ compare(comboBox.currentIndex, 1)
+ }
+
+ function test_textrole() {
+ var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox {}', testCase, '');
+ comboBox.textRole = "text"
+ comboBox.model = model
+ compare(comboBox.currentIndex, 0)
+ compare(comboBox.currentText, "Banana")
+ comboBox.textRole = "color"
+ compare(comboBox.currentText, "Yellow")
+ }
+}
diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml
new file mode 100644
index 00000000..1c62dc50
--- /dev/null
+++ b/tests/auto/controls/data/tst_groupbox.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Components project.
+**
+** $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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+import QtQuick.Controls 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_GroupBox"
+ when:windowShown
+ width:400
+ height:400
+
+ property var groupBox;
+
+ Component {
+ id: groupboxComponent
+ GroupBox {
+ property alias child1: child1
+ property alias child2: child2
+ Column {
+ CheckBox {
+ id: child1
+ text: "checkbox1"
+ }
+ CheckBox {
+ id: child2
+ text: "checkbox2"
+ }
+ }
+ }
+ }
+
+ function init() {
+ groupBox = groupboxComponent.createObject(testCase)
+ }
+
+ function test_checkable() {
+ compare(groupBox.checkable, false)
+ compare(groupBox.child1.enabled, true)
+ compare(groupBox.child2.enabled, true)
+
+ groupBox.checkable = true
+ compare(groupBox.checkable, true)
+ compare(groupBox.checked, true)
+ compare(groupBox.child1.enabled, true)
+ compare(groupBox.child2.enabled, true)
+
+ groupBox.checkable = false
+ compare(groupBox.child1.enabled, true)
+ compare(groupBox.child2.enabled, true)
+ }
+
+ function test_checked() {
+ groupBox.checkable = true
+ groupBox.checked = false
+ compare(groupBox.checked, false)
+ compare(groupBox.child1.enabled, false)
+ compare(groupBox.child2.enabled, false)
+
+ groupBox.checked = true
+ compare(groupBox.checked, true)
+ compare(groupBox.child1.enabled, true)
+ compare(groupBox.child2.enabled, true)
+ }
+}
diff --git a/tests/auto/controls/data/tst_label.qml b/tests/auto/controls/data/tst_label.qml
new file mode 100644
index 00000000..2f2591f8
--- /dev/null
+++ b/tests/auto/controls/data/tst_label.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_Label"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createLabel() {
+ var label = Qt.createQmlObject('import QtQuick.Controls 1.0; Label {}', testCase, '');
+ }
+}
diff --git a/tests/auto/controls/data/tst_menu.qml b/tests/auto/controls/data/tst_menu.qml
new file mode 100644
index 00000000..3c109347
--- /dev/null
+++ b/tests/auto/controls/data/tst_menu.qml
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+import QtQuick.Controls 1.0
+
+TestCase {
+ id: testcase
+ name: "Tests_Menu"
+ when: windowShown
+ width: 300; height: 300
+
+ property var itemsText: [ "apple", "banana", "clementine", "dragon fruit" ]
+
+ property var menu
+ property var menuItem
+
+ SignalSpy {
+ id: menuSpy
+ target: testcase.menu
+ signalName: "__selectedIndexChanged"
+ }
+
+ SignalSpy {
+ id: menuItemSpy
+ target: testcase.menuItem
+ signalName: "triggered"
+ }
+
+ Component {
+ id: creationComponent
+ Menu {
+ MenuItem { text: "apple" }
+ MenuItem { text: "banana" }
+ MenuItem { text: "clementine" }
+ MenuItem { text: "dragon fruit" }
+ }
+ }
+
+ function init() {
+ menu = creationComponent.createObject(testcase)
+ }
+
+ function cleanup() {
+ menuSpy.clear()
+ menuItemSpy.clear()
+ menu.destroy()
+ }
+
+ function test_creation() {
+ compare(menu.items.length, testcase.itemsText.length)
+ for (var i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].text, testcase.itemsText[i])
+ }
+
+ Component {
+ id: modelCreationComponent
+ Menu {
+ id: modelMenu
+ Instantiator {
+ model: itemsText
+ MenuItem {
+ text: modelData
+ }
+ onObjectAdded: modelMenu.insertItem(index, object)
+ }
+
+ }
+ }
+
+ function test_modelCreation() {
+ var menu = modelCreationComponent.createObject(testcase)
+ compare(menu.items.length, testcase.itemsText.length)
+ for (var i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].text, testcase.itemsText[i])
+ menu.destroy()
+ }
+
+ function test_trigger() {
+ menuItem = menu.items[2]
+ menuItem.trigger()
+
+ compare(menuItemSpy.count, 1)
+ compare(menuSpy.count, 1)
+ compare(menu.__selectedIndex, 2)
+ }
+
+ function test_check() {
+ for (var i = 0; i < menu.items.length; i++)
+ menu.items[i].checkable = true
+
+ menuItem = menu.items[2]
+ compare(menuItem.checkable, true)
+ compare(menuItem.checked, false)
+ menuItem.trigger()
+
+ for (i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].checked, i === 2)
+
+ menuItem = menu.items[3]
+ compare(menuItem.checkable, true)
+ compare(menuItem.checked, false)
+ menuItem.trigger()
+
+ for (i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].checked, i === 2 || i === 3)
+
+ compare(menuItemSpy.count, 2)
+ compare(menuSpy.count, 2)
+ compare(menu.__selectedIndex, 3)
+ }
+
+ ExclusiveGroup { id: eg }
+
+ function test_exclusive() {
+ for (var i = 0; i < menu.items.length; i++) {
+ menu.items[i].checkable = true
+ menu.items[i].exclusiveGroup = eg
+ }
+
+ menuItem = menu.items[2]
+ compare(menuItem.checkable, true)
+ compare(menuItem.checked, false)
+ menuItem.trigger()
+
+ for (i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].checked, i === 2)
+
+ menuItem = menu.items[3]
+ compare(menuItem.checkable, true)
+ compare(menuItem.checked, false)
+ menuItem.trigger()
+
+ for (i = 0; i < menu.items.length; i++)
+ compare(menu.items[i].checked, i === 3)
+
+ compare(menuItemSpy.count, 2)
+ compare(menuSpy.count, 2)
+ compare(menu.__selectedIndex, 3)
+ }
+
+ function test___selectedIndex() {
+ for (var i = 0; i < menu.items.length; i++)
+ menu.items[i].checkable = true
+
+ menu.__selectedIndex = 3
+ compare(menu.__selectedIndex, 3)
+ verify(!menu.items[menu.__selectedIndex].checked)
+
+ menu.items[2].trigger()
+ compare(menu.__selectedIndex, 2)
+ verify(menu.items[menu.__selectedIndex].checked)
+ }
+
+ function test_dynamicItems() {
+ menu.clear()
+ compare(menu.items.length, 0)
+ var n = 6
+ var separatorIdx = 4
+ var submenuIdx = 5
+ for (var i = 0; i < n; ++i) {
+ if (i === separatorIdx)
+ var item = menu.addSeparator()
+ else if (i === submenuIdx)
+ item = menu.addMenu("Submenu")
+ else
+ item = menu.addItem("Item " + i)
+ }
+ compare(menu.items.length, n)
+
+ for (i = 0; i < n; ++i) {
+ item = menu.items[i]
+ compare(item.type, i === submenuIdx ? MenuItemType.Menu :
+ i === separatorIdx ? MenuItemType.Separator :
+ MenuItemType.Item)
+ if (i === submenuIdx)
+ compare(item.title, "Submenu")
+ else if (i !== separatorIdx)
+ compare(item.text, "Item " + i)
+ }
+ }
+}
diff --git a/tests/auto/controls/data/tst_menubar.qml b/tests/auto/controls/data/tst_menubar.qml
new file mode 100644
index 00000000..80699d33
--- /dev/null
+++ b/tests/auto/controls/data/tst_menubar.qml
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_MenuBar"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createMenuBar() {
+ var menuBar = Qt.createQmlObject('import QtQuick.Controls 1.0; MenuBar {}', testCase, '');
+ }
+}
diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_pagestack.qml
new file mode 100644
index 00000000..f0323571
--- /dev/null
+++ b/tests/auto/controls/data/tst_pagestack.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+import QtQuick.Controls 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_PageStack"
+ when: windowShown
+ width: 400
+ height: 400
+
+ Item { id: anItem }
+ Component {
+ id: pageComponent
+ Item {}
+ }
+
+ Component {
+ id: stackComponent
+ PageStack {}
+ }
+
+ function test_pagestack() {
+ var component = stackComponent
+ var stack = component.createObject(testCase);
+ verify (stack !== null, "pagestack created is null")
+ verify (stack.depth === 0)
+ stack.push(anItem)
+ verify (stack.depth === 1)
+ stack.push(anItem)
+ verify (stack.depth === 2)
+ stack.pop()
+ verify (stack.depth === 1)
+ stack.push(pageComponent)
+ verify (stack.depth === 2)
+ }
+}
diff --git a/tests/auto/controls/data/tst_progressbar.qml b/tests/auto/controls/data/tst_progressbar.qml
new file mode 100644
index 00000000..b68a592a
--- /dev/null
+++ b/tests/auto/controls/data/tst_progressbar.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ProgressBar"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_minimumvalue() {
+ var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, '');
+
+ progressBar.minimumValue = 5
+ progressBar.maximumValue = 10
+ progressBar.value = 2
+ compare(progressBar.minimumValue, 5)
+ compare(progressBar.value, 5)
+
+ progressBar.minimumValue = 7
+ compare(progressBar.value, 7)
+ }
+
+ function test_maximumvalue() {
+ var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, '');
+
+ progressBar.minimumValue = 5
+ progressBar.maximumValue = 10
+ progressBar.value = 15
+ compare(progressBar.maximumValue, 10)
+ compare(progressBar.value, 10)
+
+ progressBar.maximumValue = 8
+ compare(progressBar.value, 8)
+ }
+
+ function test_invalidMinMax() {
+ var progressBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {}', testCase, '');
+
+ // minimumValue has priority over maximum if they are inconsistent
+
+ progressBar.minimumValue = 10
+ progressBar.maximumValue = 10
+ compare(progressBar.value, progressBar.minimumValue)
+
+ progressBar.value = 17
+ compare(progressBar.value, progressBar.minimumValue)
+
+ progressBar.maximumValue = 5
+ compare(progressBar.value, progressBar.minimumValue)
+
+ progressBar.value = 12
+ compare(progressBar.value, progressBar.minimumValue)
+
+ var progressBar2 = Qt.createQmlObject('import QtQuick.Controls 1.0; ProgressBar {minimumValue: 10; maximumValue: 4; value: 5}', testCase, '');
+ compare(progressBar.value, progressBar.minimumValue)
+ }
+
+ function test_initialization_order()
+ {
+ var spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {maximumValue: 100; value: 50}",
+ testCase, '')
+ compare(spinbox.value, 50);
+
+ spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar {" +
+ "value: 50; maximumValue: 100}",
+ testCase, '')
+ compare(spinbox.value, 50);
+
+ spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { minimumValue: -50 ; value:-10}",
+ testCase, '')
+ compare(spinbox.value, -10);
+
+ spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; ProgressBar { value:-10; minimumValue: -50}",
+ testCase, '')
+ compare(spinbox.value, -10);
+ }
+}
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
new file mode 100644
index 00000000..c2e6bffd
--- /dev/null
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+Item {
+ id: container
+ width: 400
+ height: 400
+
+ TestCase {
+ id: testCase
+ name: "Tests_RadioButton"
+ when: windowShown
+ width: 400
+ height: 400
+
+ property var radioButton
+
+ SignalSpy {
+ id: signalSpy
+ }
+
+ function init() {
+ radioButton = Qt.createQmlObject('import QtQuick.Controls 1.0; RadioButton {}', container, '');
+ }
+
+ function cleanup() {
+ signalSpy.clear();
+ }
+
+ function test_createRadioButton() {
+ compare(radioButton.checked, false);
+ compare(radioButton.text, "");
+ }
+
+ function test_defaultConstructed() {
+ compare(radioButton.checked, false);
+ compare(radioButton.text, "");
+ }
+
+ function test_text() {
+ compare(radioButton.text, "");
+
+ radioButton.text = "Check me!";
+ compare(radioButton.text, "Check me!");
+ }
+
+ function test_checked() {
+ compare(radioButton.checked, false);
+
+ radioButton.checked = true;
+ compare(radioButton.checked, true);
+
+ radioButton.checked = false;
+ compare(radioButton.checked, false);
+ }
+
+ function test_clicked() {
+ signalSpy.signalName = "clicked"
+ signalSpy.target = radioButton;
+ compare(signalSpy.count, 0);
+ mouseClick(radioButton, radioButton.x, radioButton.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(radioButton.checked, true);
+
+ // Clicking outside should do nothing.
+ mouseClick(radioButton, radioButton.x - 1, radioButton.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(radioButton.checked, true);
+
+ mouseClick(radioButton, radioButton.x, radioButton.y - 1, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(radioButton.checked, true);
+
+ mouseClick(radioButton, radioButton.x - 1, radioButton.y - 1, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(radioButton.checked, true);
+ }
+
+ function test_keyPressed() {
+ radioButton.forceActiveFocus();
+
+ signalSpy.signalName = "clicked";
+ signalSpy.target = radioButton;
+ compare(signalSpy.count, 0);
+
+ // Try cycling through checked and unchecked.
+ var expectedStates = [true, false];
+ expectedStates = expectedStates.concat(expectedStates, expectedStates, expectedStates);
+ for (var i = 0; i < expectedStates.length; ++i) {
+ keyPress(Qt.Key_Space);
+ keyRelease(Qt.Key_Space);
+ compare(signalSpy.count, i + 1);
+ compare(radioButton.checked, expectedStates[i]);
+ }
+ }
+
+ function test_exclusiveGroup() {
+ var root = Qt.createQmlObject("import QtQuick 2.1; import QtQuick.Controls 1.0; \n"
+ + "Row { \n"
+ + " property alias radioButton1: radioButton1 \n"
+ + " property alias radioButton2: radioButton2 \n"
+ + " property alias group: group \n"
+ + " ExclusiveGroup { id: group } \n"
+ + " RadioButton { id: radioButton1; checked: true; exclusiveGroup: group } \n"
+ + " RadioButton { id: radioButton2; exclusiveGroup: group } \n"
+ + "}", container, "");
+
+ compare(root.radioButton1.exclusiveGroup, root.group);
+ compare(root.radioButton2.exclusiveGroup, root.group);
+ compare(root.radioButton1.checked, true);
+ compare(root.radioButton2.checked, false);
+
+ root.forceActiveFocus();
+
+ signalSpy.target = root.radioButton2;
+ signalSpy.signalName = "clicked";
+ compare(signalSpy.count, 0);
+
+ mouseClick(root.radioButton2, root.radioButton2.x, root.radioButton2.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(root.radioButton1.checked, false);
+ compare(root.radioButton2.checked, true);
+
+ signalSpy.clear();
+ signalSpy.target = root.radioButton1;
+ signalSpy.signalName = "clicked";
+ compare(signalSpy.count, 0);
+
+ mouseClick(root.radioButton1, root.radioButton1.x, root.radioButton1.y, Qt.LeftButton);
+ compare(signalSpy.count, 1);
+ compare(root.radioButton1.checked, true);
+ compare(root.radioButton2.checked, false);
+ }
+ }
+}
diff --git a/tests/auto/qtdesktop/data/tst_rangemodel.qml b/tests/auto/controls/data/tst_rangemodel.qml
index 259c884c..52697140 100644
--- a/tests/auto/qtdesktop/data/tst_rangemodel.qml
+++ b/tests/auto/controls/data/tst_rangemodel.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,7 +38,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
import QtTest 1.0
TestCase {
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml
new file mode 100644
index 00000000..e1d9f1bf
--- /dev/null
+++ b/tests/auto/controls/data/tst_rowlayout.qml
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+Item {
+ id: container
+ width: 200
+ height: 200
+ TestCase {
+ id: testCase
+ name: "Tests_RowLayout"
+ when: windowShown
+ width: 200
+ height: 200
+
+ function test_fixedAndExpanding() {
+ var test_layoutStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Layouts 1.0; \
+ RowLayout { \
+ id: row; \
+ width: 15; \
+ spacing: 0; \
+ property alias r1: _r1; \
+ Rectangle { \
+ id: _r1; \
+ width: 5; \
+ height: 10; \
+ color: "#8080ff"; \
+ Layout.fillWidth: false \
+ } \
+ property alias r2: _r2; \
+ Rectangle { \
+ id: _r2; \
+ width: 10; \
+ height: 20; \
+ color: "#c0c0ff"; \
+ Layout.fillWidth: true \
+ } \
+ } '
+
+ var lay = Qt.createQmlObject(test_layoutStr, container, '');
+ tryCompare(lay, 'implicitWidth', 15);
+ compare(lay.implicitHeight, 20);
+ compare(lay.height, 20);
+ lay.width = 30
+ compare(lay.r1.x, 0);
+ compare(lay.r1.width, 5);
+ compare(lay.r2.x, 5);
+ compare(lay.r2.width, 25);
+ }
+
+ function test_allExpanding() {
+ var test_layoutStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Layouts 1.0; \
+ RowLayout { \
+ id: row; \
+ width: 15; \
+ spacing: 0; \
+ property alias r1: _r1; \
+ Rectangle { \
+ id: _r1; \
+ width: 5; \
+ height: 10; \
+ color: "#8080ff"; \
+ Layout.fillWidth: true \
+ } \
+ property alias r2: _r2; \
+ Rectangle { \
+ id: _r2; \
+ width: 10; \
+ height: 20; \
+ color: "#c0c0ff"; \
+ Layout.fillWidth: true \
+ } \
+ } '
+
+ var tmp = Qt.createQmlObject(test_layoutStr, container, '');
+ tryCompare(tmp, 'implicitWidth', 15);
+ compare(tmp.implicitHeight, 20);
+ compare(tmp.height, 20);
+ tmp.width = 30
+ compare(tmp.r1.width, 10);
+ compare(tmp.r2.width, 20);
+ }
+
+ function test_initialNestedLayouts() {
+ var test_layoutStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Layouts 1.0; \
+ ColumnLayout { \
+ id : col; \
+ property alias row: _row; \
+ objectName: "col"; \
+ anchors.fill: parent; \
+ RowLayout { \
+ id : _row; \
+ property alias r1: _r1; \
+ property alias r2: _r2; \
+ objectName: "row"; \
+ spacing: 0; \
+ Rectangle { \
+ id: _r1; \
+ color: "red"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ } \
+ Rectangle { \
+ id: _r2; \
+ color: "green"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ Layout.fillWidth: true; \
+ } \
+ } \
+ } '
+ var col = Qt.createQmlObject(test_layoutStr, container, '');
+ tryCompare(col, 'width', 200);
+ tryCompare(col.row, 'width', 200);
+ tryCompare(col.row.r1, 'width', 50);
+ tryCompare(col.row.r2, 'width', 150);
+ }
+
+ function test_implicitSize() {
+ var test_layoutStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Layouts 1.0; \
+ RowLayout { \
+ id: row; \
+ objectName: "row"; \
+ spacing: 0; \
+ height: 30; \
+ anchors.left: parent.left; \
+ anchors.right: parent.right; \
+ Rectangle { \
+ color: "red"; \
+ height: 2; \
+ Layout.minimumWidth: 50; \
+ } \
+ Rectangle { \
+ color: "green"; \
+ width: 10; \
+ Layout.minimumHeight: 4; \
+ } \
+ Rectangle { \
+ implicitWidth: 1000; \
+ Layout.maximumWidth: 40; \
+ implicitHeight: 6 \
+ } \
+ } '
+ var row = Qt.createQmlObject(test_layoutStr, container, '');
+ compare(row.implicitWidth, 50 + 10 + 40);
+ compare(row.implicitHeight, 6);
+ }
+
+ function test_countGeometryChanges() {
+ var test_layoutStr =
+ 'import QtQuick 2.1; \
+ import QtQuick.Layouts 1.0; \
+ ColumnLayout { \
+ id : col; \
+ property alias row: _row; \
+ objectName: "col"; \
+ anchors.fill: parent; \
+ RowLayout { \
+ id : _row; \
+ property alias r1: _r1; \
+ property alias r2: _r2; \
+ objectName: "row"; \
+ spacing: 0; \
+ property int counter : 0; \
+ onWidthChanged: { ++counter; } \
+ Rectangle { \
+ id: _r1; \
+ color: "red"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ property int counter : 0; \
+ onWidthChanged: { ++counter; } \
+ Layout.fillWidth: true; \
+ } \
+ Rectangle { \
+ id: _r2; \
+ color: "green"; \
+ implicitWidth: 50; \
+ implicitHeight: 20; \
+ property int counter : 0; \
+ onWidthChanged: { ++counter; } \
+ Layout.fillWidth: true; \
+ } \
+ } \
+ } '
+ var col = Qt.createQmlObject(test_layoutStr, container, '');
+ compare(col.width, 200);
+ compare(col.row.width, 200);
+ compare(col.row.r1.width, 100);
+ compare(col.row.r2.width, 100);
+ compare(col.row.r1.counter, 1);
+ compare(col.row.r2.counter, 1);
+ verify(col.row.counter <= 2);
+ }
+ }
+}
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
new file mode 100644
index 00000000..ee66939e
--- /dev/null
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+import QtQuick.Controls 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ScrollView"
+ when:windowShown
+ width:400
+ height:400
+
+
+ TextArea { id: textArea }
+
+ Item { id: bigItem }
+
+ Component {
+ id: scrollViewComponent
+ ScrollView { }
+ }
+
+ function test_scroll() {
+ var component = scrollViewComponent
+ var scrollView = component.createObject(testCase);
+ verify(scrollView !== null, "table created is null")
+
+ scrollView.contentItem = bigItem
+ scrollView.visible = true
+ verify(scrollView.flickableItem !== null, "flickableItem should not be null")
+ verify(scrollView.flickableItem !== scrollView.contentItem)
+ verify(scrollView.flickableItem.contentHeight === 0, "ContentHeight not set")
+
+ bigItem.height = 222
+ bigItem.width = 333
+
+ verify(scrollView.flickableItem.contentHeight === 222, "ContentHeight not set")
+ verify(scrollView.flickableItem.contentWidth === 333, "ContentHeight not set")
+
+ scrollView.flickableItem.contentY = 200
+ verify(scrollView.flickableItem.contentY === 200, "ContentY not set")
+
+ scrollView.flickableItem.contentX = 300
+ verify(scrollView.flickableItem.contentX === 300, "ContentX not set")
+ }
+
+ function test_viewport() {
+ var component = scrollViewComponent
+ var scrollView = component.createObject(testCase);
+ verify(scrollView !== null, "table created is null")
+
+ scrollView.forceActiveFocus();
+ verify(scrollView.viewport, "Viewport not defined")
+ verify(!scrollView.contentItem, "contentItem should be null")
+ verify(!scrollView.flickableItem, "flickableItem should be null")
+ verify(!scrollView.frameVisible, "Frame should be false")
+
+ scrollView.contentItem = textArea
+ verify(scrollView.viewport, "Viewport should be defined")
+ verify(scrollView.contentItem, "contentItem should not be null")
+ verify(scrollView.flickableItem, "flickableItem should not be null")
+ verify(scrollView.flickableItem.contentHeight === textArea.height, "Content height not set")
+
+ var prevViewportWidth = scrollView.viewport.width
+ scrollView.frameVisible = true
+ verify(scrollView.frameVisible, "Frame should be true")
+ verify(scrollView.viewport.width < prevViewportWidth, "Viewport should be smaller with frame")
+ }
+}
diff --git a/tests/auto/qtdesktop/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml
index 2b1ea40e..30c234a0 100644
--- a/tests/auto/qtdesktop/data/tst_shortcuts.qml
+++ b/tests/auto/controls/data/tst_shortcuts.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,10 +38,10 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
import QtTest 1.0
-
-import QtDesktop 1.0
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
TestCase {
id: testCase
@@ -52,11 +52,6 @@ TestCase {
property var rootObject
- // Style item to find out if we are on mac
- StyleItem {
- id: styleItem
- }
-
function initTestCase() {
var component = Qt.createComponent("shortcut/shortcuts.qml");
compare(component.status, Component.Ready)
@@ -65,10 +60,6 @@ TestCase {
rootObject.forceActiveFocus();
}
- function cleanupTestCase() {
- wait(100) //wait for a short while to make sure no leaked textures
- }
-
function test_shortcut_data() {
return [
{ key: Qt.Key_A, modifier: Qt.NoModifier, expected: "a pressed" },
@@ -82,7 +73,7 @@ TestCase {
{ key: Qt.Key_D, modifier: Qt.AltModifier, expected: "alt d pressed" },
{ key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" },
// on mac we don't have mnemonics
- { key: Qt.Key_T, modifier: Qt.AltModifier, expected: styleItem.style === "mac" ? "no key press" : "alt t pressed" },
+ { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "mac" ? "no key press" : "alt t pressed" },
]
}
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
new file mode 100644
index 00000000..305b0f57
--- /dev/null
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_Slider"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_vertical() {
+ var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {}', testCase, '');
+ verify(slider.height < slider.width)
+
+ slider.orientation = Qt.Vertical;
+ verify(slider.height > slider.width)
+ }
+
+ function test_minimumvalue() {
+ var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {}', testCase, '');
+
+ slider.minimumValue = 5
+ slider.maximumValue = 10
+ slider.value = 2
+ compare(slider.minimumValue, 5)
+ compare(slider.value, 5)
+ }
+
+ function test_maximumvalue() {
+ var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {}', testCase, '');
+
+ slider.minimumValue = 5
+ slider.maximumValue = 10
+ slider.value = 15
+ compare(slider.maximumValue, 10)
+ compare(slider.value, 10)
+ }
+}
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
new file mode 100644
index 00000000..5994b451
--- /dev/null
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+Item {
+ id: container
+ width: 300; height: 300
+
+ TestCase {
+ id: testcase
+ name: "Tests_SpinBox"
+ when: windowShown
+
+ property int arrowMargin: 4 // the mouse areas for the up/down arrows have margins
+ property point mainCoord: "0,0"
+ property point upCoord: "0,0"
+ property point downCoord: "0,0"
+
+ function test_increment_key() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {maximumValue: 50}', container, '')
+ spinbox.forceActiveFocus()
+
+ compare(spinbox.maximumValue, 50)
+ spinbox.value = spinbox.maximumValue - 3
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, spinbox.maximumValue - 2)
+ keyPress(Qt.Key_Up)
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, spinbox.maximumValue)
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, spinbox.maximumValue)
+ }
+
+ function test_decrement_key() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {minimumValue: 10}', container, '')
+ spinbox.forceActiveFocus()
+
+ compare(spinbox.minimumValue, 10)
+ spinbox.value = spinbox.minimumValue + 3
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, spinbox.minimumValue + 2)
+ keyPress(Qt.Key_Down)
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, spinbox.minimumValue)
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, spinbox.minimumValue)
+ }
+
+ function test_increment_mouse() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {maximumValue: 50}', container, '')
+ spinbox.forceActiveFocus()
+ setCoordinates(spinbox)
+
+ spinbox.value = spinbox.maximumValue - 3
+ mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.maximumValue - 2)
+ mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
+ mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.maximumValue)
+ mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.maximumValue)
+ }
+
+ function test_decrement_mouse() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {minimumValue: 10}', container, '')
+ spinbox.forceActiveFocus()
+ setCoordinates(spinbox)
+
+ spinbox.value = spinbox.minimumValue + 3
+ mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.minimumValue + 2)
+ mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
+ mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.minimumValue)
+ mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
+ compare(spinbox.value, spinbox.minimumValue)
+ }
+
+ function test_move_mouse() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.forceActiveFocus()
+ setCoordinates(spinbox)
+
+ mouseMove(spinbox, mainCoord.x, mainCoord.y)
+ compare(spinbox.__containsMouse, true)
+ compare(spinbox.__upHovered, false)
+ compare(spinbox.__downHovered, false)
+
+ mouseMove(spinbox.parent, upCoord.x, upCoord.y)
+ compare(spinbox.__upHovered, true)
+ compare(spinbox.__downHovered, false)
+
+ mouseMove(spinbox, downCoord.x, downCoord.y)
+ compare(spinbox.__upHovered, false)
+ compare(spinbox.__downHovered, true)
+
+ mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2)
+ compare(spinbox.__containsMouse, false)
+ compare(spinbox.__upHovered, false)
+ compare(spinbox.__downHovered, false)
+ }
+
+ function test_maxvalue() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.value = spinbox.maximumValue + 1
+ compare(spinbox.value, spinbox.maximumValue)
+
+ spinbox.maximumValue = 0;
+ spinbox.minimumValue = 0;
+ spinbox.value = 10;
+ compare(spinbox.value, 0)
+
+ spinbox.maximumValue = 5;
+ spinbox.minimumValue = 0;
+ spinbox.value = 10;
+ compare(spinbox.value, 5)
+ }
+
+ function test_minvalue() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.value = spinbox.minimumValue - 1
+ compare(spinbox.value, spinbox.minimumValue)
+
+ spinbox.maximumValue = 0;
+ spinbox.minimumValue = 6;
+ spinbox.value = 3;
+ compare(spinbox.value, 6)
+
+ spinbox.maximumValue = 10;
+ spinbox.minimumValue = 6;
+ spinbox.value = 0;
+ compare(spinbox.value, 6)
+ }
+
+ function test_nanvalue() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ // It is not possible to set a string to the spinbox value.
+ // Nan is a valid number though
+ spinbox.value = NaN
+ compare(spinbox.value, NaN)
+ compare(spinbox.__text, "nan")
+ }
+
+ function test_decimals() {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+
+ spinbox.decimals = 0
+ spinbox.value = 1.00001
+ compare(spinbox.value, 1)
+ compare(spinbox.__text, "1")
+
+ spinbox.decimals = 1
+ spinbox.value = 1.00001
+ compare(spinbox.value, 1)
+ compare(spinbox.__text, "1.0")
+ spinbox.value = 1.1
+ compare(spinbox.value, 1.1)
+ compare(spinbox.__text, "1.1")
+
+ spinbox.decimals = 5
+ spinbox.value = 1.00001
+ compare(spinbox.value, 1.00001)
+ compare(spinbox.__text, "1.00001")
+
+ spinbox.decimals = 6
+ compare(spinbox.value, 1.00001)
+ compare(spinbox.__text, "1.000010")
+ }
+
+ function test_stepsize()
+ {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.forceActiveFocus()
+
+ spinbox.stepSize = 2
+ spinbox.value = 10
+
+ compare(spinbox.value, 10)
+
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, 10 + spinbox.stepSize)
+
+ var previousValue = spinbox.value
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, previousValue - spinbox.stepSize)
+ }
+
+ function test_negativeStepSize()
+ {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.forceActiveFocus()
+
+ spinbox.minimumValue = -50
+ spinbox.maximumValue = 50
+
+ spinbox.stepSize = -2
+ spinbox.value = 5
+
+ compare(spinbox.value, 5)
+
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, 5 + spinbox.stepSize)
+
+ var previousValue = spinbox.value
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, previousValue - spinbox.stepSize)
+
+ // test on the edges
+
+ spinbox.value = -49
+ keyPress(Qt.Key_Up)
+ compare(spinbox.value, spinbox.minimumValue)
+
+ spinbox.value = 49
+ keyPress(Qt.Key_Down)
+ compare(spinbox.value, spinbox.maximumValue)
+ }
+
+ function test_initialization_order()
+ {
+ var spinbox = Qt.createQmlObject("import QtQuick.Controls 1.0; SpinBox { id: spinbox;" +
+ "maximumValue: 2000; value: 1000; implicitWidth:80}",
+ container, '')
+ compare(spinbox.value, 1000);
+
+ spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox { minimumValue: -1000 ; value:-1000}',
+ container, '')
+ compare(spinbox.value, -1000);
+ }
+
+ function test_ImplicitSize() // Verify if we correctly grow and shrink depending on contents
+ {
+ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.0; SpinBox {}', container, '')
+ spinbox.forceActiveFocus()
+ spinbox.minimumValue = -50
+ spinbox.maximumValue = 50
+
+ var oldSize = spinbox.implicitWidth
+ spinbox.maximumValue = 5000
+ verify(oldSize < spinbox.implicitWidth)
+ oldSize = spinbox.implicitWidth
+ spinbox.maximumValue = 50
+ verify(oldSize > spinbox.implicitWidth)
+
+ oldSize = spinbox.implicitWidth
+ spinbox.minimumValue = -5000
+ verify(oldSize < spinbox.implicitWidth)
+
+ spinbox.minimumValue = -50
+ oldSize = spinbox.implicitWidth
+ spinbox.minimumValue = -5000
+ verify(oldSize < spinbox.implicitWidth)
+
+ spinbox.minimumValue = -50
+ oldSize = spinbox.implicitWidth
+ spinbox.minimumValue = -5000
+ verify(oldSize < spinbox.implicitWidth)
+
+ spinbox.minimumValue = -50
+ spinbox.decimals = 0
+ oldSize = spinbox.implicitWidth
+ spinbox.decimals = 4
+ verify(oldSize < spinbox.implicitWidth)
+ }
+
+ function setCoordinates(item)
+ {
+ mainCoord.x = item.x + 1
+ mainCoord.y = item.y + 1
+ upCoord.x = item.x + item.width - arrowMargin
+ upCoord.y = item.y + arrowMargin
+ downCoord.x = upCoord.x
+ downCoord.y = item.y + item.height - arrowMargin
+ }
+ }
+}
+
diff --git a/tests/auto/controls/data/tst_splitview.qml b/tests/auto/controls/data/tst_splitview.qml
new file mode 100644
index 00000000..fee25f3e
--- /dev/null
+++ b/tests/auto/controls/data/tst_splitview.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+import QtQuick.Controls 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_SplitView"
+ when: windowShown
+ width: 400
+ height: 400
+
+
+ Component {
+ id: splitView
+ SplitView { Item {} Item {} }
+ }
+
+ function test_splitView() {
+ var component = splitView
+ var view = component.createObject(testCase);
+ verify (view !== null, "splitview created is null")
+ verify (view.orientation === Qt.Horizontal)
+ verify (view.__items.length === 2)
+ }
+
+}
diff --git a/tests/auto/qtdesktop/data/tst_button.qml b/tests/auto/controls/data/tst_stack.qml
index 94e627a9..f51251e9 100644
--- a/tests/auto/qtdesktop/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_stack.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,32 +38,28 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
import QtTest 1.0
TestCase {
id: testCase
- name: "Tests_Button"
+ name: "Tests_Stack"
when:windowShown
width:400
height:400
- function cleanupTestCase() {
- wait(100) //wait for a short while to make sure no leaked textures
+ function test_index() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property int index: Stack.index }', testCase, '');
+ compare(item.index, -1);
}
- function test_defaultbutton() {
- var tmp = Qt.createQmlObject('import QtDesktop 1.0; Button {id: button1}', testCase, '');
- compare(tmp.defaultbutton, false);
+ function test_status() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property int status: Stack.status }', testCase, '');
+ compare(item.status, 0); // Stack.Inactive
}
- function test_text() {
- var tmp1 = Qt.createQmlObject('import QtDesktop 1.0; Button {id: button2_1}', testCase, '');
- compare(tmp1.text, "");
- tmp1.text = "Hello";
- compare(tmp1.text, "Hello");
-
- var tmp2 = Qt.createQmlObject('import QtDesktop 1.0; Button {id: button2_2; text: "Hello"}', testCase, '');
- compare(tmp2.text, "Hello");
+ function test_pageStack() {
+ var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property PageStack pageStack: Stack.pageStack }', testCase, '');
+ compare(item.pageStack, null);
}
}
diff --git a/tests/auto/controls/data/tst_statusbar.qml b/tests/auto/controls/data/tst_statusbar.qml
new file mode 100644
index 00000000..f85195bd
--- /dev/null
+++ b/tests/auto/controls/data/tst_statusbar.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_StatusBar"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createStatusBar() {
+ var statusBar = Qt.createQmlObject('import QtQuick.Controls 1.0; StatusBar {}', testCase, '');
+ }
+}
+
diff --git a/tests/auto/controls/data/tst_tab.qml b/tests/auto/controls/data/tst_tab.qml
new file mode 100644
index 00000000..d839ff41
--- /dev/null
+++ b/tests/auto/controls/data/tst_tab.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_Tab"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createTab() {
+ var tab = Qt.createQmlObject('import QtQuick.Controls 1.0; Tab {}', testCase, '');
+ }
+}
+
diff --git a/tests/auto/qtdesktop/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml
index fde2c24e..475d2dd9 100644
--- a/tests/auto/qtdesktop/data/tst_tableview.qml
+++ b/tests/auto/controls/data/tst_tableview.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,10 +38,10 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick 2.1
import QtTest 1.0
-import QtDesktop 1.0
-import QtDesktopTest 1.0
+import QtQuick.Controls 1.0
+import QtQuickControlsTests 1.0
TestCase {
id: testCase
@@ -67,8 +67,8 @@ TestCase {
verify(table !== null, "table created is null")
table.forceActiveFocus();
- verify(table.currentItem !== undefined, "No current item found")
- var label = findAChild(table.currentItem, "label")
+ verify(table.currentRowItem !== undefined, "No current item found")
+ var label = findAChild(table.currentRowItem, "label")
verify(label !== undefined)
compare(label.text, data.expected.toString());
}
@@ -85,8 +85,8 @@ TestCase {
var valuefrommodel = table.model.value;
verify(valuefrommodel !== undefined, "The model has no defined value")
- verify(table.currentItem !== undefined, "No current item found")
- var label = findAChild(table.currentItem, "label")
+ verify(table.currentRowItem !== undefined, "No current item found")
+ var label = findAChild(table.currentRowItem, "label")
verify(label !== undefined)
compare(label.text, valuefrommodel.toString());
}
@@ -100,14 +100,14 @@ TestCase {
table.forceActiveFocus();
// to go to next row (this model has 10 rows)
- table.incrementCurrentIndex()
+ table.__incrementCurrentIndex()
// read data from the model directly
- var valuefrommodel = table.model.dataAt(table.currentIndex)
+ var valuefrommodel = table.model.dataAt(table.currentRow)
verify(valuefrommodel !== undefined, "The model has no defined value")
- verify(table.currentItem !== undefined, "No current item found")
- var label = findAChild(table.currentItem, "label")
+ verify(table.currentRowItem !== undefined, "No current item found")
+ var label = findAChild(table.currentRowItem, "label")
verify(label !== undefined)
compare(label.text, valuefrommodel.toString())
}
@@ -128,15 +128,15 @@ TestCase {
table.forceActiveFocus();
// to go to next row (this model has 3 rows, read the second row)
- table.incrementCurrentIndex()
+ table.__incrementCurrentIndex()
- verify(table.currentItem !== undefined, "No current item found")
- var label = findAChild(table.currentItem, "label")
+ verify(table.currentRowItem !== undefined, "No current item found")
+ var label = findAChild(table.currentRowItem, "label")
verify(label !== undefined)
compare(label.text, data.expected.toString());
}
- // In TableView, drawn text = table.currentItem.children[1].children[1].itemAt(0).children[0].children[0].text
+ // In TableView, drawn text = table.currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text
function findAChild(item, name)
{
diff --git a/tests/auto/controls/data/tst_tableviewcolumn.qml b/tests/auto/controls/data/tst_tableviewcolumn.qml
new file mode 100644
index 00000000..37468af4
--- /dev/null
+++ b/tests/auto/controls/data/tst_tableviewcolumn.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_TableViewColumn"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createTableViewColumn() {
+ var tableViewColumn = Qt.createQmlObject('import QtQuick.Controls 1.0; TableViewColumn {}', testCase, '');
+ }
+}
+
diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml
new file mode 100644
index 00000000..7bf9a00f
--- /dev/null
+++ b/tests/auto/controls/data/tst_tabview.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_TabView"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createTabView() {
+ var tabView = Qt.createQmlObject('import QtQuick.Controls 1.0; TabView {}', testCase, '');
+ }
+
+ function test_repeater() {
+ var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { } } }', testCase, '');
+ compare(tabView.count, 3)
+ }
+
+ Component {
+ id: newTab
+ Item {}
+ }
+
+ function test_changeIndex() {
+ var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { Text { text: index } } } }', testCase, '');
+ compare(tabView.count, 3)
+ verify(tabView.tabAt(1).item == undefined)
+ tabView.currentIndex = 1
+ verify(tabView.tabAt(1).item !== undefined)
+ verify(tabView.tabAt(2).item == undefined)
+ tabView.currentIndex = 1
+ verify(tabView.tabAt(2).item !== undefined)
+ }
+
+
+ function test_addRemoveTab() {
+ var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { }', testCase, '');
+ compare(tabView.count, 0)
+ tabView.addTab("title 1", newTab)
+ compare(tabView.count, 1)
+ tabView.addTab("title 2", newTab)
+ compare(tabView.count, 2)
+ compare(tabView.tabAt(0).title, "title 1")
+ compare(tabView.tabAt(1).title, "title 2")
+
+ tabView.insertTab(1, "title 3")
+ compare(tabView.count, 3)
+ compare(tabView.tabAt(0).title, "title 1")
+ compare(tabView.tabAt(1).title, "title 3")
+ compare(tabView.tabAt(2).title, "title 2")
+
+ tabView.insertTab(0, "title 4")
+ compare(tabView.count, 4)
+ compare(tabView.tabAt(0).title, "title 4")
+ compare(tabView.tabAt(1).title, "title 1")
+ compare(tabView.tabAt(2).title, "title 3")
+ compare(tabView.tabAt(3).title, "title 2")
+
+ tabView.removeTab(0)
+ compare(tabView.count, 3)
+ compare(tabView.tabAt(0).title, "title 1")
+ compare(tabView.tabAt(1).title, "title 3")
+ compare(tabView.tabAt(2).title, "title 2")
+
+ tabView.removeTab(1)
+ compare(tabView.count, 2)
+ compare(tabView.tabAt(0).title, "title 1")
+ compare(tabView.tabAt(1).title, "title 2")
+
+ tabView.removeTab(1)
+ compare(tabView.count, 1)
+ compare(tabView.tabAt(0).title, "title 1")
+
+ tabView.removeTab(0)
+ compare(tabView.count, 0)
+ }
+}
+
diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml
new file mode 100644
index 00000000..27f68a1a
--- /dev/null
+++ b/tests/auto/controls/data/tst_textarea.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_TextArea"
+ when: windowShown
+ width: 400
+ height: 400
+
+ function test_append() {
+ var textarea = Qt.createQmlObject('import QtQuick.Controls 1.0; TextArea {}', testCase, '')
+
+ compare(textarea.text, "")
+
+ textarea.append("my")
+ compare(textarea.text, "my")
+
+ textarea.append("name");
+ compare(textarea.text, "my\nname")
+ }
+}
diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml
new file mode 100644
index 00000000..e9bd4541
--- /dev/null
+++ b/tests/auto/controls/data/tst_textfield.qml
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_TextField"
+ when: windowShown
+ width: 400
+ height: 400
+
+ function test_text() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+
+ compare(textfield.text, "")
+ textfield.text = "hello world"
+ compare(textfield.text, "hello world")
+ }
+
+ function test_maximumLength() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+
+ textfield.text = "hello world"
+ textfield.maximumLength = 5
+ compare(textfield.text, "hello")
+ }
+
+ function test_length() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+
+ textfield.text = "hello world"
+ compare(textfield.length, 11)
+ }
+
+
+ function test_readonly() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ compare(textfield.readOnly, false)
+ textfield.text = "hello"
+ textfield.readOnly = true
+ keyPress(Qt.Key_9)
+ compare(textfield.text,"hello")
+ }
+
+ function test_inputMask() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ // +/- not required, 1 digit required, 1 aphabetic character required and 2 digits not required
+ textfield.inputMask = "#9A00"
+
+ keyPress(Qt.Key_Minus)
+ compare(textfield.text,"-")
+ compare(textfield.acceptableInput, false)
+
+ keyPress(Qt.Key_9)
+ compare(textfield.text,"-9")
+ compare(textfield.acceptableInput, false)
+
+ keyPress(Qt.Key_B)
+ compare(textfield.text,"-9b")
+ compare(textfield.acceptableInput, true)
+
+ keyPress(Qt.Key_1)
+ compare(textfield.text,"-9b1")
+ compare(textfield.acceptableInput, true)
+
+ keyPress(Qt.Key_1)
+ compare(textfield.text,"-9b11")
+ compare(textfield.acceptableInput, true)
+
+ keyPress(Qt.Key_Backspace)
+ keyPress(Qt.Key_Backspace)
+ keyPress(Qt.Key_Backspace)
+ compare(textfield.text,"-9")
+ compare(textfield.acceptableInput, false)
+
+ keyPress(Qt.Key_3)
+ compare(textfield.acceptableInput, false)
+ compare(textfield.text,"-93")
+ }
+
+ function test_validator() {
+ var textfield = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TextField {validator: RegExpValidator { regExp: /(red|blue|green)?/; }}', testCase, '')
+
+ textfield.text = "blu"
+ compare(textfield.acceptableInput, false)
+
+ textfield.text = "blue"
+ compare(textfield.acceptableInput, true)
+
+ textfield.text = "bluee"
+ compare(textfield.acceptableInput, false)
+ }
+
+ function test_selectAll() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.selectAll();
+
+ keyPress(Qt.Key_Delete)
+ compare(textfield.text, "")
+ }
+
+ function test_select() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.select(5, 8);
+
+ compare(textfield.selectionEnd, 8)
+ compare(textfield.selectionStart, 5)
+ compare(textfield.selectedText, "is ")
+ keyPress(Qt.Key_Delete)
+ compare(textfield.text, "this my text")
+ }
+
+ function test_cursorPosition() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ compare(textfield.cursorPosition, 0)
+ keyPress(Qt.Key_M)
+ compare(textfield.cursorPosition, 1)
+ keyPress(Qt.Key_Y)
+ compare(textfield.cursorPosition, 2)
+
+ textfield.cursorPosition = 1
+ keyPress(Qt.Key_A)
+ compare(textfield.text, "may")
+ }
+
+ function test_selectWord() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.selectWord();
+ compare(textfield.selectedText, "text")
+ textfield.cursorPosition = 2
+ textfield.selectWord();
+ compare(textfield.selectedText, "this")
+ }
+
+ function copy() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.text = "this is my text"
+ textfield.select(0, 5)
+ textfield.copy()
+ }
+
+ function test_getText() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ var gettext = textfield.getText(0, 4)
+ compare(gettext, "this")
+ }
+
+ function test_insert() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.insert(8, "not ")
+ compare(textfield.text, "this is not my text")
+ }
+
+ function test_deselect() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.selectWord();
+ textfield.deselect()
+ compare(textfield.selectedText, "")
+ }
+
+ function test_undo() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.insert(8, "not ")
+ compare(textfield.canUndo, true)
+ textfield.undo()
+ compare(textfield.text, "this is my text")
+ }
+
+ function test_redo() {
+ var textfield = Qt.createQmlObject('import QtQuick.Controls 1.0; TextField {}', testCase, '')
+ textfield.forceActiveFocus()
+
+ textfield.text = "this is my text"
+ textfield.insert(8, "not ")
+ textfield.undo()
+ compare(textfield.canRedo, true)
+ textfield.redo()
+ compare(textfield.text, "this is not my text")
+ }
+}
diff --git a/tests/auto/controls/data/tst_toolbar.qml b/tests/auto/controls/data/tst_toolbar.qml
new file mode 100644
index 00000000..68765b0d
--- /dev/null
+++ b/tests/auto/controls/data/tst_toolbar.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ToolBar"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createToolBar() {
+ var toolBar = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolBar {}', testCase, '');
+ }
+}
+
diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml
new file mode 100644
index 00000000..e488d03b
--- /dev/null
+++ b/tests/auto/controls/data/tst_toolbutton.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtTest 1.0
+
+TestCase {
+ id: testCase
+ name: "Tests_ToolButton"
+ when:windowShown
+ width:400
+ height:400
+
+ function test_createToolButton() {
+ var toolButton = Qt.createQmlObject('import QtQuick.Controls 1.0; ToolButton {}', testCase, '');
+ }
+}
+
diff --git a/tests/auto/qtdesktop/tst_qtdesktop.cpp b/tests/auto/controls/tst_controls.cpp
index a1c9da35..32ce84d7 100644
--- a/tests/auto/qtdesktop/tst_qtdesktop.cpp
+++ b/tests/auto/controls/tst_controls.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -39,5 +39,5 @@
**
****************************************************************************/
#include <QtQuickTest/quicktest.h>
-#include "qtdc_quicktest.h"
-QTDC_QUICK_TEST_MAIN(qtdesktop)
+#include "qt_quick_controls_quicktest.h"
+QT_QUICK_CONTROLS_TEST_MAIN(qtquickcontrols)
diff --git a/tests/auto/qtdesktop/data/tst_spinbox.qml b/tests/auto/qtdesktop/data/tst_spinbox.qml
deleted file mode 100644
index d460af80..00000000
--- a/tests/auto/qtdesktop/data/tst_spinbox.qml
+++ /dev/null
@@ -1,193 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtTest 1.0
-
-Item {
- id: container
- width: 300; height: 300
-
- TestCase {
- id: testcase
- name: "Tests_SpinBox"
- when: windowShown
-
- property int arrowMargin: 4 // the mouse areas for the up/down arrows have margins
- property point mainCoord: "0,0"
- property point upCoord: "0,0"
- property point downCoord: "0,0"
-
- function test_increment_key() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {maximumValue: 50}', container, '')
- spinbox.forceActiveFocus()
-
- compare(spinbox.maximumValue, 50)
- spinbox.setValue(spinbox.maximumValue - 3)
- keyPress(Qt.Key_Up)
- compare(spinbox.value, spinbox.maximumValue - 2)
- keyPress(Qt.Key_Up)
- keyPress(Qt.Key_Up)
- compare(spinbox.value, spinbox.maximumValue)
- keyPress(Qt.Key_Up)
- compare(spinbox.value, spinbox.maximumValue)
- }
-
- function test_decrement_key() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {minimumValue: 10}', container, '')
- spinbox.forceActiveFocus()
-
- compare(spinbox.minimumValue, 10)
- spinbox.setValue(spinbox.minimumValue + 3)
- keyPress(Qt.Key_Down)
- compare(spinbox.value, spinbox.minimumValue + 2)
- keyPress(Qt.Key_Down)
- keyPress(Qt.Key_Down)
- compare(spinbox.value, spinbox.minimumValue)
- keyPress(Qt.Key_Down)
- compare(spinbox.value, spinbox.minimumValue)
- }
-
- function test_increment_mouse() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {maximumValue: 50}', container, '')
- spinbox.forceActiveFocus()
- setCoordinates(spinbox)
-
- spinbox.setValue(spinbox.maximumValue - 3)
- mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.maximumValue - 2)
- mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
- mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.maximumValue)
- mouseClick(spinbox, upCoord.x, upCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.maximumValue)
- }
-
- function test_decrement_mouse() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {minimumValue: 10}', container, '')
- spinbox.forceActiveFocus()
- setCoordinates(spinbox)
-
- spinbox.setValue(spinbox.minimumValue + 3)
- mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.minimumValue + 2)
- mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
- mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.minimumValue)
- mouseClick(spinbox, downCoord.x, downCoord.y, Qt.LeftButton)
- compare(spinbox.value, spinbox.minimumValue)
- }
-
- function test_move_mouse() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
- spinbox.forceActiveFocus()
- setCoordinates(spinbox)
-
- mouseMove(spinbox, mainCoord.x, mainCoord.y)
- compare(spinbox.containsMouse, true)
- compare(spinbox.upHovered, false)
- compare(spinbox.downHovered, false)
-
- mouseMove(spinbox.parent, upCoord.x, upCoord.y)
- compare(spinbox.upHovered, true)
- compare(spinbox.downHovered, false)
-
- mouseMove(spinbox, downCoord.x, downCoord.y)
- compare(spinbox.upHovered, false)
- compare(spinbox.downHovered, true)
-
- mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2)
- compare(spinbox.containsMouse, false)
- compare(spinbox.upHovered, false)
- compare(spinbox.downHovered, false)
- }
-
- function test_maxvalue() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
- spinbox.setValue(spinbox.maximumValue + 1)
- compare(spinbox.value, spinbox.maximumValue)
- }
-
- function test_minvalue() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
- spinbox.setValue(spinbox.minimumValue - 1)
- compare(spinbox.value, spinbox.minimumValue)
- }
-
- function test_invalidvalue() {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
- spinbox.setValue("hello")
- compare(spinbox.value.toString().toLowerCase(), "nan")
- }
-
- function test_negativesinglestep()
- {
- var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
- spinbox.forceActiveFocus()
-
- spinbox.singleStep = -1
- spinbox.setValue(5)
-
- compare(spinbox.value, 5)
-
- var previousValue = spinbox.value
- keyPress(Qt.Key_Up)
-
- expectFailContinue("", "QTCOMPONENTS-1284 - sign of singleStep should be ignored when incrementing value")
- compare(spinbox.value, spinbox.value + Math.abs(spinbox.singleStep))
- keyPress(Qt.Key_Up)
-
- previousValue = spinbox.value
- expectFailContinue("", "QTCOMPONENTS-1284 - sign of singleStep should be ignored when decrementing value")
- compare(spinbox.value, previousValue - Math.abs(spinbox.singleStep))
- }
-
- function setCoordinates(item)
- {
- mainCoord.x = item.x + 1
- mainCoord.y = item.y + 1
- upCoord.x = item.x + item.width - arrowMargin
- upCoord.y = item.y + arrowMargin
- downCoord.x = upCoord.x
- downCoord.y = item.y + item.height - arrowMargin
- }
- }
-}
-
diff --git a/tests/auto/qtdesktop/qtdesktop.pro b/tests/auto/qtdesktop/qtdesktop.pro
deleted file mode 100644
index 63eb0947..00000000
--- a/tests/auto/qtdesktop/qtdesktop.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TEMPLATE = app
-TARGET = tst_qtdesktop
-
-IMPORTPATH = $$OUT_PWD/../testplugin
-
-QT += widgets
-
-CONFIG += qmltestcase
-
-INCLUDEPATH += $$PWD/../../shared
-SOURCES += $$PWD/tst_qtdesktop.cpp
-
-TESTDATA = $$PWD/data/*
-
-OTHER_FILES += \
- $$PWD/data/tst_button.qml \
- $$PWD/data/tst_shortcuts.qml \
- $$PWD/data/tst_spinbox.qml \
- $$PWD/data/tst_tableview.qml \
- $$PWD/data/tst_rangemodel.qml
-
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp
new file mode 100644
index 00000000..e0b14d60
--- /dev/null
+++ b/tests/auto/shared/util.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "util.h"
+
+#include <QtQml/QQmlComponent>
+#include <QtQml/QQmlError>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+#include <QtCore/QMutexLocker>
+
+QQmlDataTest *QQmlDataTest::m_instance = 0;
+
+QQmlDataTest::QQmlDataTest() :
+#ifdef QT_TESTCASE_BUILDDIR
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)),
+#else
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)),
+#endif
+
+ m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
+{
+ m_instance = this;
+}
+
+QQmlDataTest::~QQmlDataTest()
+{
+ m_instance = 0;
+}
+
+void QQmlDataTest::initTestCase()
+{
+ QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found");
+ m_directory = QFileInfo(m_dataDirectory).absolutePath();
+ QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
+}
+
+QString QQmlDataTest::testFile(const QString &fileName) const
+{
+ if (m_directory.isEmpty())
+ qFatal("QQmlDataTest::initTestCase() not called.");
+ QString result = m_dataDirectory;
+ result += QLatin1Char('/');
+ result += fileName;
+ return result;
+}
+
+QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c,
+ const QQmlEngine *engine /* = 0 */)
+{
+ QString result;
+ const QList<QQmlError> errors = c.errors();
+ QTextStream str(&result);
+ str << "Component '" << c.url().toString() << "' has " << errors.size()
+ << " errors: '";
+ for (int i = 0; i < errors.size(); ++i) {
+ if (i)
+ str << ", '";
+ str << errors.at(i).toString() << '\'';
+
+ }
+ if (!engine)
+ if (QQmlContext *context = c.creationContext())
+ engine = context->engine();
+ if (engine) {
+ str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", "))
+ << ") Plugin paths: (" << engine->pluginPathList().join(QStringLiteral(", "))
+ << ')';
+ }
+ return result.toLocal8Bit();
+}
+
+Q_GLOBAL_STATIC(QMutex, qQmlTestMessageHandlerMutex)
+
+QQmlTestMessageHandler *QQmlTestMessageHandler::m_instance = 0;
+
+void QQmlTestMessageHandler::messageHandler(QtMsgType, const QMessageLogContext &, const QString &message)
+{
+ QMutexLocker locker(qQmlTestMessageHandlerMutex());
+ if (QQmlTestMessageHandler::m_instance)
+ QQmlTestMessageHandler::m_instance->m_messages.push_back(message);
+}
+
+QQmlTestMessageHandler::QQmlTestMessageHandler()
+{
+ QMutexLocker locker(qQmlTestMessageHandlerMutex());
+ Q_ASSERT(!QQmlTestMessageHandler::m_instance);
+ QQmlTestMessageHandler::m_instance = this;
+ m_oldHandler = qInstallMessageHandler(messageHandler);
+}
+
+QQmlTestMessageHandler::~QQmlTestMessageHandler()
+{
+ QMutexLocker locker(qQmlTestMessageHandlerMutex());
+ Q_ASSERT(QQmlTestMessageHandler::m_instance);
+ qInstallMessageHandler(m_oldHandler);
+ QQmlTestMessageHandler::m_instance = 0;
+}
diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h
new file mode 100644
index 00000000..dc930382
--- /dev/null
+++ b/tests/auto/shared/util.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLTESTUTILS_H
+#define QQMLTESTUTILS_H
+
+#include <QtCore/QDir>
+#include <QtCore/QUrl>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QStringList>
+#include <QtTest/QTest>
+
+QT_FORWARD_DECLARE_CLASS(QQmlComponent)
+QT_FORWARD_DECLARE_CLASS(QQmlEngine)
+
+/* Base class for tests with data that are located in a "data" subfolder. */
+
+class QQmlDataTest : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlDataTest();
+ virtual ~QQmlDataTest();
+
+ QString testFile(const QString &fileName) const;
+ inline QString testFile(const char *fileName) const
+ { return testFile(QLatin1String(fileName)); }
+ inline QUrl testFileUrl(const QString &fileName) const
+ { return QUrl::fromLocalFile(testFile(fileName)); }
+ inline QUrl testFileUrl(const char *fileName) const
+ { return testFileUrl(QLatin1String(fileName)); }
+
+ inline QString dataDirectory() const { return m_dataDirectory; }
+ inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; }
+ inline QString directory() const { return m_directory; }
+
+ static inline QQmlDataTest *instance() { return m_instance; }
+
+ static QByteArray msgComponentError(const QQmlComponent &,
+ const QQmlEngine *engine = 0);
+
+public slots:
+ virtual void initTestCase();
+
+private:
+ static QQmlDataTest *m_instance;
+
+ const QString m_dataDirectory;
+ const QUrl m_dataDirectoryUrl;
+ QString m_directory;
+};
+
+class QQmlTestMessageHandler
+{
+ Q_DISABLE_COPY(QQmlTestMessageHandler)
+public:
+ QQmlTestMessageHandler();
+ ~QQmlTestMessageHandler();
+
+ const QStringList &messages() const { return m_messages; }
+ const QString messageString() const { return m_messages.join(QLatin1Char('\n')); }
+
+ void clear() { m_messages.clear(); }
+
+private:
+ static void messageHandler(QtMsgType, const QMessageLogContext &, const QString &message);
+
+ static QQmlTestMessageHandler *m_instance;
+ QStringList m_messages;
+ QtMessageHandler m_oldHandler;
+};
+
+#endif // QQMLTESTUTILS_H
diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri
new file mode 100644
index 00000000..38c2e6a1
--- /dev/null
+++ b/tests/auto/shared/util.pri
@@ -0,0 +1,8 @@
+QT += core-private gui-private v8-private qml-private quick-private
+
+HEADERS += $$PWD/visualtestutil.h \
+ $$PWD/util.h
+SOURCES += $$PWD/visualtestutil.cpp \
+ $$PWD/util.cpp
+
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/auto/shared/visualtestutil.cpp b/tests/auto/shared/visualtestutil.cpp
new file mode 100644
index 00000000..4b5c201a
--- /dev/null
+++ b/tests/auto/shared/visualtestutil.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "visualtestutil.h"
+
+#include <QtQuick/QQuickItem>
+#include <QtCore/QDebug>
+
+bool QQuickVisualTestUtil::delegateVisible(QQuickItem *item)
+{
+ return item->isVisible() && !QQuickItemPrivate::get(item)->culled;
+}
+
+QQuickItem *QQuickVisualTestUtil::findVisibleChild(QQuickItem *parent, const QString &objectName)
+{
+ QQuickItem *item = 0;
+ QList<QQuickItem*> items = parent->findChildren<QQuickItem*>(objectName);
+ for (int i = 0; i < items.count(); ++i) {
+ if (items.at(i)->isVisible() && !QQuickItemPrivate::get(items.at(i))->culled) {
+ item = items.at(i);
+ break;
+ }
+ }
+ return item;
+}
+
+void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth)
+{
+ static QString padding(" ");
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item)
+ continue;
+ qDebug() << padding.left(depth*2) << item;
+ dumpTree(item, depth+1);
+ }
+}
+
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h
new file mode 100644
index 00000000..5edb5d08
--- /dev/null
+++ b/tests/auto/shared/visualtestutil.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVISUALTESTUTIL_H
+#define QQUICKVISUALTESTUTIL_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlExpression>
+
+#include <QtQuick/private/qquickitem_p.h>
+
+namespace QQuickVisualTestUtil
+{
+ QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName);
+
+ void dumpTree(QQuickItem *parent, int depth = 0);
+
+ bool delegateVisible(QQuickItem *item);
+
+ /*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+ */
+ template<typename T>
+ T *findItem(QQuickItem *parent, const QString &objectName, int index = -1)
+ {
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item)
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QQmlExpression e(qmlContext(item), item, "index");
+ if (e.evaluate().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true)
+ {
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item || (visibleOnly && (!item->isVisible() || QQuickItemPrivate::get(item)->culled)))
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
+ {
+ QList<T*> items;
+ for (int i=0; i<indexes.count(); i++)
+ items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
+ return items;
+ }
+}
+
+#define QQUICK_VERIFY_POLISH(item) \
+ QTRY_COMPARE(QQuickItemPrivate::get(item)->polishScheduled, false)
+
+#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/testplugin/QtDesktopTest/qmldir b/tests/auto/testplugin/QtDesktopTest/qmldir
deleted file mode 100644
index 8b6dadac..00000000
--- a/tests/auto/testplugin/QtDesktopTest/qmldir
+++ /dev/null
@@ -1,2 +0,0 @@
-module QtDesktopTest
-plugin testplugin
diff --git a/tests/auto/testplugin/QtQuickControlsTests/qmldir b/tests/auto/testplugin/QtQuickControlsTests/qmldir
new file mode 100644
index 00000000..10c6cbab
--- /dev/null
+++ b/tests/auto/testplugin/QtQuickControlsTests/qmldir
@@ -0,0 +1,2 @@
+module QtQuickControlsTests
+plugin testplugin
diff --git a/tests/auto/testplugin/README.txt b/tests/auto/testplugin/README.txt
new file mode 100644
index 00000000..c22837db
--- /dev/null
+++ b/tests/auto/testplugin/README.txt
@@ -0,0 +1,11 @@
+
+The test plugin is not installed (i.e. to the qml folder).
+In order for the tst_controls to find it, you can either:
+
+- Run make check in the controls folder. The plugin will be found
+at run time because IMPORTPATH is defined in the pro file.
+
+- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH
+macro to the testplugin path. At run time QML2_IMPORT_PATH is used by
+by qmlscene to find imports required.
+i.e: export QML2_IMPORT_PATH=<path_qtquickcontrols_git_clone>/tests/auto/testplugin
diff --git a/tests/auto/testplugin/testcppmodels.h b/tests/auto/testplugin/testcppmodels.h
index 92899e1c..8a1b686e 100644
--- a/tests/auto/testplugin/testcppmodels.h
+++ b/tests/auto/testplugin/testcppmodels.h
@@ -3,36 +3,37 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
diff --git a/tests/auto/testplugin/testplugin.cpp b/tests/auto/testplugin/testplugin.cpp
index 13a9e00e..d0eaa858 100644
--- a/tests/auto/testplugin/testplugin.cpp
+++ b/tests/auto/testplugin/testplugin.cpp
@@ -3,36 +3,37 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
@@ -41,6 +42,7 @@
#include <QtQml/qqml.h>
#include <QQmlEngine>
#include <QVariant>
+#include <QStringList>
#include "testplugin.h"
#include "testcppmodels.h"
diff --git a/tests/auto/testplugin/testplugin.h b/tests/auto/testplugin/testplugin.h
index ee0d58ac..f0fb26ee 100644
--- a/tests/auto/testplugin/testplugin.h
+++ b/tests/auto/testplugin/testplugin.h
@@ -3,36 +3,37 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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."
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
**
** $QT_END_LICENSE$
**
@@ -47,7 +48,7 @@
class TestPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtdesktopcomponents.QQmlExtensionInterface" FILE "testplugin.json")
+ Q_PLUGIN_METADATA(IID "org.qt-project.playground.qtquickcontrols.QQmlExtensionInterface" FILE "testplugin.json")
public:
void registerTypes(const char *uri);
void initializeEngine(QQmlEngine *engine, const char *uri);
diff --git a/tests/auto/testplugin/testplugin.pro b/tests/auto/testplugin/testplugin.pro
index b0df3acd..d656517f 100644
--- a/tests/auto/testplugin/testplugin.pro
+++ b/tests/auto/testplugin/testplugin.pro
@@ -1,7 +1,7 @@
TEMPLATE = lib
CONFIG += plugin
TARGET = testplugin
-TARGETPATH = QtDesktopTest
+TARGETPATH = QtQuickControlsTests
QT += qml quick widgets
@@ -18,8 +18,6 @@ HEADERS += \
$$PWD/testplugin.h \
$$PWD/testcppmodels.h
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
-
mac {
LIBS += -framework Carbon
}
diff --git a/tests/manual/ContextMenu.qml b/tests/manual/ContextMenu.qml
index a40effad..2786bc83 100644
--- a/tests/manual/ContextMenu.qml
+++ b/tests/manual/ContextMenu.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
Rectangle {
@@ -63,7 +63,7 @@ Rectangle {
text : "Click to set color"
}
- ContextMenu {
+ Menu {
id : editMenu
MenuItem { text : "orange" ; onTriggered: selectedColor = text }
MenuItem { text : "lightsteelblue" ; onTriggered: selectedColor = text }
@@ -76,7 +76,7 @@ Rectangle {
id: mouse
anchors.fill: parent
acceptedButtons : Qt.LeftButton
- onClicked: editMenu.showPopup(mouseX, mouseY, 0)
+ onClicked: editMenu.popup()
}
}
}
diff --git a/tests/manual/Dialog.qml b/tests/manual/Dialog.qml
index 18942b5a..8b65f706 100644
--- a/tests/manual/Dialog.qml
+++ b/tests/manual/Dialog.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls.Experimental 1.0
Rectangle {
width: 300
diff --git a/tests/manual/Layout.qml b/tests/manual/Layout.qml
index c3b1d624..2fe82222 100644
--- a/tests/manual/Layout.qml
+++ b/tests/manual/Layout.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,456 +38,686 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
Item {
+ id: window
width: 600
height: 400
property real defaultWidth: 30
property real defaultHeight: 30
- TabFrame {
- id:frame
- anchors.fill: parent
-
- Tab {
- title: "Horizontal"
+ Column {
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+ Row {
+ width: parent.width
+ height: 20
+ CheckBox {
+ id: ckHideGreen
+ text: "Hide green rectangles"
+ checked: false
+ height: parent.height
+ }
+ Slider {
+ id: spacingSlider
+ value: 4
+ minimumValue: 0
+ maximumValue: 100
+ width: 200
+ height: parent.height
+ }
- Column {
- spacing: 4
+ }
+ TabView {
+ id:frame
+ width: parent.width
+ height: window.height - ckHideGreen.height
- anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- margins: 10
- }
+ Tab {
+ title: "Horizontal"
- // [1]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ Column {
+ spacing: 4
- Rectangle {
- color: "red"
- height: parent.height
- }
- Rectangle {
- color: "green"
- height: parent.height
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ margins: 10
}
- Rectangle {
- color: "blue"
- height: parent.height
- }
- }
-
- // [2]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
- spacing: 5
-
- Rectangle {
- color: "red"
- height: parent.height
- }
- Rectangle {
- color: "green"
- height: parent.height
- }
- Item {
- implicitWidth: 10
- }
- Rectangle {
- color: "blue"
- height: parent.height
- }
- }
-
- // [3]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ // [1]
+ RowLayout {
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
+ spacing: spacingSlider.value
- Rectangle {
- color: "red"
- height: parent.height
- Layout.minimumWidth: 50
- Layout.maximumWidth: 100
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "green"
- height: parent.height
- Layout.minimumWidth: 100
- Layout.maximumWidth: 200
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "blue"
- height: parent.height
- Layout.minimumWidth: 200
- Layout.maximumWidth: 400
- Layout.horizontalSizePolicy: Layout.Expanding
+ Rectangle {
+ color: "red"
+ width: 50
+ height: parent.height
+ }
+ Rectangle {
+ color: "green"
+ width: 100
+ height: parent.height
+ visible: !ckHideGreen.checked
+ }
+ Rectangle {
+ color: "blue"
+ width: 200
+ height: parent.height
+ }
}
- }
-
- // [4]
- RowLayout {
- spacing: 100
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
- Rectangle {
- color: "red"
- height: parent.height
- Layout.minimumWidth: 100
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "green"
- height: parent.height
- Layout.minimumWidth: 200
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "blue"
- height: parent.height
- Layout.minimumWidth: 300
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- }
+ // [2]
+ RowLayout {
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
- // [5]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ spacing: spacingSlider.value
- Rectangle {
- color: "red"
- height: parent.height
- Layout.minimumWidth: 200
- Layout.maximumWidth: 500
- Layout.horizontalSizePolicy: Layout.Expanding
+ Rectangle {
+ color: "red"
+ width: 40
+ height: parent.height
+ }
+ Rectangle {
+ color: "green"
+ width: 40
+ height: parent.height
+ visible: !ckHideGreen.checked
+ }
+ Item {
+ implicitWidth: 10
+ }
+ Rectangle {
+ color: "blue"
+ width: 40
+ height: parent.height
+ }
}
- }
-
- // [6]
- RowLayout {
- spacing: 40
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ // [3]
RowLayout {
- spacing: 10
- height: parent.height
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
+ spacing: spacingSlider.value
Rectangle {
color: "red"
height: parent.height
+ Layout.minimumWidth: 50
+ Layout.maximumWidth: 100
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ color: "green"
+ height: parent.height
+ visible: !ckHideGreen.checked
Layout.minimumWidth: 100
- Layout.horizontalSizePolicy: Layout.Expanding
+ Layout.maximumWidth: 200
+ Layout.fillWidth: true
}
Rectangle {
color: "blue"
height: parent.height
Layout.minimumWidth: 200
- Layout.horizontalSizePolicy: Layout.Expanding
+ Layout.maximumWidth: 400
+ Layout.fillWidth: true
}
}
+ // [4]
RowLayout {
- spacing: 10
- height: parent.height
+ spacing: 100 + spacingSlider.value
+
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.minimumWidth: 100
+ Layout.fillWidth: true
+ }
+ Rectangle {
color: "green"
height: parent.height
- Layout.maximumWidth: 300
- Layout.horizontalSizePolicy: Layout.Expanding
+ visible: !ckHideGreen.checked
+ Layout.minimumWidth: 200
+ Layout.fillWidth: true
}
Rectangle {
- color: "red"
+ color: "blue"
height: parent.height
- Layout.minimumWidth: 40
- Layout.maximumWidth: 100
- Layout.horizontalSizePolicy: Layout.Expanding
+ Layout.minimumWidth: 300
+ Layout.fillWidth: true
}
}
- }
- }
- }
+ // [5]
+ RowLayout {
+ spacing: spacingSlider.value
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
- Tab {
- title: "Vertical"
+ Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.minimumWidth: 200
+ Layout.maximumWidth: 500
+ Layout.fillWidth: true
+ }
+ }
- Row {
- spacing: 4
+ // [6]
+ RowLayout {
+ spacing: 40 + spacingSlider.value
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
- anchors {
- top: parent.top
- left: parent.left
- bottom: parent.bottom
- margins: 10
- }
+ RowLayout {
+ spacing: 10
+ height: parent.height
- // [1]
- ColumnLayout {
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
+ Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.minimumWidth: 100
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ color: "blue"
+ height: parent.height
+ Layout.minimumWidth: 200
+ Layout.fillWidth: true
+ }
+ }
- Rectangle {
- color: "red"
- width: parent.width
- }
- Rectangle {
- color: "green"
- width: parent.width
- }
- Rectangle {
- color: "blue"
- width: parent.width
+ RowLayout {
+ spacing: 10
+ height: parent.height
+
+ Rectangle {
+ color: "green"
+ height: parent.height
+ width: 40
+ visible: !ckHideGreen.checked
+ Layout.maximumWidth: 300
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.minimumWidth: 40
+ Layout.maximumWidth: 100
+ Layout.fillWidth: true
+ }
+ }
}
}
+ }
- // [2]
- ColumnLayout {
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- spacing: 5
+ Tab {
+ title: "Vertical"
- Rectangle {
- color: "red"
- width: parent.width
- }
- Rectangle {
- color: "green"
- width: parent.width
- }
- Item {
- implicitWidth: 10
- }
- Rectangle {
- color: "blue"
- width: parent.width
- }
- }
+ Row {
+ spacing: 4
- // [3]
- ColumnLayout {
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
+ anchors {
+ top: parent.top
- Rectangle {
- color: "red"
- width: parent.width
- Layout.minimumHeight: 50
- Layout.maximumHeight: 100
- Layout.verticalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "green"
- width: parent.width
- Layout.minimumHeight: 100
- Layout.maximumHeight: 200
- Layout.verticalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "blue"
- width: parent.width
- Layout.minimumHeight: 200
- Layout.maximumHeight: 400
- Layout.verticalSizePolicy: Layout.Expanding
+ left: parent.left
+ bottom: parent.bottom
+ margins: 10
}
- }
- // [4]
- ColumnLayout {
- spacing: 100
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
+ // [1]
+ ColumnLayout {
+ width: defaultWidth
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ spacing: spacingSlider.value
- Rectangle {
- color: "red"
- width: parent.width
- Layout.minimumHeight: 100
- Layout.verticalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "green"
- width: parent.width
- Layout.minimumHeight: 200
- Layout.verticalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "blue"
- width: parent.width
- Layout.minimumHeight: 300
- Layout.verticalSizePolicy: Layout.Expanding
+ Rectangle {
+ color: "red"
+ width: parent.width
+ height: 40
+ }
+ Rectangle {
+ color: "green"
+ width: parent.width
+ height: 80
+ visible: !ckHideGreen.checked
+ }
+ Rectangle {
+ color: "blue"
+ width: parent.width
+ height: 120
+ }
}
- }
- // [5]
- ColumnLayout {
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
+ // [2]
+ ColumnLayout {
+ width: defaultWidth
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
- Rectangle {
- color: "red"
- width: parent.width
- Layout.minimumHeight: 200
- Layout.maximumHeight: 500
- Layout.verticalSizePolicy: Layout.Expanding
- }
- }
+ spacing: spacingSlider.value
- // [6]
- ColumnLayout {
- spacing: 40
- width: defaultWidth
- anchors.top: parent.top
- anchors.bottom: parent.bottom
+ Rectangle {
+ color: "red"
+ width: parent.width
+ height: 40
+ }
+ Rectangle {
+ color: "green"
+ width: parent.width
+ visible: !ckHideGreen.checked
+ height: 80
+ }
+ Item {
+ implicitHeight: 10
+ }
+ Rectangle {
+ color: "blue"
+ width: parent.width
+ height: 40
+ }
+ }
+ // [3]
ColumnLayout {
- spacing: 10
- width: parent.width
+ width: defaultWidth
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ spacing: spacingSlider.value
Rectangle {
color: "red"
width: parent.width
- Layout.minimumHeight: 100
- Layout.verticalSizePolicy: Layout.Expanding
+ height: 60
+ Layout.minimumHeight: 50
+ Layout.maximumHeight: 100
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "green"
+ width: parent.width
+ height: 90
+ visible: !ckHideGreen.checked
+ Layout.minimumHeight: 75
+ Layout.maximumHeight: 125
+ Layout.fillHeight: true
}
Rectangle {
color: "blue"
width: parent.width
- Layout.minimumHeight: 200
- Layout.verticalSizePolicy: Layout.Expanding
+ height: 120
+ Layout.minimumHeight: 100
+ Layout.fillHeight: true
}
}
+ // [4]
ColumnLayout {
- spacing: 10
- width: parent.width
+ spacing: 100 + spacingSlider.value
+ width: defaultWidth
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
Rectangle {
+ color: "red"
+ width: parent.width
+ Layout.minimumHeight: 100
+ Layout.fillHeight: true
+ }
+ Rectangle {
color: "green"
width: parent.width
- Layout.maximumHeight: 300
- Layout.verticalSizePolicy: Layout.Expanding
+ visible: !ckHideGreen.checked
+ Layout.minimumHeight: 200
+ Layout.fillHeight: true
}
Rectangle {
- color: "red"
+ color: "blue"
width: parent.width
- Layout.minimumHeight: 40
- Layout.maximumHeight: 100
- Layout.verticalSizePolicy: Layout.Expanding
+ Layout.minimumHeight: 300
+ Layout.fillHeight: true
+ }
+ }
+
+ // [5]
+ ColumnLayout {
+ spacing: 40 + spacingSlider.value
+ width: defaultWidth
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+
+ ColumnLayout {
+ spacing: 10
+ width: parent.width
+ Layout.fillHeight: true
+
+ Rectangle {
+ color: "red"
+ width: parent.width
+ Layout.minimumHeight: 100
+ Layout.maximumHeight: 300
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "blue"
+ width: parent.width
+ Layout.minimumHeight: 100
+ Layout.fillHeight: true
+ Layout.maximumHeight: 200
+ }
+ }
+
+ ColumnLayout {
+ spacing: 10
+ width: parent.width
+ Layout.maximumHeight: 200
+ Layout.fillHeight: true
+ Rectangle {
+ color: "green"
+ width: parent.width
+ height: 50
+ visible: !ckHideGreen.checked
+ Layout.maximumHeight: 300
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "red"
+ width: parent.width
+ height: 50
+ Layout.minimumHeight: 40
+ Layout.fillHeight: true
+ }
}
}
}
}
- }
-
- Tab {
- title: "Horizontal and Vertical"
+ Tab {
+ title: "Horizontal and Vertical"
- ColumnLayout {
- anchors.fill: parent
+ ColumnLayout {
+ anchors.fill: parent
- // [1]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ // [1]
+ RowLayout {
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
- Layout.minimumHeight: 100
+ Layout.minimumHeight: 100
- Rectangle {
- color: "red"
- height: parent.height
- Layout.horizontalSizePolicy: Layout.Expanding
- }
- Rectangle {
- color: "green"
- height: parent.height
- implicitWidth: 100
+ Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ color: "green"
+ height: parent.height
+ visible: !ckHideGreen.checked
+ implicitWidth: 100
+ }
+ Rectangle {
+ color: "blue"
+ height: parent.height
+ Layout.fillWidth: true
+ }
}
+
+ // [2]
Rectangle {
- color: "blue"
+ color: "yellow"
height: parent.height
- Layout.horizontalSizePolicy: Layout.Expanding
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Layout.minimumHeight: 10
+ Layout.maximumHeight: 30
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
- }
- // [2]
- Rectangle {
- color: "yellow"
- height: parent.height
- anchors.left: parent.left
- anchors.right: parent.right
- Layout.minimumHeight: 10
- Layout.maximumHeight: 30
- Layout.horizontalSizePolicy: Layout.Expanding
- Layout.verticalSizePolicy: Layout.Expanding
- }
+ // [3]
+ RowLayout {
+ height: defaultHeight
+ anchors.left: parent.left
+ anchors.right: parent.right
- // [3]
- RowLayout {
- height: defaultHeight
- anchors.left: parent.left
- anchors.right: parent.right
+ Rectangle {
+ color: "red"
+ height: parent.height
+ Layout.maximumHeight: 200
+ Layout.fillWidth: true
+ }
+ Rectangle {
+ color: "blue"
+ height: parent.height
- Rectangle {
- color: "red"
- height: parent.height
- Layout.maximumHeight: 200
- Layout.horizontalSizePolicy: Layout.Expanding
+ ColumnLayout {
+ anchors.fill: parent
+ spacing: 10
+ opacity: 0.6
+
+ Rectangle {
+ color: "darkRed"
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Layout.minimumHeight: 100
+ Layout.maximumHeight: 200
+ Layout.fillHeight: true
+ }
+
+ Rectangle {
+ color: "darkGreen"
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Layout.fillHeight: true
+ }
+ }
+ }
}
- Rectangle {
- color: "blue"
- height: parent.height
+ }
+ }
- ColumnLayout {
- anchors.fill: parent
- spacing: 10
- opacity: 0.6
+ Tab {
+ title: "Grid"
+ Column {
+ spacing: 4
+
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ margins: 10
+ }
+
+ // [1]
+ GridLayout {
+ id: flag
+ rowSpacing: spacingSlider.value
+ columnSpacing: spacingSlider.value
+ // row 0
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Rectangle {
+ color: "red"
+ width: 52
+ height: 52
+ Layout.row: 0
+ Layout.column: 0
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 8
+ height: 52
+ Layout.row: 0
+ Layout.column: 1
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "blue"
+ width: 18
+ height: 60
+ Layout.row: 0
+ Layout.column: 2
+ Layout.rowSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 8
+ height: 52
+ Layout.row: 0
+ Layout.column: 3
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "red"
+ width: 140
+ height: 52
+ Layout.row: 0
+ Layout.column: 4
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
- Rectangle {
- color: "darkRed"
- height: parent.height
- anchors.left: parent.left
- anchors.right: parent.right
- Layout.minimumHeight: 100
- Layout.maximumHeight: 200
- Layout.verticalSizePolicy: Layout.Expanding
- }
+ // row 1
+ Rectangle {
+ color: "white"
+ width: 60
+ height: 8
+ Layout.row: 1
+ Layout.column: 0
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 60
+ height: 8
+ Layout.row: 1
+ Layout.column: 3
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
- Rectangle {
- color: "darkGreen"
- height: parent.height
- anchors.left: parent.left
- anchors.right: parent.right
- Layout.verticalSizePolicy: Layout.Expanding
- }
+ // row 2
+ Rectangle {
+ color: "blue"
+ width: 226
+ height: 18
+ Layout.row: 2
+ Layout.column: 0
+ Layout.columnSpan: 5
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+
+ // row 3
+ Rectangle {
+ color: "white"
+ width: 60
+ height: 8
+ Layout.row: 3
+ Layout.column: 0
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "blue"
+ width: 18
+ height: 60
+ Layout.row: 3
+ Layout.column: 2
+ Layout.rowSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 140
+ height: 8
+ Layout.row: 3
+ Layout.column: 3
+ Layout.columnSpan: 2
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+
+ // row 4
+ Rectangle {
+ color: "red"
+ width: 52
+ height: 52
+ Layout.row: 4
+ Layout.column: 0
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 8
+ height: 52
+ Layout.row: 4
+ Layout.column: 1
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ Rectangle {
+ color: "white"
+ width: 8
+ height: 52
+ Layout.row: 4
+ Layout.column: 3
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
+ Rectangle {
+ color: "red"
+ width: 140
+ height: 52
+ Layout.row: 4
+ Layout.column: 4
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ }
+ }
+
+ Text {
+ text: "Norwegian flag"
}
}
}
diff --git a/tests/manual/PageStack.qml b/tests/manual/PageStack.qml
index b8492a83..e84b6787 100644
--- a/tests/manual/PageStack.qml
+++ b/tests/manual/PageStack.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,9 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Window 2.1
+import QtQuick.Controls 1.0
Window {
width: 480
@@ -132,23 +133,25 @@ Window {
Component {
id: pageComponent
- Page {
+ Item {
id: page
- Component.onDestruction: console.log("destroyed component page: " + index)
+ width: parent.width
+ height: parent.height
+ Component.onDestruction: console.log("destroyed component page: " + Stack.index)
property bool pushFromOnCompleted: false
Component.onCompleted: if (pushFromOnCompleted) pageStack.push(pageComponent)
//pageTransition: rotateTransition
Rectangle {
anchors.fill: parent
- color: index % 2 ? "green" : "yellow"
+ color: page.Stack.index % 2 ? "green" : "yellow"
Column {
Text {
- text: "This is component page: " + page.index
+ text: "This is component page: " + page.Stack.index
}
Text {
- text: "Current status: " + page.status
+ text: "Current status: " + page.Stack.status
}
Text { text:" " }
Button {
@@ -193,11 +196,11 @@ Window {
}
Button {
text: "Search for page 3, and pop down to it"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (page.Stack.index === 3) return true }))
}
Button {
text: "Search for page 3, and pop down to it (dontLoad == true)"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }, true))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (page.Stack.index === 3) return true }, true))
}
Button {
text: "Clear"
@@ -228,22 +231,25 @@ Window {
}
}
- Page {
+ Item {
id: pageInline
- Component.onDestruction: console.log("destroyed inline page: " + index)
+ visible: false
+ width: parent.width
+ height: parent.height
+ Component.onDestruction: console.log("destroyed inline page: " + Stack.index)
- pageTransition: rotateTransition
+ Stack.pageTransition: rotateTransition
Rectangle {
anchors.fill: parent
- color: pageInline.index % 2 ? "green" : "yellow"
+ color: pageInline.Stack.index % 2 ? "green" : "yellow"
Column {
Text {
- text: "This is inline page: " + pageInline.index
+ text: "This is inline page: " + pageInline.Stack.index
}
Text {
- text: "Current status: " + pageInline.status
+ text: "Current status: " + pageInline.Stack.status
}
Button {
text: "Push component page"
@@ -279,11 +285,11 @@ Window {
}
Button {
text: "Search for page 3, and pop down to it"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (pageInline.Stack.index === 3) return true }))
}
Button {
text: "Search for page 3, and pop down to it (dontLoad == true)"
- onClicked: pageStack.pop(pageStack.find(function(page) { if (page.index === 3) return true }, true))
+ onClicked: pageStack.pop(pageStack.find(function(page) { if (pageInline.Stack.index === 3) return true }, true))
}
Button {
text: "Clear"
diff --git a/tests/manual/SplitterGallery.qml b/tests/manual/SplitterGallery.qml
deleted file mode 100644
index 8472ca04..00000000
--- a/tests/manual/SplitterGallery.qml
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc and its Subsidiary(-ies) 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.0
-import QtDesktop 1.0
-
-Rectangle {
- width: 800
- height: 500
- color: syspal.window
- SystemPalette{id:syspal}
- SplitterRow {
- id: sr
- anchors.fill: parent
- Item {
- id: r1
- Splitter.minimumWidth: 140
- Splitter.expanding: false
- width: 200
- CheckBox {
- id: be1
- anchors.centerIn: parent
- checked: parent.Splitter.expanding
- text: "Set expanding"
- onClicked: {
- parent.Splitter.expanding = true
- be2.checked = !parent.Splitter.expanding
- }
- }
- }
- Item {
- id: r2
- Splitter.minimumWidth: 140
- Splitter.expanding: true
- width: 200
- CheckBox {
- id: be2
- anchors.centerIn: parent
- text: "Set expanding"
- checked: true
- onClicked: {
- parent.Splitter.expanding = true
- be1.checked = !parent.Splitter.expanding
- }
- }
- }
- Item {
- id: r3
- Splitter.expanding: false
- Splitter.minimumWidth: 140
- width: 200
- SplitterColumn {
- id: sc
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- Item {
- id: cr1
- height:200
- }
- Item {
- id: cr2
- height: 200
- }
- }
- }
- }
-}
diff --git a/tests/manual/WindowContextMenu.qml b/tests/manual/WindowContextMenu.qml
index e15d209e..ec9af904 100644
--- a/tests/manual/WindowContextMenu.qml
+++ b/tests/manual/WindowContextMenu.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,9 +38,9 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtQuick.Window 2.0 // overrides any definition of Window in QtDesktop
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Window 2.1
Window {
width: 540
@@ -51,10 +51,10 @@ Window {
Text {
id : selctedLabel
anchors.centerIn: parent
- text : editMenu.itemTextAt(editMenu.selectedIndex)
+ text : editMenu.selectedIndex >= 0 ? editMenu.items[editMenu.selectedIndex].text : "No selection"
}
- ContextMenu {
+ Menu {
id : editMenu
MenuItem {
@@ -76,6 +76,6 @@ Window {
MouseArea {
anchors.fill: parent
acceptedButtons : Qt.RightButton
- onClicked: editMenu.showPopup(mouseX, mouseY, 0)
+ onClicked: editMenu.popup()
}
}
diff --git a/tests/manual/images/checkered.png b/tests/manual/images/checkered.png
new file mode 100644
index 00000000..12c8b54b
--- /dev/null
+++ b/tests/manual/images/checkered.png
Binary files differ
diff --git a/tests/manual/images/testIcon.png b/tests/manual/images/testIcon.png
new file mode 100644
index 00000000..7ac5f840
--- /dev/null
+++ b/tests/manual/images/testIcon.png
Binary files differ
diff --git a/tests/manual/keynavigation.qml b/tests/manual/keynavigation.qml
index e1efb566..55ddb478 100644
--- a/tests/manual/keynavigation.qml
+++ b/tests/manual/keynavigation.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 0.1
+import QtQuick 2.1
+import QtQuick.Controls 0.1
ApplicationWindow {
width: 400
diff --git a/tests/manual/scrollview/main.qml b/tests/manual/scrollview/main.qml
new file mode 100644
index 00000000..cc7b967d
--- /dev/null
+++ b/tests/manual/scrollview/main.qml
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+ApplicationWindow {
+ title: "Component Gallery"
+
+ width: 580
+ height: 400
+ property string loremIpsum:
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
+ "incididunt ut labore et dolore magna aliqua.\n Ut enim ad minim veniam, quis nostrud "+
+ "exercitation ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. ";
+
+ SystemPalette {id: syspal}
+ color: syspal.window
+
+ toolBar: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+ anchors.margins: 4
+ CheckBox {
+ id: frameCheck
+ text: "Frame"
+ checked: true
+ implicitWidth: 80
+ }
+ SpinBox {
+ id : widthSpinBox
+ maximumValue: 2000
+ value: 1000
+ implicitWidth: 80
+ }
+ SpinBox {
+ id : heightSpinBox
+ maximumValue: 2000
+ value: 1000
+ implicitWidth: 80
+ }
+ Item { Layout.fillWidth: true }
+ }
+ }
+
+ TabView {
+ id:frame
+ anchors.fill: parent
+ anchors.margins: 4
+ frameVisible: frameCheck.checked
+ Tab {
+ title: "Rectangle"
+ ScrollView {
+ anchors.fill: parent
+ anchors.margins:4
+ frameVisible: frameCheck.checked
+ Rectangle {
+ width: widthSpinBox.value
+ height: heightSpinBox.value
+ }
+ }
+ }
+ Tab {
+ title: "Image"
+ ScrollView {
+ anchors.fill: parent
+ anchors.margins:4
+ frameVisible: frameCheck.checked
+ Image {
+ width: widthSpinBox.value
+ height: heightSpinBox.value
+ fillMode: Image.Tile
+ source: "../../../examples/touch/images/button_pressed.png"
+ }
+ }
+ }
+ Tab {
+ title: "Flickable"
+ ScrollView{
+ anchors.fill: parent
+ anchors.margins:4
+ frameVisible: frameCheck.checked
+ Flickable {
+ contentWidth: widthSpinBox.value
+ contentHeight: heightSpinBox.value
+ Image {
+ width: widthSpinBox.value
+ height: heightSpinBox.value
+ fillMode: Image.Tile
+ source: "../../../examples/touch/images/button_pressed.png"
+ }
+ }
+ }
+ }
+ Tab {
+ title: "TextArea"
+ TextArea {
+ id: area
+ anchors.margins:4
+ frameVisible: frameCheck.checked
+ text: loremIpsum + loremIpsum + loremIpsum + loremIpsum
+ anchors.fill: parent
+ }
+ }
+ Tab {
+ title: "ListView"
+ ScrollView{
+ anchors.fill: parent
+ anchors.margins:4
+ frameVisible: frameCheck.checked
+ ListView {
+ width: 400
+ model: 30
+ delegate: Rectangle {
+ width: parent.width
+ height: 30
+ Text {
+ anchors.fill: parent
+ anchors.margins: 4
+ text: modelData
+ }
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: parent.width
+ height: 1
+ color: "darkgray"
+ }
+ }
+ }
+ }
+ }
+ Tab {
+ title: "TableView"
+ TableView {
+ id: view
+ anchors.margins:4
+ anchors.fill: parent
+ model: 10
+ frameVisible: frameCheck.checked
+
+ TableViewColumn {title: "first"
+ width: view.viewport.width
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/manual/splitter.qml b/tests/manual/splitter.qml
index 4f6bcdf8..e4b08e70 100644
--- a/tests/manual/splitter.qml
+++ b/tests/manual/splitter.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,17 +38,18 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
ApplicationWindow {
width: 400
height: 200
Row {
- SplitterColumn {
+ SplitView {
width: 200
height: 200
+ orientation: Qt.Vertical
Button {
text: "Button 1"
@@ -61,7 +62,7 @@ ApplicationWindow {
}
}
- SplitterRow {
+ SplitView {
width: 200
height: 200
diff --git a/tests/manual/stretching.qml b/tests/manual/stretching.qml
index 5d9290e9..a8d86eb3 100644
--- a/tests/manual/stretching.qml
+++ b/tests/manual/stretching.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,15 +38,15 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
Rectangle {
width: 600
height: 400
- TabFrame {
+ TabView {
anchors.fill: parent
Tab {
title: "Height"
diff --git a/tests/manual/stretchingcustom.qml b/tests/manual/stretchingcustom.qml
index 81b4d474..fa56757f 100644
--- a/tests/manual/stretchingcustom.qml
+++ b/tests/manual/stretchingcustom.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,15 +38,15 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
-import QtDesktop.Styles 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
Rectangle {
width: 600
height: 400
- TabFrame {
+ TabView {
anchors.fill: parent
Tab {
title: "Height"
diff --git a/tests/manual/tableviewmodels/main.cpp b/tests/manual/tableviewmodels/main.cpp
index 07e958bc..30f7a099 100644
--- a/tests/manual/tableviewmodels/main.cpp
+++ b/tests/manual/tableviewmodels/main.cpp
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
diff --git a/tests/manual/tableviewmodels/qml/main.qml b/tests/manual/tableviewmodels/qml/main.qml
index 2c4c359c..f9da0f68 100644
--- a/tests/manual/tableviewmodels/qml/main.qml
+++ b/tests/manual/tableviewmodels/qml/main.qml
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtDesktop 1.0
+import QtQuick 2.1
+import QtQuick.Controls 1.0
Rectangle {
width: 360
@@ -58,7 +58,7 @@ Rectangle {
model: model_listmodel // qml
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
@@ -67,7 +67,7 @@ Rectangle {
model: 3 // qml
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
@@ -75,7 +75,7 @@ Rectangle {
model: ["A", "B", "C"] // qml
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
@@ -83,7 +83,7 @@ Rectangle {
model: Item { x: 10 } // qml
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
role: "x"
width: 100
}
@@ -92,7 +92,7 @@ Rectangle {
model: model_qobjectlist // c++
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
@@ -101,7 +101,7 @@ Rectangle {
model: model_qaim // c++
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
role: "test"
width: 100
}
@@ -110,7 +110,7 @@ Rectangle {
model: model_qstringlist // c++
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
width: 100
}
}
@@ -118,7 +118,7 @@ Rectangle {
model: model_qobject // c++
anchors { left: parent.left; right: parent.right }
height: 70
- TableColumn {
+ TableViewColumn {
role: "value"
width: 100
}
diff --git a/tests/manual/tableviewmodels/testmodel.cpp b/tests/manual/tableviewmodels/testmodel.cpp
index b4cc95c7..0cbee38d 100644
--- a/tests/manual/tableviewmodels/testmodel.cpp
+++ b/tests/manual/tableviewmodels/testmodel.cpp
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
-**
-** $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 Digia Plc and its Subsidiary(-ies) 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."
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
**
** $QT_END_LICENSE$
**
diff --git a/tests/manual/tableviewmodels/testmodel.h b/tests/manual/tableviewmodels/testmodel.h
index 4815196f..98d63a71 100644
--- a/tests/manual/tableviewmodels/testmodel.h
+++ b/tests/manual/tableviewmodels/testmodel.h
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Components project.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**
diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml
new file mode 100644
index 00000000..8eca5e75
--- /dev/null
+++ b/tests/manual/testbench/content/Components.qml
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+Item {
+ property Component button: Button { text: "Push me"}
+ property Component checkbox: CheckBox { text: "A CheckBox" }
+ property Component toolbutton: ToolButton { text: "A ToolButton" }
+ property Component radiobutton: RadioButton { text: "A RadioButton" }
+ property Component textfield: TextField { }
+ property Component spinbox: SpinBox {}
+ property Component slider : Slider {}
+ property Component combobox: ComboBox { model: testDataModel }
+ property Component textarea: TextArea { text: loremIpsum }
+ property Component toolbar: ToolBar { }
+ property Component statusbar: StatusBar { }
+ property Component tableview: TableView { model: testDataModel ; TableViewColumn {title: "Column 1"}}
+ property Component tabView: TabView { Repeater { model: 3 ; delegate:Tab { title: "Tab " + index } }}
+ property Component scrollview: ScrollView {
+ Rectangle {
+ color: "#eee"
+ width: 1000
+ height: 1000
+ Image {
+ source: "../../images/checkered.png" ;
+ fillMode: Image.Tile
+ anchors.fill: parent
+ opacity: 0.1
+ }
+ }
+ }
+
+ property Component groupbox: GroupBox {
+ Column {
+ CheckBox {
+ text: "checkbox1"
+ }
+ CheckBox {
+ text: "checkbox2"
+ }
+ }
+ }
+
+ property Component progressbar: ProgressBar {
+ property bool ___isRunning: true
+ Timer {
+ id: timer
+ running: ___isRunning
+ repeat: true
+ interval: 25
+ onTriggered: {
+ var next = parent.value + 0.01;
+ parent.value = (next > parent.maximumValue) ? parent.minimumValue : next;
+ }
+ }
+ }
+
+ property var model: ListModel{
+ id: testDataModel
+ Component.onCompleted: {
+ for (var i = 0 ; i < 10 ; ++i)
+ testDataModel.append({text: "Value " + i});
+ }
+ }
+
+ property string loremIpsum:
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+
+ "incididunt ut labore et dolore magna aliqua.\n Ut enim ad minim veniam, quis nostrud "+
+ "exercitation ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. ";
+
+ property var componentModel: ListModel {
+ Component.onCompleted: {
+ append({ name: "Button", component: button});
+ append({ name: "ToolButton", component: toolbutton});
+ append({ name: "CheckBox", component: checkbox});
+ append({ name: "ComboBox", component: combobox});
+ append({ name: "RadioButton", component: radiobutton});
+ append({ name: "Slider", component: slider});
+ append({ name: "ProgressBar", component: progressbar});
+ append({ name: "TextField", component: textfield});
+ append({ name: "TextArea", component: textarea});
+ append({ name: "SpinBox", component: spinbox});
+ append({ name: "ToolBar", component: toolbar});
+ append({ name: "StatusBar", component: statusbar});
+ append({ name: "TableView", component: tableview});
+ append({ name: "ScrollView", component: scrollview});
+ append({ name: "GroupBox", component: groupbox});
+ append({ name: "TabView", component: tabView});
+ }
+ }
+}
diff --git a/tests/manual/testbench/content/PropertyLayouts.qml b/tests/manual/testbench/content/PropertyLayouts.qml
new file mode 100644
index 00000000..05061fcc
--- /dev/null
+++ b/tests/manual/testbench/content/PropertyLayouts.qml
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+
+QtObject {
+ property Component boolLayout: CheckBox {
+ checked: visible ? (result == "true") : false
+ text: name
+ onCheckedChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = checked
+ propertyChanged()
+ }
+ }
+ }
+
+ property Component intLayout: RowLayout {
+ spacing: 4
+ Label {
+ text: name + ":"
+ Layout.minimumWidth: 100
+ }
+ SpinBox {
+ value: result
+ maximumValue: 9999
+ minimumValue: -9999
+ Layout.fillWidth: true
+ onValueChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = value
+ propertyChanged()
+ }
+ }
+ }
+ }
+
+ property Component realLayout: RowLayout {
+ spacing: 4
+ Label {
+ text: name + ":"
+ Layout.minimumWidth: 100
+ }
+ SpinBox {
+ id: spinbox
+ value: result
+ decimals: 1
+ stepSize: 0.5
+ maximumValue: 9999
+ minimumValue: -9999
+ Layout.fillWidth: true
+ onValueChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = value
+ if (name != "width" && name != "height") // We dont want to reset size when size changes
+ propertyChanged()
+ }
+ }
+
+ Component.onCompleted: {
+ if (name == "width")
+ widthControl = spinbox
+ else if (name == "height")
+ heightControl = spinbox
+ }
+ }
+ }
+
+ property Component stringLayout: RowLayout {
+ spacing: 4
+ Label {
+ text: name + ":"
+ width: 100
+ }
+ TextField {
+ id: tf
+ text: result
+ Layout.fillWidth: true
+ onTextChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = tf.text
+ propertyChanged()
+ }
+ }
+ }
+ }
+
+ property Component readonlyLayout: RowLayout {
+ height: 20
+ Label {
+ id: text
+ height: 20
+ text: name + ":"
+ }
+ Label {
+ height: 20
+ anchors.right: parent.right
+ Layout.fillWidth: true
+ text: loader.item[name] !== undefined ? loader.item[name] : ""
+ }
+ }
+
+ property Component enumLayout: Column {
+ id: enumLayout
+ spacing: 4
+
+ Label { text: name + ":" }
+
+ ComboBox {
+ height: 20
+ width: parent.width
+ model: enumModel
+ onCurrentIndexChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = model.get(currentIndex).value
+ propertyChanged()
+ }
+ }
+ Component.onCompleted: currentIndex = getDefaultIndex()
+ function getDefaultIndex() {
+ for (var index = 0 ; index < model.count ; ++index) {
+ if ( model.get(index).value === result )
+ return index
+ }
+ return 0;
+ }
+
+ }
+ }
+}
diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml
new file mode 100644
index 00000000..afe2e3ab
--- /dev/null
+++ b/tests/manual/testbench/main.qml
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import "content"
+
+ApplicationWindow {
+ width: 950
+ height: 600
+
+ signal propertyChanged
+ property bool ignoreUpdate: false
+ onPropertyChanged: container.resetSize()
+
+ property var propertyMap: []
+
+ property SpinBox widthControl
+ property SpinBox heightControl
+
+ color: "lightgray"
+
+ Components{ id: components }
+ SystemPalette { id: syspal }
+
+ toolBar: ToolBar {
+ width: parent.width
+ RowLayout {
+ id: alwaysVisible
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ height: parent.height
+ ComboBox {
+ id: selector
+ width: 200
+ model: components.componentModel
+ textRole: "name"
+ }
+ CheckBox {
+ id: patternCheckBox
+ checked: false
+ text: "Background"
+ }
+ }
+
+ CheckBox {
+ id: startStopAnim
+ anchors.left: alwaysVisible.right
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Stop Animation"
+ checked: true
+ visible: false
+ onCheckedChanged: if (visible) loader.item.___isRunning = checked
+ }
+ }
+ statusBar: StatusBar {
+ Row {
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ anchors.verticalCenter: parent.verticalCenter
+ Label { text: "X: " + topLeftHandle.x ; width: 50}
+ Label { text: "Y: " + topLeftHandle.y ; width: 50}
+ Label { text: "Width: " + container.width ; width: 70}
+ Label { text: "Height: "+container.height ; width: 70}
+ }
+ }
+
+ SplitView {
+ anchors.fill: parent
+ Flickable {
+ id: testBenchRect
+ clip: true
+ Layout.fillWidth: true
+
+ Image {
+ anchors.fill: parent
+ source: "../images/checkered.png"
+ fillMode: Image.Tile
+ opacity: patternCheckBox.checked ? 0.12 : 0
+ Behavior on opacity { NumberAnimation { duration: 100 } }
+ }
+
+ Rectangle {
+ id: container
+
+ property bool pressed: topLeftHandle.pressed || bottomRightHandle.pressed
+
+ function resetSize() {
+ topLeftHandle.x = (testBenchRect.width - loader.item.implicitWidth) / 2 - topLeftHandle.width;
+ topLeftHandle.y = (testBenchRect.height - loader.item.implicitHeight) / 2 - topLeftHandle.height;
+ bottomRightHandle.x = topLeftHandle.x + loader.item.implicitWidth;
+ bottomRightHandle.y = topLeftHandle.y + loader.item.implicitHeight;
+ }
+
+ function updateSize() {
+ ignoreUpdate = true
+ if (widthControl)
+ widthControl.value = loader.item.width
+ if (heightControl)
+ heightControl.value = loader.item.height
+ ignoreUpdate = false
+ }
+
+ onHeightChanged: updateSize()
+ onWidthChanged: updateSize()
+
+ y: Math.floor(topLeftHandle.y + topLeftHandle.height - topLeftHandle.width/2)
+ x: Math.floor(topLeftHandle.x + topLeftHandle.width - topLeftHandle.height/2)
+ width: Math.floor(bottomRightHandle.x - topLeftHandle.x )
+ height: Math.floor(bottomRightHandle.y - topLeftHandle.y)
+ color: "transparent"
+ border.color: pressed ? "darkgray" : "transparent"
+
+ Loader {
+ id: loader
+ focus: true
+ sourceComponent: selector.model.get(selector.currentIndex).component
+ anchors.fill: parent
+ PropertyLayouts{ id: layouts }
+ onStatusChanged: {
+
+ startStopAnim.visible = false
+
+ if (status == Loader.Ready) {
+ propertyMap = []
+ var arr = new Array
+
+ for (var prop in item) {
+
+ if (prop.toString() === "___isRunning") {
+ startStopAnim.visible = true
+ continue;
+ }
+
+ if (!prop.indexOf("on")) { // look only for properties
+ if (prop.indexOf("Changed") !== (prop.length - 7))
+ continue;
+ var substr = prop.slice(2, prop.length - 7)
+ if (!substr.indexOf("__")) // filter private
+ continue;
+
+ var typeName = "None";
+ var layout
+ var enumModelData
+ var isColor = false
+ switch (substr) {
+
+ case "ActiveFocusOnPress":
+ case "Enabled":
+ case "Visible":
+ case "Checkable":
+ case "Checked":
+ case "FrameVisible":
+ case "AdjustToContentSize":
+ case "Flat":
+ case "SelectByMouse":
+ case "SelectByKeyboard":
+ case "ReadOnly":
+ layout = layouts.boolLayout
+ typeName = "Boolean";
+ break
+
+ case "MaximumValue":
+ case "MinimumValue":
+ case "Decimals":
+ layout = layouts.intLayout
+ typeName = "Int"
+ break;
+
+ case "Scale":
+ case "Height":
+ case "Width":
+ case "StepSize":
+ case "Value":
+ case "Opacity":
+ layout = layouts.realLayout
+ typeName = "Real";
+ break;
+
+ case "ImplicitHeight":
+ case "ActiveFocus":
+ case "ImplicitWidth":
+ case "Pressed":
+ layout = layouts.readonlyLayout
+ typeName = "ReadOnly"
+ break;
+
+ case "Prefix":
+ case "Suffix":
+ case "Text":
+ case "Title":
+ case "Tooltip":
+ layout = layouts.stringLayout
+ typeName = "String";
+ break;
+
+ case "HorizontalAlignment":
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "TextEdit.AlignLeft", value: TextEdit.AlignLeft});
+ enumModelData.append({ text: "TextEdit.AlignRight", value: TextEdit.AlignRight});
+ enumModelData.append({ text: "TextEdit.AlignHCenter", value: TextEdit.AlignHCenter});
+ break;
+
+ case "VerticalAlignment":
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "TextEdit.AlignTop", value: TextEdit.AlignTop});
+ enumModelData.append({ text: "TextEdit.AlignBottom", value: TextEdit.AlignBottom});
+ enumModelData.append({ text: "TextEdit.AlignVCenter", value: TextEdit.AlignVCenter});
+ break;
+
+ case "InputMethodHints":
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "Qt.ImhNone", value: Qt.ImhNone});
+ enumModelData.append({ text: "Qt.ImhHiddenText", value: Qt.ImhHiddenText});
+ enumModelData.append({ text: "Qt.ImhSensitiveData", value: Qt.ImhSensitiveData});
+ enumModelData.append({ text: "Qt.ImhNoAutoUppercase", value: Qt.ImhNoAutoUppercase});
+ enumModelData.append({ text: "Qt.ImhPreferNumbers", value: Qt.ImhPreferNumbers});
+ enumModelData.append({ text: "Qt.ImhPreferUppercase", value: Qt.ImhPreferUppercase});
+ enumModelData.append({ text: "Qt.ImhPreferLowercase", value: Qt.ImhPreferLowercase});
+ enumModelData.append({ text: "Qt.ImhNoPredictiveText", value: Qt.ImhNoPredictiveText});
+ enumModelData.append({ text: "Qt.ImhDate", value: Qt.ImhDate});
+ enumModelData.append({ text: "Qt.ImhTime", value: Qt.ImhTime});
+ enumModelData.append({ text: "Qt.ImhDigitsOnly", value: Qt.ImhDigitsOnly});
+ enumModelData.append({ text: "Qt.ImhFormattedNumbersOnly", value: Qt.ImhFormattedNumbersOnly});
+ enumModelData.append({ text: "Qt.ImhUppercaseOnly", value: Qt.ImhUppercaseOnly});
+ enumModelData.append({ text: "Qt.ImhLowercaseOnly", value: Qt.ImhLowercaseOnly});
+ enumModelData.append({ text: "Qt.ImhDialableCharactersOnly",value: Qt.ImhDialableCharactersOnly});
+ enumModelData.append({ text: "Qt.ImhEmailCharactersOnly", value: Qt.ImhEmailCharactersOnly});
+ enumModelData.append({ text: "Qt.ImhUrlCharactersOnly", value: Qt.ImhUrlCharactersOnly});
+ break;
+
+ case "Orientation":
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "Qt.Horizontal", value: Qt.Horizontal});
+ enumModelData.append({ text: "Qt.Vertical", value: Qt.Vertical});
+ break;
+
+ case "EchoMode":
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "TextInput.Normal", value: TextInput.Normal});
+ enumModelData.append({ text: "TextInput.Password", value: TextInput.Password});
+ enumModelData.append({ text: "TextInput.NoEcho", value: TextInput.NoEcho});
+ enumModelData.append({ text: "TextInput.PasswordEchoOnEdit",value: TextInput.PasswordEchoOnEdit});
+ break;
+
+ case "BackgroundColor":
+ case "TextColor":
+ isColor = true
+ layout = layouts.enumLayout
+ enumModelData = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; ListModel {}', layout, '');
+ typeName = "Enum";
+ enumModelData.append({ text: "Amber", value: "#FF7E00"});
+ enumModelData.append({ text: "Azure", value: "#007FFF"});
+ enumModelData.append({ text: "Carmine red", value: "#FF0038"});
+ break;
+
+
+ default:
+ break;
+ }
+
+ if (substr.length > 1)
+ substr = substr[0].toLowerCase() + substr.substring(1)
+ else
+ substr = substr.toLowerCase()
+
+ var val = item[substr] + "" // All model properties must be the same type
+
+ if (typeName != "None" && val !== undefined) {
+ if (isColor)
+ enumModelData.append({ text: "Default", value: val})
+
+ if (arr[typeName] === undefined)
+ arr[typeName] = []
+ arr[typeName].push({name: substr , result: val, typeString: typeName, layoutComponent: layout, enumModel: enumModelData})
+ }
+ }
+ propertyMap = arr;
+ container.resetSize();
+ }
+ }
+ }
+
+ Rectangle {
+ id: marginsRect
+ color: "transparent"
+ // opacity: container.pressed && loader.item.styling && loader.item.styling.topMargin != undefined ? 1 : 0
+ border.color: Qt.rgba(0, 0, 0, 0.2)
+ anchors.fill: parent
+ z: 2
+ Connections {
+ target: loader
+ onItemChanged: {
+ if (!loader.item || !loader.item.styling) return;
+ marginsRect.anchors.leftMargin = Math.max(loader.item.styling.leftMargin, 0);
+ marginsRect.anchors.rightMargin = Math.max(loader.item.styling.rightMargin, 0);
+ marginsRect.anchors.topMargin = Math.max(loader.item.styling.topMargin, 0);
+ marginsRect.anchors.bottomMargin = Math.max(loader.item.styling.bottomMargin, 0);
+ }
+ }
+ }
+ }
+ }
+
+ MouseArea {
+ id: topLeftHandle
+ width: 10
+ height: 10
+
+ drag.target: topLeftHandle
+ drag.minimumX: 0; drag.minimumY: 0
+ drag.maximumX: bottomRightHandle.x - width
+ drag.maximumY: bottomRightHandle.y - height
+ Rectangle {
+ anchors.fill: parent
+ color: "lightsteelblue"
+ border.color: "steelblue"
+ }
+ }
+
+ MouseArea {
+ id: bottomRightHandle
+ width: 10
+ height: 10
+
+ drag.target: bottomRightHandle
+ drag.minimumX: topLeftHandle.x + width
+ drag.minimumY: topLeftHandle.y + height
+ drag.maximumX: testBenchRect.width - width;
+ drag.maximumY: testBenchRect.height - height
+
+ Rectangle {
+ anchors.fill: parent
+ color: "lightsteelblue"
+ border.color: "steelblue"
+ }
+ }
+ }
+ Rectangle {
+ id: sidebar
+ color : syspal.window
+ width: 200
+ ScrollView {
+ id: scrollView
+ anchors.fill: parent
+ flickableItem.flickableDirection: Flickable.VerticalFlick
+ Column {
+ id: properties
+ anchors.left: parent ? parent.left : undefined
+ anchors.top: parent ? parent.top : undefined
+ anchors.margins: 10
+ width: scrollView.viewport.width - 20
+ spacing: 8
+ Repeater {
+ model: ["Boolean", "String","Int", "Real", "ReadOnly", "Enum"]
+ Repeater {
+ model: propertyMap[modelData]
+ Loader {
+ width: properties.width
+ sourceComponent: modelData.layoutComponent
+ property string name: modelData.name
+ property var value: modelData.value
+ property var result: modelData.result
+ property var enumModel: modelData.enumModel
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/manual/testbench/testbench.qmlproject b/tests/manual/testbench/testbench.qmlproject
new file mode 100644
index 00000000..e5a8bf02
--- /dev/null
+++ b/tests/manual/testbench/testbench.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "main.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/tests/shared/qtdc_quicktest.h b/tests/shared/qt_quick_controls_quicktest.h
index 721da6bc..0e1873af 100644
--- a/tests/shared/qtdc_quicktest.h
+++ b/tests/shared/qt_quick_controls_quicktest.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the test suite of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -39,35 +39,31 @@
**
****************************************************************************/
-#ifndef QTDC_QUICKTEST_H
-#define QTDC_QUICKTEST_H
+#ifndef QT_QUICK_CONTROLS_QUICKTEST_H
+#define QT_QUICK_CONTROLS_QUICKTEST_H
#include <QtQuickTest/quicktestglobal.h>
#include <QtWidgets/QApplication>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
#ifdef QUICK_TEST_SOURCE_DIR
-#define QTDC_QUICK_TEST_MAIN_VAR QUICK_TEST_SOURCE_DIR
+#define QT_QUICK_CONTROLS_TEST_MAIN_VAR QUICK_TEST_SOURCE_DIR
#else
-#define QTDC_QUICK_TEST_MAIN_VAR 0
+#define QT_QUICK_CONTROLS_TEST_MAIN_VAR 0
#endif
-#define QTDC_QUICK_TEST_MAIN(name) \
+#define QT_QUICK_CONTROLS_TEST_MAIN(name) \
int main(int argc, char **argv) \
{ \
QApplication* app = 0; \
if (!QCoreApplication::instance()) \
app = new QApplication(argc, argv); \
- int i = quick_test_main(argc, argv, #name, QTDC_QUICK_TEST_MAIN_VAR); \
+ int i = quick_test_main(argc, argv, #name, QT_QUICK_CONTROLS_TEST_MAIN_VAR); \
delete app; \
return i; \
}
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/tools/qmlwidget/main.cpp b/tools/qmlwidget/main.cpp
index cec4059c..37752c4d 100644
--- a/tools/qmlwidget/main.cpp
+++ b/tools/qmlwidget/main.cpp
@@ -1,38 +1,39 @@
/****************************************************************************
**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
**
-** "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 Digia Plc and its Subsidiary(-ies) nor the names
-** of its contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
**
-** 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$
**