Пример #1
0
/** Separate the input into files and directories */
void ImageView::LoadAlbumRunnable::filterDirectories(const ThumbList &input,
        ThumbList &fileList, ThumbList &dirList)
{
    for (int i = 0; i < input.size(); ++i)
    {
        ThumbItem *item = input.at(i);
        ThumbList &targetList = item->IsDir() ? dirList : fileList;
        targetList.append(item);
    }
}
Пример #2
0
void ImageView::AddItems(const ThumbList &itemList)
{
    QMutexLocker guard(&m_itemListLock);

    m_itemList.append(itemList);

    m_slideshow_sequence->extend(itemList.size());

    if (m_slideshow_sequencing == 3)
    {
        for (int i = 0; i < itemList.size(); ++i)
        {
            ThumbItem *item = itemList.at(i);
            double weight = GetSeasonalWeight(item);
            static_cast<SequenceWeighted *>(m_slideshow_sequence)->add(weight);
        }
    }

    if (!m_itemList.empty())
    {
        m_imagesLoaded.wakeAll();
    }
}
Пример #3
0
ImageView::ImageView(const ThumbList &itemList,
                     int *pos, int slideShow, int sortorder)
    : m_screenSize(640,480),
      m_wmult(1.0f),
      m_hmult(1.0f),
      m_pos(*pos),
      m_savedPos(pos),
      m_movieState(0),
      m_zoom(1.0f),

      // Info variables
      m_info_show(false),
      m_info_show_short(false),

      // Common slideshow variables
      m_slideshow_running(false),
      m_slideshow_sequencing(slideShow),
      m_slideshow_frame_delay(2),
      m_slideshow_frame_delay_state(m_slideshow_frame_delay * 1000),
      m_slideshow_timer(NULL),

      // Common effect state variables
      m_effect_running(false),
      m_effect_current_frame(0),
      m_effect_method(QString::null),
      m_effect_random(false),

      m_loaderRunnable(NULL),
      m_listener(this),
      m_loaderThread(NULL),
      m_slideshow_sequence(ComposeSlideshowSequence(slideShow)),
      m_finishedLoading(false)
{

    int xbase, ybase, screenwidth, screenheight;
    GetMythUI()->GetScreenSettings(xbase, screenwidth,  m_wmult,
                                ybase, screenheight, m_hmult);
    m_screenSize = QSize(screenwidth, screenheight);

    // --------------------------------------------------------------------

    bool recurse = gCoreContext->GetNumSetting("GalleryRecursiveSlideshow", 0);

    ThumbItem *origItem = NULL;
    if (m_pos < itemList.size())
        origItem = itemList.at(m_pos);

    ThumbList fileList, dirList;
    LoadAlbumRunnable::filterDirectories(itemList, fileList, dirList);
    AddItems(fileList);

    if (recurse)
    {
        // Load pictures from all directories on a different thread.
        m_loaderRunnable = new LoadAlbumRunnable(this, dirList, sortorder,
                                                 m_slideshow_sequencing);
        m_loaderThread = new MThread("LoadAlbum", m_loaderRunnable);
        QObject::connect(m_loaderThread->qthread(), SIGNAL(finished()),
                &m_listener, SLOT(FinishLoading()));
        m_loaderThread->start();

        // Wait for at least one image to be loaded.
        {
            QMutexLocker guard(&m_itemListLock);
            while (m_itemList.empty() && !m_finishedLoading)
            {
                m_imagesLoaded.wait(&m_itemListLock);
            }
        }
    }

    // --------------------------------------------------------------------

    // since we remove dirs item position might have changed
    if (origItem)
        m_pos = m_itemList.indexOf(origItem);

    m_pos = (!origItem || (m_pos == -1)) ? 0 : m_pos;
    m_slideshow_sequence->set(m_pos);

    // --------------------------------------------------------------------

    m_slideshow_frame_delay = gCoreContext->GetNumSetting("SlideshowDelay", 0);
    m_slideshow_frame_delay = (!m_slideshow_frame_delay) ?
        2 : m_slideshow_frame_delay;
    m_slideshow_frame_delay_state = m_slideshow_frame_delay * 1000;

    // --------------------------------------------------------------------

    if (slideShow == 2)
    {
        m_slideshow_mode = QT_TR_NOOP("Random Slideshow");
    }
    else if (slideShow == 3)
    {
        m_slideshow_mode = QT_TR_NOOP("Seasonal Slideshow");
    }
    else
    {
        m_slideshow_mode = QT_TR_NOOP("Slideshow");
    }
}