資源簡介
利用qt編寫的圖片瀏覽器,可以通過拖動滑動瀏覽,效果很炫
代碼片段和文件信息
/*
??PictureFlow?-?animated?image?show?widget
??http://pictureflow.googlecode.com
??Copyright?(C)?2008?Ariya?Hidayat?(ariya@kde.org)
??Copyright?(C)?2007?Ariya?Hidayat?(ariya@kde.org)
??Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy
??of?this?software?and?associated?documentation?files?(the?“Software“)?to?deal
??in?the?Software?without?restriction?including?without?limitation?the?rights
??to?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell
??copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?is
??furnished?to?do?so?subject?to?the?following?conditions:
??The?above?copyright?notice?and?this?permission?notice?shall?be?included?in
??all?copies?or?substantial?portions?of?the?Software.
??THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
??IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
??FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL?THE
??AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
??LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
??OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN
??THE?SOFTWARE.
*/
#include?
#include?
#include?
#include?
#include?
#if?QT_VERSION?>=?0x040000
#include?
#endif
#include?“pictureflow.h“
QStringList?findFiles(const?QString&?path?=?QString())
{
??QStringList?files;
??QDir?dir?=?QDir::current();
??if(!path.isEmpty())
????dir?=?QDir(path);
??dir.setFilter(QDir::Files?|?QDir::Hidden?|?QDir::NoSymlinks);
#if?QT_VERSION?>=?0x040000
??QFileInfoList?list?=?dir.entryInfoList();
??for?(int?i?=?0;?i???{
????QFileInfo?fileInfo?=?list.at(i);
????files.append(dir.absoluteFilePath(fileInfo.fileName()));
??}
#else
??const?QFileInfoList*?list?=?dir.entryInfoList();
??if(list)?
??{
????QFileInfoListIterator?it(?*list?);
????QFileInfo?*?fi;
????while(?(fi=it.current())?!=?0?)?
????{
??????++it;
??????files.append(dir.absFilePath(fi->fileName()));
????}
??}
#endif
??return?files;
}
#if?QT_VERSION?0x040000
#define?modifiers?state
#define?AltModifier?AltButton
#define?setWindowtitle?setCaption
#endif
#if?QT_VERSION?0x030000
#define?flush?flushX
#endif
class?Browser:?public?PictureFlow
{
public:
??Browser():?PictureFlow()
??{
????setWindowtitle(“PictureFlow“);
??}
??void?keyPressEvent(QKeyEvent*?event)
??{
????if(event->key()?==?Qt::Key_Escape?||?event->key()?==?Qt::Key_Enter?||?
??????event->key()?==?Qt::Key_Return)
??????{
????????event->accept();
????????close();
??????}
????//?checking?the?speed?of?rendering
????if(event->key()?==?Qt::Key_F10)
????if(event->modifiers()?==?Qt::AltModifier)
????{
??????qDebug(“benchmarking....?please?wait“);
??????const?int?blit_count?=?10;
??????QTime?stopwatch;
??????stopwatch.start();
??????for(int?i?=?0;?i???????{
????????render();?repaint();?QApplication::flu
評論
共有 條評論