auto open recent wallets

This commit is contained in:
Craig Raw 2020-08-07 17:31:40 +02:00
parent b43b25769e
commit cda4e30e3f
6 changed files with 28 additions and 10 deletions

View file

@ -252,8 +252,14 @@ public class AppController implements Initializable {
openTransactionIdItem.disableProperty().bind(onlineProperty.not());
openWalletFile(new File("/Users/scy/.sparrow/wallets/sparta.json"));
openWalletFile(new File("/Users/scy/.sparrow/wallets/sparta-test.json"));
List<File> recentWalletFiles = Config.get().getRecentWalletFiles();
if(recentWalletFiles != null) {
for(File walletFile : recentWalletFiles) {
if(walletFile.exists()) {
openWalletFile(walletFile);
}
}
}
}
private ElectrumServer.ConnectionService createConnectionService() {
@ -1085,6 +1091,9 @@ public class AppController implements Initializable {
@Subscribe
public void openWallets(OpenWalletsEvent event) {
List<File> walletFiles = event.getWalletsMap().values().stream().map(storage -> storage.getWalletFile()).collect(Collectors.toList());
Config.get().setRecentWalletFiles(walletFiles);
boolean usbWallet = false;
for(Map.Entry<Wallet, Storage> entry : event.getWalletsMap().entrySet()) {
Wallet wallet = entry.getKey();

View file

@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Type;
import java.util.Currency;
import java.util.List;
public class Config {
private static final Logger log = LoggerFactory.getLogger(Config.class);
@ -22,6 +23,7 @@ public class Config {
private boolean groupByAddress = true;
private boolean includeMempoolChange = true;
private boolean notifyNewTransactions = true;
private List<File> recentWalletFiles;
private Integer keyDerivationPeriod;
private File hwi;
private String electrumServer;
@ -133,6 +135,15 @@ public class Config {
flush();
}
public List<File> getRecentWalletFiles() {
return recentWalletFiles;
}
public void setRecentWalletFiles(List<File> recentWalletFiles) {
this.recentWalletFiles = recentWalletFiles;
flush();
}
public Integer getKeyDerivationPeriod() {
return keyDerivationPeriod;
}

View file

@ -272,8 +272,6 @@ public class SendController extends WalletFormController implements Initializabl
createButton.setDisable(walletTransaction == null || label.getText().isEmpty());
});
address.setText("19Sp9dLinHy3dKo2Xxj53ouuZWAoVGGhg8");
addValidation();
}

View file

@ -22,7 +22,7 @@
<MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId"/>
<MenuItem text="From Text..." onAction="#openTransactionFromText"/>
<MenuItem text="From QR..." onAction="#openTransactionFromQR"/>
<MenuItem text="Examples" onAction="#openExamples"/>
<!-- <MenuItem text="Examples" onAction="#openExamples"/> -->
</items>
</Menu>
<MenuItem fx:id="saveTransaction" mnemonicParsing="false" text="Save Transaction..." onAction="#saveTransaction"/>

View file

@ -27,7 +27,7 @@
</padding>
<columnConstraints>
<ColumnConstraints prefWidth="620" />
<ColumnConstraints prefWidth="150" />
<ColumnConstraints prefWidth="140" />
</columnConstraints>
<rowConstraints>
<RowConstraints />

View file

@ -29,15 +29,15 @@
<Insets left="25.0" right="25.0" top="25.0" />
</padding>
<columnConstraints>
<ColumnConstraints percentWidth="50" />
<ColumnConstraints percentWidth="30" />
<ColumnConstraints percentWidth="20" />
<ColumnConstraints prefWidth="385" />
<ColumnConstraints prefWidth="225" />
<ColumnConstraints prefWidth="140" />
</columnConstraints>
<rowConstraints>
<RowConstraints />
</rowConstraints>
<Form GridPane.columnIndex="0" GridPane.rowIndex="0" GridPane.columnSpan="2">
<Fieldset inputGrow="SOMETIMES" text="Send">
<Fieldset inputGrow="ALWAYS" text="Send">
<Field text="Pay to:">
<CopyableTextField fx:id="address" styleClass="address-text-field"/>
</Field>