Skip to content

Commit

Permalink
Change the preferences icons
Browse files Browse the repository at this point in the history
Now uses ikonli. Also add preliminary transfer settings.
  • Loading branch information
zapek committed Dec 11, 2023
1 parent 089e515 commit a2508ea
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected void updateItem(SettingsGroup item, boolean empty)
{
super.updateItem(item, empty);
setText(empty ? null : item.name());
setGraphic(empty ? null : item.image());
setGraphic(empty ? null : item.graphic());
setGraphicTextGap(8.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package io.xeres.ui.controller.settings;

import javafx.scene.image.ImageView;
import javafx.scene.Node;

record SettingsGroup(String name, ImageView image, Class<? extends SettingsController> controllerClass)
record SettingsGroup(String name, Node graphic, Class<? extends SettingsController> controllerClass)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2023 by David Gerber - https://zapek.com
*
* This file is part of Xeres.
*
* Xeres is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xeres is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xeres. If not, see <http://www.gnu.org/licenses/>.
*/

package io.xeres.ui.controller.settings;

import io.xeres.ui.model.settings.Settings;
import net.rgielen.fxweaver.core.FxmlView;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@FxmlView(value = "/view/settings/settings_transfer.fxml")
public class SettingsTransferController implements SettingsController
{
@Override
public void initialize() throws IOException
{

}

@Override
public void onLoad(Settings settings)
{

}

@Override
public Settings onSave()
{
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import io.xeres.ui.model.settings.Settings;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.ListView;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import net.rgielen.fxweaver.core.FxWeaver;
import net.rgielen.fxweaver.core.FxmlView;
import org.kordamp.ikonli.javafx.FontIcon;
import org.springframework.stereotype.Component;

import java.util.ResourceBundle;
Expand All @@ -37,6 +40,8 @@
@FxmlView(value = "/view/settings/settings.fxml")
public class SettingsWindowController implements WindowController
{
private static final int PREFERENCE_ICON_SIZE = 24;

private final SettingsClient settingsClient;

@FXML
Expand All @@ -62,9 +67,12 @@ public SettingsWindowController(SettingsClient settingsClient, FxWeaver fxWeaver
public void initialize()
{
listView.setCellFactory(param -> new SettingsCell());

listView.getItems().addAll(
new SettingsGroup(bundle.getString("settings.general"), new ImageView("/image/settings_general.png"), SettingsGeneralController.class),
new SettingsGroup(bundle.getString("settings.network"), new ImageView("/image/settings_networks.png"), SettingsNetworksController.class));
new SettingsGroup(bundle.getString("settings.general"), createPreferenceGraphic("fas-cog"), SettingsGeneralController.class),
new SettingsGroup(bundle.getString("settings.network"), createPreferenceGraphic("fas-network-wired"), SettingsNetworksController.class),
new SettingsGroup(bundle.getString("settings.transfer"), createPreferenceGraphic("fas-exchange-alt"), SettingsTransferController.class)
);

listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
saveContent();
Expand Down Expand Up @@ -114,8 +122,21 @@ private void saveContent()
{
if (!content.getChildren().isEmpty())
{
var controller = (SettingsController) content.getChildren().get(0).getUserData();
newSettings = controller.onSave();
var controller = (SettingsController) content.getChildren().getFirst().getUserData();
var controllerSettings = controller.onSave();
if (controllerSettings != null)
{
newSettings = controllerSettings;
}
}
}

private Node createPreferenceGraphic(String iconCode)
{
var pane = new StackPane(new FontIcon(iconCode));
pane.setPrefWidth(PREFERENCE_ICON_SIZE);
pane.setPrefHeight(PREFERENCE_ICON_SIZE);
pane.setAlignment(Pos.CENTER);
return pane;
}
}
1 change: 1 addition & 0 deletions ui/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ camera.window-title=Scan QR Code
settings.window-title=Settings
settings.general=General
settings.network=Network
settings.transfer=Transfer
## General
settings.general.system=System
settings.general.startup=Launch on system startup
Expand Down
Binary file removed ui/src/main/resources/image/settings_general.png
Binary file not shown.
Binary file removed ui/src/main/resources/image/settings_networks.png
Binary file not shown.
27 changes: 27 additions & 0 deletions ui/src/main/resources/view/settings/settings_transfer.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2023 by David Gerber - https://zapek.com
~
~ This file is part of Xeres.
~
~ Xeres is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ Xeres is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Xeres. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" spacing="12.0" xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="io.xeres.ui.controller.settings.SettingsTransferController">

</VBox>

0 comments on commit a2508ea

Please sign in to comment.