[Uludag-commits] r15584 - trunk/staj-projeleri/scanner/src

uludag-commits at pardus.org.tr uludag-commits at pardus.org.tr
1 Eki 2007 Pzt 16:54:39 EEST


Author: asli.okur
Date: Mon Oct  1 16:54:38 2007
New Revision: 15584

Added:
   trunk/staj-projeleri/scanner/src/progress.py
   trunk/staj-projeleri/scanner/src/scanevent.py
   trunk/staj-projeleri/scanner/src/scanthread.py
Modified:
   trunk/staj-projeleri/scanner/src/main.py
   trunk/staj-projeleri/scanner/src/scanner.py
   trunk/staj-projeleri/scanner/src/toolbar.py
Log:
Tooltip eklendi.
ProgressDialog eklendi.
Preview ve Scan için ayrı thread açıldı.
Cancel sırasında problem var.
Unuttuğum birşeyler vardır daha. 



Modified: trunk/staj-projeleri/scanner/src/main.py
=================================================================
--- trunk/staj-projeleri/scanner/src/main.py	(original)
+++ trunk/staj-projeleri/scanner/src/main.py	Mon Oct  1 16:54:38 2007
@@ -2,13 +2,40 @@
 
 import sys
 from qt import *
+from kdecore import *
+from kdeui import *
+from kfile import *
 import sane
 from scanner import *
 import pickle
 
-class Main(QDialog):
+#version = '0.1'
+#description = "Scanner Interface"
+
+#def loadIcon(name, group=KIcon.Desktop):
+    #return KGlobal.iconLoader().loadIcon(name, group)
+
+#def loadIconSet(name, group=KIcon.Desktop):
+        #return KGlobal.iconLoader().loadIconSet(name, group)
+
+#def AboutData():
+   #about_data = KAboutData(
+        #'scanner',
+        #'Scanner',
+        #version,
+        #description,
+        #KAboutData.License_GPL,
+        #'(C) 2007 UEKAE/TÜBİTAK',
+        #None,
+        #None,
+        #'blabla at pardus.org.tr')
+   #return about_data
+
+class Main(KDialog):
     def __init__(self,parent = None,name = None,modal = 0,fl = 0):
-        QDialog.__init__(self,parent,name,modal,fl)
+        KDialog.__init__(self,parent,name,modal,fl)
+	
+	#self.setIcon(loadIcon("scanner"))
 
         if not name:
             self.setName("Main")
@@ -127,11 +154,24 @@
         
 
 if __name__ == "__main__":
+    ##a = KApplication(sys.argv,"")
+    #about_data = AboutData()
+    #KCmdLineArgs.init(sys.argv,about_data)
+    #a = KUniqueApplication(True, True, True)
+    ##QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+    #mainForm = Main()
+    #a.setMainWidget(mainForm)
+    #QObject.connect(a, SIGNAL("aboutToQuit()"), mainForm.quit)
+    ##QObject.connect(a, SIGNAL("aboutToQuit()"), a, SLOT("quit()"))
+    ##QObject.connect(a,SIGNAL("lastWindowClosed()"),mainForm.quit)
+    ##a.exec_loop()
+    #sys.exit(mainForm.exec_loop())
+    
     a = QApplication(sys.argv)
     QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
-    w = Main()
-    a.setMainWidget(w)
-    QObject.connect(a,SIGNAL("lastWindowClosed()"),w.quit)
+    mainForm = Main()
+    a.setMainWidget(mainForm)
+    QObject.connect(a,SIGNAL("lastWindowClosed()"),mainForm.quit)
     a.exec_loop()
 
 

Modified: trunk/staj-projeleri/scanner/src/scanner.py
=================================================================
--- trunk/staj-projeleri/scanner/src/scanner.py	(original)
+++ trunk/staj-projeleri/scanner/src/scanner.py	Mon Oct  1 16:54:38 2007
@@ -1,5 +1,8 @@
 import sys
 from qt import *
+from kdecore import *
+from kdeui import *
+from kfile import *
 import sane
 
 from options import *
@@ -8,19 +11,22 @@
 from scanresult import *
 from scanresultmulti import *
 from extractor import *
+from progress import *
+
+from scanthread import *
 
 class ScanWindow(QMainWindow):
     def __init__(self,parent = None,name = None,fl = 0):
         QMainWindow.__init__(self,parent,name,fl)
         
-        sane.init()
+        #sane.init()
         
         self.statusBar()
+	self.statusBar().message("Ready")
 
         if not name:
             self.setName("Scanner")
 
-
         self.setCentralWidget(QWidget(self,"qt_central_widget"))
 
         self.hLayout = QHBoxLayout(self.centralWidget(),11,6,"mainFormLayout")
@@ -46,6 +52,14 @@
         self.connect(self.toolbar.zoomoutButton,SIGNAL("released()"),self.previewArea.previewImage.zoomout)
 
         self.connect(self.previewArea.previewImage,PYSIGNAL("selectionCreated"),self.selectArea)
