def __init__(self, title="Jade Application Kit", icon=False, transparent=False, toolbar="", parent=None): """ * :param title:str * :param icon:str * :param transparent:bool * :param toolbar:dict * :param parent: Parent widget """ QMainWindow.__init__(self) self.title = title self.video_corner = False self.center = QDesktopWidget().availableGeometry().center() self.setAttribute(Qt.WA_DeleteOnClose, True) self.setWindowTitle(title) if icon and os.path.isfile(icon): self.icon = QIcon(icon) else: # TODO detect active icon theme QIcon.setThemeName("Papirus-Maia") icon_paths = QIcon.themeSearchPaths() icon_paths.append("/usr/share/pixmaps") QIcon.setThemeSearchPaths(icon_paths) self.icon = QIcon.fromTheme("applications-internet") view = Instance.retrieve("view") if view: self.view = view self.setCentralWidget(self.view) self.view.page().titleChanged.connect(self.status_message) self.view.iconChanged.connect(self._icon_changed) if transparent: # Set Background Transparency self.setAttribute(Qt.WA_TranslucentBackground, True) self.setAutoFillBackground(True) self.toolbar = JToolbar(self, toolbar, self.icon, title) self.addToolBar(self.toolbar) # self.addToolBar(Qt.RightToolBarArea, self.bar) self.system_tray = SystemTrayIcon(self.icon, self, self.title) self._set_icons()
def show(self, workspace=None): super().show() # Initialize settings first # Set the workspace, if not provided if workspace is not None: settings.override("workspace_dir", workspace) if settings.asset_dir is None: settings.override("asset_dir", settings.workspace_dir) # Set the currently running application's directory, for convenience settings.application_dir = __file__.replace("main.py", "") icon_dir = settings.icon_path if icon_dir is None: icon_dir = path.join(settings.application_dir, "icons") # Initialize QIcon search paths and themes search_paths = QIcon.themeSearchPaths() search_paths.append(icon_dir) QIcon.setThemeSearchPaths(search_paths) QIcon.setFallbackThemeName(settings.fallback_theme_name) self._show_layout()
def __init__(self, app): self.started = False self.app = app self.args = app.args self.config = app.config self.library = app.library self.workplace = app.workplace self.analyzer = app.analyzer logging.debug("qt_argv: %r", self.args.qt_argv) self.qapp = QApplication(self.args.qt_argv) self.qapp.setApplicationName("Sample Drawer") for path in RESOURCE_FILENAMES: if os.path.exists(path): logger.debug("Loading resources from %r", path) QResource.registerResource(path) QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + ["/home/jajcus/git/sampledrawer/icons"]) logger.debug("Icon search path: %r", QIcon.themeSearchPaths()) QIcon.setFallbackSearchPaths([":icons/"] + QIcon.fallbackSearchPaths()) logger.debug("Icon fallback path: %r", QIcon.fallbackSearchPaths()) logger.debug("Theme name %r", QIcon.themeName()) logger.debug("Fallback theme name: %r", QIcon.fallbackThemeName()) self.qapp.setWindowIcon(QIcon(":icons/sampledrawer.svg"))