Skip to content

Commit

Permalink
feat(core): 新增ScreenColorPickerHideWindow配置 (#734)
Browse files Browse the repository at this point in the history
* feat(core): 新增ScreenColorPickerHideWindow配置

* build: linter工作流优化
  • Loading branch information
unknowIfGuestInDream committed Sep 16, 2023
1 parent ee1deaf commit caadc4e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.CHANGELOG }}
FILTER_REGEX_EXCLUDE: .*.md
FILTER_REGEX_INCLUDE: .*.java,.*.md,.*.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/**
* 设置页面
*
* @author xufeng
* @author unknowIfGuestInDream
*/
public class SystemSettingController extends SystemSettingView {

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -188,6 +198,9 @@ private Pane createPreviewPane() {

private void endPickColor() {
rootPane.setVisible(false);
if (hideMainStage) {
FxApp.primaryStage.setOpacity(1);
}
setAlwaysOnTop(false);
this.hide();
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/com/tlcsdm/core/javafx/util/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public enum Keys {
RememberWindowLocation("rememberWindowLocation"),
ConfirmExit("confirmExit"),
CheckForUpdatesAtStartup("checkForUpdatesAtStartup"),
ScreenshotHideWindow("screenshotHideWindow");
ScreenshotHideWindow("screenshotHideWindow"),
ScreenColorPickerHideWindow("screenColorPickerHideWindow");

private final String keyName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@
<!--截屏时最小化窗口-->
<CheckBox fx:id="screenshotHideWindowCheckBox" selected="true"
text="%core.dialog.systemSetting.check.screenshotHideWindow"/>
<!--颜色提取时最小化窗口-->
<CheckBox fx:id="screenColorPickerHideWindowCheckBox" selected="true"
text="%core.dialog.systemSetting.check.screenColorPickerHideWindow"/>
</VBox>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit caadc4e

Please sign in to comment.