Added the possibility to hide buttons
This commit is contained in:
parent
4d4bf32645
commit
d1f49803c8
@ -35,6 +35,11 @@ public class ComponentRegistry<T extends Component> {
|
||||
|
||||
public void setVisible(Predicate<Component> predicate, boolean b) {
|
||||
for (T c : set) {
|
||||
if(c instanceof TButton) {
|
||||
if(!MainWindow.hideShowCheckBox.isSelected() && b) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(predicate != null) {
|
||||
if(!predicate.test(c)) {
|
||||
continue;
|
||||
|
@ -41,6 +41,7 @@ import java.util.Properties;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
/**
|
||||
* @author Robert Vokac
|
||||
@ -61,6 +62,7 @@ public class MainWindow extends TWindow {
|
||||
private final TButton commandButton;
|
||||
private final TButton jokeButton;
|
||||
private final AboutButton aboutButton;
|
||||
public static final JCheckBox hideShowCheckBox = new JCheckBox();
|
||||
private HelpWindow helpWindow = null;
|
||||
private ConfigWindow configWindow = null;
|
||||
private ActivitiesWindow activitiesWindow = null;
|
||||
@ -115,7 +117,7 @@ public class MainWindow extends TWindow {
|
||||
|
||||
//window.add(weatherButton);
|
||||
addAll(configButton, workDaysButton, activitiesButton, restartButton,
|
||||
exitButton, focusButton, helpButton, commandButton, jokeButton);
|
||||
exitButton, focusButton, helpButton, commandButton, jokeButton, hideShowCheckBox);
|
||||
|
||||
timeCalcApp.visibilityProperty.bindTo(timeCalcConfiguration.visibilityDefaultProperty);
|
||||
if (!timeCalcConfiguration.visibilitySupportedColoredProperty.isEnabled()) {
|
||||
@ -163,6 +165,8 @@ public class MainWindow extends TWindow {
|
||||
focusButton.setBoundsFromLeft(helpButton);
|
||||
commandButton.setBoundsFromLeft(focusButton);
|
||||
jokeButton.setBoundsFromLeft(commandButton);
|
||||
hideShowCheckBox.setSelected(true);
|
||||
hideShowCheckBox.setBounds(jokeButton.getX() + jokeButton.getWidth() + SwingUtils.MARGIN, jokeButton.getY(), 20, 20);
|
||||
//
|
||||
aboutButton.setBounds(exitButton.getX(),
|
||||
exitButton.getY() + exitButton.getHeight() + SwingUtils.MARGIN);
|
||||
@ -182,6 +186,9 @@ public class MainWindow extends TWindow {
|
||||
Jokes.showRandom();
|
||||
}
|
||||
});
|
||||
hideShowCheckBox.addItemListener(e ->
|
||||
{
|
||||
});
|
||||
exitButton.addActionListener(e
|
||||
-> {
|
||||
timeCalcConfiguration.saveToTimeCalcProperties();
|
||||
@ -421,7 +428,7 @@ public class MainWindow extends TWindow {
|
||||
jokeButton.setVisible(
|
||||
TimeCalcProperties.getInstance().getBooleanProperty(
|
||||
TimeCalcProperty.JOKES_VISIBLE)
|
||||
&& !currentVisibility.isNone());
|
||||
&& !currentVisibility.isNone() && MainWindow.hideShowCheckBox.isSelected());
|
||||
|
||||
setTitle(currentVisibility.isNone() ? "" : windowTitle);
|
||||
|
||||
|
@ -34,6 +34,12 @@ public class TButton extends JButton implements GetProperty {
|
||||
public TButton(String label) {
|
||||
super(label);
|
||||
new Timer(100, e -> {
|
||||
if(!MainWindow.hideShowCheckBox.isSelected()) {
|
||||
setVisible(false);
|
||||
return;
|
||||
} else {
|
||||
setVisible(true);
|
||||
}
|
||||
Visibility visibility
|
||||
= Visibility.valueOf(visibilityProperty.getValue());
|
||||
setVisible(visibility.isNotNone() && visibleProperty.isEnabled());
|
||||
|
Loading…
x
Reference in New Issue
Block a user