feature: light/dark mode theme support (#208)
* feature: light/dark mode theme support New feature providing a more modern flat design with support for light and dark modes, including: - New SheepIt logo (old one removed) - New configuration option (-theme) that changes the existing client theme. - Minimal UI cosmetic changes (some separation lines under the logo and above the buttons)
This commit is contained in:
@@ -25,7 +25,6 @@ import java.awt.Image;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -57,6 +56,10 @@ import com.sheepit.client.standalone.swing.activity.Working;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import com.formdev.flatlaf.FlatLightLaf; // Required for dark & light mode
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
|
||||
public class GuiSwing extends JFrame implements Gui {
|
||||
public static final String type = "swing";
|
||||
|
||||
@@ -104,13 +107,6 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (useSysTray) {
|
||||
try {
|
||||
sysTray = SystemTray.getSystemTray();
|
||||
@@ -158,6 +154,20 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
|
||||
this.showActivity(ActivityType.SETTINGS);
|
||||
|
||||
try {
|
||||
if (client.getConfiguration().getTheme().equals("light")) {
|
||||
UIManager.setLookAndFeel(new FlatLightLaf());
|
||||
} else if (client.getConfiguration().getTheme().equals("dark")) {
|
||||
UIManager.setLookAndFeel(new FlatDarkLaf());
|
||||
}
|
||||
|
||||
// Apply the selected theme to swing components
|
||||
FlatLaf.updateUI();
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
while (waitingForAuthentication) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
|
||||
Reference in New Issue
Block a user