Ejemplo n.º 1
0
    def removeTriggered(self):
        downloads_removed = []
        if self.active_tree_widget is None: return
        
        answer = None
 
        for item in self.active_tree_widget.selectedItems():
            download = item.getDownload()
            
            if answer is None:
                if not download.isActive():
                    answer = QtGui.QMessageBox.Yes
                else:
                    answer = gui_utils.confirm(self, "Abort Download(s)", self.tr("This will abort the download(s) too, are you sure?"))
            
            if answer == QtGui.QMessageBox.No: return
            
            if "playlist" in self.active_tree_widget.objectName():
                if download == self.player.download:
                    self.player.stop()
                
                if item in self.player.treeWidgetItems:
                    self.player.treeWidgetItems.remove(item)
                    
            
            if download.isActive():
                download.abort()
                self.downloads_trash.append(download)
            
            #remove the item
            self.removeDownloadItem(item)
            
            downloads_removed.append(download)
        
        if ( "downloads" in self.active_tree_widget.objectName()
        and self.active_tree_widget.topLevelItemCount() == 0 ):
            self.ui.a_clearCompleted.setDisabled(True)
                    
        return downloads_removed
Ejemplo n.º 2
0
 def add(self):
     if not os.path.exists(self.ui.ledit_destFolder.text()):
         gui_utils.warning(self, title=self.tr("Warning"), 
         msg=self.tr("The given download folder doesn't exist!"))
         return
         
     download = self.ui.rb_download.isChecked()
     dest_folder = self.ui.ledit_destFolder.text()
     after_dl = self.ui.combo_options.currentIndex()
     videos = []
     
     for i in xrange(self.ui.tree_validLinks.topLevelItemCount()):
         item = self.ui.tree_validLinks.topLevelItem(i)
         
         if item.checkState(0):
             combobox = self.ui.tree_validLinks.itemWidget(item, 1)
             medium = item.getMedium()
             format = self.mediums[medium][combobox.currentIndex()]
             name = item.text(0)
             overwrite = True
             
             
             if main.file_exists(dest_folder, name):
                 answer = gui_utils.confirm(self, title=self.tr("Overwrite"),
                 msg=self.tr("Do you wish to overwrite this file?") + '\n' + name)
                 
                 if answer == QtGui.QMessageBox.No:
                     filepath = main.get_new_file(dest_folder, name)
                     name = os.path.split(filepath)[1]
                     overwrite = False
             
             videos.append(VideoInfo(name, medium.url, format.url,
             download, dest_folder, after_dl, overwrite))
             
     if not videos or self.ui.tree_validLinks.topLevelItemCount() == 0:
         gui_utils.warning(self, msg=self.tr("There are no valid links to add!"))
     else:
         self.close()
         self.parent.addNewDownloads(videos)
Ejemplo n.º 3
0
    def closeEvent(self, event):
        if self.active_download_items or (self.player and self.player.isActive()) or (
        self.dialogs["add_videos"] and not self.dialogs["add_videos"].isFinished()):
            if self.show_confirm_dialog:
                answer = gui_utils.confirm(self, title="Quit?",
                msg=self.tr("There are still some tasks active, do you really want to quit?" + 
                "\n(you won't be able to continue them after quitting)"))
            else:
                answer = QtGui.QMessageBox.Yes
            
            if answer == QtGui.QMessageBox.Yes:
                self.abortDownloads()
                if not self.isEverythingAborted():
                    #hide GUI so it gets out of the user's way while the app is closing
                    self.hide() 
                    self.close_timer.start(750)
                    event.ignore()
                    return
            else:
                event.ignore()
                return
           

        self.saveWindow()