aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo@jitsi.org>2016-05-30 00:55:12 +0200
committerIngo Bauersachs <ingo@jitsi.org>2016-05-30 01:06:52 +0200
commitfb339a3e67af942c0f1a81e66a3573cadf59fef3 (patch)
treef6ded13dbbd0ef40e0bfcc57ce5ed7e0b0673d5a /src
parent5c24dad320f355f721fc4562fbed7ecf72b66d50 (diff)
downloadjitsi-fb339a3e67af942c0f1a81e66a3573cadf59fef3.zip
jitsi-fb339a3e67af942c0f1a81e66a3573cadf59fef3.tar.gz
jitsi-fb339a3e67af942c0f1a81e66a3573cadf59fef3.tar.bz2
Add option to minimize the main frame on closing instead of hiding
Defaults to true on Windows if the application is pinned to the taskbar. Determined by searching for a shortcut with the application's name in the pin-folder.
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/impl/gui/UIServiceImpl.java13
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/MainFrame.java4
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java36
-rw-r--r--src/net/java/sip/communicator/util/ConfigurationUtils.java64
-rw-r--r--src/net/java/sip/communicator/util/UtilActivator.java18
-rw-r--r--src/net/java/sip/communicator/util/util.manifest.mf1
6 files changed, 127 insertions, 9 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
index 838e86e..b7e1d9c 100644
--- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
@@ -199,8 +199,11 @@ public class UIServiceImpl
}
}
- if(ConfigurationUtils.isApplicationVisible())
+ if(ConfigurationUtils.isApplicationVisible()
+ || ConfigurationUtils.isMinimizeInsteadOfHide())
+ {
mainFrame.setFrameVisible(true);
+ }
SwingUtilities.invokeLater(new RunLoginGui());
@@ -440,9 +443,11 @@ public class UIServiceImpl
*/
public void setExitOnMainWindowClose(boolean exitOnMainWindowClose)
{
- mainFrame.setDefaultCloseOperation(
- exitOnMainWindowClose
- ? JFrame.DISPOSE_ON_CLOSE
+ mainFrame.setDefaultCloseOperation(
+ exitOnMainWindowClose
+ ? JFrame.DISPOSE_ON_CLOSE
+ : ConfigurationUtils.isMinimizeInsteadOfHide()
+ ? JFrame.DO_NOTHING_ON_CLOSE
: JFrame.HIDE_ON_CLOSE);
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
index fb7e01c..4762df8 100644
--- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
+++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
@@ -1943,6 +1943,10 @@ public class MainFrame
});
ConfigurationUtils.setApplicationVisible(false);
+ if (ConfigurationUtils.isMinimizeInsteadOfHide())
+ {
+ this.minimize();
+ }
}
}
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
index f5e482a..6319455 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
@@ -237,6 +237,30 @@ public class GeneralConfigurationPanel
}
/**
+ * Initializes the minimize instead of hide checkbox.
+ */
+ public Component createMinimzeInsteadOfHideCheckBox()
+ {
+ JCheckBox chk = new SIPCommCheckBox();
+
+ chk.setText(
+ Resources.getString("plugin.generalconfig.MINIMIZE_NOT_HIDE"));
+ chk.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ boolean value = ((JCheckBox) e.getSource()).isSelected();
+ ConfigurationUtils.setIsMinimizeInsteadOfHide(value);
+ UtilActivator.getUIService().setExitOnMainWindowClose(
+ !UtilActivator.getSystrayService().checkInitialized());
+ }
+ });
+
+ chk.setSelected(ConfigurationUtils.isMinimizeInsteadOfHide());
+ return chk;
+ }
+
+ /**
* Creates the message configuration panel.
* @return the created panel
*/
@@ -959,15 +983,17 @@ public class GeneralConfigurationPanel
*/
public Component createStartupConfigPanel()
{
- if (!OSUtils.IS_WINDOWS)
- return null;
-
JPanel updateConfigPanel = GeneralConfigPluginActivator.
createConfigSectionComponent(
Resources.getString("plugin.generalconfig.STARTUP_CONFIG"));
- updateConfigPanel.add(createAutoStartCheckBox());
- updateConfigPanel.add(createUpdateCheckBox());
+ updateConfigPanel.add(createMinimzeInsteadOfHideCheckBox());
+ if (OSUtils.IS_WINDOWS)
+ {
+ updateConfigPanel.add(createAutoStartCheckBox());
+ updateConfigPanel.add(createUpdateCheckBox());
+ }
+
return updateConfigPanel;
}
diff --git a/src/net/java/sip/communicator/util/ConfigurationUtils.java b/src/net/java/sip/communicator/util/ConfigurationUtils.java
index 05e4f09..db9fa3b 100644
--- a/src/net/java/sip/communicator/util/ConfigurationUtils.java
+++ b/src/net/java/sip/communicator/util/ConfigurationUtils.java
@@ -92,6 +92,11 @@ public class ConfigurationUtils
private static boolean isQuitWarningShown = true;
/**
+ * Indicates if the main frame should be minimized instead of hidden.
+ */
+ private static boolean minimizeInsteadOfHide = false;
+
+ /**
* Indicates if typing notifications should be sent.
*/
private static boolean isSendTypingNotifications;
@@ -479,6 +484,10 @@ public class ConfigurationUtils
= Boolean.parseBoolean(quitWarningShown);
}
+ minimizeInsteadOfHide = configService.getBoolean(
+ "net.java.sip.communicator.impl.gui.minimizeInsteadOfHide",
+ isPinnedToTaskBar());
+
// Load the "sendTypingNotifications" property.
String isSendTypingNotifProperty =
"service.gui.SEND_TYPING_NOTIFICATIONS_ENABLED";
@@ -964,6 +973,37 @@ public class ConfigurationUtils
);
}
+ private static boolean isPinnedToTaskBar()
+ {
+ if (!OSUtils.IS_WINDOWS)
+ {
+ return false;
+ }
+
+ File taskbar = new File(System.getenv("appdata"),
+ "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar");
+ File[] pins = taskbar.listFiles(new FileFilter()
+ {
+ @Override
+ public boolean accept(File f)
+ {
+ return f.getName().endsWith(".lnk");
+ }
+ });
+
+ String title = UtilActivator.getResources()
+ .getSettingsString("service.gui.APPLICATION_NAME");
+ for (File pin : pins)
+ {
+ if (pin.getName().contains(title))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Checks whether font support is disabled, checking in default
* settings for the default value.
@@ -1055,6 +1095,30 @@ public class ConfigurationUtils
}
/**
+ * Gets whether the application should be minimized and not hidden when
+ * clicking close on the main frame.
+ * @return <tt>true</tt> when the main frame should be minimized,
+ * <tt>false</tt> otherwise
+ */
+ public static boolean isMinimizeInsteadOfHide()
+ {
+ return minimizeInsteadOfHide;
+ }
+
+ /**
+ * Sets whether the application should be minimized and not hidden when
+ * clicking close on the main frame.
+ * @param value <tt>true</tt> when the main frame should be minimized,
+ * <tt>false</tt> otherwise
+ */
+ public static void setIsMinimizeInsteadOfHide(boolean value)
+ {
+ minimizeInsteadOfHide = value;
+ configService.setProperty(
+ "net.java.sip.communicator.impl.gui.minimizeInsteadOfHide", value);
+ }
+
+ /**
* Return TRUE if "quitWarningShown" property is true, otherwise -
* return FALSE. Indicates to the user interface whether the quit warning
* dialog should be shown when user clicks on the X button.
diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java
index c2ee299..6dff186 100644
--- a/src/net/java/sip/communicator/util/UtilActivator.java
+++ b/src/net/java/sip/communicator/util/UtilActivator.java
@@ -22,6 +22,7 @@ import java.util.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.service.systray.*;
import org.jitsi.service.configuration.*;
import org.jitsi.service.fileaccess.*;
@@ -65,6 +66,8 @@ public class UtilActivator
private static AlertUIService alertUIService;
+ private static SystrayService systrayService;
+
/**
* Calls <tt>Thread.setUncaughtExceptionHandler()</tt>
*
@@ -184,6 +187,21 @@ public class UtilActivator
}
/**
+ * Gets the <tt>SystrayService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>UtilActivator</tt>.
+ *
+ * @return the <tt>SystrayService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>UtilActivator</tt>
+ */
+ public static SystrayService getSystrayService()
+ {
+ if (systrayService == null)
+ systrayService =
+ ServiceUtils.getService(bundleContext, SystrayService.class);
+ return systrayService;
+ }
+
+ /**
* Returns the <tt>FileAccessService</tt> obtained from the bundle context.
*
* @return the <tt>FileAccessService</tt> obtained from the bundle context
diff --git a/src/net/java/sip/communicator/util/util.manifest.mf b/src/net/java/sip/communicator/util/util.manifest.mf
index a6e4db7..b50df6b 100644
--- a/src/net/java/sip/communicator/util/util.manifest.mf
+++ b/src/net/java/sip/communicator/util/util.manifest.mf
@@ -32,6 +32,7 @@ Import-Package: com.sun.awt,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.call,
net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.service.systray,
net.java.sip.communicator.service.keybindings,
net.java.sip.communicator.service.msghistory,
net.java.sip.communicator.service.contactlist,