def _create_model(parent, serialized_bookmarks): result = QStandardItemModel(0, 1, parent) last_folder_item = None for entry in serialized_bookmarks: if len(entry) == 1: last_folder_item = _create_folder_item(entry[0]) result.appendRow(last_folder_item) else: url = QUrl.fromUserInput(entry[0]) title = entry[1] icon = QIcon(entry[2]) if len(entry) > 2 and entry[2] else None last_folder_item.appendRow(_create_item(url, title, icon)) return result
def Sl_on_double_click(self): file_path = QUrl.fromUserInput(self.path) QDesktopServices.openUrl(file_path)
def Sl_show_path_button_clicked(self) -> None: path = QUrl.fromUserInput(self.env_settings.value("sync_path")) QDesktopServices.openUrl(path)
def load(self): url = QUrl.fromUserInput(self.addressLineEdit.text()) if url.isValid(): self.webEngineView.load(url)
def load_url_string(self, url_s): url = QUrl.fromUserInput(url_s) if (url.isValid()): self.load_url(url)
def _remove_download_requested(self): download_widget = self.sender() self.statusBar().removeWidget(download_widget) del download_widget def _show_find(self): if self._find_tool_bar is None: self._find_tool_bar = FindToolBar() self._find_tool_bar.find.connect(self._tab_widget.find) self.addToolBar(Qt.BottomToolBarArea, self._find_tool_bar) else: self._find_tool_bar.show() self._find_tool_bar.focus_find() def write_bookmarks(self): self._bookmark_widget.write_bookmarks() if __name__ == '__main__': app = QApplication(sys.argv) main_win = create_main_window() initial_urls = sys.argv[1:] if not initial_urls: initial_urls.append('http://qt.io') for url in initial_urls: main_win.load_url_in_new_tab(QUrl.fromUserInput(url)) exit_code = app.exec_() main_win.write_bookmarks() sys.exit(exit_code)