mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
Keep the settings window inside the screen
Only two tabs scrolled, so the rest handed their full content height to the window as a minimum. The API tab alone asked for 668px, which put the window's minimum at 756px: taller than a laptop screen has room for once the menu bar and dock have taken theirs, and unshrinkable, so Save sat off the bottom edge. Every tab scrolls now, and the opening size is clamped to what the screen actually offers. The program path in the local model box was clipped to one line for a related reason: it shares a form row with a button, and the row is measured before its width is known. WrappedLabel re-measures against the width it ends up with and claims that height back.
This commit is contained in:
@@ -133,6 +133,32 @@ class Settings(DikteTest):
|
||||
self.assertEqual(tabs.count(), 9)
|
||||
self.assertEqual(window.windowTitle(), "Dikte Settings")
|
||||
|
||||
def test_no_tab_can_stretch_the_window_past_a_small_screen(self):
|
||||
# A tab that keeps its full height hands that height to the window as a
|
||||
# minimum, and a tall one then carries Save off the bottom of a laptop
|
||||
# screen with no way to drag it back. Each tab scrolls instead.
|
||||
window = self.window(cfg.Config())
|
||||
for index in range(window.tabs.count()):
|
||||
window.tabs.setCurrentIndex(index)
|
||||
self.assertLess(window.minimumSizeHint().height(), 500,
|
||||
window.tabs.tabText(index))
|
||||
|
||||
def test_a_wrapped_label_keeps_the_room_its_lines_need(self):
|
||||
# The program path shares a row with a button, and a row is measured
|
||||
# before its width is known: the label has to claim the second line back
|
||||
# itself, and give it up again when the window is widened.
|
||||
label = settings_ui.WrappedLabel()
|
||||
# Shown, because a hidden widget is told about its new size only once
|
||||
# somebody looks at it, and the height is worked out from that size.
|
||||
label.show()
|
||||
self.addCleanup(label.deleteLater)
|
||||
line = label.fontMetrics().height()
|
||||
label.resize(120, line)
|
||||
label.setText("Installed on the system: /opt/homebrew/bin/whisper-server")
|
||||
self.assertGreater(label.minimumHeight(), line)
|
||||
label.resize(2000, line)
|
||||
self.assertLessEqual(label.minimumHeight(), line)
|
||||
|
||||
def test_saving_without_touching_anything_changes_nothing(self):
|
||||
"""Every widget has to load what is stored, or Save writes its default
|
||||
over it. This says so for the whole table at once."""
|
||||
|
||||
Reference in New Issue
Block a user