コード例 #1
0
    def initAttributes(self):
        self.showMaximized()

        # Initialize the play list.
        self.playlist = []  # A list of links to the file to play.
        self.playlistTmp = [
        ]  # A temporary play list, use to shuffle play list.
        self.repeat = False

        # A timer showing the playing time.
        self.tmrTimer = QtCore.QTimer(self)
        self.tmrTimer.setInterval(
            250)  # This will emit a signal every 1/4 second
        self.tmrTimer.timeout.connect(self.on_tmrTimer_timeout)
        self.tmrTimer.start()

        #Volume control.
        self.sldVolumeSlider.setAudioOutput(self.vdpVideo.audioOutput())
        self.sldSeekSlider.setMediaObject(self.vdpVideo.mediaObject())

        # initialize the current mouse position and time.
        self.mousePos0 = QtGui.QCursor.pos()
        self.mouseT0 = QtCore.QTime.currentTime()

        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()

        # A list of uploading video.
        self.uploadingList = {}
        self.uploadDialog = UploadDialog(self)
        self.downloadingList = []

        self.feed = None  # The current feed, displayed on the search result page.
        self.entry = None  # The current entry, playing.
        self.currentDirectLink = ""  # Direct link to the current video.
        self.currentVideo = None

        # The dock widget: show or hide?
        self.dckShown = True
        self.lineEditSearch.setFocus()

        # Search thread.
        self.threadPool = []
        self.threadType = [
        ]  # Store the function names that run as threads in self.threadPool.

        # Search box: Enter pressed.
        self.lineEditSearch.returnPressed.connect(
            self.on_btnSearchVideo_clicked)

        # The page showing search result.
        # Enable the flash plugin
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,
                                                   True)
        self.videoList.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)
        self.videoList.connect(self.videoList,
                               QtCore.SIGNAL('linkClicked(const QUrl&)'),
                               self.linkClicked)

        # A seperate frame for login.
        self.logged_in = False
        self.yt_service = None

        # Advance search options
        self.advancedSearchDialog = SearchOptionDialog(parent=self)
        self.connect(self.advancedSearchDialog.optionDialogSearchTerm,
                     QtCore.SIGNAL("returnPressed()"), self.advancedSearch)
        self.connect(self.advancedSearchDialog.lineeditUserFeed,
                     QtCore.SIGNAL("returnPressed()"),
                     self.on_lineeditUserFeed_returnPressed)

        self.connect(self.advancedSearchDialog.btnTrending,
                     QtCore.SIGNAL("clicked()"), self.on_btnTrending_clicked)
        self.connect(self.advancedSearchDialog.btnTopRated,
                     QtCore.SIGNAL("clicked()"), self.on_btnTopRated_clicked)
        self.connect(self.advancedSearchDialog.btnRecentlyFeatured,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnRecentlyFeatured_clicked)
        self.connect(self.advancedSearchDialog.btnTopFavorites,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnTopFavorites_clicked)
        self.connect(self.advancedSearchDialog.btnMostShared,
                     QtCore.SIGNAL("clicked()"), self.on_btnMostShared_clicked)
        self.connect(self.advancedSearchDialog.btnMostResponded,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostResponded_clicked)
        self.connect(self.advancedSearchDialog.btnMostDiscussed,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostDiscussed_clicked)
        self.connect(self.advancedSearchDialog.btnMostRecent,
                     QtCore.SIGNAL("clicked()"), self.on_btnMostRecent_clicked)
        self.connect(self.advancedSearchDialog.btnMostPopular,
                     QtCore.SIGNAL("clicked()"),
                     self.on_btnMostPopular_clicked)

        # Menu bar actions.
        self.action_Save_playlist.triggered.connect(
            self.on_action_Save_playlist)
        self.action_Load_playlist.triggered.connect(
            self.on_action_Load_playlist)
        self.action_Open_download_folder.triggered.connect(
            self.on_action_Open_download_folder)
        self.action_Quit.triggered.connect(self.on_action_Quit)
        self.action_Guide.triggered.connect(self.on_action_Guide)
        self.action_About.triggered.connect(self.on_action_About)
        self.actionS_earch_option.triggered.connect(
            self.on_actionS_earch_option)

        self.vdpVideo.finished.connect(self.on_btnNext_clicked)

        self.btnLogout.setEnabled(False)

        self.connect(self, QtCore.SIGNAL("IWantToBeNoticed(QString)"),
                     self.showMessage)