more pretty deconfig page

This commit is contained in:
arcan1s 2014-08-29 10:22:47 +04:00
parent 8ccad0b86c
commit 87614084ab
4 changed files with 165 additions and 278 deletions

View File

@ -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)

View File

@ -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"))

View File

@ -212,6 +212,21 @@ $m - uptime minutes without zero</string>
<string notr="true">Reaumur</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">cm^-1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">kJ/mol</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">kcal/mol</string>
</property>
</item>
</widget>
</item>
</layout>
@ -258,8 +273,7 @@ $m - uptime minutes without zero</string>
<item>
<widget class="QListWidget" name="listWidget_mount">
<property name="toolTip">
<string>Editable
del - remove item</string>
<string>Editable</string>
</property>
</widget>
</item>
@ -283,8 +297,7 @@ del - remove item</string>
<item>
<widget class="QListWidget" name="listWidget_hddSpeedDevice">
<property name="toolTip">
<string>Editable
del - remove item</string>
<string>Editable</string>
</property>
</widget>
</item>
@ -308,8 +321,7 @@ del - remove item</string>
<item>
<widget class="QListWidget" name="listWidget_hddDevice">
<property name="toolTip">
<string>Editable
del - remove item</string>
<string>Editable</string>
</property>
</widget>
</item>

View File

@ -47,58 +47,62 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="layout_customCmd">
<item row="8" column="0">
<layout class="QHBoxLayout" name="layout_playerSelect">
<item>
<layout class="QHBoxLayout" name="layout_customCommand">
<item>
<widget class="QLabel" name="label_customCommand">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Custom command</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_customCommand">
<property name="toolTip">
<string>Custom command to run</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_customCommand">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_customCommand">
<property name="toolTip">
<string>Editable
del - remove item</string>
<widget class="QLabel" name="label_playerSelect">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Music player</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_playerSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string notr="true">mpris</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mpd</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="10" column="0">
<spacer name="spacer_dataengine">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_gpudev">
<item>
@ -288,177 +292,6 @@ del - remove item</string>
</item>
</layout>
</item>
<item row="8" column="0">
<layout class="QVBoxLayout" name="layout_pkgCommand">
<item>
<layout class="QHBoxLayout" name="layout_pkgCommandSelect">
<item>
<widget class="QLabel" name="label_pkgCommand">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Package manager</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_pkgCommand">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true">pacman -Qu</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">apt-show-versions -u -b</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">aptitude search '~U'</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">yum list updates</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">pkg_version -I -l '&lt;'</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">urpmq --auto-select</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pkgCommandNum">
<item>
<widget class="QLabel" name="label_pkgCommandNum">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Number of null lines</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_pkgCommandNum">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_pkgCommand">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_pkgCommand">
<property name="toolTip">
<string>Editable
del - remove item</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0">
<layout class="QHBoxLayout" name="layout_playerSelect">
<item>
<widget class="QLabel" name="label_playerSelect">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Music player</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_playerSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string notr="true">mpris</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mpd</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="10" column="0">
<spacer name="spacer_dataengine">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>657</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_desktopCmd">
<item>
@ -573,6 +406,56 @@ del - remove item</string>
</item>
</layout>
</item>
<item row="9" column="0">
<layout class="QVBoxLayout" name="layout_pkgCommand">
<item>
<widget class="QTableWidget" name="tableWidget_pkgCommand">
<property name="toolTip">
<string>Editable
del - remove item</string>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Package manager</string>
</property>
</column>
<column>
<property name="text">
<string>Null lines</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidget_customCommand">
<property name="toolTip">
<string>Editable
del - remove item</string>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Custom command</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
@ -581,9 +464,7 @@ del - remove item</string>
</widget>
<tabstops>
<tabstop>scrollArea_dattaengine</tabstop>
<tabstop>lineEdit_customCommand</tabstop>
<tabstop>pushButton_customCommand</tabstop>
<tabstop>listWidget_customCommand</tabstop>
<tabstop>tableWidget_customCommand</tabstop>
<tabstop>lineEdit_desktopCmd</tabstop>
<tabstop>comboBox_gpudev</tabstop>
<tabstop>comboBox_hdddev</tabstop>
@ -591,11 +472,8 @@ del - remove item</string>
<tabstop>lineEdit_mpdaddress</tabstop>
<tabstop>spinBox_mpdport</tabstop>
<tabstop>comboBox_mpris</tabstop>
<tabstop>comboBox_pkgCommand</tabstop>
<tabstop>spinBox_pkgCommandNum</tabstop>
<tabstop>pushButton_pkgCommand</tabstop>
<tabstop>listWidget_pkgCommand</tabstop>
<tabstop>comboBox_playerSelect</tabstop>
<tabstop>tableWidget_pkgCommand</tabstop>
</tabstops>
<resources/>
<connections/>