Add about feature
This commit is contained in:
parent
bfc867b8fd
commit
bcbf6b5153
@ -58,6 +58,7 @@ public class Main extends Application {
|
|||||||
MainController mainController = fxmlLoader.getController();
|
MainController mainController = fxmlLoader.getController();
|
||||||
mainController.getEventBus().post(new LanguageChangedEvent("Java"));
|
mainController.getEventBus().post(new LanguageChangedEvent("Java"));
|
||||||
mainController.getEventBus().post(new FileSaveStateChangedEvent(true));
|
mainController.getEventBus().post(new FileSaveStateChangedEvent(true));
|
||||||
|
mainController.setHostServices(getHostServices());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +76,8 @@ public class Main extends Application {
|
|||||||
|
|
||||||
window.setScene(scene);
|
window.setScene(scene);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
|
getHostServices().showDocument("https://google.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,9 @@ import com.google.common.eventbus.Subscribe;
|
|||||||
import app.controllers.*;
|
import app.controllers.*;
|
||||||
import app.events.ExitApplicationEvent;
|
import app.events.ExitApplicationEvent;
|
||||||
import app.events.LanguageChangedEvent;
|
import app.events.LanguageChangedEvent;
|
||||||
|
import app.events.OpenLinkInBrowserEvent;
|
||||||
import app.model.Model;
|
import app.model.Model;
|
||||||
|
import javafx.application.HostServices;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@ -30,6 +32,7 @@ public class MainController implements Initializable {
|
|||||||
private MenubarController menubarController;
|
private MenubarController menubarController;
|
||||||
|
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
private HostServices hostServices;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
@ -53,6 +56,15 @@ public class MainController implements Initializable {
|
|||||||
return this.eventBus;
|
return this.eventBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public HostServices getHostServices() {
|
||||||
|
return hostServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostServices(HostServices hostServices) {
|
||||||
|
this.hostServices = hostServices;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the CSS according to which language is being used.
|
* Change the CSS according to which language is being used.
|
||||||
* @param event
|
* @param event
|
||||||
@ -73,6 +85,12 @@ public class MainController implements Initializable {
|
|||||||
Model.getScene().getStylesheets().add(nextStyleSheet);
|
Model.getScene().getStylesheets().add(nextStyleSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
private void handle(OpenLinkInBrowserEvent event) {
|
||||||
|
this.getHostServices().showDocument(event.getLink());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an exit request for the whole program.
|
* Handle an exit request for the whole program.
|
||||||
* @param event
|
* @param event
|
||||||
|
@ -9,6 +9,7 @@ import com.google.common.eventbus.Subscribe;
|
|||||||
|
|
||||||
import app.events.ExitApplicationEvent;
|
import app.events.ExitApplicationEvent;
|
||||||
import app.events.LanguageChangedEvent;
|
import app.events.LanguageChangedEvent;
|
||||||
|
import app.events.OpenLinkInBrowserEvent;
|
||||||
import app.events.ToggleCommentEvent;
|
import app.events.ToggleCommentEvent;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@ -120,6 +121,11 @@ public class MenubarController implements Initializable, Controller {
|
|||||||
/* ABOUT */
|
/* ABOUT */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void handleAbout(ActionEvent event) {
|
||||||
|
String aboutLink = "https://gitlab.stud.idi.ntnu.no/oysteikt/tdt4100-project-2021v/-/blob/master/README.md";
|
||||||
|
this.eventBus.post(new OpenLinkInBrowserEvent(aboutLink));
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* SUBSCRIPTIONS */
|
/* SUBSCRIPTIONS */
|
||||||
|
15
src/main/java/app/events/OpenLinkInBrowserEvent.java
Normal file
15
src/main/java/app/events/OpenLinkInBrowserEvent.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package app.events;
|
||||||
|
|
||||||
|
public class OpenLinkInBrowserEvent extends Event {
|
||||||
|
|
||||||
|
private String link;
|
||||||
|
|
||||||
|
public OpenLinkInBrowserEvent(String link) {
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -67,7 +67,7 @@
|
|||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="Tips and tricks" accelerator="f1"/>
|
<MenuItem mnemonicParsing="false" text="Tips and tricks" accelerator="f1"/>
|
||||||
<MenuItem mnemonicParsing="false" text="Keyboard Shortcut list" accelerator="f2"/>
|
<MenuItem mnemonicParsing="false" text="Keyboard Shortcut list" accelerator="f2"/>
|
||||||
<MenuItem mnemonicParsing="false" text="About" accelerator="f3"/>
|
<MenuItem mnemonicParsing="false" text="About" accelerator="f3" onAction="#handleAbout"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
|
Loading…
Reference in New Issue
Block a user