Skip to content

Commit 4367658

Browse files
authored
Merge pull request #45 from doubleSlashde/feature/optional_note_reminder
Feature/optional note reminder
2 parents b8e7552 + 4fad142 commit 4367658

File tree

10 files changed

+82
-8
lines changed

10 files changed

+82
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ private void readSettings() {
199199
model.useHotkey.set(settings.isUseHotkey());
200200
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
201201
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
202+
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
202203
}
203204

204205
private void initialisePopupUI(final Stage primaryStage) throws IOException {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public void addNewProject(final Project project) {
104104

105105
public void updateSettings(final Color hoverBackgroundColor, final Color hoverFontColor,
106106
final Color defaultBackgroundColor, final Color defaultFontColor, final Color taskBarColor,
107-
final boolean useHotkey, final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit) {
107+
final boolean useHotkey, final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit,
108+
final boolean emptyNoteReminder) {
108109
// TODO create holder for all the properties (or reuse Settings.class?)
109110
final Settings settings = model.getSettingsRepository().findAll().get(0);
110111
settings.setTaskBarColor(taskBarColor);
@@ -117,6 +118,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
117118
settings.setUseHotkey(useHotkey);
118119
settings.setDisplayProjectsRight(displayProjectsRight);
119120
settings.setHideProjectsOnMouseExit(hideProjectsOnMouseExit);
121+
settings.setRemindIfNotesAreEmpty(emptyNoteReminder);
120122

121123
model.getSettingsRepository().save(settings);
122124

@@ -128,6 +130,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
128130
model.useHotkey.set(settings.isUseHotkey());
129131
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
130132
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
133+
model.remindIfNotesAreEmpty.set(settings.isRemindIfNotesAreEmpty());
131134
}
132135

133136
@PreDestroy

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
7979
public final ObjectProperty<Boolean> useHotkey = new SimpleObjectProperty<>(false);
8080
public final ObjectProperty<Boolean> displayProjectsRight = new SimpleObjectProperty<>(false);
8181
public final ObjectProperty<Boolean> hideProjectsOnMouseExit = new SimpleObjectProperty<>(true);
82-
public final ObjectProperty<Boolean> emptyNoteReminder = new SimpleObjectProperty<>(false);
82+
83+
public final ObjectProperty<Boolean> remindIfNotesAreEmpty = new SimpleObjectProperty<>(false);
8384

8485
private ConfigurableApplicationContext springContext;
8586

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class Settings {
5959

6060
private boolean hideProjectsOnMouseExit;
6161

62+
private boolean remindIfNotesAreEmpty;
63+
6264
public long getId() {
6365
return id;
6466
}
@@ -127,4 +129,12 @@ public void setHideProjectsOnMouseExit(final boolean hideProjectsOnMouseExit) {
127129
this.hideProjectsOnMouseExit = hideProjectsOnMouseExit;
128130
}
129131

132+
public boolean isRemindIfNotesAreEmpty() {
133+
return remindIfNotesAreEmpty;
134+
}
135+
136+
public void setRemindIfNotesAreEmpty(final boolean emptyNoteReminder) {
137+
this.remindIfNotesAreEmpty = emptyNoteReminder;
138+
}
139+
130140
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import de.doubleslash.keeptime.exceptions.FXMLLoaderException;
3535
import de.doubleslash.keeptime.model.Model;
3636
import de.doubleslash.keeptime.model.Project;
37+
import de.doubleslash.keeptime.model.Work;
3738
import javafx.collections.transformation.FilteredList;
3839
import javafx.fxml.FXMLLoader;
3940
import javafx.scene.Node;
@@ -49,6 +50,7 @@
4950
import javafx.scene.control.MultipleSelectionModel;
5051
import javafx.scene.control.SelectionMode;
5152
import javafx.scene.control.TextField;
53+
import javafx.scene.control.TextInputDialog;
5254
import javafx.scene.control.Tooltip;
5355
import javafx.scene.effect.Bloom;
5456
import javafx.scene.input.MouseButton;
@@ -165,7 +167,27 @@ private void changeProject(final Project newProject, final long minusSeconds) {
165167
if (hideable) {
166168
mainStage.hide();
167169
}
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();
181+
if (result.isPresent()) {
182+
currentWork.setNotes(result.get());
183+
} else {
184+
// cancel pressed
185+
return;
186+
}
187+
}
188+
}
168189
controller.changeProject(newProject, minusSeconds);
190+
169191
}
170192

171193
private void addProjectToProjectSelectionNodeMap(final Project project) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ public ReportController(final Model model, final Controller controller) {
124124
private void initialize() {
125125
LOG.info("Init reportController");
126126
currentReportDate = LocalDate.now();
127-
colorTimeLine = new ColorTimeLine(colorTimeLineCanvas);
128127

128+
colorTimeLine = new ColorTimeLine(colorTimeLineCanvas);
129129
loadCalenderWidget();
130130
initTableView();
131-
132131
}
133132

134133
private void initTableView() {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public class SettingsController {
7979
@FXML
8080
private CheckBox hideProjectsOnMouseExitCheckBox;
8181

82+
@FXML
83+
private CheckBox emptyNoteReminderCheeckBox;
84+
8285
@FXML
8386
private Button saveButton;
8487

@@ -173,7 +176,7 @@ private void initialize() {
173176
controller.updateSettings(hoverBackgroundColor.getValue(), hoverFontColor.getValue(),
174177
defaultBackgroundColor.getValue(), defaultFontColor.getValue(), taskBarColor.getValue(),
175178
useHotkeyCheckBox.isSelected(), displayProjectsRightCheckBox.isSelected(),
176-
hideProjectsOnMouseExitCheckBox.isSelected());
179+
hideProjectsOnMouseExitCheckBox.isSelected(), emptyNoteReminderCheeckBox.isSelected());
177180
thisStage.close();
178181

179182
});
@@ -193,7 +196,7 @@ private void initialize() {
193196
resetDefaultFontButton.setOnAction(ae -> defaultFontColor.setValue(Model.ORIGINAL_DEFAULT_FONT_COLOR));
194197
resetTaskBarFontButton.setOnAction(ae -> taskBarColor.setValue(Model.ORIGINAL_TASK_BAR_FONT_COLOR));
195198

196-
LOG.debug("reportBugButton.setOnAction");
199+
LOG.debug("aboutButton.setOnAction");
197200
aboutButton.setOnAction(ae -> {
198201
LOG.info("About clicked");
199202
aboutStage.show();
@@ -215,6 +218,7 @@ void update() {
215218
useHotkeyCheckBox.setSelected(model.useHotkey.get());
216219
displayProjectsRightCheckBox.setSelected(model.displayProjectsRight.get());
217220
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
221+
emptyNoteReminderCheeckBox.setSelected(model.remindIfNotesAreEmpty.get());
218222
}
219223

220224
public void setStage(final Stage thisStage) {
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 empty_note_reminder 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+
RENAME COLUMN empty_note_reminder TO remind_if_notes_are_empty

src/main/resources/layouts/settings.fxml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<?import javafx.scene.layout.VBox?>
2929
<?import javafx.scene.text.Font?>
3030

31-
<AnchorPane fx:id="settingsRoot" focusTraversable="true" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.SettingsController">
31+
<AnchorPane fx:id="settingsRoot" focusTraversable="true" xmlns="http://javafx.com/javafx/8.0.202-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.doubleslash.keeptime.view.SettingsController">
3232
<children>
3333
<VBox spacing="10.0" stylesheets="@../css/menu.css">
3434
<children>
@@ -202,7 +202,7 @@
202202
<Font name="Open Sans Bold" size="12.0" />
203203
</font>
204204
</Label>
205-
<Label fx:id="globalKeyloggerLabel" alignment="TOP_LEFT" contentDisplay="TOP" disable="true" prefHeight="17.0" prefWidth="106.0" text="(global keylogger!)">
205+
<Label fx:id="globalKeyloggerLabel" alignment="TOP_LEFT" contentDisplay="TOP" disable="true" prefHeight="17.0" prefWidth="120.0" text="(global keylistener!)">
206206
<font>
207207
<Font name="Open Sans Regular" size="12.0" />
208208
</font>
@@ -224,6 +224,36 @@
224224
</Group>
225225
</children>
226226
</VBox>
227+
<VBox styleClass="menuBorder">
228+
<children>
229+
<Group>
230+
<children>
231+
<VBox>
232+
<children>
233+
<HBox spacing="10.0">
234+
<children>
235+
<Label fx:id="hotkeyLabel1" text="Note Reminder">
236+
<font>
237+
<Font name="Open Sans Bold" size="12.0" />
238+
</font>
239+
</Label>
240+
</children>
241+
</HBox>
242+
<HBox spacing="10.0">
243+
<children>
244+
<CheckBox fx:id="emptyNoteReminderCheeckBox" mnemonicParsing="false" text="Ask for notes when switching project (if empty)" wrapText="true" HBox.hgrow="NEVER">
245+
<font>
246+
<Font name="Open Sans Regular" size="12.0" />
247+
</font>
248+
</CheckBox>
249+
</children>
250+
</HBox>
251+
</children>
252+
</VBox>
253+
</children>
254+
</Group>
255+
</children>
256+
</VBox>
227257
<HBox spacing="10.0">
228258
<children>
229259
<Button fx:id="saveButton" mnemonicParsing="false" text="Save">

0 commit comments

Comments
 (0)