2
0

Java Client: Separate user and application preferences

This commit is contained in:
Michael Ziminsky (Z) 2018-10-25 13:57:39 -07:00
parent 554c0129a2
commit 6f2dd84a31
4 changed files with 25 additions and 10 deletions

View File

@ -165,6 +165,10 @@ public abstract class Res {
return icon( "media/icon_key.png" );
}
public Icon prefs() {
return icon( "media/prefs.png" );
}
public Icon avatar(final int index) {
return icon( strf( "media/avatar-%d.png", index % avatars() ) );
}

View File

@ -55,6 +55,8 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
"Import a user from a backup file into Master Password." );
private final JButton helpButton = Components.button( Res.icons().help(), event -> showHelp(),
"Show information on how to use Master Password." );
private final JButton prefsButton = Components.button( Res.icons().prefs(), event -> showAppPreferences(),
"Show application preferences." );
private final JPanel userToolbar = Components.panel( BoxLayout.PAGE_AXIS );
private final JPanel siteToolbar = Components.panel( BoxLayout.PAGE_AXIS );
@ -248,6 +250,17 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
"About Master Password", JOptionPane.INFORMATION_MESSAGE );
}
private void showAppPreferences() {
Component checkForUpdates = Components.checkBox("Check For Updates", MPGuiConfig.get().checkForUpdates(), MPGuiConfig.get()::setCheckForUpdates);
Component stayResident = Components.checkBox(strf("<html>Stay Resident (reactivate with <strong><code>%s+%s</code></strong>)",
InputEvent.getModifiersExText(MPGuiConstants.ui_hotkey.getModifiers()),
KeyEvent.getKeyText(MPGuiConstants.ui_hotkey.getKeyCode())),
MPGuiConfig.get().stayResident(), MPGuiConfig.get()::setStayResident);
Components.showDialog(this, "Application Preferences", new JOptionPane(Components.panel(BoxLayout.PAGE_AXIS, checkForUpdates, stayResident)));
}
private enum ContentMode {
NO_USER,
AUTHENTICATE,
@ -274,6 +287,9 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
userToolbar.add( Box.createGlue() );
userToolbar.add( helpButton );
siteToolbar.add(Box.createGlue());
siteToolbar.add(prefsButton);
add( Box.createGlue() );
add( Components.heading( "Select a user to proceed." ) );
add( Box.createGlue() );
@ -312,6 +328,9 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
userToolbar.add( Box.createGlue() );
userToolbar.add( helpButton );
siteToolbar.add(Box.createGlue());
siteToolbar.add(prefsButton);
add( Components.heading( user.getFullName(), SwingConstants.CENTER ) );
add( Components.strut() );
@ -512,6 +531,8 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
siteToolbar.add( editButton );
siteToolbar.add( keyButton );
siteToolbar.add( deleteButton );
siteToolbar.add(Box.createGlue());
siteToolbar.add(prefsButton);
settingsButton.setEnabled( false );
questionsButton.setEnabled( false );
editButton.setEnabled( false );
@ -586,16 +607,6 @@ public class UserContentPanel extends JPanel implements MasterPassword.Listener,
components.add( Components.checkBox( "Hide Passwords",
user.getPreferences().isHidePasswords(), user.getPreferences()::setHidePasswords ) );
components.add( new JSeparator() );
components.add( Components.checkBox( "Check For Updates",
MPGuiConfig.get().checkForUpdates(), MPGuiConfig.get()::setCheckForUpdates ) );
components.add( Components.checkBox( strf( "<html>Stay Resident (reactivate with <strong><code>%s+%s</code></strong>)",
InputEvent.getModifiersExText( MPGuiConstants.ui_hotkey.getModifiers() ),
KeyEvent.getKeyText( MPGuiConstants.ui_hotkey.getKeyCode() ) ),
MPGuiConfig.get().stayResident(), MPGuiConfig.get()::setStayResident ) );
Components.showDialog( this, user.getFullName(), new JOptionPane( Components.panel(
BoxLayout.PAGE_AXIS, components.build().toArray( new Component[0] ) ) ) );
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB