Skip to content

Commit

Permalink
Merge pull request #106 from center-for-threat-informed-defense/AF-15…
Browse files Browse the repository at this point in the history
…5_macos_hotkeys

AF-155: Improved Hotkeys
  • Loading branch information
mikecarenzo committed Aug 29, 2023
2 parents 43bf696 + 704f317 commit b0be7f4
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 53 deletions.
75 changes: 75 additions & 0 deletions src/attack_flow_builder/public/settings_macos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"file": {
"image_export": {
"padding": 30
}
},
"edit": {
"clone_offset": [20, 20]
},
"view": {
"diagram": {
"display_grid": true,
"display_shadows": true,
"display_debug_mode": false,
"render_high_quality": true,
"disable_shadows_at": 0.7
}
},
"hotkeys": {
"file": {
"new_file": "Control+N",
"open_file": "Meta+O",
"save_file": "Meta+S",
"save_image": "",
"save_select_image": "",
"publish_file": "",
"open_library": "",
"save_library": ""
},
"edit": {
"undo": "Meta+Z",
"redo": "Meta+Y",
"cut": "Meta+X",
"copy": "Meta+C",
"paste": "Meta+V",
"delete": "Backspace",
"duplicate": "Meta+D",
"find": "Meta+F",
"find_next": "Meta+G",
"find_previous": "Shift+Meta+G",
"select_all": "Meta+A"
},
"layout": {
"selection_to_front": "Shift+Meta+F",
"selection_to_back": "Shift+Meta+B",
"bring_selection_forward": "",
"send_selection_backward": "",
"align_left": "",
"align_center": "",
"align_right": "",
"align_top": "",
"align_middle": "",
"align_bottom": "",
"group": "Meta+G",
"ungroup": "Meta+Shift+U",
"open_group": "",
"close_group": ""
},
"view": {
"toggle_grid": "Alt+G",
"toggle_shadows": "",
"reset_view": "Escape",
"zoom_in": "",
"zoom_out": "",
"fullscreen": "",
"jump_to_selection": "Shift+Z",
"jump_to_parents": "Shift+P",
"jump_to_children": "Shift+C",
"toggle_debug_view": ""
},
"select": {
"many": "Meta"
}
}
}
16 changes: 13 additions & 3 deletions src/attack_flow_builder/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ import Configuration from "@/assets/builder.config"
import { clamp } from "./assets/scripts/BlockDiagram";
import { PointerTracker } from "./assets/scripts/PointerTracker";
import { mapMutations, mapState } from 'vuex';
import { Browser, OperatingSystem } from "./assets/scripts/Browser";
import { defineComponent, markRaw, ref } from 'vue';
// Components
import FindDialog from "@/components/Elements/FindDialog.vue";
import SplashMenu from "@/components/Controls/SplashMenu.vue";
import AppTitleBar from "@/components/Elements/AppTitleBar.vue";
import AppHotkeyBox from "@/components/Elements/AppHotkeyBox.vue";
import BlockDiagram from "@/components/Elements/BlockDiagram.vue";
import AppFooterBar from "@/components/Elements/AppFooterBar.vue";
import EditorSidebar from "@/components/Elements/EditorSidebar.vue";
import FindDialog from "@/components/Elements/FindDialog.vue";
const Handle = {
None : 0,
Expand Down Expand Up @@ -165,11 +166,20 @@ export default defineComponent({
},
async created() {
// Import settings
let os = Browser.getOperatingSystemClass();
let settings;
if(Configuration.is_web_hosted) {
settings = await (await fetch("./settings.json")).json();
if(os === OperatingSystem.MacOS) {
settings = await (await fetch("../public/settings_macos.json")).json();
} else {
settings = await (await fetch("../public/settings_win.json")).json();
}
} else {
settings = require("../public/settings.json");
if(os === OperatingSystem.MacOS) {
settings = require("../public/settings_macos.json");
} else {
settings = require("../public/settings_win.json");
}
}
// Load settings
this.execute(new App.LoadSettings(this.context, settings));
Expand Down
37 changes: 36 additions & 1 deletion src/attack_flow_builder/src/assets/scripts/Browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,43 @@ export class Browser {
cast.msRequestFullscreen();
}
}


///////////////////////////////////////////////////////////////////////////
// 4. Operating System Detection ////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////


/**
* Returns the device's current operating system class.
* @returns
* The device's current operating system class.
*/
public static getOperatingSystemClass(): OperatingSystem {
if(navigator.userAgent.search("Win") !== -1) {
return OperatingSystem.Windows
} else if(navigator.userAgent.search("Mac") !== -1) {
return OperatingSystem.MacOS;
} else if(navigator.userAgent.search("X11") !== -1) {
return OperatingSystem.UNIX;
} else if(navigator.userAgent.search("Linux") !== -1) {
return OperatingSystem.Linux;
} else {
return OperatingSystem.Other;
}
}


}

/**
* Recognized operating systems.
*/
export enum OperatingSystem {
Windows,
MacOS,
UNIX,
Linux,
Other
}


Expand Down
Loading

0 comments on commit b0be7f4

Please sign in to comment.