Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/codedead/opal/OpalApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public static void main(final String[] args) {
final Properties prop = new Properties();
prop.load(fis);

final Level level = switch (prop.getProperty("loglevel", "INFO")) {
final Level level = switch (prop.getProperty("loglevel", "ERROR")) {
case "OFF" -> Level.OFF;
case "FATAL" -> Level.FATAL;
case "ERROR" -> Level.ERROR;
case "WARN" -> Level.WARN;
case "DEBUG" -> Level.DEBUG;
case "TRACE" -> Level.TRACE;
case "ALL" -> Level.ALL;
default -> Level.INFO;
default -> Level.ERROR;
};
Configurator.setAllLevels(LogManager.getRootLogger().getName(), level);
} catch (final IOException ex) {
Expand Down
413 changes: 388 additions & 25 deletions src/main/java/com/codedead/opal/controller/MainWindowController.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public final class SettingsWindowController {

@FXML
private CheckBox chbMediaButtons;
@FXML
private CheckBox chbTimerApplicationShutdown;
@FXML
Expand All @@ -36,6 +38,7 @@ public final class SettingsWindowController {
@FXML
private ComboBox<String> cboLogLevel;

private MainWindowController mainWindowController;
private SettingsController settingsController;
private ResourceBundle translationBundle;
private Properties properties;
Expand Down Expand Up @@ -80,12 +83,22 @@ public void setSettingsController(final SettingsController settingsController) {
loadSettings();
}

/**
* Set the {@link MainWindowController} object
*
* @param mainWindowController The {@link MainWindowController} object
*/
public void setMainWindowController(final MainWindowController mainWindowController) {
this.mainWindowController = mainWindowController;
}

/**
* Load all the settings into the UI
*/
private void loadSettings() {
logger.info("Attempting to load all settings");
final boolean autoUpdate = Boolean.parseBoolean(properties.getProperty("autoUpdate", "true"));
final boolean mediaButtons = Boolean.parseBoolean(properties.getProperty("mediaButtons", "true"));
final String locale = properties.getProperty("locale", DEFAULT_LOCALE);
final String logLevel = properties.getProperty("loglevel", "INFO");
long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
Expand All @@ -96,6 +109,7 @@ private void loadSettings() {
}

chbAutoUpdate.setSelected(autoUpdate);
chbMediaButtons.setSelected(mediaButtons);
chbTimerApplicationShutdown.setSelected(Boolean.parseBoolean(properties.getProperty("timerApplicationShutdown", "false")));

switch (locale.toLowerCase()) {
Expand Down Expand Up @@ -149,6 +163,7 @@ private void resetSettingsAction() {
try {
settingsController.createDefaultProperties();
settingsController.setProperties(settingsController.readPropertiesFile());
mainWindowController.loadMediaButtonVisibility(Boolean.parseBoolean(settingsController.getProperties().getProperty("mediaButtons", "true")));

setSettingsController(settingsController);
} catch (final IOException ex) {
Expand All @@ -166,7 +181,8 @@ private void saveSettingsAction() {
logger.info("Attempting to save all settings");

properties.setProperty("autoUpdate", Boolean.toString(chbAutoUpdate.isSelected()));
properties.setProperty("trayIcon", Boolean.toString(chbAutoUpdate.isSelected()));
properties.setProperty("mediaButtons", Boolean.toString(chbMediaButtons.isSelected()));
mainWindowController.loadMediaButtonVisibility(chbMediaButtons.isSelected());

showAlertIfLanguageMismatch(properties.getProperty("locale", DEFAULT_LOCALE));

Expand Down
54 changes: 45 additions & 9 deletions src/main/java/com/codedead/opal/domain/SoundPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.image.Image;
Expand All @@ -10,6 +11,7 @@

import java.io.IOException;
import java.net.URL;
import java.util.Objects;

public final class SoundPane extends GridPane {

Expand All @@ -20,7 +22,12 @@ public final class SoundPane extends GridPane {
@FXML
private Slider sldVolume;
@FXML
private String key;
private Button btnPlayPause;
@FXML
private boolean mediaButton;
@FXML
private ImageView imgMediaButton;
private boolean playing;

/**
* Initialize a new SoundPane
Expand Down Expand Up @@ -112,22 +119,51 @@ public Slider getSlider() {
}

/**
* Get the key
* Get whether media buttons are enabled
*
* @return The key
* @return True if media buttons are enabled, otherwise false
*/
@FXML
public String getKey() {
return key;
public boolean isMediaButton() {
return mediaButton;
}

/**
* Set the key
* Set whether media buttons are enabled
*
* @param key The key
* @param mediaButton True if media buttons shoudl be enabled, otherwise false
*/
@FXML
public void setKey(final String key) {
this.key = key;
public void setMediaButton(final boolean mediaButton) {
btnPlayPause.setVisible(mediaButton);
btnPlayPause.setManaged(mediaButton);
this.mediaButton = mediaButton;
}

/**
* Get the {@link Button} object to play or pause media
*
* @return The {@link Button} object to play or pause media
*/
public Button getBtnPlayPause() {
return btnPlayPause;
}

/**
* Get whether the {@link javafx.scene.media.MediaPlayer} is playing or not
*
* @return True if the {@link javafx.scene.media.MediaPlayer} is playing, otherwise false
*/
public boolean isPlaying() {
return playing;
}

public void setPlaying(final boolean playing) {
if (playing && !this.playing) {
imgMediaButton.setImage(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/pause.png"))));
} else if (!playing && this.playing) {
imgMediaButton.setImage(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/play.png"))));
}
this.playing = playing;
}
}
13 changes: 13 additions & 0 deletions src/main/resources/controls/SoundPane.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

<?import javafx.geometry.Insets?>

<?import javafx.scene.image.Image?>
<fx:root type="javafx.scene.layout.GridPane"
xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml">

<columnConstraints>
<ColumnConstraints/>
<ColumnConstraints hgrow="ALWAYS"/>
<ColumnConstraints/>
</columnConstraints>

<ImageView GridPane.rowIndex="0" GridPane.columnIndex="0" fx:id="soundImage">
Expand Down Expand Up @@ -43,4 +45,15 @@
</GridPane.margin>
</Slider>
</GridPane>

<Button GridPane.rowIndex="0" GridPane.columnIndex="2" fx:id="btnPlayPause">
<GridPane.margin>
<Insets left="5" right="5" bottom="5" top="5"/>
</GridPane.margin>
<graphic>
<ImageView fx:id="imgMediaButton">
<Image url="@../images/play.png"/>
</ImageView>
</graphic>
</Button>
</fx:root>
3 changes: 2 additions & 1 deletion src/main/resources/default.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
locale=en-US
autoUpdate=true
updateApi=https://codedead.com/Software/Opal/version.json
loglevel=INFO
loglevel=ERROR
timerDelay=3600000
timerDelayType=2
timerApplicationShutdown=false
mediaButtons=true
Binary file added src/main/resources/images/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/translations/OpalApplication.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Football
Sleepy=Sleepy
DrumTribalFestival=Drum tribal festival
Gong=Gong
MediaButtons=Media buttons
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Football
Sleepy=Schläfrig
DrumTribalFestival=Stammesfest der Trommeln
Gong=Klingel
MediaButtons=Medientasten
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Football
Sleepy=Sleepy
DrumTribalFestival=Drum tribal festival
Gong=Gong
MediaButtons=Media buttons
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Fútbol
Sleepy=Somnoliento
DrumTribalFestival=Festival tribal de tambores
Gong=Gongo
MediaButtons=Botones multimedia
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Football
Sleepy=Somnolent
DrumTribalFestival=Fête tribale du tambour
Gong=Gong
MediaButtons=Boutons multimédias
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Voetbal
Sleepy=Slaperig
DrumTribalFestival=Drumstammenfestival
Gong=Gong
MediaButtons=Mediaknoppen
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Football=Футбол
Sleepy=Сонный
DrumTribalFestival=Племенной фестиваль барабанов
Gong=Гонг
MediaButtons=Медиа-кнопки
15 changes: 11 additions & 4 deletions src/main/resources/windows/SettingsWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>

<columnConstraints>
Expand All @@ -52,12 +53,18 @@
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</CheckBox>
<Label GridPane.rowIndex="1" GridPane.columnIndex="0" text="%Language">
<CheckBox fx:id="chbMediaButtons" GridPane.columnSpan="2" GridPane.rowIndex="1"
GridPane.columnIndex="0" text="%MediaButtons">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</CheckBox>
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="%Language">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</Label>
<ComboBox fx:id="cboLanguage" GridPane.rowIndex="1" GridPane.columnIndex="1" maxWidth="Infinity">
<ComboBox fx:id="cboLanguage" GridPane.rowIndex="2" GridPane.columnIndex="1" maxWidth="Infinity">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
Expand All @@ -73,12 +80,12 @@
</items>
</ComboBox>

<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="%LogLevel">
<Label GridPane.rowIndex="3" GridPane.columnIndex="0" text="%LogLevel">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</Label>
<ComboBox fx:id="cboLogLevel" GridPane.rowIndex="2" GridPane.columnIndex="1" maxWidth="Infinity">
<ComboBox fx:id="cboLogLevel" GridPane.rowIndex="3" GridPane.columnIndex="1" maxWidth="Infinity">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
Expand Down