Show clipboard notification

This commit is contained in:
crschnick
2025-06-05 22:32:44 +00:00
parent 40bb286267
commit 1c69aebc4e
3 changed files with 25 additions and 4 deletions
@@ -6,10 +6,7 @@ import io.xpipe.app.comp.Comp;
import io.xpipe.app.comp.store.StoreLayoutComp;
import io.xpipe.app.prefs.AppPrefsComp;
import io.xpipe.app.update.AppDistributionType;
import io.xpipe.app.util.Hyperlinks;
import io.xpipe.app.util.LabelGraphic;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.app.util.PlatformThread;
import io.xpipe.app.util.*;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.Property;
@@ -28,6 +25,7 @@ import lombok.Getter;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -53,6 +51,19 @@ public class AppLayoutModel {
this.queueEntries = FXCollections.observableArrayList();
}
public void showQueueEntry(QueueEntry entry, Duration duration, boolean allowDuplicates) {
if (!allowDuplicates && queueEntries.contains(entry)) {
return;
}
queueEntries.add(entry);
if (duration != null) {
GlobalTimer.delay(() -> {
queueEntries.remove(entry);
}, duration);
}
}
public static AppLayoutModel get() {
return INSTANCE;
}
@@ -1,5 +1,7 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.core.util.SecretValue;
import javafx.animation.PauseTransition;
@@ -14,6 +16,12 @@ import java.util.stream.Stream;
public class ClipboardHelper {
private static final AppLayoutModel.QueueEntry COPY_QUEUE_ENTRY = new AppLayoutModel.QueueEntry(
AppI18n.observable("passwordCopied"),
new LabelGraphic.IconGraphic("mdi2c-clipboard-check-outline"),
() -> {}
);
private static void apply(Map<DataFormat, Object> map) {
Clipboard clipboard = Clipboard.getSystemClipboard();
Map<DataFormat, Object> contents = Stream.of(
@@ -35,6 +43,7 @@ public class ClipboardHelper {
.collect(HashMap::new, (m, v) -> m.put(v.getKey(), v.getValue()), HashMap::putAll);
contents.putAll(map);
clipboard.setContent(contents);
AppLayoutModel.get().showQueueEntry(COPY_QUEUE_ENTRY, java.time.Duration.ofSeconds(10), true);
}
public static void copyPassword(SecretValue pass) {
+1
View File
@@ -1472,3 +1472,4 @@ passwordManagerIdentity.displayName=Password manager identity
passwordManagerIdentity.displayDescription=Retrieve the credentials of an identity from your password manager
useAsJumpServer=Jump server
useAsJumpServerDescription=This system is a jump server to be used with ProxyJump
passwordCopied=Connection password copied to clipboard