From 6b81c71513e16297ba31fd49708ee440d2e43e25 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Wed, 13 Sep 2017 10:13:49 +0300 Subject: [PATCH] fix #287, #288 - main menu items enabled state fixed --- src/dlangide/ui/commands.d | 8 ++++---- src/dlangide/ui/frame.d | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index f935b19..c186200 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -79,7 +79,7 @@ const Action ACTION_PROJECT_FOLDER_OPEN_ITEM = new Action(IDEActions.ProjectFold const Action ACTION_PROJECT_FOLDER_REMOVE_ITEM = new Action(IDEActions.ProjectFolderRemoveItem, "MENU_PROJECT_FOLDER_REMOVE_ITEM"c); const Action ACTION_PROJECT_FOLDER_RENAME_ITEM = new Action(IDEActions.ProjectFolderRenameItem, "MENU_PROJECT_FOLDER_RENAME_ITEM"c); const Action ACTION_PROJECT_FOLDER_REFRESH = new Action(IDEActions.ProjectFolderRefresh, "MENU_PROJECT_FOLDER_REFRESH"c); -const Action ACTION_FILE_WORKSPACE_CLOSE = new Action(IDEActions.CloseWorkspace, "MENU_FILE_WORKSPACE_CLOSE"c); +const Action ACTION_FILE_WORKSPACE_CLOSE = new Action(IDEActions.CloseWorkspace, "MENU_FILE_WORKSPACE_CLOSE"c).disableByDefault(); const Action ACTION_FILE_NEW_SOURCE_FILE = new Action(IDEActions.FileNew, "MENU_FILE_NEW_SOURCE_FILE"c, "document-new", KeyCode.KEY_N, KeyFlag.Control); const Action ACTION_FILE_NEW_PROJECT = new Action(IDEActions.FileNewProject, "MENU_FILE_NEW_PROJECT"c); @@ -87,7 +87,7 @@ const Action ACTION_FILE_NEW_WORKSPACE = new Action(IDEActions.FileNewWorkspace, 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)).disableByDefault(); -const Action ACTION_FILE_SAVE_AS = (new Action(IDEActions.FileSaveAs, "MENU_FILE_SAVE_AS"c)).disableByDefault(); +const Action ACTION_FILE_SAVE_AS = (new Action(IDEActions.FileSaveAs, "MENU_FILE_SAVE_AS"c)).disableByDefault().disableByDefault(); const Action ACTION_FILE_SAVE_ALL = (new Action(IDEActions.FileSaveAll, "MENU_FILE_SAVE_ALL"c, null, KeyCode.KEY_S, KeyFlag.Control | KeyFlag.Shift)).disableByDefault(); 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); @@ -132,8 +132,8 @@ const Action ACTION_EDIT_PREFERENCES = (new Action(IDEActions.EditPreferences, " const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABOUT"c); const Action ACTION_HELP_VIEW_HELP = new Action(IDEActions.HelpViewHelp, "MENU_HELP_VIEW_HELP"c); const Action ACTION_HELP_DONATE = new Action(IDEActions.HelpDonate, "MENU_HELP_DONATE"c); -const Action ACTION_WINDOW_CLOSE_DOCUMENT = new Action(IDEActions.WindowCloseDocument, "MENU_WINDOW_CLOSE_DOCUMENT"c, null, KeyCode.KEY_W, KeyFlag.Control); -const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c); +const Action ACTION_WINDOW_CLOSE_DOCUMENT = new Action(IDEActions.WindowCloseDocument, "MENU_WINDOW_CLOSE_DOCUMENT"c, null, KeyCode.KEY_W, KeyFlag.Control).disableByDefault(); +const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c).disableByDefault(); const Action ACTION_WINDOW_SHOW_HOME_SCREEN = new Action(IDEActions.WindowShowHomeScreen, "MENU_WINDOW_SHOW_HOME_SCREEN"c); const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "OPTION_CREATE_NEW_WORKSPACE"c); diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index 7762c5a..85e2e6b 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -828,8 +828,6 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL return true; case IDEActions.FileExit: case IDEActions.FileOpen: - case IDEActions.WindowCloseDocument: - case IDEActions.WindowCloseAllDocuments: case IDEActions.WindowShowHomeScreen: case IDEActions.FileOpenWorkspace: // disable when background operation in progress @@ -891,6 +889,15 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL case IDEActions.FindInFiles: a.state = currentWorkspace !is null ? ACTION_STATE_ENABLED : ACTION_STATE_DISABLE; return true; + case IDEActions.CloseWorkspace: + a.state = (currentWorkspace !is null && !_currentBackgroundOperation) ? ACTION_STATE_ENABLED : ACTION_STATE_DISABLE; + return true; + case IDEActions.WindowCloseDocument: + case IDEActions.WindowCloseAllDocuments: + case IDEActions.FileSaveAll: + case IDEActions.FileSaveAs: + a.state = (currentEditor !is null && !_currentBackgroundOperation) ? ACTION_STATE_ENABLED : ACTION_STATE_DISABLE; + return true; default: return super.handleActionStateRequest(a); }