!172 修复简陋的锁定图标

Merge pull request !172 from Sky/release-v1.1.14
This commit is contained in:
Luke 2024-04-10 12:03:12 +00:00 committed by Gitee
commit e4bb8cfa17
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 17 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import javafx.scene.Node;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import org.jcnc.jnotepad.api.core.views.manager.builder.BottomStatusBoxButtonBuilder; import org.jcnc.jnotepad.api.core.views.manager.builder.BottomStatusBoxButtonBuilder;
import org.jcnc.jnotepad.app.common.constants.TextConstants; import org.jcnc.jnotepad.app.common.constants.TextConstants;
@ -20,7 +22,6 @@ import org.kordamp.ikonli.javafx.FontIcon;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.LOCK;
import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.UNLOCK; import static org.kordamp.ikonli.antdesignicons.AntDesignIconsFilled.UNLOCK;
/** /**
@ -220,17 +221,27 @@ public class BottomStatusBoxManager {
* @param tab the tab to update the read-only property for * @param tab the tab to update the read-only property for
* @param tabs the list of tabs in the center tab pane * @param tabs the list of tabs in the center tab pane
*/ */
public void updateReadOnlyProperty(CenterTab tab, ObservableList<Tab> tabs) { public void updateReadOnlyProperty(CenterTab tab, ObservableList<Tab> tabs) {
Button readOnlyButton = BOTTOM_STATUS_BOX.getReadOnlyButton(); Button readOnlyButton = BOTTOM_STATUS_BOX.getReadOnlyButton();
readOnlyButton.setStyle("-fx-background-color: rgb(230, 230, 230);");
readOnlyButton.setVisible(!tabs.isEmpty()); readOnlyButton.setVisible(!tabs.isEmpty());
FontIcon icon;
ImageView icon;
double iconSize = 20; // 修改圖標大小
if (tab.getTextCodeArea().isEditable()) { if (tab.getTextCodeArea().isEditable()) {
icon = FontIcon.of(UNLOCK); icon = new ImageView(new Image("file:src/main/resources/jcnc/app/images/unlock.png"));
readOnlyButton.setGraphic(icon);
} else { } else {
icon = FontIcon.of(LOCK); icon = new ImageView(new Image("file:src/main/resources/jcnc/app/images/lock.png"));
readOnlyButton.setGraphic(icon);
} }
icon.setFitWidth(iconSize); // 設置圖標寬度
icon.setFitHeight(iconSize); // 設置圖標高度
readOnlyButton.setGraphic(icon);
tab.getReadOnly().setSelected(!tab.getTextCodeArea().isEditable()); tab.getReadOnly().setSelected(!tab.getTextCodeArea().isEditable());
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB