├── .gitignore ├── .gitmodules ├── PhotoKit.pro ├── README.md ├── TODO ├── common.pri ├── deploy.pri ├── i18n └── PhotoKit_zh_CN.ts ├── qtc_packaging ├── common │ ├── README │ ├── changelog │ └── copyright ├── debian_fremantle │ ├── PhotoKit.desktop │ ├── PhotoKit.png │ ├── README │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ └── rules ├── debian_generic │ ├── PhotoKit.desktop │ ├── PhotoKit.png │ └── control ├── debian_harmattan │ ├── PhotoKit.desktop │ ├── PhotoKit.png │ ├── README │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── manifest.aegis │ └── rules └── rules ├── res ├── PhotoKit.icns ├── PhotoKit.ico ├── PhotoKit.rc ├── i18n │ └── PhotoKit_zh_CN.qm ├── icons │ ├── close.png │ └── ok.png └── res.qrc ├── screenshot ├── 2012-06-30 23:46:29的屏幕截图.png ├── Logo-160x120.png ├── Screenshot-6.png ├── Screenshot-854x480.png └── screenshot.745x745.png ├── src ├── BaseItem.cpp ├── BaseItem.h ├── Button.cpp ├── Button.h ├── Config.cpp ├── Config.h ├── DemoItemAnimation.cpp ├── DemoItemAnimation.h ├── Dialog.cpp ├── Dialog.h ├── Dialog_p.h ├── FlipAnimation.cpp ├── FlipAnimation.h ├── Guide.cpp ├── Guide.h ├── ImageBaseInfo.h ├── ImageProvider.cpp ├── ImageProvider.h ├── ImageProvider_p.h ├── ItemAnimation.cpp ├── ItemAnimation.h ├── OptionParser.cpp ├── OptionParser.h ├── OutlineGlowItem.cpp ├── OutlineGlowItem.h ├── PhotoKit.pro ├── PhotoKitScene.cpp ├── PhotoKitScene.h ├── PhotoKitView.cpp ├── PhotoKitView.h ├── PhotoKit_Global.h ├── ProgressBarItem.cpp ├── ProgressBarItem.h ├── ReflectEffectItem.cpp ├── ReflectEffectItem.h ├── ShareManager.cpp ├── ShareManager.h ├── SlideDisplay.cpp ├── SlideDisplay.h ├── SlidePlayControl.cpp ├── SlidePlayControl.h ├── TextEdit.cpp ├── TextEdit.h ├── ThumbItem.cpp ├── ThumbItem.h ├── ThumbRecorder.cpp ├── ThumbRecorder.h ├── ThumbTask.cpp ├── ThumbTask.h ├── ToolBar.cpp ├── ToolBar.h ├── TransformMachine.cpp ├── TransformMachine.h ├── UiManager.cpp ├── UiManager.h ├── main.cpp ├── network │ ├── GoogleImageSearcher.cpp │ ├── GoogleImageSearcher.h │ ├── WeiboDialog.cpp │ ├── WeiboDialog.h │ ├── qput.cpp │ ├── qput.h │ ├── weiboapi.cpp │ └── weiboapi.h ├── notfinish │ ├── ButtonItem.cpp │ ├── ButtonItem.h │ ├── CategoryItem.cpp │ ├── CategoryItem.h │ ├── ConfigWidget.cpp │ ├── ConfigWidget.h │ ├── Updater.cpp │ └── Updater.h ├── score.cpp ├── score.h └── tools │ ├── ExifReader.cpp │ ├── ExifReader.h │ ├── ImageInfoDialog.cpp │ ├── ImageInfoDialog.h │ ├── ToolTip.cpp │ ├── ToolTip.h │ ├── Tools.cpp │ └── Tools.h └── test ├── test.pro ├── tst_googleimage.cpp └── tst_googleimage.pro /.gitignore: -------------------------------------------------------------------------------- 1 | CVS 2 | .#* 3 | 4 | .hg 5 | .hgignore 6 | 7 | bin 8 | obj 9 | TestResults 10 | *.pbxuser 11 | *.perspectivev3 12 | .DS_Store 13 | 14 | *.old 15 | *.log 16 | *.out 17 | *.cache 18 | 19 | *.deb 20 | 21 | *.git.old* 22 | Makefile* 23 | *.*pro*.user* 24 | *.[oa] 25 | *.so* 26 | *.dll 27 | *.lib 28 | *.exp 29 | *.exe 30 | *.out 31 | 32 | #vc files 33 | *.def 34 | *.dep 35 | *.idb 36 | *.layout 37 | *.manifest 38 | *.ncb 39 | *.obj 40 | *.pdb 41 | *.suo 42 | *.user 43 | *.tlh 44 | *.tli 45 | 46 | 47 | #intel compiler 48 | *.ilk 49 | 50 | #dirs 51 | .moc 52 | .rcc 53 | .obj 54 | /bin* 55 | /lib* 56 | Debug 57 | Release 58 | *.Debug 59 | *.Release 60 | 61 | *.fuse* 62 | 63 | #qt 64 | *.prl 65 | *moc_* 66 | *.moc 67 | *qrc_res.cpp 68 | 69 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/ezlog"] 2 | path = src/ezlog 3 | url = git://github.com/wang-bin/ezlog.git 4 | [submodule "src/ProgramOptions"] 5 | path = src/ProgramOptions 6 | url = git://github.com/wang-bin/ProgramOptions.git 7 | [submodule "src/NextEffect"] 8 | path = src/NextEffect 9 | url = git://github.com/wang-bin/NextEffect.git 10 | [submodule "src/libexif-port"] 11 | path = src/libexif-port 12 | url = git://github.com/wang-bin/libexif-port.git 13 | -------------------------------------------------------------------------------- /PhotoKit.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2012-06-23T21:41:01 4 | # 5 | #------------------------------------------------- 6 | 7 | TEMPLATE = subdirs 8 | #CONFIG += ordered 9 | SUBDIRS += libezlog libprogramoptions libNextEffect photokit test 10 | 11 | libezlog.file = src/ezlog/src/libezlog.pro 12 | libprogramoptions.file = src/ProgramOptions/src/libProgramOptions.pro 13 | libNextEffect.file = src/NextEffect/src/libNextEffect.pro 14 | photokit.file = src/PhotoKit.pro 15 | 16 | win32|mac { 17 | SUBDIRS += libexif 18 | libexif.file = src/libexif-port/libexif.pro 19 | photokit.depends += libexif 20 | } 21 | photokit.depends += libezlog libprogramoptions libNextEffect 22 | 23 | symbian { 24 | TARGET.UID3 = 0xea6f847b 25 | # TARGET.CAPABILITY += 26 | TARGET.EPOCSTACKSIZE = 0x14000 27 | TARGET.EPOCHEAPSIZE = 0x020000 0x800000 28 | } 29 | 30 | 31 | OTHER_FILES += README.md TODO \ 32 | qtc_packaging/common/README \ 33 | qtc_packaging/common/copyright \ 34 | qtc_packaging/common/changelog \ 35 | qtc_packaging/debian_harmattan/manifest.aegis \ 36 | qtc_packaging/debian_harmattan/control \ 37 | qtc_packaging/debian_harmattan/rules \ 38 | qtc_packaging/debian_harmattan/compat \ 39 | qtc_packaging/debian_harmattan/PhotoKit.desktop \ 40 | qtc_packaging/debian_fremantle/control \ 41 | qtc_packaging/debian_fremantle/rules \ 42 | qtc_packaging/debian_fremantle/compat \ 43 | qtc_packaging/debian_fremantle/PhotoKit.desktop \ 44 | qtc_packaging/debian_generic/control \ 45 | qtc_packaging/debian_generic/PhotoKit.desktop 46 | 47 | # Add files and directories to ship with the application 48 | # by adapting the examples below. 49 | # file1.source = myfile 50 | # dir1.source = mydir 51 | #lang.files = i18n 52 | #DEPLOYMENTFOLDERS = lang# file1 dir1 53 | #include(deployment.pri) 54 | #qtcAddDeployment() 55 | #TODO: add other platform packaging 56 | NAME = $$basename(_PRO_FILE_PWD_) 57 | 58 | # add a make command 59 | defineReplace(mcmd) { 60 | return($$escape_expand(\n\t)$$1) 61 | } 62 | 63 | !isEmpty(MEEGO_VERSION_MAJOR): PLATFORM = harmattan #armel 64 | else:maemo5: PLATFORM = fremantle 65 | else: PLATFORM = generic 66 | 67 | unix { 68 | 69 | ARCH = `dpkg --print-architecture` 70 | *maemo*: ARCH = $$QT_ARCH 71 | #ARCH = $$QT_ARCH #what about harmattan? 72 | 73 | fakeroot.target = fakeroot 74 | fakeroot.depends = FORCE 75 | fakeroot.commands = rm -rf fakeroot && mkdir -p fakeroot/usr/share/doc/$$NAME && mkdir -p fakeroot/DEBIAN 76 | fakeroot.commands += $$mcmd(chmod -R 755 fakeroot) ##control dir must be 755 77 | 78 | deb.target = deb 79 | deb.depends += fakeroot 80 | deb.commands += $$mcmd(make install INSTALL_ROOT=\$\$PWD/fakeroot) 81 | deb.commands += $$mcmd(cd fakeroot; md5sum `find usr -type f |grep -v DEBIAN` > DEBIAN/md5sums; cd -) 82 | deb.commands += $$mcmd(cp $$PWD/qtc_packaging/debian_$${PLATFORM}/control fakeroot/DEBIAN) 83 | deb.commands += $$mcmd(sed -i \"s/%arch%/$${ARCH}/\" fakeroot/DEBIAN/control) 84 | deb.commands += $$mcmd(gzip -9 fakeroot/usr/share/doc/$$NAME/changelog) 85 | deb.commands += $$mcmd(dpkg -b fakeroot $${NAME}_0.3.9_$${PLATFORM}_$${ARCH}.deb) 86 | 87 | 88 | QMAKE_EXTRA_TARGETS += fakeroot deb 89 | 90 | } #unix 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PhotoKit 2 | ============== 3 | 4 | PhotoKit is a photo browser with impressive 3D effects and many slide effects. 5 | 6 | Features: 7 | * 3D effects 8 | * Slide effects (my another project NextEffect). 9 | * Multi-touch (e.g. on N9) 10 | * EXIF information. 11 | * Share images to sina weibo. (for Chinese users) 12 | * Online images with Google image search. 13 | * Build debian package (make deb). 14 | 15 | 16 | PhotoKit can not manager photos now, just viewing. It will be possible in the future. 17 | 18 | 19 | The UI of PhotoKit is based on Qt graphics framework (except filedialog), so you will have the same experience on all platforms. On N9, it only supports landscape mode because the limitation of QWidget. At the begining, i just use many QWidget based components, but they are very ugly on Harmattan, so I have to wrote these components using graphics framework, e.g. button, textinput and dialog. The work is hard, but the result is good. 20 | 21 | Get the binary 22 | -------------- 23 | 24 | I have built PhotoKit for many platforms, you can download them from sourceforge: https://sourceforge.net/projects/photokit/files 25 | 26 | Including deb packages for Nokia N9 and N900, dmg for Mac OS X, and zip for Windows. 27 | 28 | You can build PhotoKit yourself for linux, and building a deb is very easy, just "make deb" 29 | 30 | You can find PhotoKit for OS2 there: http://svn.netlabs.org/qtapps/wiki/QT4%20Graphics 31 | 32 | Build 33 | ------ 34 | 1. Clone the project including submodules: 35 | 36 | git clone --recursive git://github.com/wang-bin/PhotoKit.git 37 | 38 | git submodule foreach git checkout master 39 | 40 | 2. qmake -r "BUILD_DIR=/your/build/dir" [path/to/pro] 41 | 42 | 3. make -j4 43 | 44 | The binaries is in $BUILD_DIR/bin 45 | 46 | 4. Build package 47 | 48 | building debian package is supported now(tested for ubuntu 12.04, 8.04). Use the following command 49 | 50 | make deb 51 | 52 | 5. Update source code 53 | 54 | git pull 55 | 56 | git submodule update 57 | 58 | 59 | NOTE: If you are using QtCreator to build the project, you should go to Projects->Build Steps->qmake->Additional arguments, add "BUILD_DIR=your/buid/dir". 60 | 61 | 62 | Screenshot 63 | ------- 64 | 65 | ![Alt text](https://github.com/downloads/wang-bin/PhotoKit/Screenshot-854x480.png "screenshot") 66 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | QGraphicsTransform 2 | exe icon, transparent background, desktop show 3 | qput crash. http error on ok 4 | exif i18n 5 | 6 | wtf smart pointer 7 | in SildeDisplay, zoom the original image 8 | gif play 9 | progressbar 10 | 11 | QGraphicsView translate bug: https://bugreports.qt-project.org/browse/QTBUG-15239 12 | zoom on boot 13 | 14 | qtransform perspective: http://www.qtcentre.org/threads/14000-Perspective-correction-with-QTransform 15 | qgraphicsview performance: http://thesmithfam.org/blog/2007/02/03/qt-improving-qgraphicsview-performance/ 16 | center: http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming#Realizing_the_Pitfalls_with_QGraphicsView 17 | check page on event 18 | -------------------------------------------------------------------------------- /common.pri: -------------------------------------------------------------------------------- 1 | # qmake common template pri file 2 | # Copyright (C) 2011 Wang Bin 3 | # Shanghai, China. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program; if not, write to the Free Software Foundation, Inc., 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | # 19 | 20 | isEmpty(COMMON_PRI_INCLUDED): { #begin COMMON_PRI_INCLUDED 21 | 22 | CONFIG += profile 23 | #profiling, -pg is not supported for msvc 24 | debug:!*msvc*:profile { 25 | QMAKE_CXXFLAGS_DEBUG += -pg 26 | QMAKE_LFLAGS_DEBUG += -pg 27 | QMAKE_CXXFLAGS_DEBUG = $$unique(QMAKE_CXXFLAGS_DEBUG) 28 | QMAKE_LFLAGS_DEBUG = $$unique(QMAKE_LFLAGS_DEBUG) 29 | } 30 | 31 | #$$[TARGET_PLATFORM] 32 | #$$[QT_ARCH] #windows symbian windowsce arm 33 | _OS = 34 | _ARCH = 35 | _EXTRA = 36 | 37 | unix { 38 | _OS = _unix 39 | macx: _OS = _mac 40 | else:*linux*: _OS = _linux 41 | *maemo* { 42 | _OS = _maemo 43 | *maemo5*:_OS = _maemo5 44 | *maemo6*:_OS = _maemo6 45 | } 46 | else:*meego*: _OS = _meego 47 | !isEmpty(MEEGO_EDITION): _OS = _$$MEEGO_EDITION 48 | } else:wince* { 49 | _OS = _wince 50 | } else:win32 { #true for wince 51 | _OS = _win32 52 | } 53 | #*arm*: _ARCH = $${_ARCH}_arm 54 | contains(QT_ARCH, arm.*) { 55 | _ARCH = $${_ARCH}_$${QT_ARCH} 56 | } 57 | *64: _ARCH = $${_ARCH}_x64 58 | *llvm*: _EXTRA = _llvm 59 | #*msvc*: 60 | 61 | win32-msvc* { 62 | #Don't warn about sprintf, fopen etc being 'unsafe' 63 | DEFINES += _CRT_SECURE_NO_WARNINGS 64 | } 65 | 66 | #################################functions######################################### 67 | defineReplace(cleanPath) { 68 | win32:1 ~= s|\\\\|/|g 69 | contains(1, ^/.*):pfx = / 70 | else:pfx = 71 | segs = $$split(1, /) 72 | out = 73 | for(seg, segs) { 74 | equals(seg, ..):out = $$member(out, 0, -2) 75 | else:!equals(seg, .):out += $$seg 76 | } 77 | return($$join(out, /, $$pfx)) 78 | } 79 | 80 | #Acts like qtLibraryTarget. From qtcreator.pri 81 | defineReplace(qtLibName) { 82 | #TEMPLATE += fakelib 83 | #LIB_FULLNAME = $$qtLibraryTarget($$1) 84 | #TEMPLATE -= fakelib 85 | unset(LIBRARY_NAME) 86 | LIBRARY_NAME = $$1 87 | CONFIG(debug, debug|release) { 88 | !debug_and_release|build_pass { 89 | mac:RET = $$member(LIBRARY_NAME, 0)_debug 90 | else:win32:RET = $$member(LIBRARY_NAME, 0)d 91 | } 92 | } 93 | isEmpty(RET):RET = $$LIBRARY_NAME 94 | !win32: return($$RET) 95 | 96 | isEmpty(2): VERSION_EXT = $$VERSION 97 | else: VERSION_EXT = $$2 98 | !isEmpty(VERSION_EXT) { 99 | VERSION_EXT = $$section(VERSION_EXT, ., 0, 0) 100 | #isEqual(VERSION_EXT, 0):unset(VERSION_EXT) 101 | } 102 | RET = $${RET}$${VERSION_EXT} 103 | unset(VERSION_EXT) 104 | return($$RET) 105 | } 106 | 107 | 108 | #fakelib 109 | defineReplace(qtStaticLib) { 110 | unset(LIB_FULLNAME) 111 | LIB_FULLNAME = $$qtLibName($$1, $$2) 112 | *msvc*|win32-icc: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).lib 113 | else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).a 114 | return($$LIB_FULLNAME) 115 | } 116 | 117 | defineReplace(qtSharedLib) { 118 | unset(LIB_FULLNAME) 119 | LIB_FULLNAME = $$qtLibName($$1, $$2) 120 | win32: LIB_FULLNAME = $$member(LIB_FULLNAME, 0).dll 121 | else { 122 | macx|ios: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).$${QMAKE_EXTENSION_SHLIB} #default_post.prf 123 | else: LIB_FULLNAME = lib$$member(LIB_FULLNAME, 0).so 124 | } 125 | return($$LIB_FULLNAME) 126 | } 127 | 128 | defineReplace(qtLongName) { 129 | unset(LONG_NAME) 130 | LONG_NAME = $$1$${_OS}$${_ARCH}$${_EXTRA} 131 | return($$LONG_NAME) 132 | } 133 | 134 | ##############################paths#################################### 135 | #TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts i18n/$${TARGET}_zh_CN.ts 136 | 137 | #for Qt2, Qt3 which does not have QT_VERSION. Qt4: $$[QT_VERSION] 138 | MOC_DIR = $$BUILD_DIR/.moc/$${QT_VERSION} 139 | RCC_DIR = $$BUILD_DIR/.rcc/$${QT_VERSION} 140 | UI_DIR = $$BUILD_DIR/.ui/$${QT_VERSION} 141 | #obj is platform dependent 142 | OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET) 143 | 144 | isEqual(TEMPLATE, app) { 145 | DESTDIR = $$BUILD_DIR/bin 146 | # TARGET = $$qtLongName($$TARGET) 147 | EXE_EXT = 148 | win32: EXE_EXT = .exe 149 | CONFIG(release, debug|release): 150 | !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$DESTDIR/$${TARGET}$${EXE_EXT} #.exe in win 151 | } 152 | else: DESTDIR = $$qtLongName($$BUILD_DIR/lib) 153 | 154 | !build_pass:message(target: $$DESTDIR/$$TARGET) 155 | 156 | COMMON_PRI_INCLUDED = 1 157 | 158 | } #end COMMON_PRI_INCLUDED 159 | #before target name changed 160 | #TRANSLATIONS += i18n/$${TARGET}_zh-cn.ts #i18n/$${TARGET}_zh_CN.ts 161 | 162 | -------------------------------------------------------------------------------- /deploy.pri: -------------------------------------------------------------------------------- 1 | isEmpty(PROJECTROOT): PROJECTROOT = $$PWD 2 | INSTALL_PREFIX = /usr/local 3 | INSTALL_FOLDER = lib 4 | isEqual(TEMPLATE, app): INSTALL_FOLDER = bin 5 | 6 | isEqual(TEMPLATE, app) { 7 | unix:!symbian { 8 | share.files = $$PROJECTROOT/qtc_packaging/common/changelog \ 9 | $$PROJECTROOT/qtc_packaging/common/copyright \ 10 | $$PROJECTROOT/qtc_packaging/common/README 11 | share.path = /usr/share/doc/$${TARGET} 12 | 13 | !isEmpty(MEEGO_VERSION_MAJOR) { 14 | DEFINES += CACHE_APPDIR 15 | INSTALL_PREFIX = /opt/$${TARGET} 16 | desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_harmattan/$${TARGET}.desktop 17 | desktopfile.path = /usr/share/applications 18 | icon.files = $$PROJECTROOT/qtc_packaging/debian_harmattan/$${TARGET}.png 19 | icon.path = /usr/share/icons/hicolor/80x80/apps 20 | #debian.files = $$PROJECTROOT/qtc_packaging/harmattan/control 21 | } else:maemo5 { 22 | INSTALL_PREFIX = /opt/$${TARGET} 23 | desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_fremantle/$${TARGET}.desktop 24 | desktopfile.path = /usr/share/applications/hildon 25 | icon.files = $$PROJECTROOT/qtc_packaging/debian_fremantle/$${TARGET}.png 26 | icon.path = /usr/share/icons/hicolor/64x64/apps 27 | #debian.files = $$PROJECTROOT/qtc_packaging/fremantle/control 28 | } else { 29 | desktopfile.files = $$PROJECTROOT/qtc_packaging/debian_generic/$${TARGET}.desktop 30 | desktopfile.path = /usr/share/applications 31 | icon.files = $$PROJECTROOT/qtc_packaging/debian_generic/$${TARGET}.png 32 | icon.path = /usr/share/icons/hicolor/64x64/apps 33 | #debian.files = $$PROJECTROOT/qtc_packaging/generic/control 34 | } 35 | INSTALLS += desktopfile icon share 36 | #debian.path = /DEBIAN 37 | } 38 | } 39 | 40 | target.path = $${INSTALL_PREFIX}/$${INSTALL_FOLDER} 41 | INSTALLS += target 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /qtc_packaging/common/README: -------------------------------------------------------------------------------- 1 | The Debian Package photokit 2 | ---------------------------- 3 | 4 | PhotoKit is a photo braowser with impressive 3D effects and many slide effects. Support view EXIF. You can share the image 5 | to sina weibo easily with it. Google image search is supported. 6 | 7 | -- WangBin Wed, 27 Jun 2012 10:00:42 +0800 8 | -------------------------------------------------------------------------------- /qtc_packaging/common/changelog: -------------------------------------------------------------------------------- 1 | photokit (0.3.9) unstable; urgency=low 2 | * Zooming support for single touch screen 3 | 4 | -- LucasWang Sat, 22 Dec 2012 15:55:17 +0800 5 | 6 | photokit (0.3.8) unstable; urgency=low 7 | * 8 | 9 | -- LucasWang Sat, 22 Dec 2012 15:55:16 +0800 10 | 11 | photokit (0.3.7) unstable; urgency=low 12 | * creating debian package for ubuntu is supported 13 | * better project struct and submodules 14 | 15 | -- LucasWang Wed, 19 Sep 2012 20:49:39 +0800 16 | 17 | photokit (0.3.6) unstable; urgency=low 18 | * Add google image search 19 | * Bug fix: crash when playing slide 20 | 21 | -- LucasWang Sun, 15 Jul 2012 04:32:57 +0800 22 | 23 | photokit (0.3.3) unstable; urgency=low 24 | * Fix crash bug when send weibo ok 25 | 26 | -- LucasWang Wed, 11 Jul 2012 16:17:14 +0800 27 | 28 | photokit (0.3.2) unstable; urgency=low 29 | * 30 | 31 | -- LucasWang Wed, 11 Jul 2012 01:41:26 +0800 32 | 33 | photokit (0.3.0) unstable; urgency=low 34 | * Add weibo dialog and bug fix 35 | 36 | -- LucasWang Tue, 10 Jul 2012 10:07:37 +0800 37 | 38 | 39 | photokit (0.2.8) unstable; urgency=low 40 | * graphics dialogs. 41 | * exif support 42 | * bug fix 43 | 44 | -- LucasWang Mon, 09 Jul 2012 12:17:26 +0800 45 | 46 | photokit (0.2.7) unstable; urgency=low 47 | * 48 | 49 | -- LucasWang Mon, 09 Jul 2012 12:17:25 +0800 50 | 51 | photokit (0.2.6) unstable; urgency=low 52 | * Fix large image page place center error 53 | * Add graphics buttons with animation 54 | 55 | -- LucasWang Thu, 05 Jul 2012 11:08:23 +0800 56 | 57 | photokit (0.2.4) unstable; urgency=low 58 | * 59 | 60 | -- LucasWang Thu, 05 Jul 2012 11:08:09 +0800 61 | 62 | photokit (0.2.0) unstable; urgency=low 63 | * Zooming and moving support when viewing a single image 64 | * Startup animation 65 | * Show tips 66 | * Fix thumb size problem 67 | 68 | -- LucasWang Tue, 03 Jul 2012 00:42:56 +0800 69 | 70 | photokit (0.2.2) unstable; urgency=low 71 | * 72 | 73 | -- LucasWang Tue, 03 Jul 2012 00:42:53 +0800 74 | 75 | photokit (0.1.2) unstable; urgency=low 76 | * 77 | 78 | -- LucasWang Tue, 03 Jul 2012 00:42:27 +0800 79 | 80 | photokit (0.1.0) unstable; urgency=low 81 | * base functions done 82 | 83 | -- LucasWang Sat, 30 Jun 2012 22:39:12 +0800 84 | 85 | photokit (0.1.1) unstable; urgency=low 86 | * 87 | 88 | -- LucasWang Sat, 30 Jun 2012 22:39:09 +0800 89 | 90 | photokit (0.0.1) unstable; urgency=low 91 | 92 | * Initial Release. 93 | 94 | -- LucasWang Wed, 27 Jun 2012 10:00:42 +0800 95 | -------------------------------------------------------------------------------- /qtc_packaging/common/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by WangBin on 2 | Wed, 27 Jun 2012 10:00:42 +0800. 3 | 4 | It was downloaded from 5 | 6 | Upstream Author(s): 7 | 8 | WangBin aka. LucasWang, wbsecg1@gmail.com 9 | 10 | Copyright: 11 | 12 | 13 | 14 | License: 15 | 16 | This package is free software; you can redistribute it and/or modify 17 | it under the terms of the GNU General Public License as published by 18 | the Free Software Foundation; either version 2 of the License, or 19 | (at your option) any later version. 20 | 21 | This package is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | GNU General Public License for more details. 25 | 26 | You should have received a copy of the GNU General Public License 27 | along with this package; if not, write to the Free Software 28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 | 30 | On Debian systems, the complete text of the GNU General 31 | Public License can be found in `/usr/share/common-licenses/GPL'. 32 | 33 | The Debian packaging is (C) 2012, WangBin and 34 | is licensed under the GPL, see above. 35 | 36 | 37 | # Please also look if there are files or directories which have a 38 | # different copyright/license attached and list them here. 39 | -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/PhotoKit.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Encoding=UTF-8 3 | Version=1.0 4 | Type=Application 5 | Terminal=false 6 | Name=PhotoKit 7 | Exec=/opt/PhotoKit/bin/PhotoKit 8 | Icon=PhotoKit 9 | X-Window-Icon= 10 | X-HildonDesk-ShowInToolbar=true 11 | X-Osso-Type=application/x-executable 12 | -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/PhotoKit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/qtc_packaging/debian_fremantle/PhotoKit.png -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/README: -------------------------------------------------------------------------------- 1 | ../common/README -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/changelog: -------------------------------------------------------------------------------- 1 | ../common/changelog -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/copyright: -------------------------------------------------------------------------------- 1 | ../common/copyright -------------------------------------------------------------------------------- /qtc_packaging/debian_fremantle/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | 13 | 14 | 15 | 16 | configure: configure-stamp 17 | configure-stamp: 18 | dh_testdir 19 | # qmake PREFIX=/usr# Uncomment this line for use without Qt Creator 20 | 21 | touch configure-stamp 22 | 23 | 24 | build: build-stamp 25 | 26 | build-stamp: configure-stamp 27 | dh_testdir 28 | 29 | # Add here commands to compile the package. 30 | # $(MAKE) # Uncomment this line for use without Qt Creator 31 | #docbook-to-man debian/photokit.sgml > photokit.1 32 | 33 | touch $@ 34 | 35 | clean: 36 | dh_testdir 37 | dh_testroot 38 | rm -f build-stamp configure-stamp 39 | 40 | # Add here commands to clean up after the build process. 41 | $(MAKE) clean 42 | 43 | dh_clean 44 | 45 | install: build 46 | dh_testdir 47 | dh_testroot 48 | dh_clean -k 49 | dh_installdirs 50 | 51 | # Add here commands to install the package into debian/photokit. 52 | $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/photokit install 53 | 54 | 55 | # Build architecture-independent files here. 56 | binary-indep: build install 57 | # We have nothing to do by default. 58 | 59 | # Build architecture-dependent files here. 60 | binary-arch: build install 61 | dh_testdir 62 | dh_testroot 63 | dh_installchangelogs 64 | dh_installdocs 65 | dh_installexamples 66 | # dh_install 67 | # dh_installmenu 68 | # dh_installdebconf 69 | # dh_installlogrotate 70 | # dh_installemacsen 71 | # dh_installpam 72 | # dh_installmime 73 | # dh_python 74 | # dh_installinit 75 | # dh_installcron 76 | # dh_installinfo 77 | dh_installman 78 | dh_link 79 | dh_strip 80 | dh_compress 81 | dh_fixperms 82 | # dh_perl 83 | # dh_makeshlibs 84 | dh_installdeb 85 | # #dh_shlibdeps # Uncomment this line for use without Qt Creator 86 | dh_gencontrol 87 | dh_md5sums 88 | dh_builddeb 89 | 90 | binary: binary-indep binary-arch 91 | .PHONY: build clean binary-indep binary-arch binary install configure 92 | -------------------------------------------------------------------------------- /qtc_packaging/debian_generic/PhotoKit.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=PhotoKit 3 | Comment=3D photo browser 4 | TryExec=PhotoKit 5 | Exec=PhotoKit %U 6 | StartupNotify=true 7 | Terminal=false 8 | Type=Application 9 | Icon=PhotoKit 10 | Categories=Qt;2DGraphics;Graphics;RasterGraphics;Viewer; 11 | MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-gray;image/x-icb;image/x-ico;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-xbitmap;image/x-xpixmap;image/x-pcx;image/svg+xml;image/svg+xml-compressed;image/vnd.wap.wbmp; 12 | X-Ubuntu-Gettext-Domain=photokit 13 | # Extra keywords that can be used to search for PhotoKit in GNOME Shell and Unity 14 | Keywords=Picture;Slideshow;Graphics; 15 | -------------------------------------------------------------------------------- /qtc_packaging/debian_generic/PhotoKit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/qtc_packaging/debian_generic/PhotoKit.png -------------------------------------------------------------------------------- /qtc_packaging/debian_generic/control: -------------------------------------------------------------------------------- 1 | Package: photokit 2 | Version: 0.3.9 3 | Architecture: %arch% 4 | Source: photokit 5 | Section: user/graphics 6 | Priority: optional 7 | Maintainer: LucasWang 8 | Homepage: 9 | Depends: libexif12 10 | Description: A photo browser with 3D effects. Support share to weibo 11 | PhotoKit is a photo braowser with impressive 3D effects and many slide effects. Support view EXIF. You can share the image to sina weibo easily with it. Google image search is supported. 12 | -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/PhotoKit.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Encoding=UTF-8 3 | Version=1.0 4 | Type=Application 5 | Terminal=false 6 | Name=PhotoKit 7 | Exec=invoker --single-instance --type=e /opt/PhotoKit/bin/PhotoKit 8 | Icon=/usr/share/icons/hicolor/80x80/apps/PhotoKit.png 9 | X-Window-Icon= 10 | X-HildonDesk-ShowInToolbar=true 11 | X-Osso-Type=application/x-executable 12 | -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/PhotoKit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/qtc_packaging/debian_harmattan/PhotoKit.png -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/README: -------------------------------------------------------------------------------- 1 | ../common/README -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/changelog: -------------------------------------------------------------------------------- 1 | ../common/changelog -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/copyright: -------------------------------------------------------------------------------- 1 | ../common/copyright -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/manifest.aegis: -------------------------------------------------------------------------------- 1 | AutoGenerateAegisFile 2 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 43 | 44 | 45 | 48 | 49 | 50 | 53 | 54 | 55 | 58 | 59 | 60 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /qtc_packaging/debian_harmattan/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | 13 | 14 | 15 | 16 | configure: configure-stamp 17 | configure-stamp: 18 | dh_testdir 19 | # qmake PREFIX=/usr# Uncomment this line for use without Qt Creator 20 | 21 | touch configure-stamp 22 | 23 | 24 | build: build-stamp 25 | 26 | build-stamp: configure-stamp 27 | dh_testdir 28 | 29 | # Add here commands to compile the package. 30 | # $(MAKE) # Uncomment this line for use without Qt Creator 31 | #docbook-to-man debian/photokit.sgml > photokit.1 32 | 33 | touch $@ 34 | 35 | clean: 36 | dh_testdir 37 | dh_testroot 38 | rm -f build-stamp configure-stamp 39 | 40 | # Add here commands to clean up after the build process. 41 | $(MAKE) clean 42 | 43 | dh_clean 44 | 45 | install: build 46 | dh_testdir 47 | dh_testroot 48 | dh_clean -k 49 | dh_installdirs 50 | 51 | # Add here commands to install the package into debian/photokit. 52 | $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/photokit install 53 | 54 | 55 | # Build architecture-independent files here. 56 | binary-indep: build install 57 | # We have nothing to do by default. 58 | 59 | # Build architecture-dependent files here. 60 | binary-arch: build install 61 | dh_testdir 62 | dh_testroot 63 | dh_installchangelogs 64 | dh_installdocs 65 | dh_installexamples 66 | # dh_install 67 | # dh_installmenu 68 | # dh_installdebconf 69 | # dh_installlogrotate 70 | # dh_installemacsen 71 | # dh_installpam 72 | # dh_installmime 73 | # dh_python 74 | # dh_installinit 75 | # dh_installcron 76 | # dh_installinfo 77 | dh_installman 78 | dh_link 79 | dh_strip 80 | dh_compress 81 | dh_fixperms 82 | # dh_perl 83 | # dh_makeshlibs 84 | dh_installdeb 85 | # #dh_shlibdeps # Uncomment this line for use without Qt Creator 86 | dh_gencontrol 87 | dh_md5sums 88 | dh_builddeb 89 | 90 | binary: binary-indep binary-arch 91 | .PHONY: build clean binary-indep binary-arch binary install configure 92 | -------------------------------------------------------------------------------- /qtc_packaging/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | 13 | 14 | 15 | 16 | configure: configure-stamp 17 | configure-stamp: 18 | dh_testdir 19 | # qmake PREFIX=/usr# Uncomment this line for use without Qt Creator 20 | 21 | touch configure-stamp 22 | 23 | 24 | build: build-stamp 25 | 26 | build-stamp: configure-stamp 27 | dh_testdir 28 | 29 | # Add here commands to compile the package. 30 | # $(MAKE) # Uncomment this line for use without Qt Creator 31 | #docbook-to-man debian/photokit.sgml > photokit.1 32 | 33 | touch $@ 34 | 35 | clean: 36 | dh_testdir 37 | dh_testroot 38 | rm -f build-stamp configure-stamp 39 | 40 | # Add here commands to clean up after the build process. 41 | $(MAKE) clean 42 | 43 | dh_clean 44 | 45 | install: build 46 | dh_testdir 47 | dh_testroot 48 | dh_clean -k 49 | dh_installdirs 50 | 51 | # Add here commands to install the package into debian/photokit. 52 | $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/photokit install 53 | 54 | 55 | # Build architecture-independent files here. 56 | binary-indep: build install 57 | # We have nothing to do by default. 58 | 59 | # Build architecture-dependent files here. 60 | binary-arch: build install 61 | dh_testdir 62 | dh_testroot 63 | dh_installchangelogs 64 | dh_installdocs 65 | dh_installexamples 66 | # dh_install 67 | # dh_installmenu 68 | # dh_installdebconf 69 | # dh_installlogrotate 70 | # dh_installemacsen 71 | # dh_installpam 72 | # dh_installmime 73 | # dh_python 74 | # dh_installinit 75 | # dh_installcron 76 | # dh_installinfo 77 | dh_installman 78 | dh_link 79 | dh_strip 80 | dh_compress 81 | dh_fixperms 82 | # dh_perl 83 | # dh_makeshlibs 84 | dh_installdeb 85 | # dh_shlibdeps # Uncomment this line for use without Qt Creator 86 | dh_gencontrol 87 | dh_md5sums 88 | dh_builddeb 89 | 90 | binary: binary-indep binary-arch 91 | .PHONY: build clean binary-indep binary-arch binary install configure 92 | -------------------------------------------------------------------------------- /res/PhotoKit.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/res/PhotoKit.icns -------------------------------------------------------------------------------- /res/PhotoKit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/res/PhotoKit.ico -------------------------------------------------------------------------------- /res/PhotoKit.rc: -------------------------------------------------------------------------------- 1 | #include "winver.h" 2 | 3 | IDI_ICON1 ICON DISCARDABLE "PhotoKit.ico" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,3,9,0 7 | PRODUCTVERSION 0,3,9,0 8 | FILEFLAGS 0x0L 9 | FILEFLAGSMASK 0x3fL 10 | FILEOS 0x00040004L 11 | FILETYPE 0x1L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "000004b0" 17 | BEGIN 18 | VALUE "CompanyName", "Shanghai University | wbsecg1@gmail.com" 19 | VALUE "FileDescription", "Photo Browser" 20 | VALUE "FileVersion", "0.3.9.0" 21 | VALUE "LegalCopyright", "Copyright (C) 2012 WangBin." 22 | VALUE "InternalName", "PhotoKit" 23 | VALUE "OriginalFilename", "PhotoKit.exe" 24 | VALUE "ProductName", "PhotoKit" 25 | VALUE "ProductVersion", "0.3.9.0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0, 1200 31 | END 32 | END 33 | 34 | -------------------------------------------------------------------------------- /res/i18n/PhotoKit_zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/res/i18n/PhotoKit_zh_CN.qm -------------------------------------------------------------------------------- /res/icons/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/res/icons/close.png -------------------------------------------------------------------------------- /res/icons/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/res/icons/ok.png -------------------------------------------------------------------------------- /res/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | i18n/PhotoKit_zh_CN.qm 4 | icons/close.png 5 | icons/ok.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /screenshot/2012-06-30 23:46:29的屏幕截图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/screenshot/2012-06-30 23:46:29的屏幕截图.png -------------------------------------------------------------------------------- /screenshot/Logo-160x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/screenshot/Logo-160x120.png -------------------------------------------------------------------------------- /screenshot/Screenshot-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/screenshot/Screenshot-6.png -------------------------------------------------------------------------------- /screenshot/Screenshot-854x480.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/screenshot/Screenshot-854x480.png -------------------------------------------------------------------------------- /screenshot/screenshot.745x745.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wang-bin/PhotoKit/03402516b319b609c06639855a4df68c7fdc4702/screenshot/screenshot.745x745.png -------------------------------------------------------------------------------- /src/BaseItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | BaseItem: animation supported item. Many code are from qtdemo 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_BASEITEM_H 22 | #define PHOTOKIT_BASEITEM_H 23 | 24 | #include 25 | 26 | namespace PhotoKit { 27 | 28 | 29 | class SharedImage 30 | { 31 | public: 32 | SharedImage() : refCount(0), image(0), pixmap(0){} 33 | ~SharedImage() 34 | { 35 | delete image; 36 | delete pixmap; 37 | } 38 | 39 | int refCount; 40 | QImage *image; 41 | QPixmap *pixmap; 42 | QMatrix matrix; 43 | QRectF unscaledBoundingRect; 44 | }; 45 | 46 | class DemoItemAnimation; 47 | class Guide; 48 | class ItemAnimation; 49 | class BaseItem : public QGraphicsItem 50 | { 51 | public: 52 | BaseItem(QGraphicsItem *parent = 0); 53 | virtual ~BaseItem(); 54 | /* 55 | qreal boundingWidth() const; 56 | qreal boundingHeight() const; 57 | */ 58 | 59 | bool inTransition(); 60 | virtual void animationStarted(int id = 0){ Q_UNUSED(id); } 61 | virtual void animationStopped(int id = 0){ Q_UNUSED(id); } 62 | virtual void prepare(){} 63 | void setRecursiveVisible(bool visible); 64 | void useSharedImage(const QString &hashKey); 65 | void setNeverVisible(bool never = true); 66 | static void setMatrix(const QMatrix &matrix); 67 | QMatrix currentMatrix() const {return matrix;} 68 | virtual QRectF boundingRect() const; // overridden 69 | void setPosUsingSheepDog(const QPointF &dest, const QRectF &sceneFence); 70 | 71 | qreal opacity; 72 | bool locked; 73 | DemoItemAnimation *currentAnimation; 74 | bool noSubPixeling; 75 | 76 | // Used if controlled by a guide: 77 | void useGuide(Guide *guide, float startFrame = 0); 78 | void guideAdvance(float distance); 79 | void guideMove(float moveSpeed); 80 | void setGuidedPos(const QPointF &position); 81 | QPointF getGuidedPos(); 82 | float startFrame; 83 | float guideFrame; 84 | Guide *currGuide; 85 | 86 | protected: 87 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option = 0, QWidget *widget = 0); // overridden 88 | virtual QImage *createImage(const QMatrix &) const { return 0; } 89 | virtual bool collidesWithItem(const QGraphicsItem *, Qt::ItemSelectionMode) const { return false; } 90 | bool prepared; 91 | 92 | //virtual void wheelEvent(QGraphicsSceneWheelEvent *event); 93 | //virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 94 | 95 | private: 96 | SharedImage *sharedImage; 97 | QString hashKey; 98 | bool neverVisible; 99 | bool validateImage(); 100 | 101 | // Used if controlled by a guide: 102 | void switchGuide(Guide *guide); 103 | friend class Guide; 104 | QPointF guidedPos; 105 | 106 | // The next static hash is shared amongst all demo items, and 107 | // has the purpose of reusing images to save memory and time 108 | static QHash sharedImageHash; 109 | static QMatrix matrix; 110 | ItemAnimation *mItemAnimation; 111 | friend class PhotoKitView; 112 | qreal mScale; 113 | qreal mX, mY; 114 | }; 115 | 116 | } //namespace PhotoKit 117 | #endif // PHOTOKIT_BASEITEM_H 118 | -------------------------------------------------------------------------------- /src/Button.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Button: graphicsitem based button with animation support 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_BUTTON_H 22 | #define PHOTOKIT_BUTTON_H 23 | 24 | #include 25 | #include "BaseItem.h" 26 | //TODO: fit text width. 27 | namespace PhotoKit { 28 | class OutlineGlowItem; 29 | class ButtonBackground; 30 | class ButtonPrivate; 31 | class Button : public QObject, public BaseItem 32 | { 33 | Q_OBJECT 34 | Q_DECLARE_PRIVATE(Button) 35 | public: 36 | enum ButtonType { Text, Icon, CloseButton, PlayButton, PauseButton, StopButton, ArrowUp, ArrowDown, ArrowLeft, ArrowRight}; //use mirrored image 37 | enum State {ON = 1, OFF = 2, HIGHLIGHT = 4, DISABLED = 8}; 38 | enum ButtonShape { RectShape, RoundedRectShape}; 39 | explicit Button(ButtonType type, ButtonShape shape = RoundedRectShape, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); 40 | explicit Button(const QString& text, ButtonShape shape = RoundedRectShape, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); 41 | explicit Button(const QPixmap& text, ButtonShape shape = RoundedRectShape, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); 42 | virtual ~Button(); 43 | 44 | ButtonType buttonType() const; 45 | ButtonShape buttonShape() const {return mShape;} 46 | void setButtonType(ButtonType type); 47 | 48 | void resize(const QSizeF& size); 49 | void resize(qreal width, qreal height); 50 | qreal width() const; 51 | qreal height() const; 52 | 53 | void setCheckable(bool); 54 | bool isCheckable() const; 55 | 56 | bool isChecked() const; 57 | void setChecked(bool checked); 58 | 59 | void setDown(bool); 60 | bool isDown() const; 61 | 62 | void setText(const QString& text); 63 | QString text() const; //plainText(); 64 | void setIcon(const QIcon& icon); 65 | QPixmap icon() const; 66 | void setColor(const QColor& color); 67 | QColor color() const; 68 | 69 | virtual QRectF boundingRect() const; 70 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ 71 | Q_UNUSED(painter); 72 | Q_UNUSED(option); 73 | Q_UNUSED(widget); 74 | } 75 | //shape() 76 | 77 | signals: 78 | void pressed(); 79 | void released(); 80 | void clicked(bool checked = false); 81 | void toggled(bool checked); 82 | 83 | protected: 84 | void init(); 85 | void setState(State state); 86 | void prepairBackgrounds(); 87 | 88 | virtual void resizeEvent(QGraphicsSceneResizeEvent *event); 89 | //all accept to avoid event send to back items 90 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 91 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 92 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 93 | virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); 94 | virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); 95 | virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); 96 | private: 97 | bool prepared; 98 | ButtonType mType; 99 | ButtonShape mShape; 100 | State mState; 101 | QString mText; 102 | QPixmap mIcon; 103 | ButtonBackground *mBgDisabled, *mBgHighlight, *mBgOn, *mBgOff; 104 | QGraphicsTextItem *mTextItem; 105 | QGraphicsPixmapItem *mIconItem; 106 | OutlineGlowItem *mGlow; 107 | QSize logicalSize; 108 | QColor mColor; 109 | 110 | ButtonPrivate *d_ptr; 111 | }; 112 | 113 | } //namespace PhotoKit 114 | #endif // PHOTOKIT_BUTTON_H 115 | -------------------------------------------------------------------------------- /src/Config.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Config: global configurations 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_CONFIG_H 22 | #define PHOTOKIT_CONFIG_H 23 | 24 | #include "PhotoKit_Global.h" 25 | #include 26 | #include 27 | 28 | namespace PhotoKit { 29 | 30 | class Config 31 | { 32 | public: 33 | static void setAppDir(const QString& dir); 34 | static bool read(const QString& cfg=configPath); 35 | static bool save(const QString& cfg=configPath); 36 | 37 | static void detectSystemResources(); 38 | static void postConfigure(); 39 | static void setLowSettings(); 40 | 41 | static QString glVersion; 42 | 43 | // properties: 44 | static bool openGlAvailable; 45 | static bool openGlRendering; 46 | static bool softwareRendering; 47 | static bool xRenderPresent; 48 | static bool noAdapt; 49 | static bool noTicker; 50 | static bool noRescale; 51 | static bool noAnimations; 52 | static bool noBlending; 53 | static bool noScreenSync; 54 | static bool useLoop; 55 | static bool noWindowMask; 56 | static bool usePixmaps; 57 | static bool useEightBitPalette; 58 | static bool fullscreen; 59 | static bool showBoundingRect; 60 | static float animSpeed; 61 | static bool showFps; 62 | static int fps; 63 | static bool adapted; 64 | static bool verbose; 65 | 66 | static QString language; 67 | 68 | static QColor backgroundColor; 69 | static QColor glowColor; 70 | static QString configPath; 71 | 72 | static bool showLastDisplayed; 73 | static bool showTips; 74 | static int contentHMargin; 75 | static int contentVMargin; 76 | static bool useThumb; 77 | static QString thumbRecordFile; 78 | static QString displayedThumbRecordFile; 79 | static int thumbRows; 80 | static int thumbSpacing; 81 | static int thumbMargin; 82 | static int thumbBorder; 83 | static int thumbItemWidth; 84 | static int thumbItemHeight; 85 | static QString thumbDir; 86 | 87 | static bool keepAspectRatio; 88 | 89 | static QString weiboUser; 90 | static QString weiboPasswd; 91 | 92 | static bool logToFile; 93 | private: 94 | Config(){} 95 | }; 96 | 97 | } //namespace PhotoKit 98 | 99 | #endif // PHOTOKIT_CONFIG_H 100 | -------------------------------------------------------------------------------- /src/DemoItemAnimation.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | DemoItemAnimation: from qtdemo 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_DEMOITEMANIMATION_H 22 | #define PHOTOKIT_DEMOITEMANIMATION_H 23 | 24 | #include 25 | #include 26 | namespace PhotoKit { 27 | class BaseItem; 28 | class DemoItemAnimation : public QGraphicsItemAnimation 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | enum INOROUT {ANIM_IN, ANIM_OUT, ANIM_UNSPECIFIED}; 34 | 35 | DemoItemAnimation(BaseItem *item, INOROUT inOrOut = ANIM_UNSPECIFIED, bool hideOnFinished = false); 36 | virtual ~DemoItemAnimation(); 37 | 38 | virtual void play(bool fromStart = true, bool force = false); 39 | virtual void playReverse(); 40 | virtual void stop(bool reset = true); 41 | virtual void setRepeat(int nr = 0); 42 | 43 | void setDuration(int duration); 44 | void setDuration(float duration){ setDuration(int(duration)); } 45 | void setOpacityAt0(qreal opacity); 46 | void setOpacityAt1(qreal opacity); 47 | void setOpacity(qreal step); 48 | void setCurrentTime(int ms); 49 | void setStartPos(const QPointF &pos); 50 | bool notOwnerOfItem(); 51 | 52 | bool running(); 53 | bool runningOrItemLocked(); 54 | void lockItem(bool state); 55 | void prepare(); 56 | 57 | BaseItem *baseAnimationItem(); 58 | 59 | virtual void afterAnimationStep(qreal step); // overridden 60 | 61 | QTimeLine *timeline; 62 | qreal opacityAt0; 63 | qreal opacityAt1; 64 | int startDelay; 65 | QPointF startPos; 66 | bool hideOnFinished; 67 | bool moveOnPlay; 68 | bool forcePlay; 69 | bool fromStart; 70 | INOROUT inOrOut; 71 | 72 | private slots: 73 | virtual void playWithoutDelay(); 74 | }; 75 | } //namespace PhotoKit 76 | #endif // PHOTOKIT_DEMOITEMANIMATION_H 77 | -------------------------------------------------------------------------------- /src/Dialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Dialog: widget with dialog options 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_DIALOG_H 22 | #define PHOTOKIT_DIALOG_H 23 | 24 | #include 25 | 26 | //TODO: set effect. reject, done, etc 27 | 28 | namespace PhotoKit { 29 | class DialogPrivate; 30 | class Dialog : public QGraphicsWidget 31 | { 32 | Q_OBJECT 33 | public: 34 | enum DialogCode { Accepted, Rejected }; 35 | explicit Dialog(QGraphicsScene *scene, QGraphicsItem *parent = 0); 36 | virtual ~Dialog(); 37 | //void setText(const QString& text); 38 | 39 | void setBackgroundColor(const QColor& color); 40 | QGraphicsWidget* titleBar(); 41 | QGraphicsWidget* centralWidget(); 42 | QGraphicsWidget* buttonBar(); 43 | 44 | void flipShow(); 45 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 46 | signals: 47 | void accepted(); 48 | void rejected(); 49 | void finished(int result); 50 | public slots: 51 | int exec(); 52 | void accept(); 53 | void reject(); 54 | //void done(int r); 55 | 56 | protected: 57 | Dialog(DialogPrivate& d, QGraphicsScene *scene, QGraphicsItem *parent = 0); 58 | 59 | protected slots: 60 | void rotate3D(qreal step); 61 | 62 | protected: 63 | Q_DECLARE_PRIVATE(Dialog) 64 | DialogPrivate* d_ptr; 65 | }; 66 | 67 | } //namespace PhotoKit 68 | 69 | #endif // PHOTOKIT_DIALOG_H 70 | -------------------------------------------------------------------------------- /src/Dialog_p.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | DialogPrivate: base class for the private class of Dialog's subclasses 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKI_DIALOG_P_H 22 | #define PHOTOKI_DIALOG_P_H 23 | 24 | #include 25 | #include 26 | #include 27 | class QSizeF; 28 | class QGraphicsWidget; 29 | class QGraphicsScene; 30 | class QEventLoop; 31 | class QTimeLine; 32 | namespace PhotoKit { 33 | class Dialog; 34 | class ItemAnimation; 35 | class Button; 36 | class DialogPrivate 37 | { 38 | Q_DECLARE_PUBLIC(Dialog) 39 | public: 40 | DialogPrivate(); 41 | QSizeF size() const; 42 | 43 | void setupUi(Dialog* ui); 44 | 45 | virtual ~DialogPrivate(); 46 | 47 | QGraphicsWidget *titleBar; 48 | QGraphicsWidget *central; 49 | QGraphicsWidget *buttonBar; 50 | //QGraphicsTextItem *text; 51 | QEventLoop loop; 52 | QGraphicsScene *scene; 53 | ItemAnimation *animation; 54 | QTimeLine *timeline; //for 3d animation 55 | qreal width; //FIXME: width after resize is not the value i resized, why? 56 | int result; 57 | QColor color; 58 | protected: 59 | Dialog *q_ptr; 60 | }; 61 | 62 | 63 | } //namespace PhotoKit 64 | #endif // PHOTOKI_DIALOG_P_H 65 | -------------------------------------------------------------------------------- /src/FlipAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "FlipAnimation.h" 2 | 3 | FlipAnimation::FlipAnimation(QObject *parent) : 4 | QGraphicsItemAnimation(parent) 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /src/FlipAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef FLIPANIMATION_H 2 | #define FLIPANIMATION_H 3 | 4 | #include 5 | 6 | class FlipAnimation : public QGraphicsItemAnimation 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit FlipAnimation(QObject *parent = 0); 11 | 12 | signals: 13 | 14 | public slots: 15 | 16 | }; 17 | 18 | #endif // FLIPANIMATION_H 19 | -------------------------------------------------------------------------------- /src/Guide.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Guide: from qtdemo 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "Guide.h" 22 | #include 23 | 24 | #include "BaseItem.h" 25 | 26 | namespace PhotoKit { 27 | Guide::Guide(Guide *follows) 28 | { 29 | this->scaleX = 1.0; 30 | this->scaleY = 1.0; 31 | 32 | if (follows){ 33 | while (follows->nextGuide != follows->firstGuide) // append to end 34 | follows = follows->nextGuide; 35 | 36 | follows->nextGuide = this; 37 | this->prevGuide = follows; 38 | this->firstGuide = follows->firstGuide; 39 | this->nextGuide = follows->firstGuide; 40 | this->startLength = int(follows->startLength + follows->length()) + 1; 41 | } 42 | else{ 43 | this->prevGuide = this; 44 | this->firstGuide = this; 45 | this->nextGuide = this; 46 | this->startLength = 0; 47 | } 48 | } 49 | 50 | void Guide::setScale(float scaleX, float scaleY, bool all) 51 | { 52 | this->scaleX = scaleX; 53 | this->scaleY = scaleY; 54 | 55 | if (all){ 56 | Guide *next = this->nextGuide; 57 | while(next != this){ 58 | next->scaleX = scaleX; 59 | next->scaleY = scaleY; 60 | next = next->nextGuide; 61 | } 62 | } 63 | } 64 | 65 | void Guide::setFence(const QRectF &fence, bool all) 66 | { 67 | this->fence = fence; 68 | 69 | if (all){ 70 | Guide *next = this->nextGuide; 71 | while(next != this){ 72 | next->fence = fence; 73 | next = next->nextGuide; 74 | } 75 | } 76 | } 77 | 78 | Guide::~Guide() 79 | { 80 | if (this != this->nextGuide && this->nextGuide != this->firstGuide) 81 | delete this->nextGuide; 82 | } 83 | 84 | float Guide::lengthAll() 85 | { 86 | float len = length(); 87 | Guide *next = this->nextGuide; 88 | while(next != this){ 89 | len += next->length(); 90 | next = next->nextGuide; 91 | } 92 | return len; 93 | } 94 | 95 | void Guide::move(BaseItem *item, QPointF &dest, float moveSpeed) 96 | { 97 | QLineF walkLine(item->getGuidedPos(), dest); 98 | if (moveSpeed >= 0 && walkLine.length() > moveSpeed){ 99 | // The item is too far away from it's destination point. 100 | // So we choose to move it towards it instead. 101 | float dx = walkLine.dx(); 102 | float dy = walkLine.dy(); 103 | 104 | if (qAbs(dx) > qAbs(dy)){ 105 | // walk along x-axis 106 | if (dx != 0){ 107 | float d = moveSpeed * dy / qAbs(dx); 108 | float s = dx > 0 ? moveSpeed : -moveSpeed; 109 | dest.setX(item->getGuidedPos().x() + s); 110 | dest.setY(item->getGuidedPos().y() + d); 111 | } 112 | } 113 | else{ 114 | // walk along y-axis 115 | if (dy != 0){ 116 | float d = moveSpeed * dx / qAbs(dy); 117 | float s = dy > 0 ? moveSpeed : -moveSpeed; 118 | dest.setX(item->getGuidedPos().x() + d); 119 | dest.setY(item->getGuidedPos().y() + s); 120 | } 121 | } 122 | } 123 | 124 | item->setGuidedPos(dest); 125 | } 126 | } //namespace PhotoKit 127 | -------------------------------------------------------------------------------- /src/Guide.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Guide: from qtdemo 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHTOKIT_GUIDE_H 22 | #define PHTOKIT_GUIDE_H 23 | 24 | #include 25 | 26 | namespace PhotoKit { 27 | class BaseItem; 28 | class Guide 29 | { 30 | public: 31 | Guide(Guide *follows = 0); 32 | virtual ~Guide(); 33 | 34 | virtual void guide(BaseItem *item, float moveSpeed) = 0; 35 | void move(BaseItem *item, QPointF &dest, float moveSpeed); 36 | virtual QPointF startPos(){ return QPointF(0, 0); } 37 | virtual QPointF endPos(){ return QPointF(0, 0); } 38 | virtual float length(){ return 1; } 39 | float lengthAll(); 40 | 41 | void setScale(float scaleX, float scaleY, bool all = true); 42 | void setFence(const QRectF &fence, bool all = true); 43 | 44 | int startLength; 45 | Guide *nextGuide; 46 | Guide *firstGuide; 47 | Guide *prevGuide; 48 | float scaleX; 49 | float scaleY; 50 | QRectF fence; 51 | }; 52 | 53 | } //namespace PhotoKit 54 | #endif // PHTOKIT_GUIDE_H 55 | -------------------------------------------------------------------------------- /src/ImageBaseInfo.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageBaseInfo.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef IMAGEBASEINFO_H 22 | #define IMAGEBASEINFO_H 23 | 24 | #endif // IMAGEBASEINFO_H 25 | -------------------------------------------------------------------------------- /src/ImageProvider.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageProvider: base class for image filtering 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ImageProvider.h" 22 | #include "ImageProvider_p.h" 23 | 24 | namespace PhotoKit { 25 | 26 | 27 | ImageProvider::ImageProvider(QObject *parent) 28 | :QObject(parent),d_ptr(new ImageProviderPrivate) 29 | { 30 | } 31 | 32 | ImageProvider::ImageProvider(ImageProviderPrivate &d, QObject *parent) 33 | :QObject(parent),d_ptr(&d) 34 | { 35 | 36 | } 37 | 38 | ImageProvider::~ImageProvider() 39 | { 40 | if (d_ptr) { 41 | delete d_ptr; 42 | d_ptr = 0; 43 | } 44 | } 45 | 46 | void ImageProvider::setNameFilter(const QString &filter) 47 | { 48 | Q_D(ImageProvider); 49 | d->nameFilter = filter; 50 | d->page = 0; //reset for a new search 51 | } 52 | 53 | bool ImageProvider::canFetchMore() const 54 | { 55 | return true; 56 | } 57 | 58 | } //namespace PhotoKit 59 | -------------------------------------------------------------------------------- /src/ImageProvider.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageProvider: base class for image filtering 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_IMAGEPROVIDER_H 22 | #define PHOTOKIT_IMAGEPROVIDER_H 23 | 24 | #include 25 | #include 26 | 27 | namespace PhotoKit { 28 | 29 | class ImageBaseInfo 30 | { 31 | public: 32 | int width, height; 33 | int thumbWidth, thumbHeight; 34 | QString path; 35 | QString thumbPath; 36 | //QString title; 37 | }; 38 | 39 | class ImageProviderPrivate; 40 | class ImageProvider : public QObject 41 | { 42 | Q_OBJECT 43 | Q_DECLARE_PRIVATE(ImageProvider) 44 | public: 45 | ImageProvider(QObject *parent = 0); 46 | virtual ~ImageProvider(); 47 | 48 | void setNameFilter(const QString& filter); 49 | //void setSizeFilter(); 50 | 51 | virtual bool canFetchMore() const; 52 | virtual void fetchMore() = 0; 53 | 54 | signals: 55 | //void imageReady(const QImage& image); 56 | void imageReady(const ImageBaseInfo& path); 57 | void imagesReady(const QList& paths); 58 | //void imagesReady(const QList& paths); 59 | 60 | 61 | protected: 62 | ImageProvider(ImageProviderPrivate& d, QObject* parent = 0); 63 | 64 | ImageProviderPrivate *d_ptr; 65 | }; 66 | 67 | } //namespace PhotoKit 68 | #endif // PHOTOKIT_IMAGEPROVIDER_H 69 | -------------------------------------------------------------------------------- /src/ImageProvider_p.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageProviderPrivate: base class for the private class of ImageProvider's subclasses 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_IMAGEPROVIDER_P_H 22 | #define PHOTOKIT_IMAGEPROVIDER_P_H 23 | #include 24 | 25 | namespace PhotoKit { 26 | 27 | class ImageProviderPrivate 28 | { 29 | public: 30 | ImageProviderPrivate():page(0){} 31 | virtual ~ImageProviderPrivate(){} 32 | int page; 33 | QString nameFilter; 34 | 35 | }; 36 | 37 | } //namespace PhotoKit 38 | #endif // PHOTOKIT_IMAGEPROVIDER_P_H 39 | -------------------------------------------------------------------------------- /src/ItemAnimation.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ItemAnimation: animation for non-qobject items 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include "ItemAnimation.h" 21 | #include 22 | #include 23 | #include "TransformMachine.h" 24 | namespace PhotoKit { 25 | 26 | ItemAnimation::ItemAnimation(QGraphicsItem *item, QObject *parent) : 27 | QObject(parent),mHide(false),mFade(None) 28 | { 29 | mMachine = new TransformMachine;//QGraphicsItemAnimation; 30 | QTimeLine *timer = new QTimeLine(1000); 31 | timer->setEasingCurve(QEasingCurve::OutQuad); 32 | timer->setFrameRange(0, 100); 33 | mMachine->setTimeLine(timer); 34 | connect(mMachine, SIGNAL(transformChanged(QTransform)), this, SLOT(setTransform(QTransform))); 35 | connect(mMachine, SIGNAL(zValueChanged(qreal)), this, SLOT(setZValue(qreal))); 36 | connect(mMachine, SIGNAL(posChanged(QPointF)), this, SLOT(setItemPos(QPointF))); 37 | connect(mMachine->timeLine(), SIGNAL(finished()), this, SLOT(tryHide())); 38 | connect(mMachine->timeLine(), SIGNAL(finished()), this, SIGNAL(finished())); 39 | 40 | setItem(item); 41 | } 42 | 43 | void ItemAnimation::setItem(QGraphicsItem *item) 44 | { 45 | if (item) { 46 | mItem = item; 47 | mMachine->setStartPos(item->pos()); // 48 | } 49 | } 50 | 51 | void ItemAnimation::setDuration(int duration) 52 | { 53 | mMachine->timeLine()->setDuration(duration); 54 | } 55 | 56 | void ItemAnimation::setTransform(const QTransform &m) 57 | { 58 | mItem->setTransform(m); 59 | switch (mFade) { 60 | case FadeOut: 61 | mItem->setOpacity(qMax(1.0 - currentStep(), 0)); 62 | break; 63 | case FadeIn: 64 | mItem->setVisible(true); 65 | mItem->setOpacity(currentStep()); 66 | break; 67 | case None: 68 | mItem->setOpacity(1.0); 69 | break; 70 | default: 71 | break; 72 | } 73 | } 74 | 75 | void ItemAnimation::setItemPos(const QPointF &pos) 76 | { 77 | mItem->setPos(pos); 78 | } 79 | 80 | void ItemAnimation::setZValue(qreal z) 81 | { 82 | mItem->setZValue(z); 83 | } 84 | 85 | void ItemAnimation::setAutoHide(bool hide) 86 | { 87 | mHide = hide; 88 | } 89 | 90 | void ItemAnimation::setFade(Fade fade) 91 | { 92 | mFade = fade; 93 | mHide = mFade == FadeOut; 94 | } 95 | 96 | TransformMachine* ItemAnimation::transformMachine() 97 | { 98 | return mMachine; 99 | } 100 | 101 | qreal ItemAnimation::currentStep() const 102 | { 103 | return mMachine->timeLine()->currentValue(); 104 | } 105 | 106 | bool ItemAnimation::isRunning() const 107 | { 108 | return mMachine->timeLine()->state() == QTimeLine::Running; 109 | } 110 | 111 | void ItemAnimation::start() 112 | { 113 | mMachine->timeLine()->start(); 114 | } 115 | 116 | void ItemAnimation::stop() 117 | { 118 | mMachine->timeLine()->stop(); 119 | } 120 | 121 | void ItemAnimation::tryHide() 122 | { 123 | mItem->setVisible(!mHide || mFade == FadeOut); 124 | } 125 | 126 | } //namespace PhotoKit 127 | -------------------------------------------------------------------------------- /src/ItemAnimation.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ItemAnimation: animation for non-qobject items 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_ITEMANIMATION_H 22 | #define PHOTOKIT_ITEMANIMATION_H 23 | 24 | #include 25 | #include "PhotoKit_Global.h" 26 | 27 | class QGraphicsItem; 28 | class QTransform; 29 | class QPointF; 30 | namespace PhotoKit { 31 | class TransformMachine; 32 | //We can use QGraphicsItemAnimation instead. but zValue can't be animated; 33 | class ItemAnimation : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | enum Fade {FadeIn, FadeOut, None}; 38 | ItemAnimation(QGraphicsItem *item = 0, QObject *parent = 0); 39 | void setItem(QGraphicsItem *item); 40 | void setDuration(int duration); 41 | void setAutoHide(bool hide); 42 | void setFade(Fade fade); 43 | TransformMachine* transformMachine(); 44 | qreal currentStep() const; 45 | bool isRunning() const; 46 | 47 | void start(); 48 | void stop(); 49 | 50 | signals: 51 | void finished(); 52 | public slots: 53 | void setTransform(const QTransform& m); 54 | void setItemPos(const QPointF& pos); 55 | void setZValue(qreal z); 56 | void tryHide(); 57 | 58 | private: 59 | QGraphicsItem* mItem; 60 | TransformMachine *mMachine; 61 | bool mHide; 62 | Fade mFade; 63 | }; 64 | 65 | }//namespace PhotoKit 66 | #endif // PHOTOKIT_ITEMANIMATION_H 67 | -------------------------------------------------------------------------------- /src/OptionParser.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | OptionParser: commandline parser based on my ProgramOptions 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "OptionParser.h" 22 | #include 23 | #include "ProgramOptions.h" 24 | #include "ThumbRecorder.h" 25 | #include "tools/Tools.h" 26 | #include "Config.h" 27 | 28 | //priority: cmd > config.ini > auto detect 29 | namespace po = ProgramOptions; 30 | 31 | namespace PhotoKit { 32 | QStringList OptionParser::images; 33 | void OptionParser::parseCmd(int argc, const char *const*argv) 34 | { 35 | static OptionParser cmd; 36 | po::parse(argc, argv); 37 | if (po::get("h")) 38 | po::help(); 39 | if (po::get("no-thumb")) { 40 | Config::useThumb = false; 41 | } 42 | if (po::get("opengl")) { 43 | Config::openGlRendering = true; 44 | } 45 | if (po::get("no-opengl")) { 46 | Config::openGlRendering = false; 47 | } 48 | if (po::get("logfile")) { 49 | Config::logToFile = true; 50 | } 51 | QString d(po::get("d").str().c_str()); 52 | if (!d.isEmpty()) { 53 | getImagesFromDirs(d.split(";")); 54 | } 55 | QString f(po::get("f").str().c_str()); 56 | if (!f.isEmpty()) { 57 | Config::showLastDisplayed = false; 58 | images << f.split(";"); 59 | } 60 | if (images.isEmpty()) { 61 | images << *ThumbRecorder::instance()->displayedThumbs(); 62 | } 63 | } 64 | 65 | OptionParser::OptionParser() 66 | { 67 | po::summary("PhotoKit is a photo browser with impressive 3d effects.\n" 68 | "Copyright (C) 2012 Wang Bin ") 69 | ["Usage:"] 70 | ("-h,--help", "show this message") 71 | ("--no-thumb", "load images without using thumbnails") 72 | ("--opengl", "enable opengl") 73 | ("--no-opengl", "disable opengl") 74 | ("-d,--dirs", "", "load images from dirs") 75 | ("-f,--files", "", "load image from files") 76 | ("--logfile", "enable log to file") 77 | ; 78 | 79 | //the read after detect so that the configuration in config file will be applied 80 | Config::detectSystemResources(); 81 | Config::read(); 82 | Config::postConfigure(); 83 | } 84 | 85 | void OptionParser::getImagesFromDirs(const QStringList &dirs) 86 | { 87 | images.clear(); 88 | foreach(const QString& dir, dirs) { 89 | QDir d(dir); 90 | if (!d.exists()) 91 | continue; 92 | QStringList list = d.entryList(Tools::imageNameFilters(), QDir::Files); 93 | list.replaceInStrings(QRegExp("^(.*)"), dir + "/\\1"); 94 | images << list; 95 | } 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/OptionParser.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | OptionParser: commandline parser based on my ProgramOptions 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_CMDPARSER_H 22 | #define PHOTOKIT_CMDPARSER_H 23 | 24 | class QStringList; 25 | namespace PhotoKit { 26 | 27 | class OptionParser { 28 | public: 29 | static void parseCmd(int argc, const char* const* argv); 30 | static QStringList images; 31 | private: 32 | OptionParser(); 33 | static void getImagesFromDirs(const QStringList& dirs); 34 | }; 35 | 36 | 37 | 38 | } 39 | #endif // PHOTOKIT_CMDPARSER_H 40 | -------------------------------------------------------------------------------- /src/OutlineGlowItem.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | OutlineGlowItem: blured outline for items 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "OutlineGlowItem.h" 22 | 23 | #include 24 | #include 25 | #include "Config.h" 26 | 27 | namespace PhotoKit { 28 | 29 | OutlineGlowItem::OutlineGlowItem(QGraphicsItem *parent) 30 | :QGraphicsPixmapItem(parent),mGlowWidth(7),mColor(Config::glowColor) 31 | { 32 | setCacheMode(QGraphicsItem::ItemCoordinateCache); //item.scroll enabled(not for gl). speed up 33 | setFlag(QGraphicsItem::ItemStacksBehindParent); 34 | QGraphicsBlurEffect *blur = new QGraphicsBlurEffect; 35 | blur->setBlurHints(QGraphicsBlurEffect::PerformanceHint); 36 | blur->setBlurRadius(22); 37 | setGraphicsEffect(blur); 38 | } 39 | 40 | QColor OutlineGlowItem::color() const 41 | { 42 | return mColor; 43 | } 44 | 45 | qreal OutlineGlowItem::glowWidth() const 46 | { 47 | return mGlowWidth; 48 | } 49 | 50 | void OutlineGlowItem::render() 51 | { 52 | QPainterPathStroker pps; 53 | pps.setCapStyle(Qt::RoundCap); 54 | pps.setJoinStyle(Qt::RoundJoin); 55 | pps.setWidth(mGlowWidth); 56 | mOutline = pps.createStroke(mShape).simplified();//.united(mShape).simplified(); 57 | //QImage image(mSize, QImage::Format_ARGB32_Premultiplied); 58 | mPixmap = QPixmap(mSize); 59 | mPixmap.fill(Qt::transparent); 60 | //QPainter painter(&image);//&mPixmap); 61 | QPainter painter(&mPixmap); 62 | QBrush brush(mColor); 63 | painter.drawPath(mOutline); 64 | painter.fillPath(mOutline, brush); 65 | //painter.setPen(mColor.lighter(123)); 66 | //painter.drawPath(mOutline); 67 | setPixmap(mPixmap); 68 | //setPixmap(QPixmap::fromImage(image)); 69 | } 70 | 71 | void OutlineGlowItem::setColor(const QColor& color) 72 | { 73 | mColor = color; 74 | } 75 | 76 | void OutlineGlowItem::setGlowWidth(qreal glowWidth) 77 | { 78 | mGlowWidth = glowWidth; 79 | } 80 | 81 | void OutlineGlowItem::setShape(const QPainterPath& shape) 82 | { 83 | mShape = shape; 84 | } 85 | 86 | void OutlineGlowItem::setSize(const QSize& size) 87 | { 88 | mSize = size; 89 | } 90 | 91 | 92 | } //namespace PhotoKit 93 | -------------------------------------------------------------------------------- /src/OutlineGlowItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | OutlineGlowItem: blured outline for items 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_OUTLINEGLOWITEM_H 22 | #define PHOTOKIT_OUTLINEGLOWITEM_H 23 | 24 | #include "PhotoKit_Global.h" 25 | 26 | #include 27 | 28 | namespace PhotoKit { 29 | //TODO: shapeitem 30 | class OutlineGlowItem : public QGraphicsPixmapItem 31 | { 32 | public: 33 | OutlineGlowItem(QGraphicsItem * parent = 0); 34 | qreal glowWidth() const; 35 | QColor color() const; 36 | void render(); 37 | void setGlowWidth(qreal glowWidth); 38 | void setColor(const QColor& color); 39 | void setShape(const QPainterPath& shape); 40 | void setSize(const QSize& size); 41 | 42 | private: 43 | qreal mGlowWidth; 44 | QColor mColor; 45 | QPainterPath mOutline, mShape; 46 | QSize mSize; 47 | QPixmap mPixmap; 48 | }; 49 | 50 | } //namespace PhotoKit 51 | #endif // PHOTOKIT_OUTLINEGLOWITEM_H 52 | -------------------------------------------------------------------------------- /src/PhotoKit.pro: -------------------------------------------------------------------------------- 1 | 2 | QT += opengl network 3 | 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets concurrent 5 | 6 | TARGET = PhotoKit 7 | TEMPLATE = app 8 | PROJECTROOT = $$PWD/.. 9 | include($$PROJECTROOT/deploy.pri) 10 | isEmpty(BUILD_DIR):BUILD_DIR=$$(BUILD_DIR) 11 | isEmpty(BUILD_DIR):BUILD_DIR=$$[BUILD_DIR] 12 | isEmpty(BUILD_DIR):BUILD_IN_SRC = yes 13 | #TODO: lupdate doing wrong 14 | TRANSLATIONS += $${PROJECTROOT}/i18n/$${TARGET}_zh-cn.ts $${PROJECTROOT}/i18n/$${TARGET}_zh_CN.ts 15 | #common.pri will be included only once and dirs are the values first time included, so include the project's 16 | #common.pri first. 17 | #if BUILD_DIR not set, keep the src structure 18 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/../out 19 | include($${PROJECTROOT}/common.pri) 20 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/ezlog/out 21 | !include(ezlog/src/libezlog.pri): error(could not find libezlog.pri) 22 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/ProgramOptions/out 23 | !include(ProgramOptions/src/libProgramOptions.pri): error(could not find libProgramOptions.pri) 24 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/NextEffect/out 25 | !include(NextEffect/src/libNextEffect.pri): error(could not find libNextEffect.pri) 26 | win32|mac { 27 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/libexif-port/out 28 | !include(libexif-port/libexif.pri): error(could not find libexif.pri) 29 | } else { 30 | LIBS += -lexif 31 | } 32 | 33 | message(PhotoKit out=$$BUILD_DIR) 34 | unix:!macx { 35 | QMAKE_RPATHDIR *= $$PROJECT_LIBDIR:\'\$\$ORIGIN\':\'\$\$ORIGIN/lib\':. 36 | QMAKE_LFLAGS *= -Wl,-z,origin 37 | } 38 | 39 | INCLUDEPATH += $$PWD 40 | SOURCES += main.cpp \ 41 | ThumbTask.cpp \ 42 | Config.cpp \ 43 | PhotoKitView.cpp \ 44 | PhotoKitScene.cpp \ 45 | ThumbItem.cpp \ 46 | OutlineGlowItem.cpp \ 47 | TransformMachine.cpp \ 48 | ItemAnimation.cpp \ 49 | ReflectEffectItem.cpp \ 50 | ShareManager.cpp \ 51 | UiManager.cpp \ 52 | OptionParser.cpp \ 53 | tools/Tools.cpp \ 54 | SlideDisplay.cpp \ 55 | SlidePlayControl.cpp \ 56 | network/weiboapi.cpp \ 57 | network/qput.cpp \ 58 | Guide.cpp \ 59 | DemoItemAnimation.cpp \ 60 | tools/ToolTip.cpp \ 61 | ToolBar.cpp \ 62 | Button.cpp \ 63 | ProgressBarItem.cpp \ 64 | score.cpp \ 65 | BaseItem.cpp \ 66 | FlipAnimation.cpp \ 67 | tools/ExifReader.cpp \ 68 | Dialog.cpp \ 69 | tools/ImageInfoDialog.cpp \ 70 | network/WeiboDialog.cpp \ 71 | TextEdit.cpp \ 72 | ImageProvider.cpp \ 73 | network/GoogleImageSearcher.cpp \ 74 | ThumbRecorder.cpp 75 | 76 | HEADERS += \ 77 | ThumbTask.h \ 78 | Config.h \ 79 | PhotoKit_Global.h \ 80 | PhotoKitView.h \ 81 | PhotoKitScene.h \ 82 | ThumbItem.h \ 83 | OutlineGlowItem.h \ 84 | TransformMachine.h \ 85 | ItemAnimation.h \ 86 | ReflectEffectItem.h \ 87 | ShareManager.h \ 88 | UiManager.h \ 89 | OptionParser.h \ 90 | tools/Tools.h \ 91 | SlideDisplay.h \ 92 | SlidePlayControl.h \ 93 | network/weiboapi.h \ 94 | network/qput.h \ 95 | Guide.h \ 96 | DemoItemAnimation.h \ 97 | tools/ToolTip.h \ 98 | ToolBar.h \ 99 | Button.h \ 100 | ProgressBarItem.h \ 101 | score.h \ 102 | BaseItem.h \ 103 | FlipAnimation.h \ 104 | tools/ExifReader.h \ 105 | Dialog.h \ 106 | tools/ImageInfoDialog.h \ 107 | Dialog_p.h \ 108 | network/WeiboDialog.h \ 109 | TextEdit.h \ 110 | ImageProvider.h \ 111 | ImageProvider_p.h \ 112 | network/GoogleImageSearcher.h \ 113 | ImageBaseInfo.h \ 114 | ThumbRecorder.h 115 | 116 | #CONFIG += mobility 117 | MOBILITY = 118 | 119 | RESOURCES += \ 120 | ../res/res.qrc 121 | #exe icon on win 122 | win32 { 123 | RC_FILE = ../res/PhotoKit.rc 124 | } 125 | #on mac 126 | mac { 127 | ICON = ../res/PhotoKit.icns 128 | } 129 | OTHER_FILES += $$RESOURCES $$RC_FILE 130 | message($$_PRO_FILE_PWD_) 131 | #message($$_PRO_FILE_) 132 | message($$OUT_PWD) 133 | message($$PWD) 134 | message($$IN_PWD) 135 | message($$_FILE_) 136 | message($$_LINE_) 137 | message($$QMAKE_HOST.version) 138 | message($$QMAKE_HOST.name) 139 | message($$QMAKE_HOST.os) 140 | message($$QMAKE_HOST.arch) 141 | message($$BUILD_NAME) 142 | 143 | 144 | -------------------------------------------------------------------------------- /src/PhotoKitScene.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | PhotoKitScene: PhotoKit's scene 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "PhotoKitScene.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "Config.h" 29 | #include "ezlog.h" 30 | namespace PhotoKit { 31 | 32 | PhotoKitScene::PhotoKitScene(QObject *parent) : 33 | QGraphicsScene(parent) 34 | { 35 | //setItemIndexMethod(QGraphicsScene::NoIndex); 36 | setBackgroundBrush(QBrush(Config::backgroundColor)); 37 | 38 | } 39 | /* 40 | void PhotoKitScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) 41 | { 42 | // 43 | QGraphicsScene::contextMenuEvent(event); 44 | } 45 | */ 46 | /* 47 | void PhotoKitScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) 48 | { 49 | //ezlog_debug("move in scene"); 50 | event->accept(); 51 | }*/ 52 | 53 | } //namespace PhotoKit 54 | -------------------------------------------------------------------------------- /src/PhotoKitScene.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | PhotoKitScene: PhotoKit's scene 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_PHOTOKITSCENE_H 22 | #define PHOTOKIT_PHOTOKITSCENE_H 23 | 24 | #include "PhotoKit_Global.h" 25 | 26 | #include 27 | 28 | namespace PhotoKit { 29 | 30 | //remove singleton. UiManager::updateThumbItemAt() 31 | class PhotoKitScene : public QGraphicsScene 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit PhotoKitScene(QObject *parent = 0); 36 | 37 | protected: 38 | //virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); 39 | //virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 40 | 41 | private: 42 | }; 43 | 44 | } //namespace PhotoKit 45 | 46 | #endif // PHOTOKIT_PHOTOKITSCENE_H 47 | -------------------------------------------------------------------------------- /src/PhotoKitView.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | PhotoKitView: PhotoKit's view 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_PHOTOKITVIEW_H 22 | #define PHOTOKIT_PHOTOKITVIEW_H 23 | 24 | #include "PhotoKit_Global.h" 25 | 26 | //#include 27 | #include 28 | 29 | namespace PhotoKit { 30 | class TransformMachine; 31 | class PhotoKitScene; 32 | class PhotoKitView : public QGraphicsView 33 | { 34 | Q_OBJECT 35 | public: 36 | enum ZoomAction { ZoomIn, ZoomOut}; 37 | explicit PhotoKitView(QWidget *parent = 0); 38 | bool canTransform() const; 39 | void setCanTransform(bool can); 40 | QRectF visibleSceneRect() const; 41 | void setAnimationDuration(int ms); 42 | void setInitialPos(qreal x, qreal y); 43 | void smartTransform(qreal x, qreal y, qreal scale0, qreal scale, qreal xRot, qreal yRot, qreal zRot, qreal xShear, qreal yShear); 44 | void smoothScale(ZoomAction zoom, qreal dRatio_abs = 0.1); 45 | signals: 46 | 47 | protected: 48 | //TODO: add smartTransform(qreal x, qreal y, qreal scale); 49 | //TODO: multiTouch 50 | //virtual bool event(QEvent *event); 51 | /*not move to scene. scene may be transformed*/ 52 | //virtual void dragMoveEvent(QDragMoveEvent *event); 53 | virtual void contextMenuEvent(QContextMenuEvent *event); 54 | virtual void keyPressEvent(QKeyEvent *event); 55 | virtual void wheelEvent(QWheelEvent *event); 56 | virtual void mousePressEvent(QMouseEvent *event); 57 | virtual void mouseMoveEvent(QMouseEvent *event); //TODO:test rotate 58 | virtual void mouseReleaseEvent(QMouseEvent *event); 59 | virtual void mouseDoubleClickEvent(QMouseEvent *event); 60 | virtual void resizeEvent(QResizeEvent *event); 61 | virtual bool viewportEvent(QEvent *event); 62 | 63 | private slots: 64 | void doTransform(const QTransform& m); 65 | private: 66 | void setRenderingSystem(); 67 | 68 | bool mPressed; 69 | PhotoKitScene *mScene; 70 | /*qreal &mScale; 71 | qreal mScaleS, mScaleT; //search page, thumb page 72 | //qreal mXRot, mYRot, mZRot; 73 | qreal &mX, &mY; 74 | qreal mXS, mYS, mXT, mYT; //search page 75 | //qreal mHShear, mVShear;*/ 76 | QPointF mMousePos; 77 | //QTime mPressTime; //not required. use movement distance is enough 78 | 79 | TransformMachine *mMachine; 80 | bool mCanTransform; 81 | bool mZoomOnMove; 82 | }; 83 | 84 | } //namespace PhotoKit 85 | 86 | #endif // PHOTOKIT_PHOTOKITVIEW_H 87 | -------------------------------------------------------------------------------- /src/PhotoKit_Global.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | PhotoKit_Global.h: macros 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_GLOBAL_H 22 | #define PHOTOKIT_GLOBAL_H 23 | 24 | #define BEGIN_NAMESPACE_PHOTOKIT namespace PhotoKit { 25 | #define END_NAMESPACE_PHOTOKIT } //namespace PhotoKit 26 | 27 | 28 | #undef PHOTOKIT_VERSION //0x000309 29 | 30 | #define PHOTOKIT_VERSION_MAJOR 0 //((PHOTOKIT_VERSION&0xff0000)>>16) 31 | #define PHOTOKIT_VERSION_MINOR 3 //((PHOTOKIT_VERSION&0xff00)>>8) 32 | #define PHOTOKIT_VERSION_PATCH 9 //(PHOTOKIT_VERSION&0xff) 33 | 34 | #define VERSION_CHK(major, minor, patch) \ 35 | (((major&0xff)<<16) | ((minor&0xff)<<8) | (patch&0xff)) 36 | 37 | #define PHOTOKIT_VERSION VERSION_CHK(PHOTOKIT_VERSION_MAJOR, PHOTOKIT_VERSION_MINOR, PHOTOKIT_VERSION_PATCH) 38 | 39 | /*! Stringify \a x. */ 40 | #define _TOSTR(x) #x 41 | /*! Stringify \a x, perform macro expansion. */ 42 | #define TOSTR(x) _TOSTR(x) 43 | 44 | static const char* const k_PhotoKit_version_string = TOSTR(PHOTOKIT_VERSION_MAJOR)"."TOSTR(PHOTOKIT_VERSION_MINOR)"."TOSTR(PHOTOKIT_VERSION_PATCH)"(" __DATE__", "__TIME__")"; 45 | #define PHOTOKIT_VERSION_STR TOSTR(PHOTOKIT_VERSION_MAJOR)"."TOSTR(PHOTOKIT_VERSION_MINOR)"."TOSTR(PHOTOKIT_VERSION_PATCH) 46 | #define PHOTOKIT_VERSION_STR_LONG PHOTOKIT_VERSION_STR"(" __DATE__", "__TIME__")" 47 | 48 | /***from webkit/JavascriptCore/wtf***/ 49 | #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE) 50 | 51 | /* COMPILER(MSVC) Microsoft Visual C++ */ 52 | /* COMPILER(MSVC7_OR_LOWER) Microsoft Visual C++ 2003 or lower*/ 53 | /* COMPILER(MSVC9_OR_LOWER) Microsoft Visual C++ 2008 or lower*/ 54 | #if defined(_MSC_VER) 55 | #define WTF_COMPILER_MSVC 1 56 | #if _MSC_VER < 1400 57 | #define WTF_COMPILER_MSVC7_OR_LOWER 1 58 | #elif _MSC_VER < 1600 59 | #define WTF_COMPILER_MSVC9_OR_LOWER 1 60 | #endif 61 | #endif 62 | 63 | /* COMPILER(GCC) - GNU Compiler Collection */ 64 | /* --gnu option of the RVCT compiler also defines __GNUC__ */ 65 | #if defined(__GNUC__) && !COMPILER(RVCT) 66 | #define WTF_COMPILER_GCC 1 67 | #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 68 | #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) 69 | #else 70 | /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_AT_LEAST(4, 1, 0). */ 71 | #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 72 | #endif 73 | 74 | 75 | /* COMPILER(RVCT) - ARM RealView Compilation Tools */ 76 | /* COMPILER(RVCT4_OR_GREATER) - ARM RealView Compilation Tools 4.0 or greater */ 77 | #if defined(__CC_ARM) || defined(__ARMCC__) 78 | #define WTF_COMPILER_RVCT 1 79 | #define RVCT_VERSION_AT_LEAST(major, minor, patch, build) (__ARMCC_VERSION >= (major * 100000 + minor * 10000 + patch * 1000 + build)) 80 | #else 81 | /* Define this for !RVCT compilers, just so we can write things like RVCT_VERSION_AT_LEAST(3, 0, 0, 0). */ 82 | #define RVCT_VERSION_AT_LEAST(major, minor, patch, build) 0 83 | #endif 84 | 85 | /* COMPILER(MINGW) - MinGW GCC */ 86 | /* COMPILER(MINGW64) - mingw-w64 GCC - only used as additional check to exclude mingw.org specific functions */ 87 | #if defined(__MINGW32__) 88 | #define WTF_COMPILER_MINGW 1 89 | #endif /* __MINGW32__ */ 90 | 91 | #ifdef __GNUC__ 92 | # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) 93 | #else 94 | # define AV_GCC_VERSION_AT_LEAST(x,y) 0 95 | #endif 96 | 97 | 98 | #ifndef ALWAYS_INLINE 99 | #if COMPILER(GCC) && AV_GCC_VERSION_AT_LEAST(3,1) && !COMPILER(MINGW) 100 | #define ALWAYS_INLINE inline __attribute__((__always_inline__)) 101 | #elif (COMPILER(MSVC) || COMPILER(RVCT)) 102 | #define ALWAYS_INLINE __forceinline 103 | #else 104 | #define ALWAYS_INLINE inline 105 | #endif 106 | #endif //ALWAYS_INLINE 107 | 108 | #ifndef NEVER_INLINE 109 | #if COMPILER(GCC) && AV_GCC_VERSION_AT_LEAST(3,1) 110 | #define NEVER_INLINE __attribute__((__noinline__)) 111 | #elif COMPILER(RVCT) 112 | #define NEVER_INLINE __declspec(noinline) 113 | #else 114 | #define NEVER_INLINE 115 | #endif 116 | #endif //NEVER_INLINE 117 | 118 | #ifndef UNLIKELY 119 | #if COMPILER(GCC) || (RVCT_VERSION_AT_LEAST(3, 0, 0, 0) && defined(__GNUC__)) 120 | #define UNLIKELY(x) __builtin_expect((x), 0) 121 | #else 122 | #define UNLIKELY(x) (x) 123 | #endif 124 | #endif //UNLIKELY 125 | 126 | #ifndef LIKELY 127 | #if COMPILER(GCC) || (RVCT_VERSION_AT_LEAST(3, 0, 0, 0) && defined(__GNUC__)) 128 | #define LIKELY(x) __builtin_expect((x), 1) 129 | #else 130 | #define LIKELY(x) (x) 131 | #endif 132 | #endif //LIKELY 133 | 134 | #include 135 | 136 | //e.g. qt4.7.0 137 | #ifndef Q_UNLIKELY 138 | #define Q_UNLIKELY(x) UNLIKELY(x) 139 | #endif 140 | 141 | #ifndef Q_LIKELY 142 | #define Q_LIKELY(x) LIKELY(x) 143 | #endif 144 | 145 | #endif // PHOTOKIT_GLOBAL_H 146 | -------------------------------------------------------------------------------- /src/ProgressBarItem.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ProgressBarItem.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ProgressBarItem.h" 22 | 23 | namespace PhotoKit { 24 | 25 | ProgressBarItem::ProgressBarItem(QGraphicsItem *parent) : 26 | QGraphicsItem(parent) 27 | { 28 | } 29 | 30 | } //namespace PhotoKit 31 | -------------------------------------------------------------------------------- /src/ProgressBarItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ProgressBarItem.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_PROGRESSBARITEM_H 22 | #define PHOTOKIT_PROGRESSBARITEM_H 23 | 24 | #include "PhotoKit_Global.h" 25 | 26 | #include 27 | //Hide bar if value == 100 28 | namespace PhotoKit { 29 | 30 | class ProgressBarItem : public QGraphicsItem 31 | { 32 | public: 33 | explicit ProgressBarItem(QGraphicsItem *parent = 0); 34 | 35 | 36 | }; 37 | 38 | } //namespace PhotoKit 39 | #endif // PHOTOKIT_PROGRESSBARITEM_H 40 | -------------------------------------------------------------------------------- /src/ReflectEffectItem.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ReflectEffectItem: reflection effect for a ThumbItem 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include "ReflectEffectItem.h" 21 | 22 | #include 23 | #include 24 | 25 | #include "ThumbItem.h" 26 | namespace PhotoKit { 27 | 28 | ReflectEffectItem::ReflectEffectItem(ThumbItem* target, MirrorDirection direction) 29 | :QGraphicsObject(target),mBlur(true),mGradient(true),mBlurEffect(0),mTarget(target),mDirection(direction),mMirrorDistance(2),mReflect(0) 30 | { 31 | mSourceAvailable = !mTarget->isOnlineImage(); 32 | setCacheMode(QGraphicsItem::ItemCoordinateCache); //item.scroll enabled(not for gl). speed up 33 | setFlag(QGraphicsItem::ItemStacksBehindParent); 34 | 35 | connect(mTarget, SIGNAL(loadFinished()), this, SLOT(updateSourceReflect())); 36 | } 37 | 38 | ReflectEffectItem::~ReflectEffectItem() 39 | { 40 | if (mReflect) { 41 | delete mReflect; 42 | mReflect = 0; 43 | } 44 | } 45 | 46 | int ReflectEffectItem::mirrorDistance() const 47 | { 48 | return mMirrorDistance; 49 | } 50 | 51 | void ReflectEffectItem::setMirrorDistance(int distance) 52 | { 53 | mMirrorDistance = distance; 54 | } 55 | 56 | ReflectEffectItem::MirrorDirection ReflectEffectItem::mirrorDirection() const 57 | { 58 | return mDirection; 59 | } 60 | 61 | void ReflectEffectItem::setMirrorDirection(MirrorDirection direction) 62 | { 63 | mDirection = direction; 64 | } 65 | 66 | bool ReflectEffectItem::blurEnabled() const 67 | { 68 | return mBlur; 69 | } 70 | 71 | void ReflectEffectItem::enableBlur(bool enable) 72 | { 73 | mBlur = enable; 74 | } 75 | 76 | bool ReflectEffectItem::gradientEnabled() const 77 | { 78 | return mGradient; 79 | } 80 | 81 | void ReflectEffectItem::enableGradient(bool enable) 82 | { 83 | mGradient = enable; 84 | } 85 | 86 | QRectF ReflectEffectItem::boundingRect() const 87 | { 88 | if (mDirection == MirrorBottom || mDirection == MirrorTop) 89 | return QRectF(0, 0, mTarget->boundingRect().width(), 2*mTarget->boundingRect().height() + 2*mMirrorDistance); 90 | else 91 | return QRectF(0, 0, 2*mTarget->boundingRect().width() + 2*mMirrorDistance, mTarget->boundingRect().height()); 92 | } 93 | 94 | void ReflectEffectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 95 | { 96 | if (!mReflect && mSourceAvailable) { 97 | drawReflect(); 98 | } 99 | if (mReflect) 100 | painter->drawImage(mPos, *mReflect); 101 | } 102 | 103 | void ReflectEffectItem::drawReflect() 104 | { 105 | if (mReflect) { 106 | delete mReflect; 107 | mReflect = 0; 108 | } 109 | QLinearGradient g(QPointF(), QPointF(0, mTarget->contentHeight())); 110 | if (mDirection == MirrorBottom) { 111 | mReflect = new QImage(mTarget->scaledThumbImage().mirrored(false, true)); 112 | g.setColorAt(0, QColor(0, 0, 0, 100)); 113 | g.setColorAt(1, Qt::transparent); 114 | mPos.setX(mTarget->marginWidth() + mTarget->borderWidth()); 115 | mPos.setY(mTarget->boundingHeight() + mTarget->marginWidth() + mTarget->borderWidth() + 2*mMirrorDistance); 116 | } else if (mDirection == MirrorTop) { 117 | mReflect = new QImage(mTarget->scaledThumbImage().mirrored(false, true)); 118 | g.setColorAt(1, QColor(0, 0, 0, 100)); 119 | g.setColorAt(0, Qt::transparent); 120 | mPos.setX(mTarget->marginWidth() + mTarget->borderWidth()); 121 | mPos.setY(- mTarget->boundingHeight() + mTarget->marginWidth() + mTarget->borderWidth() - 2*mMirrorDistance); 122 | } else if (mDirection == MirrorLeft) { 123 | mReflect = new QImage(mTarget->scaledThumbImage().mirrored(true, false)); 124 | g.setFinalStop(QPointF(mReflect->width(), 0)); 125 | g.setColorAt(1, QColor(0, 0, 0, 100)); 126 | g.setColorAt(0, Qt::transparent); 127 | mPos.setX(-mTarget->boundingWidth() - 2*mMirrorDistance + mTarget->marginWidth() + mTarget->borderWidth()); 128 | mPos.setY(mTarget->marginWidth() + mTarget->borderWidth()); 129 | } else { 130 | mReflect = new QImage(mTarget->scaledThumbImage().mirrored(true, false)); 131 | g.setFinalStop(QPointF(mReflect->width(), 0)); 132 | g.setColorAt(1, QColor(0, 0, 0, 100)); 133 | g.setColorAt(1, Qt::transparent); 134 | mPos.setX(mTarget->boundingWidth() + 2*mMirrorDistance + mTarget->marginWidth() + mTarget->borderWidth()); 135 | mPos.setY(mTarget->marginWidth() + mTarget->borderWidth()); 136 | } 137 | if (mReflect->format() != QImage::Format_ARGB32_Premultiplied) 138 | *mReflect = mReflect->convertToFormat(QImage::Format_ARGB32_Premultiplied); //fast scaled image does not have alpha? 139 | QPainter painter(mReflect); 140 | painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); 141 | painter.fillRect(0, 0, mReflect->width(), mReflect->height(), g); 142 | 143 | if (mBlur) { 144 | if (mBlurEffect) 145 | return; 146 | mBlurEffect = new QGraphicsBlurEffect; 147 | mBlurEffect->setBlurRadius(1.3); 148 | mBlurEffect->setBlurHints(QGraphicsBlurEffect::PerformanceHint); 149 | setGraphicsEffect(mBlurEffect); 150 | } //TODO: how to remove effect? can not delete 151 | } 152 | 153 | void ReflectEffectItem::updateSourceReflect() 154 | { 155 | drawReflect(); 156 | mSourceAvailable = true; 157 | update(); 158 | } 159 | 160 | } //namespace PhotoKit 161 | 162 | -------------------------------------------------------------------------------- /src/ReflectEffectItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ReflectEffectItem: reflection effect for a ThumbItem 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_REFLECTEFFECTITEM_H 22 | #define PHOTOKIT_REFLECTEFFECTITEM_H 23 | 24 | /*! 25 | TODO: subclass of QGraphicsEffect 26 | */ 27 | #include 28 | class QGraphicsBlurEffect; 29 | namespace PhotoKit { 30 | 31 | class ThumbItem; 32 | class ReflectEffectItem : public QGraphicsObject 33 | { 34 | Q_OBJECT 35 | public: 36 | //TODO: MirrorLeft and MirrorTop 37 | /*MirrorBottom and MirrorRight can be directly installed to an item without special settings*/ 38 | enum MirrorDirection { MirrorLeft, MirrorTop, MirrorRight, MirrorBottom}; 39 | ReflectEffectItem(ThumbItem* target, MirrorDirection direction = MirrorBottom); 40 | ~ReflectEffectItem(); 41 | 42 | MirrorDirection mirrorDirection() const; 43 | void setMirrorDirection(MirrorDirection direction); 44 | 45 | int mirrorDistance() const; 46 | void setMirrorDistance(int distance); 47 | 48 | bool blurEnabled() const; 49 | void enableBlur(bool enable = true); 50 | 51 | bool gradientEnabled() const; 52 | void enableGradient(bool enable); 53 | 54 | virtual QRectF boundingRect() const; 55 | 56 | protected: 57 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option = 0, QWidget *widget = 0); 58 | void drawReflect(); //createImage 59 | 60 | protected slots: 61 | void updateSourceReflect(); 62 | 63 | private: 64 | bool mSourceAvailable; 65 | bool mBlur, mGradient; 66 | QGraphicsBlurEffect *mBlurEffect; 67 | ThumbItem *mTarget; 68 | MirrorDirection mDirection; 69 | int mMirrorDistance; 70 | QImage *mReflect; 71 | QPointF mPos; 72 | }; 73 | 74 | } //namespace PhotoKit 75 | #endif // PHOTOKIT_REFLECTEFFECTITEM_H 76 | -------------------------------------------------------------------------------- /src/ShareManager.cpp: -------------------------------------------------------------------------------- 1 | #include "ShareManager.h" 2 | 3 | ShareManager::ShareManager(QObject *parent) : 4 | QObject(parent) 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /src/ShareManager.h: -------------------------------------------------------------------------------- 1 | #ifndef SHAREMANAGER_H 2 | #define SHAREMANAGER_H 3 | 4 | #include 5 | 6 | class ShareManager : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit ShareManager(QObject *parent = 0); 11 | 12 | signals: 13 | 14 | public slots: 15 | 16 | }; 17 | 18 | #endif // SHAREMANAGER_H 19 | -------------------------------------------------------------------------------- /src/SlideDisplay.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | SlideDisplay: an item to show slide effect 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_SLIDEDISPLAY_H 22 | #define PHOTOKIT_SLIDEDISPLAY_H 23 | 24 | #include 25 | #include "ItemAnimation.h" 26 | #include 27 | #include "BaseItem.h" 28 | class NextEffect; 29 | 30 | namespace PhotoKit { 31 | class SlidePlayControl; 32 | //TODO: flip background to show information 33 | class SlideDisplay : public BaseItem 34 | { 35 | public: 36 | enum ViewMode { SingleImage, SlideImage}; 37 | SlideDisplay(QGraphicsItem *parent = 0); 38 | void setImagePath(const QString& path); 39 | QString imagePath() const; 40 | void setPlayControl(SlidePlayControl* control); 41 | SlidePlayControl* playControl() const; 42 | void setEffect(NextEffect* effect); 43 | QSize size(); 44 | 45 | virtual QRectF boundingRect() const; 46 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 47 | 48 | void smoothScale(qreal s0, qreal s, ItemAnimation::Fade fade); 49 | 50 | protected: 51 | void prepairImage(); 52 | //depends on mode 53 | virtual void keyPressEvent(QKeyEvent *event); 54 | // virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 55 | // virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 56 | // virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); //next pre 57 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); //go back to ThumbPage 58 | // virtual bool sceneEvent(QEvent *event); //touch 59 | 60 | protected: 61 | ViewMode mMode; 62 | NextEffect *mSlideEffect; 63 | SlidePlayControl *mControl; 64 | qreal mWidth, mHeight; //scaled size 65 | qreal mMaxWidth, mMaxHeight; //desktop 66 | QPointF mMousePos; 67 | QTime mMouseOnTime; 68 | QString mPath; 69 | QImage mImage; 70 | 71 | ItemAnimation *mItemAnimation; 72 | }; 73 | 74 | } //namespace PhotoKit 75 | #endif // PHOTOKIT_SLIDEDISPLAY_H 76 | -------------------------------------------------------------------------------- /src/SlidePlayControl.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | SlidePlayControl: slide effect controller 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_SLIDEPLAYCONTROL_H 22 | #define PHOTOKIT_SLIDEPLAYCONTROL_H 23 | 24 | #include 25 | #include 26 | #include "nexteffect.h" 27 | 28 | namespace PhotoKit { 29 | class SlideDisplay; 30 | class SlidePlayControl : public QObject 31 | { 32 | Q_OBJECT 33 | public: 34 | enum Direction { Forward, Backward}; 35 | explicit SlidePlayControl(QObject *parent = 0); 36 | ~SlidePlayControl(); 37 | 38 | bool isRunning() const {return running;} 39 | void setDisplay(SlideDisplay* display); //not own the display 40 | void setDirectory(const QString& dir); //add remove 41 | void setImages(const QStringList& images); 42 | void addImage(const QString& path); 43 | void setPlayOne(bool yes); //TODO: remove 44 | void setDirection(Direction d); 45 | //void setImages(const QStringList& paths); //add remove 46 | QString currentImage() const {return current_path;} 47 | void setCurrentImage(const QString& path) {current_path = path;} 48 | void setNextImage(const QString& path) {next_path = path;} 49 | 50 | void setRandomEffect(bool r) {random=r;} 51 | void setEffectType(EffectId t); 52 | 53 | public slots: 54 | void start(); 55 | void stop(); 56 | void startOne(); 57 | 58 | protected: 59 | virtual void timerEvent(QTimerEvent *); 60 | 61 | 62 | private: 63 | bool random; 64 | bool one; 65 | bool running; 66 | Direction direction; 67 | SlideDisplay *view; 68 | NextEffect *effect; 69 | int tid_effect, tid_slide; 70 | 71 | QString current_path, next_path; 72 | QStringList paths; 73 | }; 74 | 75 | } //namespace PhotoKit 76 | 77 | #endif // PHOTOKIT_SLIDEPLAYCONTROL_H 78 | -------------------------------------------------------------------------------- /src/TextEdit.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | TextEdit: QGraphicsTextItem based editor. 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "TextEdit.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "ezlog.h" 28 | 29 | namespace PhotoKit { 30 | 31 | TextEdit::TextEdit(QGraphicsItem *parent) : 32 | QGraphicsTextItem(parent),single_line(false),mEchoMode(Normal) 33 | { 34 | setTextInteractionFlags(Qt::TextEditorInteraction); 35 | document()->setDocumentMargin(8); 36 | //document()->setTextWidth(); 37 | QFont f; 38 | f.setPixelSize(22); 39 | setFont(f); 40 | 41 | //connect(document(), SIGNAL(contentsChange(int,int,int)), SLOT(storeString(int,int,int))); 42 | connect(document(), SIGNAL(contentsChanged()), SLOT(storeString())); 43 | } 44 | /* 45 | TextEdit::~TextEdit() 46 | { 47 | if (mGradient) { 48 | delete mGradient; 49 | mGradient = 0; 50 | } 51 | }*/ 52 | 53 | TextEdit::EchoMode TextEdit::echoMode() const 54 | { 55 | return mEchoMode; 56 | } 57 | 58 | void TextEdit::setEchoMode(EchoMode mode) 59 | { 60 | mEchoMode = mode; 61 | } 62 | 63 | void TextEdit::setSingleLine(bool yes) 64 | { 65 | single_line = yes; 66 | } 67 | 68 | bool TextEdit::isSingleLine() const 69 | { 70 | return single_line; 71 | } 72 | 73 | QString TextEdit::text() const 74 | { 75 | if (mEchoMode == Password) { 76 | QString stored = data(0).toString(); 77 | //set text not by setPlainText() 78 | if (!stored.isEmpty()) 79 | return stored; 80 | return toPlainText(); 81 | } 82 | return toPlainText(); 83 | } 84 | 85 | void TextEdit::resize(const QSizeF &size) 86 | { 87 | resize(size.width(), size.height()); 88 | } 89 | 90 | void TextEdit::resize(qreal width, qreal height) 91 | { 92 | mWidth = width; 93 | mHeight = height; 94 | setTextWidth(mWidth); 95 | mGradient.setStart(0, 0); 96 | mGradient.setFinalStop(mWidth, mHeight); 97 | mGradient.setColorAt(0, QColor(180, 212, 234, 148)); 98 | mGradient.setColorAt(0.618, QColor(220, 230, 240, 168)); 99 | mGradient.setColorAt(1, QColor(211, 222, 238, 180)); 100 | } 101 | 102 | QSizeF TextEdit::size() const 103 | { 104 | return QSizeF(mWidth, mHeight); 105 | } 106 | 107 | QRectF TextEdit::boundingRect() const 108 | { 109 | return QRectF(0, 0, mWidth, mHeight); 110 | } 111 | 112 | void TextEdit::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 113 | { 114 | QPen pen(Qt::gray); 115 | pen.setWidthF(2.71828); 116 | painter->setPen(pen); 117 | painter->setBrush(mGradient); 118 | painter->drawRoundedRect(boundingRect(), 8, 8); 119 | QGraphicsTextItem::paint(painter, option, widget); 120 | } 121 | 122 | //NOT PRESS. TODO: postion 123 | void TextEdit::storeString()//(int position, int charsRemoved, int charsAdded) //keyReleaseEvent(QKeyEvent *event) 124 | { 125 | //qDebug("%d %d %d", position, charsRemoved, charsAdded); 126 | if (mEchoMode == Password) { 127 | int len = toPlainText().size(); 128 | QString stored = data(0).toString(); 129 | if (stored.size() > len) 130 | stored = stored.left(len); 131 | else if (stored.size() == len) 132 | return; 133 | else 134 | stored = stored + toPlainText().right(len - stored.size()); 135 | setData(0, stored); 136 | setPlainText(QString(len, '*')); //cusor will set to begin 137 | QTextCursor cursor(textCursor()); 138 | cursor.setPosition(len); 139 | setTextCursor(cursor); //FIXME: can't move cursor! 140 | } 141 | //qDebug("string %s", qPrintable(text())); 142 | //QGraphicsTextItem::keyReleaseEvent(event); 143 | } 144 | 145 | void TextEdit::keyPressEvent(QKeyEvent *event) 146 | { 147 | if (single_line && event->key() == Qt::Key_Return) { 148 | emit submit(); 149 | event->accept(); 150 | } else { 151 | QGraphicsTextItem::keyPressEvent(event); 152 | } 153 | } 154 | 155 | 156 | /* 157 | void TextEdit::storeString(int position, int charsRemoved, int charsAdded) 158 | {qDebug("changetext"); 159 | if (mEchoMode == Password) { 160 | QString str = toPlainText(); 161 | QString stored = data(0).toString(); 162 | QString ct = str.mid(position, charsAdded); 163 | if (ct == stored.mid(position, charsAdded)) 164 | return; 165 | stored.replace(position, charsRemoved, str.mid(position, charsAdded)); 166 | setData(0, stored); 167 | setPlainText(QString(stored.length(), '*')); 168 | qDebug("%s", qPrintable(stored)); 169 | } 170 | } 171 | */ 172 | /* 173 | void TextEdit::inputMethodEvent(QInputMethodEvent *event) 174 | { 175 | //qDebug("input method: %s", qPrintable(event->commitString())); 176 | QGraphicsTextItem::inputMethodEvent(event); 177 | } 178 | */ 179 | } //namespace PhotoKit 180 | -------------------------------------------------------------------------------- /src/TextEdit.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | TextEdit: QGraphicsTextItem based editor. 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_TEXTEDIT_H 22 | #define PHOTOKIT_TEXTEDIT_H 23 | 24 | #include 25 | #include 26 | namespace PhotoKit { 27 | 28 | class TextEdit : public QGraphicsTextItem 29 | { 30 | Q_OBJECT 31 | public: 32 | enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }; 33 | explicit TextEdit(QGraphicsItem *parent = 0); 34 | //virtual ~TextEdit(); //father's non-virtual! 35 | 36 | EchoMode echoMode() const; 37 | void setEchoMode(EchoMode mode); 38 | 39 | void setSingleLine(bool yes); 40 | bool isSingleLine() const; 41 | 42 | QString text() const; //the real plain string user inputed. e.g. in Password mode, not "***" 43 | 44 | void resize(qreal width, qreal height); 45 | void resize(const QSizeF& size); 46 | QSizeF size() const; 47 | virtual QRectF boundingRect() const; 48 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 49 | signals: 50 | void submit(); //press return in single line mode 51 | private slots: 52 | void storeString();//(int position, int charsRemoved, int charsAdded); 53 | //void storeString(int position, int charsRemoved, int charsAdded); 54 | protected: 55 | virtual void keyPressEvent(QKeyEvent *event); 56 | //virtual void keyReleaseEvent(QKeyEvent *event); 57 | //virtual void inputMethodEvent(QInputMethodEvent *event); 58 | private: 59 | bool single_line; 60 | EchoMode mEchoMode; 61 | qreal mWidth, mHeight; 62 | QLinearGradient mGradient; 63 | }; 64 | 65 | } //namespace PhotoKit 66 | 67 | #endif // PHOTOKIT_TEXTEDIT_H 68 | -------------------------------------------------------------------------------- /src/ThumbItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ThumbItem: display thumbnail on the wall 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_THUMBITEM_H 22 | #define PHOTOKIT_THUMBITEM_H 23 | 24 | #include "PhotoKit_Global.h" 25 | #include 26 | #define NO_BASE 27 | class QGraphicsItemAnimation; 28 | class QNetworkReply; 29 | class QNetworkAccessManager; 30 | namespace PhotoKit { 31 | class ItemAnimation; 32 | class OutlineGlowItem; 33 | class ThumbItem : public QGraphicsObject //QGraphicsItem 34 | { 35 | Q_OBJECT 36 | public: 37 | enum ZoomAction { ZoomIn, ZoomOut}; 38 | explicit ThumbItem(QGraphicsItem *parent = 0); 39 | explicit ThumbItem(const QImage& image, QGraphicsItem *parent = 0); 40 | ~ThumbItem(); 41 | 42 | void setOnlineImage(bool online); 43 | bool isOnlineImage() const; 44 | void setThumbPath(const QString& path); 45 | void setOriginImage(const QString& path); 46 | 47 | void resize(qreal width, qreal height); 48 | void resize(const QSizeF& size); 49 | qreal borderWidth() const; 50 | qreal marginWidth() const; 51 | QImage thumbImage() const; //origin thumb 52 | QImage scaledThumbImage() const; //thumb scaled to fit item size 53 | void setThumbImage(const QImage& image); 54 | #ifdef NO_BASE 55 | virtual QRectF boundingRect() const; // overridden 56 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option = 0, QWidget *widget = 0); 57 | #else 58 | 59 | #endif //NO_BASE 60 | void showGlow(); 61 | void hideGlow(); 62 | void zoom(ZoomAction action); 63 | qreal boundingWidth() const; 64 | qreal boundingHeight() const; 65 | qreal contentWidth() const; 66 | qreal contentHeight() const; 67 | 68 | signals: 69 | void loadFinished(); 70 | 71 | protected: 72 | void prepairSize(); 73 | virtual QImage* createImage(const QMatrix &) const; 74 | 75 | virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); 76 | virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); 77 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 78 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); 79 | //virtual bool sceneEvent(QEvent *event); 80 | 81 | private slots: 82 | void updateLoadProgress(qint64 value); 83 | void loadFinish(QNetworkReply* reply); //TODO: no param 84 | 85 | private: 86 | bool mIsOnlineImage; 87 | QNetworkAccessManager *mNetwork; 88 | QString thumb_path, origin_image_path; 89 | QImage thumb; 90 | //QImage origin; 91 | OutlineGlowItem *mGlow; 92 | ItemAnimation *mItemAnimation; 93 | qreal mWidth, mHeight; //scaled thumb width, height 94 | int maxWidth; 95 | int maxHeight; 96 | //ProgressItem 97 | //TextItem *name 98 | bool adjustSize; 99 | float scale; 100 | }; 101 | 102 | } //namespace PhotoKit 103 | #endif // PHOTOKIT_THUMBITEM_H 104 | -------------------------------------------------------------------------------- /src/ThumbRecorder.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ThumbRecorder.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ThumbRecorder.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include "Config.h" 28 | 29 | 30 | namespace PhotoKit { 31 | 32 | //ThumbHash ThumbRecorder::mThumbs; 33 | //QStringList ThumbRecorder::mDisplay; 34 | ThumbRecorder* ThumbRecorder::self = 0; 35 | ThumbRecorder::ThumbRecorder(QObject *parent) 36 | :QObject(parent) 37 | { 38 | self = this; 39 | QFile f(Config::thumbRecordFile); 40 | if (!f.open(QIODevice::ReadOnly)) { 41 | qWarning("Open thumb record file error: %s", qPrintable(f.errorString())); 42 | } else {QDataStream d(&f); 43 | d >> mThumbs; 44 | } 45 | QFile f2(Config::displayedThumbRecordFile); 46 | if (!f2.open(QIODevice::ReadOnly)) { 47 | qWarning("Open thumb record file error: %s", qPrintable(f2.errorString())); 48 | } else {QDataStream d2(&f2); 49 | d2 >> mDisplay; 50 | } 51 | } 52 | 53 | ThumbRecorder* ThumbRecorder::instance() 54 | { 55 | if (!self) { 56 | new ThumbRecorder; 57 | } 58 | return self; 59 | } 60 | 61 | ThumbHash *ThumbRecorder::thumbHash() 62 | { 63 | if (!self) 64 | new ThumbRecorder; 65 | return &mThumbs; 66 | } 67 | 68 | QStringList* ThumbRecorder::displayedThumbs() 69 | { 70 | if (!self) 71 | new ThumbRecorder; 72 | return &mDisplay; 73 | } 74 | 75 | void ThumbRecorder::addDisplayedThumb(const QString &path) 76 | { 77 | if (mDisplay.contains(path)) 78 | return; 79 | mDisplay.append(path); 80 | } 81 | 82 | void ThumbRecorder::clearDisplay() 83 | { 84 | mDisplay.clear(); 85 | } 86 | 87 | void ThumbRecorder::save() 88 | { 89 | QFile f(Config::thumbRecordFile); 90 | if (!f.open(QIODevice::WriteOnly)) { 91 | qWarning("Open thumb record file error: %s", qPrintable(f.errorString())); 92 | return; 93 | } 94 | QDataStream d(&f); 95 | d << mThumbs; 96 | QFile f2(Config::displayedThumbRecordFile); 97 | if (!f2.open(QIODevice::WriteOnly)) { 98 | qWarning("Open thumb record file error: %s", qPrintable(f2.errorString())); 99 | return; 100 | } 101 | QDataStream d2(&f2); 102 | d2 << mDisplay; 103 | } 104 | 105 | } //namespace PhotoKit 106 | -------------------------------------------------------------------------------- /src/ThumbRecorder.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ThumbRecorder.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_THUMBRECORDER_H 22 | #define PHOTOKIT_THUMBRECORDER_H 23 | 24 | #include 25 | #include 26 | #include 27 | //template class QHash; //enough if static member 28 | //class QStringList; 29 | namespace PhotoKit { 30 | 31 | typedef QHash ThumbHash; 32 | 33 | class ThumbRecorder : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | static ThumbRecorder* instance(); 38 | ThumbHash* thumbHash(); 39 | QStringList* displayedThumbs(); 40 | void addDisplayedThumb(const QString& path); 41 | 42 | void clearDisplay(); 43 | public slots: 44 | void save(); 45 | private: 46 | ThumbRecorder(QObject *parent = 0); 47 | static ThumbRecorder* self; 48 | ThumbHash mThumbs; 49 | QStringList mDisplay; 50 | }; 51 | 52 | } //namespace PhotoKit 53 | #endif // PHOTOKIT_THUMBRECORDER_H 54 | -------------------------------------------------------------------------------- /src/ThumbTask.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ThumbTask.h: Thumbnail creator and recorder 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_THUMBTASK_H 22 | #define PHOTOKIT_THUMBTASK_H 23 | 24 | #include "PhotoKit_Global.h" 25 | 26 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 27 | //#include //internal namespace 28 | //#include 29 | #include //Why in Qt5 must include this? 30 | #else 31 | #include 32 | #endif //QT_VERSION_CHECK(5, 0, 0) 33 | #include 34 | 35 | namespace PhotoKit { 36 | 37 | struct ThumbInfo 38 | { 39 | QImage thumb; //OwnPtr? use thumbPath? 40 | QString path; 41 | }; 42 | 43 | class ThumbTask //Singleton? 44 | { 45 | public: 46 | ThumbTask(); 47 | ~ThumbTask(); 48 | 49 | QFutureWatcher* watcher(); 50 | void createThumbs(const QStringList& paths, bool create = true); // 51 | void createThumbsFromDirs(const QStringList& dirs, bool create = true); 52 | void createThumbsFromDirsAndPaths(const QStringList& dirs, const QStringList& paths, bool create = true); 53 | 54 | QImage thumbAt(int index); 55 | ThumbInfo thumbInfoAt(int index); 56 | 57 | void stop(); 58 | private: 59 | #ifdef QT_NO_CONCURRENT 60 | 61 | #else 62 | QFutureWatcher *mThumbsWatcher; //OwnPtr? 63 | #endif //QT_NO_CONCURRENT 64 | }; 65 | 66 | } //namespace PhotoKit 67 | 68 | #endif // PHOTOKIT_THUMBTASK_H 69 | -------------------------------------------------------------------------------- /src/ToolBar.cpp: -------------------------------------------------------------------------------- 1 | #include "ToolBar.h" 2 | #include 3 | 4 | 5 | namespace PhotoKit { 6 | 7 | ToolBar::ToolBar(QGraphicsItem * parent, Qt::WindowFlags wFlags) : 8 | QGraphicsWidget(parent, wFlags) 9 | { 10 | setFlag(QGraphicsItem::ItemIgnoresTransformations); //auto ignore transform? 11 | setFlag(QGraphicsItem::ItemIsSelectable, false); 12 | setFlag(QGraphicsItem::ItemIsMovable, false); 13 | setFlag(QGraphicsItem::ItemIsPanel); 14 | setZValue(9); //auto ignore transform 15 | //setMinimumWidth(qApp->desktop()->rect().width()); 16 | //setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 17 | } 18 | 19 | void ToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 20 | { 21 | QLinearGradient g(QPointF(), rect().bottomLeft()); 22 | g.setColorAt(0, QColor(255,255,255, 168)); 23 | g.setColorAt(1, QColor(33,33,33, 168)); 24 | g.setColorAt(0.5, QColor(22,22,22, 168)); 25 | painter->fillRect(rect(), g); 26 | } 27 | 28 | 29 | QVariant ToolBar::itemChange(GraphicsItemChange change, const QVariant &value) 30 | { 31 | if (change == QGraphicsItem::ItemPositionHasChanged) { 32 | qDebug("pos change: (%f, %f)", value.toPointF().x(), value.toPointF().y()); 33 | } else if (change == QGraphicsItem::ItemPositionChange) { 34 | qDebug("pos changed: (%f, %f)", value.toPointF().x(), value.toPointF().y()); 35 | } 36 | return value; 37 | } 38 | 39 | } //namespace PhotoKit 40 | -------------------------------------------------------------------------------- /src/ToolBar.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOLBAR_H 2 | #define TOOLBAR_H 3 | 4 | #include 5 | 6 | namespace PhotoKit { 7 | 8 | class ToolBar : public QGraphicsWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | //enum direction 13 | explicit ToolBar(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); 14 | 15 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 16 | signals: 17 | 18 | public slots: 19 | 20 | protected: 21 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); 22 | 23 | }; 24 | 25 | } //namespace PhotoKit 26 | #endif // TOOLBAR_H 27 | -------------------------------------------------------------------------------- /src/TransformMachine.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | TransformMachine: transform and other value sequence generator 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #ifndef PHOTOKIT_TRANSFORMMACHINE_H 21 | #define PHOTOKIT_TRANSFORMMACHINE_H 22 | /*! 23 | TODO: custome variables. valueAt(qreal step, const QString& key); 24 | */ 25 | 26 | #include 27 | 28 | class QTransform; 29 | class QPointF; 30 | class QTimeLine; 31 | 32 | template struct QPair; 33 | 34 | namespace PhotoKit { 35 | 36 | class TransformMachinePrivate; 37 | class TransformMachine : public QObject 38 | { 39 | Q_OBJECT 40 | public: 41 | TransformMachine(QObject *parent = 0); 42 | virtual ~TransformMachine(); 43 | 44 | QTimeLine *timeLine() const; 45 | void setTimeLine(QTimeLine *timeLine); 46 | //TODO: value animation 47 | /* 48 | qreal valueAt(qreal step, const QString& key) const; 49 | QList > valueList(const QString& key) const; 50 | void setValueAt(qreal step, qreal value, const QString& key); 51 | */ 52 | void setStartPos(const QPointF& pos); 53 | QPointF posAt(qreal step) const; 54 | QList > posList() const; 55 | void setPosAt(qreal step, const QPointF &pos); 56 | 57 | QTransform transformAt(qreal step) const; 58 | void setStartTransform(const QTransform& m); 59 | 60 | qreal xRotationAt(qreal step) const; 61 | QList > xRotationList() const; 62 | void setXRotationAt(qreal step, qreal angle); 63 | 64 | qreal yRotationAt(qreal step) const; 65 | QList > yRotationList() const; 66 | void setYRotationAt(qreal step, qreal angle); 67 | 68 | qreal zRotationAt(qreal step) const; 69 | QList > zRotationList() const; 70 | void setZRotationAt(qreal step, qreal angle); 71 | 72 | void setRotationAt(qreal step, qreal xrot, qreal yrot, qreal zrot); 73 | 74 | qreal xTranslationAt(qreal step) const; 75 | qreal yTranslationAt(qreal step) const; 76 | QList > translationList() const; 77 | void setTranslationAt(qreal step, qreal dx, qreal dy); 78 | 79 | qreal verticalScaleAt(qreal step) const; 80 | qreal horizontalScaleAt(qreal step) const; 81 | QList > scaleList() const; 82 | void setScaleAt(qreal step, qreal sx, qreal sy); 83 | 84 | qreal verticalShearAt(qreal step) const; 85 | qreal horizontalShearAt(qreal step) const; 86 | QList > shearList() const; 87 | void setShearAt(qreal step, qreal sh, qreal sv); 88 | 89 | qreal zValueAt(qreal step) const; 90 | QList > zValueList() const; 91 | void setZValueAt(qreal step, qreal value); 92 | 93 | void clear(); 94 | 95 | Q_SIGNALS: 96 | void transformChanged(const QTransform& transform); 97 | void zValueChanged(qreal value); 98 | void posChanged(const QPointF& pos); 99 | //void valueChanged(const QString& key, qreal value); 100 | 101 | public Q_SLOTS: 102 | void setStep(qreal x); 103 | void reset(); 104 | 105 | protected: 106 | virtual void beforeAnimationStep(qreal step); 107 | virtual void afterAnimationStep(qreal step); 108 | 109 | private: 110 | Q_DISABLE_COPY(TransformMachine) 111 | TransformMachinePrivate *d; 112 | }; 113 | 114 | } //namespace PhotoKit 115 | 116 | #endif // PHOTOKIT_TRANSFORMMACHINE_H 117 | -------------------------------------------------------------------------------- /src/UiManager.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | UiManager: the manager 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_UIMANAGER_H 22 | #define PHOTOKIT_UIMANAGER_H 23 | 24 | #include 25 | #include "network/GoogleImageSearcher.h" 26 | #include "score.h" 27 | class QGraphicsView; 28 | class QGraphicsWidget; 29 | class QGraphicsItem; 30 | class QMenu; 31 | class QPoint; 32 | class QTransform; 33 | namespace PhotoKit { 34 | //class ToolTip; 35 | class PhotoKitView; 36 | class ThumbItem; 37 | class ThumbTask; 38 | class ToolBar; 39 | class SlideDisplay; 40 | class SlidePlayControl; 41 | class BaseItem; 42 | class Button; 43 | class Score; 44 | class TextEdit; 45 | class GoogleImageSearcher; 46 | class UiManager : public QObject 47 | { 48 | Q_OBJECT 49 | public: 50 | enum PageType { 51 | CategoryPage, ThumbPage, PlayPage, SearchPage, InfoPage, ConfigPage 52 | }; 53 | static UiManager* instance(); 54 | virtual ~UiManager(); 55 | void init(PhotoKitView *view); //call createMenus 56 | BaseItem* currentPageRootItem(); 57 | BaseItem* thumbPageRootItem(); 58 | SlideDisplay* playPageItem() {return mPlayPageRoot;} 59 | QGraphicsView *view(); 60 | bool isSliding() const; 61 | void updateFixedItems(); 62 | 63 | void showImagesFromThumb(const QString& dir, bool yes = true); 64 | void showImagesFromThumb(const QStringList& paths, bool yes = true); 65 | 66 | void gotoPage(PageType pageType, const QString& image = QString()); 67 | 68 | void tryMoveCenter(QGraphicsItem* item); 69 | 70 | static ThumbItem *lastHoverThumb; 71 | static PageType page; 72 | signals: 73 | 74 | public slots: 75 | //void transformItem(const QTransform& t); 76 | void clearThumbs(); 77 | void addImagesFromDir(); 78 | void addImages(); 79 | void startSlide(); 80 | void stopSlide(); 81 | void showCurrentImageInfo(); 82 | void shareToWeibo(); 83 | void showHelp(); 84 | void showAbout(); 85 | 86 | void updateThumbItemAt(int index); 87 | void updateDisplayedThumbList(); 88 | 89 | private slots: 90 | void clickMenuItem(); //check sender's button text 91 | void okCancelFinish(); 92 | void hideConfigMenu(); 93 | void searchGoogleImage(); 94 | void showOnlineImage(const ImageBaseInfo& image); 95 | 96 | private: 97 | explicit UiManager(QObject *parent = 0); 98 | void createMenus(); //called by init() 99 | void createLeftMenuTopInMovie(Button *item, int i, bool hideOnFinished, Movie* movieIn, Movie *movieCollapse, Movie* movieOut, Movie *movieShake = 0); 100 | void createConfigMenuMovie(Button *item, int i, Movie* movieIn, Movie* movieOut); 101 | void createOkCancelMovie(Button *item, int index, Movie* movieIn, Movie *movieOut); //index 0: from top 102 | void createBackButtonMovie(Button *item, Movie* movieIn, Movie *movieOut); 103 | void showMenu(const QString& menu); 104 | void hideMenu(const QString& menu); 105 | 106 | static UiManager *mInstance; 107 | BaseItem *mCurrentPageRoot; 108 | BaseItem *mThumbPageRoot, *mSearchPageRoot; 109 | SlideDisplay *mPlayPageRoot; 110 | SlidePlayControl *mPlayControl; 111 | ToolBar *mBottomBar; 112 | PhotoKitView *mView; 113 | ThumbTask *mThumbTask; 114 | int mThumbsCount; 115 | Score *score; 116 | 117 | Button *mOk, *mCancel; //for connecting signals and slots with dialogs 118 | Button *mBack; 119 | TextEdit *mSearchInput; 120 | GoogleImageSearcher *mGoogleSearcher; 121 | int mSearchImageIndex; 122 | }; 123 | } //namespace PhotoKit 124 | #endif // PHOTOKIT_UIMANAGER_H 125 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | main.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "ezlog.h" 27 | #include "OptionParser.h" 28 | #include "PhotoKitView.h" 29 | #include "UiManager.h" 30 | #include "tools/Tools.h" 31 | #include "Config.h" 32 | #include "ezlog.h" 33 | using namespace PhotoKit; 34 | 35 | int main(int argc, char *argv[]) 36 | { 37 | ezlog_init_default(); 38 | 39 | QApplication a(argc, argv); 40 | a.setApplicationName("PhotoKit"); 41 | a.setObjectName("wbsecg1@gmail.com"); 42 | #if QT_VERSION >= QT_VERSION_CHECK(4, 4, 0) 43 | a.setApplicationVersion("0.3.8"); 44 | #endif //QT_VERSION 45 | #ifdef CACHE_APPDIR 46 | //Config::setAppDir(QCoreApplication::applicationDirPath()); 47 | #endif //CACHE_APPDIR 48 | QDir().mkpath(Config::thumbDir); 49 | ezlog_debug("appdir: %s, thumbdir: %s", qPrintable(QCoreApplication::applicationDirPath()), qPrintable(Config::thumbDir)); 50 | OptionParser::parseCmd(argc, argv); 51 | if (Config::logToFile) { 52 | ezlog_registerAppender(file_appender); 53 | ezlog_add_logfile("/tmp/PhotoKit.ezlog", New); 54 | } 55 | QString qm("PhotoKit_" + QLocale::system().name()); 56 | QTranslator translator; 57 | translator.load(qm, ":/i18n"); 58 | a.installTranslator(&translator); 59 | qDebug("qm: %s", qPrintable(qm)); 60 | //qDebug() << QStyleFactory::keys(); //("Windows", "Motif", "CDE", "Plastique", "GTK+", "Cleanlooks") 61 | //a.setStyle(QStyleFactory::create("Cleanlooks")); 62 | /*QFile f(":/style/ui.css"); 63 | if (f.open(QIODevice::ReadOnly)) { 64 | QTextStream qss(&f); 65 | a.setStyleSheet(qss.readAll()); 66 | } else { 67 | qDebug() << "Open ui.css error:" << f.errorString(); 68 | }*/ 69 | PhotoKitView view; 70 | view.setFocus(); 71 | UiManager::instance()->init(&view); 72 | view.showFullScreen(); 73 | //view.showMaximized(); 74 | ezlog_debug("images total: %d", OptionParser::images.size()); 75 | if (OptionParser::images.isEmpty()) { 76 | ezlog_debug("add default images"); 77 | QStringList defalutimages ; 78 | QString mpath(":/images/"); //ends with '/' 79 | if (QDir(mpath).exists()) 80 | defalutimages = QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 81 | mpath = qApp->applicationDirPath() + "/images/"; //ends with '/' 82 | ezlog_debug("Adding '%s'", qPrintable(mpath)); 83 | if (QDir(mpath).exists()) { 84 | defalutimages = QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 85 | } 86 | mpath = QDir::homePath() + "/MyDocs/Pictures/"; //Meego 87 | if (QDir(mpath).exists()) 88 | defalutimages << QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 89 | mpath = qApp->applicationDirPath() + "/images/"; 90 | if (QDir(mpath).exists()) 91 | defalutimages << QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 92 | mpath = QDir::homePath() + "/MyDocs/.images/"; //Maemo5 93 | if (QDir(mpath).exists()) 94 | defalutimages << QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 95 | mpath = QDir::homePath() + "/MyDocs/DCIM/"; //Maemo5 96 | if (QDir(mpath).exists()) 97 | defalutimages << QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 98 | 99 | mpath = QDir::homePath() + "/Pictures/"; // 100 | if (QDir(mpath).exists()) 101 | defalutimages << QDir(mpath).entryList(Tools::imageNameFilters()).replaceInStrings(QRegExp("^"), mpath); 102 | 103 | UiManager::instance()->showImagesFromThumb(defalutimages, Config::useThumb); 104 | } else { 105 | UiManager::instance()->showImagesFromThumb(OptionParser::images, Config::useThumb); 106 | } 107 | ezlog_debug("PhotoKit thumbdir: %s", qPrintable(Config::thumbDir)); 108 | return a.exec(); 109 | } 110 | -------------------------------------------------------------------------------- /src/network/GoogleImageSearcher.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | GoogleImageSearcher: a wrapper for google image search api 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "GoogleImageSearcher.h" 22 | #include 23 | #include 24 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 25 | #include 26 | #endif //QT_VERSION_CHECK(5, 0, 0) 27 | #include 28 | #include 29 | #include 30 | #include "ImageProvider_p.h" 31 | 32 | namespace PhotoKit { 33 | 34 | static const QByteArray GooglerImageSeachServer("https://ajax.googleapis.com/ajax/services/search/images"); 35 | static const int PageMax(8); 36 | 37 | static QMap GIParam; 38 | 39 | class GoogleImageSearcherPrivate : public ImageProviderPrivate 40 | { 41 | public: 42 | GoogleImageSearcherPrivate():network(new QNetworkAccessManager),size(GoogleImageSearcher::MediumSize) 43 | { 44 | if (GIParam.isEmpty()) { 45 | GIParam.insert(GoogleImageSearcher::IconSize, "icon"); 46 | GIParam.insert(GoogleImageSearcher::MediumSize, "small|medium|large|xlarge"); 47 | GIParam.insert(GoogleImageSearcher::LargeSize, "xxlarge"); 48 | GIParam.insert(GoogleImageSearcher::HugeSize, "huge"); 49 | } 50 | } 51 | ~GoogleImageSearcherPrivate() { 52 | if (network) { 53 | delete network; 54 | network = 0; 55 | } 56 | } 57 | 58 | QNetworkAccessManager *network; 59 | GoogleImageSearcher::SizeFilter size; 60 | 61 | }; 62 | 63 | GoogleImageSearcher::GoogleImageSearcher(QObject *parent) : 64 | ImageProvider(*new GoogleImageSearcherPrivate, parent) 65 | { 66 | Q_D(GoogleImageSearcher); 67 | connect(d->network, SIGNAL(finished(QNetworkReply*)), SLOT(parseReply(QNetworkReply*))); 68 | } 69 | 70 | void GoogleImageSearcher::setSizeFilter(SizeFilter size) 71 | { 72 | Q_D(GoogleImageSearcher); 73 | d->size = size; 74 | } 75 | 76 | bool GoogleImageSearcher::canFetchMore() const 77 | { 78 | Q_D(const GoogleImageSearcher); 79 | return d->page < PageMax; 80 | } 81 | 82 | void GoogleImageSearcher::fetchMore() 83 | { 84 | if (!canFetchMore()) 85 | return; 86 | 87 | Q_D(GoogleImageSearcher); 88 | QUrl url(GooglerImageSeachServer); 89 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 90 | QUrlQuery urlqurey; 91 | urlqurey.addQueryItem("v", "1.0"); 92 | urlqurey.addQueryItem("q", QUrl::toPercentEncoding(QString(d->nameFilter).replace(' ', '+'))); //+ 93 | urlqurey.addQueryItem("imgsz", GIParam[d->size]); 94 | urlqurey.addQueryItem("start", QString::number(d->page*8)); 95 | urlqurey.addQueryItem("rsz", "8"); //rsz: 1-8, the number of results to return per page 96 | url.setQuery(urlqurey); 97 | #else 98 | url.addQueryItem("v", "1.0"); 99 | url.addQueryItem("q", QUrl::toPercentEncoding(QString(d->nameFilter).replace(' ', '+'))); //+ 100 | url.addQueryItem("imgsz", GIParam[d->size]); 101 | url.addQueryItem("start", QString::number(d->page*8)); 102 | url.addQueryItem("rsz", "8"); //rsz: 1-8, the number of results to return per page 103 | #endif //QT_VERSION_CHECK(5.0.0) 104 | 105 | QNetworkRequest request(url); 106 | request.setRawHeader("Referer", "https://github.com/wang-bin/PhotoKit"); 107 | d->network->get(request); 108 | 109 | d->page++; 110 | } 111 | 112 | void GoogleImageSearcher::reset() 113 | { 114 | Q_D(GoogleImageSearcher); 115 | d->page = 0; 116 | } 117 | 118 | void GoogleImageSearcher::parseJson(const QByteArray &json) 119 | { 120 | //qDebug("%s", json.constData()); 121 | static QRegExp w("\"width\":\\s*\"(\\d+)\","); 122 | static QRegExp h("\"height\":\\s*\"(\\d+)\","); 123 | static QRegExp tw("\"tbWidth\":\\s*\"(\\d+)\","); 124 | static QRegExp th("\"tbHeight\":\\s*\"(\\d+)\","); 125 | //[^\"] not .*, because greedy is default. or setMinimal(true). What if contains '"'? 126 | static QRegExp url("\"url\":\\s*\"([^\"]+)\","); 127 | static QRegExp turl("\"tbUrl\":\\s*\"([^\"]+)\","); 128 | //QList imgs; 129 | QList results = json.split('}'); 130 | foreach (QByteArray res, results) { 131 | if (!res.contains("GsearchResultClass")) 132 | break; 133 | QString r(res.append(',')); 134 | ImageBaseInfo img; 135 | if (w.indexIn(r, 0) != -1) 136 | img.width = w.cap(1).toInt(); 137 | else 138 | continue; 139 | if (h.indexIn(r, 0) != -1) 140 | img.height = h.cap(1).toInt(); 141 | else 142 | continue; 143 | if (tw.indexIn(r, 0) != -1) 144 | img.thumbWidth = tw.cap(1).toInt(); 145 | else 146 | continue; 147 | if (th.indexIn(r, 0) != -1) 148 | img.thumbHeight = th.cap(1).toInt(); 149 | else 150 | continue; 151 | if (url.indexIn(r, 0) != -1) 152 | img.path = url.cap(1); 153 | else 154 | continue; 155 | if (turl.indexIn(r, 0) != -1) 156 | img.thumbPath = turl.cap(1).replace("\\u003d", "="); //\u003d 157 | else 158 | continue; 159 | //qDebug("w: %d h: %d, tw: %d, th: %d", img.width, img.height, img.thumbWidth, img.thumbHeight); 160 | //qDebug("url: %s\nturl: %s", qPrintable(img.path), qPrintable(img.thumbPath)); 161 | emit imageReady(img); 162 | } 163 | } 164 | 165 | void GoogleImageSearcher::parseReply(QNetworkReply *reply) 166 | { 167 | QNetworkReply::NetworkError error = reply->error(); 168 | if (error != QNetworkReply::NoError) { 169 | qWarning("Network error: %s", qPrintable(reply->errorString())); 170 | } 171 | QByteArray data = reply->readAll(); 172 | reply->deleteLater(); 173 | 174 | parseJson(data); 175 | } 176 | 177 | } //namespace PhotoKit 178 | -------------------------------------------------------------------------------- /src/network/GoogleImageSearcher.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | GoogleImageSearcher: a wrapper for google image search api 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_GOOGLEIMAGESEARCHER_H 22 | #define PHOTOKIT_GOOGLEIMAGESEARCHER_H 23 | 24 | #include "ImageProvider.h" 25 | 26 | /*! 27 | https://developers.google.com/image-search/v1/jsondevguide 28 | */ 29 | 30 | class QNetworkReply; 31 | namespace PhotoKit { 32 | 33 | class GoogleImageSearcherPrivate; 34 | class GoogleImageSearcher : public ImageProvider 35 | { 36 | Q_OBJECT 37 | Q_DECLARE_PRIVATE(GoogleImageSearcher) 38 | public: 39 | enum SizeFilter { 40 | IconSize = 0, //imgsz=icon 41 | MediumSize, //imgsz=small|medium|large|xlarge 42 | LargeSize, //imgsz=xxlarge 43 | HugeSize //imgsz=huge 44 | }; 45 | 46 | explicit GoogleImageSearcher(QObject *parent = 0); 47 | void setSizeFilter(SizeFilter size); 48 | 49 | virtual bool canFetchMore() const; 50 | virtual void fetchMore(); 51 | 52 | void reset(); 53 | 54 | private: 55 | void parseJson(const QByteArray& json); 56 | private slots: 57 | void parseReply(QNetworkReply* reply); 58 | }; 59 | 60 | } //namespace PhotoKit 61 | #endif // PHOTOKIT_GOOGLEIMAGESEARCHER_H 62 | -------------------------------------------------------------------------------- /src/network/WeiboDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | WeiboDialog: QGraphicsItem based weibo dialog 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_WEIBOBOX_H 22 | #define PHOTOKIT_WEIBOBOX_H 23 | 24 | #include "Dialog.h" 25 | 26 | namespace PhotoKit { 27 | class WeiboDialogPrivate; 28 | class WeiboDialog : public Dialog 29 | { 30 | Q_OBJECT 31 | Q_DECLARE_PRIVATE(WeiboDialog) 32 | public: 33 | explicit WeiboDialog(QGraphicsScene *scene, QGraphicsItem *parent = 0); 34 | ~WeiboDialog(); 35 | 36 | void setUser(const QString& user); 37 | void setPassword(const QString& passwd); 38 | void setImage(const QString& path); 39 | 40 | //void showLogin(); 41 | 42 | public slots: 43 | void doError(const QString& error); 44 | //void loginOrSend(); 45 | //void cancel(); 46 | void login(); 47 | void sendWeiboWithPicture(); 48 | void loginDone(); 49 | 50 | private slots: 51 | void sendOk(); 52 | 53 | }; 54 | 55 | } //namespace PhotoKit 56 | 57 | #endif // PHOTOKIT_WEIBOBOX_H 58 | -------------------------------------------------------------------------------- /src/network/qput.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | QPut: make post easy 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include "qput.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include "ezlog.h" 31 | 32 | namespace PhotoKit { 33 | QPut::QPut(QObject *parent) 34 | :QObject(parent) 35 | { 36 | init(); 37 | } 38 | 39 | QPut::QPut(const QUrl& pUrl, QObject *parent) 40 | :QObject(parent),mUrl(pUrl) 41 | { 42 | init(); 43 | } 44 | 45 | QPut::~QPut() 46 | { 47 | } 48 | 49 | void QPut::reset() 50 | { 51 | mTextPart.clear(); 52 | mDataPart.clear(); 53 | mData.clear(); 54 | mUrl.clear(); 55 | mSuccess = false; 56 | } 57 | 58 | //body should be url encoded 59 | void QPut::addTextPart(const QByteArray &name, const QByteArray &body) 60 | { 61 | mTextPart += "--" + mBoundary + "\r\n"; //can be multiple text part? 62 | mTextPart += "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n"; 63 | mTextPart += body; 64 | mTextPart += "\r\n"; 65 | } 66 | 67 | void QPut::addDataPart(const QByteArray &mine, const QByteArray &name, const QByteArray &data, const QString& fileName) 68 | { 69 | mDataPart += "--" + mBoundary + "\r\n"; 70 | mDataPart += "Content-Disposition: form-data; name=\"" + name + "\""; 71 | if (!fileName.isEmpty()) 72 | mDataPart += "; filename=\"" + QUrl::toPercentEncoding(fileName) + "\""; 73 | mDataPart += "\r\n"; 74 | mDataPart += "Content-Type: " + mine + "\r\n"; 75 | mDataPart += "Content-Transfer-Encoding: binary\r\n"; 76 | mDataPart += "\r\n"; 77 | mDataPart += data; 78 | mDataPart += "\r\n"; 79 | } 80 | 81 | void QPut::upload() 82 | { 83 | mData = mTextPart + mDataPart; 84 | mData.append("--" + mBoundary + "--\r\n"); 85 | 86 | qDebug("form:\n%s", mData.constData()); 87 | QNetworkRequest request(mUrl); 88 | request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + mBoundary); 89 | qDebug("sending data to %s", qPrintable(mUrl.path())); 90 | QNetworkReply *reply = mNetwork->post(request, mData); 91 | connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(DoReplyError())); 92 | connect(reply, SIGNAL(finished()), this, SLOT(DoFinished())); 93 | } 94 | 95 | void QPut::post() 96 | { 97 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 98 | QByteArray data(mUrl.query(QUrl::FullyEncoded).toLatin1()); 99 | #else 100 | QByteArray data(mUrl.encodedQuery()); 101 | #endif //QT_VERSION_CHECK(5, 0, 0) 102 | QNetworkRequest request(mUrl); 103 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); 104 | request.setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(data.length())); 105 | qDebug("post data %s to %s", data.constData(), mUrl.toString().toLocal8Bit().constData()); 106 | QNetworkReply *reply = mNetwork->post(request, data); 107 | connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(DoReplyError())); 108 | connect(reply, SIGNAL(finished()), this, SLOT(DoFinished())); 109 | } 110 | 111 | void QPut::setData(const QByteArray &pData) 112 | { 113 | mData = pData; 114 | } 115 | 116 | void QPut::setUrl(const QUrl &pUrl) 117 | { 118 | mUrl = pUrl; 119 | } 120 | 121 | void QPut::DoReplyError() 122 | { 123 | QNetworkReply *reply = qobject_cast(sender()); 124 | QString err = reply->errorString(); 125 | emit fail(err); 126 | qWarning("Network error: %s", qPrintable(err)); 127 | mSuccess = false; 128 | //qApp->exit(1); 129 | } 130 | 131 | void QPut::abort() 132 | { 133 | //mNetwork->Accessible 134 | } 135 | 136 | void QPut::DoFinished() 137 | { 138 | QNetworkReply *reply = qobject_cast(sender()); 139 | QNetworkReply::NetworkError error = reply->error(); 140 | QByteArray res = reply->readAll(); 141 | mSuccess = (error == QNetworkReply::NoError); 142 | if (mSuccess) { 143 | emit ok(res); 144 | } else { 145 | emit fail(reply->errorString()); 146 | } 147 | 148 | QNetworkRequest r = reply->request(); 149 | 150 | foreach(QByteArray h, r.rawHeaderList()) 151 | qDebug("Head [%s] = %s", h.constData(), r.rawHeader(h).constData()); 152 | 153 | //qDebug("Network finished. Result: %s", res.trimmed().constData()); 154 | //reply->deleteLater(); 155 | //qApp->exit(!mSuccess); 156 | } 157 | 158 | void QPut::init() 159 | { 160 | reset(); 161 | mNetwork = new QNetworkAccessManager(this); 162 | //Form-based File Upload in HTML. http://www.ietf.org/rfc/rfc1867.txt 163 | //“boundary”是用来隔开表单中不同部分数据的。“boundary”一般随机产生, 也可以简单的用“-------------”来代替。 164 | mBoundary = "---------------------------"; 165 | mBoundary += QByteArray::number(QDateTime::currentDateTime().toTime_t()); 166 | if (mBoundary.size() > 70) 167 | mBoundary = mBoundary.left(70); 168 | } 169 | }//namespace PhotoKit 170 | -------------------------------------------------------------------------------- /src/network/qput.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | QPut: make post easy 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #ifndef PHOTOKIT_QPUT_H 21 | #define PHOTOKIT_QPUT_H 22 | 23 | #include 24 | #include 25 | class QNetworkAccessManager; 26 | 27 | namespace PhotoKit { 28 | class QPut : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | QPut(QObject* parent = 0); 33 | explicit QPut(const QUrl &pUrl, QObject* parent = 0); 34 | ~QPut(); 35 | 36 | void reset(); //call it before a new post 37 | //equals setSnapshotData(pData) then start() 38 | void addTextPart(const QByteArray& name, const QByteArray& body); 39 | void addDataPart(const QByteArray& mine, const QByteArray& name, const QByteArray& data, const QString& fileName = QString()); 40 | void upload(); 41 | void post(); 42 | 43 | void setData(const QByteArray& pData); 44 | void setUrl(const QUrl& pUrl); 45 | 46 | signals: 47 | void fail(const QString& error); 48 | void ok(const QByteArray& replyData); 49 | public slots: 50 | void abort(); 51 | private slots: 52 | void DoFinished(); 53 | void DoReplyError(); 54 | 55 | private: 56 | void init(); 57 | 58 | QNetworkAccessManager *mNetwork; 59 | QUrl mUrl; 60 | bool mSuccess; 61 | QByteArray mData; 62 | QByteArray mTextPart, mDataPart; 63 | QByteArray mBoundary; 64 | }; 65 | } //namespace PhotoKit 66 | #endif // PHOTOKIT_QPUT_H 67 | -------------------------------------------------------------------------------- /src/network/weiboapi.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | WeiboApi: login, logout and upload api 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "weiboapi.h" 22 | 23 | #include 24 | #include 25 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 26 | #include 27 | #endif //QT_VERSION_CHECK(5, 0, 0) 28 | #include 29 | #include "qput.h" 30 | 31 | namespace PhotoKit { 32 | 33 | const QString OAuthUrl = "https://api.weibo.com/oauth2/access_token"; 34 | const QString ApiHost = "https://api.weibo.com/2/"; 35 | //appkey, appsecret are weico for iOS 36 | const QString AppKey = "82966982"; 37 | const QString AppSecret = "72d4545a28a46a6f329c4f2b1e949e6a"; 38 | 39 | WeiboApi::WeiboApi(QObject *parent) 40 | :QObject(parent) 41 | { 42 | mPut = new QPut(this); 43 | //connect(mPut, SIGNAL(ok(QByteArray)), this, SIGNAL(ok())); 44 | connect(mPut, SIGNAL(fail(QString)), this, SIGNAL(error(QString))); 45 | } 46 | 47 | void WeiboApi::setUSer(const QString &user) 48 | { 49 | mUser = user; 50 | } 51 | 52 | void WeiboApi::setPassword(const QString &passwd) 53 | { 54 | mPasswd = passwd; 55 | } 56 | 57 | void WeiboApi::setAccessToken(const QByteArray &token) 58 | { 59 | mAccessToken = token; 60 | } 61 | 62 | QByteArray WeiboApi::accessToken() const 63 | { 64 | return mAccessToken; 65 | } 66 | 67 | void WeiboApi::login() 68 | { 69 | if (mUser.isEmpty() || mPasswd.isEmpty()) { 70 | qWarning("user name and password can't be empty"); 71 | return; 72 | } 73 | mPut->reset(); 74 | QUrl url(OAuthUrl); 75 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 76 | QUrlQuery urlqurey; 77 | urlqurey.addQueryItem("client_id", AppKey); 78 | urlqurey.addQueryItem("client_secret", AppSecret); 79 | urlqurey.addQueryItem("grant_type", "password"); 80 | urlqurey.addQueryItem("username", mUser); 81 | urlqurey.addQueryItem("password", mPasswd); 82 | url.setQuery(urlqurey); 83 | #else 84 | url.addQueryItem("client_id", AppKey); 85 | url.addQueryItem("client_secret", AppSecret); 86 | url.addQueryItem("grant_type", "password"); 87 | url.addQueryItem("username", mUser); 88 | url.addQueryItem("password", mPasswd); 89 | #endif //QT_VERSION_CHECK(5, 0, 0) 90 | connect(mPut, SIGNAL(ok(QByteArray)), SLOT(parseOAuth2ReplyData(QByteArray))); 91 | mPut->setUrl(url); 92 | mPut->post(); 93 | } 94 | 95 | void WeiboApi::logout() 96 | { 97 | 98 | } 99 | //仅支持JPEG、GIF、PNG格式,图片大小小于5M 100 | void WeiboApi::updateStatusWithPicture(const QString &status, const QString &fileName) 101 | { 102 | mStatus = status; 103 | mFile = fileName; 104 | if (mAccessToken.isEmpty()) { 105 | qDebug("Not login."); 106 | connect(this, SIGNAL(loginOk()), SLOT(sendStatusWithPicture())); 107 | login(); 108 | return; 109 | } 110 | sendStatusWithPicture(); 111 | } 112 | 113 | void WeiboApi::parseOAuth2ReplyData(const QByteArray &data) 114 | { 115 | //{"access_token":"2.00xxxxD","remind_in":"4652955","expires_in":4652955,"uid":"12344"} 116 | QByteArray d(data); 117 | int i = d.indexOf("access_token"); 118 | int p0 = d.indexOf(":", i) + 2; 119 | int p1 = d.indexOf("\"", p0); 120 | mAccessToken = d.mid(p0, p1 - p0); 121 | i = d.indexOf("uid"); 122 | p0 = d.indexOf(":", i) + 2; 123 | p1 = d.indexOf("\"", p0); 124 | mUid = d.mid(p0, p1 - p0); 125 | qDebug("token=%s, uid=%s", mAccessToken.constData(), mUid.constData()); 126 | 127 | disconnect(this, SLOT(parseOAuth2ReplyData(QByteArray))); 128 | emit loginOk(); 129 | } 130 | 131 | void WeiboApi::sendStatusWithPicture() 132 | { 133 | qDebug("update weibo with picture"); 134 | QString path(mFile); 135 | //TODO: gif 136 | if (!path.endsWith("jpg", Qt::CaseInsensitive) 137 | && !path.endsWith("jpeg", Qt::CaseInsensitive) 138 | && !path.endsWith("png", Qt::CaseInsensitive) 139 | && !path.endsWith("gif", Qt::CaseInsensitive)) { 140 | QImage image(path); 141 | path = QDir::tempPath() + "/weibotemp" + ".jpg"; 142 | if (!image.save(path)) { 143 | qWarning("convert image failed! %s", qPrintable(path)); 144 | return; 145 | } 146 | } 147 | QFile f(path); 148 | if (!f.open(QIODevice::ReadOnly)) { 149 | qDebug("open error: %s", qPrintable(f.errorString())); 150 | return; 151 | } 152 | QByteArray data = f.readAll(); 153 | f.close(); 154 | 155 | connect(mPut, SIGNAL(ok(QByteArray)), this, SIGNAL(sendOk())); 156 | 157 | mPut->reset(); 158 | QUrl url(ApiHost + "statuses/upload.json"); 159 | mPut->setUrl(url); 160 | mPut->addTextPart("access_token", mAccessToken); 161 | mPut->addTextPart("status", QUrl::toPercentEncoding(mStatus)); 162 | mPut->addDataPart("image/jpg", "pic", data, path); 163 | mPut->upload(); 164 | } 165 | 166 | } //namespace PhotoKit 167 | -------------------------------------------------------------------------------- /src/network/weiboapi.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | WeiboApi: login, logout and upload api 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #ifndef PHOTOKIT_WEIBOAPI_H 21 | #define PHOTOKIT_WEIBOAPI_H 22 | 23 | #include 24 | namespace PhotoKit { 25 | class QPut; 26 | class WeiboApi : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit WeiboApi(QObject *parent = 0); 31 | void setUSer(const QString& user); 32 | void setPassword(const QString& passwd); 33 | void setAccessToken(const QByteArray& token); 34 | QByteArray accessToken() const; 35 | 36 | void login(); 37 | void logout(); 38 | void updateStatusWithPicture(const QString& status, const QString& fileName); 39 | 40 | signals: 41 | void error(const QString& error); 42 | void loginOk(); 43 | void loginFail(); 44 | void sendOk(); 45 | private slots: 46 | void parseOAuth2ReplyData(const QByteArray& data); 47 | void sendStatusWithPicture(); 48 | private: 49 | QPut *mPut; 50 | QString mUser, mPasswd; 51 | QByteArray mAccessToken; 52 | QByteArray mUid; 53 | QString mStatus, mFile; 54 | }; 55 | } //namespace PhotoKit 56 | #endif // PHOTOKIT_WEIBOAPI_H 57 | -------------------------------------------------------------------------------- /src/notfinish/ButtonItem.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ButtonItem.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ButtonItem.h" 22 | 23 | ButtonItem::ButtonItem() 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /src/notfinish/ButtonItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ButtonItem.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef BUTTONITEM_H 22 | #define BUTTONITEM_H 23 | 24 | #include 25 | 26 | class ButtonItem : public QGraphicsItem 27 | { 28 | public: 29 | ButtonItem(); 30 | }; 31 | 32 | #endif // BUTTONITEM_H 33 | -------------------------------------------------------------------------------- /src/notfinish/CategoryItem.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | CategoryItem.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "CategoryItem.h" 22 | 23 | CategoryItem::CategoryItem() 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /src/notfinish/CategoryItem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | CategoryItem.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef CATEGORYITEM_H 22 | #define CATEGORYITEM_H 23 | 24 | #include 25 | 26 | class CategoryItem : public QGraphicsItem 27 | { 28 | public: 29 | CategoryItem(); 30 | }; 31 | 32 | #endif // CATEGORYITEM_H 33 | -------------------------------------------------------------------------------- /src/notfinish/ConfigWidget.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ConfigWidget.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ConfigWidget.h" 22 | 23 | ConfigWidget::ConfigWidget() 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /src/notfinish/ConfigWidget.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ConfigWidget.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef CONFIGWIDGET_H 22 | #define CONFIGWIDGET_H 23 | 24 | #include 25 | 26 | //Gui for PhotoKit::Config 27 | class ConfigWidget : public QGraphicsWidget 28 | { 29 | public: 30 | ConfigWidget(); 31 | //gl 32 | 33 | }; 34 | 35 | #endif // CONFIGWIDGET_H 36 | -------------------------------------------------------------------------------- /src/notfinish/Updater.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Updater.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "Updater.h" 22 | 23 | Updater::Updater(QObject *parent) : 24 | QObject(parent) 25 | { 26 | } 27 | -------------------------------------------------------------------------------- /src/notfinish/Updater.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Updater.h: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef UPDATER_H 22 | #define UPDATER_H 23 | 24 | #include 25 | 26 | class Updater : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit Updater(QObject *parent = 0); 31 | 32 | signals: 33 | 34 | public slots: 35 | 36 | }; 37 | 38 | #endif // UPDATER_H 39 | -------------------------------------------------------------------------------- /src/score.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) 6 | ** 7 | ** This file is part of the demonstration applications of the Qt Toolkit. 8 | ** 9 | ** $QT_BEGIN_LICENSE:LGPL$ 10 | ** Commercial Usage 11 | ** Licensees holding valid Qt Commercial licenses may use this file in 12 | ** accordance with the Qt Commercial License Agreement provided with the 13 | ** Software or, alternatively, in accordance with the terms contained in 14 | ** a written agreement between you and Nokia. 15 | ** 16 | ** GNU Lesser General Public License Usage 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser 18 | ** General Public License version 2.1 as published by the Free Software 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the 20 | ** packaging of this file. Please review the following information to 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 | ** 24 | ** In addition, as a special exception, Nokia gives you certain additional 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 | ** 28 | ** GNU General Public License Usage 29 | ** Alternatively, this file may be used under the terms of the GNU 30 | ** General Public License version 3.0 as published by the Free Software 31 | ** Foundation and appearing in the file LICENSE.GPL included in the 32 | ** packaging of this file. Please review the following information to 33 | ** ensure the GNU General Public License version 3.0 requirements will be 34 | ** met: http://www.gnu.org/copyleft/gpl.html. 35 | ** 36 | ** If you have questions regarding the use of this file, please contact 37 | ** Nokia at qt-info@nokia.com. 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #include "score.h" 43 | #include 44 | #include "Config.h" 45 | #include "BaseItem.h" 46 | #include "DemoItemAnimation.h" 47 | #include "ezlog.h" 48 | namespace PhotoKit { 49 | Score::Score() 50 | { 51 | } 52 | 53 | Score::~Score() 54 | { 55 | // NB! Deleting all movies. 56 | qDeleteAll(this->index); 57 | } 58 | 59 | void Score::prepare(Movie *movie, RUN_MODE runMode, LOCK_MODE lockMode) 60 | { 61 | if (lockMode == LOCK_ITEMS){ 62 | for (int i=0; isize(); ++i){ 63 | if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->baseAnimationItem()->isVisible()) 64 | continue; 65 | movie->at(i)->lockItem(true); 66 | movie->at(i)->prepare(); 67 | } 68 | } 69 | else if (lockMode == UNLOCK_ITEMS){ 70 | for (int i=0; isize(); ++i){ 71 | if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->baseAnimationItem()->isVisible()) 72 | continue; 73 | movie->at(i)->lockItem(false); 74 | movie->at(i)->prepare(); 75 | } 76 | } 77 | else { 78 | for (int i=0; isize(); ++i){ 79 | if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->baseAnimationItem()->isVisible()) 80 | continue; 81 | movie->at(i)->prepare(); 82 | } 83 | } 84 | } 85 | 86 | void Score::play(Movie *movie, RUN_MODE runMode) 87 | { 88 | if (runMode == NEW_ANIMATION_ONLY){ 89 | //ezlog_debug(); 90 | for (int i=0; isize(); ++i) 91 | if (movie->at(i)->notOwnerOfItem()) 92 | movie->at(i)->play(true); 93 | } 94 | else if (runMode == ONLY_IF_VISIBLE){ 95 | //ezlog_debug(); 96 | for (int i=0; isize(); ++i) 97 | if (movie->at(i)->baseAnimationItem()->isVisible()) 98 | movie->at(i)->play(runMode == FROM_START); 99 | } 100 | else { 101 | //ezlog_debug(); 102 | for (int i=0; isize(); ++i) 103 | movie->at(i)->play(runMode == FROM_START); 104 | } 105 | } 106 | 107 | void Score::playMovie(const QString &indexName, RUN_MODE runMode, LOCK_MODE lockMode) 108 | { 109 | MovieIndex::iterator movieIterator = this->index.find(indexName); 110 | if (movieIterator == this->index.end()) 111 | return; 112 | 113 | Movie *movie = *movieIterator; 114 | this->prepare(movie, runMode, lockMode); 115 | this->play(movie, runMode); 116 | } 117 | 118 | void Score::queueMovie(const QString &indexName, RUN_MODE runMode, LOCK_MODE lockMode) 119 | { 120 | MovieIndex::iterator movieIterator = this->index.find(indexName); 121 | if (movieIterator == this->index.end()){ 122 | //if (Config::verbose) 123 | // qDebug() << "Queuing movie:" << indexName << "(does not exist)"; 124 | return; 125 | } 126 | 127 | Movie *movie = *movieIterator; 128 | this->prepare(movie, runMode, lockMode); 129 | this->playList.append(PlayListMember(movie, int(runMode))); 130 | //if (Config::verbose) 131 | // qDebug() << "Queuing movie:" << indexName; 132 | } 133 | 134 | void Score::playQue() 135 | { 136 | //ezlog_debug(); 137 | int movieCount = this->playList.size(); 138 | for (int i=0; iplay(this->playList.at(i).movie, RUN_MODE(this->playList.at(i).runMode)); 140 | this->playList.clear(); 141 | /* 142 | if (Config::verbose) 143 | qDebug() << "********* Playing que *********";*/ 144 | } 145 | 146 | void Score::insertMovie(const QString &indexName, Movie *movie) 147 | { 148 | this->index.insert(indexName, movie); 149 | } 150 | 151 | Movie *Score::insertMovie(const QString &indexName) 152 | { 153 | Movie *movie = new Movie(); 154 | insertMovie(indexName, movie); 155 | return movie; 156 | } 157 | }//namespace PhotoKit 158 | -------------------------------------------------------------------------------- /src/score.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) 6 | ** 7 | ** This file is part of the demonstration applications of the Qt Toolkit. 8 | ** 9 | ** $QT_BEGIN_LICENSE:LGPL$ 10 | ** Commercial Usage 11 | ** Licensees holding valid Qt Commercial licenses may use this file in 12 | ** accordance with the Qt Commercial License Agreement provided with the 13 | ** Software or, alternatively, in accordance with the terms contained in 14 | ** a written agreement between you and Nokia. 15 | ** 16 | ** GNU Lesser General Public License Usage 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser 18 | ** General Public License version 2.1 as published by the Free Software 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the 20 | ** packaging of this file. Please review the following information to 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 | ** 24 | ** In addition, as a special exception, Nokia gives you certain additional 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 | ** 28 | ** GNU General Public License Usage 29 | ** Alternatively, this file may be used under the terms of the GNU 30 | ** General Public License version 3.0 as published by the Free Software 31 | ** Foundation and appearing in the file LICENSE.GPL included in the 32 | ** packaging of this file. Please review the following information to 33 | ** ensure the GNU General Public License version 3.0 requirements will be 34 | ** met: http://www.gnu.org/copyleft/gpl.html. 35 | ** 36 | ** If you have questions regarding the use of this file, please contact 37 | ** Nokia at qt-info@nokia.com. 38 | ** $QT_END_LICENSE$ 39 | ** 40 | ****************************************************************************/ 41 | 42 | #ifndef SCORE_H 43 | #define SCORE_H 44 | 45 | #include 46 | #include 47 | #include "BaseItem.h" 48 | 49 | namespace PhotoKit { 50 | class DemoItemAnimation; 51 | typedef QList Movie; 52 | typedef QHash MovieIndex; 53 | 54 | class PlayListMember 55 | { 56 | public: 57 | PlayListMember(Movie *movie, int runMode) : movie(movie), runMode(runMode){} 58 | Movie *movie; 59 | int runMode; 60 | }; 61 | typedef QList PlayList; 62 | 63 | class Score 64 | { 65 | public: 66 | enum LOCK_MODE {LOCK_ITEMS, UNLOCK_ITEMS, SKIP_LOCK}; 67 | enum RUN_MODE {FROM_CURRENT, FROM_START, NEW_ANIMATION_ONLY, ONLY_IF_VISIBLE}; 68 | 69 | Score(); 70 | virtual ~Score(); 71 | 72 | void playMovie(const QString &indexName, RUN_MODE runMode = FROM_START, LOCK_MODE lockMode = SKIP_LOCK); 73 | void insertMovie(const QString &indexName, Movie *movie); 74 | Movie *insertMovie(const QString &indexName); 75 | void queueMovie(const QString &indexName, RUN_MODE runMode = FROM_START, LOCK_MODE lockMode = SKIP_LOCK); 76 | void playQue(); 77 | bool hasQueuedMovies(){ return this->playList.size() > 0; } 78 | 79 | MovieIndex index; 80 | PlayList playList; 81 | 82 | private: 83 | void prepare(Movie *movie, RUN_MODE runMode, LOCK_MODE lockMode); 84 | void play(Movie *movie, RUN_MODE runMode); 85 | }; 86 | } //namespace PhotoKit 87 | #endif // SCORE_H 88 | 89 | -------------------------------------------------------------------------------- /src/tools/ExifReader.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ExifReader: reading the exif information using libexif 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_EXIFREADER_H 22 | #define PHOTOKIT_EXIFREADER_H 23 | 24 | #include 25 | #include 26 | namespace PhotoKit { 27 | class ExifReaderPrivate; 28 | class ExifReader 29 | { 30 | public: 31 | enum IFD { 32 | IFD_0, IFD_1, EXIF, GPS, Interoperability 33 | }; 34 | enum Tag { 35 | FNumber, ExposureTime, ExposureMode, FocalLength, Flash, ISOSpeed, MeteringMode 36 | , DateTimeOrigin, WhiteBalance, Manufacturer, Model, Software, Copyright 37 | , LatitudeRef, Latitude, LongitudeRef, Longitude, AltitudeRef, Altitude, ImageDirectionRef 38 | , ImageDirection 39 | }; 40 | typedef QMap TagInfo; 41 | ExifReader(const QString& fileName = QString()); 42 | ~ExifReader(); 43 | 44 | bool hasData() const; 45 | 46 | bool hasIFD(IFD ifd) const; 47 | bool hasIFD0() const; 48 | bool hasIFD1() const; 49 | bool hasIFDExif() const; 50 | bool hasIFDGPS() const; 51 | bool hasIFDInteroperability() const; 52 | 53 | void loadFile(const QString& fileName); 54 | //QList > 55 | TagInfo dumpAll() const; 56 | TagInfo getIFD0Brief() const; 57 | TagInfo getExifBrief() const; 58 | TagInfo getGpsBrief() const; 59 | 60 | //QString value(Tag tag) const; 61 | 62 | //IFD_0 63 | QString manufacturer() const; 64 | QString model() const; 65 | QString software() const; 66 | QString copyright() const; 67 | 68 | //IFD_EXIF 69 | QString fNumber() const; 70 | QString exposureTime() const; 71 | QString exposureMode() const; 72 | QString focalLength() const; 73 | QString flash() const; 74 | QString isoSpeed() const; 75 | QString dateTimeOrigin() const; 76 | QString meteringMode() const; 77 | QString whiteBalance() const; 78 | 79 | private: 80 | ExifReaderPrivate *d; 81 | }; 82 | 83 | } //namespace PhotoKit 84 | 85 | #endif //PHOTOKIT_EXIFREADER_H 86 | -------------------------------------------------------------------------------- /src/tools/ImageInfoDialog.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageInfoDialog: a dialog to display image information 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ImageInfoDialog.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "Dialog_p.h" 27 | #include "Button.h" 28 | namespace PhotoKit { 29 | 30 | class ImageInfoDialogPrivate : public DialogPrivate 31 | { 32 | public: 33 | friend class ImageInfoDialog; 34 | ImageInfoDialogPrivate() { 35 | text = new QGraphicsTextItem; 36 | text->setDefaultTextColor(Qt::blue); 37 | text->document()->setDocumentMargin(22); 38 | //text->document()->setPageSize(QSizeF(qApp->desktop()->width()/2, qApp->desktop()->height() - 22)); 39 | 40 | base = new Button("

" + QObject::tr("Base info") + "

", Button::RectShape); 41 | exif = new Button("

EXIF

", Button::RectShape); 42 | gps = new Button("

GPS

", Button::RectShape); 43 | base->setColor(Qt::black); 44 | exif->setColor(Qt::black); 45 | gps->setColor(Qt::black); 46 | base->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); 47 | exif->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); 48 | gps->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); 49 | base->resize(100, 33); 50 | exif->resize(88, 33); 51 | gps->resize(88, 33); 52 | base->setData(0, 0); //signal slot 53 | exif->setData(0, 1); 54 | gps->setData(0, 2); 55 | 56 | okBtn = new Button("

" + QObject::tr("Ok") + "

", Button::RoundedRectShape, buttonBar); 57 | buttonBar->resize(okBtn->boundingRect().size()); 58 | okBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); 59 | okBtn->resize(100, 33); 60 | buttonBar->resize(okBtn->boundingRect().size()); 61 | okBtn->setColor(Qt::black); 62 | } 63 | ~ImageInfoDialogPrivate() { 64 | delete okBtn; 65 | } 66 | 67 | void setupUi(ImageInfoDialog* ui) { 68 | QObject::connect(okBtn, SIGNAL(clicked()), ui, SLOT(accept())); 69 | text->setParentItem(central); 70 | base->setParentItem(titleBar); 71 | exif->setParentItem(titleBar); 72 | gps->setParentItem(titleBar); 73 | base->setPos(0, 0); 74 | exif->setPos(base->width(), 0); 75 | gps->setPos(base->width() + exif->width(), 0); 76 | width = base->width() + exif->width() + gps->width() + 22; 77 | titleBar->resize(width, base->height()); 78 | 79 | QObject::connect(base, SIGNAL(clicked()), ui, SLOT(showInfo())); 80 | QObject::connect(exif, SIGNAL(clicked()), ui, SLOT(showInfo())); 81 | QObject::connect(gps, SIGNAL(clicked()), ui, SLOT(showInfo())); 82 | } 83 | 84 | Button *okBtn; 85 | QGraphicsTextItem* text; 86 | Button *base, *exif, *gps; 87 | QString info[3]; 88 | }; 89 | 90 | ImageInfoDialog::ImageInfoDialog(QGraphicsScene *scene, QGraphicsItem *parent) : 91 | Dialog(*new ImageInfoDialogPrivate, scene, parent) 92 | { 93 | Q_D(ImageInfoDialog); 94 | d->ImageInfoDialogPrivate::setupUi(this); 95 | } 96 | 97 | ImageInfoDialog::~ImageInfoDialog() 98 | {/* 99 | if (d_ptr) { 100 | delete d_ptr; 101 | d_ptr = 0; 102 | }*/ 103 | } 104 | 105 | void ImageInfoDialog::setBaseImageInfo(const QString &text) 106 | { 107 | Q_D(ImageInfoDialog); 108 | d->info[0] = text; 109 | } 110 | 111 | void ImageInfoDialog::setExifInfo(const QString &text) 112 | { 113 | Q_D(ImageInfoDialog); 114 | d->info[1] = text; 115 | } 116 | 117 | void ImageInfoDialog::setGPSInfo(const QString &text) 118 | { 119 | Q_D(ImageInfoDialog); 120 | d->info[2] = text; 121 | } 122 | 123 | void ImageInfoDialog::showInfo() 124 | { 125 | Q_D(ImageInfoDialog); 126 | Button *b = qobject_cast(sender()); 127 | d->text->document()->setTextWidth(size().width()); 128 | d->text->setHtml(d->info[b->data(0).toInt()]); 129 | centralWidget()->resize(d->text->document()->size()); 130 | prepareGeometryChange(); 131 | resize(d->size()); 132 | } 133 | 134 | void ImageInfoDialog::showBaseInfo() 135 | { 136 | Q_D(ImageInfoDialog); 137 | d->text->document()->setTextWidth(size().width()); 138 | d->text->setHtml(d->info[0]); 139 | centralWidget()->resize(d->text->document()->size()); 140 | prepareGeometryChange(); 141 | resize(d->size()); 142 | 143 | //flipShow(); 144 | } 145 | 146 | } //namespace PhotoKit 147 | -------------------------------------------------------------------------------- /src/tools/ImageInfoDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ImageInfoDialog: a dialog to display image information 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHOTOKIT_IMAGEINFODIALOG_H 22 | #define PHOTOKIT_IMAGEINFODIALOG_H 23 | 24 | #include "Dialog.h" 25 | 26 | namespace PhotoKit { 27 | class ImageInfoDialogPrivate; 28 | class ImageInfoDialog : public Dialog 29 | { 30 | Q_OBJECT 31 | Q_DECLARE_PRIVATE(ImageInfoDialog) 32 | public: 33 | explicit ImageInfoDialog(QGraphicsScene *scene, QGraphicsItem *parent = 0); 34 | ~ImageInfoDialog(); 35 | 36 | void setBaseImageInfo(const QString& text); 37 | void setExifInfo(const QString& text); 38 | void setGPSInfo(const QString& text); 39 | 40 | void showBaseInfo(); 41 | protected: 42 | //ImageInfoDialog(ImageInfoDialogPrivate& d, QGraphicsScene *scene, QGraphicsItem *parent = 0); 43 | 44 | private slots: 45 | void showInfo(); 46 | }; 47 | 48 | } //namespace PhotoKit 49 | 50 | #endif // PHOTOKIT_IMAGEINFODIALOG_H 51 | -------------------------------------------------------------------------------- /src/tools/ToolTip.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ToolTip: tooltip to show image or text 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #include "ToolTip.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "ezlog.h" 34 | 35 | namespace PhotoKit { 36 | //TODO: add glow 37 | static int count = 0; 38 | ToolTip* ToolTip::instance = 0; 39 | bool ToolTip::isText = true; 40 | ToolTip::ToolTip(const QString& text, QGraphicsScene* scene, QGraphicsItem *parent) : 41 | QGraphicsObject(parent),mTextChanged(false),mScene(scene) 42 | { 43 | mMargin = 16; 44 | mTextItem = new QGraphicsTextItem(this); 45 | mTextItem->setDefaultTextColor(Qt::white); 46 | mTextItem->document()->setDocumentMargin(mMargin); 47 | setFlag(QGraphicsItem::ItemIgnoresTransformations); 48 | setZValue(100); 49 | mScene->addItem(this); 50 | setText(text); 51 | } 52 | 53 | ToolTip::ToolTip(const QImage& image, QGraphicsScene* scene, QGraphicsItem *parent) : 54 | QGraphicsObject(parent),mTextChanged(false),mScene(scene) 55 | { 56 | mTextItem = new QGraphicsTextItem(this); 57 | mTextItem->setDefaultTextColor(Qt::white); 58 | mTextItem->document()->setDocumentMargin(mMargin); 59 | setFlag(QGraphicsItem::ItemIgnoresTransformations); 60 | setZValue(100); 61 | mScene->addItem(this); 62 | setImage(image); 63 | } 64 | 65 | QRectF ToolTip::boundingRect() const 66 | { 67 | return QRectF(0, 0, mWidth + 2*mMargin, mHeight + 2*mMargin); 68 | } 69 | 70 | void ToolTip::setText(const QString &text) 71 | { 72 | isText = true; 73 | mTextItem->setHtml(text); 74 | mWidth = mTextItem->document()->size().width(); 75 | mHeight = mTextItem->document()->size().height(); 76 | } 77 | 78 | void ToolTip::setImage(const QImage &image) 79 | { 80 | isText = false; 81 | mImage = image; 82 | mWidth = image.width(); 83 | mHeight = image.height(); 84 | } 85 | 86 | void ToolTip::showText(const QString &text, QGraphicsScene* scene, int msshow) 87 | { 88 | if (!instance) { 89 | instance = new ToolTip(text, scene); //more then one scene? 90 | } else { 91 | instance->hide(); //count--? 92 | instance->setText(text); 93 | } 94 | int w = qApp->desktop()->width(), h = qApp->desktop()->height(); 95 | int x = (w - instance->boundingRect().width())*0.5; 96 | int y = (h - instance->boundingRect().height())*0.5; 97 | instance->setPos(x, y); 98 | instance->show(); 99 | QTimer::singleShot(msshow, instance, SLOT(done())); 100 | count++; 101 | } 102 | 103 | void ToolTip::showImage(const QImage &image, QGraphicsScene *scene, int msshow) 104 | { 105 | if (!instance) { 106 | instance = new ToolTip(image, scene); //more then one scene? 107 | } else { 108 | instance->hide(); 109 | instance->setImage(image); 110 | } 111 | 112 | int w = qApp->desktop()->width(), h = qApp->desktop()->height(); 113 | instance->setPos((w - image.width())/2, (h - image.height())/2); //TODO: random 114 | instance->show(); 115 | QTimer::singleShot(msshow, instance, SLOT(done())); 116 | count++; 117 | } 118 | 119 | void ToolTip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 120 | { 121 | if (!isText) { 122 | mTextItem->hide(); 123 | painter->drawImage(QPointF(), mImage); 124 | return; 125 | } 126 | Q_UNUSED(option); 127 | Q_UNUSED(widget); 128 | painter->setPen(Qt::NoPen); 129 | painter->setBrush(QColor(44, 44, 44, 234)); 130 | painter->setClipRect(boundingRect()); 131 | painter->drawRoundedRect(boundingRect(), 12, 12, Qt::AbsoluteSize); 132 | mTextItem->show(); 133 | } 134 | 135 | void ToolTip::mousePressEvent(QGraphicsSceneMouseEvent *event) 136 | { 137 | setVisible(false); 138 | event->accept(); 139 | } 140 | 141 | void ToolTip::done() 142 | { 143 | if (--count == 0) 144 | setVisible(false); 145 | } 146 | 147 | } //namespace PhotoKit 148 | -------------------------------------------------------------------------------- /src/tools/ToolTip.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ToolTip: tooltip to show image or text 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef TOOLTIP_H 22 | #define TOOLTIP_H 23 | 24 | #include 25 | //TODO: fadein/out 26 | namespace PhotoKit { 27 | class ToolTip : public QGraphicsObject 28 | { 29 | Q_OBJECT 30 | public: 31 | //static void showText(const QPointF& pos, const QString text, int msec); 32 | 33 | explicit ToolTip(const QString& text, QGraphicsScene* scene, QGraphicsItem *parent = 0); 34 | explicit ToolTip(const QImage& image, QGraphicsScene* scene, QGraphicsItem *parent = 0); 35 | static void showText(const QString& text, QGraphicsScene* scene, int msshow = 8000); 36 | static void showImage(const QImage& image, QGraphicsScene* scene, int msshow = 8000); 37 | virtual QRectF boundingRect() const; 38 | 39 | void setText(const QString& text); 40 | void setImage(const QImage& image); 41 | 42 | protected: 43 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 44 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 45 | 46 | public slots: 47 | void done(); 48 | private: 49 | static bool isText; 50 | static ToolTip* instance; 51 | bool mTextChanged; 52 | QGraphicsScene *mScene; 53 | QString mText; 54 | QImage mImage; 55 | qreal mWidth, mHeight; 56 | qreal mMargin; 57 | int mTextFlag; 58 | QFont mFont; 59 | QGraphicsTextItem *mTextItem; 60 | }; 61 | 62 | } //namespace PhotoKit 63 | #endif // TOOLTIP_H 64 | -------------------------------------------------------------------------------- /src/tools/Tools.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Tools: tiny but useful tools 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include "Tools.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "ToolTip.h" 27 | #include "UiManager.h" 28 | #include "../Config.h" //"Config.h": vc or icl will fail to compile; name followed by '::' must be a class or namespace name 29 | #include "ezlog.h" 30 | 31 | namespace PhotoKit { 32 | 33 | namespace Tools { 34 | 35 | void showTip(const QString &text, bool force, int msshow) 36 | { 37 | if (Config::showTips || force) { 38 | ToolTip::showText(text, UiManager::instance()->view()->scene(), msshow); 39 | } 40 | 41 | } 42 | 43 | void showTip(const QImage &image, bool force, int msshow) 44 | { 45 | if (Config::showTips || force) { 46 | ToolTip::showImage(image, UiManager::instance()->view()->scene(), msshow); 47 | } 48 | } 49 | 50 | void showOk(int msshow) 51 | { 52 | ToolTip::showImage(QImage(":/icons/ok.png"), UiManager::instance()->view()->scene(), msshow); 53 | } 54 | 55 | void showError(int msshow) 56 | { 57 | ToolTip::showImage(QImage(":/icons/close.png"), UiManager::instance()->view()->scene(), msshow); 58 | } 59 | 60 | QStringList imageNameFilters() 61 | { 62 | static QStringList image_formats; 63 | if (image_formats.isEmpty()) { 64 | foreach(QByteArray f, QImageReader::supportedImageFormats()) { 65 | image_formats << QString("*." + f); 66 | } 67 | } 68 | return image_formats; 69 | } 70 | 71 | } 72 | 73 | 74 | } //namespace PhotoKit 75 | -------------------------------------------------------------------------------- /src/tools/Tools.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Tools: tiny but useful tools 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | 21 | #ifndef PHTOKIT_TOOLS_H 22 | #define PHTOKIT_TOOLS_H 23 | 24 | class QString; 25 | class QStringList; 26 | class QImage; 27 | namespace PhotoKit { 28 | 29 | namespace Tools { 30 | 31 | //TODO: remove force param 32 | void showTip(const QString& text, bool force = false, int msshow = 8000); 33 | void showTip(const QImage &image, bool force = false, int msshow = 8000); 34 | void showOk(int msshow = 8000); 35 | void showError(int msshow = 8000); 36 | 37 | QStringList imageNameFilters(); 38 | 39 | } //namespace Tools 40 | 41 | } //namespace PhotoKit 42 | 43 | 44 | #endif // PHTOKIT_TOOLS_H 45 | -------------------------------------------------------------------------------- /test/test.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = tst_googleimage 3 | 4 | tst_googleimage.file = tst_googleimage.pro 5 | -------------------------------------------------------------------------------- /test/tst_googleimage.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | tst_googleimage.cpp: description 3 | Copyright (C) 2012 Wang Bin 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | ******************************************************************************/ 19 | 20 | #include 21 | #include "network/GoogleImageSearcher.h" 22 | 23 | using namespace PhotoKit; 24 | 25 | int main(int argc, char** argv) 26 | { 27 | QCoreApplication app(argc, argv); 28 | GoogleImageSearcher gi; 29 | gi.setNameFilter("Hello Kitty"); 30 | while (gi.canFetchMore()) 31 | gi.fetchMore(); 32 | qDebug("google image search request end"); //async so this may print first 33 | return app.exec(); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /test/tst_googleimage.pro: -------------------------------------------------------------------------------- 1 | QT += network 2 | #QT -= gui 3 | 4 | TARGET = tst_googleimage 5 | PROJECTROOT=$$PWD/.. 6 | isEmpty(BUILD_DIR):BUILD_DIR=$$(BUILD_DIR) 7 | isEmpty(BUILD_DIR):BUILD_DIR=$$[BUILD_DIR] 8 | isEmpty(BUILD_DIR):BUILD_IN_SRC = yes 9 | !isEmpty(BUILD_IN_SRC):BUILD_DIR=$$OUT_PWD/../out 10 | include($$PROJECTROOT/common.pri) 11 | #DESTDIR = $$PWD 12 | 13 | SRCPATH = $$PROJECTROOT/src 14 | INCLUDEPATH += $$SRCPATH 15 | 16 | SOURCES = $$SRCPATH/ImageProvider.cpp \ 17 | $$SRCPATH/network/GoogleImageSearcher.cpp \ 18 | tst_googleimage.cpp 19 | 20 | HEADERS = $$SRCPATH/ImageProvider.h \ 21 | $$SRCPATH/ImageProvider_p.h \ 22 | $$SRCPATH/network/GoogleImageSearcher.h 23 | --------------------------------------------------------------------------------