+	
+	self.progress = Progress(self.centralWidget())
+	#self.connect(self.options.device, PYSIGNAL("sigScanProgress"), self.progress.setProgress)
+	self.progress.setTotalSteps(0)
+	self.progress.hide()
+	
+	self.connect(self.progress,SIGNAL("canceled()"),self.stopScan)
+	
 
         self.helpContentsAction = QAction(self,"helpContentsAction")
         self.helpIndexAction = QAction(self,"helpIndexAction")
@@ -76,7 +90,7 @@
         sane.exit()
 
     def languageChange(self):
-        self.setCaption(self.__tr("Form1"))
+        self.setCaption(self.__tr("Scanner"))
         self.helpContentsAction.setText(self.__tr("Contents"))
         self.helpContentsAction.setMenuText(self.__tr("&Contents..."))
         self.helpContentsAction.setAccel(QString.null)
@@ -91,16 +105,16 @@
 
 
     def helpIndex(self):
-        print "Form1.helpIndex(): Not implemented yet"
+        print "Scanner.helpIndex(): Not implemented yet"
 
     def helpContents(self):
-        print "Form1.helpContents(): Not implemented yet"
+        print "Scanner.helpContents(): Not implemented yet"
 
     def helpAbout(self):
-        print "Form1.helpAbout(): Not implemented yet"
+	about = QMessageBox.about(self, "About", "Bu program Pardus staj projeleri kapsaminda hazirlanmistir." )
 
     def __tr(self,s,c = None):
-        return qApp.translate("Form1",s,c)
+        return qApp.translate("Scanner",s,c)
 
     def newDeviceSelected(self):
         self.toolbar.setEnabled(True)
@@ -119,7 +133,7 @@
         self.toolbar.setEnabled(False)
         self.previewArea.noImage()
         self.previewArea.setEnabled(False)
-
+	
     def selectArea(self,ratio_tl_x,ratio_tl_y,ratio_br_x,ratio_br_y):
         if self.options.device != None:
             for option in self.options.optionList:
@@ -146,7 +160,10 @@
 
     def previewScan(self):
         if self.options.device != None:
-            oldValues = self.options.getOptionValues()
+            qApp.processEvents()
+	    self.statusBar().message("Busy")
+	    self.progress.show()
+            self.oldValues = self.options.getOptionValues()
             
             for option in self.options.optionList:
                 if option.deviceOption.is_settable() and option.deviceOption.is_active():
@@ -163,19 +180,43 @@
                     if option.deviceOption.name == "br-y":
                         self.options.device.__setattr__("br_y",max(option.deviceOption.constraint))
                     
-            self.options.device.start()
-    
-            im = self.options.device.snap();
+            #self.options.device.start()
      
-            self.previewArea.previewImage.setImage(im)
+            #im = self.options.device.snap();
+     	    self.previewThread = PreviewThread(self, self.options.device)
+	    self.previewThread.start()
+	    #self.previewThread.work(self.options)
+            #self.previewArea.previewImage.setImage(im)
             
-            self.options.setOptionValues(oldValues)
-
-    def startScan(self):
-        if self.options.device != None:
-            self.options.device.start()
-    
-            im = self.options.device.snap();
+            #self.options.setOptionValues(oldValues)
+	    #self.statusBar().message("Ready")
+	    
+	    
+    def stopScan(self):
+	if self.options.device != None:
+		#self.options.device.cancel()
+		self.stopThread = StopThread(self, self.options.device)
+		self.stopThread.start()
+		#qApp.wakeUpGuiThread()
+		qApp.processEvents()
+		self.progress.setLabelText("<p align=\"center\">Stopping</p>")
+		#self.statusBar().message("Ready")
+		#self.progress.hide()
+		
+    def backToNormal(self):
+	self.progress.setLabelText("<p align=\"center\">Scanning in progress</p>")
+	self.statusBar().message("Ready")
+	self.progress.hide()
+
+    def customEvent(self,event):
+        if(event.type() == 1002):
+            self.createScanWindow(event.image)
+	if(event.type() == 1003):
+	    self.createPreview(event.image)
+	if(event.type() == 1004):
+	    self.backToNormal()
+	    
+    def createScanWindow(self, im):
             self.maxDiff = 20
             self.aveRgb = 0x222625
             self.minSize = 90000
@@ -188,7 +229,59 @@
                     s.addImage(tmpImage)
             else:
                 s = ScanResult(im,self,"scanResult",1)
