Пример #1
0
/** \fn     GalleryWidget::HandleFadeTransition()
 *  \brief  Handles the fading between two images
 *  \return void
 */
void GalleryWidget::HandleFadeTransition()
{
    int index = (m_index == 0) ? 1 : 0;

    // Fade out the old image if its loaded. This will not be done when
    // called for the first time because there is no object at this index
    if (m_fileDataList->at(index))
        m_fileList->at(index)->AdjustAlpha(1, (m_transitionTime * -1), 0, 255);

    // Fade in the new image and if the next
    // file is a video then start playing it
    if (m_fileDataList->at(m_index))
    {
        m_fileList->at(m_index)->AdjustAlpha(1, m_transitionTime, 0, 255);
        if (m_fileDataList->at(m_index)->m_type == kVideoFile)
        {
            if (m_fileDataList->at(index))
                m_fileList->at(index)->SetAlpha(0);

            PauseSlideShow();
            GetMythMainWindow()->HandleMedia("Internal",
                                             m_fileDataList->at(m_index)->m_fileName);
        }
    }
}
Пример #2
0
static void StartCalibration(HBROWSER_HANDLE hbrowser, HDOC_HANDLE hdoc, HELEMENT_HANDLE helem)
{
	 timer_running = 1;
	 per_cent_complete = 0;
	 PauseSlideShow();
	 UpdateCalibrationScreen(hbrowser, helem, hdoc, per_cent_complete);
     CalibrateRearmTimer(hbrowser, helem, 0);
}
Пример #3
0
/** \fn     GalleryWidget::ShowRandomFile()
 *  \brief  Loads a random image
 *  \return void
 */
void GalleryWidget::ShowRandomFile()
{
    volatile bool exit = false;

    int size = m_gvh->m_currentNode->getSelectedChild()->siblingCount();
    int counter = 0;
    int position = 0;

    MythGenericTree *node = NULL;
    ImageMetadata *im = NULL;

    PauseSlideShow();

    // Get a random node from the list. If its not an image or
    // video continue and try to get a new one until its an image
    // or all siblings have been checked.
    if (size > 0)
    {
        while (!exit)
        {
            position = (qrand() % size);
            counter++;

            node = m_gvh->m_currentNode->getChildAt(position);
            im = m_gvh->GetImageMetadataFromNode(node);

            if ((im && (im->m_type == kImageFile ||
                          im->m_type == kVideoFile)) || counter == size)
                exit = true;
        }

        // If we have data then is is already an image or
        // video. This has been checked in the while loop
        if (im)
        {
            m_gvh->m_currentNode->setSelectedChild(node);
            LoadFile();
        }
    }
    else
    {
        QString msg = "There are no images in the current directory.";
        ShowInformation(msg);
    }
}
Пример #4
0
/** \fn     GalleryView::MenuMain()
 *  \brief  Shows a dialog popup with the main menu
 *  \return void
 */
void GalleryWidget::MenuMain()
{
    // Create the main menu that will contain the submenus above
    MythMenu *menu = new MythMenu(tr("Image Information"), this, "mainmenu");

    // If no slideshow type was given show the item to start it
    // otherwise show the items to stop or resume a slideshow.
    if (m_slideShowType == kNoSlideShow)
    {
        menu->AddItem(tr("Start Normal SlideShow"),
                      SLOT(StartNormalSlideShow()));
        menu->AddItem(tr("Start Random SlideShow"),
                      SLOT(StartRandomSlideShow()));
    }
    else
    {
        if (m_timer->isActive())
            menu->AddItem(tr("Pause SlideShow"), SLOT(PauseSlideShow()));
        else
        {
            if (m_slideShowType == kNormalSlideShow)
                menu->AddItem(tr("Resume SlideShow"),
                              SLOT(StartNormalSlideShow()));

            if (m_slideShowType == kRandomSlideShow)
                menu->AddItem(tr("Resume SlideShow"),
                              SLOT(StartRandomSlideShow()));
        }
    }

    MenuMetadata(menu);
    menu->AddItem(tr("Show Details"),   SLOT(FileDetails()));

    m_menuPopup = new MythDialogBox(menu, m_popupStack, "menuPopup");
    if (!m_menuPopup->Create())
    {
        delete m_menuPopup;
        m_menuPopup = NULL;
        return;
    }

    m_popupStack->AddScreen(m_menuPopup);
}
Пример #5
0
/** \fn     GalleryWidget::ShowNextFile()
 *  \brief  Loads the next image file if possible
 *  \return void
 */
