Parcourir la source

issue 1135: Main frame should update icon in response to config changes

git-svn-id: http://svn.dmdirc.com/trunk@3902 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Gregory Holmes il y a 16 ans
Parent
révision
bee924a4fd
1 fichiers modifiés avec 18 ajouts et 12 suppressions
  1. 18
    12
      src/com/dmdirc/ui/swing/MainFrame.java

+ 18
- 12
src/com/dmdirc/ui/swing/MainFrame.java Voir le fichier

@@ -19,7 +19,6 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
-
23 22
 package com.dmdirc.ui.swing;
24 23
 
25 24
 import com.dmdirc.FrameContainer;
@@ -97,7 +96,7 @@ public final class MainFrame extends JFrame implements WindowListener,
97 96
      * direction. */
98 97
     private int yOffset;
99 98
     /** The main application icon. */
100
-    private final ImageIcon imageIcon;
99
+    private ImageIcon imageIcon;
101 100
     /** The frame manager that's being used. */
102 101
     private FrameManager mainFrameManager;
103 102
     /** Dekstop pane. */
@@ -155,6 +154,8 @@ public final class MainFrame extends JFrame implements WindowListener,
155 154
                 getOptionBool("ui", "showversion", false);
156 155
         IdentityManager.getGlobalConfig().
157 156
                 addChangeListener("ui", "showversion", this);
157
+        IdentityManager.getGlobalConfig().
158
+                addChangeListener("icon", "icon", this);
158 159
 
159 160
         //TODO: Remove me when we switch to java7
160 161
         addWindowFocusListener(new WindowFocusListener() {
@@ -162,7 +163,7 @@ public final class MainFrame extends JFrame implements WindowListener,
162 163
             /** {@inheritDoc} */
163 164
             @Override
164 165
             public void windowGainedFocus(WindowEvent e) {
165
-            //Ignore
166
+                //Ignore
166 167
             }
167 168
 
168 169
             /** {@inheritDoc} */
@@ -289,7 +290,7 @@ public final class MainFrame extends JFrame implements WindowListener,
289 290
     /** {@inheritDoc}. */
290 291
     @Override
291 292
     public void windowOpened(final WindowEvent windowEvent) {
292
-    //ignore
293
+        //ignore
293 294
     }
294 295
 
295 296
     /** {@inheritDoc} */
@@ -301,7 +302,7 @@ public final class MainFrame extends JFrame implements WindowListener,
301 302
     /** {@inheritDoc}. */
302 303
     @Override
303 304
     public void windowClosed(final WindowEvent windowEvent) {
304
-    //ignore
305
+        //ignore
305 306
     }
306 307
 
307 308
     /** {@inheritDoc}. */
@@ -319,13 +320,13 @@ public final class MainFrame extends JFrame implements WindowListener,
319 320
     /** {@inheritDoc}. */
320 321
     @Override
321 322
     public void windowActivated(final WindowEvent windowEvent) {
322
-    //ignore
323
+        //ignore
323 324
     }
324 325
 
325 326
     /** {@inheritDoc}. */
326 327
     @Override
327 328
     public void windowDeactivated(final WindowEvent windowEvent) {
328
-    //ignore
329
+        //ignore
329 330
     }
330 331
 
331 332
     /** Initialiases the frame managers. */
@@ -572,15 +573,21 @@ public final class MainFrame extends JFrame implements WindowListener,
572 573
     /** {@inheritDoc} */
573 574
     @Override
574 575
     public void configChanged(final String domain, final String key) {
575
-        showVersion =
576
-                IdentityManager.getGlobalConfig().
577
-                getOptionBool("ui", "showversion", false);
576
+        if ("ui".equals(domain)) {
577
+            showVersion =
578
+                    IdentityManager.getGlobalConfig().
579
+                    getOptionBool("ui", "showversion", false);
580
+        } else {
581
+            imageIcon =
582
+                    new ImageIcon(IconManager.getIconManager().getImage("icon"));
583
+            setIconImage(imageIcon.getImage());
584
+        }
578 585
     }
579 586
 
580 587
     /** {@inheritDoc}. */
581 588
     @Override
582 589
     public void setParent(final JComponent parent) {
583
-    //Ignore
590
+        //Ignore
584 591
     }
585 592
 
586 593
     /** {@inheritDoc}. */
@@ -651,5 +658,4 @@ public final class MainFrame extends JFrame implements WindowListener,
651 658
     public void delWindow(final FrameContainer parent, final FrameContainer window) {
652 659
         delWindow(window);
653 660
     }
654
-
655 661
 }

Chargement…
Annuler
Enregistrer