Skip to content

Commit 4359f5f

Browse files
authored
Merge pull request #14 from doubleSlashde/feature/#13_hideProjectsSetting
Feature/#13 hide projects setting
2 parents eb74428 + 9767733 commit 4359f5f

File tree

10 files changed

+185
-107
lines changed

10 files changed

+185
-107
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void start(final Stage primaryStage) throws Exception {
7878
settings.setHoverFontColor(model.hoverFontColor.get());
7979
settings.setUseHotkey(false);
8080
settings.setDisplayProjectsRight(false);
81+
settings.setHideProjectsOnMouseExit(true);
8182
model.settingsRepository.save(settings);
8283
} else {
8384
settings = settingsList.get(0);
@@ -90,6 +91,7 @@ public void start(final Stage primaryStage) throws Exception {
9091
model.taskBarColor.set(settings.getTaskBarColor());
9192
model.useHotkey.set(settings.isUseHotkey());
9293
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
94+
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
9395

9496
final List<Work> todaysWorkItems = model.workRepository.findByCreationDate(LocalDate.now());
9597
LOG.info("Found {} past work items", todaysWorkItems.size());

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void addNewProject(final String projectName, final boolean isWork, final
9191

9292
public void updateSettings(final Color hoverBackgroundColor, final Color hoverFontColor,
9393
final Color defaultBackgroundColor, final Color defaultFontColor, final Color taskBarColor,
94-
final boolean useHotkey, final boolean displayProjectsRight) {
94+
final boolean useHotkey, final boolean displayProjectsRight, final boolean hideProjectsOnMouseExit) {
9595
// TODO create holder for all the properties (or reuse Settings.class?)
9696
final Settings settings = model.settingsRepository.findAll().get(0);
9797
settings.setTaskBarColor(taskBarColor);
@@ -103,6 +103,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
103103
settings.setHoverFontColor(hoverFontColor);
104104
settings.setUseHotkey(useHotkey);
105105
settings.setDisplayProjectsRight(displayProjectsRight);
106+
settings.setHideProjectsOnMouseExit(hideProjectsOnMouseExit);
106107

107108
model.settingsRepository.save(settings);
108109

@@ -113,6 +114,7 @@ public void updateSettings(final Color hoverBackgroundColor, final Color hoverFo
113114
model.taskBarColor.set(settings.getTaskBarColor());
114115
model.useHotkey.set(settings.isUseHotkey());
115116
model.displayProjectsRight.set(settings.isDisplayProjectsRight());
117+
model.hideProjectsOnMouseExit.set(settings.isHideProjectsOnMouseExit());
116118
}
117119

118120
@PreDestroy
@@ -161,13 +163,13 @@ public void editProject(final Project p, final String newName, final Color newCo
161163
* Changes the indexes of the originalList parameter to have a consistent order.
162164
*
163165
* @param originalList
164-
* list of all projects to adapt the indexes for
166+
* list of all projects to adapt the indexes for
165167
* @param changedProject
166-
* the project which has changed which already has the new index
168+
* the project which has changed which already has the new index
167169
* @param oldIndex
168-
* the old index of the changed project
170+
* the old index of the changed project
169171
* @param newIndex
170-
* the new index of the changed project (which the projects also already has)
172+
* the new index of the changed project (which the projects also already has)
171173
* @return all projects whose index has been adapted
172174
*/
173175
List<Project> resortProjectIndexes(final List<Project> originalList, final Project changedProject,
@@ -209,9 +211,9 @@ List<Project> resortProjectIndexes(final List<Project> originalList, final Proje
209211
* Decreases all indexes by one, after the removed index
210212
*
211213
* @param originalList
212-
* list of all projects to adapt the indexes for
214+
* list of all projects to adapt the indexes for
213215
* @param removedIndex
214-
* the index which has been removed
216+
* the index which has been removed
215217
* @return all projects whose index has been adapted
216218
*/
217219
List<Project> adaptProjectIndexesAfterRemoving(final List<Project> originalList, final int removedIndex) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ public Model(final ProjectRepository projectRepository, final WorkRepository wor
5959
public ObjectProperty<Color> defaultFontColor = new SimpleObjectProperty<>(originalDefaultFontColor);
6060
public ObjectProperty<Boolean> useHotkey = new SimpleObjectProperty<>(false);
6161
public ObjectProperty<Boolean> displayProjectsRight = new SimpleObjectProperty<>(false);
62-
62+
public ObjectProperty<Boolean> hideProjectsOnMouseExit = new SimpleObjectProperty<>(true);
6363
}

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

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

4242
private boolean displayProjectsRight;
4343

44+
private boolean hideProjectsOnMouseExit;
45+
4446
public long getId() {
4547
return id;
4648
}
@@ -101,4 +103,12 @@ public void setDisplayProjectsRight(final boolean displayProjectsRight) {
101103
this.displayProjectsRight = displayProjectsRight;
102104
}
103105

106+
public boolean isHideProjectsOnMouseExit() {
107+
return hideProjectsOnMouseExit;
108+
}
109+
110+
public void setHideProjectsOnMouseExit(final boolean hideProjectsOnMouseExit) {
111+
this.hideProjectsOnMouseExit = hideProjectsOnMouseExit;
112+
}
113+
104114
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class SettingsController {
4747
private CheckBox useHotkeyCheckBox;
4848
@FXML
4949
private CheckBox displayProjectsRightCheckBox;
50+
@FXML
51+
private CheckBox hideProjectsOnMouseExitCheckBox;
5052

5153
@FXML
5254
private Button saveButton;
@@ -75,7 +77,8 @@ private void initialize() {
7577
LOG.info("Save clicked");
7678
controller.updateSettings(hoverBackgroundColor.getValue(), hoverFontColor.getValue(),
7779
defaultBackgroundColor.getValue(), defaultFontColor.getValue(), taskBarColor.getValue(),
78-
useHotkeyCheckBox.isSelected(), displayProjectsRightCheckBox.isSelected());
80+
useHotkeyCheckBox.isSelected(), displayProjectsRightCheckBox.isSelected(),
81+
hideProjectsOnMouseExitCheckBox.isSelected());
7982
thisStage.close();
8083
});
8184

@@ -130,6 +133,7 @@ void update() {
130133

131134
useHotkeyCheckBox.setSelected(model.useHotkey.get());
132135
displayProjectsRightCheckBox.setSelected(model.displayProjectsRight.get());
136+
hideProjectsOnMouseExitCheckBox.setSelected(model.hideProjectsOnMouseExit.get());
133137
}
134138

135139
public void setStage(final Stage thisStage) {

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,12 @@ private void initialize() throws IOException {
182182

183183
// reposition window if projects are hidden (as anchor is top left)
184184
mouseHoveringProperty.addListener((a, b, c) -> {
185-
// TODO fix the not so nice jumping..
186-
projectsVBox.setManaged(c);
187-
final double beforeWidth = mainStage.getWidth();
188-
mainStage.sizeToScene();
189-
final double afterWidth = mainStage.getWidth();
190-
projectsVBox.setVisible(c);
191-
final double offset = afterWidth - beforeWidth;
192-
if (!model.displayProjectsRight.get()) {
193-
// we only need to move the stage if the node on the left is hidden
194-
mainStage.setX(mainStage.getX() - offset);
185+
if (!model.hideProjectsOnMouseExit.get()) {
186+
setProjectListVisible(true);
187+
return;
195188
}
189+
190+
setProjectListVisible(c);
196191
});
197192

198193
minimizeButton.setOnAction((ae) -> {
@@ -447,6 +442,20 @@ private void initialize() throws IOException {
447442

448443
}
449444

445+
private void setProjectListVisible(final Boolean c) {
446+
// TODO fix the not so nice jumping..
447+
projectsVBox.setManaged(c);
448+
final double beforeWidth = mainStage.getWidth();
449+
mainStage.sizeToScene();
450+
final double afterWidth = mainStage.getWidth();
451+
projectsVBox.setVisible(c);
452+
final double offset = afterWidth - beforeWidth;
453+
if (!model.displayProjectsRight.get()) {
454+
// we only need to move the stage if the node on the left is hidden
455+
mainStage.setX(mainStage.getX() - offset);
456+
}
457+
}
458+
450459
private void loadSubStages() {
451460
try {
452461
// Report stage

src/main/resources/ProjectDetailLayout.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<?import javafx.scene.control.Label?>
44
<?import javafx.scene.layout.Pane?>
55

6-
<Pane minHeight="-Infinity" prefHeight="17.0" prefWidth="114.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
6+
<Pane minHeight="-Infinity" prefHeight="14.0" prefWidth="114.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1">
77
<children>
88
<Label prefWidth="70.0" text="Projectname" />
99
<Label layoutX="69.0" prefWidth="45.0" text="00:00:00" />
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 hide_projects_on_mouse_exit BOOLEAN NOT NULL DEFAULT(true)

src/main/resources/menu.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.menuBorder {
2+
-fx-border-color: rgba(180,180,180,1);
3+
-fx-padding: 2px;
4+
}

0 commit comments

Comments
 (0)