This commit is contained in:
Tamara Hogenhout 2015-08-03 13:21:06 +02:00
commit c1b55cc651
14 changed files with 520 additions and 240 deletions

View file

@ -7,7 +7,7 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import UM 1.0 as UM
import UM 1.1 as UM
UM.MainWindow {
id: base
@ -30,24 +30,52 @@ UM.MainWindow {
title: qsTr("&File");
MenuItem { action: actions.open; }
MenuItem { action: actions.save; }
Menu {
id: recentFilesMenu;
title: "Open Recent"
iconName: "document-open-recent";
enabled: Printer.recentFiles.length > 0;
Instantiator {
model: Printer.recentFiles
MenuItem {
text: {
var path = modelData.toString()
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
}
onTriggered: UM.MeshFileHandler.readLocalFile(modelData);
}
onObjectAdded: recentFilesMenu.insertItem(index, object)
onObjectRemoved: recentFilesMenu.removeItem(object)
}
}
MenuSeparator { }
Instantiator {
model: Printer.recentFiles
MenuItem {
text: {
var path = modelData.toString()
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
}
onTriggered: {
UM.MeshFileHandler.readLocalFile(modelData);
Printer.setPlatformActivity(true)
MenuItem {
text: "Save Selection to File";
enabled: UM.Selection.hasSelection;
iconName: "document-save-as";
onTriggered: devicesModel.requestWriteSelectionToDevice("local_file");
}
Menu {
id: saveAllMenu
title: "Save All"
iconName: "document-save";
enabled: devicesModel.count > 0 && UM.Backend.progress > 0.99;
Instantiator {
model: UM.OutputDevicesModel { id: devicesModel; }
MenuItem {
text: model.description
onTriggered: devicesModel.requestWriteToDevice(model.id);
}
onObjectAdded: saveAllMenu.insertItem(index, object)
onObjectRemoved: saveAllMenu.removeItem(object)
}
onObjectAdded: fileMenu.insertItem(index, object)
onObjectRemoved: fileMenu.removeItem(object)
}
MenuSeparator { }
@ -65,7 +93,26 @@ UM.MainWindow {
MenuItem { action: actions.deleteSelection; }
MenuItem { action: actions.deleteAll; }
}
Menu
{
title: qsTr("&View");
id: top_view_menu
Instantiator
{
model: UM.Models.viewModel
MenuItem
{
text: model.name;
checkable: true;
checked: model.active;
exclusiveGroup: view_menu_top_group;
onTriggered: UM.Controller.setActiveView(model.id);
}
onObjectAdded: top_view_menu.insertItem(index, object)
onObjectRemoved: top_view_menu.removeItem(object)
}
ExclusiveGroup { id: view_menu_top_group; }
}
Menu {
id: machineMenu;
//: Machine menu
@ -281,7 +328,6 @@ UM.MainWindow {
addMachineAction: actions.addMachine;
configureMachinesAction: actions.configureMachines;
saveAction: actions.save;
}
Rectangle {
@ -439,22 +485,6 @@ UM.MainWindow {
}
}
FileDialog {
id: saveDialog;
//: File save dialog title
title: qsTr("Save File");
selectExisting: false;
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
nameFilters: UM.MeshFileHandler.supportedWriteFileTypes
onAccepted:
{
UM.MeshFileHandler.writeLocalFile(fileUrl);
}
}
EngineLog {
id: engineLog;
}
@ -474,7 +504,6 @@ UM.MainWindow {
addMachineWizard.visible = true
addMachineWizard.printer = false
}
onWriteToLocalFileRequested: saveDialog.open();
}
Component.onCompleted: UM.Theme.load(UM.Resources.getPath(UM.Resources.ThemesLocation, "cura"))

View file

@ -6,47 +6,18 @@ import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import UM 1.0 as UM
import UM 1.1 as UM
Rectangle {
id: base;
property Action saveAction;
property real progress: UM.Backend.progress;
property bool activity: Printer.getPlatformActivity;
Behavior on progress { NumberAnimation { duration: 250; } }
property string currentDevice: "local_file"
property bool defaultOverride: false;
property bool defaultAmbiguous: false;
property variant printDuration: PrintInformation.currentPrintTime;
property real printMaterialAmount: PrintInformation.materialAmount;
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;
}
}
}
}
Rectangle{
id: background
implicitWidth: base.width;
@ -76,7 +47,7 @@ Rectangle {
visible: base.progress >= 0 && base.progress < 0.99 ? false : true
color: UM.Theme.colors.save_button_estimated_text;
font: UM.Theme.fonts.small;
text:
text: {
if(base.activity == false) {
//: Save button label
return qsTr("Please load a 3D model");
@ -90,6 +61,8 @@ Rectangle {
//: Save button label
return qsTr("Estimated Print-time");
}
return "";
}
}
Label {
id: printDurationLabel
@ -113,7 +86,7 @@ Rectangle {
elide: mediumLengthDuration ? Text.ElideRight : Text.ElideNone
visible: base.activity == false || base.progress < 0.99 ? false : true
//: Print material amount save button label
text: base.printMaterialAmount < 0 ? "" : qsTr("%1m material").arg(base.printMaterialAmount);
text: base.printMaterialAmount < 0 ? "" : qsTr("%1m of Material").arg(base.printMaterialAmount);
}
}
Rectangle {
@ -134,29 +107,28 @@ Rectangle {
anchors.topMargin: UM.Theme.sizes.save_button_text_margin.height;
anchors.left: parent.left
anchors.leftMargin: UM.Theme.sizes.default_margin.width;
tooltip: ''
tooltip: devicesModel.activeDevice.description;
enabled: progress > 0.99 && base.activity == true
width: infoBox.width/6*4.5
height: UM.Theme.sizes.save_button_save_to_button.height
text: devicesModel.activeDevice.short_description;
style: ButtonStyle {
background: Rectangle {
color: !control.enabled ? UM.Theme.colors.save_button_inactive : control.hovered ? UM.Theme.colors.save_button_active_hover : UM.Theme.colors.save_button_active;
Label {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.centerIn: parent
color: UM.Theme.colors.save_button_safe_to_text;
font: UM.Theme.fonts.sidebar_save_to;
text: Printer.outputDevices[base.currentDevice].shortDescription;
text: control.text;
}
}
label: Item { }
}
onClicked:
if(base.defaultAmbiguous) {
devicesMenu.popup();
} else {
Printer.writeToOutputDevice(base.currentDevice);
}
onClicked: devicesModel.requestWriteToDevice(devicesModel.activeDevice.id)
}
Button {
@ -165,16 +137,20 @@ Rectangle {
anchors.topMargin: UM.Theme.sizes.save_button_text_margin.height
anchors.right: parent.right
anchors.rightMargin: UM.Theme.sizes.default_margin.width;
tooltip: ''
tooltip: qsTr("Select the active output device");
width: infoBox.width/6*1.3 - UM.Theme.sizes.save_button_text_margin.height;
height: UM.Theme.sizes.save_button_save_to_button.height
iconSource: UM.Theme.icons[devicesModel.activeDevice.icon_name];
style: ButtonStyle {
background: Rectangle {
color: UM.Theme.colors.save_button_background;
border.width: control.hovered ? UM.Theme.sizes.save_button_border.width : 0
border.color: UM.Theme.colors.save_button_border
color: UM.Theme.colors.save_button_background;
border.width: control.hovered ? UM.Theme.sizes.save_button_border.width : 0
border.color: UM.Theme.colors.save_button_border
Rectangle {
id: deviceSelectionIcon
color: UM.Theme.colors.save_button_background;
@ -183,14 +159,13 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter;
width: parent.height - UM.Theme.sizes.save_button_text_margin.width ;
height: parent.height - UM.Theme.sizes.save_button_text_margin.width;
UM.RecolorImage {
anchors.centerIn: parent;
width: parent.width;
height: parent.height;
anchors.fill: parent;
sourceSize.width: width;
sourceSize.height: height;
color: UM.Theme.colors.save_button_active
source: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon];
source: control.iconSource;
}
}
Label {
@ -203,24 +178,20 @@ Rectangle {
color: UM.Theme.colors.save_button_active;
}
}
label: Item { }
}
menu: Menu {
id: devicesMenu;
Instantiator {
model: Printer.outputDeviceNames;
model: devicesModel;
MenuItem {
text: Printer.outputDevices[modelData].description;
text: model.description
checkable: true;
checked: base.defaultAmbiguous ? false : modelData == base.currentDevice;
checked: model.id == devicesModel.activeDevice.id;
exclusiveGroup: devicesMenuGroup;
onTriggered: {
base.defaultOverride = true;
base.currentDevice = modelData;
if(base.defaultAmbiguous) {
base.defaultAmbiguous = false;
Printer.writeToOutputDevice(modelData);
}
devicesModel.setActiveDevice(model.id);
}
}
onObjectAdded: devicesMenu.insertItem(index, object)
@ -230,4 +201,8 @@ Rectangle {
}
}
}
}
UM.OutputDevicesModel {
id: devicesModel;
}
}

View file

@ -13,7 +13,6 @@ Rectangle {
property Action addMachineAction;
property Action configureMachinesAction;
property alias saveAction: saveButton.saveAction;
color: UM.Theme.colors.sidebar;