Exemplo n.º 1
0
void ImageView::LoadAlbumRunnable::run()
{
    while (!m_dirList.empty())
    {
        ThumbItem *dir = m_dirList.takeFirst();
        ThumbList children;
        GalleryUtil::LoadDirectory(children, dir->GetPath(),
                                   GalleryFilter(m_sortorder != 0),
                                   false, NULL, NULL);

        {
            QMutexLocker guard(&m_isAliveLock);
            if (!m_isAlive)
            {
                break;
            }
        }

        // The first images should not always come from the first directory.
        if (m_slideshow_sequencing > 1)
        {
            std::random_shuffle(children.begin(), children.end());
        }

        ThumbList fileList;
        filterDirectories(children, fileList, m_dirList);
        if (!fileList.empty())
        {
            m_parent->AddItems(fileList);
        }
    }
}
Exemplo n.º 2
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);
    }
}
Exemplo n.º 3
0
void ThumbInfo::OnLButtonUp()
{
	RECT	rcMiranda;
	RECT	rcThumb;
	RECT	rcOverlap;

	if (!bMouseMoved && fcOpt.bUseSingleClick && bMouseIn)
		PopupMessageDialog();

	if (bMouseDown) {
		bMouseDown = FALSE;
		SetCursor(LoadCursor(nullptr, IDC_ARROW));

		// Check whether we shoud remove the window
		GetWindowRect(hwndMiranda, &rcMiranda);
		GetThumbRect(&rcThumb);

		if (IntersectRect(&rcOverlap, &rcMiranda, &rcThumb)) {
			if (IsWindowVisible(hwndMiranda)) {
				DeleteContactPos();
				thumbList.RemoveThumb(this);
			}
		}
	}

	SaveContactsPos();
}
Exemplo n.º 4
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();
    }
}
Exemplo n.º 5
0
void ThumbInfo::PositionThumb(int nX, int nY)
{
	POINT pos = { nX, nY };

	HDWP hdwp = BeginDeferWindowPos(1);

	ThumbInfo *pThumb = this;
	while (pThumb) {
		pThumb->PositionThumbWorker(pos.x, pos.y, &pos);
		if (nullptr != pThumb->hwnd) /* Wine fix. */
			hdwp = DeferWindowPos(hdwp, pThumb->hwnd, HWND_TOPMOST, pos.x, pos.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

		pThumb->ptPos = pos;
		pos.x += pThumb->szSize.cx;

		pThumb = fcOpt.bMoveTogether ? thumbList.FindThumb(pThumb->dockOpt.hwndRight) : nullptr;
	}

	EndDeferWindowPos(hdwp);
}
Exemplo n.º 6
0
bool GalleryUtil::LoadDirectory(ThumbList& itemList, const QString& dir,
                                const GalleryFilter& flt, bool recurse,
                                ThumbHash *itemHash, ThumbGenerator* thumbGen)
{
    QString blah = dir;
    QDir d(blah);
    QString currDir = d.absolutePath();
    QStringList splitFD;

    bool isGallery;
    QFileInfoList gList = d.entryInfoList(QStringList("serial*.dat"),
                                          QDir::Files);
    isGallery = (gList.count() != 0);

    // Create .thumbcache dir if neccesary
    if (thumbGen)
        thumbGen->getThumbcacheDir(currDir);

    QFileInfoList list = d.entryInfoList(GetMediaFilter(),
                                         QDir::Files | QDir::AllDirs |
                                         QDir::NoDotAndDotDot,
                                         (QDir::SortFlag)flt.getSort());

    if (list.isEmpty())
        return false;

    QFileInfoList::const_iterator it = list.begin();
    const QFileInfo *fi;

    if (thumbGen)
    {
        thumbGen->cancel();
        thumbGen->setDirectory(currDir, isGallery);
    }

    if (!flt.getDirFilter().isEmpty())
    {
        splitFD = flt.getDirFilter().split(":");
    }

    while (it != list.end())
    {
        fi = &(*it);
        ++it;

        // remove these already-resized pictures.
        if (isGallery && (
                (fi->fileName().indexOf(".thumb.") > 0) ||
                (fi->fileName().indexOf(".sized.") > 0) ||
                (fi->fileName().indexOf(".highlight.") > 0)))
            continue;

        // skip filtered directory
        if (fi->isDir() &&
             !splitFD.filter(fi->fileName(), Qt::CaseInsensitive).isEmpty())
            continue;

        if (fi->isDir() && recurse)
        {
            LoadDirectory(itemList, QDir::cleanPath(fi->absoluteFilePath()),
                          flt, true, itemHash, thumbGen);
        }
        else
        {
            if ((GalleryUtil::IsImage(fi->absoluteFilePath()) &&
                 flt.getTypeFilter() == kTypeFilterMoviesOnly) ||
                (GalleryUtil::IsMovie(fi->absoluteFilePath()) &&
                 flt.getTypeFilter() == kTypeFilterImagesOnly))
                continue;

            ThumbItem *item = new ThumbItem(fi->fileName(),
                QDir::cleanPath(fi->absoluteFilePath()), fi->isDir());

            itemList.append(item);

            if (itemHash)
                itemHash->insert(item->GetName(), item);

            if (thumbGen)
                thumbGen->addFile(item->GetName());
        }
    }

    return isGallery;
}
Exemplo n.º 7
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");
    }
}
Exemplo n.º 8
0
void ThumbInfo::PositionThumbWorker(int nX, int nY, POINT *newPos)
{
	RECT  rc;
	RECT  rcThumb;
	int   nNewX;
	int   nNewY;
	int   nWidth;
	int   nHeight;
	POINT pt;
	RECT	rcLeft;
	RECT	rcTop;
	RECT	rcRight;
	RECT	rcBottom;
	BOOL	bDocked;
	BOOL	bDockedLeft;
	BOOL	bDockedRight;
	BOOL	bLeading;

	// Get thumb dimnsions
	GetThumbRect(&rcThumb);
	nWidth = rcThumb.right - rcThumb.left;
	nHeight = rcThumb.bottom - rcThumb.top;

	// Docking and screen boundaries check
	SnapToScreen(rcThumb, nX, nY, &nNewX, &nNewY);

	bLeading = dockOpt.hwndRight != nullptr;

	if (fcOpt.bMoveTogether)
		UndockThumbs(this, thumbList.FindThumb(dockOpt.hwndLeft));

	for (auto &it : thumbList) {
		if (it == this)
			continue;

		GetThumbRect(&rcThumb);
		OffsetRect(&rcThumb, nX - rcThumb.left, nY - rcThumb.top);

		it->GetThumbRect(&rc);

		// These are rects we will dock into

		rcLeft.left = rc.left - nOffs;
		rcLeft.top = rc.top - nOffs;
		rcLeft.right = rc.left + nOffs;
		rcLeft.bottom = rc.bottom + nOffs;

		rcTop.left = rc.left - nOffs;
		rcTop.top = rc.top - nOffs;
		rcTop.right = rc.right + nOffs;
		rcTop.bottom = rc.top + nOffs;

		rcRight.left = rc.right - nOffs;
		rcRight.top = rc.top - nOffs;
		rcRight.right = rc.right + nOffs;
		rcRight.bottom = rc.bottom + nOffs;

		rcBottom.left = rc.left - nOffs;
		rcBottom.top = rc.bottom - nOffs;
		rcBottom.right = rc.right + nOffs;
		rcBottom.bottom = rc.bottom + nOffs;

		bDockedLeft = bDockedRight = FALSE;

		// Upper-left
		pt.x = rcThumb.left;
		pt.y = rcThumb.top;
		bDocked = FALSE;

		if (PtInRect(&rcRight, pt)) {
			nNewX = rc.right;
			bDocked = TRUE;
		}

		if (PtInRect(&rcBottom, pt)) {
			nNewY = rc.bottom;
			if (PtInRect(&rcLeft, pt))
				nNewX = rc.left;
		}

		if (PtInRect(&rcTop, pt)) {
			nNewY = rc.top;
			bDockedLeft = bDocked;
		}

		// Upper-right
		pt.x = rcThumb.right;
		pt.y = rcThumb.top;
		bDocked = FALSE;

		if (!bLeading && PtInRect(&rcLeft, pt)) {
			if (!bDockedLeft) {
				nNewX = rc.left - nWidth;
				bDocked = TRUE;
			}
			else if (rc.right == rcThumb.left)
				bDocked = TRUE;
		}


		if (PtInRect(&rcBottom, pt)) {
			nNewY = rc.bottom;
			if (PtInRect(&rcRight, pt))
				nNewX = rc.right - nWidth;
		}

		if (!bLeading && PtInRect(&rcTop, pt)) {
			nNewY = rc.top;
			bDockedRight = bDocked;
		}

		if (fcOpt.bMoveTogether) {
			if (bDockedRight)
				DockThumbs(this, it);

			if (bDockedLeft)
				DockThumbs(it, this);
		}

		// Lower-left
		pt.x = rcThumb.left;
		pt.y = rcThumb.bottom;

		if (PtInRect(&rcRight, pt))
			nNewX = rc.right;

		if (PtInRect(&rcTop, pt)) {
			nNewY = rc.top - nHeight;
			if (PtInRect(&rcLeft, pt))
				nNewX = rc.left;
		}


		// Lower-right
		pt.x = rcThumb.right;
		pt.y = rcThumb.bottom;

		if (!bLeading && PtInRect(&rcLeft, pt))
			nNewX = rc.left - nWidth;

		if (!bLeading && PtInRect(&rcTop, pt)) {
			nNewY = rc.top - nHeight;

			if (PtInRect(&rcRight, pt)) {
				nNewX = rc.right - nWidth;
			}
		}
	}

	// Adjust coords once again
	SnapToScreen(rcThumb, nNewX, nNewY, &nNewX, &nNewY);

	newPos->x = nNewX;
	newPos->y = nNewY;
}
Exemplo n.º 9
0
void ThumbInfo::ResizeThumb()
{
	int index = FLT_FONTID_NOTONLIST;

	himlMiranda = Clist_GetImageList();
	if (himlMiranda == nullptr)
		return;

	SIZEL sizeIcon;
	ImageList_GetIconSize_my(himlMiranda, sizeIcon);

	HDC hdc = GetWindowDC(hwnd);
	if (!db_get_b(hContact, "CList", "NotOnList", 0)) {
		char *szProto = GetContactProto(hContact);
		if (nullptr != szProto) {
			int nStatus = Proto_GetStatus(szProto);
			int nContactStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
			int nApparentMode = db_get_w(hContact, szProto, "ApparentMode", 0);

			if ((nStatus == ID_STATUS_INVISIBLE && nApparentMode == ID_STATUS_ONLINE) ||
				(nStatus != ID_STATUS_INVISIBLE && nApparentMode == ID_STATUS_OFFLINE)) {
				if (ID_STATUS_OFFLINE == nContactStatus)
					index = FLT_FONTID_OFFINVIS;
				else
					index = FLT_FONTID_INVIS;
			}
			else if (ID_STATUS_OFFLINE == nContactStatus)
				index = FLT_FONTID_OFFLINE;
			else
				index = FLT_FONTID_CONTACTS;
		}
	}
	else index = FLT_FONTID_NOTONLIST;

	HFONT hOldFont = (HFONT)SelectObject(hdc, hFont[index]);

	// Get text and icon sizes
	SIZEL sizeText;
	GetTextExtentPoint32(hdc, ptszName, (int)mir_wstrlen(ptszName), &sizeText);

	SelectObject(hdc, hOldFont);

	// Transform text size
	POINT ptText;
	ptText.x = sizeText.cx;
	ptText.y = sizeText.cy;
	LPtoDP(hdc, &ptText, 1);

	szSize.cx = fcOpt.bFixedWidth ? fcOpt.nThumbWidth : sizeIcon.cx + ptText.x + 10;
	szSize.cy = ((sizeIcon.cy > ptText.y) ? sizeIcon.cy : ptText.y) + 4;

	SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, szSize.cx, szSize.cy, SWP_NOMOVE | SWP_NOACTIVATE);

	RefreshContactIcon(0xFFFFFFFF);

	ReleaseDC(hwnd, hdc);

	// Move the docked widnow if needed
	ThumbInfo *pNextThumb = thumbList.FindThumb(dockOpt.hwndRight);
	if (pNextThumb) {
		RECT rcThumb;
		GetThumbRect(&rcThumb);
		pNextThumb->PositionThumb(rcThumb.right, rcThumb.top);
	}
}
Exemplo n.º 10
0
bool GalleryUtil::LoadDirectory(ThumbList& itemList, const QString& dir,
                                int sortorder, bool recurse,
                                ThumbHash *itemHash, ThumbGenerator* thumbGen)
{
    QString blah = dir;
    QDir d(blah);
    QString currDir = d.absolutePath();

    bool isGallery;
    QFileInfoList gList = d.entryInfoList(QStringList("serial*.dat"),
                                          QDir::Files);
    isGallery = (gList.count() != 0);

    // Create .thumbcache dir if neccesary
    if (thumbGen)
        thumbGen->getThumbcacheDir(currDir);

    QFileInfoList list = d.entryInfoList(GetMediaFilter(),
                                         QDir::Files | QDir::AllDirs,
                                         (QDir::SortFlag)sortorder);

    if (list.isEmpty())
        return false;

    QFileInfoList::const_iterator it = list.begin();
    const QFileInfo *fi;

    if (thumbGen) 
    {
        thumbGen->cancel();
        thumbGen->setDirectory(currDir, isGallery);
    }

    while (it != list.end())
    {
        fi = &(*it);
        ++it;
        if (fi->fileName() == "." || fi->fileName() == "..")
            continue;

        // remove these already-resized pictures.
        if (isGallery && (
                (fi->fileName().indexOf(".thumb.") > 0) ||
                (fi->fileName().indexOf(".sized.") > 0) ||
                (fi->fileName().indexOf(".highlight.") > 0)))
            continue;

        if (fi->isDir() && recurse) 
        {
            GalleryUtil::LoadDirectory(
                itemList, QDir::cleanPath(fi->absoluteFilePath()),
                sortorder, true, itemHash, thumbGen);
        }
        else 
        {
            ThumbItem *item = new ThumbItem(
                fi->fileName(),
                QDir::cleanPath(fi->absoluteFilePath()), fi->isDir());

            itemList.append(item);

            if (itemHash)
                itemHash->insert(item->GetName(), item);

            if (thumbGen)
                thumbGen->addFile(item->GetName());
        }
    }

    return isGallery;
}