Skip to content

Commit

Permalink
ui scaling settings
Browse files Browse the repository at this point in the history
  • Loading branch information
subhra74 committed Apr 19, 2020
1 parent aa42c3c commit 258076e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
1 change: 0 additions & 1 deletion muon-app/src/main/java/muon/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class App {
private static Map<String, List<String>> pinnedLogs = new HashMap<>();

public static void main(String[] args) throws UnsupportedLookAndFeelException {

Security.setProperty("networkaddress.cache.ttl", "0");
Security.setProperty("networkaddress.cache.negative.ttl", "0");

Expand Down
6 changes: 3 additions & 3 deletions muon-app/src/main/java/muon/app/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Settings {
// 2 Open with internal editor
, numberOfSimultaneousConnection = 3;

private float uiScaling = 1.0f;
private double uiScaling = 1.0;
private boolean manualScaling = false;

private List<EditorEntry> editors = new ArrayList<>();
Expand Down Expand Up @@ -549,11 +549,11 @@ public void setEditors(List<EditorEntry> editors) {
this.editors = editors;
}

public float getUiScaling() {
public double getUiScaling() {
return uiScaling;
}

public void setUiScaling(float uiScaling) {
public void setUiScaling(double uiScaling) {
this.uiScaling = uiScaling;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public class SettingsDialog extends JDialog {
private JPanel cardPanel;
private JList<String> navList;

private JCheckBox chkUseManualScaling;
private JSpinner spScaleValue;

/**
*
*/
Expand Down Expand Up @@ -119,7 +122,7 @@ public SettingsDialog(JFrame window) {
panelMap.put(SettingsPageName.General.toString(), createGeneralPanel());
panelMap.put(SettingsPageName.Terminal.toString(), createTerminalPanel());
panelMap.put(SettingsPageName.Editor.toString(), createEditorPanel());
panelMap.put(SettingsPageName.Misc.toString(), new JPanel());
panelMap.put(SettingsPageName.Misc.toString(), createMiscPanel());

for (String key : panelMap.keySet()) {
navModel.addElement(key);
Expand Down Expand Up @@ -161,8 +164,8 @@ public SettingsDialog(JFrame window) {

private void resizeNumericSpinner(JSpinner spinner) {
SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel();
int val = (Integer) model.getValue();
int max = (Integer) model.getMaximum();
Number val = (Number) model.getValue();
Number max = (Number) model.getMaximum();
spinner.getModel().setValue(max);
Dimension d = spinner.getPreferredSize();
spinner.getModel().setValue(val);
Expand Down Expand Up @@ -387,7 +390,6 @@ public JPanel createGeneralPanel() {
chkPromptForSudo = new JCheckBox("Prompt for sudo if operation fails due to permission issues");
chkDirectoryCache = new JCheckBox("Use directory caching");
chkShowPathBar = new JCheckBox("Show current folder in path bar style");
chkUseGlobalDarkTheme = new JCheckBox("Use global dark theme (Needs restart)");
chkShowMessagePrompt = new JCheckBox("Show banner");

chkLogWrap = new JCheckBox("Word wrap on log viewer");
Expand Down Expand Up @@ -421,7 +423,6 @@ public JPanel createGeneralPanel() {
chkPromptForSudo.setAlignmentX(Box.LEFT_ALIGNMENT);
chkDirectoryCache.setAlignmentX(Box.LEFT_ALIGNMENT);
chkShowPathBar.setAlignmentX(Box.LEFT_ALIGNMENT);
chkUseGlobalDarkTheme.setAlignmentX(Box.LEFT_ALIGNMENT);
chkShowMessagePrompt.setAlignmentX(Box.LEFT_ALIGNMENT);

chkLogWrap.setAlignmentX(Box.LEFT_ALIGNMENT);
Expand Down Expand Up @@ -456,8 +457,6 @@ public JPanel createGeneralPanel() {
vbox.add(chkShowPathBar);
vbox.add(Box.createRigidArea(new Dimension(10, 10)));
vbox.add(chkShowMessagePrompt);
vbox.add(Box.createRigidArea(new Dimension(10, 10)));
vbox.add(chkUseGlobalDarkTheme);
vbox.add(Box.createRigidArea(new Dimension(10, 20)));

JLabel lbl1 = new JLabel("Log viewer lines per page"), lbl2 = new JLabel("Log viewer font size"),
Expand All @@ -484,7 +483,7 @@ public JPanel createGeneralPanel() {
vbox.add(Box.createRigidArea(new Dimension(10, 10)));

vbox.setBorder(new EmptyBorder(30, 10, 10, 10));
add(vbox);
// add(vbox);

panel.add(vbox);

Expand Down Expand Up @@ -576,6 +575,9 @@ private void applySettings() {

settings.setEditors(editorModel.getEntries());

settings.setManualScaling(chkUseManualScaling.isSelected());
settings.setUiScaling((double) spScaleValue.getValue());

App.saveSettings();
super.setVisible(false);
}
Expand Down Expand Up @@ -673,6 +675,9 @@ public boolean showDialog(JFrame window, SettingsPageName page) {
navList.setSelectedIndex(page.index);
}

this.chkUseManualScaling.setSelected(settings.isManualScaling());
this.spScaleValue.setValue(settings.getUiScaling());

super.setVisible(true);
return false;
}
Expand All @@ -690,7 +695,7 @@ private String[] getTerminalFonts() {

public JPanel createEditorPanel() {
JPanel panel = new JPanel(new BorderLayout(10, 10));
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
panel.setBorder(new EmptyBorder(30, 10, 10, 10));

editorTable = new JTable(editorModel);
panel.add(new SkinnedScrollPane(editorTable));
Expand Down Expand Up @@ -724,6 +729,31 @@ public JPanel createEditorPanel() {
return panel;
}

private Component createMiscPanel() {
JPanel panel = new JPanel(new BorderLayout());

chkUseManualScaling = new JCheckBox("Zoom application view (Needs restart)");
spScaleValue = new JSpinner(new SpinnerNumberModel(1.0, 0.5, 100.0, 0.01));
resizeNumericSpinner(spScaleValue);

chkUseGlobalDarkTheme = new JCheckBox("Use global dark theme (Needs restart)");
chkUseGlobalDarkTheme.setAlignmentX(Box.LEFT_ALIGNMENT);

Box vbox = Box.createVerticalBox();
chkUseManualScaling.setAlignmentX(Box.LEFT_ALIGNMENT);
vbox.add(chkUseManualScaling);
vbox.add(Box.createRigidArea(new Dimension(10, 10)));
vbox.add(createRow(new JLabel("Zoom percentage"), Box.createHorizontalGlue(), spScaleValue));
vbox.add(Box.createRigidArea(new Dimension(10, 10)));
vbox.add(chkUseGlobalDarkTheme);
vbox.setBorder(new EmptyBorder(30, 10, 10, 10));
// add(vbox);

panel.add(vbox);

return panel;
}

// private void resizeTextField(JTextField txt) {
// txt.setText("WW");
// Dimension d = txt.getPreferredSize();
Expand Down

0 comments on commit 258076e

Please sign in to comment.