2011-01-15 16:48:09 +01:00
|
|
|
from servicebase import DigitallyImportedServiceBase
|
2011-01-15 14:59:58 +01:00
|
|
|
|
|
|
|
from PyQt4.QtCore import QSettings
|
|
|
|
from PyQt4.QtGui import QDialog, QIcon
|
2011-01-15 01:57:43 +01:00
|
|
|
import PyQt4.uic
|
|
|
|
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
class SettingsDialog(QDialog):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
QDialog.__init__(self, parent)
|
|
|
|
|
|
|
|
self.path = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# Set up the user interface
|
|
|
|
PyQt4.uic.loadUi(os.path.join(self.path, "settingsdialog.ui"), self)
|
|
|
|
|
2011-01-15 14:59:58 +01:00
|
|
|
# Set the window icon
|
2011-01-15 01:57:43 +01:00
|
|
|
self.setWindowIcon(QIcon(os.path.join(self.path, "icon-small.png")))
|
2011-01-15 14:59:58 +01:00
|
|
|
|
|
|
|
def showEvent(self, event):
|
|
|
|
# Load the settings
|
|
|
|
settings = QSettings()
|
2011-01-15 16:48:09 +01:00
|
|
|
settings.beginGroup(DigitallyImportedServiceBase.SETTINGS_GROUP)
|
2011-01-15 14:59:58 +01:00
|
|
|
self.type.setCurrentIndex(int(settings.value("audio_type", 0).toPyObject()))
|
|
|
|
self.username.setText(settings.value("username", "").toPyObject())
|
|
|
|
self.password.setText(settings.value("password", "").toPyObject())
|
|
|
|
|
|
|
|
QDialog.showEvent(self, event)
|
|
|
|
|
|
|
|
def accept(self):
|
|
|
|
# Save the settings
|
|
|
|
settings = QSettings()
|
2011-01-15 16:48:09 +01:00
|
|
|
settings.beginGroup(DigitallyImportedServiceBase.SETTINGS_GROUP)
|
2011-01-15 14:59:58 +01:00
|
|
|
settings.setValue("audio_type", self.type.currentIndex())
|
|
|
|
settings.setValue("username", self.username.text())
|
|
|
|
settings.setValue("password", self.password.text())
|
|
|
|
|
|
|
|
QDialog.accept(self)
|