diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..e85efc8
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,21 @@
+pipeline {
+ agent {
+ docker {
+ image 'maven:3-jdk-11'
+ args '-v /home/docker/jenkins/files/m2:/root/.m2'
+ }
+ }
+
+ stages {
+ stage('Build') {
+ steps {
+ sh 'mvn -B -DskipTests clean package'
+ }
+ }
+ }
+ post {
+ always {
+ archiveArtifacts artifacts: 'target/*.jar, target/*.exe', onlyIfSuccessful: true
+ }
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 96a2825..fda55e0 100644
--- a/README.md
+++ b/README.md
@@ -58,8 +58,8 @@ Want to support development? Make a donation* (see below):
* [x] Tray support
* [ ] tray icon size checks
* [x] Configuration files support
-* [ ] Settings
- * [ ] Tray icon settings
+* [x] Settings
+ * [x] Tray icon settings
* [ ] Autoload
* [ ] Headless mode (CLI)
* [x] Fix UI
diff --git a/pom.xml b/pom.xml
index 596e6ad..998072c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
loper
LogiLed
- 0.4-SNAPSHOT
+ 1.0-SNAPSHOT
@@ -164,14 +164,15 @@
2.10.0
compile
+
+
+ net.java.dev.jna
+ jna
+ 5.4.0
+ compile
+
+ -->
diff --git a/src/main/java/logiled/AppPreferences.java b/src/main/java/logiled/AppPreferences.java
new file mode 100644
index 0000000..f0e87f4
--- /dev/null
+++ b/src/main/java/logiled/AppPreferences.java
@@ -0,0 +1,25 @@
+package logiled;
+
+import java.util.prefs.Preferences;
+
+// Rule application settings
+public class AppPreferences {
+
+ private Preferences preferences;
+
+ public AppPreferences(){
+ preferences = Preferences.userRoot().node("LogiLed");
+ }
+
+ public void setUseTray(boolean value){ preferences.putBoolean("USE_TRAY", value); }
+ public boolean getUseTray(){ return preferences.getBoolean("USE_TRAY", true); }
+
+/*
+ public void setPath(String path){
+ preferences.put("PATH", path);
+ }
+ public String getPath(){
+ return preferences.get("PATH", "/");
+ }
+*/
+}
diff --git a/src/main/java/logiled/Controllers/MainController.java b/src/main/java/logiled/Controllers/MainController.java
index 4d3268f..21c9e9c 100644
--- a/src/main/java/logiled/Controllers/MainController.java
+++ b/src/main/java/logiled/Controllers/MainController.java
@@ -12,6 +12,7 @@ import logiled.About.AboutWindow;
import logiled.MessagesConsumer;
import logiled.Config.SettingsFileFormat;
import logiled.ServiceWindow;
+import logiled.Settings.SettingsWindow;
import logiled.USB.EffectsThread;
import logiled.USB.GameModeThread;
import logiled.USB.KeyLedThread;
@@ -39,7 +40,7 @@ public class MainController implements Initializable {
private Tab KeyLedTab, EffectsTab;
*/
@FXML
- private Button applyBtn, openBtn, saveBtn, saveAsBtn, aboutBtn;
+ private Button applyBtn, openBtn, saveBtn, saveAsBtn, settingsBtn, aboutBtn;
@FXML
private Label infoLbl;
@@ -54,6 +55,7 @@ public class MainController implements Initializable {
this.rb = resourceBundle;
aboutBtn.setOnAction(actionEvent -> new AboutWindow());
+ settingsBtn.setOnAction(actionEvent -> new SettingsWindow());
MessagesConsumer.getInstance().setInstance(infoLbl);
MessagesConsumer.getInstance().start();
diff --git a/src/main/java/logiled/MainFx.java b/src/main/java/logiled/MainFx.java
index c815f66..d8f5017 100644
--- a/src/main/java/logiled/MainFx.java
+++ b/src/main/java/logiled/MainFx.java
@@ -16,15 +16,21 @@ import java.util.Locale;
import java.util.ResourceBundle;
public class MainFx extends Application {
- public static final String appVersion = "v0.4";
+ public static final String appVersion = "v1.0";
private static boolean traySupport = true;
private Stage stage;
+ private SystemTray tray;
+ private TrayIcon trayIcon;
+
private ResourceBundle rb;
@Override
public void start(Stage primaryStage) throws Exception{
+ AppPreferences appPreferences = new AppPreferences();
+ if (traySupport) // By default it's enabled, but in case it disabled from CLI, don't touch.
+ traySupport = appPreferences.getUseTray(); // Otherwise, check against preferences
//-----------------------Tray support---------------------
this.stage = primaryStage;
if (traySupport){
@@ -32,7 +38,8 @@ public class MainFx extends Application {
SwingUtilities.invokeLater(this::addAppToTray);
}
//--------------------------------------------------------
- Mediator.getInstance().setInstance(getHostServices());
+ Mediator.getInstance().setHostServices(getHostServices());
+ Mediator.getInstance().setPreferences(appPreferences);
FXMLLoader loader = new FXMLLoader(getClass().getResource("/Main.fxml"));
@@ -52,8 +59,20 @@ public class MainFx extends Application {
new Image(getClass().getResourceAsStream("/ico/appIcon_128.png"))
);
// NOTE: tray leftovers
- if (traySupport)
- primaryStage.setOnCloseRequest(windowEvent -> primaryStage.hide());
+ if (traySupport) {
+ stage.setOnCloseRequest(windowEvent -> {
+ Platform.exit();
+ tray.remove(trayIcon);
+ });
+
+ stage.iconifiedProperty().addListener((observableValue, oldVal, iconified) -> {
+ if (iconified)
+ Platform.runLater(this::hideStage);
+ else
+ Platform.runLater(this::showStage);
+ });
+ //primaryStage.setOnCloseRequest(windowEvent -> primaryStage.hide());
+ }
primaryStage.setTitle("LogiLed "+appVersion);
primaryStage.setMinWidth(1215);
@@ -75,9 +94,9 @@ public class MainFx extends Application {
Platform.exit();
}
- SystemTray tray = SystemTray.getSystemTray();
+ tray = SystemTray.getSystemTray();
- TrayIcon trayIcon = new TrayIcon(ImageIO.read(getClass().getResourceAsStream("/ico/appIcon_24.png")));
+ trayIcon = new TrayIcon(ImageIO.read(getClass().getResourceAsStream("/ico/appIcon_24.png")));
trayIcon.addActionListener(ActionEvent -> Platform.runLater(this::showStage));
@@ -89,9 +108,16 @@ public class MainFx extends Application {
java.awt.Font defaultFont = java.awt.Font.decode(null);
java.awt.Font boldFont = defaultFont.deriveFont(java.awt.Font.BOLD);
+
+ MenuItem openItem = new MenuItem(rb.getString("open"));
+ openItem.addActionListener(actionEvent -> Platform.runLater(this::showStage));
+
+ openItem.setFont(boldFont);
closeItem.setFont(boldFont);
final PopupMenu popupMenu = new PopupMenu();
+ popupMenu.add(openItem);
+ popupMenu.addSeparator();
popupMenu.add(closeItem);
trayIcon.setPopupMenu(popupMenu);
tray.add(trayIcon);
@@ -103,10 +129,16 @@ public class MainFx extends Application {
}
private void showStage() {
- if (stage != null) {
- stage.show();
- stage.toFront();
- }
+ if (stage == null)
+ return;
+ stage.show();
+ stage.toFront();
+ }
+
+ private void hideStage(){
+ if (stage == null)
+ return;
+ stage.hide();
}
public static void main(String[] args) {
diff --git a/src/main/java/logiled/Mediator.java b/src/main/java/logiled/Mediator.java
index 50c48ff..a94bc03 100644
--- a/src/main/java/logiled/Mediator.java
+++ b/src/main/java/logiled/Mediator.java
@@ -5,14 +5,17 @@ import javafx.application.HostServices;
public class Mediator{
private HostServices hostServices;
+ private AppPreferences preferences;
public static Mediator getInstance(){ return MediatorHolder.INSTANCE; }
- public void setInstance(HostServices hostServices){ this.hostServices = hostServices; }
+ public void setHostServices(HostServices hostServices){ this.hostServices = hostServices; }
+ public void setPreferences(AppPreferences preferences){ this.preferences = preferences; }
private static class MediatorHolder{
private static final Mediator INSTANCE = new Mediator();
}
public HostServices getHostServices() { return hostServices; }
+ public AppPreferences getPreferences() { return preferences; }
}
\ No newline at end of file
diff --git a/src/main/java/logiled/Settings/SettingsController.java b/src/main/java/logiled/Settings/SettingsController.java
new file mode 100644
index 0000000..5509635
--- /dev/null
+++ b/src/main/java/logiled/Settings/SettingsController.java
@@ -0,0 +1,34 @@
+package logiled.Settings;
+
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.stage.Stage;
+import logiled.Mediator;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+public class SettingsController implements Initializable {
+
+ @FXML
+ private Button cancelBtn, okBtn;
+
+ @FXML
+ private CheckBox trayCB;
+
+ @Override
+ public void initialize(URL url, ResourceBundle resourceBundle) {
+ trayCB.setSelected(Mediator.getInstance().getPreferences().getUseTray());
+
+ cancelBtn.setOnAction(actionEvent -> ((Stage) cancelBtn.getScene().getWindow()).close());
+
+ okBtn.setOnAction(actionEvent -> {
+ Mediator.getInstance().getPreferences().setUseTray(trayCB.isSelected());
+ ((Stage) cancelBtn.getScene().getWindow()).close();
+ });
+
+ //trayCB.setSelected();
+ }
+}
diff --git a/src/main/java/logiled/Settings/SettingsWindow.java b/src/main/java/logiled/Settings/SettingsWindow.java
new file mode 100644
index 0000000..2fdb1a0
--- /dev/null
+++ b/src/main/java/logiled/Settings/SettingsWindow.java
@@ -0,0 +1,44 @@
+package logiled.Settings;
+
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+public class SettingsWindow {
+
+ public SettingsWindow(){
+ Stage stageAbout = new Stage();
+
+ stageAbout.setMinWidth(500);
+ stageAbout.setMinHeight(500);
+
+ FXMLLoader loaderAbout = new FXMLLoader(getClass().getResource("/SettingsLayout.fxml"));
+ ResourceBundle resourceBundle;
+
+ Locale userLocale = new Locale(Locale.getDefault().getISO3Language()); // NOTE: user locale based on ISO3 Language codes
+ resourceBundle = ResourceBundle.getBundle("locale", userLocale);
+ loaderAbout.setResources(resourceBundle);
+
+ try {
+ Parent parentAbout = loaderAbout.load();
+
+ stageAbout.setTitle(resourceBundle.getString("btn_settings"));
+ stageAbout.getIcons().addAll(
+ new Image(getClass().getResourceAsStream("/ico/appIcon_32.png")),
+ new Image(getClass().getResourceAsStream("/ico/appIcon_48.png")),
+ new Image(getClass().getResourceAsStream("/ico/appIcon_64.png")),
+ new Image(getClass().getResourceAsStream("/ico/appIcon_128.png"))
+ );
+ stageAbout.setScene(new Scene(parentAbout, 500, 500));
+
+ stageAbout.show();
+
+ } catch (IOException ignored){}
+ }
+}
diff --git a/src/main/resources/Main.fxml b/src/main/resources/Main.fxml
index 7d29c4d..a3ee670 100644
--- a/src/main/resources/Main.fxml
+++ b/src/main/resources/Main.fxml
@@ -71,7 +71,7 @@
-