toggle distraction free mode action

This commit is contained in:
Sergey Ignatov
2014-10-21 20:57:25 +04:00
parent 2eee8cdfbc
commit eef1a02de8
3 changed files with 44 additions and 0 deletions
@@ -0,0 +1,41 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.registry.RegistryValue;
import org.jetbrains.annotations.NotNull;
public class ToggleDistractionFreeModeAction extends AnAction implements DumbAware {
private static final String key = "editor.distraction.free.mode";
@Override
public void update(@NotNull AnActionEvent e) {
RegistryValue value = Registry.get(key);
boolean selected = value.asBoolean();
e.getPresentation().setText(selected ? "Exit Distraction Free Mode" : "Enter Distraction Free Mode");
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
RegistryValue value = Registry.get(key);
value.setValue(!value.asBoolean());
EditorFactory.getInstance().refreshAllEditors();
}
}
@@ -797,6 +797,8 @@ action.TogglePresentationMode.text.enter=Enter Presentation mode
action.TogglePresentationMode.text.exit=Exit Presentation mode
action.TogglePresentationMode.text=Toggle Presentation mode
action.TogglePresentationMode.description=Toggle Presentation mode
action.ToggleDistractionFreeMode.text=Toggle Distraction Free mode
action.ToggleDistractionFreeMode.description=Toggle Distraction Free mode
action.ToggleFullScreen.text.enter=Enter Full Screen
action.ToggleFullScreen.text.exit=Exit Full Screen
action.ToggleFullScreen.text=Toggle Full Screen mode
@@ -314,6 +314,7 @@
<group id="ToggleFullScreenGroup">
<separator/>
<action id="TogglePresentationMode" class="com.intellij.ide.actions.TogglePresentationModeAction"/>
<action id="ToggleDistractionFreeMode" class="com.intellij.ide.actions.ToggleDistractionFreeModeAction"/>
<action id="ToggleFullScreen" class="com.intellij.ide.actions.ToggleFullScreenAction"/>
</group>
</group>