- Timestamp:
- 2020-05-31T17:09:02+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DialogsToggleAction.java
r14397 r16528 52 52 boolean selected = isSelected(); 53 53 if (!selected) { 54 toolbarPreviouslyVisible = Config.getPref().getBoolean("toolbar.visible", true);55 sideToolbarPreviouslyVisible = Config.getPref().getBoolean("sidetoolbar.visible", true);54 toolbarPreviouslyVisible = MapFrame.TOOLBAR_VISIBLE.get(); 55 sideToolbarPreviouslyVisible = MapFrame.SIDE_TOOLBAR_VISIBLE.get(); 56 56 } 57 57 MapFrame map = MainApplication.getMap(); … … 61 61 // Toolbars listen to preference changes, use it here 62 62 if (!Config.getPref().getBoolean("toolbar.always-visible", true) && (!selected || toolbarPreviouslyVisible)) { 63 Config.getPref().putBoolean("toolbar.visible",selected);63 MapFrame.TOOLBAR_VISIBLE.put(selected); 64 64 } 65 65 if (!Config.getPref().getBoolean("sidetoolbar.always-visible", true) && (!selected || sideToolbarPreviouslyVisible)) { 66 Config.getPref().putBoolean("sidetoolbar.visible",selected);66 MapFrame.SIDE_TOOLBAR_VISIBLE.put(selected); 67 67 } 68 68 map.mapView.rememberLastPositionOnScreen(); -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r16285 r16528 823 823 viewMenu.add(new PreferenceToggleAction(tr("Main toolbar"), 824 824 tr("Toggles the visibility of the main toolbar (i.e., the horizontal toolbar)"), 825 "toolbar.visible", true).getCheckbox());825 MapFrame.TOOLBAR_VISIBLE.getKey(), MapFrame.TOOLBAR_VISIBLE.getDefaultValue()).getCheckbox()); 826 826 viewMenu.add(new PreferenceToggleAction(tr("Edit toolbar"), 827 827 tr("Toggles the visibility of the edit toolbar (i.e., the vertical tool)"), 828 "sidetoolbar.visible", true).getCheckbox());828 MapFrame.SIDE_TOOLBAR_VISIBLE.getKey(), MapFrame.SIDE_TOOLBAR_VISIBLE.getDefaultValue()).getCheckbox()); 829 829 // -- dialogs panel toggle action 830 830 final JCheckBoxMenuItem dialogsToggle = new JCheckBoxMenuItem(dialogsToggleAction); -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r16438 r16528 57 57 import org.openstreetmap.josm.actions.mapmode.ZoomAction; 58 58 import org.openstreetmap.josm.data.ViewportData; 59 import org.openstreetmap.josm.data.preferences.AbstractProperty; 59 60 import org.openstreetmap.josm.data.preferences.BooleanProperty; 60 61 import org.openstreetmap.josm.data.preferences.IntegerProperty; … … 83 84 import org.openstreetmap.josm.gui.util.AdvancedKeyPressDetector; 84 85 import org.openstreetmap.josm.spi.preferences.Config; 85 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;86 86 import org.openstreetmap.josm.tools.Destroyable; 87 87 import org.openstreetmap.josm.tools.GBC; … … 108 108 */ 109 109 public static final BooleanProperty MODELESS = new BooleanProperty("modeless", false); 110 /** 111 * Whether the toolbar is visible 112 */ 113 public static final BooleanProperty TOOLBAR_VISIBLE = new BooleanProperty("toolbar.visible", true); 114 /** 115 * Whether the side toolbar is visible 116 */ 117 public static final BooleanProperty SIDE_TOOLBAR_VISIBLE = new BooleanProperty("sidetoolbar.visible", true); 110 118 /** 111 119 * The current mode, this frame operates. … … 346 354 rememberToggleDialogWidth(); 347 355 dialogsPanel.destroy(); 348 Config.getPref().removePreferenceChangeListener(sidetoolbarPreferencesChangedListener);356 SIDE_TOOLBAR_VISIBLE.removeListener(sidetoolbarPreferencesChangedListener); 349 357 for (int i = 0; i < toolBarActions.getComponentCount(); ++i) { 350 358 if (toolBarActions.getComponent(i) instanceof Destroyable) { … … 546 554 sideToolBar = svp; 547 555 } 548 sideToolBar.setVisible(Config.getPref().getBoolean("sidetoolbar.visible", true)); 549 sidetoolbarPreferencesChangedListener = e -> { 550 if ("sidetoolbar.visible".equals(e.getKey())) { 551 sideToolBar.setVisible(Config.getPref().getBoolean("sidetoolbar.visible")); 552 } 553 }; 554 Config.getPref().addPreferenceChangeListener(sidetoolbarPreferencesChangedListener); 556 sideToolBar.setVisible(SIDE_TOOLBAR_VISIBLE.get()); 557 sidetoolbarPreferencesChangedListener = e -> sideToolBar.setVisible(e.getProperty().get()); 558 SIDE_TOOLBAR_VISIBLE.addListener(sidetoolbarPreferencesChangedListener); 555 559 556 560 /** … … 633 637 @Override 634 638 public void actionPerformed(ActionEvent e) { 635 Config.getPref().putBoolean("sidetoolbar.visible",false);639 SIDE_TOOLBAR_VISIBLE.put(false); 636 640 } 637 641 }); … … 802 806 private static final CopyOnWriteArrayList<MapModeChangeListener> mapModeChangeListeners = new CopyOnWriteArrayList<>(); 803 807 804 private transient PreferenceChangedListenersidetoolbarPreferencesChangedListener;808 private transient AbstractProperty.ValueChangeListener<Boolean> sidetoolbarPreferencesChangedListener; 805 809 /** 806 810 * Adds a mapMode change listener -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r16438 r16528 70 70 import org.openstreetmap.josm.data.imagery.ImageryLayerInfo; 71 71 import org.openstreetmap.josm.gui.MainApplication; 72 import org.openstreetmap.josm.gui.MapFrame; 72 73 import org.openstreetmap.josm.gui.help.HelpUtil; 73 74 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; … … 1016 1017 control.setComponentPopupMenu(popupMenu); 1017 1018 }); 1018 Config.getPref().addPreferenceChangeListener(e -> { 1019 if ("toolbar.visible".equals(e.getKey())) { 1020 refreshToolbarControl(); 1021 } 1022 }); 1019 MapFrame.TOOLBAR_VISIBLE.addListener(e -> refreshToolbarControl()); 1023 1020 } 1024 1021 … … 1202 1199 } 1203 1200 1204 boolean visible = Config.getPref().getBoolean("toolbar.visible", true);1201 boolean visible = MapFrame.TOOLBAR_VISIBLE.get(); 1205 1202 1206 1203 control.setFocusTraversalKeysEnabled(!unregisterTab);
Note:
See TracChangeset
for help on using the changeset viewer.