class formLog(QDialog): '''Error log form''' def __init__(self,text,*args): '''text = text to display in a readonly QTextEdit''' QDialog.__init__(self,*args) formLayout = QGridLayout(self)#,1,1,11,6,'formLayout') self.formLayout = formLayout self.scroll = QScrollArea(self) self.lab = QTextEdit() self.lab.setFont(QFont('monospace', 10)) self.lab.setText(text) self.lab.setReadOnly(True) self.scroll.setWidget(self.lab) self.scroll.setWidgetResizable(True) self.scroll.setMinimumWidth(700) self.scroll.setMinimumHeight(700) formLayout.addWidget(self.scroll,1,1,1,2) self.btnClose = QPushButton('Close', self) formLayout.addWidget(self.btnClose,3,2,1,1) self.connect(self.btnClose, SIGNAL('clicked ()'),self.close)
class formLog(QDialog): '''Error log form''' def __init__(self, text, *args): '''text = text to display in a readonly QTextEdit''' QDialog.__init__(self, *args) formLayout = QGridLayout(self) #,1,1,11,6,'formLayout') self.formLayout = formLayout self.scroll = QScrollArea(self) self.lab = QTextEdit() self.lab.setFont(QFont('monospace', 10)) self.lab.setText(text) self.lab.setReadOnly(True) self.scroll.setWidget(self.lab) self.scroll.setWidgetResizable(True) self.scroll.setMinimumWidth(700) self.scroll.setMinimumHeight(700) formLayout.addWidget(self.scroll, 1, 1, 1, 2) self.btnClose = QPushButton('Close', self) formLayout.addWidget(self.btnClose, 3, 2, 1, 1) self.connect(self.btnClose, SIGNAL('clicked ()'), self.close)
def __init__(self, conf, parent=None): QWidget.__init__(self, parent) self._conf = conf self._projects = [] for project in self._conf.projects: self._projects += [ProjectWidgets(project)] gLayout = QGridLayout() column = 0 for iproject in range(len(self._projects)): column += self._projects[iproject].addToLayout(column, gLayout) toolsGroup = QGroupBox('Projects && Tools') toolsGroup.setLayout(gLayout) scrollToolsGroup = QScrollArea() scrollToolsGroup.setMinimumHeight(350) #scrollToolsGroup.setVerticalScrollBarPolicy( Qt.ScrollBarAlwaysOn ) scrollToolsGroup.setWidget(toolsGroup) self._buildMode = QComboBox() self._buildMode.addItems(('Release', 'Debug')) #self._svnUpdate = QCheckBox( 'SVN Update' ) #self._svnStatus = QCheckBox( 'SVN Status' ) self._make = QCheckBox('Build') self._enableDoc = QCheckBox('Build Documentation') self._devtoolset2 = QCheckBox('Build with devtoolset 2') self._qt5 = QCheckBox('Build with Qt 5 (Qt 4 default)') self._noCache = QCheckBox('Remove previous CMake cache') self._rmBuild = QCheckBox('Cleanup Build Directory') self._verbose = QCheckBox('Display Compiler Commands') self._threads = QComboBox() for j in range(16): self._threads.addItem('-j%d' % (j + 1), j + 1) self._commandGroup = QButtonGroup() self._commandGroup.setExclusive(True) #self._commandGroup.addButton( self._svnUpdate ) #self._commandGroup.addButton( self._svnStatus ) self._commandGroup.addButton(self._make) vLayout = QVBoxLayout() #vLayout.addWidget( self._svnUpdate ) #vLayout.addWidget( self._svnStatus ) vLayout.addWidget(self._make) vLayout.addStretch() commandGroup = QGroupBox('Command') commandGroup.setLayout(vLayout) vLayout = QVBoxLayout() vLayout.addWidget(self._buildMode) vLayout.addWidget(self._enableDoc) vLayout.addWidget(self._devtoolset2) vLayout.addWidget(self._qt5) vLayout.addWidget(self._noCache) vLayout.addWidget(self._rmBuild) vLayout.addStretch() optionsGroup = QGroupBox('Command Options') optionsGroup.setLayout(vLayout) vLayout = QVBoxLayout() vLayout.addWidget(self._threads) vLayout.addWidget(self._verbose) vLayout.addStretch() miscGroup = QGroupBox('Misc. Options') miscGroup.setLayout(vLayout) hLayout = QHBoxLayout() hLayout.addWidget(commandGroup) hLayout.addWidget(optionsGroup) hLayout.addWidget(miscGroup) commands = QWidget() commands.setLayout(hLayout) vLayout = QVBoxLayout() vLayout.addWidget(commands) vLayout.addWidget(scrollToolsGroup) vLayout.addStretch() self.setLayout(vLayout) self.readSettings() return
class SectionsContainerWidget(QWidget): def __init__(self, parent=None, isLinacSection=True, sectionClass=None): QWidget.__init__(self, parent) self.isLinacSection = isLinacSection self.sectionClass = sectionClass self.setParent(parent) self.sectionWidgets = list() self.setMinimumWidth(460) self.setMinimumHeight(600) self.sumSize = 0 self.setupLayout() self.setupScrollArea() self.addSectionButton = QPushButton(self.containerWidget) self.addSectionButton.setText("Add new section") self.layout.addWidget(self.addSectionButton) self.connect(self.addSectionButton, QtCore.SIGNAL("clicked()"), self.addNewSection) def setupLayout(self): self.containerWidget = QWidget(self) self.widgetHeight = 120 self.containerWidget.setGeometry(QRect(0, 0, 460, self.widgetHeight)) self.layout = QVBoxLayout() self.containerWidget.setLayout(self.layout) def setupScrollArea(self): self.scrollArea = QScrollArea(self) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.scrollArea.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setMaximumWidth(460) self.scrollArea.setMinimumHeight(600) self.scrollArea.setWidgetResizable(False) self.scrollArea.setWidget(self.containerWidget) def addNewSection(self): newSection = self.sectionClass(self.containerWidget) widgetPosition = len(self.sectionWidgets) self.layout.insertWidget(widgetPosition, newSection) self.sectionWidgets.append(newSection) self.setDefaultValues(newSection) self.widgetHeight += 80 self.containerWidget.resize(460, self.widgetHeight) self.connect(newSection, QtCore.SIGNAL("remove()"), self.removeSection) self.connect(newSection, QtCore.SIGNAL("sizeValueChanged(QWidget*)"), self.updateSumOfSize) def setDefaultValues(self, section): pass # section.colorLabel.setColor(SettingsCloud.getParameter("subsectionColor")) # self.setSectionSize(section) def setSectionSize(self, section): pass # def setSubsectionSize(self, section): # if self.isLinacSection: # defaultSize = SettingsCloud.getParameter("linacSubsectionSize") # else: # defaultSize = SettingsCloud.getParameter("ringSubsectionSize") # section.sizeEdit.setValue(defaultSize) # self.updateSumOfSize(section) def updateSumOfSize(self, sectionWidget): self.sumSize = 0 for section in self.sectionWidgets: self.sumSize += section.getSize() if self.sumSize > 100: diff = self.sumSize - 100.0 actualSize = sectionWidget.getSize() sectionWidget.setSize(actualSize - diff) def removeSection(self): messageBox = QMessageBox(self) userReply = messageBox.question(self, "Are you sure?", "Do you want to remove this section?", QMessageBox.Yes | QMessageBox.No) if userReply == QMessageBox.Yes: sender = self.sender() self.layout.removeWidget(sender) self.sectionWidgets.remove(sender) sender.setVisible(False) self.widgetHeight -= 80 self.containerWidget.resize(460, self.widgetHeight) def getNumberOfSections(self): return len(self.sectionWidgets) def getSections(self): return self.sectionWidgets def getSectionsData(self): subsectionsData = list() for subsection in self.sectionWidgets: subsectionsData.append(subsection.getSectionData()) return subsectionsData
class SectionsContainerWidget(QWidget): def __init__(self, parent=None, isLinacSection=True, sectionClass=None): QWidget.__init__(self, parent) self.isLinacSection = isLinacSection self.sectionClass = sectionClass self.setParent(parent) self.sectionWidgets = list() self.setMinimumWidth(460) self.setMinimumHeight(600) self.sumSize = 0 self.setupLayout() self.setupScrollArea() self.addSectionButton = QPushButton(self.containerWidget) self.addSectionButton.setText("Add new section") self.layout.addWidget(self.addSectionButton) self.connect(self.addSectionButton, QtCore.SIGNAL("clicked()"), self.addNewSection) def setupLayout(self): self.containerWidget = QWidget(self) self.widgetHeight = 120 self.containerWidget.setGeometry(QRect(0,0,460,self.widgetHeight)) self.layout = QVBoxLayout() self.containerWidget.setLayout(self.layout) def setupScrollArea(self): self.scrollArea = QScrollArea(self) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setMaximumWidth(460) self.scrollArea.setMinimumHeight(600) self.scrollArea.setWidgetResizable(False) self.scrollArea.setWidget(self.containerWidget) def addNewSection(self): newSection = self.sectionClass(self.containerWidget) widgetPosition = len(self.sectionWidgets) self.layout.insertWidget(widgetPosition, newSection) self.sectionWidgets.append(newSection) self.setDefaultValues(newSection) self.widgetHeight += 80 self.containerWidget.resize(460,self.widgetHeight) self.connect(newSection, QtCore.SIGNAL("remove()"), self.removeSection) self.connect(newSection, QtCore.SIGNAL("sizeValueChanged(QWidget*)"), self.updateSumOfSize) def setDefaultValues(self, section): pass # section.colorLabel.setColor(SettingsCloud.getParameter("subsectionColor")) # self.setSectionSize(section) def setSectionSize(self, section): pass # def setSubsectionSize(self, section): # if self.isLinacSection: # defaultSize = SettingsCloud.getParameter("linacSubsectionSize") # else: # defaultSize = SettingsCloud.getParameter("ringSubsectionSize") # section.sizeEdit.setValue(defaultSize) # self.updateSumOfSize(section) def updateSumOfSize(self, sectionWidget): self.sumSize = 0 for section in self.sectionWidgets: self.sumSize += section.getSize() if self.sumSize > 100: diff = self.sumSize - 100.0 actualSize = sectionWidget.getSize() sectionWidget.setSize(actualSize - diff) def removeSection(self): messageBox = QMessageBox(self) userReply = messageBox.question(self, "Are you sure?", "Do you want to remove this section?", QMessageBox.Yes|QMessageBox.No) if userReply == QMessageBox.Yes: sender = self.sender() self.layout.removeWidget(sender) self.sectionWidgets.remove(sender) sender.setVisible(False) self.widgetHeight -= 80 self.containerWidget.resize(460,self.widgetHeight) def getNumberOfSections(self): return len(self.sectionWidgets) def getSections(self): return self.sectionWidgets def getSectionsData(self): subsectionsData = list() for subsection in self.sectionWidgets: subsectionsData.append(subsection.getSectionData()) return subsectionsData
class QtSCJ(QDialog) : """ QtSCJ est une boite de dialogue contenant l'état de la progression de chaque processus """ def __init__(self, parent=None): super(QtSCJ, self).__init__(parent) self.dir = None self.jobs = { } self.log = [ ] self.mode = "ogg" self.filter = "*.mp3 *.ogg *.wav" self.modes = [ "ogg", "mp3", "wav" ] self.readSettings() self.setupUi() self.retranslateUi() self.fermer.setEnabled(True) self.connect(self.fermer,SIGNAL("clicked()"),self.close) self.connect(self.convertDir,SIGNAL("clicked()"),self.getDir) self.connect(self.convertFile,SIGNAL("clicked()"),self.getFiles) self.connect(self.startallbtn,SIGNAL("clicked()"),self.startAll) self.connect(self.delallbtn,SIGNAL("clicked()"),self.delAll) self.connect(self.output,SIGNAL("currentIndexChanged(const QString)"), self.setMode) def setMode(self, mode): self.mode = mode self.writeSettings() def writeSettings(self): settings = QSettings("scj", "scj") settings.setValue("mode", self.mode) def readSettings(self): settings = QSettings("scj", "scj") self.mode = settings.value("mode", "ogg").toString() def setupUi(self): self.setObjectName("SCJ") self.setFixedSize(600,260) #self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.verticalLayout = QVBoxLayout(self) self.verticalLayout.setObjectName("verticalLayout") #self.infoText = QTextEdit(self) self.infoText = QLabel(self) palette = QPalette() brush = QBrush(QColor(245, 245, 245)) brush.setStyle(Qt.SolidPattern) palette.setBrush(QPalette.Normal, QPalette.Background, brush) self.infoText.setPalette(palette) self.infoText.setAutoFillBackground(True) self.infoText.setFixedHeight(200) self.infoText.setObjectName("infoText") #self.infoText.setReadOnly(True) self.infoText.setWordWrap(True) self.verticalLayout.addWidget(self.infoText) # Manage Actions buttons self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) ## Format de sortie self.outlabel = QLabel(self.trUtf8("Choix du format de destination")) self.horizontalLayout.addWidget(self.outlabel) self.output = QComboBox() self.output.addItems(self.modes) self.output.setCurrentIndex(self.output.findText(self.mode)) self.horizontalLayout.addWidget(self.output) # Buttons self.fermer = QPushButton(self) self.fermer.setObjectName("fermer") self.horizontalLayout.addWidget(self.fermer) self.convertDir = QPushButton(self) self.convertDir.setObjectName("convertDir") self.horizontalLayout.addWidget(self.convertDir) self.convertFile = QPushButton(self) self.convertFile.setObjectName("convertFile") self.horizontalLayout.addWidget(self.convertFile) self.verticalLayout.addLayout(self.horizontalLayout) # Layout for allButtons self.allLayout = QHBoxLayout() # Add startAll bouton self.startallbtn = QPushButton(self) self.allLayout.addWidget(self.startallbtn) self.startallbtn.hide() self.verticalLayout.addLayout(self.allLayout) # Add delAll bouton self.delallbtn = QPushButton(self) self.allLayout.addWidget(self.delallbtn) self.delallbtn.hide() # Mode avec scroll self.frame = QFrame() self.frame.setMinimumSize(520,250) self.frame.setMaximumWidth(520) self.scroll = QScrollArea() self.scroll.setMinimumHeight(180) self.jobsLayout = QVBoxLayout(self.frame) self.jobsLayout.setSizeConstraint(QLayout.SetMinAndMaxSize) #self.jobsLayout.setSizeConstraint(QLayout.SetMinimumSize) #self.jobsLayout.setSizeConstraint(QLayout.SetMaximumSize) self.scroll.setWidget(self.frame) self.scroll.setWidgetResizable(False) self.verticalLayout.addWidget(self.scroll) self.scroll.hide() # Mode sans scroll #self.jobsLayout = QVBoxLayout() #self.verticalLayout.addLayout(self.jobsLayout) # Add a strech to the bottom of the window self.verticalLayout.insertStretch(-1) def retranslateUi(self): self.setWindowTitle(u"SCJ") self.infoText.setToolTip(self.trUtf8("Messages")) self.fermer.setToolTip(self.trUtf8("Fermer la fenetre")) self.fermer.setText(self.trUtf8("Fermer")) self.startallbtn.setToolTip(self.trUtf8("Demarrer toutes les taches")) self.startallbtn.setText(self.trUtf8("Tout demarrer")) self.delallbtn.setToolTip(self.trUtf8("Supprimmer toutes les taches")) self.delallbtn.setText(self.trUtf8("Tout supprimer")) self.convertDir.setToolTip(self.trUtf8("Convertir un repertoire")) self.convertDir.setText(self.trUtf8("Repertoire")) self.convertFile.setToolTip(self.trUtf8("Convertir un fichier")) self.convertFile.setText(self.trUtf8("Fichier(s)")) self.infoText.setText(u"<h1>%s</h1>\ \n%s<br/>\ \n%s\ \n<ul><li>%s</li>\ \n <li>%s</li>\ \n <li><b>%s</b></li>\ \n</ul>" % (self.trUtf8("BIENVENUE SUR SCJ"), self.trUtf8("SCJ permet de convertir un ou plusieurs fichiers"+ " son vers differents formats."), self.trUtf8("Il gere egalement les repertoires en convertissant"+ " l'ensemble des fichiers sons presents vers le"+ " format voulu."), self.trUtf8("Choisissez le format de destination"), self.trUtf8("Cliquez sur Fichier(s) ou Repertoire en fonction"+ " de ve que vous voulez convertir."), self.trUtf8("Demarrez la conversion !") )) def addFile(self, file, createDir=False): file.makeAbsolute() if (file.suffix() != self.mode): job = SCJProgress( parent=None, file=file.filePath(), format=self.mode, createDir=createDir) if not self.jobs.get(job.output): self.jobs[job.output] = job self.jobsLayout.addLayout(self.jobs[job.output]) self.connect(self.jobs[job.output], SIGNAL("void removed(QString)"), self.delFile) self.addStartAll() def delFile(self, job): j = self.jobs.pop(job) self.addStartAll() self.jobsLayout.removeItem(j) def getDir(self): self.dir = QFileDialog.getExistingDirectory( parent = self, caption = self.trUtf8("Choix du repertoire"), directory = QDir.homePath(), options = QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) if self.dir : directory = QDir(self.dir, self.filter) for file in directory.entryInfoList(): self.addFile(file, createDir=True) def getFiles(self): files = QFileDialog.getOpenFileNames( parent = self, caption = self.trUtf8("Choix des fichiers"), directory = QDir.homePath(), filter = u"%s (%s)" % (self.trUtf8("Sons"), self.filter)) for file in files: self.addFile(QFileInfo(file), createDir=False) def addStartAll(self): if (len(self.jobs) > 0 ): self.startallbtn.setVisible(True) self.delallbtn.setVisible(True) self.scroll.setVisible(True) self.setFixedSize(600, 480) else: self.startallbtn.setVisible(False) self.delallbtn.setVisible(False) self.scroll.setVisible(False) self.setFixedSize(600, 260) self.updateGeometry() def startAll(self): for (key, job) in self.jobs.items(): job.start() def delAll(self): for (key, job) in self.jobs.items(): job.stop() self.delFile(key) def close(self): print u"%s" % self.trUtf8("We are stopping running jobs"), for (key, job) in self.jobs.items(): job.stop() print ".", print u"%s" % self.trUtf8("Done") super(QtSCJ, self).close()
class DeviceOrderWidget(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.section = None self.deviceWidgets = list() self.setMinimumWidth(520) self.setMinimumHeight(600) self.iconAssigner = IconAssigner() self.setupLayout() self.setupScrollArea() # self.addNewDeviceWidget(device = Device("ABC", None, None)) # self.addNewDeviceWidget(device = Device("XD", None, None)) # self.addNewDeviceWidget(device = Device("1313XD", None, None)) # self.addNewDeviceWidget(device = Device(":-(", None, None)) def setupLayout(self): self.containerWidget = QWidget(self) self.widgetHeight = 0 self.containerWidget.setGeometry(QRect(0,0,451,self.widgetHeight)) self.layout = QVBoxLayout() self.containerWidget.setLayout(self.layout) def setupScrollArea(self): self.scrollArea = QScrollArea(self) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea.setMaximumWidth(530) self.scrollArea.setMinimumHeight(600) self.scrollArea.setWidgetResizable(False) self.scrollArea.setWidget(self.containerWidget) def setSection(self, section): self.section = section devices = section.devices devices = sorted(devices, key=lambda device: device.getShortName()) for device in devices: self.addNewDeviceWidget(device) def addNewDeviceWidget(self, device=None): newWidget = DeviceWidget(self, device = device) newWidget.position = len(self.deviceWidgets) iconPath = self.iconAssigner.getIconPath(device) newWidget.deviceIcon.setIcon(iconPath) self.deviceWidgets.append(newWidget) self.layout.addWidget(newWidget) self.widgetHeight += 70 self.containerWidget.resize(530, self.widgetHeight) self.connect(newWidget, QtCore.SIGNAL("up()"), self.upWidget) self.connect(newWidget, QtCore.SIGNAL("down()"), self.downWidget) def upWidget(self): widget = self.sender() if widget.position > 0: self.swap(widget.position, widget.position-1) def downWidget(self): widget = self.sender() if widget.position < len(self.deviceWidgets)-1: self.swap(widget.position, widget.position+1) def swap(self, first, second): firstWidget = self.deviceWidgets[first] secondWidget = self.deviceWidgets[second] firstWidget.position = second secondWidget.position = first self.layout.removeWidget(firstWidget) self.layout.removeWidget(secondWidget) self.deviceWidgets.remove(firstWidget) self.deviceWidgets.remove(secondWidget) if first > second: self.layout.insertWidget(second, firstWidget) self.layout.insertWidget(first, secondWidget) self.deviceWidgets.insert(second, firstWidget) self.deviceWidgets.insert(first, secondWidget) else: self.layout.insertWidget(first, secondWidget) self.layout.insertWidget(second, firstWidget) self.deviceWidgets.insert(first, secondWidget) self.deviceWidgets.insert(second, firstWidget) def getSortedDevices(self): devices = list() for deviceWidget in self.deviceWidgets: devices.append(deviceWidget.device) return devices