123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // Copyright (c) 2016 Ultimaker B.V.
- // Cura is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.1
- import QtQuick.Controls 2.2
- import QtQuick.Controls.Styles 2.2
- import QtQuick.Controls 2.3 as NewControls
- import UM 1.2 as UM
- import Cura 1.0 as Cura
- UM.PreferencesPage
- {
- title: catalog.i18nc("@title:tab", "Setting Visibility");
- property QtObject settingVisibilityPresetsModel: CuraApplication.getSettingVisibilityPresetsModel()
- property int scrollToIndex: 0
- signal scrollToSection( string key )
- onScrollToSection:
- {
- settingsListView.positionViewAtIndex(definitionsModel.getIndex(key), ListView.Beginning)
- }
- function reset()
- {
- settingVisibilityPresetsModel.setActivePreset("basic")
- }
- resetEnabled: true;
- Item
- {
- id: base;
- anchors.fill: parent;
- CheckBox
- {
- id: toggleVisibleSettings
- anchors
- {
- verticalCenter: filter.verticalCenter;
- left: parent.left;
- leftMargin: UM.Theme.getSize("default_margin").width
- }
- text: catalog.i18nc("@label:textbox", "Check all")
- checkedState:
- {
- if(definitionsModel.visibleCount == definitionsModel.categoryCount)
- {
- return Qt.Unchecked
- }
- else if(definitionsModel.visibleCount == definitionsModel.count)
- {
- return Qt.Checked
- }
- else
- {
- return Qt.PartiallyChecked
- }
- }
- partiallyCheckedEnabled: true
- MouseArea
- {
- anchors.fill: parent;
- onClicked:
- {
- if(parent.checkedState == Qt.Unchecked || parent.checkedState == Qt.PartiallyChecked)
- {
- definitionsModel.setAllExpandedVisible(true)
- }
- else
- {
- definitionsModel.setAllExpandedVisible(false)
- }
- }
- }
- }
- TextField
- {
- id: filter;
- anchors
- {
- top: parent.top
- left: toggleVisibleSettings.right
- leftMargin: UM.Theme.getSize("default_margin").width
- right: visibilityPreset.left
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- placeholderText: catalog.i18nc("@label:textbox", "Filter...")
- onTextChanged: definitionsModel.filter = {"i18n_label|i18n_description": "*" + text}
- }
- NewControls.ComboBox
- {
- id: visibilityPreset
- width: 150 * screenScaleFactor
- anchors
- {
- top: parent.top
- right: parent.right
- bottom: scrollView.top
- }
- model: settingVisibilityPresetsModel.items
- textRole: "name"
- currentIndex:
- {
- var idx = -1;
- for(var i = 0; i < settingVisibilityPresetsModel.items.length; ++i)
- {
- if(settingVisibilityPresetsModel.items[i].presetId == settingVisibilityPresetsModel.activePreset)
- {
- idx = i;
- break;
- }
- }
- return idx;
- }
- onActivated:
- {
- var preset_id = settingVisibilityPresetsModel.items[index].presetId
- settingVisibilityPresetsModel.setActivePreset(preset_id)
- }
- }
- ScrollView
- {
- id: scrollView
- frameVisible: true
- anchors
- {
- top: filter.bottom;
- topMargin: UM.Theme.getSize("default_margin").height
- left: parent.left;
- right: parent.right;
- bottom: parent.bottom;
- }
- ListView
- {
- id: settingsListView
- model: UM.SettingDefinitionsModel
- {
- id: definitionsModel
- containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
- showAll: true
- exclude: ["machine_settings", "command_line_settings"]
- showAncestors: true
- expanded: ["*"]
- visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
- }
- delegate: Loader
- {
- id: loader
- width: settingsListView.width
- height: model.type != undefined ? UM.Theme.getSize("section").height : 0
- property var definition: model
- property var settingDefinitionsModel: definitionsModel
- asynchronous: true
- active: model.type != undefined
- sourceComponent:
- {
- switch(model.type)
- {
- case "category":
- return settingVisibilityCategory
- default:
- return settingVisibilityItem
- }
- }
- }
- }
- }
- UM.I18nCatalog { name: "cura"; }
- SystemPalette { id: palette; }
- Component
- {
- id: settingVisibilityCategory;
- UM.SettingVisibilityCategory { }
- }
- Component
- {
- id: settingVisibilityItem;
- UM.SettingVisibilityItem { }
- }
- }
- }
|