Skip to content

Commit

Permalink
Merge pull request #6 from rememberber/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rememberber authored Jan 14, 2022
2 parents 1f69d83 + d6d46cb commit 8f9b4e8
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 40 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.luoboduner.moo.info</groupId>
<artifactId>MooInfo</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<packaging>jar</packaging>

<name>MooInfo</name>
Expand All @@ -26,11 +26,11 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<guava.version>31.0.1-jre</guava.version>
<okhttp.version>4.9.3</okhttp.version>
<flatlaf.version>2.0-rc1</flatlaf.version>
<flatlaf-extras.version>2.0-rc1</flatlaf-extras.version>
<flatlaf.version>2.0</flatlaf.version>
<flatlaf-extras.version>2.0</flatlaf-extras.version>
<hutool-all.version>5.7.16</hutool-all.version>
<fastjson.version>1.2.78</fastjson.version>
<oshi-core.version>5.8.6</oshi-core.version>
<oshi-core.version>6.0.0</oshi-core.version>
<jfreechart.version>1.5.3</jfreechart.version>
</properties>

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/luoboduner/moo/info/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.luoboduner.moo.info.ui.form.MainWindow;
import com.luoboduner.moo.info.ui.frame.MainFrame;
import com.luoboduner.moo.info.util.ConfigUtil;
import com.luoboduner.moo.info.util.UIUtil;
import com.luoboduner.moo.info.util.UpgradeUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
Expand Down Expand Up @@ -39,7 +40,9 @@ public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("apple.awt.application.name", "MooInfo");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MooInfo");
System.setProperty("apple.awt.application.appearance", "system");
if (UIUtil.isDarkLaf()) {
System.setProperty("apple.awt.application.appearance", "system");
}

FlatDesktop.setAboutHandler(() -> {
try {
Expand Down Expand Up @@ -90,7 +93,6 @@ public static void main(String[] args) {
MainWindow.getInstance().init();
Init.initAllTab();
Init.initOthers();
mainFrame.addListeners();
mainFrame.remove(loadingPanel);
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/luoboduner/moo/info/ui/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cn.hutool.log.LogFactory;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.IntelliJTheme;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.luoboduner.moo.info.App;
import com.luoboduner.moo.info.ui.component.TopMenuBar;
import com.luoboduner.moo.info.ui.form.*;
Expand Down Expand Up @@ -190,6 +191,12 @@ If you have following code in your app, you can remove it (no longer necessary):
}
UIManager.setLookAndFeel("com.formdev.flatlaf.FlatDarculaLaf");
}
if (UIUtil.isDarkLaf()) {
// FlatSVGIcon.ColorFilter.getInstance().setMapper(color -> color.brighter().brighter());
} else {
FlatSVGIcon.ColorFilter.getInstance().setMapper(color -> color.darker().darker());
}
// SwingUtilities.windowForComponent(App.mainFrame).repaint();
} catch (Exception e) {
logger.error(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/luoboduner/moo/info/ui/UiConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class UiConsts {

public static final String APP_NAME = "MooInfo";
public static final String APP_VERSION = "1.1.0";
public static final String APP_VERSION = "1.1.1";

public static final int TABLE_ROW_HEIGHT = 36;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.dialog.AboutDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="20" left="20" bottom="20" right="20"/>
<constraints>
<xy x="48" y="54" width="911" height="1381"/>
</constraints>
Expand All @@ -16,7 +16,7 @@
<border type="empty"/>
<children>
<grid id="3215c" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="40" left="40" bottom="40" right="0"/>
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
<border type="empty"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class AboutDialog extends JDialog {
public AboutDialog() {

super(App.mainFrame, "About");
ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64);
ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.5, 0.64);
setContentPane(contentPane);
setModal(true);

Expand Down Expand Up @@ -354,12 +354,12 @@ private void onOK() {
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(20, 20, 20, 20), -1, -1));
scrollPane = new JScrollPane();
contentPane.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(9, 2, new Insets(40, 40, 40, 0), -1, -1));
panel1.setLayout(new GridLayoutManager(9, 2, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(panel1);
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
logoLabel = new JLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SystemInfoTestDialog extends JDialog {

public SystemInfoTestDialog() {
super(App.mainFrame, "System Info Test");
ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.6, 0.64);
ComponentUtil.setPreferSizeAndLocateToCenter(this, App.mainFrame.getWidth(), App.mainFrame.getHeight());
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/luoboduner/moo/info/ui/form/DetailForm.form
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.form.DetailForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="500" height="1011"/>
</constraints>
Expand All @@ -16,7 +16,7 @@
<border type="empty"/>
<children>
<grid id="1b97f" layout-manager="GridLayoutManager" row-count="12" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
<border type="none"/>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/luoboduner/moo/info/ui/form/DetailForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ private static String getNetworkInfo() {
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
scrollPane = new JScrollPane();
mainPanel.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(12, 1, new Insets(10, 10, 10, 10), -1, -1));
panel1.setLayout(new GridLayoutManager(12, 1, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(panel1);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/luoboduner/moo/info/ui/form/DiskForm.form
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.form.DiskForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
Expand All @@ -24,7 +24,7 @@
<border type="empty"/>
<children>
<grid id="959a9" binding="diskListPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="10" bottom="0" right="10"/>
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
<border type="none"/>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/luoboduner/moo/info/ui/form/DiskForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ private static void initInfo() {
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
scrollPane = new JScrollPane();
panel1.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
diskListPanel = new JPanel();
diskListPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1));
diskListPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(diskListPanel);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.form.OverviewForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="500" height="635"/>
</constraints>
Expand All @@ -16,7 +16,7 @@
<border type="empty"/>
<children>
<grid id="e4c5c" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
<border type="none"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,12 @@ private static String getFirmware(HardwareAbstractionLayer hardware) {
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
scrollPane = new JScrollPane();
mainPanel.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1));
panel1.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(panel1);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.form.PowerSourceForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
Expand All @@ -16,7 +16,7 @@
<border type="empty"/>
<children>
<grid id="baebb" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<margin top="0" left="0" bottom="0" right="0"/>
<constraints/>
<properties/>
<border type="none"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ private static void initInfo() {
powerNameBuilder.append(powerSource.getName());
powerNameBuilder.append(" ").append(powerSource.getManufacturer());
powerNameBuilder.append(" ").append(powerSource.getDeviceName());
powerNameBuilder.append(" ").append(powerSource.getChemistry());
if (!"unknown".equals(powerSource.getChemistry())) {
powerNameBuilder.append(" ").append(powerSource.getChemistry());
}
powerNameLabel.setText(powerNameBuilder.toString());
powerPanel.add(powerNameLabel, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));

Expand All @@ -100,7 +102,8 @@ private static void initInfo() {
capacityBuilder.append("Current ").append(powerSource.getCurrentCapacity());
capacityBuilder.append(" / ").append("Max ").append(powerSource.getMaxCapacity());
capacityBuilder.append(" / ").append("Design ").append(powerSource.getDesignCapacity());
capacityBuilder.append(" (").append(powerSource.getCapacityUnits()).append(")");
capacityBuilder.append(" (").append(powerSource.getCapacityUnits()).append(") ");
capacityBuilder.append((powerSource.getDesignCapacity() - powerSource.getMaxCapacity()) * 100 / powerSource.getDesignCapacity()).append("% wastage");
capacityLabel.setText(capacityBuilder.toString());
powerPanel.add(capacityLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));

Expand Down Expand Up @@ -205,12 +208,12 @@ private static String formatTimeRemaining(double timeInSeconds) {
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
scrollPane = new JScrollPane();
mainPanel.add(scrollPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
panel1.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
scrollPane.setViewportView(panel1);
powerBasePanel = new JPanel();
powerBasePanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/luoboduner/moo/info/ui/frame/MainFrame.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.luoboduner.moo.info.ui.frame;

import cn.hutool.core.thread.ThreadUtil;
import com.formdev.flatlaf.extras.FlatSVGUtils;
import com.luoboduner.moo.info.ui.UiConsts;
import com.luoboduner.moo.info.ui.component.TopMenuBar;
Expand All @@ -26,12 +25,8 @@ public void init() {
topMenuBar.init();
setJMenuBar(topMenuBar);
ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.6, 0.8);
}

/**
* add event listeners
*/
public void addListeners() {
ThreadUtil.execute(FrameListener::addListeners);
FrameListener.addListeners();
}

}
1 change: 1 addition & 0 deletions src/main/java/com/luoboduner/moo/info/util/UIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static boolean isDarkLaf() {
|| "Darcula(Recommended)".equals(App.config.getTheme())
|| "Flat Dark".equals(App.config.getTheme())
|| "Flat Darcula".equals(App.config.getTheme())
|| "Dark purple".equals(App.config.getTheme())
|| "Flat Darcula(Recommended)".equals(App.config.getTheme());
}
}
10 changes: 8 additions & 2 deletions src/main/resources/version_summary.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"currentVersion": "1.1.0",
"currentVersion": "1.1.1",
"versionIndex": {
"0.0.0": "0",
"1.0.0": "1",
"1.1.0": "2"
"1.1.0": "2",
"1.1.1": "3"
},
"versionDetailList": [
{
Expand All @@ -20,6 +21,11 @@
"version": "1.1.0",
"title": "Some minor features and optimizations",
"log": "● update oshi-core to 5.8.6\n● update flatlaf to 2.0-rc1(Support Windows 11 snap layouts menu, macOS screen menu optimization)\n● processes sort method added same as the oshi's demo\n● add cpu usage chart\n● make System Boot Time and Uptime readable\n● add System Info Test function menu same as oshi-core\n"
},
{
"version": "1.1.1",
"title": "update flatlaf to 2.0",
"log": "● update flatlaf to 2.0\n● update oshi-core to 6.0.0\n● add battery wastage indicator\n● optimization of light theme\n"
}
]
}

0 comments on commit 8f9b4e8

Please sign in to comment.