Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added command line option for opening UGS in fullscreen #2471

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ugs-platform/ugs-platform-ugscore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<version>${netbeans.version}</version>
</dependency>

<!-- for being able to enter fullscreen -->
<dependency>
<groupId>org.netbeans.modules</groupId>
<artifactId>org-netbeans-core-windows</artifactId>
<version>${netbeans.version}</version>
<type>jar</type>
</dependency>

<!-- app netbeans dependencies -->
<dependency>
<groupId>org.netbeans.api</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2024 Will Winder

This file is part of Universal Gcode Sender (UGS).

UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.ugs.nbp.core.lifecycle;

import java.util.logging.Logger;
import javax.swing.Action;
import org.openide.awt.Actions;
import org.openide.windows.OnShowing;

/**
* Makes the application enter full screen if the {@link #setUseFullScreen(boolean)} was set to true
* before the application was started
*
* @author Joacim Breiler
*/
@OnShowing
public class FullScreenOptionProcessor implements Runnable {
private static final Logger LOGGER = Logger.getLogger(StartupOptionProcessor.class.getName());

private static boolean useFullScreen = false;

@Override
public void run() {
if (useFullScreen) {
Action action = Actions.forID("Window", "org.netbeans.core.windows.actions.ToggleFullScreenAction");
if (action == null) {
LOGGER.info("Could not find the ToggleFullScreenAction to enter full screen");
return;
}
action.actionPerformed(null);
}
}

public static void setUseFullScreen(boolean useFullscreen) {
FullScreenOptionProcessor.useFullScreen = useFullscreen;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
Copyright 2024 Will Winder

This file is part of Universal Gcode Sender (UGS).

UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.ugs.nbp.core.lifecycle;

import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -30,6 +48,7 @@ public class StartupOptionProcessor extends OptionProcessor {
private final Option openOption = Option.additionalArguments('o', "open");
private final Option defaultOpenOption = Option.defaultArguments();
private final Option clearCacheOption = Option.withoutArgument('c', "clearcache");
private final Option fullscreenOption = Option.withoutArgument(Option.NO_SHORT_NAME, "fullscreen");

/**
* Register interest in the "open" option.
Expand All @@ -40,6 +59,7 @@ public Set<Option> getOptions() {
set.add(openOption);
set.add(defaultOpenOption);
set.add(clearCacheOption);
set.add(fullscreenOption);
return set;
}

Expand All @@ -52,8 +72,12 @@ protected void process(Env env, Map<Option, String[]> optionsMap) throws Command
clearCache();
}

if (optionsMap.containsKey(fullscreenOption)) {
FullScreenOptionProcessor.setUseFullScreen(true);
}

Optional<String> fileToOpen = getFileToOpen(optionsMap, openOption);
if (!fileToOpen.isPresent()) {
if (fileToOpen.isEmpty()) {
fileToOpen = getFileToOpen(optionsMap, defaultOpenOption);
}

Expand Down
Loading