Skip to content

Commit 9c888e5

Browse files
committed
(feat) Synchronize the scrolls of input/ouput boxes
1 parent 5e87add commit 9c888e5

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2023-08-18 -- v0.8.3
2+
-- Synchronize the scrolls of input/ouput boxes.
3+
14
2023-08-17 -- v0.8.2
25
-- `txt` as a default extension for saving/opening file.
36

negar_gui/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import platform
22
from pathlib import Path
33

4-
__version__ = "0.8.2"
4+
__version__ = "0.8.3"
55

66
APPDATA = "AppData/Roaming/" if platform.system() == "Windows" else "."
77
SETTING_FILE = Path.home() / f"{APPDATA}negar-gui/settings.toml"

negar_gui/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,26 @@ def connectSlots(self):
406406
)
407407
)
408408

409+
self.input_editor.verticalScrollBar().valueChanged.connect(self._sync_inout_scroll)
410+
self.output_editor.verticalScrollBar().valueChanged.connect(self._sync_inout_scroll)
411+
409412
####################### SLOTs ###############################
413+
def _sync_inout_scroll(self, value):
414+
max_in_scroll = self.input_editor.verticalScrollBar().maximum()
415+
max_out_scroll = self.output_editor.verticalScrollBar().maximum()
416+
sender = self.sender()
417+
if sender == self.input_editor.verticalScrollBar() and max_in_scroll!=0:
418+
new_value = int(value/max_in_scroll * max_out_scroll)
419+
self.output_editor.verticalScrollBar().valueChanged.disconnect(self._sync_inout_scroll)
420+
self.output_editor.verticalScrollBar().setValue(new_value)
421+
self.output_editor.verticalScrollBar().valueChanged.connect(self._sync_inout_scroll)
422+
423+
elif sender == self.output_editor.verticalScrollBar() and max_out_scroll!=0:
424+
new_value = int(value/max_out_scroll * max_in_scroll)
425+
self.input_editor.verticalScrollBar().valueChanged.disconnect(self._sync_inout_scroll)
426+
self.input_editor.verticalScrollBar().setValue(new_value)
427+
self.input_editor.verticalScrollBar().valueChanged.connect(self._sync_inout_scroll)
428+
410429
def full_screen_input_slot(self):
411430
(
412431
self._grid_full_input() if self.actionFull_Screen_Input.isChecked() else

0 commit comments

Comments
 (0)