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
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public void setControllers(final SettingsController settingsController, final Up
if (shouldUpdate) {
checkForUpdates(false, false);
}

setAudioBalance(Double.parseDouble(properties.getProperty("audioBalance", "0.0")));
}

/**
Expand Down Expand Up @@ -654,6 +656,15 @@ public void run() {
timer.schedule(timerTask, delay);
}

/**
* Set the audio balance
*
* @param audioBalance The audio balance
*/
public void setAudioBalance(final double audioBalance) {
getAllSoundPanes(grpControls).forEach(s -> s.setBalance(audioBalance));
}

/**
* Method that is called when the Window should be hidden or shown
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Slider;
import javafx.stage.Stage;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
Expand All @@ -30,6 +31,8 @@

public final class SettingsWindowController {

@FXML
private Slider sldAudioBalance;
@FXML
private CheckBox chbTimerComputerShutdown;
@FXML
Expand Down Expand Up @@ -186,6 +189,8 @@ private void loadSettings() {
cboTheme.getSelectionModel().select(themeIndex);
numDelay.setText(String.valueOf(correctDelay));
chbTimerComputerShutdown.setSelected(Boolean.parseBoolean(settingsController.getProperties().getProperty("timerComputerShutdown", "false")));

sldAudioBalance.setValue(Double.parseDouble(settingsController.getProperties().getProperty("audioBalance", "0.0")));
}

/**
Expand All @@ -201,7 +206,10 @@ private void resetSettingsAction() {
try {
settingsController.createDefaultProperties();
settingsController.setProperties(settingsController.readPropertiesFile());

mainWindowController.loadMediaButtonVisibility(Boolean.parseBoolean(settingsController.getProperties().getProperty("mediaButtons", "true")));
mainWindowController.setAudioBalance(Double.parseDouble(settingsController.getProperties().getProperty("audioBalance", "0.0")));

trayIconController.hideTrayIcon();

loadSettings();
Expand Down Expand Up @@ -282,6 +290,9 @@ private void saveSettingsAction() {
settingsController.getProperties().setProperty("timerApplicationShutdown", String.valueOf(chbTimerApplicationShutdown.isSelected()));
settingsController.getProperties().setProperty("timerComputerShutdown", String.valueOf(chbTimerComputerShutdown.isSelected()));

settingsController.getProperties().setProperty("audioBalance", String.valueOf(sldAudioBalance.getValue()));
mainWindowController.setAudioBalance(sldAudioBalance.getValue());

Configurator.setAllLevels(LogManager.getRootLogger().getName(), level);
try {
settingsController.saveProperties();
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/codedead/opal/domain/SoundPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class SoundPane extends GridPane {
private String mediaPath;
@FXML
private String mediaKey;
private double balance;
private MediaPlayer mediaPlayer;
private final Logger logger;

Expand Down Expand Up @@ -104,6 +105,7 @@ private void initializeMediaPlayer(final String value) throws URISyntaxException
imgMediaButton.setImage(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/play.png"))));
}
});
mediaPlayer.setBalance(balance);
}

/**
Expand Down Expand Up @@ -287,4 +289,28 @@ private void disposeMediaPlayer() {
mediaPlayer = null;
}
}

/**
* Get the audio balance
*
* @return The audio balance
*/
public double getBalance() {
return balance;
}