+	    s.show()
+	    #self.progress.setProgress(100)
+	    self.progress.hide()
+	    self.statusBar().message("Ready")
+	    
+    def createPreview(self, im):
+            self.statusBar().message("Ready")
+	    self.progress.hide()
+	    self.previewArea.previewImage.setImage(im)
+            self.options.setOptionValues(self.oldValues)
+
+    def startScan(self):
+        if self.options.device != None:
+	    self.statusBar().message("Busy")
+	    qApp.processEvents()
+	    self.progress.show()
+	    #self.progress.setProgress(0)
+	    #self.hide()
+	    
+	    #self.options.device.start()
+            #im = self.options.device.snap()
+	    
+	    self.scanThread = ScanThread(self, self.options.device)
+	    self.scanThread.start()
+	    #self.scanThread.work(self.options)
+	    #while(self.worker.finished() == False):
+		#pass
+	    
+	    #im = self.scanThread.getImage()
+	    
+	    #qApp.processEvents()
+	    #qEventLoop.processEvents(AllEvents,500)
+	    
+	    
+	    
+            #self.maxDiff = 20
+            #self.aveRgb = 0x222625
+            #self.minSize = 90000
+            #self.enableExtract = True
+            #if self.enableExtract:
+                #extract(im,self.maxDiff,self.aveRgb,self.minSize)
+                #s = ScanResultMulti(self,"scanResultMulti",1)
+                #tmpImage = QImage()
+                #while(nextImage(tmpImage)):
+                    #s.addImage(tmpImage)
+            #else:
+                #s = ScanResult(im,self,"scanResult",1)
             
-            s.show()
+	    #self.progress.setProgress(100)
+            #s.show()
+	    #self.statusBar().message("Ready")
+	    #self.progress.reset()
+	    #self.show()
+	    #self.progress.hide()
      
-            return
+            #return

Modified: trunk/staj-projeleri/scanner/src/toolbar.py
=================================================================
--- trunk/staj-projeleri/scanner/src/toolbar.py	(original)
+++ trunk/staj-projeleri/scanner/src/toolbar.py	Mon Oct  1 16:54:38 2007
@@ -26,6 +26,7 @@
         self.previewButton = QToolButton(LayoutWidget,"previewButton")
         self.previewButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.previewButton.sizePolicy().hasHeightForWidth()))
         self.previewButton.setText("P")
+	QToolTip.add(self.previewButton,self.__tr("Preview"))
         self.previewButton.setMinimumSize(QSize(30,30))
         self.previewButton.setAutoRaise(1)
         layout7.addWidget(self.previewButton)
@@ -33,6 +34,7 @@
         self.scanButton = QToolButton(LayoutWidget,"scanButton")
         self.scanButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.scanButton.sizePolicy().hasHeightForWidth()))
         self.scanButton.setText("S")
+	QToolTip.add(self.scanButton,self.__tr("Scan"))
         self.scanButton.setMinimumSize(QSize(30,30))
         #self.scanButton.setIconSet(QIconSet(self.image0))
         self.scanButton.setAutoRaise(1)
@@ -42,6 +44,7 @@
         self.fitButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.fitButton.sizePolicy().hasHeightForWidth()))
         self.fitButton.setMinimumSize(QSize(30,30))
         self.fitButton.setText("F")
+	QToolTip.add(self.fitButton,self.__tr("Fit Scan Area"))
         self.fitButton.setAutoRaise(1)
         layout7.addWidget(self.fitButton)
 
@@ -49,6 +52,7 @@
         self.fitSelectButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.fitSelectButton.sizePolicy().hasHeightForWidth()))
         self.fitSelectButton.setMinimumSize(QSize(30,30))
         self.fitSelectButton.setText("FS")
+	QToolTip.add(self.fitSelectButton,self.__tr("Fit Selected Area"))
         self.fitSelectButton.setAutoRaise(1)
         layout7.addWidget(self.fitSelectButton)
 
@@ -56,6 +60,7 @@
         self.zoominButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.zoominButton.sizePolicy().hasHeightForWidth()))
         self.zoominButton.setMinimumSize(QSize(30,30))
         self.zoominButton.setIconSet(QIconSet(self.image0))
+	QToolTip.add(self.zoominButton,self.__tr("Zoom In"))	
         self.zoominButton.setAutoRaise(1)
         layout7.addWidget(self.zoominButton)
 
@@ -63,6 +68,7 @@
         self.actualSizeButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.actualSizeButton.sizePolicy().hasHeightForWidth()))
         self.actualSizeButton.setMinimumSize(QSize(30,30))
         self.actualSizeButton.setText("AS")
+	QToolTip.add(self.actualSizeButton,self.__tr("Actual Size"))
         self.actualSizeButton.setAutoRaise(1)
         layout7.addWidget(self.actualSizeButton)
 
@@ -70,7 +76,11 @@
         self.zoomoutButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.zoomoutButton.sizePolicy().hasHeightForWidth()))
         self.zoomoutButton.setMinimumSize(QSize(30,30))
         self.zoomoutButton.setIconSet(QIconSet(self.image1))
+	QToolTip.add(self.zoomoutButton,self.__tr("Zoom Out"))
         self.zoomoutButton.setAutoRaise(1)
         layout7.addWidget(self.zoomoutButton)
         spacer4 = QSpacerItem(20,50,QSizePolicy.Minimum,QSizePolicy.Expanding)
         layout7.addItem(spacer4)
+
+    def __tr(self,s,c = None):
+        return qApp.translate("toolbar",s,c)


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi