mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
Merge pull request #380 from Gaubiche/master
Remember window position on screen
This commit is contained in:
commit
8aa1ca3dd9
@ -26,6 +26,8 @@ public class GUIConfig {
|
||||
public boolean askScanConfirmation;
|
||||
|
||||
public int[] mainWindowSize;
|
||||
|
||||
public int[] mainWindowPosition;
|
||||
public boolean isMainWindowMaximized;
|
||||
|
||||
public int[] detailsWindowSize;
|
||||
@ -49,6 +51,7 @@ public class GUIConfig {
|
||||
|
||||
isMainWindowMaximized = preferences.getBoolean("windowMaximized", false);
|
||||
mainWindowSize = new int[] {preferences.getInt("windowWidth", 800), preferences.getInt("windowHeight", 450)};
|
||||
mainWindowPosition = new int[]{preferences.getInt("windowPosition-x",50), preferences.getInt("windowPosition-y",85)};
|
||||
detailsWindowSize = new int[] {preferences.getInt("detailsWidth", 400), preferences.getInt("detailsHeight", 300)};
|
||||
}
|
||||
|
||||
@ -66,6 +69,9 @@ public class GUIConfig {
|
||||
if (!isMainWindowMaximized) {
|
||||
preferences.putInt("windowWidth", mainWindowSize[0]);
|
||||
preferences.putInt("windowHeight", mainWindowSize[1]);
|
||||
|
||||
preferences.putInt("windowPosition-x",mainWindowPosition[0]);
|
||||
preferences.putInt("windowPosition-y",mainWindowPosition[1]);
|
||||
}
|
||||
|
||||
preferences.putInt("detailsWidth", detailsWindowSize[0]);
|
||||
@ -91,6 +97,17 @@ public class GUIConfig {
|
||||
isMainWindowMaximized = isMaximized;
|
||||
}
|
||||
|
||||
public Point getMainWindowPosition(){
|
||||
return new Point(mainWindowPosition[0], mainWindowPosition[1]);
|
||||
}
|
||||
|
||||
public void setMainWindowPosition(Point position, boolean isMaximized){
|
||||
if (!isMaximized) {
|
||||
mainWindowPosition = new int[] {position.x, position.y};
|
||||
}
|
||||
isMainWindowMaximized = isMaximized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return column width corresponding to a fetcher
|
||||
*/
|
||||
|
||||
@ -76,6 +76,10 @@ public class MainWindow {
|
||||
|
||||
// after all controls are initialized, resize and open
|
||||
shell.setSize(guiConfig.getMainWindowSize());
|
||||
|
||||
// remember stored position in the screen by preferences
|
||||
shell.setLocation(guiConfig.getMainWindowPosition());
|
||||
|
||||
shell.open();
|
||||
if (guiConfig.isMainWindowMaximized) {
|
||||
shell.setMaximized(true);
|
||||
@ -99,8 +103,9 @@ public class MainWindow {
|
||||
shell.setImage(image);
|
||||
|
||||
shell.addListener(SWT.Close, event -> {
|
||||
// save dimensions!
|
||||
// save dimensions! and position!
|
||||
guiConfig.setMainWindowSize(shell.getSize(), shell.getMaximized());
|
||||
guiConfig.setMainWindowPosition(shell.getLocation(), shell.getMaximized());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user