def __init__(self, center_widget, title, parent, hide_close=False): super().__init__(None) self.setupUi(self) self.setModal(True) self.setObjectName("GreyedDialog") self.setWindowModality(Qt.ApplicationModal) self.button_close.apply_style() if platform.system() == "Windows": # SplashScreen on Windows freezes the Window self.setWindowFlags(Qt.FramelessWindowHint) else: # FramelessWindowHint on Linux (at least xfce) is less pretty self.setWindowFlags(Qt.SplashScreen) self.setAttribute(Qt.WA_TranslucentBackground) self.center_widget = center_widget self.main_layout.addWidget(center_widget) if not title and hide_close: self.widget_title.hide() if title: self.label_title.setText(title) if hide_close: self.button_close.hide() main_win = ParsecApp.get_main_window() if main_win: if main_win.isVisible(): self.setParent(main_win) self.resize(main_win.size()) else: self.showMaximized() self.move(0, 0) else: logger.error("GreyedDialog did not find the main window, this is probably a bug") self.setFocus() self.accepted.connect(self.on_finished) self.rejected.connect(self.on_finished)
def start_core(self, device): assert not self.running_core_job assert not self.core assert not self.core_jobs_ctx self.config = ParsecApp.get_main_window().config self.running_core_job = self.jobs_ctx.submit_job( self.run_core_success, self.run_core_error, _do_run_core, self.config, device, self.run_core_ready, )
def start_core(self, device): assert not self.running_core_job assert not self.core assert not self.core_jobs_ctx self.config = ParsecApp.get_main_window().config self.running_core_job = self.jobs_ctx.submit_job( ThreadSafeQtSignal(self, "run_core_success"), ThreadSafeQtSignal(self, "run_core_error"), _do_run_core, self.config, device, ThreadSafeQtSignal(self, "run_core_ready", object, object), )
def move_popup(self): main_window = ParsecApp.get_main_window() if not main_window: return offset = 10 height = 101 if platform.system() == "Windows" else 75 width = min(500, main_window.size().width() - 40) self.resize(QSize(width, height)) x = main_window.size().width() - width - 20 y = main_window.size().height() - ((height + offset) * (self.index + 1)) # Hide the snackbar if the main window does not have enough space to show it self.set_visible(y > 30) pos = main_window.mapToGlobal(QPoint(x, y)) self.setGeometry(pos.x(), pos.y(), width, height)
def __init__( self, center_widget, title, parent, hide_close=False, width=None, close_on_click=False ): super().__init__(None) self.setupUi(self) self.setModal(True) self.setObjectName("GreyedDialog") self.setWindowModality(Qt.ApplicationModal) self.button_close.apply_style() self.close_on_click = close_on_click if sys.platform == "win32": # SplashScreen on Windows freezes the Window self.setWindowFlags(Qt.FramelessWindowHint) else: # FramelessWindowHint on Linux (at least xfce) is less pretty self.setWindowFlags(Qt.SplashScreen) self.setAttribute(Qt.WA_TranslucentBackground) self.center_widget = center_widget self.main_layout.addWidget(center_widget) if not title and hide_close: self.widget_title.hide() if title: self.label_title.setText(title) if hide_close: self.button_close.hide() main_win = ParsecApp.get_main_window() if width: if width < main_win.size().width(): spacing = int((main_win.size().width() - width) / 2) self._get_spacer_right().changeSize( spacing, 0, QSizePolicy.Preferred, QSizePolicy.Preferred ) self._get_spacer_left().changeSize( spacing, 0, QSizePolicy.Preferred, QSizePolicy.Preferred ) if main_win: if main_win.isVisible(): self.setParent(main_win) self.resize(main_win.size()) else: self.showMaximized() self.move(0, 0) elif parent is not None: logger.error("GreyedDialog did not find the main window, this is probably a bug") self.setFocus() self.accepted.connect(self.on_finished) self.rejected.connect(self.on_finished)
def right_main_window(): assert ParsecApp.get_main_window() is main_w
def __init__(self): super().__init__() self.snackbars = [] ParsecApp.get_main_window().installEventFilter(self) self.setParent(ParsecApp.get_main_window()) self.destroyed.connect(self._on_destroyed)