add config, usb status fixes

This commit is contained in:
Craig Raw
2020-05-21 15:37:13 +02:00
parent fdd8327464
commit 7fc0e9b530
12 changed files with 194 additions and 53 deletions
@@ -1,5 +1,6 @@
package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
import com.sparrowwallet.sparrow.io.Device;
import javafx.geometry.Side;
@@ -10,33 +11,41 @@ import org.controlsfx.glyphfont.Glyph;
import java.util.List;
public class UsbStatusButton extends MenuButton {
private final List<Device> devices;
public UsbStatusButton(List<Device> devices) {
public UsbStatusButton() {
super("");
setGraphic(getIcon());
this.devices = devices;
this.setPopupSide(Side.TOP);
getStyleClass().add("status-bar-button");
this.setPopupSide(Side.RIGHT);
}
public void setDevices(List<Device> devices) {
for(Device device : devices) {
MenuItem deviceItem = new MenuItem(device.getModel().toDisplayString());
if(device.getNeedsPinSent()) {
deviceItem.setGraphic(getLockIcon());
} else {
deviceItem.setGraphic(getLockOpenIcon());
}
getItems().add(deviceItem);
}
}
private Node getIcon() {
Glyph usb = new Glyph(FontAwesome5Brands.FONT_NAME, FontAwesome5Brands.Glyph.USB);
usb.setFontSize(10);
usb.setFontSize(15);
return usb;
}
private class UsbStatusContextMenu extends ContextMenu {
public UsbStatusContextMenu() {
for(Device device : devices) {
MenuItem deviceItem = new MenuItem(device.getModel().toDisplayString());
getItems().add(deviceItem);
}
}
private Node getLockIcon() {
Glyph usb = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.LOCK);
usb.setFontSize(12);
return usb;
}
private Node getLockOpenIcon() {
Glyph usb = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.LOCK_OPEN);
usb.setFontSize(12);
return usb;
}
}