def get_window(via_ipc, force_window=False, force_tab=False, force_target=None): """Helper function for app.py to get a window id. Args: via_ipc: Whether the request was made via IPC. force_window: Whether to force opening in a window. force_tab: Whether to force opening in a tab. force_target: Override the new-instance-open-target config """ if force_window and force_tab: raise ValueError("force_window and force_tab are mutually exclusive!") if not via_ipc: # Initial main window return 0 window_to_raise = None if force_target is not None: open_target = force_target else: open_target = config.get('general', 'new-instance-open-target') if (open_target == 'window' or force_window) and not force_tab: window = MainWindow() window.show() win_id = window.win_id window_to_raise = window else: try: win_mode = config.get('general', 'new-instance-open-target.window') if win_mode == 'last-focused': window = objreg.last_focused_window() elif win_mode == 'last-opened': window = objreg.last_window() elif win_mode == 'last-visible': window = objreg.last_visible_window() except objreg.NoWindow: # There is no window left, so we open a new one window = MainWindow() window.show() win_id = window.win_id window_to_raise = window win_id = window.win_id if open_target not in ['tab-silent', 'tab-bg-silent']: window_to_raise = window if window_to_raise is not None: window_to_raise.setWindowState( window.windowState() & ~Qt.WindowMinimized | Qt.WindowActive) window_to_raise.raise_() window_to_raise.activateWindow() QApplication.instance().alert(window_to_raise) return win_id
def get_window(via_ipc, force_window=False, force_tab=False, force_target=None): """Helper function for app.py to get a window id. Args: via_ipc: Whether the request was made via IPC. force_window: Whether to force opening in a window. force_tab: Whether to force opening in a tab. force_target: Override the new-instance-open-target config """ if force_window and force_tab: raise ValueError("force_window and force_tab are mutually exclusive!") if not via_ipc: # Initial main window return 0 window_to_raise = None if force_target is not None: open_target = force_target else: open_target = config.get('general', 'new-instance-open-target') if (open_target == 'window' or force_window) and not force_tab: window = MainWindow() window.show() win_id = window.win_id window_to_raise = window else: try: window = objreg.last_window() except objreg.NoWindow: # There is no window left, so we open a new one window = MainWindow() window.show() win_id = window.win_id window_to_raise = window win_id = window.win_id if open_target not in ('tab-silent', 'tab-bg-silent'): window_to_raise = window if window_to_raise is not None: window_to_raise.setWindowState(window.windowState() & ~Qt.WindowMinimized | Qt.WindowActive) window_to_raise.raise_() window_to_raise.activateWindow() QApplication.instance().alert(window_to_raise) return win_id
def _get_window(self, via_ipc, force_window=False, force_tab=False): """Helper function for process_args to get a window id. Args: via_ipc: Whether the request was made via IPC. force_window: Whether to force opening in a window. force_tab: Whether to force opening in a tab. """ if force_window and force_tab: raise ValueError("force_window and force_tab are mutually " "exclusive!") if not via_ipc: # Initial main window return 0 window_to_raise = None open_target = config.get('general', 'new-instance-open-target') if (open_target == 'window' or force_window) and not force_tab: win_id = mainwindow.MainWindow.spawn() window = objreg.get('main-window', scope='window', window=win_id) window_to_raise = window else: try: window = objreg.last_window() except objreg.NoWindow: # There is no window left, so we open a new one win_id = mainwindow.MainWindow.spawn() window = objreg.get('main-window', scope='window', window=win_id) window_to_raise = window win_id = window.win_id if open_target != 'tab-silent': window_to_raise = window if window_to_raise is not None: window_to_raise.setWindowState(window.windowState() & ~Qt.WindowMinimized | Qt.WindowActive) window_to_raise.raise_() window_to_raise.activateWindow() self.alert(window_to_raise) return win_id
def _get_window(self, via_ipc, force_window=False, force_tab=False): """Helper function for process_pos_args to get a window id. Args: via_ipc: Whether the request was made via IPC. force_window: Whether to force opening in a window. force_tab: Whether to force opening in a tab. """ if force_window and force_tab: raise ValueError("force_window and force_tab are mutually " "exclusive!") if not via_ipc: # Initial main window return 0 window_to_raise = None open_target = config.get('general', 'new-instance-open-target') if (open_target == 'window' or force_window) and not force_tab: window = mainwindow.MainWindow() window.show() win_id = window.win_id window_to_raise = window else: try: window = objreg.last_window() except objreg.NoWindow: # There is no window left, so we open a new one window = mainwindow.MainWindow() window.show() win_id = window.win_id window_to_raise = window win_id = window.win_id if open_target != 'tab-silent': window_to_raise = window if window_to_raise is not None: window_to_raise.setWindowState(window.windowState() & ~Qt.WindowMinimized | Qt.WindowActive) window_to_raise.raise_() window_to_raise.activateWindow() self.alert(window_to_raise) return win_id
def get_window(via_ipc, force_window=False, force_tab=False): """Helper function for app.py to get a window id. Args: via_ipc: Whether the request was made via IPC. force_window: Whether to force opening in a window. force_tab: Whether to force opening in a tab. """ if force_window and force_tab: raise ValueError("force_window and force_tab are mutually exclusive!") if not via_ipc: # Initial main window return 0 window_to_raise = None open_target = config.get("general", "new-instance-open-target") if (open_target == "window" or force_window) and not force_tab: window = MainWindow() window.show() win_id = window.win_id window_to_raise = window else: try: window = objreg.last_window() except objreg.NoWindow: # There is no window left, so we open a new one window = MainWindow() window.show() win_id = window.win_id window_to_raise = window win_id = window.win_id if open_target not in ("tab-silent", "tab-bg-silent"): window_to_raise = window if window_to_raise is not None: window_to_raise.setWindowState(window.windowState() & ~Qt.WindowMinimized | Qt.WindowActive) window_to_raise.raise_() window_to_raise.activateWindow() QApplication.instance().alert(window_to_raise) return win_id