Esempio n. 1
0
    def openEditor(self,nfile):
        text = ""
        try:
            infile = open(nfile, 'r')
            tt = infile.read()
            if(config.encoding() == Encoding.UNICODE):
                text = unicode(tt,"utf-8")#must add utf-8 for it to work
            else:
                text = str(tt)

            #infile.close()
            self.files.append(nfile)
            config.setFile(self.files) 
            self.dirty.append(False)
            #print len(self.files)
            tab = Editor(self,text,self.syntax(nfile),self.colorStyle) 
            self.tabWidget.addTab(tab,ospathbasename(nfile))
            tab.textChanged.connect(lambda:self.setDirty(nfile))  
            if(self.files != None):
                if(len(self.files)) != 0:
                    #This line sets the opened file to display first Important not checked
                    self.tabWidget.setCurrentIndex(len(self.files)-1)
            return True
        except:
            if(nfile in self.files):
                self.files.remove(nfile)
            config.setFile(self.files)
            QMessageBox.about(self,"Can't Open","File is Being Used\n"+nfile)
            return False
        finally:
            if(infile != None):
                infile.close()
Esempio n. 2
0
 def openEditor(self,nfile):
     text = ""
     infile = open(nfile, 'r')
     tt = infile.read()
     try:
         text = str(tt)
         self.files.append(nfile)
         config.setFile(self.files) 
         self.dirty.append(False)
         tab = Editor(self,text,nfile) 
         self.tabWidget.addTab(tab,ospathbasename(nfile))
         #print len(self.files)
         tab.textChanged.connect(lambda:self.setDirty(nfile))  
         if(self.files != None):
             if(len(self.files)) != 0:
                 self.tabWidget.setCurrentIndex(len(self.files)-1)
     except:
         if(nfile in self.files):
             self.files.remove(nfile)
         config.setFile(self.files)
         QMessageBox.about(self,"Can't Open","File is Being Used\n"+nfile)
         error("Opening: File is Being Used "+nfile)
         return False
     finally:
         if(infile != None):
             infile.close() 
             return True
         return False
Esempio n. 3
0
 def setDirty(self, file):
     """On change of text in textEdit window, set the flag
     "dirty" to True"""
     index = self.files.index(file)
     if self.dirty[index]:
         return True
     self.dirty[index] = True
     flbase = ospathbasename(self.files[index])
     self.tabWidget.setTabText(index, "*" + flbase)
Esempio n. 4
0
 def __init__(self,parent,startDir,closed = False):
     QTreeWidgetItem.__init__(self,parent)
     self.path = ospathjoin(startDir)
     self.closed = closed
     if(self.closed):
         self.setIcon(0,Icons.cprj)
     else:
         self.setIcon(0,Icons.prj)
     self.setText (0, ospathbasename(ospathnormpath(startDir))) # set the text of the first 0
     self.setToolTip(0,startDir)
     self.Count += 1
     self.setExpanded(True)
Esempio n. 5
0
 def newFile(self,item):
     itempath = item.getPath()
     text,ok = QInputDialog.getText(self,"QInputDialog::getText()","Name:") 
     if (ok and text != ''):
         fname = ospathjoin(ospathdirname(itempath),str(text))
         try:
             nfile = open(fname,'w')
             nfile.close()
             f = File(item,ospathbasename(fname),ospathdirname(fname))
             item.addChild(f)
         except:
             QMessageBox.about(self,"Error","Could Not Create The File")
Esempio n. 6
0
 def renameFile(self,item):
     text,ok = QInputDialog.getText(self,"QInputDialog::getText()","New Name:")
     itempath = item.getPath()
     if (ok and text != ''):
         newname = ospathjoin(ospathdirname(itempath),str(text))
         try:
             #print newname
             osrename(itempath,newname)
             p = item.parent()
             p.removeChild(item)
             f = File(p,ospathbasename(newname),ospathdirname(newname))
             #p.addChild(f)
         except:
             QMessageBox.about(self,"Error","Could Not Rename The File")
Esempio n. 7
0
    def __init__(self,parent,nfile):
        QtGui.QDialog.__init__(self,parent)
        self.resize(300, 250)
        self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, self)
        self.mediaObject = Phonon.MediaObject(self)

        self.mediaObject.setTickInterval(1000)
        self.mediaObject.tick.connect(self.tick)
        self.mediaObject.stateChanged.connect(self.stateChanged)

        Phonon.createPath(self.mediaObject, self.audioOutput)
        
        self.setupActions()
        self.setupUi()
        self.timeLcd.display("00:00") 
        self.finished.connect(self.stop)
        if nfile == "":
            return
        self.title.setText("<b><big>"+ospathbasename(nfile)+"</big></b>")
        self.mediaObject.enqueue(Phonon.MediaSource(nfile))
        self.mediaObject.play()
Esempio n. 8
0
    def createTab(self, nfile):
        if nfile != None:
            if self.files != None:
                if len(self.files) != 0:
                    for i in self.files:
                        if i == nfile:
                            # print "File Already Open\n"+nfile
                            self.tabWidget.setCurrentIndex(self.files.index(nfile))
                            return
            if type(nfile) == str:
                if ospathexists(nfile):
                    text = ""
                    try:
                        infile = open(nfile, "r")
                        text = infile.read()
                        infile.close()
                        config.addFile(nfile)
                        self.dirty.append(False)
                        self.files.append(nfile)
                        # print len(self.files)
                    except:
                        config.removeFile(nfile)
                        QMessageBox.about(self, "Can't Open", "File Does Not Exist or Locked\n" + nfile)

                    tab = Editor(self, text, self.syntax(nfile), self.colorStyle)
                    self.tabWidget.addTab(tab, ospathbasename(nfile))
                    tab.textChanged.connect(lambda: self.setDirty(nfile))
                    if self.files != None:
                        if (len(self.files)) != 0:
                            # This line sets the opened file to display first Important not checked
                            self.tabWidget.setCurrentIndex(len(self.files) - 1)
                else:
                    # dont know must check this the last file is not removed executes only
                    # twice when it has to remove 3 files
                    # check sel.files
                    # print len(config.files())
                    config.removeFile(nfile)
                    QMessageBox.about(self, "Can't Open", "File Does Not Exist or Locked\n" + nfile)
Esempio n. 9
0
 def clearDirty(self, index):
     """Clear the dirty."""
     self.dirty[index] = False
     flbase = ospathbasename(self.files[index])
     self.tabWidget.setTabText(index, flbase)