File tree Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Expand file tree Collapse file tree 5 files changed +37
-23
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export type MainMessage = {
15
15
"reload-full-app" : ( ) => void ;
16
16
"save-last-tab" : ( index : number ) => void ;
17
17
"switch-server-tab" : ( index : number ) => void ;
18
+ "sync-zooms" : ( ) => void ;
18
19
"toggle-app" : ( ) => void ;
19
20
"toggle-badge-option" : ( newValue : boolean ) => void ;
20
21
"toggle-menubar" : ( showMenubar : boolean ) => void ;
@@ -23,7 +24,6 @@ export type MainMessage = {
23
24
"update-badge" : ( messageCount : number ) => void ;
24
25
"update-menu" : ( properties : MenuProperties ) => void ;
25
26
"update-taskbar-icon" : ( data : string , text : string ) => void ;
26
- "zoom-other-tabs" : ( zoomLevel : number ) => void ;
27
27
} ;
28
28
29
29
export type MainCall = {
@@ -65,6 +65,7 @@ export type RendererMessage = {
65
65
"show-keyboard-shortcuts" : ( ) => void ;
66
66
"show-notification-settings" : ( ) => void ;
67
67
"switch-server-tab" : ( index : number ) => void ;
68
+ "sync-zooms" : ( ) => void ;
68
69
"tab-devtools" : ( ) => void ;
69
70
"toggle-autohide-menubar" : (
70
71
autoHideMenubar : boolean ,
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ function createMainWindow(): BrowserWindow {
154
154
app . quit ( ) ;
155
155
return ;
156
156
}
157
-
157
+
158
158
await app . whenReady ( ) ;
159
159
160
160
if ( process . env . GDK_BACKEND !== GDK_BACKEND ) {
@@ -279,13 +279,6 @@ function createMainWindow(): BrowserWindow {
279
279
}
280
280
} ) ;
281
281
282
- ipcMain . on ( "zoom-other-tabs" , ( event , zoomLevel ) => {
283
- const windows = BrowserWindow . getAllWindows ( ) ;
284
- for ( const window of windows ) {
285
- window . webContents . setZoomLevel ( zoomLevel ) ;
286
- }
287
- } ) ;
288
-
289
282
ipcMain . on ( "fetch-user-agent" , ( event ) => {
290
283
event . returnValue = session
291
284
. fromPartition ( "persist:webviewsession" )
Original file line number Diff line number Diff line change @@ -158,19 +158,24 @@ export default class WebView {
158
158
this . show ( ) ;
159
159
}
160
160
161
+ getZoomFactor ( ) : number {
162
+ return this . getWebContents ( ) . getZoomFactor ( ) ;
163
+ }
164
+
165
+ setZoomFactor ( value : number ) : void {
166
+ this . getWebContents ( ) . setZoomFactor ( value ) ;
167
+ }
168
+
161
169
zoomIn ( ) : void {
162
170
this . getWebContents ( ) . zoomLevel += 0.5 ;
163
- this . syncZooms ( ) ;
164
171
}
165
172
166
173
zoomOut ( ) : void {
167
174
this . getWebContents ( ) . zoomLevel -= 0.5 ;
168
- this . syncZooms ( ) ;
169
175
}
170
176
171
177
zoomActualSize ( ) : void {
172
178
this . getWebContents ( ) . zoomLevel = 0 ;
173
- this . syncZooms ( ) ;
174
179
}
175
180
176
181
logOut ( ) : void {
@@ -227,15 +232,6 @@ export default class WebView {
227
232
ipcRenderer . send ( "forward-to" , this . webContentsId , channel , ...arguments_ ) ;
228
233
}
229
234
230
- private syncZooms ( ) : void {
231
- // Sync zoom level with other tabs if useOneZoom is enabled
232
- const useOneZoom = ConfigUtil . getConfigItem ( "useOneZoom" , true ) ;
233
- if ( useOneZoom ) {
234
- const zoomLevel = this . getWebContents ( ) . getZoomLevel ( ) ;
235
- ipcRenderer . send ( "zoom-other-tabs" , zoomLevel ) ;
236
- }
237
- }
238
-
239
235
private registerListeners ( ) : void {
240
236
const webContents = this . getWebContents ( ) ;
241
237
Original file line number Diff line number Diff line change @@ -887,18 +887,21 @@ export class ServerManagerView {
887
887
"zoomIn" ,
888
888
( webview ) => {
889
889
webview . zoomIn ( ) ;
890
+ this . syncZooms ( webview . getZoomFactor ( ) ) ;
890
891
} ,
891
892
] ,
892
893
[
893
894
"zoomOut" ,
894
895
( webview ) => {
895
896
webview . zoomOut ( ) ;
897
+ this . syncZooms ( webview . getZoomFactor ( ) ) ;
896
898
} ,
897
899
] ,
898
900
[
899
901
"zoomActualSize" ,
900
902
( webview ) => {
901
903
webview . zoomActualSize ( ) ;
904
+ this . syncZooms ( webview . getZoomFactor ( ) ) ;
902
905
} ,
903
906
] ,
904
907
[
@@ -1085,6 +1088,10 @@ export class ServerManagerView {
1085
1088
} ,
1086
1089
) ;
1087
1090
1091
+ ipcRenderer . on ( "sync-zooms" , ( ) => {
1092
+ this . syncZooms ( ) ;
1093
+ } ) ;
1094
+
1088
1095
ipcRenderer . on ( "enter-fullscreen" , ( ) => {
1089
1096
this . $fullscreenPopup . classList . add ( "show" ) ;
1090
1097
this . $fullscreenPopup . classList . remove ( "hidden" ) ;
@@ -1177,6 +1184,23 @@ export class ServerManagerView {
1177
1184
await dingSound . play ( ) ;
1178
1185
} ) ;
1179
1186
}
1187
+
1188
+ private syncZooms ( value = 1 ) : void {
1189
+ const shouldUseOneZoom = ConfigUtil . getConfigItem ( "useOneZoom" , true ) ;
1190
+ if ( shouldUseOneZoom ) {
1191
+ for ( const tab of this . tabs ) {
1192
+ if ( tab instanceof ServerTab ) {
1193
+ tab . webview
1194
+ . then ( ( webv ) => {
1195
+ webv . setZoomFactor ( value ) ;
1196
+ } )
1197
+ . catch ( ( error ) => {
1198
+ console . error ( "Error syncing zoom factors:" , error ) ;
1199
+ } ) ;
1200
+ }
1201
+ }
1202
+ }
1203
+ }
1180
1204
}
1181
1205
1182
1206
window . addEventListener ( "load" , async ( ) => {
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {
128
128
</ div >
129
129
< div class ="setting-row " id ="one-zoom-option ">
130
130
< div class ="setting-description ">
131
- ${ t . __ ( "Use one zoom for all server tabs" ) }
131
+ ${ t . __ ( "Use one zoom for all organization tabs" ) }
132
132
</ div >
133
133
< div class ="setting-control "> </ div >
134
134
</ div >
@@ -279,7 +279,7 @@ export function initGeneralSection({$root}: GeneralSectionProperties): void {
279
279
ConfigUtil . setConfigItem ( "useOneZoom" , newValue ) ;
280
280
useOneZoom ( ) ;
281
281
if ( newValue ) {
282
- ipcRenderer . send ( "zoom-other-tabs" , 1 ) ;
282
+ ipcRenderer . send ( "sync-zooms" ) ;
283
283
}
284
284
} ,
285
285
} ) ;
You can’t perform that action at this time.
0 commit comments