mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Rename ExtruderSelectorBar -> SingleSettingExtruderSelectorBar to be inline with new single setting widgets.
Move common functionality into SingleSettingExtruderSelectorBar Add adhesion settings CURA-9793
This commit is contained in:
parent
c240833868
commit
c356b9d46f
6 changed files with 79 additions and 75 deletions
|
@ -1,43 +0,0 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.5 as Cura
|
||||
|
||||
Row
|
||||
{
|
||||
id: extruderSelectionBar
|
||||
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
spacing: 0
|
||||
|
||||
property alias model: extruderButtonRepeater.model
|
||||
property int selectedIndex: 0
|
||||
function onClickExtruder(index) {}
|
||||
|
||||
|
||||
Repeater
|
||||
{
|
||||
id: extruderButtonRepeater
|
||||
|
||||
delegate: Item
|
||||
{
|
||||
width: {
|
||||
const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count);
|
||||
return Math.min(UM.Theme.getSize("large_button").width, maximum_width);
|
||||
}
|
||||
height: childrenRect.height
|
||||
|
||||
Cura.ExtruderButton
|
||||
{
|
||||
extruder: model
|
||||
checked: extruder.index == selectedIndex
|
||||
iconScale: 0.6
|
||||
buttonSize: UM.Theme.getSize("large_button").width
|
||||
onClicked: extruder.enabled && onClickExtruder(extruder.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ Cura.ComboBox {
|
|||
id: comboboxModel
|
||||
|
||||
// The propertyProvider has not loaded the setting when this components onComplete triggers. Populating the model
|
||||
// is defered until propertyProvider signals "onIsValueUsedChanged".
|
||||
// is defered until propertyProvider signals "onIsValueUsedChanged". The defered upate is triggered with this function.
|
||||
function updateModel()
|
||||
{
|
||||
clear()
|
||||
|
|
64
resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml
Normal file
64
resources/qml/Widgets/SingleSettingExtruderSelectorBar.qml
Normal file
|
@ -0,0 +1,64 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.3
|
||||
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.5 as Cura
|
||||
|
||||
// This component displays a row of extruder icons, clicking on the extruder will update the setting passed to "settingName"
|
||||
// with the index of that extruder.
|
||||
// This will only work for settings that take an extruder index.
|
||||
Row
|
||||
{
|
||||
id: extruderSelectionBar
|
||||
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
spacing: 0
|
||||
|
||||
property int selectedIndex: extruderSettingProvider.properties.value !== undefined ? extruderSettingProvider.properties.value : 0
|
||||
property alias model: extruderButtonRepeater.model
|
||||
property alias extruderSettingName: extruderSettingProvider.key
|
||||
property alias containerStack: extruderSettingProvider.containerStack
|
||||
|
||||
property UM.SettingPropertyProvider extruderSettingProvider: UM.SettingPropertyProvider
|
||||
{
|
||||
id: extruderSettingProvider
|
||||
containerStack: Cura.MachineManager.activeMachine
|
||||
watchedProperties: [ "value" ]
|
||||
storeIndex: 0
|
||||
}
|
||||
|
||||
function onClickExtruder(index)
|
||||
{
|
||||
forceActiveFocus();
|
||||
extruderSettingProvider.setPropertyValue("value", index);
|
||||
}
|
||||
|
||||
|
||||
Repeater
|
||||
{
|
||||
id: extruderButtonRepeater
|
||||
|
||||
model: CuraApplication.getExtrudersModel()
|
||||
|
||||
delegate: Item
|
||||
{
|
||||
width: {
|
||||
// This will "squish" the extruder buttons together when the fill up the horizontal space
|
||||
const maximum_width = Math.floor(extruderSelectionBar.width / extruderButtonRepeater.count);
|
||||
return Math.min(UM.Theme.getSize("large_button").width, maximum_width);
|
||||
}
|
||||
height: childrenRect.height
|
||||
|
||||
Cura.ExtruderButton
|
||||
{
|
||||
extruder: model
|
||||
checked: extruder.index == selectedIndex
|
||||
iconScale: 0.6
|
||||
buttonSize: UM.Theme.getSize("large_button").width
|
||||
onClicked: extruder.enabled && onClickExtruder(extruder.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue