suggs: condense file sizes to MB, better selection handling

This commit is contained in:
Downforce Agent 2024-07-21 12:30:39 -05:00
parent 851223fa9f
commit 13f82e3866
2 changed files with 39 additions and 12 deletions

View File

@ -125,7 +125,9 @@
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
<properties>
<disabledTextColor color="-10124141"/>
</properties>
</component>
<component id="f7802" class="javax.swing.JLabel">
<constraints>
@ -143,7 +145,9 @@
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
<properties>
<disabledTextColor color="-10124141"/>
</properties>
</component>
<grid id="27515" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
@ -337,7 +341,7 @@
<text value="no track"/>
</properties>
</component>
<component id="c11e8" class="javax.swing.JLabel" binding="dSSize">
<component id="c11e8" class="javax.swing.JLabel" binding="dSSize">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
@ -347,7 +351,7 @@
<text value="no size"/>
</properties>
</component>
<component id="8480f" class="javax.swing.JLabel" binding="dMSize">
<component id="8480f" class="javax.swing.JLabel" binding="dMSize">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>

View File

@ -126,6 +126,13 @@ public class Suggs implements ActionListener, ListSelectionListener {
}
});
fTitle.setText("");
fArtist.setText("");
dTrackNo.setText("\u200E");
dFileSize.setText("\u200E");
fTitle.setEnabled(false);
fArtist.setEnabled(false);
frame.setVisible(true);
}
@ -184,16 +191,26 @@ public class Suggs implements ActionListener, ListSelectionListener {
public void valueChanged(ListSelectionEvent listSelectionEvent) {
curIndex = dSongList.getSelectedIndex();
if (curIndex >= 0) {
fTitle.setEnabled(true);
fArtist.setEnabled(true);
AudioTrack at = tracklist.get(curIndex);
fTitle.setText(at.title);
fArtist.setText(at.artist);
dTrackNo.setText(String.format("MT_%02d", curIndex+1));
dFileSize.setText((at.size / 1000) + "kb");
dFileSize.setText(at.size + " B");
if (at.size > 1023) {
dFileSize.setText((at.size / 1024) + " KB");
}
if (at.size > 1048575) {
dFileSize.setText((at.size / 1048576) + " MB");
}
} else {
fTitle.setEnabled(false);
fArtist.setEnabled(false);
fTitle.setText("");
fArtist.setText("");
dTrackNo.setText("--");
dFileSize.setText("-kb");
dTrackNo.setText("\u200E");
dFileSize.setText("\u200E");
}
}
@ -247,11 +264,17 @@ public class Suggs implements ActionListener, ListSelectionListener {
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("ATRAC9", "at9"));
int result = fileChooser.showOpenDialog(frame);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
sptrack = selectedFile;
dSTitle.setText(selectedFile.getName());
dSSize.setText((selectedFile.length() / 1000) + "kb");
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
sptrack = selectedFile;
dSTitle.setText(selectedFile.getName());
dSSize.setText(selectedFile.length() + " B");
if (selectedFile.length() > 1023) {
dSSize.setText((selectedFile.length() / 1024) + " KB");
}
if (selectedFile.length() > 1048575) {
dSSize.setText((selectedFile.length() / 1048576) + " MB");
}
}
}