IDE actions and menu

This commit is contained in:
Vadim Lopatin 2015-01-26 17:35:59 +03:00
parent aeb265f224
commit 75a2bf89a7
3 changed files with 32 additions and 7 deletions

View File

@ -5,10 +5,13 @@ import dlangui.widgets.editors;
enum IDEActions : int {
None = 0,
ProjectOpen = 1010000,
FileNew,
//ProjectOpen = 1010000,
FileNew = 1010000,
FileOpen,
FileOpenWorkspace,
FileSave,
FileSaveAs,
FileSaveAll,
FileClose,
FileExit,
BuildWorkspace,
@ -29,7 +32,10 @@ enum IDEActions : int {
const Action ACTION_FILE_NEW = new Action(IDEActions.FileOpen, "MENU_FILE_NEW"c, "document-new", KeyCode.KEY_N, KeyFlag.Control);
const Action ACTION_FILE_OPEN = new Action(IDEActions.FileOpen, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control);
const Action ACTION_FILE_OPEN_WORKSPACE = new Action(IDEActions.FileOpenWorkspace, "MENU_FILE_OPEN_WORKSPACE"c, null, KeyCode.KEY_O, KeyFlag.Control | KeyFlag.Shift);
const Action ACTION_FILE_SAVE = new Action(IDEActions.FileSave, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control);
const Action ACTION_FILE_SAVE_AS = new Action(IDEActions.FileSaveAs, "MENU_FILE_SAVE_AS"c);
const Action ACTION_FILE_SAVE_ALL = new Action(IDEActions.FileSaveAll, "MENU_FILE_SAVE_ALL"c, null, KeyCode.KEY_S, KeyFlag.Control | KeyFlag.Shift);
const Action ACTION_FILE_EXIT = new Action(IDEActions.FileExit, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt);
const Action ACTION_WORKSPACE_BUILD = new Action(IDEActions.BuildWorkspace, "MENU_BUILD_WORKSPACE_BUILD"c);
const Action ACTION_WORKSPACE_REBUILD = new Action(IDEActions.RebuildWorkspace, "MENU_BUILD_WORKSPACE_REBUILD"c);

View File

@ -192,10 +192,12 @@ class IDEFrame : AppFrame {
mainMenuItems = new MenuItem();
MenuItem fileItem = new MenuItem(new Action(1, "MENU_FILE"));
fileItem.add(ACTION_FILE_NEW, ACTION_FILE_OPEN, ACTION_FILE_SAVE, ACTION_FILE_EXIT);
fileItem.add(ACTION_FILE_NEW, ACTION_FILE_OPEN_WORKSPACE, ACTION_FILE_OPEN,
ACTION_FILE_SAVE, ACTION_FILE_SAVE_AS, ACTION_FILE_SAVE_ALL, ACTION_FILE_EXIT);
MenuItem editItem = new MenuItem(new Action(2, "MENU_EDIT"));
editItem.add(ACTION_EDIT_COPY, ACTION_EDIT_PASTE, ACTION_EDIT_CUT, ACTION_EDIT_UNDO, ACTION_EDIT_REDO);
editItem.add(ACTION_EDIT_COPY, ACTION_EDIT_PASTE,
ACTION_EDIT_CUT, ACTION_EDIT_UNDO, ACTION_EDIT_REDO);
editItem.add(new Action(20, "MENU_EDIT_PREFERENCES"));
@ -207,7 +209,8 @@ class IDEFrame : AppFrame {
ACTION_PROJECT_BUILD, ACTION_PROJECT_REBUILD, ACTION_PROJECT_CLEAN);
MenuItem debugItem = new MenuItem(new Action(23, "MENU_DEBUG"));
debugItem.add(ACTION_DEBUG_START, ACTION_DEBUG_START_NO_DEBUG, ACTION_DEBUG_CONTINUE, ACTION_DEBUG_STOP, ACTION_DEBUG_PAUSE);
debugItem.add(ACTION_DEBUG_START, ACTION_DEBUG_START_NO_DEBUG,
ACTION_DEBUG_CONTINUE, ACTION_DEBUG_STOP, ACTION_DEBUG_PAUSE);
MenuItem windowItem = new MenuItem(new Action(3, "MENU_WINDOW"c));
@ -262,6 +265,7 @@ class IDEFrame : AppFrame {
UIString caption;
caption = "Open Text File"d;
FileDialog dlg = new FileDialog(caption, window, null);
dlg.addFilter(FileFilterEntry(UIString("Source files"d), "*.d;*.dd;*.ddoc;*.dh;*.json;*.xml;*.ini"));
dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
if (result.id == ACTION_OPEN.id) {
string filename = result.stringParam;
@ -272,6 +276,18 @@ class IDEFrame : AppFrame {
};
dlg.show();
return true;
case IDEActions.FileOpenWorkspace:
UIString caption;
caption = "Open Workspace or Project"d;
FileDialog dlg = new FileDialog(caption, window, null);
dlg.addFilter(FileFilterEntry(UIString("Workspace and project files"d), "*.dlangidews;dub.json"));
dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
if (result.id == ACTION_OPEN.id) {
string filename = result.stringParam;
}
};
dlg.show();
return true;
default:
return super.handleAction(a);
}

View File

@ -1,9 +1,12 @@
EXIT=Exit
MENU_FILE=&FILE
MENU_FILE_NEW=&New
MENU_FILE_OPEN=&Open
MENU_FILE_OPEN=&Open file
MENU_FILE_OPEN_WORKSPACE=Open project or workspace
MENU_FILE_OPEN_RECENT=Open recent
MENU_FILE_SAVE=&Save
MENU_FILE_SAVE=&Save file
MENU_FILE_SAVE_AS=&Save file as...
MENU_FILE_SAVE_ALL=&Save All
MENU_FILE_EXIT=E&xit
MENU_EDIT=&EDIT
MENU_EDIT_COPY=&Copy