Skip to content

Commit 31ca16a

Browse files
ddamkeddamke
authored andcommitted
Merge branch 'develop' into feature/import_sql_to_database
2 parents f5cb6b8 + bfeaa67 commit 31ca16a

File tree

11 files changed

+155
-42
lines changed

11 files changed

+155
-42
lines changed

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ private void readSettings() {
209209
model.screenSettings.screenHash.set(settings.getScreenHash());
210210
model.screenSettings.saveWindowPosition.set(settings.isSaveWindowPosition());
211211
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
212+
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
213+
model.confirmClose.set(settings.isConfirmClose());
212214

213215
}
214216

src/main/java/de/doubleslash/keeptime/common/SvgNodeProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static String getSvgPathWithXMl(Resources.RESOURCE resource) {
4242
return svgPath;
4343
}
4444

45-
public static Node getSvgNodeWithScale(Resources.RESOURCE resource, Double scaleX, Double scaleY) {
45+
public static SVGPath getSvgNodeWithScale(Resources.RESOURCE resource, Double scaleX, Double scaleY) {
4646
SVGPath iconSvg = new SVGPath();
4747
iconSvg.setContent(getSvgPathWithXMl(resource));
4848
iconSvg.setScaleX(scaleX);

src/main/java/de/doubleslash/keeptime/controller/Controller.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public void updateSettings(final Settings newValuedSettings) {
131131
settings.setWindowYProportion(newValuedSettings.getWindowYProportion());
132132
settings.setScreenHash(newValuedSettings.getScreenHash());
133133
settings.setRemindIfNotesAreEmpty(newValuedSettings.isRemindIfNotesAreEmpty());
134+
settings.setRemindIfNotesAreEmptyOnlyForWorkEntry(newValuedSettings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
135+
settings.setConfirmClose(newValuedSettings.isConfirmClose());
134136

135137
settings = model.getSettingsRepository().save(settings);
136138

@@ -147,6 +149,8 @@ public void updateSettings(final Settings newValuedSettings) {
147149
model.screenSettings.proportionalY.set(settings.getWindowYProportion());
148150
model.screenSettings.screenHash.set(settings.getScreenHash());
149151
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
152+
model.remindIfNotesAreEmptyOnlyForWorkEntry.set(settings.isRemindIfNotesAreEmptyOnlyForWorkEntry());
153+
model.confirmClose.set(settings.isConfirmClose());
150154
}
151155

152156
@PreDestroy
@@ -162,7 +166,8 @@ public void shutdown() {
162166
model.useHotkey.get(), model.displayProjectsRight.get(), model.hideProjectsOnMouseExit.get(),
163167
model.screenSettings.proportionalX.get(), model.screenSettings.proportionalY.get(),
164168
model.screenSettings.screenHash.get(), model.screenSettings.saveWindowPosition.get(),
165-
model.remindIfNotesAreEmpty.get());
169+
model.remindIfNotesAreEmpty.get(), model.remindIfNotesAreEmptyOnlyForWorkEntry.get(),
170+
model.confirmClose.get());
166171
updateSettings(newSettings);
167172
}
168173

src/main/java/de/doubleslash/keeptime/model/Model.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
8282

8383
public final ObjectProperty<Boolean> remindIfNotesAreEmpty = new SimpleObjectProperty<>(false);
8484

85+
public final ObjectProperty<Boolean> remindIfNotesAreEmptyOnlyForWorkEntry = new SimpleObjectProperty<>(false);
86+
87+
public final ObjectProperty<Boolean> confirmClose = new SimpleObjectProperty<>(false);
88+
8589
public final ScreenSettings screenSettings = new ScreenSettings();
8690

8791
private ConfigurableApplicationContext springContext;

src/main/java/de/doubleslash/keeptime/model/Settings.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ public class Settings {
6969

7070
private boolean remindIfNotesAreEmpty;
7171

72-
public Settings() {
73-
}
72+
private boolean remindIfNotesAreEmptyOnlyForWorkEntry;
73+
74+
private boolean confirmClose;
75+
76+
public Settings() {}
7477

7578
public Settings(final Color hoverBackgroundColor, final Color hoverFontColor, final Color defaultBackgroundColor,
7679
final Color defaultFontColor, final Color taskBarColor, final boolean useHotkey,
7780
final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit, final double windowPositionX,
7881
final double windowPositionY, final int screenHash, final boolean saveWindowPosition,
79-
final boolean remindIfNotesAreEmpty) {
82+
final boolean remindIfNotesAreEmpty, final boolean remindIfNotesAreEmptyOnlyForWorkEntry,
83+
final boolean confirmClose) {
8084
this.hoverBackgroundColor = hoverBackgroundColor;
8185
this.hoverFontColor = hoverFontColor;
8286
this.defaultBackgroundColor = defaultBackgroundColor;
@@ -90,7 +94,25 @@ public Settings(final Color hoverBackgroundColor, final Color hoverFontColor, fi
9094
this.windowScreenhash = screenHash;
9195
this.saveWindowPosition = saveWindowPosition;
9296
this.remindIfNotesAreEmpty = remindIfNotesAreEmpty;
97+
this.remindIfNotesAreEmptyOnlyForWorkEntry = remindIfNotesAreEmptyOnlyForWorkEntry;
98+
this.confirmClose = confirmClose;
99+
100+
}
101+
102+
public boolean isRemindIfNotesAreEmptyOnlyForWorkEntry() {
103+
return remindIfNotesAreEmptyOnlyForWorkEntry;
104+
}
105+
106+
public void setRemindIfNotesAreEmptyOnlyForWorkEntry(boolean emptyNoteReminderCheckBoxIsWork) {
107+
this.remindIfNotesAreEmptyOnlyForWorkEntry = emptyNoteReminderCheckBoxIsWork;
108+
}
109+
110+
public boolean isConfirmClose() {
111+
return confirmClose;
112+
}
93113

114+
public void setConfirmClose(boolean confirmClose) {
115+
this.confirmClose = confirmClose;
94116
}
95117

96118
public long getId() {

src/main/java/de/doubleslash/keeptime/view/ProjectsListViewController.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,11 @@ private void changeProject(final Project newProject, final long minusSeconds) {
167167
if (hideable) {
168168
mainStage.hide();
169169
}
170-
if (model.remindIfNotesAreEmpty.get()) {
171-
final Work currentWork = model.activeWorkItem.get();
172-
if (currentWork != null && currentWork.getNotes().isEmpty()) {
173-
final TextInputDialog noteDialog = new TextInputDialog();
174-
noteDialog.setTitle("Empty Notes");
175-
noteDialog.setHeaderText("Switch projects without notes?");
176-
noteDialog.setContentText(
177-
"What did you do for project '" + model.activeWorkItem.get().getProject().getName() + "' ?");
178-
noteDialog.initOwner(mainStage);
179-
180-
final Optional<String> result = noteDialog.showAndWait();
170+
final Work currentWork = model.activeWorkItem.get();
171+
if (model.remindIfNotesAreEmpty.get() && currentWork != null && currentWork.getNotes().isEmpty()) {
172+
173+
if (!model.remindIfNotesAreEmptyOnlyForWorkEntry.get() || currentWork.getProject().isWork()) {
174+
Optional<String> result = showDialogNoNoteSelected(currentWork);
181175
if (result.isPresent()) {
182176
currentWork.setNotes(result.get());
183177
} else {
@@ -187,7 +181,17 @@ private void changeProject(final Project newProject, final long minusSeconds) {
187181
}
188182
}
189183
controller.changeProject(newProject, minusSeconds);
184+
}
185+
186+
private Optional<String> showDialogNoNoteSelected(Work currentWork) {
187+
final TextInputDialog noteDialog = new TextInputDialog();
188+
noteDialog.setTitle("Empty Notes");
189+
noteDialog.setHeaderText("Switch projects without notes?");
190+
noteDialog.setContentText("What did you do for project '" + currentWork.getProject().getName() + "' ?");
191+
noteDialog.initOwner(mainStage);
190192

193+
final Optional<String> result = noteDialog.showAndWait();
194+
return result;
191195
}
192196

193197
private void addProjectToProjectSelectionNodeMap(final Project project) {

src/main/java/de/doubleslash/keeptime/view/SettingsController.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public class SettingsController {
9191
@FXML
9292
private CheckBox emptyNoteReminderCheckBox;
9393

94+
@FXML
95+
private CheckBox emptyNoteReminderOnlyForWorkEntryCheckBox;
96+
97+
@FXML
98+
private CheckBox confirmCloseCheckBox;
99+
94100
@FXML
95101
private Button saveButton;
96102

@@ -207,7 +213,8 @@ private void initialize() {
207213
useHotkeyCheckBox.isSelected(), displayProjectsRightCheckBox.isSelected(),
208214
hideProjectsOnMouseExitCheckBox.isSelected(), model.screenSettings.proportionalX.get(),
209215
model.screenSettings.proportionalY.get(), model.screenSettings.screenHash.get(),
210-
saveWindowPositionCheckBox.isSelected(), emptyNoteReminderCheckBox.isSelected()));
216+
saveWindowPositionCheckBox.isSelected(), emptyNoteReminderCheckBox.isSelected(),
217+
emptyNoteReminderOnlyForWorkEntryCheckBox.isSelected(), confirmCloseCheckBox.isSelected()));
211218
thisStage.close();
212219

213220
});
@@ -349,6 +356,9 @@ void update() {
349356
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
350357
saveWindowPositionCheckBox.setSelected(model.screenSettings.saveWindowPosition.get());
351358
emptyNoteReminderCheckBox.setSelected(model.remindIfNotesAreEmpty.get());
359+
emptyNoteReminderOnlyForWorkEntryCheckBox.disableProperty().bind(emptyNoteReminderCheckBox.selectedProperty().not());
360+
emptyNoteReminderOnlyForWorkEntryCheckBox.setSelected(model.remindIfNotesAreEmptyOnlyForWorkEntry.get());
361+
confirmCloseCheckBox.setSelected(model.confirmClose.get());
352362
}
353363

354364
public void setStage(final Stage thisStage) {

src/main/java/de/doubleslash/keeptime/view/ViewController.java

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
import java.time.LocalDateTime;
2323
import java.util.Optional;
2424

25-
import de.doubleslash.keeptime.common.*;
26-
import javafx.scene.control.*;
27-
import javafx.scene.shape.SVGPath;
2825
import org.slf4j.Logger;
2926
import org.slf4j.LoggerFactory;
3027
import org.springframework.beans.factory.annotation.Autowired;
3128
import org.springframework.stereotype.Component;
3229

30+
import de.doubleslash.keeptime.common.ColorHelper;
31+
import de.doubleslash.keeptime.common.DateFormatter;
32+
import de.doubleslash.keeptime.common.Resources;
3333
import de.doubleslash.keeptime.common.Resources.RESOURCE;
34+
import de.doubleslash.keeptime.common.ScreenPosHelper;
35+
import de.doubleslash.keeptime.common.StyleUtils;
36+
import de.doubleslash.keeptime.common.SvgNodeProvider;
3437
import de.doubleslash.keeptime.common.time.Interval;
3538
import de.doubleslash.keeptime.controller.Controller;
3639
import de.doubleslash.keeptime.exceptions.FXMLLoaderException;
@@ -56,6 +59,14 @@
5659
import javafx.scene.SnapshotParameters;
5760
import javafx.scene.canvas.Canvas;
5861
import javafx.scene.canvas.GraphicsContext;
62+
import javafx.scene.control.Alert;
63+
import javafx.scene.control.Button;
64+
import javafx.scene.control.ButtonType;
65+
import javafx.scene.control.Dialog;
66+
import javafx.scene.control.Label;
67+
import javafx.scene.control.ListView;
68+
import javafx.scene.control.TextArea;
69+
import javafx.scene.control.TextField;
5970
import javafx.scene.image.Image;
6071
import javafx.scene.image.ImageView;
6172
import javafx.scene.image.WritableImage;
@@ -67,6 +78,7 @@
6778
import javafx.scene.layout.VBox;
6879
import javafx.scene.paint.Color;
6980
import javafx.scene.shape.Circle;
81+
import javafx.scene.shape.SVGPath;
7082
import javafx.scene.text.TextAlignment;
7183
import javafx.stage.Modality;
7284
import javafx.stage.Stage;
@@ -112,19 +124,6 @@ public class ViewController {
112124
private Button settingsButton;
113125
@FXML
114126
private Button calendarButton;
115-
116-
@FXML
117-
private SVGPath calendarIcon;
118-
119-
@FXML
120-
private SVGPath settingsIcon;
121-
122-
@FXML
123-
private SVGPath minimizeIcon;
124-
125-
@FXML
126-
private SVGPath closeIcon;
127-
128127
@FXML
129128
private TextArea textArea;
130129

@@ -187,7 +186,7 @@ private void initialize() {
187186

188187
minimizeButton.setOnAction(ae -> mainStage.setIconified(true));
189188
minimizeButton.textFillProperty().bind(fontColorProperty);
190-
closeButton.setOnAction(ae -> mainStage.close());
189+
closeButton.setOnAction(ae -> openConfirmationWindow());
191190
closeButton.textFillProperty().bind(fontColorProperty);
192191

193192
addNewProjectButton.textFillProperty().bind(fontColorProperty);
@@ -196,17 +195,21 @@ private void initialize() {
196195

197196
calendarButton.setOnAction(ae -> calendarClicked());
198197

199-
calendarButton.textFillProperty().bind(fontColorProperty);
200-
calendarButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CALENDAR_DAYS_ICON, 0.03, 0.03));
198+
SVGPath calendarSvgPath = SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CALENDAR_DAYS_ICON, 0.03, 0.03);
199+
calendarSvgPath.fillProperty().bind(fontColorProperty);
200+
calendarButton.setGraphic(calendarSvgPath);
201201

202-
closeButton.textFillProperty().bind(fontColorProperty);
203-
closeButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CLOSE_ICON, 0.03, 0.03));
202+
SVGPath closeSvgPath = SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_CLOSE_ICON, 0.03, 0.03);
203+
closeSvgPath.fillProperty().bind(fontColorProperty);
204+
closeButton.setGraphic(closeSvgPath);
204205

205-
settingsButton.textFillProperty().bind(fontColorProperty);
206-
settingsButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_SETTINGS_ICON, 0.03, 0.03));
206+
SVGPath settingsSvgPath = SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_SETTINGS_ICON, 0.03, 0.03);
207+
settingsSvgPath.fillProperty().bind(fontColorProperty);
208+
settingsButton.setGraphic(settingsSvgPath);
207209

208-
minimizeButton.textFillProperty().bind(fontColorProperty);
209-
minimizeButton.setGraphic(SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_MINUS_ICON, 0.03, 0.03));
210+
SVGPath minimizeSvgPath = SvgNodeProvider.getSvgNodeWithScale(RESOURCE.SVG_MINUS_ICON, 0.03, 0.03);
211+
minimizeSvgPath.fillProperty().bind(fontColorProperty);
212+
minimizeButton.setGraphic(minimizeSvgPath);
210213

211214
final Runnable updateMainBackgroundColor = this::runUpdateMainBackgroundColor;
212215

@@ -315,6 +318,23 @@ private void initialize() {
315318

316319
}
317320

321+
private void openConfirmationWindow() {
322+
if (model.confirmClose.get()) {
323+
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.CANCEL);
324+
alert.setTitle("Confirm exit");
325+
alert.setHeaderText("Are you sure you want to close KeepTime?");
326+
327+
alert.initOwner(mainStage);
328+
alert.showAndWait();
329+
330+
if (alert.getResult() == ButtonType.YES) {
331+
mainStage.close();
332+
}
333+
} else {
334+
mainStage.close();
335+
}
336+
}
337+
318338
private Dialog<Project> dialogResultConverter(final Dialog<Project> dialog,
319339
final ManageProjectController manageProjectController) {
320340
dialog.setResultConverter(dialogButton -> {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE settings
2+
ADD COLUMN remind_if_notes_are_empty_only_for_work_entry BOOLEAN NOT NULL DEFAULT(false)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE settings
2+
ADD COLUMN confirm_close BOOLEAN NOT NULL DEFAULT(false)

0 commit comments

Comments
 (0)