From caadc4ebfdb071c7efa2f4ac1f90805480bfc6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E9=87=8C=E4=B8=8D=E7=9F=A5=E8=BA=AB=E6=98=AF?= =?UTF-8?q?=E5=AE=A2?= Date: Sat, 16 Sep 2023 16:03:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E6=96=B0=E5=A2=9EScreenColorPick?= =?UTF-8?q?erHideWindow=E9=85=8D=E7=BD=AE=20(#734)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(core): 新增ScreenColorPickerHideWindow配置 * build: linter工作流优化 --- .github/workflows/linter.yml | 2 +- .../core/javafx/controller/PreferencesView.java | 7 ++++++- .../javafx/controller/SystemSettingController.java | 4 +++- .../core/javafx/stage/ScreenColorPickerStage.java | 13 +++++++++++++ .../main/java/com/tlcsdm/core/javafx/util/Keys.java | 3 ++- .../tlcsdm/core/javafx/view/SystemSettingView.java | 7 ++----- .../com/tlcsdm/core/fxml/SystemSetting.fxml | 3 +++ .../com/tlcsdm/core/i18n/messages_en.properties | 1 + .../com/tlcsdm/core/i18n/messages_ja.properties | 1 + .../com/tlcsdm/core/i18n/messages_zh.properties | 1 + 10 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 680b3b8b3..8d1cb1cf5 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -52,4 +52,4 @@ jobs: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.CHANGELOG }} - FILTER_REGEX_EXCLUDE: .*.md \ No newline at end of file + FILTER_REGEX_INCLUDE: .*.java,.*.md,.*.groovy diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controller/PreferencesView.java b/core/src/main/java/com/tlcsdm/core/javafx/controller/PreferencesView.java index 56bb0dc68..1742b1a08 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/controller/PreferencesView.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/controller/PreferencesView.java @@ -52,6 +52,7 @@ public class PreferencesView extends StackPane { BooleanProperty saveStageBound = new SimpleBooleanProperty(true); BooleanProperty checkForUpdatesAtStartup = new SimpleBooleanProperty(true); BooleanProperty screenshotHideWindow = new SimpleBooleanProperty(true); + BooleanProperty screenColorPickerHideWindow = new SimpleBooleanProperty(true); public PreferencesView() { preferencesFx = createPreferences(); @@ -77,7 +78,11 @@ private PreferencesFx createPreferences() { Category.of("core.menubar.tool", Group.of( Setting.of("core.dialog.systemSetting.check.screenshotHideWindow", screenshotHideWindow)) - .description("core.menubar.setting.screenshot")))) + .description("core.menubar.setting.screenshot"), + Group.of( + Setting.of("core.dialog.systemSetting.check.screenColorPickerHideWindow", screenColorPickerHideWindow)) + .description("core.menubar.setting.colorPicker") + ))) .i18n(rbs).persistWindowState(false).saveSettings(true).debugHistoryMode(false).buttonsVisibility(true) .instantPersistent(false).dialogTitle(I18nUtils.get("core.button.preferences")).dialogIcon(FxApp.appIcon); } diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controller/SystemSettingController.java b/core/src/main/java/com/tlcsdm/core/javafx/controller/SystemSettingController.java index b16d6e528..40151a137 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/controller/SystemSettingController.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/controller/SystemSettingController.java @@ -38,7 +38,7 @@ /** * 设置页面 * - * @author xufeng + * @author unknowIfGuestInDream */ public class SystemSettingController extends SystemSettingView { @@ -53,6 +53,7 @@ private void initView() { saveStageBoundCheckBox.setSelected(Config.getBoolean(Keys.RememberWindowLocation, true)); checkForUpdatesAtStartupCheckBox.setSelected(Config.getBoolean(Keys.CheckForUpdatesAtStartup, true)); screenshotHideWindowCheckBox.setSelected(Config.getBoolean(Keys.ScreenshotHideWindow, true)); + screenColorPickerHideWindowCheckBox.setSelected(Config.getBoolean(Keys.ScreenColorPickerHideWindow, true)); } catch (Exception e) { StaticLog.error("Init setting failed: ", e); } @@ -64,6 +65,7 @@ public void applySettings() { Config.set(Keys.RememberWindowLocation, saveStageBoundCheckBox.isSelected()); Config.set(Keys.CheckForUpdatesAtStartup, checkForUpdatesAtStartupCheckBox.isSelected()); Config.set(Keys.ScreenshotHideWindow, screenshotHideWindowCheckBox.isSelected()); + Config.set(Keys.ScreenColorPickerHideWindow, screenColorPickerHideWindowCheckBox.isSelected()); } catch (Exception e) { StaticLog.error("Save setting failed: ", e); } diff --git a/core/src/main/java/com/tlcsdm/core/javafx/stage/ScreenColorPickerStage.java b/core/src/main/java/com/tlcsdm/core/javafx/stage/ScreenColorPickerStage.java index 22836b017..58274a95f 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/stage/ScreenColorPickerStage.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/stage/ScreenColorPickerStage.java @@ -28,6 +28,8 @@ package com.tlcsdm.core.javafx.stage; import com.tlcsdm.core.javafx.FxApp; +import com.tlcsdm.core.javafx.util.Config; +import com.tlcsdm.core.javafx.util.Keys; import com.tlcsdm.core.javafx.util.OSUtil; import com.tlcsdm.core.javafx.util.PaintConvertUtil; import com.tlcsdm.core.util.I18nUtils; @@ -75,8 +77,16 @@ public class ScreenColorPickerStage extends Stage { private Rectangle previewRect; private Label colorLabel; + private final boolean hideMainStage; + public ScreenColorPickerStage() { this.initOwner(FxApp.primaryStage); + this.hideMainStage = Config.getBoolean(Keys.ScreenColorPickerHideWindow, true); + if (hideMainStage) { + // 如果设置TRANSPARENT样式时 {@code stage.initStyle(StageStyle.TRANSPARENT);} + // 可以通过 FxApp.primaryStage.setIconified(true); 来隐藏窗口 + FxApp.primaryStage.setOpacity(0); + } screenScaleX = Screen.getPrimary().getOutputScaleX(); screenScaleY = Screen.getPrimary().getOutputScaleY(); fxScreenWidth = Screen.getPrimary().getBounds().getWidth(); @@ -188,6 +198,9 @@ private Pane createPreviewPane() { private void endPickColor() { rootPane.setVisible(false); + if (hideMainStage) { + FxApp.primaryStage.setOpacity(1); + } setAlwaysOnTop(false); this.hide(); } diff --git a/core/src/main/java/com/tlcsdm/core/javafx/util/Keys.java b/core/src/main/java/com/tlcsdm/core/javafx/util/Keys.java index cec51f24b..df4994b7c 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/util/Keys.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/util/Keys.java @@ -47,7 +47,8 @@ public enum Keys { RememberWindowLocation("rememberWindowLocation"), ConfirmExit("confirmExit"), CheckForUpdatesAtStartup("checkForUpdatesAtStartup"), - ScreenshotHideWindow("screenshotHideWindow"); + ScreenshotHideWindow("screenshotHideWindow"), + ScreenColorPickerHideWindow("screenColorPickerHideWindow"); private final String keyName; diff --git a/core/src/main/java/com/tlcsdm/core/javafx/view/SystemSettingView.java b/core/src/main/java/com/tlcsdm/core/javafx/view/SystemSettingView.java index f23630208..2e9aed398 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/view/SystemSettingView.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/view/SystemSettingView.java @@ -41,19 +41,16 @@ public abstract class SystemSettingView implements Initializable { @FXML protected CheckBox exitShowAlertCheckBox; - @FXML protected CheckBox saveStageBoundCheckBox; - @FXML protected CheckBox checkForUpdatesAtStartupCheckBox; - @FXML protected CheckBox screenshotHideWindowCheckBox; - + @FXML + protected CheckBox screenColorPickerHideWindowCheckBox; @FXML protected Button saveButton; - @FXML protected Button cancelButton; } diff --git a/core/src/main/resources/com/tlcsdm/core/fxml/SystemSetting.fxml b/core/src/main/resources/com/tlcsdm/core/fxml/SystemSetting.fxml index b5c115d09..fc03cc73f 100644 --- a/core/src/main/resources/com/tlcsdm/core/fxml/SystemSetting.fxml +++ b/core/src/main/resources/com/tlcsdm/core/fxml/SystemSetting.fxml @@ -48,4 +48,7 @@ + + diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties index 509bea0bf..00ae1fe9b 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties @@ -50,6 +50,7 @@ core.dialog.systemSetting.check.confirmExit=Whether to show a confirmation dialo core.dialog.systemSetting.check.rememberWindowLocation=Whether to save the window size and position information when exiting core.dialog.systemSetting.check.checkForUpdatesAtStartup=Check for updates at startup core.dialog.systemSetting.check.screenshotHideWindow=Minimize window when taking screenshots +core.dialog.systemSetting.check.screenColorPickerHideWindow=Minimize window when taking screenColorPicker core.menubar.file=File core.menubar.file.restart=Restart core.menubar.file.exit=Exit diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties index 1762725aa..f3847be01 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties @@ -50,6 +50,7 @@ core.dialog.systemSetting.check.confirmExit=\u7D42\u4E86\u6642\u306B\u78BA\u8A8D core.dialog.systemSetting.check.rememberWindowLocation=\u7D42\u4E86\u6642\u306B\u30A6\u30A3\u30F3\u30C9\u30A6\u306E\u30B5\u30A4\u30BA\u3068\u4F4D\u7F6E\u60C5\u5831\u3092\u4FDD\u5B58\u3059\u308B\u304B\u3069\u3046\u304B core.dialog.systemSetting.check.checkForUpdatesAtStartup=\u8D77\u52D5\u6642\u306B\u66F4\u65B0\u30D7\u30ED\u30B0\u30E9\u30E0\u3092\u78BA\u8A8D\u3059\u308B core.dialog.systemSetting.check.screenshotHideWindow=\u30B9\u30AF\u30EA\u30FC\u30F3\u30B7\u30E7\u30C3\u30C8\u64AE\u5F71\u6642\u306B\u30A6\u30A3\u30F3\u30C9\u30A6\u3092\u6700\u5C0F\u5316 +core.dialog.systemSetting.check.screenColorPickerHideWindow=\u753B\u9762\u306E\u30AB\u30E9\u30FC\u30D4\u30C3\u30AB\u30FC\u3092\u53D6\u5F97\u3059\u308B\u969B\u306B\u30A6\u30A3\u30F3\u30C9\u30A6\u3092\u6700\u5C0F\u5316\u3059\u308B core.menubar.file=\u30D5\u30A1\u30A4\u30EB core.menubar.file.restart=\u518D\u8D77\u52D5 core.menubar.file.exit=\u7D42\u4E86\u3059\u308B diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties index 9aaa3fe7f..6680f8c7c 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties @@ -50,6 +50,7 @@ core.dialog.systemSetting.check.confirmExit=\u9000\u51FA\u65F6\u662F\u5426\u663E core.dialog.systemSetting.check.rememberWindowLocation=\u662F\u5426\u5728\u9000\u51FA\u65F6\u4FDD\u5B58\u7A97\u53E3\u5927\u5C0F\u53CA\u4F4D\u7F6E\u4FE1\u606F core.dialog.systemSetting.check.checkForUpdatesAtStartup=\u542F\u52A8\u65F6\u68C0\u67E5\u66F4\u65B0 core.dialog.systemSetting.check.screenshotHideWindow=\u622A\u5C4F\u65F6\u6700\u5C0F\u5316\u7A97\u53E3 +core.dialog.systemSetting.check.screenColorPickerHideWindow=\u989C\u8272\u63D0\u53D6\u65F6\u6700\u5C0F\u5316\u7A97\u53E3 core.menubar.file=\u6587\u4EF6 core.menubar.file.restart=\u91CD\u542F core.menubar.file.exit=\u9000\u51FA