Skip to content

Commit 9b54b08

Browse files
feat: hide settings button (close #290)
1 parent a3d00fe commit 9b54b08

File tree

8 files changed

+22
-9
lines changed

8 files changed

+22
-9
lines changed

src/shell/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct config {
9494
bool reverse_if_open_to_up = true;
9595
bool experimental_ownerdraw_support = false;
9696
bool hotkeys = true;
97+
bool show_settings_button = true;
9798

9899
// debug purpose only
99100
bool search_large_dwItemData_range = false;

src/shell/script/binding_qjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ template<> struct js_bind<mb_shell::js::breeze> {
11401140
.static_fun<&mb_shell::js::breeze::is_light_theme>("is_light_theme")
11411141
.static_fun<&mb_shell::js::breeze::user_language>("user_language")
11421142
.static_fun<&mb_shell::js::breeze::set_can_reload_js>("set_can_reload_js")
1143+
.static_fun<&mb_shell::js::breeze::should_show_settings_button>("should_show_settings_button")
11431144
;
11441145
}
11451146
};

src/shell/script/binding_types.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ std::string breeze::version() { return BREEZE_VERSION; }
624624
std::string breeze::data_directory() {
625625
return config::data_directory().generic_string();
626626
}
627+
bool breeze::should_show_settings_button() {
628+
return mb_shell::config::current->context_menu.show_settings_button;
629+
}
627630
std::vector<std::string> fs::readdir(std::string path) {
628631
std::vector<std::string> result;
629632
std::ranges::copy(std::filesystem::directory_iterator(path) |

src/shell/script/binding_types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@ export class breeze {
10751075
* @returns void
10761076
*/
10771077
static set_can_reload_js(can: boolean): void
1078+
static should_show_settings_button(): boolean
10781079
}
10791080
export class win32 {
10801081
/**

src/shell/script/binding_types.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ struct breeze {
632632
static bool is_light_theme();
633633
static std::string user_language();
634634
static void set_can_reload_js(bool can);
635+
static bool should_show_settings_button();
635636
};
636637

637638
struct win32 {

src/shell/script/script.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/shell/script/ts/src/config_page/ContextMenuConfig.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ const ContextMenuConfig = memo(() => {
143143
setNestedValue(newConfig, "hotkeys", v);
144144
update(newConfig);
145145
}} />
146+
<Toggle label={t("在左上角显示设置按钮")} value={getNestedValue(config, "show_settings_button") ?? true} onChange={(v) => {
147+
const newConfig = { ...config };
148+
setNestedValue(newConfig, "show_settings_button", v);
149+
update(newConfig);
150+
}} />
146151
</flex>
147152
</flex>
148153
);

src/shell/script/ts/src/entry.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ shell.menu_controller.add_menu_listener(ctx => {
2929
})
3030
}
3131

32-
ctx.screenside_button.add_button(SVG_CONFIG, () => {
33-
ctx.menu.close()
34-
showConfigPage()
35-
})
32+
if (shell.breeze.should_show_settings_button())
33+
ctx.screenside_button.add_button(SVG_CONFIG, () => {
34+
ctx.menu.close()
35+
showConfigPage()
36+
})
3637

3738
// fixtures
3839
for (const items of ctx.menu.items) {

0 commit comments

Comments
 (0)