示例#1
0
 def save(self):
     if get_current_tournament() is None:
         print("Tournament None")
         return
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     name,path = QFileDialog.getSaveFileName(self, "Save Tournament", filter="Tournament File (*.Tournament)", options=options)
     
     if (path != ""):
         get_current_tournament().save(name)
     self.updateStatusDisplay()
示例#2
0
 def stopRecording(self):
     self.updateStatusDisplay()
     if get_current_tournament() is None:
         print("Tournament None")
         return
     self.isRecording = False
     self.camera.stopRecording()
     self.recordButton.updateStyle(self.isRecording)
     self.id+=1
     get_current_tournament().save()
     self.comboBox.setCurrentIndex(self.id)
     self.match_recording = None
     self.updateStatusDisplay()
示例#3
0
 def startRecording(self):
     self.updateStatusDisplay()
     if get_current_tournament() is None:
         print("Tournament None!")
         return
     self.match_recording = get_current_tournament().matches[self.comboBox.currentIndex()]
     self.isRecording = True
     filename = self.match_recording.create_file_name()
     self.camera.startRecording("videos/" + filename)
     get_current_tournament().matches[self.comboBox.currentIndex()]\
         .videos.append(filename)
     self.recordButton.updateStyle(self.isRecording)
     self.id = self.comboBox.currentIndex()
     self.updateStatusDisplay()
示例#4
0
 def updateStatusDisplay(self):
     teams = ['','','','']
     if get_current_tournament() is not None and get_current_tournament().matches is not None:
         r1 = get_current_tournament().matches[self.comboBox.currentIndex()].red1
         r2 = get_current_tournament().matches[self.comboBox.currentIndex()].red2
         b1 = get_current_tournament().matches[self.comboBox.currentIndex()].blue1
         b2 = get_current_tournament().matches[self.comboBox.currentIndex()].blue2
         teams = [r1, r2, b1, b2]
         print(teams)
         self.updateWindowTitle(match_number=get_current_tournament().
                            matches[self.comboBox.currentIndex()].toId(), teams=teams)
         self.infoDisplay.updateInfo(get_current_tournament().matches[self.comboBox.currentIndex()].toId(), teams, self.isRecording)
示例#5
0
    def toggleRecording(self):
        if get_current_tournament() is None:
            return

        if (self.isRecording):
            self.stopRecording()
        else:
            self.startRecording()
        # update the window title and status bar
        self.updateStatusDisplay()
示例#6
0
    def getVideos(self):
        print("Videos")
        videos_array = []
        for match in get_current_tournament().matches:
            print(match.videos)
            for video in match.videos:
                video_tuple = (video, match)
                videos_array.append(video_tuple)

        return videos_array
示例#7
0
 def reload_combo(self):
     self.comboBox.clear()
     current_tournament = get_current_tournament()
     print(current_tournament)
     if current_tournament is not None:
         for match in current_tournament.matches:
             self.comboBox.addItem(match.toInfoString())
         self.id = 0
         self.match_recording = None
         self.comboBox.activated.connect(self.matchSelected)
     self.updateStatusDisplay()
示例#8
0
    def __init__(self, camera, parent=None):
        super(VideoWindow, self).__init__(parent)
        global vWindow
        vWindow = self
        self.createMenu()
        self.camera = camera
        # quit on alt+f4 or ctrl+w
        self.shortcut = QShortcut(QKeySequence.Close, self)
        self.shortcut.activated.connect(self.onQuit)
        # by default, camera recording is off
        self.isRecording = False
        self.match_number = None
        # Create a widget for window contents
        centralWidget = QWidget(self)
        self.setCentralWidget(centralWidget)
		
        # create the top information display row
        self.infoDisplay = infoDisplay.InfoDisplay()
		
        # create the bottom control layout with buttons
        self.recordButton = recordButton.RecordButton()
        self.recordButton.clicked.connect(self.toggleRecording)

        self.comboBox = QComboBox()
        current_tournament = get_current_tournament()
        if current_tournament is not None:
            for match in current_tournament.matches:
                self.comboBox.addItem(match.toInfoString())
            self.comboBox.activated.connect(self.matchSelected)
        controlLayout = QHBoxLayout()
        controlLayout.setContentsMargins(0, 0, 0, 0)
        controlLayout.addWidget(self.comboBox)
        controlLayout.addWidget(self.recordButton)

        # create the mainlayout that contains the viewfiner and controls
        mainLayout = QVBoxLayout()
        mainLayout.addLayout(self.infoDisplay)
        mainLayout.addWidget(self.camera.getViewFinder())
        mainLayout.addLayout(controlLayout)

        # apply the mainlayout
        centralWidget.setLayout(mainLayout)
        self.updateWindowTitle()

        #load default tournament file
        self.load_default()

        # self.recordButton.updateStyle(False)
        self.updateStatusDisplay()
示例#9
0
    def updateStyle(self, isRecording):
        self.isRecording = isRecording
        if get_current_tournament() is not None:
            self.setEnabled(True)
        else:
            self.setEnabled(False)

        if (isRecording):
            self.setIcon(self.style().standardIcon(QStyle.SP_MediaStop))
            # recording color: red
            self.setStyleSheet('QPushButton {background-color: #e57373}')
        else:
            self.setIcon(self.style().standardIcon(QStyle.SP_DialogNoButton))
            # non-recording color: cyan
            self.setStyleSheet('QPushButton {background-color: #26c6da}')
示例#10
0
 def updateWindowTitle(self, match_number=None, teams=None):
     if get_current_tournament() is None:
         self.setWindowTitle('VEX Match Recorder - [No Tournament Selected]')
         return
     if (match_number == None or teams == None):
         # initialization
         self.setWindowTitle('VEX Match Recorder - [No Match Selected]')
     else:
         if (self.isRecording):
             title = 'VEX Match Recorder - Match ' + (match_number) + " Teams "
         else:
             title = 'VEX Match Recorder - Match ' + (match_number) + " Teams "
         # add the teams to the title
         for team in teams:
             title += str(team) + " "
         self.setWindowTitle(title)
示例#11
0
 def updatepull(self):
     if get_current_tournament() is not None:
         get_current_tournament().update_match_data()
         self.reload()
     self.updateStatusDisplay()
示例#12
0
 def __init__(self, *args, tournament):
     QAbstractTableModel.__init__(self, *args)
     self.tournament = get_current_tournament()
     global videos
     videos = self.getVideos()