/**
* Set the audio balance
*
* @param balance The audio balance
*/
public void setBalance(final double balance) {
if (balance < -1.0 || balance > 1.0)
throw new IllegalArgumentException("Balance must be between -1.0 and 1.0!");

this.balance = balance;
if (mediaPlayer != null) {
mediaPlayer.setBalance(balance);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ mediaButtons=true
dragDrop=true
theme=light
trayIcon=false
audioBalance=0.0
Binary file added src/main/resources/images/advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/resources/translations/OpalApplication.properties
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Radio frequency static
PinkNoise=Pink noise
BrownNoise=Brown noise
TimerComputerShutdown=Shutdown computer
AudioBalance=Audio balance
Advanced=Advanced
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Radiofrequenzstörung
PinkNoise=Pinkes Rauschen
BrownNoise=Braunes Rauschen
TimerComputerShutdown=Computer herunterfahren
AudioBalance=Audiobalance
Advanced=Erweitert
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Radio frequency static
PinkNoise=Pink noise
BrownNoise=Brown noise
TimerComputerShutdown=Shutdown computer
AudioBalance=Audio balance
Advanced=Advanced
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Estático de frecuencia de radio
PinkNoise=Ruido rosa
BrownNoise=Ruido marrón
TimerComputerShutdown=Apagar la computadora
AudioBalance=Balance de audio
Advanced=Avanzado
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Bruit blanc de fréquence radio
PinkNoise=Bruit rose
BrownNoise=Bruit brun
TimerComputerShutdown=Éteindre l'ordinateur
AudioBalance=Balance audio
Advanced=Avancé
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=ラジオ周波数の静電気
PinkNoise=ピンクノイズ
BrownNoise=ブラウンノイズ
TimerComputerShutdown=コンピューターをシャットダウン
AudioBalance=オーディオ バランス
Advanced=高度な
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Radiofrequentie ruis
PinkNoise=Roze geluid
BrownNoise=Bruin geluid
TimerComputerShutdown=Computer afsluiten
AudioBalance=Audio balans
Advanced=Geavanceerd
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ RadioFrequencyStatic=Радиочастотный статический
PinkNoise=Розовый шум
BrownNoise=Коричневый шум
TimerComputerShutdown=Выключение компьютера
AudioBalance=Баланс аудио
Advanced=Дополнительно
83 changes: 58 additions & 25 deletions src/main/resources/windows/SettingsWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.image.Image?>

<?import javafx.scene.control.Slider?>
<GridPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="com.codedead.opal.controller.SettingsWindowController"
prefHeight="350.0" prefWidth="450.0">
prefHeight="320.0" prefWidth="450.0">

<rowConstraints>
<RowConstraints vgrow="ALWAYS"/>
Expand All @@ -43,7 +44,6 @@
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>

<columnConstraints>
Expand Down Expand Up @@ -115,29 +115,6 @@
</FXCollections>
</items>
</ComboBox>

<Label GridPane.rowIndex="6" 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="6" GridPane.columnIndex="1" maxWidth="Infinity">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="OFF"/>
<String fx:value="FATAL"/>
<String fx:value="ERROR"/>
<String fx:value="WARN"/>
<String fx:value="INFO"/>
<String fx:value="DEBUG"/>
<String fx:value="TRACE"/>
<String fx:value="ALL"/>
</FXCollections>
</items>
</ComboBox>
</GridPane>
</Tab>
<Tab text="%Timer">
Expand Down Expand Up @@ -191,6 +168,62 @@
</CheckBox>
</GridPane>
</Tab>
<Tab text="%Advanced">
<graphic>
<ImageView>
<Image url="@../images/advanced.png"/>
</ImageView>
</graphic>
<GridPane alignment="CENTER">
<rowConstraints>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>
<columnConstraints>
<ColumnConstraints/>
<ColumnConstraints/>
</columnConstraints>

<Label GridPane.rowIndex="0" text="%AudioBalance">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</Label>
<Slider GridPane.rowIndex="0" GridPane.columnIndex="1"
fx:id="sldAudioBalance" maxWidth="Infinity"
min="-1" max="1" majorTickUnit="1.0"
showTickLabels="true"
showTickMarks="true"
snapToTicks="true">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
</Slider>

<Label GridPane.rowIndex="1" 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="1" GridPane.columnIndex="1" maxWidth="Infinity">
<GridPane.margin>
<Insets bottom="3" left="3" right="3" top="3"/>
</GridPane.margin>
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="OFF"/>
<String fx:value="FATAL"/>
<String fx:value="ERROR"/>
<String fx:value="WARN"/>
<String fx:value="INFO"/>
<String fx:value="DEBUG"/>
<String fx:value="TRACE"/>
<String fx:value="ALL"/>
</FXCollections>
</items>
</ComboBox>
</GridPane>
</Tab>
</TabPane>

<GridPane GridPane.rowIndex="1">
Expand Down