Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darkmode_maybe #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ dependencies {
implementation 'com.github.wendykierp:JTransforms:3.1'
implementation 'com.google.code.gson:gson:2.10'
implementation 'com.google.guava:guava:33.3.0-jre'
implementation 'com.jidesoft:jide-oss:3.6.18'
implementation 'com.miglayout:miglayout-swing:11.0'
implementation 'com.mpatric:mp3agic:0.9.1'
implementation 'commons-io:commons-io:2.11.0'
Expand All @@ -121,6 +120,12 @@ dependencies {
implementation 'org.usb4java:usb4java:1.3.0'
implementation 'org.usb4java:usb4java-javax:1.3.0'
implementation 'pl.edu.icm:JLargeArrays:1.6'
implementation("com.formdev:flatlaf:3.5.4")
implementation 'com.jidesoft:jide-oss:3.6.8' //updated for 3.6.18 for linux dependency
implementation 'com.jidesoft:jidefx-common:0.9.1' //added for common jidefx
implementation 'com.formdev:jide-oss:3.7.12'
implementation 'com.jfoenix:jfoenix:9.0.10'

}

def os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem
Expand Down Expand Up @@ -163,7 +168,17 @@ application {
applicationDefaultJvmArgs = jvmArgsLinux
}
}

processResources{
from("src/main/resouces"){
include"**/*.css"
include"**/*.png"
include"**/*.xml"
include"**/*.rules"
include"**/*.properties"
include"images/*.*"
include "css/*.css"
}
}
test {
if(os.isWindows()) {
jvmArgs = jvmArgsWindows
Expand Down Expand Up @@ -207,7 +222,7 @@ String targetWindowsAarch64 = 'windows-aarch64-v' + version
* Optional pre-downloaded Java Development Kit (JDK) for each target OS and CPU. These locations are hard-coded to the
* author's development environment, but can be changed to your environment if you want to use this build pattern.
*/
String jdk_base = '/home/denny/java_jdks/'
String jdk_base = '/home/denny/java_jdks/' // edited out for personal reasons
String jdk_linux_aarch64 = jdk_base + 'linux-arm64/jdk-22.0.2-full'
String jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-22.0.2-full'
String jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-22.0.2-full.jdk'
Expand Down
101 changes: 92 additions & 9 deletions src/main/java/io/github/dsheirer/gui/SDRTrunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package io.github.dsheirer.gui;

import com.formdev.flatlaf.FlatDarkLaf;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.JideSplitPane;
import io.github.dsheirer.alias.AliasModel;
Expand All @@ -38,6 +39,7 @@
import io.github.dsheirer.gui.preference.PreferenceEditorType;
import io.github.dsheirer.gui.preference.ViewUserPreferenceEditorRequest;
import io.github.dsheirer.gui.preference.calibration.CalibrationDialog;
import io.github.dsheirer.gui.theme.DarkMetalTheme;
import io.github.dsheirer.gui.viewer.ViewRecordingViewerRequest;
import io.github.dsheirer.icon.IconModel;
import io.github.dsheirer.log.ApplicationLog;
Expand Down Expand Up @@ -94,18 +96,12 @@
import org.slf4j.LoggerFactory;

import javax.imageio.ImageIO;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JSeparator;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;

public class SDRTrunk implements Listener<TunerEvent>
{
Expand Down Expand Up @@ -147,6 +143,7 @@ public SDRTrunk()
{
if(!GraphicsEnvironment.isHeadless())
{
//ERC Create JFrame under JavaFX
mMainGui = new JFrame();
}

Expand All @@ -169,14 +166,36 @@ public SDRTrunk()
{
try
{
//UIManager.setLookAndFeel(FlatDarkLaf.class.getName());
mLog.info("Operating system determined as " + operatingSystem);
mLog.info("UIManager is " + UIManager.getLookAndFeel().getClass().getName());
mLog.info("Look and Feel Factory checking result is Installed?" + LookAndFeelFactory.isJideExtensionInstalled());
mLog.info("Classloader for LookandFeelFacotry is " + LookAndFeelFactory.class.getClassLoader());
Class<?> cls = Class.forName("com.jidesoft.plaf.LookAndFeelFactory");
mLog.info("Running Code Class<?> cls = Class.forName(\"com.jidesoft.plaf.LookAndFeelFactory\")) = " + cls.getName());

MetalLookAndFeel.setCurrentTheme(new DarkMetalTheme());
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());

LookAndFeelFactory.installJideExtension();
mLog.info("Passed Installing Look and Feel JideExtension");
}
catch(Exception e)
{
mLog.error("Error trying to set Metal look and feel for OS [" + operatingSystem + "]");
}
}
if(operatingSystem.contains("windows")){
try{
MetalLookAndFeel.setCurrentTheme(new DarkMetalTheme());
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
}
catch(UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException |
IllegalAccessException e)
{
e.printStackTrace();
}
}

ThreadPool.logSettings();

Expand Down Expand Up @@ -308,11 +327,13 @@ public SDRTrunk()
});
}


/**
* Shows a dialog that lists the channels that have been designated for auto-start, sorted by auto-start order and
* allows the user to start now, cancel, or allow the timer to expire and then start the channels. The dialog will
* only show if there are one ore more channels designated for auto-start.
*/

private void autoStartChannels()
{
List<Channel> channels = mPlaylistManager.getChannelModel().getAutoStartChannels();
Expand Down Expand Up @@ -627,8 +648,70 @@ private void initGUI()
});

menuBar.add(screenCaptureItem);

JMenuItem toggleGUI = new JMenuItem("DarkMode");
toggleGUI.addActionListener(toggleGuiModes ->{
if("DarkMode".equals(toggleGUI.getText())){
toggleGUI.setText("LightMode");
DarkmodeToggle("On");

}
else {
toggleGUI.setText("DarkMode");
DarkmodeToggle("Off");
}
SwingUtilities.updateComponentTreeUI(mMainGui);
}
);
menuBar.add(toggleGUI);
}


private static void DarkmodeToggle(String str) {
String operatingSystem = System.getProperty("os.name").toLowerCase();
mLog.error("Darkmode toggle activated");
if(operatingSystem.contains("mac") || operatingSystem.contains("nux"))
{
try
{
//UIManager.setLookAndFeel(FlatDarkLaf.class.getName());
if (str == "On") {
MetalLookAndFeel.setCurrentTheme(new DarkMetalTheme());
mLog.error("Setting Darkmode to " + str);
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
}
else{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
mLog.error("Setting DarkMode to " + str);
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
}
}
catch(Exception e)
{
mLog.error("Error trying to set Metal look and feel for OS [" + operatingSystem + "]");
}
}
if(operatingSystem.contains("windows")){
try
{
//UIManager.setLookAndFeel(FlatDarkLaf.class.getName());
if (str == "Off") {
MetalLookAndFeel.setCurrentTheme(new DarkMetalTheme ());
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
}
else{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
UIManager.setLookAndFeel(MetalLookAndFeel.class.getName());
}
}
catch(Exception e)
{
mLog.error("Error trying to set Metal look and feel for OS [" + operatingSystem + "]");
}
}
}


/**
* Performs shutdown operations
*/
Expand Down
Loading