Browse Source

[App] Override autostart in Viewer

- Option added in preferences to override auto-switching to Viewer when
opening a presentation file.

Fixes #4
master
Bogdan Cordier 1 year ago
parent
commit
fbce336325
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      hadaly/app.py

+ 6
- 1
hadaly/app.py View File

@@ -69,9 +69,11 @@ class HadalyApp(App):
69 69
         return root
70 70
 
71 71
     def build_config(self, config):
72
+        config.add_section('general')
72 73
         config.add_section('viewer')
73 74
         config.add_section('editor')
74 75
         config.add_section('search')
76
+        config.set('general', 'switch_on_start', 1)
75 77
         config.set('editor', 'autosave_time', '15')
76 78
         config.set('editor', 'autosave', '0')
77 79
         config.set('editor', 'font_size', '12')
@@ -92,17 +94,20 @@ class HadalyApp(App):
92 94
             if argv[1].endswith('.opah') and tarfile.is_tarfile(argv[1]):
93 95
                 self.load_presentation(os.path.dirname(argv[1]), [os.path.basename(argv[1])])
94 96
                 Logger.info('Application: file \'{file}\' loaded'.format(file=self.filename))
95
-                self.root.current = 'viewer'
96 97
         except IndexError:
97 98
             pass
98 99
 
99 100
     def load_presentation(self, path, filename):
100 101
         if len(self.root.get_screen('editor').slides_view.grid_layout.children) > 0:
101 102
             self.clear()
103
+
102 104
         self.extract_opah(path, filename)
103 105
         self.load_json()
104 106
         self.load_slides(path, filename)
105 107
 
108
+        if self.config.getint('general', 'switch_on_start'):
109
+            self.root.current = 'viewer'
110
+
106 111
     def extract_opah(self, path, filename):
107 112
 
108 113
         try:

Loading…
Cancel
Save