mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
Merge pull request #1045 from zhouer/minimize
Add minimize button, fixes #1035
This commit is contained in:
@@ -33,6 +33,7 @@ public enum FontAwesome5Icon {
|
||||
SYNC("\uF021"), //
|
||||
TIMES("\uF00D"), //
|
||||
WRENCH("\uF0AD"), //
|
||||
WINDOW_MINIMIZE("\uF2D1"), //
|
||||
;
|
||||
|
||||
private final String unicode;
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.awt.desktop.QuitResponse;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
@MainWindowScoped
|
||||
public class MainWindowTitleController implements FxController {
|
||||
@@ -26,6 +28,7 @@ public class MainWindowTitleController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final FxApplication application;
|
||||
private final CountDownLatch shutdownLatch;
|
||||
private final boolean minimizeToSysTray;
|
||||
private final UpdateChecker updateChecker;
|
||||
private final BooleanBinding updateAvailable;
|
||||
@@ -35,9 +38,10 @@ public class MainWindowTitleController implements FxController {
|
||||
private double yOffset;
|
||||
|
||||
@Inject
|
||||
MainWindowTitleController(@MainWindow Stage window, FxApplication application, @Named("trayMenuSupported") boolean minimizeToSysTray, UpdateChecker updateChecker, LicenseHolder licenseHolder) {
|
||||
MainWindowTitleController(@MainWindow Stage window, FxApplication application, @Named("shutdownLatch") CountDownLatch shutdownLatch, @Named("trayMenuSupported") boolean minimizeToSysTray, UpdateChecker updateChecker, LicenseHolder licenseHolder) {
|
||||
this.window = window;
|
||||
this.application = application;
|
||||
this.shutdownLatch = shutdownLatch;
|
||||
this.minimizeToSysTray = minimizeToSysTray;
|
||||
this.updateChecker = updateChecker;
|
||||
this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
|
||||
@@ -63,10 +67,29 @@ public class MainWindowTitleController implements FxController {
|
||||
if (minimizeToSysTray) {
|
||||
window.close();
|
||||
} else {
|
||||
window.setIconified(true);
|
||||
quitApplication();
|
||||
}
|
||||
}
|
||||
|
||||
private void quitApplication() {
|
||||
application.showQuitWindow(new QuitResponse() {
|
||||
@Override
|
||||
public void performQuit() {
|
||||
shutdownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelQuit() {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void minimize() {
|
||||
window.setIconified(true);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void showPreferences() {
|
||||
application.showPreferencesWindow(SelectedPreferencesTab.ANY);
|
||||
@@ -91,5 +114,7 @@ public class MainWindowTitleController implements FxController {
|
||||
return updateAvailable.get();
|
||||
}
|
||||
|
||||
|
||||
public boolean isMinimizeToSysTray() {
|
||||
return minimizeToSysTray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,14 @@
|
||||
<Tooltip text="%main.preferencesBtn.tooltip"/>
|
||||
</tooltip>
|
||||
</Button>
|
||||
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#minimize" focusTraversable="false" visible="${!controller.minimizeToSysTray}" managed="${!controller.minimizeToSysTray}">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="WINDOW_MINIMIZE" glyphSize="12"/>
|
||||
</graphic>
|
||||
<tooltip>
|
||||
<Tooltip text="%main.minimizeBtn.tooltip"/>
|
||||
</tooltip>
|
||||
</Button>
|
||||
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" onAction="#close" focusTraversable="false">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="TIMES" glyphSize="16"/>
|
||||
|
||||
@@ -135,6 +135,7 @@ preferences.donationKey.getDonationKey=Get a donation key
|
||||
|
||||
# Main Window
|
||||
main.closeBtn.tooltip=Close
|
||||
main.minimizeBtn.tooltip=Minimize
|
||||
main.preferencesBtn.tooltip=Preferences
|
||||
main.donationKeyMissing.tooltip=Please consider donating
|
||||
## Drag 'n' Drop
|
||||
|
||||
Reference in New Issue
Block a user