From 734fac9af6eb7d6feab991cb7d2d66891677d822 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 18 Jun 2024 20:23:40 +0000 Subject: [PATCH] Add double click option --- .../xpipe/app/comp/store/StoreEntryComp.java | 20 ++++++++++++--- .../java/io/xpipe/app/prefs/AppPrefs.java | 8 ++++++ .../xpipe/app/prefs/AppearanceCategory.java | 4 --- .../io/xpipe/app/prefs/WorkflowCategory.java | 25 +++++++++++++++++++ .../io/xpipe/app/storage/DataStoreEntry.java | 2 +- beacon/README.md | 6 +++-- lang/app/strings/translations_en.properties | 4 ++- 7 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/io/xpipe/app/prefs/WorkflowCategory.java diff --git a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java index 12cf74978..154aa8f9e 100644 --- a/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/store/StoreEntryComp.java @@ -103,13 +103,25 @@ public abstract class StoreEntryComp extends SimpleComp { }); }); button.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> { - if (event.getClickCount() > 1) { - event.consume(); + if (AppPrefs.get().requireDoubleClickForConnections().get()) { + if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() != 2) { + event.consume(); + } + } else { + if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() > 1) { + event.consume(); + } } }); button.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> { - if (event.getClickCount() > 1) { - event.consume(); + if (AppPrefs.get().requireDoubleClickForConnections().get()) { + if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() != 2) { + event.consume(); + } + } else { + if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() > 1) { + event.consume(); + } } }); new ContextMenuAugment<>( diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index ade255930..16fa3a0ec 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -112,6 +112,13 @@ public class AppPrefs { final ObjectProperty language = map(new SimpleObjectProperty<>(SupportedLocale.getEnglish()), "language", SupportedLocale.class); + final BooleanProperty requireDoubleClickForConnections = + map(new SimpleBooleanProperty(false), "requireDoubleClickForConnections", Boolean.class); + + public ObservableBooleanValue requireDoubleClickForConnections() { + return requireDoubleClickForConnections; + } + @Getter private final Property lockPassword = new SimpleObjectProperty<>(); @@ -165,6 +172,7 @@ public class AppPrefs { new LocalShellCategory(), new SecurityCategory(), new HttpApiCategory(), + new WorkflowCategory(), new TroubleshootCategory(), new DeveloperCategory()) .filter(appPrefsCategory -> appPrefsCategory.show()) diff --git a/app/src/main/java/io/xpipe/app/prefs/AppearanceCategory.java b/app/src/main/java/io/xpipe/app/prefs/AppearanceCategory.java index 0434cb540..f4b987625 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppearanceCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppearanceCategory.java @@ -49,10 +49,6 @@ public class AppearanceCategory extends AppPrefsCategory { .addToggle(prefs.condenseConnectionDisplay) .nameAndDescription("showChildCategoriesInParentCategory") .addToggle(prefs.showChildCategoriesInParentCategory)) - .addTitle("workflow") - .sub(new OptionsBuilder() - .nameAndDescription("openConnectionSearchWindowOnConnectionCreation") - .addToggle(prefs.openConnectionSearchWindowOnConnectionCreation)) .addTitle("windowOptions") .sub(new OptionsBuilder() .nameAndDescription("windowOpacity") diff --git a/app/src/main/java/io/xpipe/app/prefs/WorkflowCategory.java b/app/src/main/java/io/xpipe/app/prefs/WorkflowCategory.java new file mode 100644 index 000000000..4e792c533 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/prefs/WorkflowCategory.java @@ -0,0 +1,25 @@ +package io.xpipe.app.prefs; + +import io.xpipe.app.fxcomps.Comp; +import io.xpipe.app.util.OptionsBuilder; + +public class WorkflowCategory extends AppPrefsCategory { + + @Override + protected String getId() { + return "workflow"; + } + + @Override + protected Comp create() { + var prefs = AppPrefs.get(); + return new OptionsBuilder() + .addTitle("workflow") + .sub(new OptionsBuilder() + .nameAndDescription("openConnectionSearchWindowOnConnectionCreation") + .addToggle(prefs.openConnectionSearchWindowOnConnectionCreation) + .nameAndDescription("requireDoubleClickForConnections") + .addToggle(prefs.requireDoubleClickForConnections)) + .buildComp(); + } +} diff --git a/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java b/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java index f60f24a8f..190d1454f 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStoreEntry.java @@ -417,7 +417,7 @@ public class DataStoreEntry extends StorageElement { stateObj.set("persistentState", storePersistentStateNode); obj.set("configuration", mapper.valueToTree(configuration)); stateObj.put("expanded", expanded); - stateObj.put("orderBefore", explicitOrder != null ? explicitOrder.toString() : null); + stateObj.set("order", mapper.valueToTree(explicitOrder)); var entryString = mapper.writeValueAsString(obj); var stateString = mapper.writeValueAsString(stateObj); diff --git a/beacon/README.md b/beacon/README.md index 5563a5fbb..b2a6a62a9 100644 --- a/beacon/README.md +++ b/beacon/README.md @@ -7,6 +7,8 @@ The XPipe beacon component is responsible for handling all communications betwee and the APIs and the CLI. It provides an API that supports all kinds of different operations. +For a full documentation, see the [OpenAPI spec](/../openapi.yaml) + ### Inner Workings - The underlying communication is realized through an HTTP server on port `21721` @@ -17,14 +19,14 @@ of different operations. - Every exchange is initiated from the outside by sending a request message to the XPipe daemon. The daemon then always sends a response message. -- The body of a message is formatted in the json format. +- The body of a message is usually formatted in the json format. As a result, all data structures exchanged must be serializable/deserializable with jackson. ## Configuration #### Custom port -The default port can be changed by passing the property `io.xpipe.beacon.port=` to the daemon or changing it in the settings menu. +The default port can be changed by passing the property `io.xpipe.beacon.port=` to the daemon. Note that if both sides do not have the same port setting, they won't be able to reach each other. #### Custom launch command diff --git a/lang/app/strings/translations_en.properties b/lang/app/strings/translations_en.properties index a7bfdc7d3..dad38eef3 100644 --- a/lang/app/strings/translations_en.properties +++ b/lang/app/strings/translations_en.properties @@ -476,4 +476,6 @@ isOnlySupportedLimit=is only supported with a professional license when having m areOnlySupportedLimit=are only supported with a professional license when having more than $COUNT$ connections enabled=Enabled enableGitStoragePtbDisabled=Git synchronization is disabled for public test builds to prevent usage with regular release git repositories and to discourage using a PTB build as your daily driver. -copyId=Copy ID \ No newline at end of file +copyId=Copy ID +requireDoubleClickForConnections=Require double click for connections +requireDoubleClickForConnectionsDescription=If enabled, you have to double-click connections to launch them. This is useful if you're used to double-clicking things. \ No newline at end of file