コード例 #1
0
ファイル: infoview.py プロジェクト: valmynd/MediaFetcher
class InfoBoxDialog(QDialog):
	def __init__(self, parent_widget, model):
		QDialog.__init__(self, parent_widget)
		self.mapper = QueueWidgetMapper(model)
		self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)
		self.setWindowTitle("Clipboard Item Description")
		dialoglayout = QVBoxLayout()
		self.setLayout(dialoglayout)

		group = QGroupBox("Clipboard Information")
		layout = QFormLayout()
		group.setLayout(layout)
		dialoglayout.addWidget(group)
		self.infoBrowser = ItemInfoWidget()
		layout.addRow(self.infoBrowser)
		group.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)

		group = QGroupBox("Download Settings")
		layout = QFormLayout()
		group.setLayout(layout)
		dialoglayout.addWidget(group)
		self.folderField = QFolderChooser(self)
		self.folderLabel = self.mapper.map(self.folderField, "Path", "Download Folder")
		self.fileNameField = QLineEdit(self)
		self.fileNameLabel = self.mapper.map(self.fileNameField, "Filename", "File Name")
		layout.addRow(self.folderLabel, self.folderField)
		layout.addRow(self.fileNameLabel, self.fileNameField)
		self.fileNameLabel.setToolTip("Filename Template Conventions:\n"
																	"%extension% → transform to lowercase (mp4)\n"
																	"%EXTENSION% → transform to uppercase (MP4)\n"
																	"%exTenSiOn% or something like that → no transformation\n\n"
																	"Available Keywords: title, url, host, extension, quality")

		buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
		buttonbox.accepted.connect(self.submit)
		buttonbox.rejected.connect(self.close)
		dialoglayout.addWidget(buttonbox)

	def open_for_selection(self, selected_index):
		self.mapper.setCurrentModelIndex(selected_index)
		element = selected_index.internalPointer()
		self.infoBrowser.setToElement(element)
		self.exec_()

	def submit(self):
		# TODO: when the filename or path changes and the file is already downloaded,
		#       ask user if the file shall be renamed or moved!!!
		if self.folderField.checkPermissions(self.folderField.text()):
			self.mapper.submit()
			self.close()
コード例 #2
0
ファイル: infoview.py プロジェクト: valmynd/MediaFetcher
	def __init__(self, parent_widget, model):
		QDialog.__init__(self, parent_widget)
		self.mapper = QueueWidgetMapper(model)
		self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)
		self.setWindowTitle("Clipboard Item Description")
		dialoglayout = QVBoxLayout()
		self.setLayout(dialoglayout)

		group = QGroupBox("Clipboard Information")
		layout = QFormLayout()
		group.setLayout(layout)
		dialoglayout.addWidget(group)
		self.infoBrowser = ItemInfoWidget()
		layout.addRow(self.infoBrowser)
		group.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)

		group = QGroupBox("Download Settings")
		layout = QFormLayout()
		group.setLayout(layout)
		dialoglayout.addWidget(group)
		self.folderField = QFolderChooser(self)
		self.folderLabel = self.mapper.map(self.folderField, "Path", "Download Folder")
		self.fileNameField = QLineEdit(self)
		self.fileNameLabel = self.mapper.map(self.fileNameField, "Filename", "File Name")
		layout.addRow(self.folderLabel, self.folderField)
		layout.addRow(self.fileNameLabel, self.fileNameField)
		self.fileNameLabel.setToolTip("Filename Template Conventions:\n"
																	"%extension% → transform to lowercase (mp4)\n"
																	"%EXTENSION% → transform to uppercase (MP4)\n"
																	"%exTenSiOn% or something like that → no transformation\n\n"
																	"Available Keywords: title, url, host, extension, quality")

		buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
		buttonbox.accepted.connect(self.submit)
		buttonbox.rejected.connect(self.close)
		dialoglayout.addWidget(buttonbox)