void GalleryWidget::ShowNextFile()
{
    PauseSlideShow();

    MythGenericTree *node = m_gvh->m_currentNode->getSelectedChild()->nextSibling(1);
    ImageMetadata *im = m_gvh->GetImageMetadataFromNode(node);

    // If a data object exists then a node must also exist
    if (im && (im->m_type == kImageFile ||
                 im->m_type == kVideoFile))
    {
        m_gvh->m_currentNode->setSelectedChild(node);
        LoadFile();
    }
    else
    {
        QString msg = "You have reached the end of the gallery.";
        ShowInformation(msg);
    }
}
Пример #6
0
/** \fn     GalleryWidget::LoadFile()
 *  \brief  Stops any slideshow and loads the file
 *          from disk or memory in the background.
 *  \return void
 */
void GalleryWidget::LoadFile()
{
    // Pause the slideshow so that the timer can't fire
    // until the image loading thread has finished
    PauseSlideShow();

    // Switch the index
    m_index = (m_index == 0) ? 1 : 0;

    // Load the new data into the new index, this will be
    // the new image which will be shown in the foreground
    m_fileDataList->replace(m_index, m_gvh->GetImageMetadataFromSelectedNode());

    if (m_fileDataList->at(m_index))
    {
        // Show an information that
        // the image is being loaded
        if (m_status)
            m_status->SetVisible(true);

        m_fileList->at(m_index)->SetAlpha(0);

        // Get the full path and name of the image
        // or if its a video the first preview image
        QString fileName = m_fileDataList->at(m_index)->m_fileName;
        if (m_fileDataList->at(m_index)->m_type == kVideoFile)
            fileName = m_fileDataList->at(m_index)->m_thumbFileNameList->at(0);

        QString url = CreateImageUrl(fileName);

        // This thread will loads the image so the UI is not blocked.
        m_ilt->setImage(m_fileList->at(m_index),
                        m_fileDataList->at(m_index), url);
        m_ilt->start();
    }
}
Пример #7
0
/** \fn     GalleryWidget::keyPressEvent(QKeyEvent *)
 *  \brief  Translates the keypresses and keys bound to the
 *          plugin to specific actions within the plugin
 *  \param  event The pressed key
 *  \return True if key was used, otherwise false
 */
bool GalleryWidget::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Images", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
            ShowPrevFile();
        else if (action == "RIGHT")
            ShowNextFile();
        else if (action == "INFO")
            ShowFileDetails();
        else if (action == "MENU")
            MenuMain();
        else if (action == "PLAY")
        {
            // If no slideshow is active and the user presses the play
            // button then start a normal slideshow. But if a slideshow
            // is already running then start or pause it.
            if (m_slideShowType == kNoSlideShow)
                StartNormalSlideShow();
            else
            {
                if (m_timer->isActive())
                    PauseSlideShow();
                else
                    ResumeSlideShow();
            }
        }
        else if (action == "PAUSE")
            PauseSlideShow();
        else if (action == "STOP")
            StopSlideShow();
        else if (action == "ROTRIGHT")
        {
            m_gvh->SetFileOrientation(kFileRotateCW);
            LoadFile();
        }
        else if (action == "ROTLEFT")
        {
            m_gvh->SetFileOrientation(kFileRotateCCW);
            LoadFile();
        }
        else if (action == "FLIPHORIZONTAL")
        {
            m_gvh->SetFileOrientation(kFileFlipHorizontal);
            LoadFile();
        }
        else if (action == "FLIPVERTICAL")
        {
            m_gvh->SetFileOrientation(kFileFlipVertical);
            LoadFile();
        }
        else if (action == "ZOOMIN")
        {
            m_gvh->SetFileZoom(kFileZoomIn);
            LoadFile();
        }
        else if (action == "ZOOMOUT")
        {
            m_gvh->SetFileZoom(kFileZoomOut);
            LoadFile();
        }
        else if (action == "ESCAPE")
        {
            if (m_infoVisible)
                HideFileDetails();
            else
                handled = false;
        }
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}