mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-09-09 00:59:56 +00:00
more pretty deconfig page
This commit is contained in:
@ -103,8 +103,9 @@ class ConfigDefinition:
|
||||
try:
|
||||
with open(dataengineConfig, 'w') as deConfigFile:
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['dataengine'].ui.listWidget_customCommand.count()):
|
||||
item.append(self.configpage['dataengine'].ui.listWidget_customCommand.item(i).text())
|
||||
for i in range(self.configpage['dataengine'].ui.tableWidget_customCommand.count()):
|
||||
if (self.configpage['dataengine'].ui.tableWidget_customCommand.item(i, 0) != None):
|
||||
item.append(self.configpage['dataengine'].ui.tableWidget_customCommand.item(i, 0).text())
|
||||
deConfigFile.write("CUSTOM=" + str(item.join(QString('@@'))) + "\n")
|
||||
deConfigFile.write("DESKTOPCMD=" + str(self.configpage['dataengine'].ui.lineEdit_desktopCmd.text()) + "\n")
|
||||
deConfigFile.write("GPUDEV=" + str(self.configpage['dataengine'].ui.comboBox_gpudev.currentText()) + "\n")
|
||||
@ -114,8 +115,10 @@ class ConfigDefinition:
|
||||
deConfigFile.write("MPDPORT=" + str(self.configpage['dataengine'].ui.spinBox_mpdport.value()) + "\n")
|
||||
deConfigFile.write("MPRIS=" + str(self.configpage['dataengine'].ui.comboBox_mpris.currentText()) + "\n")
|
||||
item = QStringList()
|
||||
for i in range(self.configpage['dataengine'].ui.listWidget_pkgCommand.count()):
|
||||
item.append(self.configpage['dataengine'].ui.listWidget_pkgCommand.item(i).text())
|
||||
for i in range(self.configpage['dataengine'].ui.tableWidget_pkgCommand.rowCount()):
|
||||
if (self.configpage['dataengine'].ui.tableWidget_pkgCommand.item(i, 0) != None):
|
||||
item.append(self.configpage['dataengine'].ui.tableWidget_pkgCommand.item(i, 0).text() + ":" +
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.item(i, 1).text())
|
||||
pkgCmd = []
|
||||
pkgNull = []
|
||||
for command in item:
|
||||
@ -259,11 +262,18 @@ class ConfigDefinition:
|
||||
deSettings[line.split('=')[0]] = line.split('=')[1][:-1]
|
||||
except:
|
||||
pass
|
||||
for item in deSettings['CUSTOM'].split('@@'):
|
||||
self.configpage['dataengine'].ui.listWidget_customCommand.addItem(item)
|
||||
index = self.configpage['dataengine'].ui.comboBox_gpudev.findText(deSettings['GPUDEV'])
|
||||
self.configpage['dataengine'].ui.tableWidget_customCommand.clear()
|
||||
self.configpage['dataengine'].ui.tableWidget_customCommand.setRowCount(len(deSettings['CUSTOM'].split('@@')))
|
||||
headerList = QStringList()
|
||||
headerList.append(i18n("Custom command"))
|
||||
self.configpage['dataengine'].ui.tableWidget_customCommand.setHorizontalHeaderLabels(headerList)
|
||||
self.configpage['dataengine'].ui.tableWidget_customCommand.horizontalHeader().setResizeMode(QHeaderView.Stretch)
|
||||
for i in range(len(deSettings['CUSTOM'].split('@@'))):
|
||||
self.configpage['dataengine'].ui.tableWidget_customCommand.setItem(i, 0, QTableWidgetItem(deSettings['CUSTOM'].split('@@')[i]))
|
||||
self.configpage['dataengine'].ui.lineEdit_desktopCmd.setText(deSettings['DESKTOPCMD'])
|
||||
index = self.configpage['dataengine'].ui.comboBox_gpudev.findText(deSettings['GPUDEV'])
|
||||
self.configpage['dataengine'].ui.comboBox_gpudev.setCurrentIndex(index)
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.clear()
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.addItem("all")
|
||||
self.configpage['dataengine'].ui.comboBox_hdddev.addItem("disable")
|
||||
commandOut = commands.getoutput("find /dev -name '[hms]d[a-z]'")
|
||||
@ -280,13 +290,20 @@ class ConfigDefinition:
|
||||
self.configpage['dataengine'].ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT']))
|
||||
self.configpage['dataengine'].ui.comboBox_mpris.addItem(deSettings['MPRIS'])
|
||||
self.configpage['dataengine'].ui.comboBox_mpris.setCurrentIndex(self.configpage['dataengine'].ui.comboBox_mpris.count()-1)
|
||||
self.configpage['dataengine'].ui.listWidget_pkgCommand.clear()
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.clear()
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.setRowCount(len(deSettings['PKGCMD'].split(',')))
|
||||
headerList = QStringList()
|
||||
headerList.append(i18n("Package manager"))
|
||||
headerList.append(i18n("Null lines"))
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.setHorizontalHeaderLabels(headerList)
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.horizontalHeader().setResizeMode(QHeaderView.Stretch)
|
||||
for i in range(len(deSettings['PKGCMD'].split(','))):
|
||||
try:
|
||||
num = deSettings['PKGNULL'].split(',')[i]
|
||||
except:
|
||||
num = "0"
|
||||
self.configpage['dataengine'].ui.listWidget_pkgCommand.addItem(deSettings['PKGCMD'].split(',')[i] + ':' + num)
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.setItem(i, 0, QTableWidgetItem(deSettings['PKGCMD'].split(',')[i]))
|
||||
self.configpage['dataengine'].ui.tableWidget_pkgCommand.setItem(i, 1, QTableWidgetItem(num))
|
||||
index = self.configpage['dataengine'].ui.comboBox_playerSelect.findText(deSettings['PLAYER'])
|
||||
self.configpage['dataengine'].ui.comboBox_playerSelect.setCurrentIndex(index)
|
||||
|
||||
|
@ -39,12 +39,10 @@ class DEConfigWindow(QWidget):
|
||||
self.ui = uic.loadUi(parent.package().filePath('ui', 'deconfig.ui'), self)
|
||||
self.parent = parent
|
||||
|
||||
QObject.connect(self.ui.pushButton_customCommand, SIGNAL("clicked()"), self.addCustomCommand)
|
||||
QObject.connect(self.ui.pushButton_pkgCommand, SIGNAL("clicked()"), self.addPkgCommand)
|
||||
QObject.connect(self.ui.listWidget_customCommand, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_customCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.listWidget_pkgCommand, SIGNAL("itemActivated(QListWidgetItem*)"), self.ui.listWidget_pkgCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("currentIndexChanged(int)"), self.updatePkgNullValue)
|
||||
QObject.connect(self.ui.comboBox_pkgCommand, SIGNAL("editTextChanged(QString)"), self.updatePkgNullValue)
|
||||
QObject.connect(self.ui.tableWidget_customCommand, SIGNAL("itemActivated(QTableWidgetItem*)"), self.ui.tableWidget_customCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.tableWidget_customCommand, SIGNAL("itemChanged(QTableWidgetItem*)"), self.addCustomCommand)
|
||||
QObject.connect(self.ui.tableWidget_pkgCommand, SIGNAL("itemActivated(QTableWidgetItem*)"), self.ui.tableWidget_pkgCommand.openPersistentEditor)
|
||||
QObject.connect(self.ui.tableWidget_pkgCommand, SIGNAL("itemChanged(QTableWidgetItem*)"), self.addPkgCommand)
|
||||
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
@ -52,43 +50,25 @@ class DEConfigWindow(QWidget):
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [keyPressEvent]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [keyPressEvent] : Run function with event '%s'" %(event.key()))
|
||||
if (event.key() == Qt.Key_Delete):
|
||||
if (self.ui.listWidget_customCommand.hasFocus() and
|
||||
(self.ui.listWidget_customCommand.currentRow() > -1)):
|
||||
self.ui.listWidget_customCommand.takeItem(self.ui.listWidget_customCommand.currentRow())
|
||||
elif (self.ui.listWidget_pkgCommand.hasFocus() and
|
||||
(self.ui.listWidget_pkgCommand.currentRow() > -1)):
|
||||
self.ui.listWidget_pkgCommand.takeItem(self.ui.listWidget_pkgCommand.currentRow())
|
||||
if (self.ui.tableWidget_customCommand.hasFocus() and
|
||||
(self.ui.tableWidget_customCommand.currentRow() > -1)):
|
||||
self.ui.tableWidget_customCommand.removeRow(self.ui.tableWidget_customCommand.currentRow())
|
||||
elif (self.ui.tableWidget_pkgCommand.hasFocus() and
|
||||
(self.ui.tableWidget_pkgCommand.currentRow() > -1)):
|
||||
self.ui.tableWidget_pkgCommand.removeRow(self.ui.tableWidget_pkgCommand.currentRow())
|
||||
|
||||
|
||||
def addCustomCommand(self):
|
||||
def addCustomCommand(self, item):
|
||||
"""function to add custom command"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addCustomCommand]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addCustomCommand] : Cmd '%s'" %(self.ui.lineEdit_customCommand.text()))
|
||||
self.ui.listWidget_customCommand.clearSelection()
|
||||
self.ui.listWidget_customCommand.addItem(self.ui.lineEdit_customCommand.text())
|
||||
if (item.row() == (self.ui.tableWidget_customCommand.rowCount() - 1)):
|
||||
self.ui.tableWidget_customCommand.insertRow(self.ui.tableWidget_customCommand.rowCount());
|
||||
|
||||
|
||||
def addPkgCommand(self):
|
||||
"""function to add package manager command"""
|
||||
def addPkgCommand(self, item):
|
||||
"""function to add new row"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addPkgCommand]")
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [addPkgCommand] : Cmd '%s'" %(self.ui.comboBox_pkgCommand.currentText()))
|
||||
self.ui.listWidget_pkgCommand.clearSelection()
|
||||
self.ui.listWidget_pkgCommand.addItem(self.ui.comboBox_pkgCommand.currentText() +\
|
||||
QString(":") + QString.number(self.ui.spinBox_pkgCommandNum.value()))
|
||||
|
||||
|
||||
def updatePkgNullValue(self):
|
||||
"""function to set default values to PKGNULL spinbox"""
|
||||
if self.debug: qDebug("[PTM] [deconfig.py] [updatePkgNullValue]")
|
||||
if (self.ui.comboBox_pkgCommand.currentText().contains(QString("pacman -Qu"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("apt-show-versions -u -b"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("aptitude search '~U'"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("yum list updates"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(3)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("pkg_version -I -l '<'"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
elif (self.ui.comboBox_pkgCommand.currentText().contains(QString("urpmq --auto-select"))):
|
||||
self.ui.spinBox_pkgCommandNum.setValue(0)
|
||||
if ((item.row() == (self.ui.tableWidget_pkgCommand.rowCount() - 1)) and
|
||||
(item.column() == 0)):
|
||||
self.ui.tableWidget_pkgCommand.insertRow(self.ui.tableWidget_pkgCommand.rowCount());
|
||||
self.ui.tableWidget_pkgCommand.setItem(self.ui.tableWidget_pkgCommand.rowCount()-1, 1, QTableWidgetItem("0"))
|
||||
|
Reference in New Issue
Block a user