mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 00:50:31 +00:00
Add showcase property and rework property loading
This commit is contained in:
parent
2221430c78
commit
e085445344
9 changed files with 69 additions and 47 deletions
|
@ -150,6 +150,7 @@ run {
|
|||
systemProperty 'io.xpipe.app.developerMode', "true"
|
||||
systemProperty 'io.xpipe.app.logLevel', "trace"
|
||||
systemProperty 'io.xpipe.app.fullVersion', rootProject.fullVersion
|
||||
systemProperty 'io.xpipe.app.showcase', 'false'
|
||||
// systemProperty "io.xpipe.beacon.port", "21724"
|
||||
// systemProperty "io.xpipe.beacon.printMessages", "true"
|
||||
// systemProperty 'io.xpipe.app.debugPlatform', "true"
|
||||
|
@ -173,17 +174,6 @@ task runAttachedDebugger(type: JavaExec) {
|
|||
systemProperties run.systemProperties
|
||||
}
|
||||
|
||||
task writeBuildProperties(type: DefaultTask) {
|
||||
doLast {
|
||||
def resourcesDir = new File(sourceSets.main.output.resourcesDir, "io/xpipe/app/resources")
|
||||
resourcesDir.mkdirs()
|
||||
def contents = "version=$appVersion\n" +
|
||||
"build=$appVersion-${new Date().format('yyyyMMddHHmm')}\n"
|
||||
new File(resourcesDir, "app.properties").text = contents
|
||||
}
|
||||
}
|
||||
processResources.finalizedBy(writeBuildProperties)
|
||||
|
||||
task writeLicenses(type: DefaultTask) {
|
||||
doLast {
|
||||
def resourcesDir = new File(sourceSets.main.output.resourcesDir, "io/xpipe/app/resources/third-party")
|
||||
|
|
|
@ -111,7 +111,7 @@ public class BrowserModel {
|
|||
}
|
||||
}
|
||||
|
||||
public void openFileSystemAsync(String name, ShellStore store, String path, BooleanProperty busy) {
|
||||
public void openFileSystemAsync(String name, ShellStore store, String path, BooleanProperty externalBusy) {
|
||||
// // Prevent multiple tabs in non browser modes
|
||||
// if (!mode.equals(Mode.BROWSER)) {
|
||||
// ThreadHelper.runFailableAsync(() -> {
|
||||
|
@ -132,9 +132,10 @@ public class BrowserModel {
|
|||
ThreadHelper.runFailableAsync(() -> {
|
||||
OpenFileSystemModel model;
|
||||
|
||||
try (var b = new BusyProperty(busy != null ? busy : new SimpleBooleanProperty())) {
|
||||
try (var b = new BusyProperty(externalBusy != null ? externalBusy : new SimpleBooleanProperty())) {
|
||||
model = new OpenFileSystemModel(name, this, store);
|
||||
model.initFileSystem();
|
||||
model.initSavedState();
|
||||
}
|
||||
|
||||
openFileSystems.add(model);
|
||||
|
|
|
@ -306,7 +306,6 @@ public final class OpenFileSystemModel {
|
|||
this.fileSystem = fs;
|
||||
this.local =
|
||||
fs.getShell().map(shellControl -> shellControl.isLocal()).orElse(false);
|
||||
this.initState();
|
||||
this.cache.init();
|
||||
});
|
||||
}
|
||||
|
@ -320,7 +319,7 @@ public final class OpenFileSystemModel {
|
|||
history.updateCurrent(null);
|
||||
}
|
||||
|
||||
void initState() {
|
||||
void initSavedState() {
|
||||
this.savedState = OpenFileSystemSavedState.loadForStore(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,8 +86,6 @@ public class AppLayoutComp extends Comp<CompStructure<BorderPane>> {
|
|||
|
||||
pane.setCenter(getRegion(n, map));
|
||||
});
|
||||
pane.setPrefWidth(1280);
|
||||
pane.setPrefHeight(720);
|
||||
AppFont.normal(pane);
|
||||
return new SimpleCompStructure<>(pane);
|
||||
}
|
||||
|
|
|
@ -68,10 +68,15 @@ public class App extends Application {
|
|||
var base = String.format(
|
||||
"XPipe Desktop (%s)", AppProperties.get().getVersion());
|
||||
var prefix = AppProperties.get().isStaging() ? "[STAGE] " : "";
|
||||
var suffix = XPipeDistributionType.get().getUpdateHandler().getPreparedUpdate().getValue() != null
|
||||
var suffix = XPipeDistributionType.get()
|
||||
.getUpdateHandler()
|
||||
.getPreparedUpdate()
|
||||
.getValue()
|
||||
!= null
|
||||
? String.format(
|
||||
" (Update to %s ready)",
|
||||
XPipeDistributionType.get().getUpdateHandler()
|
||||
" (Update to %s ready)",
|
||||
XPipeDistributionType.get()
|
||||
.getUpdateHandler()
|
||||
.getPreparedUpdate()
|
||||
.getValue()
|
||||
.getVersion())
|
||||
|
@ -89,14 +94,6 @@ public class App extends Application {
|
|||
stage.setOnShown(event -> {
|
||||
focus();
|
||||
});
|
||||
|
||||
// For demo purposes
|
||||
// if (true) {
|
||||
// stage.setX(310);
|
||||
// stage.setY(178);
|
||||
// stage.setWidth(1300);
|
||||
// stage.setHeight(730);
|
||||
// }
|
||||
}
|
||||
|
||||
public void focus() {
|
||||
|
|
|
@ -7,6 +7,7 @@ import javafx.scene.image.WritableImage;
|
|||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
|
@ -106,6 +107,18 @@ public class AppImages {
|
|||
return DEFAULT_IMAGE;
|
||||
}
|
||||
|
||||
public static BufferedImage toAwtImage(Image fxImage) {
|
||||
BufferedImage img = new BufferedImage(
|
||||
(int) fxImage.getWidth(), (int) fxImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < fxImage.getWidth(); x++) {
|
||||
for (int y = 0; y < fxImage.getHeight(); y++) {
|
||||
int rgb = fxImage.getPixelReader().getArgb(x, y);
|
||||
img.setRGB(x, y, rgb);
|
||||
}
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
private static Image loadImage(Path p) {
|
||||
if (p == null) {
|
||||
return DEFAULT_IMAGE;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.fxcomps.Comp;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.prefs.CloseBehaviourAlert;
|
||||
|
@ -19,6 +20,9 @@ import lombok.Getter;
|
|||
import lombok.Value;
|
||||
import lombok.extern.jackson.Jacksonized;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
@ -160,9 +164,14 @@ public class AppMainWindow {
|
|||
// stage.setMaximized(state.maximized);
|
||||
|
||||
TrackEvent.debug("Window loaded saved bounds");
|
||||
} else {
|
||||
} else if (!AppProperties.get().isShowcase()) {
|
||||
stage.setWidth(1280);
|
||||
stage.setHeight(720);
|
||||
} else {
|
||||
stage.setX(310);
|
||||
stage.setY(178);
|
||||
stage.setWidth(1300);
|
||||
stage.setHeight(730);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +180,10 @@ public class AppMainWindow {
|
|||
return;
|
||||
}
|
||||
|
||||
if (AppProperties.get().isShowcase()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newState = WindowState.builder()
|
||||
.maximized(stage.isMaximized())
|
||||
.windowX((int) stage.getX())
|
||||
|
@ -186,6 +199,10 @@ public class AppMainWindow {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (AppProperties.get().isShowcase()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
WindowState state = AppCache.get("windowState", WindowState.class, () -> null);
|
||||
if (state == null) {
|
||||
return null;
|
||||
|
@ -232,6 +249,19 @@ public class AppMainWindow {
|
|||
TrackEvent.debug("Rebuilt content");
|
||||
event.consume();
|
||||
}
|
||||
|
||||
if (AppProperties.get().isShowcase() && event.getCode().equals(KeyCode.F12)) {
|
||||
var image = stage.getScene().getRoot().snapshot(null, null);
|
||||
var awt = AppImages.toAwtImage(image);
|
||||
var file = Path.of(System.getProperty("user.home"), "Desktop", "xpipe-screenshot.png");
|
||||
try {
|
||||
ImageIO.write(awt, "png",file.toFile());
|
||||
} catch (IOException e) {
|
||||
ErrorEvent.fromThrowable(e).handle();
|
||||
}
|
||||
TrackEvent.debug("Screenshot taken");
|
||||
event.consume();
|
||||
}
|
||||
});
|
||||
TrackEvent.debug("Set content reload listener");
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package io.xpipe.app.core;
|
||||
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.util.ModuleHelper;
|
||||
import lombok.Value;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Value
|
||||
public class AppProperties {
|
||||
|
@ -28,26 +28,15 @@ public class AppProperties {
|
|||
boolean image;
|
||||
boolean staging;
|
||||
Path dataDir;
|
||||
boolean showcase;
|
||||
|
||||
public AppProperties() {
|
||||
image = ModuleHelper.isImage();
|
||||
|
||||
Properties props = new Properties();
|
||||
AppResources.with(AppResources.XPIPE_MODULE, "app.properties", p -> {
|
||||
if (Files.exists(p)) {
|
||||
try (var in = Files.newInputStream(p)) {
|
||||
props.load(in);
|
||||
} catch (IOException e) {
|
||||
ErrorEvent.fromThrowable(e).omitted(true).build().handle();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fullVersion = Optional.ofNullable(System.getProperty("io.xpipe.app.fullVersion"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(false);
|
||||
version = Optional.ofNullable(props.getProperty("version")).orElse("dev");
|
||||
build = Optional.ofNullable(props.getProperty("build")).orElse("unknown");
|
||||
version = Optional.ofNullable(System.getProperty("io.xpipe.app.version")).orElse("dev");
|
||||
build = Optional.ofNullable(System.getProperty("io.xpipe.app.build")).orElse("unknown");
|
||||
buildUuid = Optional.ofNullable(System.getProperty("io.xpipe.app.buildId"))
|
||||
.map(UUID::fromString)
|
||||
.orElse(UUID.randomUUID());
|
||||
|
@ -57,6 +46,9 @@ public class AppProperties {
|
|||
staging = Optional.ofNullable(System.getProperty("io.xpipe.app.staging"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(false);
|
||||
showcase = Optional.ofNullable(System.getProperty("io.xpipe.app.showcase"))
|
||||
.map(Boolean::parseBoolean)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
public static void logSystemProperties() {
|
||||
|
|
2
dist/jpackage.gradle
vendored
2
dist/jpackage.gradle
vendored
|
@ -6,6 +6,8 @@ def distJvmArgs = new ArrayList<String>(project(':app').application.applicationD
|
|||
|
||||
def releaseArguments = distJvmArgs + [
|
||||
'-Dio.xpipe.app.writeLogs=true',
|
||||
"-Dio.xpipe.app.version=$rootProject.versionString",
|
||||
"-Dio.xpipe.app.build=$rootProject.versionString-${new Date().format('yyyyMMddHHmm')}",
|
||||
"-Dio.xpipe.app.buildId=$rootProject.buildId",
|
||||
"-Dio.xpipe.app.fullVersion=$rootProject.fullVersion",
|
||||
"-Dio.xpipe.app.staging=$rootProject.isStage",
|
||||
|
|
Loading…
Reference in a new issue