From af59cea62c5fb530d446fe4f2a803ffca529c577 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 29 Apr 2021 11:02:25 -0400 Subject: [PATCH] Fixing issue with GUI events being triggered prematurely when loading prefs (#7785) --- .../mage/client/dialog/PreferencesDialog.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java index fdeed45702..c175326c4a 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java @@ -35,7 +35,7 @@ import static mage.client.constants.Constants.BATTLEFIELD_FEEDBACK_COLORIZING_MO import static mage.constants.Constants.*; /** - * @author nantuko, JayDi85 + * @author nantuko, JayDi85, leemi */ public class PreferencesDialog extends javax.swing.JDialog { @@ -320,7 +320,9 @@ public class PreferencesDialog extends javax.swing.JDialog { private static int selectedAvatarId; private static ThemeType currentTheme = null; - + + private static boolean ignoreGUISizeSliderStateChangedEvent = false; + public static ThemeType getCurrentTheme() { if (currentTheme == null) { currentTheme = ThemeType.valueByName(getCachedValue(KEY_THEME, "Default")); @@ -3299,7 +3301,12 @@ public class PreferencesDialog extends javax.swing.JDialog { }//GEN-LAST:event_cbThemeActionPerformed private void sliderGUISizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderGUISizeStateChanged - saveGUISize(); + // This prevents this event from firing during the initial + // setting of the sliders from pref values + if (!ignoreGUISizeSliderStateChangedEvent) + { + saveGUISize(); + } }//GEN-LAST:event_sliderGUISizeStateChanged private void showProxySettings() { @@ -3462,6 +3469,7 @@ public class PreferencesDialog extends javax.swing.JDialog { } private static void loadGuiSize(Preferences prefs) { + ignoreGUISizeSliderStateChangedEvent = true; load(prefs, dialog.sliderFontSize, KEY_GUI_TABLE_FONT_SIZE, "14"); load(prefs, dialog.sliderChatFontSize, KEY_GUI_CHAT_FONT_SIZE, "14"); load(prefs, dialog.sliderCardSizeHand, KEY_GUI_CARD_HAND_SIZE, "14"); @@ -3475,6 +3483,7 @@ public class PreferencesDialog extends javax.swing.JDialog { load(prefs, dialog.sliderCardSizeOtherZones, KEY_GUI_CARD_OTHER_ZONES_SIZE, "14"); load(prefs, dialog.sliderCardSizeMinBattlefield, KEY_GUI_CARD_BATTLEFIELD_MIN_SIZE, "10"); load(prefs, dialog.sliderCardSizeMaxBattlefield, KEY_GUI_CARD_BATTLEFIELD_MAX_SIZE, "14"); + ignoreGUISizeSliderStateChangedEvent = false; } private static void loadImagesSettings(Preferences prefs) {