Skip to content

Commit

Permalink
Added quran quote | variable settings title size | user installtion i…
Browse files Browse the repository at this point in the history
…nstead of general installation
  • Loading branch information
DBChoco committed May 22, 2022
1 parent 7f93960 commit 8457704
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 44 deletions.
41 changes: 3 additions & 38 deletions pom.xml
Expand Up @@ -155,13 +155,15 @@
<!-- https://github.com/fvarrui/JavaPackager/blob/master/docs/macosx-specific-properties.md -->
<winConfig>
<!-- general properties -->
<generateMsi>false</generateMsi>
<icoFile>src/main/resources/io/github/dbchoco/Salawat/images/icon.ico</icoFile>

<!-- exe creation properties -->
<headerType>console</headerType>
<originalFilename>${name}-${version}.exe</originalFilename>

<!-- setup generation properties -->
<setupMode>installForCurrentUser</setupMode>
<disableRunAfterInstall>false</disableRunAfterInstall>
<createDesktopIconTask>false</createDesktopIconTask>

Expand All @@ -172,7 +174,7 @@
<key>HKCU:Software\Microsoft\Windows\CurrentVersion\Run</key>
<valueName>Salawat</valueName>
<valueType>REG_SZ</valueType>
<valueData>C:\Program Files\Salawat\Salawat.exe</valueData>
<valueData>%USERPROFILE%\AppData\Local\Programs\Salawat\Salawat.exe</valueData>
</entry>
</entries>
</registry>
Expand All @@ -183,41 +185,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>flatpak</id>
<build>
<plugins>
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.6.6</version>
<executions>
<execution>
<configuration>
<!-- mandatory -->
<mainClass>io.github.dbchoco.Salawat.FakeMain</mainClass>
<!-- optional -->
<bundleJre>true</bundleJre>
<copyDependencies>true</copyDependencies>
<runnableJar>${project.build.directory}/${project.artifactId}-${project.version}.jar</runnableJar>
<generateInstaller>true</generateInstaller>
<administratorRequired>false</administratorRequired>
<createTarball>false</createTarball>
<platform>auto</platform>
<additionalResources>Salawat.desktop</additionalResources>
<linuxConfig>
<pngFile>src/main/resources/io/github/dbchoco/Salawat/images/icon.png</pngFile>
<generateDeb>false</generateDeb>
<generateRpm>false</generateRpm>
</linuxConfig>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- https://github.com/fvarrui/JavaPackager -->
</profile>
</profiles>
</project>
Expand Up @@ -2,6 +2,7 @@

import io.github.dbchoco.Salawat.app.I18N;
import io.github.dbchoco.Salawat.controllers.BaseController;
import io.github.dbchoco.Salawat.helpers.FontBinder;
import io.github.dbchoco.Salawat.helpers.SizeBinder;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
Expand All @@ -24,7 +25,8 @@ protected void translate() {

@Override
protected void makeResizable() {
SizeBinder.bindSize(hbox, 1280, 70, "settings");
SizeBinder.bindSize(flowPane, 600, 70, "settings");
SizeBinder.bindSize(hbox, 1280, 80, "settings");
SizeBinder.bindSize(flowPane, 600, 80, "settings");
FontBinder.bindFontSize(settingsLabel, "large");
}
}
@@ -1,35 +1,47 @@
package io.github.dbchoco.Salawat.controllers.settings;

import io.github.dbchoco.Salawat.app.I18N;
import io.github.dbchoco.Salawat.app.UserSettings;
import io.github.dbchoco.Salawat.controllers.BaseController;
import io.github.dbchoco.Salawat.helpers.Controllers;
import io.github.dbchoco.Salawat.helpers.FontBinder;
import io.github.dbchoco.Salawat.helpers.SizeBinder;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;

import java.awt.*;

