""" Picture settings dialog, see picture_settings.ui """ ## MODULE IMPORTS ######################################################## import sys, os # Can run stand-alone KBTV_MAINPATH = os.path.dirname(os.path.abspath(sys.argv[0])) if not KBTV_MAINPATH in sys.path: sys.path.append(KBTV_MAINPATH) import btcopyright, btdriver, buildprefs, bt848 if buildprefs.WITH_SAA: import saa if buildprefs.WITH_PWC: import pwc from kdecore import KCmdLineArgs, KApplication from qt import QObject, SIGNAL, SLOT from picture_settings import PictureSettings ## MODULE COPYRIGHT ###################################################### MODULE_AUTHOR = btcopyright.MY_NAME MODULE_AUTHOR_EMAIL = btcopyright.MY_EMAIL MODULE_COPYRIGHT = btcopyright.MY_COPYRIGHT MODULE_LICENSE = btcopyright.BSD_LICENSE MODULE_LICENSE_TEXT = btcopyright.BSD_LICENSE_TEXT ## KBTVPICTURESETTINGS CLASS ############################################# class KbtvPictureSettings(PictureSettings): """ Shows a dialog for adjusting brightness, contrast, etc. """ def __init__(self, fd, *args): """ -> KbtvPictureSettings Creates a non-modal dialog showing four sliders to adjust brightness, contrast, color (green -> red), saturation. Uses the bt848 module for tuner (bktr) operations or the saa module. Uses the pwc module for pwc image operations. If pwc is used, you must provide a file descriptor fd for the opened device. Otherwise, it should be None. Inherits PictureSettings, generated from picture_settings.ui. """ self.fd = fd PictureSettings.__init__(self, *args) if btdriver.use_driver == "pwc" and self.fd: # Tunables self.brightness.setValue(pwc.camera_brightness(self.fd.fileno())) self.contrast.setValue(pwc.camera_contrast(self.fd.fileno())) self.color.setValue(pwc.camera_color(self.fd.fileno())) self.saturation.setValue(pwc.camera_saturation(self.fd.fileno())) elif btdriver.use_driver == "saa": self.brightness.setValue(saa.tuner_brightness()) self.contrast.setValue(saa.tuner_contrast()) self.color.setValue(saa.tuner_color()) self.saturation.setValue(saa.tuner_saturation()) else: self.brightness.setValue(bt848.tuner_brightness()) self.contrast.setValue(bt848.tuner_contrast()) self.color.setValue(bt848.tuner_color()) self.saturation.setValue(bt848.tuner_saturation()) def setBrightness(self): """ -> void Sets the brightness to the slider's value (SLOT). """ if btdriver.use_driver == "pwc" and self.fd: pwc.camera_brightness_set(self.fd.fileno(), self.brightness.value()) elif btdriver.use_driver == "saa": saa.tuner_brightness_set(self.brightness.value()) else: bt848.tuner_brightness_set(self.brightness.value()) def setContrast(self): """ -> void Sets the contrast to the slider's value (SLOT). """ if btdriver.use_driver == "pwc" and self.fd: pwc.camera_contrast_set(self.fd.fileno(), self.contrast.value()) elif btdriver.use_driver == "saa": saa.tuner_contrast_set(self.contrast.value()) else: bt848.tuner_contrast_set(self.contrast.value()) def setColor(self): """ -> void Sets the color (green -> red) to the slider's value (SLOT). """ if btdriver.use_driver == "pwc" and self.fd: pwc.camera_color_set(self.fd.fileno(), self.color.value()) elif btdriver.use_driver == "saa": saa.tuner_color_set(self.color.value()) else: bt848.tuner_color_set(self.color.value()) def setSaturation(self): """ -> void Sets the color saturation to the slider's value (SLOT). """ if btdriver.use_driver == "pwc" and self.fd: pwc.camera_saturation_set(self.fd.fileno(), self.saturation.value()) elif btdriver.use_driver == "saa": saa.tuner_saturation_set(self.saturation.value()) else: bt848.tuner_saturation_set(self.saturation.value()) ## END ################################################################### if __name__ == "__main__": appname = "kbtv_picture.py" description = "PyKDE dialog for picture settings (brightness, etc)" version = "1.2.4" KCmdLineArgs.init (sys.argv, appname, description, version) a = KApplication () QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) # Stand-alone doesn't work with pwc (needs open file descriptor) # Remove stand-alone possibility later w = KbtvPictureSettings() a.setMainWidget(w) w.show() a.exec_loop()