From bb0e0498354a12fc77ee7e519d9a84eb247f5361 Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 18 Nov 2024 15:52:30 +0000 Subject: [PATCH] Improve tab pins --- .../app/browser/BrowserFullSessionModel.java | 23 +++++++++++-- .../file/BrowserFileSystemTabComp.java | 30 +++++++++++++--- .../java/io/xpipe/app/prefs/AppPrefs.java | 34 +++++++++++-------- .../xpipe/app/prefs/FileBrowserCategory.java | 5 ++- lang/app/strings/translations_da.properties | 2 ++ lang/app/strings/translations_de.properties | 2 ++ lang/app/strings/translations_en.properties | 4 ++- lang/app/strings/translations_es.properties | 2 ++ lang/app/strings/translations_fr.properties | 2 ++ lang/app/strings/translations_it.properties | 2 ++ lang/app/strings/translations_ja.properties | 2 ++ lang/app/strings/translations_nl.properties | 2 ++ lang/app/strings/translations_pt.properties | 2 ++ lang/app/strings/translations_ru.properties | 2 ++ lang/app/strings/translations_tr.properties | 2 ++ lang/app/strings/translations_zh.properties | 2 ++ 16 files changed, 95 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java index 5df06abad..a053d2b31 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserFullSessionModel.java @@ -5,6 +5,7 @@ import io.xpipe.app.browser.file.BrowserHistorySavedState; import io.xpipe.app.browser.file.BrowserHistorySavedStateImpl; import io.xpipe.app.browser.file.BrowserHistoryTabModel; import io.xpipe.app.browser.file.BrowserTransferModel; +import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStoreEntryRef; import io.xpipe.app.util.BooleanScope; @@ -34,6 +35,13 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel { + DEFAULT.openSync(tab,null); + DEFAULT.pinTab(tab); + }); + } } private final BrowserTransferModel localTransfersStage = new BrowserTransferModel(this); @@ -41,6 +49,7 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel globalPinnedTab = new SimpleObjectProperty<>(); private final ObservableMap splits = FXCollections.observableHashMap(); private final ObservableValue effectiveRightTab = createEffectiveRightTab(); + private final SequencedSet previousTabs = new LinkedHashSet<>(); private ObservableValue createEffectiveRightTab() { return Bindings.createObjectBinding( @@ -80,6 +89,13 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel !c.getList().contains(browserSessionTab)); }); + + selectedEntry.addListener((observable, oldValue, newValue) -> { + if (newValue != null) { + previousTabs.remove(newValue); + previousTabs.add(newValue); + } + }); } public Set getAllTabs() { @@ -118,9 +134,10 @@ public class BrowserFullSessionModel extends BrowserAbstractSessionModel browserSessionTab != tab).toList(); + var prev = previousOthers.getLast(); + if (prev != null) { + getSelectedEntry().setValue(prev); } } diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java index d603faa4e..427efbddb 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserFileSystemTabComp.java @@ -1,17 +1,17 @@ package io.xpipe.app.browser.file; +import io.xpipe.app.browser.BrowserFullSessionModel; import io.xpipe.app.browser.action.BrowserAction; import io.xpipe.app.comp.Comp; import io.xpipe.app.comp.SimpleComp; import io.xpipe.app.comp.SimpleCompStructure; import io.xpipe.app.comp.augment.ContextMenuAugment; -import io.xpipe.app.comp.base.ModalOverlayComp; -import io.xpipe.app.comp.base.MultiContentComp; -import io.xpipe.app.comp.base.TooltipAugment; -import io.xpipe.app.comp.base.VerticalComp; +import io.xpipe.app.comp.base.*; import io.xpipe.app.core.AppFont; import io.xpipe.app.util.InputHelper; +import io.xpipe.app.util.PlatformThread; +import javafx.beans.binding.Bindings; import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.MenuButton; @@ -96,6 +96,28 @@ public class BrowserFileSystemTabComp extends SimpleComp { refreshBtn, terminalBtn, menuButton); + + if (model.getBrowserModel() instanceof BrowserFullSessionModel fullSessionModel) { + var pinButton = new Button(); + pinButton.graphicProperty().bind(PlatformThread.sync(Bindings.createObjectBinding(() -> { + if (fullSessionModel.getGlobalPinnedTab().getValue() != model) { + return new FontIcon("mdi2p-pin"); + } + + return new FontIcon("mdi2p-pin-off"); + }, fullSessionModel.getGlobalPinnedTab()))); + pinButton.setOnAction(e -> { + if (fullSessionModel.getGlobalPinnedTab().getValue() != model) { + fullSessionModel.pinTab(model); + } else { + fullSessionModel.unpinTab(model); + } + e.consume(); + }); + topBar.getChildren().add(7, pinButton); + squaredSize(navBar.get(), pinButton, true); + } + squaredSize(navBar.get(), overview, true); squaredSize(navBar.get(), backBtn, true); squaredSize(navBar.get(), forthBtn, true); 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 6f47a2b3a..3b489c4cc 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -43,6 +43,13 @@ public class AppPrefs { @Getter private final BooleanProperty requiresRestart = new SimpleBooleanProperty(false); + final BooleanProperty pinLocalMachineOnStartup = + map(Mapping.builder() + .property(new SimpleBooleanProperty(false)) + .key("pinLocalMachineOnStartup") + .valueClass(Boolean.class) + .requiresRestart(true) + .build()); final BooleanProperty dontAllowTerminalRestart = mapVaultShared(new SimpleBooleanProperty(false), "dontAllowTerminalRestart", Boolean.class, false); final BooleanProperty enableHttpApi = @@ -191,6 +198,10 @@ public class AppPrefs { return dontAllowTerminalRestart; } + public ObservableBooleanValue pinLocalMachineOnStartup() { + return pinLocalMachineOnStartup; + } + private final IntegerProperty editorReloadTimeout = mapLocal(new SimpleIntegerProperty(1000), "editorReloadTimeout", Integer.class, false); private final BooleanProperty confirmDeletions = @@ -480,19 +491,21 @@ public class AppPrefs { @SuppressWarnings("unchecked") private T map(Mapping m) { mapping.add(m); + m.property.addListener((observable, oldValue, newValue) -> { + var running = OperationMode.get() == OperationMode.GUI; + if (running && m.requiresRestart) { + AppPrefs.get().requiresRestart.set(true); + } + }); return (T) m.getProperty(); } - @SuppressWarnings("unchecked") private T mapLocal(Property o, String name, Class clazz, boolean requiresRestart) { - mapping.add(new Mapping(name, o, clazz, false, requiresRestart)); - return (T) o; + return map(new Mapping(name, o, clazz, false, requiresRestart)); } - @SuppressWarnings("unchecked") - private T mapVaultShared(T o, String name, Class clazz, boolean requiresRestart) { - mapping.add(new Mapping(name, (Property) o, (Class) clazz, true, requiresRestart)); - return o; + private T mapVaultShared(Property o, String name, Class clazz, boolean requiresRestart) { + return map(new Mapping(name, o, clazz, true, requiresRestart)); } public void setFromExternal(ObservableValue prop, T newValue) { @@ -646,13 +659,6 @@ public class AppPrefs { this.vaultSpecific = vaultSpecific; this.requiresRestart = requiresRestart; this.licenseFeatureId = null; - - this.property.addListener((observable, oldValue, newValue) -> { - var running = OperationMode.get() == OperationMode.GUI; - if (running && requiresRestart) { - AppPrefs.get().requiresRestart.set(true); - } - }); } } diff --git a/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java b/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java index b0a916e3f..9b89c8103 100644 --- a/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/FileBrowserCategory.java @@ -21,7 +21,10 @@ public class FileBrowserCategory extends AppPrefsCategory { .pref(prefs.confirmAllDeletions) .addToggle(prefs.confirmAllDeletions) .pref(prefs.downloadsDirectory) - .addString(prefs.downloadsDirectory)) + .addString(prefs.downloadsDirectory) + .pref(prefs.pinLocalMachineOnStartup) + .addToggle(prefs.pinLocalMachineOnStartup) + ) .buildComp(); } } diff --git a/lang/app/strings/translations_da.properties b/lang/app/strings/translations_da.properties index 8f4851053..064f625db 100644 --- a/lang/app/strings/translations_da.properties +++ b/lang/app/strings/translations_da.properties @@ -554,3 +554,5 @@ enableTerminalDocking=Aktiver terminal-docking enableTerminalDockingDescription=Med terminal-docking kan du docke terminalvinduer til XPipe-applikationsvinduet for at simulere en nogenlunde integreret terminal. Terminalvinduerne styres derefter af XPipe, så de altid passer ind i docken. downloadsDirectory=Brugerdefineret download-mappe downloadsDirectoryDescription=Den brugerdefinerede mappe, som downloadede filer skal placeres i, når man klikker på knappen Flyt til downloads. Som standard vil XPipe bruge din brugers download-bibliotek. +pinLocalMachineOnStartup=Fastgør fane for lokal maskine ved opstart +pinLocalMachineOnStartupDescription=Åbn automatisk en fane på den lokale maskine og fastgør den. Det er nyttigt, hvis du ofte bruger en delt filbrowser med den lokale maskine og fjernfilsystemet åbent. diff --git a/lang/app/strings/translations_de.properties b/lang/app/strings/translations_de.properties index ab502d1e5..495b8bf90 100644 --- a/lang/app/strings/translations_de.properties +++ b/lang/app/strings/translations_de.properties @@ -548,3 +548,5 @@ enableTerminalDocking=St Finn We transmission enableTerminalDockingDescription=Mit Terminal Docking kannst du Terminalfenster an das XPipe-Anwendungsfenster andocken, um ein integriertes Terminal zu simulieren. Κ Finn continues theARotional'93 Veranstə Off extampİ Weṣς downloadsDirectory=Benutzerdefiniertes Download-Verzeichnis downloadsDirectoryDescription=Das benutzerdefinierte Verzeichnis, in das heruntergeladene Dateien verschoben werden sollen, wenn du auf die Schaltfläche In Downloads verschieben klickst. Standardmäßig verwendet XPipe dein Benutzer-Download-Verzeichnis. +pinLocalMachineOnStartup=Registerkarte "Lokaler Rechner" beim Starten anheften +pinLocalMachineOnStartupDescription=Öffne automatisch eine Registerkarte für den lokalen Rechner und pinne sie an. Dies ist nützlich, wenn du häufig einen geteilten Dateibrowser verwendest, bei dem der lokale Rechner und das entfernte Dateisystem geöffnet sind. diff --git a/lang/app/strings/translations_en.properties b/lang/app/strings/translations_en.properties index d39b6a830..8812a20ba 100644 --- a/lang/app/strings/translations_en.properties +++ b/lang/app/strings/translations_en.properties @@ -553,4 +553,6 @@ pinned=Pinned enableTerminalDocking=Enable terminal docking enableTerminalDockingDescription=With terminal docking you can dock terminal windows to the XPipe application window to simulate a somewhat integrated terminal. The terminal windows are then managed by XPipe to always fit into the dock. downloadsDirectory=Custom downloads directory -downloadsDirectoryDescription=The custom directory to put downloaded files into when clicking on the move to downloads button. By default, XPipe will use your user downloads directory. \ No newline at end of file +downloadsDirectoryDescription=The custom directory to put downloaded files into when clicking on the move to downloads button. By default, XPipe will use your user downloads directory. +pinLocalMachineOnStartup=Pin local machine tab on startup +pinLocalMachineOnStartupDescription=Automatically open a local machine tab and pin it. This is useful if you are frequently using a split file browser with the local machine and remote file system open. \ No newline at end of file diff --git a/lang/app/strings/translations_es.properties b/lang/app/strings/translations_es.properties index 437a171b5..7a4aa3ce3 100644 --- a/lang/app/strings/translations_es.properties +++ b/lang/app/strings/translations_es.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Activar el acoplamiento de terminales enableTerminalDockingDescription=Con el acoplamiento de terminales puedes acoplar ventanas de terminal a la ventana de la aplicación XPipe para simular un terminal algo integrado. Las ventanas de terminal son gestionadas por XPipe para que siempre quepan en el acoplamiento. downloadsDirectory=Directorio de descargas personalizado downloadsDirectoryDescription=El directorio personalizado en el que colocar los archivos descargados al pulsar el botón mover a descargas. Por defecto, XPipe utilizará tu directorio de descargas de usuario. +pinLocalMachineOnStartup=Fijar la pestaña de máquina local al iniciar +pinLocalMachineOnStartupDescription=Abre automáticamente una pestaña de la máquina local y fíjala. Esto es útil si utilizas con frecuencia un explorador de archivos dividido con la máquina local y el sistema de archivos remoto abiertos. diff --git a/lang/app/strings/translations_fr.properties b/lang/app/strings/translations_fr.properties index 513fce93f..eb01ea470 100644 --- a/lang/app/strings/translations_fr.properties +++ b/lang/app/strings/translations_fr.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Activer l'ancrage du terminal enableTerminalDockingDescription=Avec l'ancrage de terminal, tu peux ancrer des fenêtres de terminal à la fenêtre de l'application XPipe pour simuler un terminal quelque peu intégré. Les fenêtres du terminal sont alors gérées par XPipe pour toujours tenir dans la station d'accueil. downloadsDirectory=Répertoire de téléchargements personnalisé downloadsDirectoryDescription=Le répertoire personnalisé dans lequel placer les fichiers téléchargés lorsqu'on clique sur le bouton déplacer vers les téléchargements. Par défaut, XPipe utilisera le répertoire des téléchargements de l'utilisateur. +pinLocalMachineOnStartup=Onglet de la machine locale au démarrage +pinLocalMachineOnStartupDescription=Ouvrir automatiquement un onglet de machine locale et l'épingler. C'est utile si tu utilises fréquemment un navigateur de fichiers fractionné avec la machine locale et le système de fichiers distant ouverts. diff --git a/lang/app/strings/translations_it.properties b/lang/app/strings/translations_it.properties index 514171556..6e5e92754 100644 --- a/lang/app/strings/translations_it.properties +++ b/lang/app/strings/translations_it.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Abilita l'aggancio del terminale enableTerminalDockingDescription=Con il docking del terminale puoi agganciare le finestre del terminale alla finestra dell'applicazione XPipe per simulare un terminale integrato. Le finestre del terminale vengono gestite da XPipe in modo da essere sempre inserite nel dock. downloadsDirectory=Directory di download personalizzata downloadsDirectoryDescription=La directory personalizzata in cui inserire i file scaricati quando si fa clic sul pulsante sposta nei download. Per impostazione predefinita, XPipe utilizzerà la directory dei download dell'utente. +pinLocalMachineOnStartup=Blocca la scheda della macchina locale all'avvio +pinLocalMachineOnStartupDescription=Apre automaticamente una scheda del computer locale e la blocca. Questa funzione è utile se utilizzi spesso un browser di file suddiviso con il computer locale e il file system remoto aperti. diff --git a/lang/app/strings/translations_ja.properties b/lang/app/strings/translations_ja.properties index a91962da2..646e10eac 100644 --- a/lang/app/strings/translations_ja.properties +++ b/lang/app/strings/translations_ja.properties @@ -535,3 +535,5 @@ enableTerminalDocking=端末のドッキングを有効にする enableTerminalDockingDescription=ターミナルドッキングを使えば、XPipeのアプリケーションウィンドウにターミナルウィンドウをドッキングさせることができる。ターミナルウィンドウはXPipeによって管理され、常にドックに収まる。 downloadsDirectory=カスタムダウンロードディレクトリ downloadsDirectoryDescription=ダウンロードに移動ボタンをクリックしたときに、ダウンロードしたファイルを置くカスタムディレクトリ。デフォルトでは、XPipeはユーザーダウンロードディレクトリを使用する。 +pinLocalMachineOnStartup=起動時にローカルマシンのタブをピン留めする +pinLocalMachineOnStartupDescription=ローカルマシンのタブを自動的に開き、ピン留めする。これは、ローカルマシンとリモートファイルシステムを開いた状態で、分割ファイルブラウザを頻繁に使用する場合に便利である。 diff --git a/lang/app/strings/translations_nl.properties b/lang/app/strings/translations_nl.properties index b07ec0d63..76635876c 100644 --- a/lang/app/strings/translations_nl.properties +++ b/lang/app/strings/translations_nl.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Terminal docking inschakelen enableTerminalDockingDescription=Met terminal docking kun je terminalvensters in het XPipe toepassingsvenster plaatsen om een enigszins geïntegreerde terminal te simuleren. De terminalvensters worden dan door XPipe beheerd zodat ze altijd in het dock passen. downloadsDirectory=Aangepaste downloadmap downloadsDirectoryDescription=De aangepaste map om gedownloade bestanden in te plaatsen als je op de knop Verplaats naar downloads klikt. Standaard gebruikt XPipe je gebruikersdownloadmap. +pinLocalMachineOnStartup=Tabblad lokale machine vastpinnen bij het opstarten +pinLocalMachineOnStartupDescription=Automatisch een lokale machine tab openen en vastpinnen. Dit is handig als je vaak een gesplitste bestandsbrowser gebruikt met de lokale machine en het externe bestandssysteem open. diff --git a/lang/app/strings/translations_pt.properties b/lang/app/strings/translations_pt.properties index 90ba7ec7b..e456a3cf8 100644 --- a/lang/app/strings/translations_pt.properties +++ b/lang/app/strings/translations_pt.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Ativar a ancoragem do terminal enableTerminalDockingDescription=Com o terminal docking podes acoplar janelas de terminal à janela da aplicação XPipe para simular um terminal integrado. As janelas de terminal são então geridas pelo XPipe para caberem sempre na doca. downloadsDirectory=Diretório de transferências personalizado downloadsDirectoryDescription=O diretório personalizado para colocar os arquivos baixados ao clicar no botão mover para downloads. Por defeito, o XPipe utiliza o diretório de downloads do utilizador. +pinLocalMachineOnStartup=Fixa o separador da máquina local no arranque +pinLocalMachineOnStartupDescription=Abre automaticamente um separador da máquina local e fixa-o. Isto é útil se estiveres a utilizar frequentemente um navegador de ficheiros dividido com a máquina local e o sistema de ficheiros remoto abertos. diff --git a/lang/app/strings/translations_ru.properties b/lang/app/strings/translations_ru.properties index 7a8bc5aeb..3049395b8 100644 --- a/lang/app/strings/translations_ru.properties +++ b/lang/app/strings/translations_ru.properties @@ -535,3 +535,5 @@ enableTerminalDocking=Включить стыковку терминалов enableTerminalDockingDescription=С помощью терминальной докировки ты можешь пристыковать окна терминалов к окну приложения XPipe, чтобы имитировать некий интегрированный терминал. Окна терминала управляются XPipe, чтобы всегда помещаться в док. downloadsDirectory=Пользовательский каталог загрузок downloadsDirectoryDescription=Пользовательская директория, в которую будут помещаться скачанные файлы при нажатии на кнопку перемещения в загрузки. По умолчанию XPipe будет использовать твой пользовательский каталог загрузок. +pinLocalMachineOnStartup=Закрепить вкладку локальной машины при запуске +pinLocalMachineOnStartupDescription=Автоматически открывай вкладку локальной машины и закрепляй ее. Это полезно, если ты часто используешь разделенный файловый браузер с открытыми локальной машиной и удаленной файловой системой. diff --git a/lang/app/strings/translations_tr.properties b/lang/app/strings/translations_tr.properties index b8d777c5a..135cf87b2 100644 --- a/lang/app/strings/translations_tr.properties +++ b/lang/app/strings/translations_tr.properties @@ -536,3 +536,5 @@ enableTerminalDocking=Terminal yerleştirmeyi etkinleştir enableTerminalDockingDescription=Terminal kenetleme ile terminal pencerelerini XPipe uygulama penceresine kenetleyerek bir nevi entegre terminal simülasyonu yapabilirsiniz. Terminal pencereleri daha sonra XPipe tarafından her zaman yuvaya sığacak şekilde yönetilir. downloadsDirectory=Özel indirme dizini downloadsDirectoryDescription=İndirilen dosyaları indirilenlere taşı düğmesine tıklandığında yerleştirilecek özel dizin. Varsayılan olarak, XPipe kullanıcı indirme dizininizi kullanacaktır. +pinLocalMachineOnStartup=Başlangıçta yerel makine sekmesini sabitleme +pinLocalMachineOnStartupDescription=Otomatik olarak bir yerel makine sekmesi açın ve sabitleyin. Bu, yerel makine ve uzak dosya sistemi açıkken sık sık bölünmüş bir dosya tarayıcısı kullanıyorsanız kullanışlıdır. diff --git a/lang/app/strings/translations_zh.properties b/lang/app/strings/translations_zh.properties index 93fa797d3..a851914d7 100644 --- a/lang/app/strings/translations_zh.properties +++ b/lang/app/strings/translations_zh.properties @@ -535,3 +535,5 @@ enableTerminalDocking=启用终端对接 enableTerminalDockingDescription=使用终端停靠功能,您可以将终端窗口停靠在 XPipe 应用程序窗口上,以模拟集成终端。XPipe会对终端窗口进行管理,使其始终适合停靠。 downloadsDirectory=自定义下载目录 downloadsDirectoryDescription=单击 "移动到下载 "按钮时将下载文件放入的自定义目录。默认情况下,XPipe 将使用您的用户下载目录。 +pinLocalMachineOnStartup=启动时 Pin 本地计算机选项卡 +pinLocalMachineOnStartupDescription=自动打开本地计算机标签并将其固定。如果你经常在打开本地机器和远程文件系统的情况下使用分割文件浏览器,这将非常有用。