public class SettingsController extends BaseController {
public BorderPane borderPane;
public GridPane gridPane;
public AnchorPane root;
public FlowPane mainSettings;
public Label quranQuote;
public Label quranSource;

public void initialize(){
loadBackground();
Controllers.setSettingsController(this);
makeResizable();
translate();
}

@Override
protected void translate() {

I18N.bindString(quranQuote, "quote");
I18N.bindString(quranSource, "source");
}

@Override
protected void makeResizable() {
//SizeBinder.bindSize(root, 1280, 720, "settings");
SizeBinder.bindSize(borderPane, 1280, 720, "settings");
SizeBinder.bindSize(gridPane, 1280, 500, "settings");
FontBinder.bindFontSize(quranQuote, "small");
FontBinder.bindFontSize(quranSource, "smaller");
}

public ReadOnlyDoubleProperty getWidthProperty(){
Expand Down
Expand Up @@ -14,12 +14,16 @@ public class FontBinder {
private static final ObjectProperty<Font> fontLarge = new SimpleObjectProperty<Font>(font);
static final ObjectProperty<Font> fontMedium = new SimpleObjectProperty<Font>(font);
private static final ObjectProperty<Font> fontSmall = new SimpleObjectProperty<Font>(font);
private static final ObjectProperty<Font> fontSmaller = new SimpleObjectProperty<Font>(font);

private static final Integer smallerFontRatio = 50;
private static final Integer smallFontRatio = 35;
private static final Integer mediumFontRatio = 25;
private static final Integer largeFontRatio = 18;
private static final Integer largerFontRatio = 10;

public static void init(){
fontSmaller.set(FontChooser.getFont(StageController.getStage().heightProperty().doubleValue() / smallerFontRatio));
fontSmall.set(FontChooser.getFont(StageController.getStage().heightProperty().doubleValue() / smallFontRatio));
fontMedium.set(FontChooser.getFont(
StageController.getStage().heightProperty().doubleValue() / mediumFontRatio));
Expand All @@ -28,6 +32,7 @@ public static void init(){
StageController.getStage().heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number t1) {
fontSmaller.set(FontChooser.getFont(t1.doubleValue() / smallerFontRatio));
fontSmall.set(FontChooser.getFont(t1.doubleValue() / smallFontRatio));
fontMedium.set(FontChooser.getFont(t1.doubleValue() / mediumFontRatio));
fontLarge.set(FontChooser.getFont(t1.doubleValue() / largeFontRatio));
Expand All @@ -37,6 +42,7 @@ public void changed(ObservableValue<? extends Number> observableValue, Number nu
}

public static void reloadFonts(){
fontSmaller.set(FontChooser.getFont(StageController.getStage().heightProperty().doubleValue() / smallerFontRatio));
fontSmall.set(FontChooser.getFont(StageController.getStage().heightProperty().doubleValue() / smallFontRatio));
fontMedium.set(FontChooser.getFont(
StageController.getStage().heightProperty().doubleValue() / mediumFontRatio));
Expand All @@ -46,6 +52,7 @@ public static void reloadFonts(){

public static void bindFontSize(Label label, String size){
switch (size){
case "smaller" -> label.fontProperty().bind(fontSmaller);
case "small" -> label.fontProperty().bind(fontSmall);
case "medium" -> label.fontProperty().bind(fontMedium);
case "large" -> label.fontProperty().bind(fontLarge);
Expand Down
28 changes: 25 additions & 3 deletions src/main/resources/io/github/dbchoco/Salawat/fxml/settings.fxml
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<AnchorPane fx:id="root" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.github.dbchoco.Salawat.controllers.settings.SettingsController">
<children>
Expand All @@ -22,22 +25,41 @@
</FlowPane>
</bottom>
<center>
<GridPane fx:id="gridPane" alignment="TOP_CENTER" pickOnBounds="false" prefHeight="582.0" prefWidth="669.0" BorderPane.alignment="CENTER">
<GridPane fx:id="gridPane" alignment="TOP_CENTER" pickOnBounds="false" prefHeight="550.0" prefWidth="1280.0" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="481.0" minHeight="10.0" prefHeight="448.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="285.0" minHeight="10.0" prefHeight="134.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<HBox fx:id="innerHBox" alignment="TOP_CENTER" pickOnBounds="false" spacing="20.0">
<children>
<fx:include fx:id="sideBar" source="settings/sideBar.fxml" />
<FlowPane fx:id="mainSettings" prefHeight="600" prefWidth="400.0">
<FlowPane fx:id="mainSettings" prefHeight="585.0" prefWidth="400.0">
<fx:include source="settings/tabs/general.fxml" />
</FlowPane>
</children>
<GridPane.margin>
<Insets top="30.0" />
</GridPane.margin>
</HBox>
<VBox alignment="BOTTOM_CENTER" mouseTransparent="true" pickOnBounds="false" prefWidth="1280.0" GridPane.rowIndex="1">
<children>
<Label fx:id="quranQuote" alignment="CENTER" contentDisplay="CENTER" text="Quran Quote" wrapText="true">
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin></Label>
<Label fx:id="quranSource" text="Quran Source" />
</children>
<GridPane.margin>
<Insets bottom="40.0" />
</GridPane.margin>
<opaqueInsets>
<Insets />
</opaqueInsets>
</VBox>
</children>
</GridPane>
</center>
Expand Down

0 comments on commit 8457704

Please sign in to comment.