mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-23 08:55:41 +00:00
Show clipboard notification
This commit is contained in:
@@ -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) {
|
||||
|
||||
Generated
+1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user