mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-153597 Settings > Appearance > "Override default fonts" should display current font when unchecked
This commit is contained in:
@@ -19,6 +19,7 @@ import com.intellij.ide.WelcomeWizardUtil
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.IconLoader
|
||||
import com.intellij.openapi.util.Pair
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
@@ -264,6 +265,8 @@ class UISettings : BaseState(), PersistentStateComponent<UISettings> {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(UISettings::class.java)
|
||||
|
||||
const val ANIMATION_DURATION = 300 // Milliseconds
|
||||
|
||||
/** Not tabbed pane. */
|
||||
@@ -369,14 +372,16 @@ class UISettings : BaseState(), PersistentStateComponent<UISettings> {
|
||||
|
||||
@JvmStatic
|
||||
fun restoreFontSize(readSize: Int, readScale: Float?): Int {
|
||||
var size = readSize
|
||||
if (readScale == null || readScale <= 0) {
|
||||
// Reset font to default on switch from IDE-managed HiDPI to JRE-managed HiDPI. Doesn't affect OSX.
|
||||
if (UIUtil.isJreHiDPIEnabled() && !SystemInfo.isMac) return UIUtil.DEF_SYSTEM_FONT_SIZE.toInt()
|
||||
if (UIUtil.isJreHiDPIEnabled() && !SystemInfo.isMac) size = UIUtil.DEF_SYSTEM_FONT_SIZE.toInt()
|
||||
}
|
||||
else {
|
||||
return ((readSize.toFloat() / readScale) * normalizingScale).toInt()
|
||||
size = ((readSize.toFloat() / readScale) * normalizingScale).toInt()
|
||||
}
|
||||
return readSize
|
||||
LOG.info("Loaded: fontSize=$readSize, fontScale=$readScale; restored: fontSize=$size, fontScale=$normalizingScale")
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.ui.FontComboBox;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -198,9 +199,11 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
settings.setAllowMergeButtons(myComponent.myAllowMergeButtons.isSelected());
|
||||
update |= settings.getCycleScrolling() != myComponent.myCycleScrollingCheckBox.isSelected();
|
||||
settings.setCycleScrolling(myComponent.myCycleScrollingCheckBox.isSelected());
|
||||
boolean shouldResetLafFonts = false;
|
||||
if (settings.getOverrideLafFonts() != myComponent.myOverrideLAFFonts.isSelected()) {
|
||||
shouldUpdateUI = true;
|
||||
update = true;
|
||||
shouldResetLafFonts = !myComponent.myOverrideLAFFonts.isSelected();
|
||||
}
|
||||
settings.setOverrideLafFonts(myComponent.myOverrideLAFFonts.isSelected());
|
||||
settings.setMoveMouseOnDefaultButton(myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected());
|
||||
@@ -253,6 +256,14 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
|
||||
if (shouldUpdateUI) {
|
||||
lafManager.updateUI();
|
||||
if (shouldResetLafFonts) {
|
||||
int defSize = JBUI.Fonts.label().getSize();
|
||||
settings.setFontSize(defSize);
|
||||
myComponent.myFontSizeCombo.getModel().setSelectedItem(String.valueOf(defSize));
|
||||
String defName = JBUI.Fonts.label().getFontName();
|
||||
settings.setFontFace(defName);
|
||||
myComponent.myFontCombo.setFontName(defName);
|
||||
}
|
||||
}
|
||||
|
||||
if (WindowManagerEx.getInstanceEx().isAlphaModeSupported()) {
|
||||
|
||||
@@ -152,6 +152,8 @@ public class JBUI {
|
||||
|
||||
static {
|
||||
setUserScaleFactor(UIUtil.isJreHiDPIEnabled() ? 1f : SYSTEM_SCALE_FACTOR);
|
||||
LOG.info("System scale factor: " + SYSTEM_SCALE_FACTOR + " (" +
|
||||
(UIUtil.isJreHiDPIEnabled() ? "JRE-managed" : "IDE-managed") + " HiDPI)");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +317,7 @@ public class JBUI {
|
||||
|
||||
private static void setUserScaleFactorProperty(float scale) {
|
||||
PCS.firePropertyChange(USER_SCALE_FACTOR_PROPERTY, userScaleFactor, userScaleFactor = scale);
|
||||
LOG.info("UI scale factor: " + userScaleFactor);
|
||||
LOG.info("User scale factor: " + userScaleFactor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user