Ticket #11914: 11914-v3.patch

File 11914-v3.patch, 4.9 KB (added by GerdP, 3 months ago)
  • use tr(" ({0})", string)
  • src/org/openstreetmap/josm/gui/MainFrame.java

     
    2020import javax.swing.JFrame;
    2121import javax.swing.JPanel;
    2222
     23import org.openstreetmap.josm.data.UserIdentityManager;
    2324import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    2425import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
    2526import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     
    2829import org.openstreetmap.josm.gui.layer.OsmDataLayer.LayerStateChangeListener;
    2930import org.openstreetmap.josm.gui.util.WindowGeometry;
    3031import org.openstreetmap.josm.spi.preferences.Config;
     32import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener;
    3133import org.openstreetmap.josm.tools.ImageProvider;
    3234import org.openstreetmap.josm.tools.Logging;
    3335
     
    4749        }
    4850    };
    4951
     52    private final transient PreferenceChangedListener updateTitleUserChange = evt -> {
     53        if ("osm-server.username".equals(evt.getKey()) || "draw.show-user".equals(evt.getKey())) {
     54            refreshTitle();
     55        }
     56    };
     57
    5058    protected transient WindowGeometry geometry;
    5159    protected int windowState = JFrame.NORMAL;
    5260    private final MainPanel panel;
     
    102110        // This listener is never removed, since the main frame exists forever.
    103111        MainApplication.getLayerManager().addActiveLayerChangeListener(e -> refreshTitle());
    104112        MainApplication.getLayerManager().addAndFireLayerChangeListener(new ManageLayerListeners());
     113        Config.getPref().addPreferenceChangeListener(updateTitleUserChange);
    105114
    106115        refreshTitle();
    107116
     
    165174        OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    166175        boolean dirty = editLayer != null && (editLayer.requiresSaveToFile()
    167176                || (editLayer.requiresUploadToServer() && !editLayer.isUploadDiscouraged()));
    168         setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor"));
     177        String user = UserIdentityManager.getInstance().getUserName();
     178        if (user != null && Config.getPref().getBoolean("draw.show-user", false))
     179            user = tr(" ({0})", "@"  + user);
     180        else
     181            user = "";
     182        setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor") + user);
    169183        getRootPane().putClientProperty("Window.documentModified", dirty);
    170184    }
    171185
  • src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

     
    8080    private JosmComboBox<LookAndFeelInfo> lafCombo;
    8181    VerticallyScrollablePanel panel;
    8282    private final JCheckBox showSplashScreen = new JCheckBox(tr("Show splash screen at startup"));
     83    private final JCheckBox showUser = new JCheckBox(tr("Show user name in tile"));
    8384    private final JCheckBox showID = new JCheckBox(tr("Show object ID in selection lists"));
    8485    private final JCheckBox showVersion = new JCheckBox(tr("Show object version in selection lists"));
    8586    private final JCheckBox showCoor = new JCheckBox(tr("Show node coordinates in selection lists"));
     
    129130        showSplashScreen.setSelected(Config.getPref().getBoolean("draw.splashscreen", true));
    130131        panel.add(showSplashScreen, GBC.eop().insets(20, 0, 0, 0));
    131132
     133        // Show user name in title
     134        showUser.setToolTipText(tr("Show user name in title"));
     135        showUser.setSelected(Config.getPref().getBoolean("draw.show-user", false));
     136
    132137        // Show ID in selection
    133138        showID.setToolTipText(tr("Show object ID in selection lists"));
    134139        showID.setSelected(Config.getPref().getBoolean("osm-primitives.showid", false));
     
    150155        modeless.setSelected(MapFrame.MODELESS.get());
    151156        ExpertToggleAction.addVisibilitySwitcher(modeless);
    152157
     158        panel.add(showUser, GBC.eop().insets(20, 0, 0, 0));
    153159        panel.add(showID, GBC.eop().insets(20, 0, 0, 0));
    154160        panel.add(showVersion, GBC.eop().insets(20, 0, 0, 0));
    155161        panel.add(showCoor, GBC.eop().insets(20, 0, 0, 0));
     
    215221    public boolean ok() {
    216222        boolean mod = false;
    217223        Config.getPref().putBoolean("draw.splashscreen", showSplashScreen.isSelected());
     224        Config.getPref().putBoolean("draw.show-user", showUser.isSelected());
    218225        Config.getPref().putBoolean("osm-primitives.showid", showID.isSelected());
    219226        Config.getPref().putBoolean("osm-primitives.showversion", showVersion.isSelected());
    220227        Config.getPref().putBoolean("osm-primitives.showcoor", showCoor.isSelected());