mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
#804 Tracks main application gui maximized state on shutdown and restores to maximized on restart. (#811)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -281,6 +281,11 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
}
|
||||
|
||||
mMainGui.setSize(dimension);
|
||||
|
||||
if(mUserPreferences.getSwingPreference().getMaximized(WINDOW_FRAME_IDENTIFIER, false))
|
||||
{
|
||||
mMainGui.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -414,6 +419,8 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
mLog.info("Application shutdown started ...");
|
||||
mUserPreferences.getSwingPreference().setLocation(WINDOW_FRAME_IDENTIFIER, mMainGui.getLocation());
|
||||
mUserPreferences.getSwingPreference().setDimension(WINDOW_FRAME_IDENTIFIER, mMainGui.getSize());
|
||||
mUserPreferences.getSwingPreference().setMaximized(WINDOW_FRAME_IDENTIFIER,
|
||||
(mMainGui.getExtendedState() & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH);
|
||||
mUserPreferences.getSwingPreference().setDimension(SPECTRAL_PANEL_IDENTIFIER, mSpectralPanel.getSize());
|
||||
mUserPreferences.getSwingPreference().setDimension(CONTROLLER_PANEL_IDENTIFIER, mControllerPanel.getSize());
|
||||
mJavaFxWindowManager.shutdown();
|
||||
|
||||
@@ -40,6 +40,7 @@ public class SwingPreference
|
||||
private static final String LOCATION_Y = ".y";
|
||||
private static final String SIZE_HEIGHT = ".height";
|
||||
private static final String SIZE_WIDTH = ".width";
|
||||
private static final String MAXIMIZED = ".maximized";
|
||||
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(SwingPreference.class);
|
||||
|
||||
@@ -80,11 +81,7 @@ public class SwingPreference
|
||||
if(x != Integer.MAX_VALUE && y != Integer.MAX_VALUE)
|
||||
{
|
||||
Point location = new Point(x,y);
|
||||
|
||||
if(isValidWindowLocation(location))
|
||||
{
|
||||
return location;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -101,6 +98,27 @@ public class SwingPreference
|
||||
mPreferences.putInt(key + LOCATION_Y, location.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the window maximized state for the window key
|
||||
* @param key identifying the window
|
||||
* @param maximized state
|
||||
*/
|
||||
public void setMaximized(String key, boolean maximized)
|
||||
{
|
||||
mPreferences.putBoolean(key + MAXIMIZED, maximized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the window maximized preference for the specified window key
|
||||
* @param key to identify the window
|
||||
* @param defaultMaximized to be the default value when no preference exists
|
||||
* @return maximized state
|
||||
*/
|
||||
public boolean getMaximized(String key, boolean defaultMaximized)
|
||||
{
|
||||
return mPreferences.getBoolean(key + MAXIMIZED, defaultMaximized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stored size/dimension of the window identified by the key argument.
|
||||
* @param key to identify the window
|
||||
|
||||
Reference in New Issue
Block a user