def __init__(self, model: Model) -> None: super().__init__() self.model = model self.setWindowTitle(getTitleString('Mod Manager')) self.setMinimumSize(QSize(750, 500)) self.setupMenu() settings = QSettings() if settings.value('mainWindowGeometry'): self.restoreGeometry( settings.value('mainWindowGeometry')) # type: ignore if settings.value('mainWindowState'): self.restoreState( settings.value('mainWindowState')) # type: ignore # TODO: enhancement: add an url handler for 'nxm://' urls # see https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85) # noqa # TODO: enhancement: import settings from the witcher 3 mod manager QApplication.clipboard().dataChanged.connect( self.copyBufferChangedEvent) self.mainwidget = MainWidget(self, model) self.setCentralWidget(self.mainwidget) self.show() self.raise_() self.activateWindow()
def slot_copy_js_code(self) -> None: QApplication.clipboard().setText( 'javascript:var script = document.createElement("script");script.src = "http://localhost:10241/static/bridge.js";document.body.appendChild(script);' ) self.api.show_message( 'CExplore Bridge', 'Copied JS code to clipboard.\nPaste it as the url to a bookmark.\nThen go open the CExplore instance and click on the bookmark to connect.' )
def _copyRowsToClipboard(self, rows: Iterable[int]) -> None: if not rows or not self.columnCount(): return rows_text = ['\t'.join(self.model().headerData(column, Qt.Horizontal) for column in range(self.columnCount()))] for row in rows: rows_text.append('\t'.join(self.item(row, column).text() for column in range(self.columnCount()))) QApplication.clipboard().setText('\n'.join(rows_text))
def pasteEvent(self) -> None: clipboard = QApplication.clipboard().text().splitlines() if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]): self.parentWidget().showDownloadModDialog() else: urls = [ url for url in QApplication.clipboard().text().splitlines() if len(str(url.strip())) ] if all( isValidModDownloadUrl(url) or isValidFileUrl(url) for url in urls): asyncio.create_task(self.modlist.checkInstallFromURLs(urls))
def copy_content_to_clipboard(self, idx: int) -> None: text_edit = getattr(self, f"tab{idx}TextEdit") text = text_edit.toPlainText().strip() + "\n" cb = QApplication.clipboard() cb.setText(text) msg = f"the content of Tab {idx} was copied to the clipboard" self.mini_log(msg) self.log.info(msg)
def copyBufferChangedEvent(self) -> None: if QSettings().value('nexusCheckClipboard', 'False') == 'True': clipboard = QApplication.clipboard().text().splitlines() if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]): # TODO: enhancement: only allow one download window at once self.show() self.setWindowState(Qt.WindowActive) self.activateWindow() self.showDownloadModDialog()
def showDownloadModDialog(self) -> DownloadWindow: clipboard = QApplication.clipboard().text().splitlines() if len(clipboard) == 1 and isValidNexusModsUrl(clipboard[0]): url = clipboard[0] else: url = '' dialog = DownloadWindow(self, url) dialog.setModal(True) dialog.open() dialog.signals.download.connect(lambda urls: asyncio.create_task( self.mainwidget.modlist.checkInstallFromURLs(urls, local=False))) return dialog
def copy(self,pos): con = sqlite3.connect(self.filepath) c = con.cursor() c.execute('SELECT password FROM DETAILS where oid=?',(pos+1,)) res = c.fetchone() pw = process.decryptor(self.key,res[0]) cb = QApplication.clipboard() cb.clear(mode=cb.Clipboard) cb.setText(pw.decode(),mode=cb.Clipboard) QMessageBox(QMessageBox.Information,'Success','The password has been copied').exec()
def eventFilter(self, source: QLineEdit, event: Union[QDropEvent, QMouseEvent, QDragEnterEvent]): if event.type() == QEvent.DragEnter: event.accept() elif event.type() == QEvent.Drop: # 任何拖放事件 都先清空原来的内容 source.clear() md = event.mimeData() # type: QMimeData if md.hasUrls() and len(md.urls()) == 1: path = md.urls()[0].toLocalFile() if os.path.exists(path): source.setText(path) self.update_name.emit(path) return True elif event.type() == QEvent.MouseButtonDblClick: # 获取剪切板内容 看看有没有链接或者是文件 clipboard = QApplication.clipboard() md = clipboard.mimeData() if md.hasUrls() and len(md.urls()) == 1: # 比如复制了文件 这里就可以获取到文件的路径 但超链接并不会在这里 path = md.urls()[0].toLocalFile() if os.path.exists(path): source.clear() source.setText(path) self.update_name.emit(path) elif md.hasText(): # 检查是不是http(s)://开头的链接 text = md.text() if re.match(r'^https?://', text): source.clear() source.setText(text) self.update_name.emit(text) else: # 否则尝试选择本地元数据文件 fileName, selectedFilter = QFileDialog.getOpenFileUrl( None, caption="选择元数据文件", dir=QUrl("file://.")) if isinstance(fileName, QUrl): path = fileName.toLocalFile() if os.path.exists(path): source.clear() source.setText(path) self.update_name.emit(path) return True return super(URIQLineEdit, self).eventFilter(source, event)
def run(): initialization_result = initialize() conf = config() window_config = conf['window'] WIDTH = window_config['width'] HEIGHT = window_config['height'] app = QApplication(sys.argv) app.setStyleSheet(style) geometry = app.screens()[0].size() clipboard = app.clipboard() widget = MainWidget(clipboard) widget.setWindowOpacity(window_config['opacity']) widget.resize(WIDTH, HEIGHT) widget.move(0, geometry.height() - HEIGHT - 280) widget.setWindowTitle('Albion Online Stats') widget.setWindowIcon(QtGui.QIcon(path('albion-stats-icon.png'))) if window_config['always_on_top']: widget.setWindowFlag(Qt.WindowStaysOnTopHint) if window_config['frameless']: widget.setWindowFlag(Qt.FramelessWindowHint) widget.show() current_version, latest_version = (get_current_version(), get_latest_version()) if latest_version and current_version != latest_version: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setWindowTitle("Update available!") msg.setText("Another version of app is avaliable.") msg.setInformativeText( "You are using app in version {}, latest version is {}".format( current_version, latest_version)) msg.setStandardButtons(QMessageBox.Ok) msg.show() if initialization_result == InitializationResult.NetworkInterfaceListMissing: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setWindowTitle("Unable to track network traffic data!") msg.setText( "On windows make sure that WinPcap is installed in your system.") msg.setInformativeText( "WinPcap can be installed from <a href='{}'>here</a> <br>\ <b>Make sure to install with the \"Install Npcap in WinPcap API-compatible Mode\"<b> option<br><br>\ In case where npcap is installed try to fix npcap and restart the app" .format('https://nmap.org/npcap/dist/npcap-0.9990.exe')) msg.setStandardButtons(QMessageBox.Ok) button = QPushButton("Fix npcap") button.clicked.connect(fix_npcap) msg.addButton(button, QMessageBox.NoRole) msg.show() sys.exit(app.exec_())
def __init__(self, parent, receiver_slot, settings, video_dict={}): super().__init__(parent, receiver_slot, settings, video_dict) self.setWindowTitle( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video Finder')) self.size_label.hide() # empty lists for no_audio and no_video and video_audio files self.no_audio_list = [] self.no_video_list = [] self.video_audio_list = [] self.media_title = '' # add support for other languages locale = str(self.persepolis_setting.value('settings/locale')) QLocale.setDefault(QLocale(locale)) self.translator = QTranslator() if self.translator.load(':/translations/locales/ui_' + locale, 'ts'): QCoreApplication.installTranslator(self.translator) # extension_label self.extension_label = QLabel(self.link_frame) self.change_name_horizontalLayout.addWidget(self.extension_label) # Fetch Button self.url_submit_pushButtontton = QPushButton(self.link_frame) self.link_horizontalLayout.addWidget(self.url_submit_pushButtontton) # Status Box self.status_box_textEdit = QTextEdit(self.link_frame) self.status_box_textEdit.setMaximumHeight(150) self.link_verticalLayout.addWidget(self.status_box_textEdit) # Select format horizontal layout select_format_horizontalLayout = QHBoxLayout() # Selection Label self.select_format_label = QLabel(self.link_frame) select_format_horizontalLayout.addWidget(self.select_format_label) # Selection combobox self.media_comboBox = QComboBox(self.link_frame) self.media_comboBox.setMinimumWidth(200) select_format_horizontalLayout.addWidget(self.media_comboBox) # Duration label self.duration_label = QLabel(self.link_frame) select_format_horizontalLayout.addWidget(self.duration_label) self.format_selection_frame = QFrame(self) self.format_selection_frame.setLayout(select_format_horizontalLayout) self.link_verticalLayout.addWidget(self.format_selection_frame) # advanced_format_selection_checkBox self.advanced_format_selection_checkBox = QCheckBox(self) self.link_verticalLayout.addWidget( self.advanced_format_selection_checkBox) # advanced_format_selection_frame self.advanced_format_selection_frame = QFrame(self) self.link_verticalLayout.addWidget( self.advanced_format_selection_frame) advanced_format_selection_horizontalLayout = QHBoxLayout( self.advanced_format_selection_frame) # video_format_selection self.video_format_selection_label = QLabel( self.advanced_format_selection_frame) self.video_format_selection_comboBox = QComboBox( self.advanced_format_selection_frame) # audio_format_selection self.audio_format_selection_label = QLabel( self.advanced_format_selection_frame) self.audio_format_selection_comboBox = QComboBox( self.advanced_format_selection_frame) for widget in [ self.video_format_selection_label, self.video_format_selection_comboBox, self.audio_format_selection_label, self.audio_format_selection_comboBox ]: advanced_format_selection_horizontalLayout.addWidget(widget) # Set Texts self.url_submit_pushButtontton.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Fetch Media List')) self.select_format_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Select a format')) self.video_format_selection_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Video format:')) self.audio_format_selection_label.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Audio format:')) self.advanced_format_selection_checkBox.setText( QCoreApplication.translate("ytaddlink_src_ui_tr", 'Advanced options')) # Add Slot Connections self.url_submit_pushButtontton.setEnabled(False) self.change_name_lineEdit.setEnabled(False) self.ok_pushButton.setEnabled(False) self.download_later_pushButton.setEnabled(False) self.format_selection_frame.setEnabled(True) self.advanced_format_selection_frame.setEnabled(False) self.advanced_format_selection_checkBox.toggled.connect( self.advancedFormatFrame) self.url_submit_pushButtontton.clicked.connect(self.submitClicked) self.media_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'video_audio')) self.video_format_selection_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'video')) self.audio_format_selection_comboBox.activated.connect( partial(self.mediaSelectionChanged, 'audio')) self.link_lineEdit.textChanged.disconnect( super().linkLineChanged) # Should be disconnected. self.link_lineEdit.textChanged.connect(self.linkLineChangedHere) self.setMinimumSize(650, 480) self.status_box_textEdit.hide() self.format_selection_frame.hide() self.advanced_format_selection_frame.hide() self.advanced_format_selection_checkBox.hide() if 'link' in video_dict.keys() and video_dict['link']: self.link_lineEdit.setText(video_dict['link']) self.url_submit_pushButtontton.setEnabled(True) else: # check clipboard clipboard = QApplication.clipboard() text = clipboard.text() if (("tp:/" in text[2:6]) or ("tps:/" in text[2:7])): self.link_lineEdit.setText(str(text)) self.url_submit_pushButtontton.setEnabled(True)
def copy_clicked(self) -> None: QApplication.clipboard().setText(self.command.replace("\n", " "))
def __init__(self, parent, callback, persepolis_setting, plugin_add_link_dictionary={}): super().__init__(persepolis_setting) self.callback = callback self.plugin_add_link_dictionary = plugin_add_link_dictionary self.persepolis_setting = persepolis_setting self.parent = parent # entry initialization # read values from persepolis_setting # connections connections = int( self.persepolis_setting.value('settings/connections')) self.connections_spinBox.setValue(connections) # download_path download_path = str( self.persepolis_setting.value('settings/download_path')) self.download_folder_lineEdit.setText(download_path) self.download_folder_lineEdit.setEnabled(False) # enable ok button only if link_lineEdit is not empty! # see linkLineChanged method. self.ok_pushButton.setEnabled(False) self.download_later_pushButton.setEnabled(False) self.link_lineEdit.textChanged.connect(self.linkLineChanged) # if browsers plugin didn't send any links # then check clipboard for link! if ('link' in self.plugin_add_link_dictionary.keys()): # check plugin_add_link_dictionary for link! # "link" key-value must be checked self.link_lineEdit.setText( str(self.plugin_add_link_dictionary['link'])) else: # check clipboard clipboard = QApplication.clipboard() text = clipboard.text() if (("tp:/" in text[2:6]) or ("tps:/" in text[2:7])): self.link_lineEdit.setText(str(text)) # detect_proxy_pushButton self.detect_proxy_pushButton.clicked.connect(self.detectProxy) # ip_lineEdit initialization -> settings_ip = self.persepolis_setting.value( 'add_link_initialization/ip', None) if (settings_ip): self.ip_lineEdit.setText(str(settings_ip)) # proxy user lineEdit initialization -> settings_proxy_user = self.persepolis_setting.value( 'add_link_initialization/proxy_user', None) if (settings_proxy_user): self.proxy_user_lineEdit.setText(str(settings_proxy_user)) # port_spinBox initialization -> settings_port = self.persepolis_setting.value( 'add_link_initialization/port', 0) self.port_spinBox.setValue(int(int(settings_port))) # download UserName initialization -> settings_download_user = self.persepolis_setting.value( 'add_link_initialization/download_user', None) if (settings_download_user): self.download_user_lineEdit.setText(str(settings_download_user)) # get categories name and add them to add_queue_comboBox categories_list = self.parent.persepolis_db.categoriesList() for queue in categories_list: if queue != 'All Downloads': self.add_queue_comboBox.addItem(queue) self.add_queue_comboBox.setCurrentIndex(0) # add_queue_comboBox event self.add_queue_comboBox.currentIndexChanged.connect(self.queueChanged) # connect folder_pushButton self.folder_pushButton.clicked.connect(self.changeFolder) # connect OK and cancel download_later button -> self.cancel_pushButton.clicked.connect(self.close) self.ok_pushButton.clicked.connect( partial(self.okButtonPressed, download_later=False)) self.download_later_pushButton.clicked.connect( partial(self.okButtonPressed, download_later=True)) # frames and checkBoxes -> self.proxy_frame.setEnabled(False) self.proxy_checkBox.toggled.connect(self.proxyFrame) self.download_frame.setEnabled(False) self.download_checkBox.toggled.connect(self.downloadFrame) self.limit_frame.setEnabled(False) self.limit_checkBox.toggled.connect(self.limitFrame) self.start_frame.setEnabled(False) self.start_checkBox.toggled.connect(self.startFrame) self.end_frame.setEnabled(False) self.end_checkBox.toggled.connect(self.endFrame) self.change_name_lineEdit.setEnabled(False) self.change_name_checkBox.toggled.connect(self.changeName) # set focus to ok button self.ok_pushButton.setFocus() # check plugin_add_link_dictionary for finding file name # perhaps plugin sended file name in plugin_add_link_dictionary # for finding file name "out" key must be checked if ('out' in self.plugin_add_link_dictionary.keys()): if self.plugin_add_link_dictionary['out']: self.change_name_lineEdit.setText( str(self.plugin_add_link_dictionary['out'])) self.change_name_checkBox.setChecked(True) # get referer and header and user_agent and load_cookies in plugin_add_link_dictionary if exits. if ('referer' in self.plugin_add_link_dictionary): self.referer_lineEdit.setText( str(self.plugin_add_link_dictionary['referer'])) if ('header' in self.plugin_add_link_dictionary): if str(self.plugin_add_link_dictionary['header']) != 'None': self.header_lineEdit.setText( str(self.plugin_add_link_dictionary['header'])) if ('user_agent' in self.plugin_add_link_dictionary): self.user_agent_lineEdit.setText( str(self.plugin_add_link_dictionary['user_agent'])) if ('load_cookies' in self.plugin_add_link_dictionary): self.load_cookies_lineEdit.setText( (self.plugin_add_link_dictionary['load_cookies'])) # set window size and position size = self.persepolis_setting.value('AddLinkWindow/size', QSize(520, 425)) position = self.persepolis_setting.value('AddLinkWindow/position', QPoint(300, 300)) self.resize(size) self.move(position)
def copy_selected_bytes(self): QApplication.clipboard().setText( self.get_bytes_str(self.get_selected_range()))
def copy_to_clipboard(self, text: str) -> None: cb = QApplication.clipboard() cb.setText(text)
def _on_paste_button(self): self.permalink_edit.setText(QApplication.clipboard().text())
def get_text_from_clipboard() -> str: cb: QClipboard = QApplication.clipboard() return str(cb.text())
def copy_text_to_clipboard(text: str) -> None: cb: QClipboard = QApplication.clipboard() cb.setText(text)
def copy_download_link_button(self): data = self.ui.listAppsWidget.currentItem().data(Qt.UserRole) QApplication.clipboard().setText(metadata.url(data['internal_name'], repo=HOST)) self.status_message(f"Copied the download link for \"{data['display_name']}\" to clipboard")
def copy_text(self): QApplication.clipboard().setText(self.toPlainText().strip())
def copy_selected_pointer_address(self): address = self.cursor if self.selected_bytes == -4: address -= 3 points_to = self.get_as_pointer(address) QApplication.clipboard().setText(hex(points_to))
def copy_cursor_address(self): local_address = self.address_resolver.to_local( self.cursor) + ROM_OFFSET QApplication.clipboard().setText(hex(local_address).upper().replace('0X', '0x'))
def __init__(self, args: List[str]): """ At the moment the very, very long initialization of the main window, setting up everything. :param default_path: Use a user defined path as entrypoint. If it's empty, the home directory of the current user will be used. :type default_path: str """ super(tfm, self).__init__() self.setupUi(self) self.setWindowIcon(QIcon.fromTheme('system-file-manager')) self.clipboard = QApplication.clipboard() self.marked_to_cut = [] self.back_stack = stack() self.forward_stack = stack() self.config_dir = os.path.join( QStandardPaths.writableLocation( QStandardPaths().ConfigLocation), type(self).__name__) self.current_path = utility.handle_args(args) self.default_path = self.current_path self.threadpool = QThreadPool() # MAIN VIEW # # set up QFileSystemModel self.filesystem = QFileSystemModel() self.filesystem.setRootPath(self.current_path) self.filesystem.setReadOnly(False) # connect QFileSystemModel to View self.table_view.setModel(self.filesystem) self.table_view.setRootIndex( self.filesystem.index(self.current_path)) # set up header self.horizontal_header = self.table_view.horizontalHeader() self.horizontal_header.setSectionsMovable(True) # name self.horizontal_header.resizeSection(0, 200) # size self.horizontal_header.resizeSection(1, 100) # type self.horizontal_header.resizeSection(2, 100) # FS TREE # # create seperate FileSystemModel for the fs tree self.fs_tree_model = QFileSystemModel() self.fs_tree_model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot) self.fs_tree_model.setRootPath(QDir.rootPath()) # connect model to view self.fs_tree.setModel(self.fs_tree_model) # hide unneeded columns for column in range(1, self.fs_tree.header().count()): self.fs_tree.hideColumn(column) # expand root item self.fs_tree.expand(self.fs_tree_model.index(0, 0)) # BOOKMARKS # self.bookmarks = bm(path_to_bookmark_file=os.path.join(self.config_dir, 'bookmarks')) self.bookmark_view.setModel(self.bookmarks) # MOUNTS # self.udev_context = Context() self.mounts = mounts_model(context=self.udev_context) self.mounts_view.setModel(self.mounts) udev_monitor = Monitor.from_netlink(self.udev_context) udev_monitor.filter_by(subsystem='block', device_type='partition') udev_observer = MonitorObserver(udev_monitor, self.devices_changed) udev_observer.start() # STATUSBAR # # TODO: dir info self.item_info = QLabel() # self.dir_info = QLabel() self.part_info = QLabel() self.statusbar.addPermanentWidget(self.item_info) # self.statusbar.addPermanentWidget(self.dir_info) self.statusbar.addPermanentWidget(self.part_info) self.part_info.setText(utility.part_info(self.current_path)) # TOOLBAR # # initially disable back/forward navigation self.action_back.setEnabled(False) self.action_forward.setEnabled(False) # main menu self.main_menu = QMenu() self.main_menu.addAction(self.action_show_hidden) self.menu_button = QToolButton() self.menu_button.setMenu(self.main_menu) self.menu_button.setPopupMode(QToolButton().InstantPopup) self.menu_button.setDefaultAction(self.action_menu) self.toolbar.insertWidget(self.action_back, self.menu_button) # adress bar self.adressbar = QLineEdit() self.adressbar.setText(self.current_path) self.toolbar.insertWidget(self.action_go, self.adressbar) # menu for new file or directory self.new_menu = QMenu() self.new_menu.addAction(self.action_new_dir) self.new_menu.addAction(self.action_new_file) self.new_button = QToolButton() self.new_button.setMenu(self.new_menu) self.new_button.setPopupMode(QToolButton().MenuButtonPopup) self.new_button.setDefaultAction(self.action_new_dir) self.toolbar.insertWidget(self.action_back, self.new_button) self.connect_actions_to_events() self.set_shortcuts() self.set_icons() self.set_context_menus()
def slot_copy_symbol(self): symbol = self.symbols.get_symbol_at(self.address_resolver.to_local(self.cursor)) if symbol is not None: QApplication.clipboard().setText(symbol.name)
def readClipboardQR(self): self.initUi() if not self.readImageQR(QApplication.clipboard().image()): logging.warning(self.tr("No QR codes found in clipboard"))
def launchItem(self, inputDataList, catItem): if self.settings['copyToClipboard']: QApplication.clipboard().setText(catItem.shortName())
def CopyPicture(self): clipboard = QApplication.clipboard() clipboard.setPixmap(self.pixMap) QtBubbleLabel.ShowMsgEx(self, "Copy Success") return