diff --git a/qml/Printer.qml b/qml/Printer.qml index 59ac3fde10..88bc7eff69 100644 --- a/qml/Printer.qml +++ b/qml/Printer.qml @@ -143,7 +143,7 @@ UM.MainWindow { } } - Sidebar { + UM.Sidebar { id: sidebar; anchors { diff --git a/qml/SaveButton.qml b/qml/SaveButton.qml deleted file mode 100644 index 5216886e90..0000000000 --- a/qml/SaveButton.qml +++ /dev/null @@ -1,183 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -Button { - id: base; - - property Action saveAction; - - property real progress: UM.Backend.progress; - Behavior on progress { NumberAnimation { duration: 250; } } - - enabled: progress >= 0.95; - - property string currentDevice: 'local_file' - property bool defaultOverride: false; - property bool defaultAmbiguous: false; - - iconSource: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon]; - tooltip: Printer.outputDevices[base.currentDevice].description; - - Connections { - target: Printer; - onOutputDevicesChanged: { - if(!base.defaultOverride) { - base.defaultAmbiguous = false; - var device = null; - for(var i in Printer.outputDevices) { - if(device == null) { - device = i; - } else if(Printer.outputDevices[i].priority > Printer.outputDevices[device].priority) { - device = i; - } else if(Printer.outputDevices[i].priority == Printer.outputDevices[device].priority) { - base.defaultAmbiguous = true; - } - } - - if(device != null) { - base.currentDevice = device; - } - } - } - } - - style: ButtonStyle { - background: UM.AngledCornerRectangle { - implicitWidth: control.width; - implicitHeight: control.height; - - color: UM.Theme.colors.save_button_border; - cornerSize: UM.Theme.sizes.default_margin.width; - - UM.AngledCornerRectangle { - anchors.fill: parent; - anchors.margins: UM.Theme.sizes.save_button_border.width; - cornerSize: UM.Theme.sizes.default_margin.width; - color: UM.Theme.colors.save_button; - } - - UM.AngledCornerRectangle { - anchors { - left: parent.left; - top: parent.top; - bottom: parent.bottom; - } - - width: Math.max(parent.height + (parent.width - parent.height) * control.progress, parent.height); - cornerSize: UM.Theme.sizes.default_margin.width; - - color: !control.enabled ? UM.Theme.colors.save_button_inactive : control.hovered ? UM.Theme.colors.save_button_active_hover : UM.Theme.colors.save_button_active; - Behavior on color { ColorAnimation { duration: 50; } } - } - - UM.AngledCornerRectangle { - anchors.left: parent.left; - width: parent.height + UM.Theme.sizes.save_button_border.width; - height: parent.height; - cornerSize: UM.Theme.sizes.default_margin.width; - color: UM.Theme.colors.save_button; - } - - UM.AngledCornerRectangle { - anchors.left: parent.left; - width: parent.height + UM.Theme.sizes.save_button_border.width; - height: parent.height; - cornerSize: UM.Theme.sizes.default_margin.width; - - color: UM.Theme.colors.save_button; - } - - UM.AngledCornerRectangle { - id: icon; - - anchors.left: parent.left; - width: parent.height; - height: parent.height; - cornerSize: UM.Theme.sizes.default_margin.width; - color: !control.enabled ? UM.Theme.colors.save_button_inactive : control.hovered ? UM.Theme.colors.save_button_active_hover : UM.Theme.colors.save_button_active; - Behavior on color { ColorAnimation { duration: 50; } } - - Image { - anchors.centerIn: parent; - - width: UM.Theme.sizes.button_icon.width; - height: UM.Theme.sizes.button_icon.height; - - sourceSize.width: width; - sourceSize.height: height; - - source: control.iconSource; - } - } - } - - label: Label { - id: label; - anchors.top: parent.top; - anchors.topMargin: UM.Theme.sizes.save_button_label_margin.height; - anchors.left: parent.left; - anchors.leftMargin: control.height + UM.Theme.sizes.save_button_label_margin.width; - - color: UM.Theme.colors.save_button_text; - font: UM.Theme.fonts.default; - - text: control.text; - } - } - - MouseArea { - anchors.fill: parent; - - acceptedButtons: Qt.RightButton; - - onClicked: devicesMenu.popup(); - } - - Menu { - id: devicesMenu; - - Instantiator { - model: Printer.outputDeviceNames; - MenuItem { - text: Printer.outputDevices[modelData].description; - checkable: true; - checked: base.defaultAmbiguous ? false : modelData == base.currentDevice; - exclusiveGroup: devicesMenuGroup; - onTriggered: { - base.defaultOverride = true; - base.currentDevice = modelData; - if(base.defaultAmbiguous) { - base.defaultAmbiguous = false; - Printer.writeToOutputDevice(modelData); - } - } - } - onObjectAdded: devicesMenu.insertItem(index, object) - onObjectRemoved: devicesMenu.removeItem(object) - } - - ExclusiveGroup { id: devicesMenuGroup; } - } - - text: { - if(base.progress < 0) { - return qsTr("Please load a 3D model"); - } else if (base.progress < 0.95) { - return qsTr("Calculating Print-time"); - } else { - return qsTr("Estimated Print-time"); - } - } - - onClicked: { - if(base.defaultAmbiguous) { - devicesMenu.popup(); - } else { - Printer.writeToOutputDevice(base.currentDevice); - } - } -} diff --git a/qml/Sidebar.qml b/qml/Sidebar.qml deleted file mode 100644 index 43b6c43bbb..0000000000 --- a/qml/Sidebar.qml +++ /dev/null @@ -1,76 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -UM.AngledCornerRectangle { - id: base; - - property Action addMachineAction; - property Action configureMachinesAction; - property alias saveAction: saveButton.saveAction; - - cornerSize: UM.Theme.sizes.default_margin.width; - - function showTooltip(item, position, text) { - tooltip.text = text; - position = item.mapToItem(base, position.x, position.y); - tooltip.show(position); - } - - function hideTooltip() { - tooltip.hide(); - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.AllButtons; - - onWheel: { - wheel.accepted = true; - } - } - - ColumnLayout { - anchors.fill: parent; - anchors.topMargin: UM.Theme.sizes.default_margin.height; - anchors.bottomMargin: UM.Theme.sizes.window_margin.height; - - spacing: UM.Theme.sizes.default_margin.height; - - SidebarHeader { - id: header; - - Layout.fillWidth: true; - - addMachineAction: base.addMachineAction; - configureMachinesAction: base.configureMachinesAction; - } - - Loader { - id: sidebarContents; - - Layout.fillWidth: true; - Layout.fillHeight: true; - - source: header.currentModeFile; - - property Item sidebar: base; - - onLoaded: if(item) item.configureSettings = base.configureMachinesAction - } - - SaveButton { - id: saveButton; - Layout.preferredWidth: base.width - UM.Theme.sizes.default_margin.width * 2; - Layout.preferredHeight: UM.Theme.sizes.button.height; - Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter; - } - } - - SidebarTooltip { - id: tooltip; - } -} diff --git a/qml/SidebarAdvanced.qml b/qml/SidebarAdvanced.qml deleted file mode 100644 index a26d5f0fd2..0000000000 --- a/qml/SidebarAdvanced.qml +++ /dev/null @@ -1,150 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -ScrollView { - id: base; - - style: UM.Theme.styles.scrollview; - - property Action configureSettings; - - Column { - id: contents - spacing: UM.Theme.sizes.default_margin.height; - - Repeater { - model: UM.Models.settingCategoriesModel; - - delegate: Item { - id: delegateItem; - - width: childrenRect.width; - height: childrenRect.height; - - visible: model.visible; - - property variant settingsModel: model.settings; - - SidebarCategoryHeader { - id: categoryHeader; - - width: base.viewport.width; - height: UM.Theme.sizes.section.height; - - text: model.name; - iconSource: UM.Theme.icons[model.icon]; - checkable: true; - } - - Column { - id: settings; - - anchors.top: categoryHeader.bottom; - anchors.topMargin: 0; - - height: 0; - width: UM.Theme.sizes.setting.width; - spacing: UM.Theme.sizes.default_margin.height; - opacity: 0; - - property real childrenHeight: { - var h = 0.0; - for(var i in children) { - var item = children[i]; - h += children[i].height; - if(item.settingVisible) { - if(i > 0) { - h += spacing; - } - } - } - return h; - } - - Repeater { - model: delegateItem.settingsModel; - - delegate: UM.SettingItem { - id: item; - - width: UM.Theme.sizes.setting.width; - - height: model.visible ? UM.Theme.sizes.setting.height : 0; - Behavior on height { NumberAnimation { duration: 75; } } - opacity: model.visible ? 1 : 0; - Behavior on opacity { NumberAnimation { duration: 75; } } - - enabled: categoryHeader.checked && model.visible; - - property bool settingVisible: model.visible; - - name: model.name; - description: model.description; - value: model.value; - unit: model.unit; - valid: model.valid; - type: model.type; - options: model.type == "enum" ? model.options : null; - key: model.key; - - style: UM.Theme.styles.setting_item; - - onItemValueChanged: delegateItem.settingsModel.setSettingValue(index, model.key, value); - onContextMenuRequested: contextMenu.popup(); - - onShowTooltip: { - position = { x: UM.Theme.sizes.default_margin.width, y: item.height } - sidebar.showTooltip(item, position, model.description); - } - onHideTooltip: sidebar.hideTooltip(); - - Menu { - id: contextMenu; - - MenuItem { - //: Settings context menu action - text: qsTr("Hide this setting"); - onTriggered: delegateItem.settingsModel.hideSetting(model.key); - } - MenuItem { - //: Settings context menu action - text: qsTr("Configure setting visiblity..."); - - onTriggered: if(base.configureSettings) base.configureSettings.trigger(); - } - } - } - } - - states: State { - name: "expanded"; - when: categoryHeader.checked; - - PropertyChanges { - target: settings; - opacity: 1; - height: settings.childrenHeight; - anchors.topMargin: UM.Theme.sizes.default_margin.height; - } - } - - transitions: Transition { - to: "expanded"; - reversible: true; - SequentialAnimation { - ParallelAnimation { - NumberAnimation { property: "height"; duration: 75; } - NumberAnimation { property: "anchors.topMargin"; duration: 75; } - } - NumberAnimation { property: "opacity"; duration: 75; } - } - } - } - } - } - } -} diff --git a/qml/SidebarCategoryHeader.qml b/qml/SidebarCategoryHeader.qml deleted file mode 100644 index 1a9ffd75ac..0000000000 --- a/qml/SidebarCategoryHeader.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -Button { - id: base; - - Layout.preferredHeight: UM.Theme.sizes.section.height; - Layout.preferredWidth: UM.Theme.sizes.section.width; - - property variant color; - - style: UM.Theme.styles.sidebar_category; -} diff --git a/qml/SidebarHeader.qml b/qml/SidebarHeader.qml deleted file mode 100644 index 8d0601794a..0000000000 --- a/qml/SidebarHeader.qml +++ /dev/null @@ -1,120 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -Column { - id: base; - - property string currentModeFile: modeModel.get(modeMenu.currentIndex).file; - property Action addMachineAction; - property Action configureMachinesAction; - - spacing: UM.Theme.sizes.default_margin.height; - - RowLayout { - anchors.horizontalCenter: parent.horizontalCenter; - - width: parent.width - UM.Theme.sizes.default_margin.width * 2; - height: UM.Theme.sizes.line.height; - - Label { - text: qsTr("Mode:"); - - font: UM.Theme.fonts.sidebar_header; - color: UM.Theme.colors.text_inactive; - } - - ToolButton { - text: qsTr(modeModel.get(modeMenu.currentIndex).text); - - style: UM.Theme.styles.sidebar_header_button; - - Layout.preferredWidth: base.width * 0.25; - - menu: Menu { - id: modeMenu; - - property int currentIndex: 0; - - Instantiator { - model: ListModel { - id: modeModel; - ListElement { text: QT_TR_NOOP("Simple"); file: "SidebarSimple.qml" } - ListElement { text: QT_TR_NOOP("Advanced"); file: "SidebarAdvanced.qml" } - } - - MenuItem { - text: qsTr(model.text); - checkable: true; - checked: modeMenu.currentIndex == index; - exclusiveGroup: modeMenuGroup; - onTriggered: modeMenu.currentIndex = index; - } - onObjectAdded: modeMenu.insertItem(index, object) - onObjectRemoved: modeMenu.removeItem(object) - } - - ExclusiveGroup { id: modeMenuGroup; } - } - } - - Rectangle { - width: 1; - height: parent.height; - color: UM.Theme.colors.border; - } - - Label { - text: qsTr("Printer:"); - - font: UM.Theme.fonts.sidebar_header; - color: UM.Theme.colors.text_inactive; - } - - ToolButton { - id: machineButton; - text: UM.Application.machineName; - - style: UM.Theme.styles.sidebar_header_button; - - Layout.fillWidth: true; - - menu: Menu { - id: machineMenu; - Instantiator { - model: UM.Models.machinesModel - MenuItem { - text: model.name; - checkable: true; - checked: model.active; - exclusiveGroup: machineMenuGroup; - onTriggered: UM.Models.machinesModel.setActive(index) - } - onObjectAdded: machineMenu.insertItem(index, object) - onObjectRemoved: machineMenu.removeItem(object) - } - - ExclusiveGroup { id: machineMenuGroup; } - - MenuSeparator { } - - MenuItem { action: base.addMachineAction; } - MenuItem { action: base.configureMachinesAction; } - } - } - } - - SidebarCategoryHeader { - width: parent.width; - height: UM.Theme.sizes.section.height; - - iconSource: UM.Theme.icons.printsetup; - text: qsTr("Print Setup"); - enabled: false; - - color: UM.Theme.colors.primary; - } -} diff --git a/qml/SidebarSimple.qml b/qml/SidebarSimple.qml deleted file mode 100644 index 53dbb5a48a..0000000000 --- a/qml/SidebarSimple.qml +++ /dev/null @@ -1,82 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -Item { - anchors.fill: parent; - anchors.leftMargin: UM.Theme.sizes.default_margin.width; - anchors.rightMargin: UM.Theme.sizes.default_margin.width; - - property Action configureSettings; - - ColumnLayout { - anchors.fill: parent; - - Item { - Layout.fillWidth: true; - Layout.preferredHeight: UM.Theme.sizes.section.height; - - Label { - anchors.left: parent.left; - anchors.verticalCenter: parent.verticalCenter; - text: "00:00"; - font: UM.Theme.fonts.timeslider_time; - color: UM.Theme.colors.primary; - } - Label { anchors.centerIn: parent; text: "Estimated Print Time"; color: UM.Theme.colors.text; font: UM.Theme.fonts.default; } - Label { - anchors.right: parent.right; - anchors.verticalCenter: parent.verticalCenter; - text: "21:00"; - font: UM.Theme.fonts.timeslider_time; - color: UM.Theme.colors.primary; - } - } - - Slider { - Layout.fillWidth: true; - Layout.preferredHeight: UM.Theme.sizes.section.height; - - minimumValue: 0; - maximumValue: 100; - - style: UM.Theme.styles.slider; - } - - Item { - Layout.fillWidth: true; - Layout.preferredHeight: UM.Theme.sizes.section.height; - - Label { - anchors.left: parent.left; - anchors.verticalCenter: parent.verticalCenter; - text: "Minimum\nDraft"; - color: UM.Theme.colors.text; - font: UM.Theme.fonts.default; - } - - Label { - anchors.right: parent.right; - anchors.verticalCenter: parent.verticalCenter; - text: "Maximum\nQuality"; - horizontalAlignment: Text.AlignRight; - color: UM.Theme.colors.text; - font: UM.Theme.fonts.default; - } - } - - CheckBox { - Layout.fillWidth: true; - Layout.preferredHeight: UM.Theme.sizes.section.height; - - text: "Enable Support"; - - style: UM.Theme.styles.checkbox; - } - - Item { Layout.fillWidth: true; Layout.fillHeight: true; } - } -} diff --git a/qml/SidebarTooltip.qml b/qml/SidebarTooltip.qml deleted file mode 100644 index 643e6b75e0..0000000000 --- a/qml/SidebarTooltip.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.0 as UM - -Rectangle { - id: base; - - width: UM.Theme.sizes.tooltip.width; - height: label.height + UM.Theme.sizes.tooltip_margins.height * 2; - color: UM.Theme.colors.tooltip; - - opacity: 0; - Behavior on opacity { NumberAnimation { duration: 100; } } - - property alias text: label.text; - - function show(position) { - if(position.y + base.height > parent.height) { - x = position.x; - y = parent.height - base.height; - } else { - x = position.x; - y = position.y; - } - base.opacity = 1; - } - - function hide() { - base.opacity = 0; - } - - Label { - id: label; - anchors { - top: parent.top; - topMargin: UM.Theme.sizes.tooltip_margins.height; - left: parent.left; - leftMargin: UM.Theme.sizes.tooltip_margins.width; - right: parent.right; - rightMargin: UM.Theme.sizes.tooltip_margins.width; - } - wrapMode: Text.Wrap; - font: UM.Theme.fonts.default; - } -}