Added:
trunk/kamera/configwindow.py
Modified:
trunk/TODO
trunk/kamera/defaultsettings.py
trunk/kamera/mainwindow.py
trunk/ui/configwindow.ui
trunk/ui/mainwindow.ui
Log:
configwindow
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Wed Nov 26 22:51:36 2008
@@ -1,3 +1,4 @@
Settings Window
- Webcam Selection
- Display Settings(colors, mirror)
+ Webcam selection
+ Display Settings(colors)
+ Image format selection
Added: trunk/kamera/configwindow.py
==============================================================================
--- (empty file)
+++ trunk/kamera/configwindow.py Wed Nov 26 22:51:36 2008
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Licensed under GPL v3
+# Copyright 2008, Ugur Cetin
+#
+# This program is free software; you can redistribute it and/or modify it
under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option)
+# any later version.
+#
+# Please read the COPYING file.
+#
+
+from PyQt4 import QtCore
+from PyQt4 import QtGui
+
+from ui_configwindow import Ui_ConfigWindow
+from defaultsettings import IMAGE_FORMAT, IMAGE_DIRECTORY,
VIDEO_FLIP_TOP_BOTTOM, VIDEO_FLIP_LEFT_RIGHT
+
+class ConfigWindow(QtGui.QDialog, Ui_ConfigWindow):
+ def __init__(self, parent=0):
+ QtGui.QDialog.__init__(self, parent)
+ self.setupUi(self)
+ self.setModal(True)
+ self.settings = QtCore.QSettings()
+ self.loadSettings()
+ self.connect(self, QtCore.SIGNAL("accepted()"), self.saveSettings)
+
+ def loadSettings(self):
+
self.checkBox_video_flip_top_bottom.setChecked(self.settings.value("video/flip_top_bottom",
VIDEO_FLIP_TOP_BOTTOM).toBool())
+
self.checkBox_video_flip_left_right.setChecked(self.settings.value("video/flip_left_right",
VIDEO_FLIP_LEFT_RIGHT).toBool())
+
self.lineEdit_image_directory.setText(self.settings.value("image/directory",
IMAGE_DIRECTORY).toString())
+
+ def saveSettings(self):
+ self.settings.setValue("video/flip_top_bottom",
QtCore.QVariant(self.checkBox_video_flip_top_bottom.isChecked()))
+ self.settings.setValue("video/flip_left_right",
QtCore.QVariant(self.checkBox_video_flip_left_right.isChecked()))
+ self.settings.setValue("image/directory",
QtCore.QVariant(self.lineEdit_image_directory.text()))
+ QtCore.QDir.setCurrent(self.settings.value("image/directory",
IMAGE_DIRECTORY).toString())
+
+ @QtCore.pyqtSignature("bool")
+ def on_pushButton_image_directory_clicked(self):
+
self.lineEdit_image_directory.setText(QtGui.QFileDialog.getExistingDirectory(self,
+ QtGui.QApplication.translate("ConfigWindow", "Select Image
Directory"),
+ self.settings.value("image/directory",
IMAGE_DIRECTORY).toString()))
Modified: trunk/kamera/defaultsettings.py
==============================================================================
--- trunk/kamera/defaultsettings.py (original)
+++ trunk/kamera/defaultsettings.py Wed Nov 26 22:51:36 2008
@@ -12,8 +12,10 @@
# Please read the COPYING file.
#
+from PyQt4.QtCore import QDir
from PyQt4.QtCore import QVariant
IMAGE_FORMAT = QVariant("jpg")
VIDEO_FLIP_LEFT_RIGHT = QVariant(True)
VIDEO_FLIP_TOP_BOTTOM = QVariant(False)
+IMAGE_DIRECTORY = QVariant(QDir.homePath())
Modified: trunk/kamera/mainwindow.py
==============================================================================
--- trunk/kamera/mainwindow.py (original)
+++ trunk/kamera/mainwindow.py Wed Nov 26 22:51:36 2008
@@ -23,7 +23,8 @@
from opencvwidget import OpenCVWidget, CamThread
from ui_mainwindow import Ui_MainWindow
-from defaultsettings import IMAGE_FORMAT, VIDEO_FLIP_LEFT_RIGHT,
VIDEO_FLIP_TOP_BOTTOM
+from configwindow import ConfigWindow
+from defaultsettings import IMAGE_DIRECTORY, IMAGE_FORMAT,
VIDEO_FLIP_LEFT_RIGHT, VIDEO_FLIP_TOP_BOTTOM
import __init__
class MyOpenCVWidget(OpenCVWidget):
@@ -37,9 +38,9 @@
def updateImage(self, cvimage):
try:
image = opencv.adaptors.Ipl2PIL(cvimage)
- if self.settings.value("video/flip_left_right",
VIDEO_FLIP_LEFT_RIGHT):
+ if self.settings.value("video/flip_left_right",
VIDEO_FLIP_LEFT_RIGHT).toBool():
image = image.transpose(Image.FLIP_LEFT_RIGHT)
- if self.settings.value("video/flip_top_bottom",
VIDEO_FLIP_TOP_BOTTOM):
+ if self.settings.value("video/flip_top_bottom",
VIDEO_FLIP_TOP_BOTTOM).toBool():
image = image.transpose(Image.FLIP_TOP_BOTTOM)
self.image = ImageQt.ImageQt(image)
self.pixmap = QtGui.QPixmap.fromImage(self.image)
@@ -55,6 +56,8 @@
self.settings = QtCore.QSettings()
self.createImageList()
self.opencvwidget = MyOpenCVWidget(self.label_webcam)
+ self.configWindow = ConfigWindow(self)
+ QtCore.QDir.setCurrent(self.settings.value("image/directory",
IMAGE_DIRECTORY).toString())
#TODO: connect opencvwidget's error signal to a slot
def createImageList(self):
@@ -81,11 +84,11 @@
self.addImage(self.opencvwidget.pixmap)
@QtCore.pyqtSignature("bool")
- def on_action_About_Qt_triggered(self):
- QtGui.QMessageBox.aboutQt(self)
-
- @QtCore.pyqtSignature("bool")
- def on_action_About_Kamera_triggered(self):
+ def on_pushButton_about_clicked(self):
title = QtGui.QApplication.translate("MainWindow", "About Kamera")
text = QtGui.QApplication.translate("MainWindow", "Kamera %1 -
webcam photographer\nThis software is released under the terms of GPL
v3.\nhttp://kamera.googlecode.com\n\nDeveloper:\nUgur Cetin <ugur.jnmbk at
gmail.com>").arg(__init__.__version__)
QtGui.QMessageBox.about(self, title, text)
+
+ @QtCore.pyqtSignature("bool")
+ def on_pushButton_configure_clicked(self):
+ self.configWindow.show()
Modified: trunk/ui/configwindow.ui
==============================================================================
--- trunk/ui/configwindow.ui (original)
+++ trunk/ui/configwindow.ui Wed Nov 26 22:51:36 2008
@@ -1,6 +1,6 @@
<ui version="4.0" >
- <class>Dialog</class>
- <widget class="QDialog" name="Dialog" >
+ <class>ConfigWindow</class>
+ <widget class="QDialog" name="ConfigWindow" >
<property name="geometry" >
<rect>
<x>0</x>
@@ -58,10 +58,14 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
- <widget class="QLineEdit" name="lineEdit" />
+ <widget class="QLineEdit" name="lineEdit_image_directory" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QPushButton" name="pushButton" >
+ <widget class="QPushButton"
name="pushButton_image_directory" >
<property name="text" >
<string>...</string>
</property>
@@ -70,7 +74,7 @@
</layout>
</item>
<item>
- <widget class="QComboBox" name="comboBox" >
+ <widget class="QComboBox" name="comboBox_image_format" >
<property name="currentIndex" >
<number>1</number>
</property>
@@ -150,7 +154,7 @@
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox_2" >
+ <widget class="QComboBox" name="comboBox_video_webcam" >
<item>
<property name="text" >
<string>Default</string>
@@ -167,14 +171,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
- <widget class="QCheckBox" name="checkBox" >
+ <widget class="QCheckBox"
name="checkBox_video_flip_left_right" >
<property name="text" >
<string>Flip Horizontally</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="checkBox_2" >
+ <widget class="QCheckBox"
name="checkBox_video_flip_top_bottom" >
<property name="text" >
<string>Flip Vertically</string>
</property>
@@ -234,7 +238,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
- <receiver>Dialog</receiver>
+ <receiver>ConfigWindow</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
@@ -250,7 +254,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
- <receiver>Dialog</receiver>
+ <receiver>ConfigWindow</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
Modified: trunk/ui/mainwindow.ui
==============================================================================
--- trunk/ui/mainwindow.ui (original)
+++ trunk/ui/mainwindow.ui Wed Nov 26 22:51:36 2008
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>673</width>
- <height>734</height>
+ <height>705</height>
</rect>
</property>
<property name="windowTitle" >
@@ -76,6 +76,20 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="pushButton_configure" >
+ <property name="text" >
+ <string>&Configure...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_about" >
+ <property name="text" >
+ <string>&Aboout...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@@ -118,34 +132,6 @@
</layout>
</widget>
<widget class="QStatusBar" name="statusbar" />
- <widget class="QMenuBar" name="menuBar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>673</width>
- <height>29</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_Help" >
- <property name="title" >
- <string>&Help</string>
- </property>
- <addaction name="action_About_Kamera" />
- <addaction name="action_About_Qt" />
- </widget>
- <addaction name="menu_Help" />
- </widget>
- <action name="action_About_Qt" >
- <property name="text" >
- <string>About &Qt...</string>
- </property>
- </action>
- <action name="action_About_Kamera" >
- <property name="text" >
- <string>About &Kamera...</string>
- </property>
- </action>
</widget>
<resources>
<include location="../data/kamera.qrc" />