-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/12351 area of preview hover #12355
base: main
Are you sure you want to change the base?
Changes from 8 commits
611462a
708d297
97cb3e4
f0b9828
8032be1
5b36aa3
e9d0c71
4d145ed
f66f3c6
7e684d1
4f7964a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import javafx.scene.control.Label; | ||
import javafx.scene.control.Tooltip; | ||
import javafx.scene.layout.Region; | ||
import javafx.scene.layout.VBox; | ||
import javafx.util.Duration; | ||
|
||
|
@@ -17,26 +18,51 @@ public class MainTableTooltip extends Tooltip { | |
|
||
private final PreviewViewer preview; | ||
private final GuiPreferences preferences; | ||
private final VBox tooltipContent = new VBox(); | ||
private final Label fieldValueLabel = new Label(); | ||
private final VBox tooltipContent = new VBox(); // A vertical box to hold the tooltip content | ||
private final Label fieldValueLabel = new Label(); // Label to show field value | ||
|
||
public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) { | ||
this.preferences = preferences; | ||
this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor); | ||
this.setShowDelay(Duration.seconds(1)); | ||
|
||
this.setShowDelay(Duration.millis(100)); // 100ms delay | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you change the delay? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
this.setHideDelay(Duration.millis(500)); // Slight delay before hiding | ||
|
||
// Add the field value label and preview area to the tooltip content | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remoce the comments everywhere here, they state the obvious. Use comments only when you want to why you did something There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
this.tooltipContent.getChildren().addAll(fieldValueLabel, preview); | ||
|
||
// Add some basic styling to the tooltip | ||
tooltipContent.setStyle("-fx-padding: 10; -fx-background-color: white; -fx-border-color: gray; -fx-border-radius: 5;"); | ||
} | ||
|
||
public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) { | ||
// Set the text for the field value label | ||
fieldValueLabel.setText(fieldValue + "\n"); | ||
|
||
// Make sure the text wraps if it's too long | ||
fieldValueLabel.setWrapText(true); | ||
fieldValueLabel.setMaxWidth(400); // Set a limit for how wide the text can be | ||
|
||
// Automatically size the tooltip content based on what's inside | ||
tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); | ||
tooltipContent.setMaxWidth(500); // Prevent the tooltip from being too wide | ||
tooltipContent.setMaxHeight(400); // Prevent the tooltip from being too tall | ||
|
||
// If the user has enabled preview in the preferences | ||
if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { | ||
// Set up the preview | ||
preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout()); | ||
preview.setDatabaseContext(databaseContext); | ||
preview.setEntry(entry); | ||
|
||
// Show both the field value and the preview | ||
this.setGraphic(tooltipContent); | ||
} else { | ||
// If preview is disabled, only show the field value | ||
this.setGraphic(fieldValueLabel); | ||
} | ||
return this; | ||
|
||
return this; // Return the tooltip object | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,4 @@ public List<IntegrityMessage> check(BibEntry entry) { | |
.ifPresent(val -> messages.add(new IntegrityMessage(Localization.lang("abbreviation detected"), entry, field))); | ||
} | ||
return messages; | ||
} | ||
} | ||
}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Siedlerchr i expected checkstyle to complain here, but it's green. Maybe we need to add a rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the comments they are just describing the code itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done