Browse Source

Changed Timeout setting in OSD plugin to be an OptionalInteger which allows for OSD windows to stay open indefinitely

Fixes issue 4292

Change-Id: I23638f76f81f8aa6cd260cc07268a16eaaf9a564
Reviewed-on: http://gerrit.dmdirc.com/1508
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
Automatic-Compile: Gregory Holmes <greg@dmdirc.com>
tags/0.6.5
Simon Mott 13 years ago
parent
commit
ea460fbf9c

+ 9
- 0
src/com/dmdirc/addons/osd/OsdManager.java View File

@@ -176,4 +176,13 @@ public class OsdManager {
176 176
     public int getWindowCount() {
177 177
         return windowList.size();
178 178
     }
179
+
180
+    /**
181
+     * Return the current plugin.
182
+     *
183
+     * @return Returns current plugin instance.
184
+     */
185
+    public OsdPlugin getPlugin() {
186
+        return plugin;
187
+    }
179 188
 }

+ 2
- 2
src/com/dmdirc/addons/osd/OsdPlugin.java View File

@@ -110,8 +110,8 @@ public final class OsdPlugin extends Plugin implements CategoryChangeListener,
110 110
         widthSetting = new PreferencesSetting(PreferencesType.INTEGER,
111 111
                 getDomain(), "width", "OSD Width", "Width of the OSD Window").
112 112
                 registerChangeListener(this);
113
-        timeoutSetting = new PreferencesSetting(PreferencesType.INTEGER,
114
-                new NumericalValidator(1, Integer.MAX_VALUE),
113
+        timeoutSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,
114
+                new OptionalValidator(new NumericalValidator(1, Integer.MAX_VALUE)),
115 115
                 getDomain(), "timeout", "Timeout", "Length of time in " +
116 116
                 "seconds before the OSD window closes");
117 117
         maxWindowsSetting = new PreferencesSetting(PreferencesType.OPTIONALINTEGER,

+ 15
- 9
src/com/dmdirc/addons/osd/OsdWindow.java View File

@@ -78,6 +78,9 @@ public class OsdWindow extends JDialog implements MouseListener,
78 78
     /** Is this a config instance? */
79 79
     private final boolean config;
80 80
 
81
+    /** Timeout before the windows are automatically closed */
82
+    private final Integer timeout;
83
+
81 84
     /**
82 85
      * Creates a new instance of OsdWindow.
83 86
      *
@@ -96,6 +99,8 @@ public class OsdWindow extends JDialog implements MouseListener,
96 99
 
97 100
         this.config = config;
98 101
         this.osdManager = osdManager;
102
+        this.timeout = IdentityManager.getGlobalConfig()
103
+            .getOptionInt(osdManager.getPlugin().getDomain(), "timeout");
99 104
 
100 105
         setFocusableWindowState(false);
101 106
         setAlwaysOnTop(true);
@@ -136,15 +141,16 @@ public class OsdWindow extends JDialog implements MouseListener,
136 141
             addMouseListener(this);
137 142
         } else {
138 143
             addMouseListener(this);
139
-            new Timer("OSD Display Timer").schedule(new TimerTask() {
140
-
141
-                /** {@inheritDoc} */
142
-                @Override
143
-                public void run() {
144
-                    osdManager.closeWindow(OsdWindow.this);
145
-                }
146
-            }, Math.max(IdentityManager.getGlobalConfig().getOptionInt(plugin
147
-                    .getDomain(), "timeout"), 1) * 1000);
144
+            if (timeout != null) {
145
+                new Timer("OSD Display Timer").schedule(new TimerTask() {
146
+
147
+                    /** {@inheritDoc} */
148
+                    @Override
149
+                    public void run() {
150
+                        osdManager.closeWindow(OsdWindow.this);
151
+                    }
152
+                }, Math.max(timeout, 1) * 1000);
153
+            }
148 154
         }
149 155
     }
150 156
 

+ 1
- 1
src/com/dmdirc/addons/osd/plugin.config View File

@@ -40,7 +40,7 @@ defaults:
40 40
   bgcolour=2222aa
41 41
   fgcolour=ffffff
42 42
   fontSize=20
43
-  timeout=15
43
+  timeout=true:15
44 44
   width=500
45 45
   maxWindows=false:5
46 46
 

Loading…
Cancel
Save