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