This commit is contained in:
Robert Vokac 2024-03-23 08:19:58 +01:00
parent fcffaed480
commit 9756a2fd6a
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
9 changed files with 26 additions and 8 deletions

View File

@ -157,6 +157,7 @@ public class TimeCalcConfiguration {
= new BooleanProperty("testModeProperty", false);
public final StringProperty profileNameProperty
= new StringProperty(TimeCalcProperty.PROFILE_NAME.getKey());
public final BooleanProperty testEnabledProperty = new BooleanProperty(TimeCalcProperty.TEST_ENABLED.getKey(), false);
public final IntegerProperty testYearCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_YEAR
.getKey(), Integer.MAX_VALUE);
public final IntegerProperty testMonthCustomProperty = new IntegerProperty(TimeCalcProperty.TEST_CLOCK_CUSTOM_MONTH
@ -225,6 +226,7 @@ public class TimeCalcConfiguration {
walkingHumanVisibleProperty,
mainWindowCustomTitleProperty,
profileNameProperty,
testEnabledProperty,
testYearCustomProperty,
testMonthCustomProperty,
testDayCustomProperty,

View File

@ -597,6 +597,16 @@ public class TimeCalcKeyAdapter extends KeyAdapter {
}
break;
}
case KeyEvent.VK_SLASH: {
if(timeCalcConfiguration.testEnabledProperty.isDisabled()) {
if(!Utils.askYesNo(null, "Do you really want to enable \"Test mode\"? If yes, then you will be allowed to set custom time.", "Enabling \"Test mode\"")) {
break;
}
}
timeCalcConfiguration.testEnabledProperty.flip();
Utils.showNotification((timeCalcConfiguration.testEnabledProperty.isEnabled()? "Enabled" : "Disabled") + " \"Test mode\".");
break;
}
default:
if (!numberKeyWasPressed) {
Utils.showNotification(

View File

@ -78,6 +78,7 @@ public enum TimeCalcProperty {
MAIN_WINDOW_CUSTOM_TITLE("main-window.custom-title",
"Main Window : Custom Title"),
PROFILE_NAME("profile.name", "Profile : Name"),
TEST_ENABLED("test.enabled", "Test : Enabled", Boolean.class),
TEST_CLOCK_CUSTOM_YEAR("test.clock.custom.year", "Test : Clock : Custom : Year", Integer.class),
TEST_CLOCK_CUSTOM_MONTH("test.clock.custom.month", "Test : Clock : Custom : Month", Integer.class),
TEST_CLOCK_CUSTOM_DAY("test.clock.custom.day", "Test : Clock : Custom : Day", Integer.class),

View File

@ -286,7 +286,7 @@ public class WorkingDayRepositorySQLiteImpl implements WorkingDayRepositoryApi {
@Override
public int getTotalOvertimeForDayInMinutes(int year, int month, int day) {
System.out.println("#"+year+month+day);
StringBuilder sb = new StringBuilder();
sb
.append("SELECT (sum(OVERTIME_HOUR)*60 + sum(OVERTIME_MINUTE) - sum(FORGET_OVERTIME)) as total_overtime FROM ")

View File

@ -376,7 +376,7 @@ public class AnalogClock extends Widget {
}
public int getTimerDelay() {
return 10;
return 100;
}
}

View File

@ -104,7 +104,7 @@ public class Time extends Thread {
dayOfWeekReadWriteProperty
.setValue(dayOfWeek);
try {
Thread.sleep(10);
Thread.sleep(100);
} catch (InterruptedException e) {
System.out.println(e);
}

View File

@ -166,6 +166,8 @@ public class ConfigWindow extends TWindow {
= new JTextField();
private final JTextField profileNameProperty
= new JTextField();
private final JCheckBox testEnabledProperty
= new JCheckBox(TimeCalcProperty.TEST_ENABLED.getKey());
private final JTextField testClockCustomYearProperty
= new JTextField(TimeCalcProperty.TEST_CLOCK_CUSTOM_YEAR.getKey());
private final JTextField testClockCustomMonthProperty
@ -203,7 +205,7 @@ public class ConfigWindow extends TWindow {
panelInsideScrollPaneBattery,
panelInsideScrollPaneSmileys,
panelInsideScrollPaneTest,
panelInsideScrollPaneMisc).toList();
panelInsideScrollPaneMisc).collect(Collectors.toList());
panelsInsideScrollPane.forEach(p-> {
final BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS);
p.setLayout(boxLayout);
@ -229,7 +231,7 @@ public class ConfigWindow extends TWindow {
scrollPaneSmileys,
scrollPaneTest,
scrollPaneMisc
).toList();
).collect(Collectors.toList());
tp.add("Clock", scrollPaneClock);
tp.add("Battery", scrollPaneBattery);
@ -361,6 +363,7 @@ public class ConfigWindow extends TWindow {
smileysVisibleProperty,
smileysVisibleOnlyIfMouseMovingOverProperty,
smileysColoredProperty,
testEnabledProperty,
testClockCustomYearProperty,
testClockCustomMonthProperty,
testClockCustomDayProperty,

View File

@ -146,7 +146,7 @@ public class MainWindow extends TWindow {
.bindTo(timeCalcConfiguration.testSecondCustomProperty);
time.millisecondCustomProperty
.bindTo(timeCalcConfiguration.testMillisecondCustomProperty);
time.allowCustomValuesProperty.setValue(true);
time.allowCustomValuesProperty.bindTo(timeCalcConfiguration.testEnabledProperty);
arrivalTextField.addVetoableChangeListener(e -> {
String newValue = (String) e.getNewValue();
@ -696,7 +696,7 @@ public class MainWindow extends TWindow {
while (true) {
if(Math.random() > 0.99) {
if(Math.random() > 0.999) {
File dbFileBackup = new File(dbFile.getAbsolutePath() + ".backup." + DateFormats.DATE_TIME_FORMATTER_SHORT.format(new Date()).substring(0, 10) + ".sqlite3");
if (dbFile.exists() && !dbFileBackup.exists()) {
try {
@ -711,7 +711,7 @@ public class MainWindow extends TWindow {
long now = System.currentTimeMillis();
long diff = now - Files.getLastModifiedTime(file.toPath()).toMillis();
int fileAgeInDays = (int) (diff/ 1000 / 60 / 60 / 24);
System.out.println("Found backup file " + file.getName() + "with age: " + fileAgeInDays);
System.out.println("Found backup file " + file.getName() + " with age: " + fileAgeInDays);
if(fileAgeInDays > 14) {
file.delete();
}

View File

@ -46,6 +46,8 @@ circle.visible=true
walking-human.visible=true
main-window.custom-title=---
profile.name=
test.enabled=false
test.clock.custom.year=2147483647
test.clock.custom.year=2147483647
test.clock.custom.month=2147483647
test.clock.custom.day=2147483647