From f4ea53861558dc0d77ae8d2a4e00437fe1304a3d Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 24 Feb 2015 18:12:33 +0100 Subject: [PATCH] Move Actions to their own file for more separation --- Printer.qml | 134 ++++++++++----------------------------------- PrinterActions.qml | 111 +++++++++++++++++++++++++++++++++++++ PrinterToolbar.qml | 1 + 3 files changed, 141 insertions(+), 105 deletions(-) create mode 100644 PrinterActions.qml diff --git a/Printer.qml b/Printer.qml index e3e4fcc414..9136e8bc5f 100644 --- a/Printer.qml +++ b/Printer.qml @@ -27,23 +27,23 @@ UM.MainWindow { //: File menu title: qsTr("&File"); - MenuItem { action: openAction; } - MenuItem { action: saveAction; } + MenuItem { action: actions.open; } + MenuItem { action: actions.save; } MenuSeparator { } - MenuItem { action: quitAction; } + MenuItem { action: actions.quit; } } Menu { //: Edit menu title: qsTr("&Edit"); - MenuItem { action: undoAction; } - MenuItem { action: redoAction; } + MenuItem { action: actions.undo; } + MenuItem { action: actions.redo; } MenuSeparator { } - MenuItem { action: deleteAction; } - MenuItem { action: deleteAllAction; } + MenuItem { action: actions.deleteSelection; } + MenuItem { action: actions.deleteAll; } } Menu { @@ -69,8 +69,8 @@ UM.MainWindow { MenuSeparator { } - MenuItem { action: addMachineAction; } - MenuItem { action: settingsAction; } + MenuItem { action: actions.addMachine; } + MenuItem { action: actions.settings; } } Menu { @@ -85,15 +85,15 @@ UM.MainWindow { //: Settings menu title: qsTr("&Settings"); - MenuItem { action: preferencesAction; } + MenuItem { action: actions.preferences; } } Menu { //: Help menu title: qsTr("&Help"); - MenuItem { action: helpAction; enabled: false; } - MenuItem { action: aboutAction; enabled: false; } + MenuItem { action: actions.help; } + MenuItem { action: actions.about; } } } @@ -126,9 +126,9 @@ UM.MainWindow { top: parent.top; } - undo: undoAction; - redo: redoAction; - settings: settingsAction; + undo: actions.undo; + redo: actions.redo; + settings: actions.settings; } FilePane { @@ -145,7 +145,7 @@ UM.MainWindow { width: UM.Theme.panelWidth; height: base.height / 2 - UM.Theme.toolbarHeight; - onRequestOpenFile: openAction.trigger(); + onRequestOpenFile: actions.open.trigger(); onOpenFile: UM.Controller.addMesh(file); } @@ -198,105 +198,29 @@ UM.MainWindow { UM.PreferencesDialog { id: preferences } - Action { - id: undoAction; - //: Undo action - text: qsTr("Undo"); - iconName: "edit-undo"; - shortcut: StandardKey.Undo; - onTriggered: UM.OperationStack.undo(); - enabled: UM.OperationStack.canUndo; - } + PrinterActions { + id: actions; - Action { - id: redoAction; - //: Redo action - text: qsTr("Redo"); - iconName: "edit-redo"; - shortcut: StandardKey.Redo; - onTriggered: UM.OperationStack.redo(); - enabled: UM.OperationStack.canRedo; - } + open.onTriggered: openDialog.open(); + save.onTriggered: saveDialog.open(); - Action { - id: quitAction; - //: Quit action - text: qsTr("Quit"); - iconName: "application-exit"; - shortcut: StandardKey.Quit; - onTriggered: base.visible = false; - } + quit.onTriggered: base.visible = false; - Action { - id: preferencesAction; - //: Preferences action - text: qsTr("Preferences"); - iconName: "configure"; - onTriggered: preferences.visible = true; - } + undo.onTriggered: UM.OperationStack.undo(); + undo.enabled: UM.OperationStack.canUndo; + redo.onTriggered: UM.OperationStack.redo(); + redo.enabled: UM.OperationStack.canRedo; - Action { - id: settingsAction; - //: Manage Printers action - text: qsTr("Configure Printers"); - iconSource: UM.Resources.getIcon("settings.png"); - onTriggered: preferences.visible = true; - } + deleteSelection.onTriggered: UM.Controller.removeSelection(); - Action { - id: helpAction; - //: Show Manual action - text: qsTr("Show Manual"); - iconName: "help-contents"; - shortcut: StandardKey.Help; - } - - Action { - id: aboutAction; - //: About action - text: qsTr("About..."); - iconName: "help-about"; - } - - Action { - id: deleteAction; - //: Delete selection action - text: qsTr("Delete Selection"); - iconName: "edit-delete"; - shortcut: StandardKey.Delete; - onTriggered: UM.Controller.removeSelection(); - } - - Action { - id: deleteAllAction; - //: Clear build platform action - text: qsTr("Clear Build Platform"); - iconName: "edit-clear"; - enabled: false; - } - - Action { - id: openAction; - //: Open file action - text: qsTr("Open..."); - iconName: "document-open"; - shortcut: StandardKey.Open; - onTriggered: openDialog.open(); - } - - Action { - id: saveAction; - //: Save file action - text: qsTr("Save..."); - iconName: "document-save"; - shortcut: StandardKey.Save; - onTriggered: saveDialog.open(); + preferences.onTriggered: preferences.visible = true; + settings.onTriggered: preferences.visible = true; } Menu { id: contextMenu; - MenuItem { action: deleteAction; } + MenuItem { action: actions.deleteSelection; } } FileDialog { diff --git a/PrinterActions.qml b/PrinterActions.qml new file mode 100644 index 0000000000..dd247527bd --- /dev/null +++ b/PrinterActions.qml @@ -0,0 +1,111 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Item { + property alias open: openAction; + property alias save: saveAction; + property alias quit: quitAction; + + property alias undo: undoAction; + property alias redo: redoAction; + + property alias deleteSelection: deleteAction; + property alias deleteAll: deleteAllAction; + + property alias addMachine: addMachineAction; + property alias settings: settingsAction; + + property alias preferences: preferencesAction; + property alias help: helpAction; + property alias about: aboutAction; + + Action { + id: undoAction; + //: Undo action + text: qsTr("Undo"); + iconName: "edit-undo"; + shortcut: StandardKey.Undo; + } + + Action { + id: redoAction; + //: Redo action + text: qsTr("Redo"); + iconName: "edit-redo"; + shortcut: StandardKey.Redo; + } + + Action { + id: quitAction; + //: Quit action + text: qsTr("Quit"); + iconName: "application-exit"; + shortcut: StandardKey.Quit; + } + + Action { + id: preferencesAction; + //: Preferences action + text: qsTr("Preferences"); + iconName: "configure"; + } + + Action { + id: addMachineAction; + //: Add a Machine action + text: qsTr("Add Printer..."); + } + + Action { + id: settingsAction; + //: Manage Printers action + text: qsTr("Configure Printers"); + iconName: "configure"; + } + + Action { + id: helpAction; + //: Show Manual action + text: qsTr("Show Manual"); + iconName: "help-contents"; + shortcut: StandardKey.Help; + } + + Action { + id: aboutAction; + //: About action + text: qsTr("About..."); + iconName: "help-about"; + } + + Action { + id: deleteAction; + //: Delete selection action + text: qsTr("Delete Selection"); + iconName: "edit-delete"; + shortcut: StandardKey.Delete; + } + + Action { + id: deleteAllAction; + //: Clear build platform action + text: qsTr("Clear Build Platform"); + iconName: "edit-clear"; + } + + Action { + id: openAction; + //: Open file action + text: qsTr("Open..."); + iconName: "document-open"; + shortcut: StandardKey.Open; + } + + Action { + id: saveAction; + //: Save file action + text: qsTr("Save..."); + iconName: "document-save"; + shortcut: StandardKey.Save; + } +} diff --git a/PrinterToolbar.qml b/PrinterToolbar.qml index 692b5368ce..29a9214dbd 100644 --- a/PrinterToolbar.qml +++ b/PrinterToolbar.qml @@ -153,6 +153,7 @@ UM.Toolbar { foregroundHighlightColor: "black"; } action: base.settings; + iconSource: UM.Resources.getIcon("settings.png"); } Item { width: UM.Theme.windowRightMargin; }